Skip to content

Commit

Permalink
fix: tally flow incorporating expiration
Browse files Browse the repository at this point in the history
  • Loading branch information
hacheigriega committed Oct 25, 2024
1 parent 7e959a2 commit 8edd6cf
Showing 1 changed file with 27 additions and 27 deletions.
54 changes: 27 additions & 27 deletions x/tally/keeper/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,37 +92,37 @@ func (k Keeper) ProcessTallies(ctx sdk.Context, coreContract sdk.AccAddress) err
SedaPayload: req.SedaPayload,
}

// Check for expiration.
if len(req.Commits) < int(req.ReplicationFactor) {
var result TallyResult
switch {
case len(req.Commits) < int(req.ReplicationFactor):
k.Logger(ctx).Info("data request's number of commits did not meet replication factor", "request_id", req.ID)
dataResults[i].Result = []byte(fmt.Sprintf("need %d commits; received %d", req.ReplicationFactor, len(req.Commits)))
dataResults[i].ExitCode = 200
continue
}
if len(req.Reveals) < int(req.ReplicationFactor) {
dataResults[i].Result = []byte(fmt.Sprintf("need %d reveals; received %d", req.ReplicationFactor, len(req.Commits)))
case len(req.Reveals) < int(req.ReplicationFactor):
k.Logger(ctx).Info("data request's number of reveals did not meet replication factor", "request_id", req.ID)
dataResults[i].Result = []byte(fmt.Sprintf("need %d reveals; received %d", req.ReplicationFactor, len(req.Reveals)))
dataResults[i].ExitCode = 201
continue
}

result, err := k.FilterAndTally(ctx, req)
if err != nil {
// Return with exit code 255 to signify that the tally VM
// was not executed due to the error specified in the result
// field.
dataResults[i].ExitCode = 0xff
dataResults[i].Result = []byte(err.Error())
dataResults[i].Consensus = result.consensus
} 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].Consensus = result.consensus
default:
result, err := k.FilterAndTally(ctx, req)
if err != nil {
// Return with exit code 255 to signify that the tally VM
// was not executed due to the error specified in the result
// field.
dataResults[i].ExitCode = 0xff
dataResults[i].Result = []byte(err.Error())
dataResults[i].Consensus = result.consensus
} 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].Consensus = result.consensus
}
k.Logger(ctx).Info(
"completed tally execution",
"request_id", req.ID,
"tally_result", result,
)
}
k.Logger(ctx).Info(
"completed tally execution",
"request_id", req.ID,
"tally_result", result,
)

dataResults[i].Id, err = dataResults[i].TryHash()
if err != nil {
Expand Down

0 comments on commit 8edd6cf

Please sign in to comment.