Skip to content

Commit

Permalink
fix(x/tally): fix tally gas used tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
hacheigriega committed Jan 7, 2025
1 parent 53e7b5b commit 46ed9a5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions x/tally/keeper/endblock.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}
}

Expand Down
2 changes: 1 addition & 1 deletion x/tally/keeper/tally_vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 46ed9a5

Please sign in to comment.