Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: upgrade tally vm to v1.2.0 #361

Merged
merged 2 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ fmt:
### Linting ###
###############################################################################

golangci_version=v1.60.3
golangci_version=v1.61.0

lint-install:
@echo "--> Installing golangci-lint $(golangci_version)"
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ require (
github.com/pkg/errors v0.9.1
github.com/rakyll/statik v0.1.7
github.com/rs/zerolog v1.33.0
github.com/sedaprotocol/seda-wasm-vm/tallyvm v1.1.3
github.com/sedaprotocol/seda-wasm-vm/tallyvm v1.2.0
github.com/sedaprotocol/vrf-go v0.0.0-20231211075603-e5a17bb0b87c
github.com/spf13/cast v1.7.0
github.com/spf13/cobra v1.8.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1015,8 +1015,8 @@ github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg
github.com/seccomp/libseccomp-golang v0.9.2-0.20220502022130-f33da4d89646/go.mod h1:JA8cRccbGaA1s33RQf7Y1+q9gHmZX1yB/z9WDN1C6fg=
github.com/sedaprotocol/rosetta-seda v0.0.0-20240427181737-e1d7563b2529 h1:VbJcd022MkoohRyAfktHnN99Brt/4eJr01mdLqPhGaE=
github.com/sedaprotocol/rosetta-seda v0.0.0-20240427181737-e1d7563b2529/go.mod h1:GdlDqGJN2g55PHiwYJs2bQMlL0rdlQQbauK4dcrOI6w=
github.com/sedaprotocol/seda-wasm-vm/tallyvm v1.1.3 h1:1y88DHfjQk6MERSzU/N6csBmx0XTClyVDzw2ZAwdJxs=
github.com/sedaprotocol/seda-wasm-vm/tallyvm v1.1.3/go.mod h1:AaX9uRy6qD2q+o1SapTRnGUe9HHZWTmBN2BVNAptq3U=
github.com/sedaprotocol/seda-wasm-vm/tallyvm v1.2.0 h1:Hv7Ox1F2bhdZYDjjRGgAwXDy4/U80PolpWR8YolA2g4=
github.com/sedaprotocol/seda-wasm-vm/tallyvm v1.2.0/go.mod h1:AaX9uRy6qD2q+o1SapTRnGUe9HHZWTmBN2BVNAptq3U=
github.com/sedaprotocol/vrf-go v0.0.0-20231211075603-e5a17bb0b87c h1:PbSn7HpWeox6lqBu6Ba6YZS3On3euwn1BPz/egsnEgA=
github.com/sedaprotocol/vrf-go v0.0.0-20231211075603-e5a17bb0b87c/go.mod h1:DEIXHk41VUzOMVbZnIApssPXtZ+2zrETDP7kJjGc1RM=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
Expand Down
16 changes: 10 additions & 6 deletions x/randomness/keeper/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func (h *ProposalHandler) PrepareProposalHandler(

var maxBlockGas uint64
if b := ctx.ConsensusParams().Block; b != nil {
//nolint:gosec // G115: We should always have a gas limit for blocks.
maxBlockGas = uint64(b.MaxGas)
}

Expand Down Expand Up @@ -93,7 +94,9 @@ func (h *ProposalHandler) PrepareProposalHandler(
return nil, err
}

stop := h.txSelector.SelectTxForProposal(ctx, uint64(req.MaxTxBytes), maxBlockGas, newSeedTx, newSeedTxBz)
//nolint:gosec // G115: We should always have a bytes limit for transactions
maxTxBytes := uint64(req.MaxTxBytes)
stop := h.txSelector.SelectTxForProposal(ctx, maxTxBytes, maxBlockGas, newSeedTx, newSeedTxBz)
if stop {
return nil, types.ErrNewSeedTxNotIncluded
}
Expand All @@ -111,7 +114,7 @@ func (h *ProposalHandler) PrepareProposalHandler(
continue
}

stop := h.txSelector.SelectTxForProposal(ctx, uint64(req.MaxTxBytes), maxBlockGas, tx, txBz)
stop := h.txSelector.SelectTxForProposal(ctx, maxTxBytes, maxBlockGas, tx, txBz)
if stop {
break
}
Expand All @@ -130,9 +133,10 @@ func (h *ProposalHandler) ProcessProposalHandler(
) sdk.ProcessProposalHandler {
return func(ctx sdk.Context, req *abci.RequestProcessProposal) (*abci.ResponseProcessProposal, error) {
var totalTxGas uint64
var maxBlockGas int64
var maxBlockGas uint64
if b := ctx.ConsensusParams().Block; b != nil {
maxBlockGas = b.MaxGas
//nolint:gosec // G115: We should always have a gas limit for blocks.
maxBlockGas = uint64(b.MaxGas)
}

// process the NewSeed tx
Expand All @@ -147,7 +151,7 @@ func (h *ProposalHandler) ProcessProposalHandler(
totalTxGas += gasTx.GetGas()
}

if totalTxGas > uint64(maxBlockGas) {
if totalTxGas > maxBlockGas {
return &abci.ResponseProcessProposal{Status: abci.ResponseProcessProposal_REJECT}, err
}
}
Expand Down Expand Up @@ -216,7 +220,7 @@ func (h *ProposalHandler) ProcessProposalHandler(
totalTxGas += gasTx.GetGas()
}

if totalTxGas > uint64(maxBlockGas) {
if totalTxGas > maxBlockGas {
return &abci.ResponseProcessProposal{Status: abci.ResponseProcessProposal_REJECT}, err
}
}
Expand Down
5 changes: 3 additions & 2 deletions x/tally/keeper/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ func (k Keeper) ProcessTallies(ctx sdk.Context) error {
sudoMsg := types.Sudo{
ID: req.ID,
Result: types.DataResult{
Version: req.Version,
ID: req.ID,
Version: req.Version,
ID: req.ID,
//nolint:gosec // G115: We shouldn't get negative block heights anwyay...
BlockHeight: uint64(ctx.BlockHeight()),
GasUsed: "0", // TODO
PaybackAddress: req.PaybackAddress,
Expand Down
18 changes: 9 additions & 9 deletions x/tally/keeper/abci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func TestTallyVM(t *testing.T) {
"commits":{},
"dr_binary_id":"9471d36add157cd7eaa32a42b5ddd091d5d5d396bf9ad67938a4fc40209df6cf",
"dr_inputs":"",
"gas_limit":"20",
"gas_limit":"5000000000",
"gas_price":"10",
"height":1661661742461173125,
"id":"fba5314c57e52da7d1a2245d18c670fde1cb8c237062d2a1be83f449ace0932e",
Expand Down Expand Up @@ -72,7 +72,7 @@ func TestTallyVM(t *testing.T) {
"commits":{},
"dr_binary_id":"9471d36add157cd7eaa32a42b5ddd091d5d5d396bf9ad67938a4fc40209df6cf",
"dr_inputs":"",
"gas_limit":"20",
"gas_limit":"5000000000",
"gas_price":"10",
"height":1661661742461173125,
"id":"fba5314c57e52da7d1a2245d18c670fde1cb8c237062d2a1be83f449ace0932e",
Expand Down Expand Up @@ -113,7 +113,7 @@ func TestTallyVM(t *testing.T) {
"commits":{},
"dr_binary_id":"9471d36add157cd7eaa32a42b5ddd091d5d5d396bf9ad67938a4fc40209df6cf",
"dr_inputs":"",
"gas_limit":"20",
"gas_limit":"5000000000",
"gas_price":"10",
"height":9859593541233596221,
"id":"d4e40f45fbf529134926acf529baeb6d4f37b5c380d7ab6b934833e7c00d725f",
Expand Down Expand Up @@ -185,7 +185,7 @@ func TestTallyVM_EnvVars(t *testing.T) {
"commits":{},
"dr_binary_id":"9471d36add157cd7eaa32a42b5ddd091d5d5d396bf9ad67938a4fc40209df6cf",
"dr_inputs":"",
"gas_limit":"20",
"gas_limit":"5000000000",
"gas_price":"10",
"height":1661661742461173200,
"id":"fba5314c57e52da7d1a2245d18c670fde1cb8c237062d2a1be83f449ace0932e",
Expand Down Expand Up @@ -252,7 +252,7 @@ func TestExecuteTally(t *testing.T) {
"commits":{},
"dr_binary_id":"9471d36add157cd7eaa32a42b5ddd091d5d5d396bf9ad67938a4fc40209df6cf",
"dr_inputs":"",
"gas_limit":"20",
"gas_limit":"5000000000",
"gas_price":"10",
"height":1661661742461173125,
"id":"fba5314c57e52da7d1a2245d18c670fde1cb8c237062d2a1be83f449ace0932e",
Expand Down Expand Up @@ -289,7 +289,7 @@ func TestExecuteTally(t *testing.T) {
"commits":{},
"dr_binary_id":"9471d36add157cd7eaa32a42b5ddd091d5d5d396bf9ad67938a4fc40209df6cf",
"dr_inputs":"",
"gas_limit":"20",
"gas_limit":"5000000000",
"gas_price":"10",
"height":9859593541233596221,
"id":"d4e40f45fbf529134926acf529baeb6d4f37b5c380d7ab6b934833e7c00d725f",
Expand Down Expand Up @@ -319,7 +319,7 @@ func TestExecuteTally(t *testing.T) {
"commits":{},
"dr_binary_id":"9471d36add157cd7eaa32a42b5ddd091d5d5d396bf9ad67938a4fc40209df6cf",
"dr_inputs":"",
"gas_limit":"20",
"gas_limit":"5000000000",
"gas_price":"10",
"height":1661661742461173200,
"id":"fba5314c57e52da7d1a2245d18c670fde1cb8c237062d2a1be83f449ace0932e",
Expand Down Expand Up @@ -356,7 +356,7 @@ func TestExecuteTally(t *testing.T) {
"commits":{},
"dr_binary_id":"9471d36add157cd7eaa32a42b5ddd091d5d5d396bf9ad67938a4fc40209df6cf",
"dr_inputs":"",
"gas_limit":"20",
"gas_limit":"5000000000",
"gas_price":"10",
"height":9859593541233596000,
"id":"d4e40f45fbf529134926acf529baeb6d4f37b5c380d7ab6b934833e7c00d725f",
Expand Down Expand Up @@ -419,7 +419,7 @@ func TestEndBlock(t *testing.T) {
}{
{
name: "Invalid fetch format (gas limit)",
resp: []byte(`[{"commits":{},"dr_binary_id":"9471d36add157cd7eaa32a42b5ddd091d5d5d396bf9ad67938a4fc40209df6cf","dr_inputs":"","gas_limit":10,"gas_price":"10","height":1661661742461173200,"id":"fba5314c57e52da7d1a2245d18c670fde1cb8c237062d2a1be83f449ace0932e","memo":"","payback_address":"","consensus_filter":"A","replication_factor":3,"reveals":{"1b85dfb9420e6757630a0db2280fa1787ec8c1e419a6aca76dbbfe8ef6e17521":{"exit_code":0,"gas_used":"10","reveal":"eyJyZXN1bHQiOiB7InRleHQiOiAiQSIsICJudW1iZXIiOiAxMH19","salt":"05952214b2ba3549a8d627c57d2d0dd1b0a2ce65c46e3b2f25c273464be8ba5f"},"1dae290cd880b79d21079d89aee3460cf8a7d445fb35cade70cf8aa96924441c":{"exit_code":0,"gas_used":"10","reveal":"eyJyZXN1bHQiOiB7InRleHQiOiAiQSIsICJudW1iZXIiOiAyMH19","salt":"05952214b2ba3549a8d627c57d2d0dd1b0a2ce65c46e3b2f25c273464be8ba5f"},"421e735518ef77fc1209a9d3585cdf096669b52ea68549e2ce048d4919b4c8c0":{"exit_code":0,"gas_used":"10","reveal":"eyJyZXN1bHQiOiB7InRleHQiOiAiQiIsICJudW1iZXIiOiAxMH19","salt":"05952214b2ba3549a8d627c57d2d0dd1b0a2ce65c46e3b2f25c273464be8ba5f"}},"seda_payload":"","tally_binary_id":"8ade60039246740faa80bf424fc29e79fe13b32087043e213e7bc36620111f6b","tally_inputs":"AAEBAQE=","version":"1.0.0"},{"commits":{},"dr_binary_id":"9471d36add157cd7eaa32a42b5ddd091d5d5d396bf9ad67938a4fc40209df6cf","dr_inputs":"","gas_limit":"20","gas_price":"10","height":9859593541233596000,"id":"d4e40f45fbf529134926acf529baeb6d4f37b5c380d7ab6b934833e7c00d725f","memo":"","payback_address":"","consensus_filter":"AQAAAAAAAAALcmVzdWx0LnRleHQ=","replication_factor":1,"reveals":{"c9a4c8f1e70a0059a88b4768a920e41c95c587b8387ea3286d8fa4ee3b68b038":{"exit_code":0,"gas_used":"10","reveal":"eyJyZXN1bHQiOiB7InRleHQiOiAiQiIsICJudW1iZXIiOiAxMH19","salt":"f837455a930a66464f1c50586dc745a6b14ea807727c6069acac24c9558b6dbf"}},"seda_payload":"","tally_binary_id":"8ade60039246740faa80bf424fc29e79fe13b32087043e213e7bc36620111f6b","tally_inputs":"AAEBAQE=","version":"1.0.0"}]`),
resp: []byte(`[{"commits":{},"dr_binary_id":"9471d36add157cd7eaa32a42b5ddd091d5d5d396bf9ad67938a4fc40209df6cf","dr_inputs":"","gas_limit":10,"gas_price":"10","height":1661661742461173200,"id":"fba5314c57e52da7d1a2245d18c670fde1cb8c237062d2a1be83f449ace0932e","memo":"","payback_address":"","consensus_filter":"A","replication_factor":3,"reveals":{"1b85dfb9420e6757630a0db2280fa1787ec8c1e419a6aca76dbbfe8ef6e17521":{"exit_code":0,"gas_used":"10","reveal":"eyJyZXN1bHQiOiB7InRleHQiOiAiQSIsICJudW1iZXIiOiAxMH19","salt":"05952214b2ba3549a8d627c57d2d0dd1b0a2ce65c46e3b2f25c273464be8ba5f"},"1dae290cd880b79d21079d89aee3460cf8a7d445fb35cade70cf8aa96924441c":{"exit_code":0,"gas_used":"10","reveal":"eyJyZXN1bHQiOiB7InRleHQiOiAiQSIsICJudW1iZXIiOiAyMH19","salt":"05952214b2ba3549a8d627c57d2d0dd1b0a2ce65c46e3b2f25c273464be8ba5f"},"421e735518ef77fc1209a9d3585cdf096669b52ea68549e2ce048d4919b4c8c0":{"exit_code":0,"gas_used":"10","reveal":"eyJyZXN1bHQiOiB7InRleHQiOiAiQiIsICJudW1iZXIiOiAxMH19","salt":"05952214b2ba3549a8d627c57d2d0dd1b0a2ce65c46e3b2f25c273464be8ba5f"}},"seda_payload":"","tally_binary_id":"8ade60039246740faa80bf424fc29e79fe13b32087043e213e7bc36620111f6b","tally_inputs":"AAEBAQE=","version":"1.0.0"},{"commits":{},"dr_binary_id":"9471d36add157cd7eaa32a42b5ddd091d5d5d396bf9ad67938a4fc40209df6cf","dr_inputs":"","gas_limit":"5000000000","gas_price":"10","height":9859593541233596000,"id":"d4e40f45fbf529134926acf529baeb6d4f37b5c380d7ab6b934833e7c00d725f","memo":"","payback_address":"","consensus_filter":"AQAAAAAAAAALcmVzdWx0LnRleHQ=","replication_factor":1,"reveals":{"c9a4c8f1e70a0059a88b4768a920e41c95c587b8387ea3286d8fa4ee3b68b038":{"exit_code":0,"gas_used":"10","reveal":"eyJyZXN1bHQiOiB7InRleHQiOiAiQiIsICJudW1iZXIiOiAxMH19","salt":"f837455a930a66464f1c50586dc745a6b14ea807727c6069acac24c9558b6dbf"}},"seda_payload":"","tally_binary_id":"8ade60039246740faa80bf424fc29e79fe13b32087043e213e7bc36620111f6b","tally_inputs":"AAEBAQE=","version":"1.0.0"}]`),
expErrLog: []string{"ERR", "json: cannot unmarshal number into Go struct field Request.gas_limit of type string"},
},
}
Expand Down
1 change: 0 additions & 1 deletion x/tally/types/filters.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package types
import (
"bytes"
"encoding/binary"

"slices"

"golang.org/x/exp/constraints"
Expand Down
Loading