From 46ed9a5f5d63140268fae20c1cecc75c96c04943 Mon Sep 17 00:00:00 2001 From: hacheigriega Date: Tue, 7 Jan 2025 23:49:29 +0900 Subject: [PATCH] fix(x/tally): fix tally gas used tracking --- x/tally/keeper/endblock.go | 5 +++-- x/tally/keeper/tally_vm.go | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/x/tally/keeper/endblock.go b/x/tally/keeper/endblock.go index 08a5db9f..e8052acb 100644 --- a/x/tally/keeper/endblock.go +++ b/x/tally/keeper/endblock.go @@ -210,6 +210,7 @@ func (k Keeper) FilterAndTally(ctx sdk.Context, req types.Request) TallyResult { filterResult, err = ApplyFilter(filter, reveals) result.consensus = filterResult.Consensus result.proxyPubKeys = filterResult.ProxyPubKeys + result.tallyGasUsed += filterResult.GasUsed // Phase II: Tally Program Execution if err != nil { @@ -219,14 +220,14 @@ func (k Keeper) FilterAndTally(ctx sdk.Context, req types.Request) TallyResult { vmRes, err := k.ExecuteTallyProgram(ctx, req, filterResult, reveals) if err != nil { result.result = []byte(err.Error()) - result.exitInfo.ExitCode = TallyExitCodeFilterError + result.exitInfo.ExitCode = TallyExitCodeExecError } else { result.result = vmRes.Result result.exitInfo = vmRes.ExitInfo result.stdout = vmRes.Stdout result.stderr = vmRes.Stderr - result.tallyGasUsed = vmRes.GasUsed + filterResult.GasUsed } + result.tallyGasUsed += vmRes.GasUsed } } diff --git a/x/tally/keeper/tally_vm.go b/x/tally/keeper/tally_vm.go index 5b641b70..60bdbb24 100644 --- a/x/tally/keeper/tally_vm.go +++ b/x/tally/keeper/tally_vm.go @@ -18,7 +18,7 @@ const ( TallyExitCodeNotEnoughReveals = 201 // tally VM not executed due to not enough reveals TallyExitCodeInvalidFilterInput = 253 // tally VM not executed due to invalid filter input TallyExitCodeFilterError = 254 // tally VM not executed due to filter error - TallyExitCodeError = 255 // error while executing tally VM + TallyExitCodeExecError = 255 // error while executing tally VM ) func (k Keeper) ExecuteTallyProgram(ctx sdk.Context, req types.Request, filterResult FilterResult, reveals []types.RevealBody) (tallyvm.VmResult, error) {