From 1939f59b27d8ce548fee1f4cf4fe347070c097c8 Mon Sep 17 00:00:00 2001 From: Thomas van Dam Date: Wed, 11 Dec 2024 15:24:45 +0100 Subject: [PATCH] fix(tally): publish correct tally completion event values Turns out we were accidentally shadowing the `result` variable in the switch statement, which meant that when we assigned result after the statement we used the empty reference with default values. --- x/tally/keeper/abci.go | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/x/tally/keeper/abci.go b/x/tally/keeper/abci.go index a3331771..a2d80a97 100644 --- a/x/tally/keeper/abci.go +++ b/x/tally/keeper/abci.go @@ -93,7 +93,6 @@ func (k Keeper) ProcessTallies(ctx sdk.Context, coreContract sdk.AccAddress) err SedaPayload: req.SedaPayload, } - var result TallyResult switch { case len(req.Commits) < int(req.ReplicationFactor): dataResults[i].Result = []byte(fmt.Sprintf("need %d commits; received %d", req.ReplicationFactor, len(req.Commits))) @@ -104,20 +103,20 @@ func (k Keeper) ProcessTallies(ctx sdk.Context, coreContract sdk.AccAddress) err dataResults[i].ExitCode = batchingtypes.TallyExitCodeNotEnoughReveals k.Logger(ctx).Info("data request's number of reveals did not meet replication factor", "request_id", req.ID) default: - result, err := k.FilterAndTally(ctx, req) + tallyResults[i], err = k.FilterAndTally(ctx, req) if err != nil { dataResults[i].ExitCode = batchingtypes.TallyExitCodeFailedToExecute dataResults[i].Result = []byte(err.Error()) } else { //nolint:gosec // G115: We shouldn't get negative exit code anyway. - dataResults[i].ExitCode = uint32(result.exitInfo.ExitCode) - dataResults[i].Result = result.result + dataResults[i].ExitCode = uint32(tallyResults[i].exitInfo.ExitCode) + dataResults[i].Result = tallyResults[i].result } - dataResults[i].Consensus = result.consensus - dataResults[i].GasUsed = result.execGasUsed + result.tallyGasUsed + dataResults[i].Consensus = tallyResults[i].consensus + dataResults[i].GasUsed = tallyResults[i].execGasUsed + tallyResults[i].tallyGasUsed k.Logger(ctx).Info("completed tally execution", "request_id", req.ID) - k.Logger(ctx).Debug("tally execution result", "request_id", req.ID, "tally_result", result) + k.Logger(ctx).Debug("tally execution result", "request_id", req.ID, "tally_result", tallyResults[i]) } dataResults[i].Id, err = dataResults[i].TryHash() @@ -125,7 +124,6 @@ func (k Keeper) ProcessTallies(ctx sdk.Context, coreContract sdk.AccAddress) err return err } sudoMsgs[i] = types.SudoRemoveDataRequest{ID: req.ID} - tallyResults[i] = result } // Notify the Core Contract of tally completion.