Skip to content

Commit

Permalink
chore(tally): address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
hacheigriega committed Dec 18, 2024
1 parent f363304 commit 53cbd3d
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 5 deletions.
7 changes: 6 additions & 1 deletion x/tally/keeper/endblock.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,12 @@ func (k Keeper) FilterAndTally(ctx sdk.Context, req types.Request) (TallyResult,
if err != nil {
return result, k.logErrAndRet(ctx, err, types.ErrGettingMaxTallyGasLimit, req)
}
gasLimit := min(req.TallyGasLimit, maxGasLimit) - filterResult.GasUsed
var gasLimit uint64
if min(req.TallyGasLimit, maxGasLimit) > filterResult.GasUsed {
gasLimit = min(req.TallyGasLimit, maxGasLimit) - filterResult.GasUsed
} else {
gasLimit = 0
}

k.Logger(ctx).Info(
"executing tally VM",
Expand Down
3 changes: 2 additions & 1 deletion x/tally/keeper/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"

sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/sedaprotocol/seda-chain/x/tally/types"
)

Expand All @@ -27,7 +28,7 @@ type FilterResult struct {
// index i is an outlier, consensus boolean, consensus data proxy
// public keys, and error. It assumes that the reveals and their
// proxy public keys are sorted.
func (k Keeper) ApplyFilter(ctx sdk.Context, input []byte, reveals []types.RevealBody, replicationFactor int64) (FilterResult, error) {
func (k Keeper) ApplyFilter(ctx sdk.Context, input []byte, reveals []types.RevealBody, replicationFactor uint16) (FilterResult, error) {
var result FilterResult
result.Outliers = make([]int, len(reveals))

Expand Down
2 changes: 1 addition & 1 deletion x/tally/keeper/filter_fuzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func FuzzStdDevFilter(f *testing.F) {
filter, err := hex.DecodeString(filterHex)
require.NoError(t, err)

result, err := fixture.tallyKeeper.ApplyFilter(fixture.Context(), filter, reveals, int64(len(reveals)))
result, err := fixture.tallyKeeper.ApplyFilter(fixture.Context(), filter, reveals, uint16(len(reveals)))
require.Equal(t, expOutliers, result.Outliers)
require.ErrorIs(t, err, nil)
})
Expand Down
2 changes: 1 addition & 1 deletion x/tally/keeper/filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ func TestFilter(t *testing.T) {
sort.Strings(tt.reveals[i].ProxyPubKeys)
}

result, err := f.tallyKeeper.ApplyFilter(f.Context(), filter, tt.reveals, int64(len(tt.reveals)))
result, err := f.tallyKeeper.ApplyFilter(f.Context(), filter, tt.reveals, uint16(len(tt.reveals)))
require.ErrorIs(t, err, tt.wantErr)
if tt.consPubKeys == nil {
require.Nil(t, nil, result.ProxyPubKeys)
Expand Down
2 changes: 1 addition & 1 deletion x/tally/types/abci_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type Request struct {
GasPrice string `json:"gas_price"`
Memo string `json:"memo"`
PaybackAddress string `json:"payback_address"`
ReplicationFactor int64 `json:"replication_factor"`
ReplicationFactor uint16 `json:"replication_factor"`
ConsensusFilter string `json:"consensus_filter"`
Commits map[string][]byte `json:"commits"`
Reveals map[string]RevealBody `json:"reveals"`
Expand Down

0 comments on commit 53cbd3d

Please sign in to comment.