From 5feda1982e2d8fcaae1938d6a9ab77da193ffa93 Mon Sep 17 00:00:00 2001 From: sw360cab Date: Tue, 2 Sep 2025 16:07:09 +0200 Subject: [PATCH 1/8] dagger multimode --- .github/workflows/dagger.yaml | 6 +++++- ci/dagger/run-supernova/main.go | 31 ++++++++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dagger.yaml b/.github/workflows/dagger.yaml index 25463f8..519c5c7 100644 --- a/.github/workflows/dagger.yaml +++ b/.github/workflows/dagger.yaml @@ -9,6 +9,10 @@ jobs: supernova: name: supernova-ci runs-on: ubuntu-latest + strategy: + matrix: + env: [PACKAGE_DEPLOYMENT, REALM_DEPLOYMENT, REALM_CALL] + steps: - name: Checkout uses: actions/checkout@v5 @@ -28,4 +32,4 @@ jobs: version: ${{ steps.dagger_version.outputs.version }} verb: call module: ci/dagger/run-supernova/ - args: run-stress-test --src-dir . --chain-id ${CHAIN_ID} --rpc-endpoint ${RPC_URL} --sub-accounts 2 --transactions 10 + args: run-stress-test --src-dir . --chain-id ${CHAIN_ID} --rpc-endpoint ${RPC_URL} --mode ${{ matrix.env }} --sub-accounts 2 --transactions 100 diff --git a/ci/dagger/run-supernova/main.go b/ci/dagger/run-supernova/main.go index d39ade6..1c4f431 100644 --- a/ci/dagger/run-supernova/main.go +++ b/ci/dagger/run-supernova/main.go @@ -13,6 +13,14 @@ const ( MNEMONIC = "source bonus chronic canvas draft south burst lottery vacant surface solve popular case indicate oppose farm nothing bullet exhibit title speed wink action roast" ) +type supernovaMode string + +const ( + PACKAGE_DEPLOYMENT supernovaMode = "PACKAGE_DEPLOYMENT" + REALM_DEPLOYMENT supernovaMode = "REALM_DEPLOYMENT" + REALM_CALL supernovaMode = "REALM_CALL" +) + type Supernova struct{} // Builds Supernova image from code passed into a *dagger.Directory item @@ -51,7 +59,9 @@ func (s *Supernova) RunStressTest( subAccounts int, // +optional transactions int, - // + optional + // +default="REALM_DEPLOYMENT" + mode string, + // +optional srcDir *dagger.Directory, ) (int, error) { @@ -65,10 +75,16 @@ func (s *Supernova) RunStressTest( transactions = DEFAULT_TRANSACTIONS } + runningMode, err := toSupernovaMode(mode) + if err != nil { + return -1, err + } + return s.buildOrPull(srcDir). WithExec([]string{ "-sub-accounts", fmt.Sprintf("%d", subAccounts), "-transactions", fmt.Sprintf("%d", transactions), + "-mode", string(runningMode), "-chain-id", chainId, "-url", rpcEndpoint, "-mnemonic", MNEMONIC}, @@ -77,3 +93,16 @@ func (s *Supernova) RunStressTest( }). ExitCode(ctx) } + +func toSupernovaMode(s string) (supernovaMode, error) { + switch s { + case string(PACKAGE_DEPLOYMENT): + return PACKAGE_DEPLOYMENT, nil + case string(REALM_DEPLOYMENT): + return REALM_DEPLOYMENT, nil + case string(REALM_CALL): + return REALM_CALL, nil + default: + return "", fmt.Errorf("invalid supernova oode: %s", s) + } +} From f44f8ebf93ce0d39980f9efd2bd3038838250195 Mon Sep 17 00:00:00 2001 From: sw360cab Date: Wed, 3 Sep 2025 16:51:35 +0200 Subject: [PATCH 2/8] trying self hosted runner --- .github/workflows/dagger.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dagger.yaml b/.github/workflows/dagger.yaml index 519c5c7..2122324 100644 --- a/.github/workflows/dagger.yaml +++ b/.github/workflows/dagger.yaml @@ -8,7 +8,7 @@ on: jobs: supernova: name: supernova-ci - runs-on: ubuntu-latest + runs-on: [ self-hosted, Linux, X64, dagger ] strategy: matrix: env: [PACKAGE_DEPLOYMENT, REALM_DEPLOYMENT, REALM_CALL] From d18ec1266a539910e7487dda60686c57a01897b1 Mon Sep 17 00:00:00 2001 From: sw360cab Date: Wed, 3 Sep 2025 16:55:56 +0200 Subject: [PATCH 3/8] back to ubuntu gh runner --- .github/workflows/dagger.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/dagger.yaml b/.github/workflows/dagger.yaml index 2122324..f3267a0 100644 --- a/.github/workflows/dagger.yaml +++ b/.github/workflows/dagger.yaml @@ -8,10 +8,12 @@ on: jobs: supernova: name: supernova-ci - runs-on: [ self-hosted, Linux, X64, dagger ] + runs-on: ubuntu-latest + # runs-on: [ self-hosted, Linux, X64, dagger ] strategy: matrix: env: [PACKAGE_DEPLOYMENT, REALM_DEPLOYMENT, REALM_CALL] + max-parallel: 1 steps: - name: Checkout From 9276f08b69a492933b266d0ab1bef087553f8aef Mon Sep 17 00:00:00 2001 From: sw360cab Date: Wed, 3 Sep 2025 17:05:18 +0200 Subject: [PATCH 4/8] upgrading gnolang dep --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 59381f6..49db023 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.23.0 toolchain go1.24.1 require ( - github.com/gnolang/gno v0.0.0-20250826105341-fba926958b6b + github.com/gnolang/gno v0.0.0-20250903104743-a56a225e7cee github.com/peterbourgon/ff/v3 v3.4.0 github.com/schollz/progressbar/v3 v3.18.0 github.com/stretchr/testify v1.10.0 diff --git a/go.sum b/go.sum index 60f31ad..61a5485 100644 --- a/go.sum +++ b/go.sum @@ -76,8 +76,8 @@ github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwV github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU= github.com/getsentry/sentry-go v0.27.0 h1:Pv98CIbtB3LkMWmXi4Joa5OOcwbmnX88sF5qbK3r3Ps= github.com/getsentry/sentry-go v0.27.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY= -github.com/gnolang/gno v0.0.0-20250826105341-fba926958b6b h1:z0iw3ObgSnibeOpORPzRZjnx6v5eeSbQ35zgdoZndjE= -github.com/gnolang/gno v0.0.0-20250826105341-fba926958b6b/go.mod h1:j9wKq29meqwktEj2ReqPbSkeYUwoisfxHHVeV20lhtw= +github.com/gnolang/gno v0.0.0-20250903104743-a56a225e7cee h1:Yxb+u3eyP3pcF/EVQ8zPz1wjoz5sqWqr9FuYqjrr8YU= +github.com/gnolang/gno v0.0.0-20250903104743-a56a225e7cee/go.mod h1:j9wKq29meqwktEj2ReqPbSkeYUwoisfxHHVeV20lhtw= github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= From 93b712978b371965ed963767835fd4e5f606ed30 Mon Sep 17 00:00:00 2001 From: sw360cab Date: Wed, 3 Sep 2025 17:32:40 +0200 Subject: [PATCH 5/8] broken missing context - TO BE fixed --- internal/client/client.go | 44 +++++++++++++++-------------- internal/collector/types.go | 9 +++--- internal/distributor/distributor.go | 9 +++--- 3 files changed, 33 insertions(+), 29 deletions(-) diff --git a/internal/client/client.go b/internal/client/client.go index 1e08c70..914fad7 100644 --- a/internal/client/client.go +++ b/internal/client/client.go @@ -1,6 +1,7 @@ package client import ( + "context" "fmt" "github.com/gnolang/gno/gno.land/pkg/gnoland" @@ -49,12 +50,12 @@ func (h *Client) CreateBatch() common.Batch { return &Batch{batch: h.conn.NewBatch()} } -func (h *Client) ExecuteABCIQuery(path string, data []byte) (*core_types.ResultABCIQuery, error) { - return h.conn.ABCIQuery(path, data) +func (h *Client) ExecuteABCIQuery(ctx context.Context, path string, data []byte) (*core_types.ResultABCIQuery, error) { + return h.conn.ABCIQuery(ctx, path, data) } -func (h *Client) GetLatestBlockHeight() (int64, error) { - status, err := h.conn.Status() +func (h *Client) GetLatestBlockHeight(ctx context.Context) (int64, error) { + status, err := h.conn.Status(ctx) if err != nil { return 0, fmt.Errorf("unable to fetch status, %w", err) } @@ -62,25 +63,25 @@ func (h *Client) GetLatestBlockHeight() (int64, error) { return status.SyncInfo.LatestBlockHeight, nil } -func (h *Client) GetBlock(height *int64) (*core_types.ResultBlock, error) { - return h.conn.Block(height) +func (h *Client) GetBlock(ctx context.Context, height *int64) (*core_types.ResultBlock, error) { + return h.conn.Block(ctx, height) } -func (h *Client) GetBlockResults(height *int64) (*core_types.ResultBlockResults, error) { - return h.conn.BlockResults(height) +func (h *Client) GetBlockResults(ctx context.Context, height *int64) (*core_types.ResultBlockResults, error) { + return h.conn.BlockResults(ctx, height) } -func (h *Client) GetConsensusParams(height *int64) (*core_types.ResultConsensusParams, error) { - return h.conn.ConsensusParams(height) +func (h *Client) GetConsensusParams(ctx context.Context, height *int64) (*core_types.ResultConsensusParams, error) { + return h.conn.ConsensusParams(ctx, height) } -func (h *Client) BroadcastTransaction(tx *std.Tx) error { +func (h *Client) BroadcastTransaction(ctx context.Context, tx *std.Tx) error { marshalledTx, err := amino.Marshal(tx) if err != nil { return fmt.Errorf("unable to marshal transaction, %w", err) } - res, err := h.conn.BroadcastTxCommit(marshalledTx) + res, err := h.conn.BroadcastTxCommit(ctx, marshalledTx) if err != nil { return fmt.Errorf("unable to broadcast transaction, %w", err) } @@ -96,8 +97,9 @@ func (h *Client) BroadcastTransaction(tx *std.Tx) error { return nil } -func (h *Client) GetAccount(address string) (*gnoland.GnoAccount, error) { +func (h *Client) GetAccount(ctx context.Context, address string) (*gnoland.GnoAccount, error) { queryResult, err := h.conn.ABCIQuery( + ctx, fmt.Sprintf("auth/accounts/%s", address), []byte{}, ) @@ -117,8 +119,8 @@ func (h *Client) GetAccount(address string) (*gnoland.GnoAccount, error) { return &acc, nil } -func (h *Client) GetBlockGasUsed(height int64) (int64, error) { - blockRes, err := h.conn.BlockResults(&height) +func (h *Client) GetBlockGasUsed(ctx context.Context, height int64) (int64, error) { + blockRes, err := h.conn.BlockResults(ctx, &height) if err != nil { return 0, fmt.Errorf("unable to fetch block results, %w", err) } @@ -131,8 +133,8 @@ func (h *Client) GetBlockGasUsed(height int64) (int64, error) { return gasUsed, nil } -func (h *Client) GetBlockGasLimit(height int64) (int64, error) { - consensusParams, err := h.conn.ConsensusParams(&height) +func (h *Client) GetBlockGasLimit(ctx context.Context, height int64) (int64, error) { + consensusParams, err := h.conn.ConsensusParams(ctx, &height) if err != nil { return 0, fmt.Errorf("unable to fetch block info, %w", err) } @@ -140,7 +142,7 @@ func (h *Client) GetBlockGasLimit(height int64) (int64, error) { return consensusParams.ConsensusParams.Block.MaxGas, nil } -func (h *Client) EstimateGas(tx *std.Tx) (int64, error) { +func (h *Client) EstimateGas(ctx context.Context, tx *std.Tx) (int64, error) { // Prepare the transaction. // The transaction needs to be amino-binary encoded // in order to be estimated @@ -150,7 +152,7 @@ func (h *Client) EstimateGas(tx *std.Tx) (int64, error) { } // Perform the simulation query - resp, err := h.conn.ABCIQuery(simulatePath, encodedTx) + resp, err := h.conn.ABCIQuery(ctx, simulatePath, encodedTx) if err != nil { return 0, fmt.Errorf("unable to perform ABCI query: %w", err) } @@ -174,11 +176,11 @@ func (h *Client) EstimateGas(tx *std.Tx) (int64, error) { return deliverTx.GasUsed, nil } -func (h *Client) FetchGasPrice() (std.GasPrice, error) { +func (h *Client) FetchGasPrice(ctx context.Context) (std.GasPrice, error) { // Perform auth/gasprice gp := std.GasPrice{} - qres, err := h.conn.ABCIQuery(gaspricePath, []byte{}) + qres, err := h.conn.ABCIQuery(ctx, gaspricePath, []byte{}) if err != nil { return gp, err } diff --git a/internal/collector/types.go b/internal/collector/types.go index 642b3b5..8b95269 100644 --- a/internal/collector/types.go +++ b/internal/collector/types.go @@ -1,16 +1,17 @@ package collector import ( + "context" "time" core_types "github.com/gnolang/gno/tm2/pkg/bft/rpc/core/types" ) type Client interface { - GetBlock(height *int64) (*core_types.ResultBlock, error) - GetBlockGasUsed(height int64) (int64, error) - GetBlockGasLimit(height int64) (int64, error) - GetLatestBlockHeight() (int64, error) + GetBlock(ctx context.Context, height *int64) (*core_types.ResultBlock, error) + GetBlockGasUsed(ctx context.Context, height int64) (int64, error) + GetBlockGasLimit(ctx context.Context, height int64) (int64, error) + GetLatestBlockHeight(ctx context.Context) (int64, error) } // RunResult is the complete test-run result diff --git a/internal/distributor/distributor.go b/internal/distributor/distributor.go index c278b2f..263577d 100644 --- a/internal/distributor/distributor.go +++ b/internal/distributor/distributor.go @@ -1,6 +1,7 @@ package distributor import ( + "context" "errors" "fmt" "sort" @@ -17,10 +18,10 @@ import ( var errInsufficientFunds = errors.New("insufficient distributor funds") type Client interface { - GetAccount(address string) (*gnoland.GnoAccount, error) - BroadcastTransaction(tx *std.Tx) error - EstimateGas(tx *std.Tx) (int64, error) - FetchGasPrice() (std.GasPrice, error) + GetAccount(ctx context.Context, address string) (*gnoland.GnoAccount, error) + BroadcastTransaction(ctx context.Context, tx *std.Tx) error + EstimateGas(ctx context.Context, tx *std.Tx) (int64, error) + FetchGasPrice(ctx context.Context) (std.GasPrice, error) } // Distributor is the process From 060472541ac9181332f60a816697e4abe94dbc47 Mon Sep 17 00:00:00 2001 From: Miguel Victoria Date: Thu, 4 Sep 2025 10:24:12 +0200 Subject: [PATCH 6/8] add context everywhere --- cmd/root.go | 2 +- go.mod | 2 +- go.sum | 4 ++-- internal/batcher/batcher.go | 7 ++++-- internal/batcher/batcher_test.go | 3 ++- internal/batcher/mock_test.go | 8 ++++--- internal/batcher/types.go | 4 +++- internal/client/client.go | 3 ++- internal/collector/collector.go | 13 ++++++---- internal/collector/collector_test.go | 11 +++++---- internal/collector/mock_test.go | 30 ++++++++++++++---------- internal/distributor/distributor.go | 11 +++++---- internal/distributor/distributor_test.go | 12 ++++++---- internal/distributor/mock_test.go | 26 ++++++++++---------- internal/pipeline.go | 23 ++++++++++-------- internal/runtime/helper.go | 7 ++++-- internal/runtime/helper_test.go | 4 +++- internal/runtime/package_deployment.go | 13 +++++++--- internal/runtime/realm_call.go | 12 +++++++--- internal/runtime/realm_deployment.go | 13 +++++++--- internal/runtime/runtime.go | 12 ++++++---- internal/runtime/runtime_test.go | 13 +++++----- 22 files changed, 145 insertions(+), 88 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index 335df65..5f06e9d 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -111,5 +111,5 @@ func execMain(cfg *internal.Config) error { return fmt.Errorf("unable to create pipeline, %w", err) } - return pipeline.Execute() + return pipeline.Execute(context.Background()) } diff --git a/go.mod b/go.mod index 49db023..8335f5c 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,6 @@ go 1.23.0 toolchain go1.24.1 require ( - github.com/gnolang/gno v0.0.0-20250903104743-a56a225e7cee github.com/peterbourgon/ff/v3 v3.4.0 github.com/schollz/progressbar/v3 v3.18.0 github.com/stretchr/testify v1.10.0 @@ -30,6 +29,7 @@ require ( github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect github.com/fsnotify/fsnotify v1.5.4 // indirect github.com/getsentry/sentry-go v0.27.0 // indirect + github.com/gnolang/gno v0.0.0-20250903154725-71e9ac3593a9 // indirect github.com/go-logr/logr v1.4.2 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/gofrs/flock v0.12.1 // indirect diff --git a/go.sum b/go.sum index 61a5485..852b5fc 100644 --- a/go.sum +++ b/go.sum @@ -76,8 +76,8 @@ github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwV github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU= github.com/getsentry/sentry-go v0.27.0 h1:Pv98CIbtB3LkMWmXi4Joa5OOcwbmnX88sF5qbK3r3Ps= github.com/getsentry/sentry-go v0.27.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY= -github.com/gnolang/gno v0.0.0-20250903104743-a56a225e7cee h1:Yxb+u3eyP3pcF/EVQ8zPz1wjoz5sqWqr9FuYqjrr8YU= -github.com/gnolang/gno v0.0.0-20250903104743-a56a225e7cee/go.mod h1:j9wKq29meqwktEj2ReqPbSkeYUwoisfxHHVeV20lhtw= +github.com/gnolang/gno v0.0.0-20250903154725-71e9ac3593a9 h1:ijDZP1N5mHhedtGlIinq9IsNy3GpG3MTcw6V+s10WT8= +github.com/gnolang/gno v0.0.0-20250903154725-71e9ac3593a9/go.mod h1:j9wKq29meqwktEj2ReqPbSkeYUwoisfxHHVeV20lhtw= github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= diff --git a/internal/batcher/batcher.go b/internal/batcher/batcher.go index 018f672..4db2990 100644 --- a/internal/batcher/batcher.go +++ b/internal/batcher/batcher.go @@ -1,6 +1,7 @@ package batcher import ( + "context" "errors" "fmt" "math" @@ -16,12 +17,14 @@ import ( // to the Gno Tendermint node type Batcher struct { cli Client + ctx context.Context } // NewBatcher creates a new Batcher instance -func NewBatcher(cli Client) *Batcher { +func NewBatcher(ctx context.Context, cli Client) *Batcher { return &Batcher{ cli: cli, + ctx: ctx, } } @@ -31,7 +34,7 @@ func (b *Batcher) BatchTransactions(txs []*std.Tx, batchSize int) (*TxBatchResul fmt.Printf("\nšŸ“¦ Batching Transactions šŸ“¦\n\n") // Note the current latest block - latest, err := b.cli.GetLatestBlockHeight() + latest, err := b.cli.GetLatestBlockHeight(b.ctx) if err != nil { return nil, fmt.Errorf("unable to fetch latest block %w", err) } diff --git a/internal/batcher/batcher_test.go b/internal/batcher/batcher_test.go index e1db6ed..fb7a505 100644 --- a/internal/batcher/batcher_test.go +++ b/internal/batcher/batcher_test.go @@ -2,6 +2,7 @@ package batcher import ( "bytes" + "context" "crypto/rand" "fmt" "testing" @@ -85,7 +86,7 @@ func TestBatcher_BatchTransactions(t *testing.T) { ) // Create the batcher - b := NewBatcher(mockClient) + b := NewBatcher(context.Background(), mockClient) // Batch the transactions res, err := b.BatchTransactions(txs, batchSize) diff --git a/internal/batcher/mock_test.go b/internal/batcher/mock_test.go index e4fd6cb..47480bc 100644 --- a/internal/batcher/mock_test.go +++ b/internal/batcher/mock_test.go @@ -1,12 +1,14 @@ package batcher import ( + "context" + "github.com/gnolang/supernova/internal/common" ) type ( createBatchDelegate func() common.Batch - getLatestBlockHeightDelegate func() (int64, error) + getLatestBlockHeightDelegate func(context.Context) (int64, error) ) type mockClient struct { @@ -22,9 +24,9 @@ func (m *mockClient) CreateBatch() common.Batch { return nil } -func (m *mockClient) GetLatestBlockHeight() (int64, error) { +func (m *mockClient) GetLatestBlockHeight(ctx context.Context) (int64, error) { if m.getLatestBlockHeightFn != nil { - return m.getLatestBlockHeightFn() + return m.getLatestBlockHeightFn(ctx) } return 0, nil diff --git a/internal/batcher/types.go b/internal/batcher/types.go index 48d2473..df516a6 100644 --- a/internal/batcher/types.go +++ b/internal/batcher/types.go @@ -1,12 +1,14 @@ package batcher import ( + "context" + "github.com/gnolang/supernova/internal/common" ) type Client interface { CreateBatch() common.Batch - GetLatestBlockHeight() (int64, error) + GetLatestBlockHeight(ctx context.Context) (int64, error) } // TxBatchResult contains batching results diff --git a/internal/client/client.go b/internal/client/client.go index 914fad7..8ac57a7 100644 --- a/internal/client/client.go +++ b/internal/client/client.go @@ -55,7 +55,7 @@ func (h *Client) ExecuteABCIQuery(ctx context.Context, path string, data []byte) } func (h *Client) GetLatestBlockHeight(ctx context.Context) (int64, error) { - status, err := h.conn.Status(ctx) + status, err := h.conn.Status(ctx, nil) if err != nil { return 0, fmt.Errorf("unable to fetch status, %w", err) } @@ -143,6 +143,7 @@ func (h *Client) GetBlockGasLimit(ctx context.Context, height int64) (int64, err } func (h *Client) EstimateGas(ctx context.Context, tx *std.Tx) (int64, error) { + fmt.Println(tx.Fee) // Prepare the transaction. // The transaction needs to be amino-binary encoded // in order to be estimated diff --git a/internal/collector/collector.go b/internal/collector/collector.go index 7376592..acd1fab 100644 --- a/internal/collector/collector.go +++ b/internal/collector/collector.go @@ -1,6 +1,7 @@ package collector import ( + "context" "errors" "fmt" "time" @@ -17,15 +18,17 @@ var errTimeout = errors.New("collector timed out") // transaction indexing is introduced type Collector struct { cli Client + ctx context.Context requestTimeout time.Duration } // NewCollector creates a new instance of the collector -func NewCollector(cli Client) *Collector { +func NewCollector(ctx context.Context, cli Client) *Collector { return &Collector{ cli: cli, requestTimeout: time.Second * 2, + ctx: ctx, } } @@ -58,7 +61,7 @@ func (c *Collector) GetRunResult( case <-timeout: return nil, errTimeout case <-time.After(c.requestTimeout): - latest, err := c.cli.GetLatestBlockHeight() + latest, err := c.cli.GetLatestBlockHeight(c.ctx) if err != nil { return nil, fmt.Errorf("unable to fetch latest block height, %w", err) } @@ -71,7 +74,7 @@ func (c *Collector) GetRunResult( // Iterate over each block and find relevant transactions for blockNum := start; blockNum <= latest; blockNum++ { // Fetch the block - block, err := c.cli.GetBlock(&blockNum) + block, err := c.cli.GetBlock(c.ctx, &blockNum) if err != nil { return nil, fmt.Errorf("unable to fetch block, %w", err) } @@ -87,13 +90,13 @@ func (c *Collector) GetRunResult( _ = bar.Add(belong) //nolint:errcheck // No need to check // Fetch the total gas used by transactions - blockGasUsed, err := c.cli.GetBlockGasUsed(blockNum) + blockGasUsed, err := c.cli.GetBlockGasUsed(c.ctx, blockNum) if err != nil { return nil, fmt.Errorf("unable to fetch block gas used, %w", err) } // Fetch the block gas limit - blockGasLimit, err := c.cli.GetBlockGasLimit(blockNum) + blockGasLimit, err := c.cli.GetBlockGasLimit(c.ctx, blockNum) if err != nil { return nil, fmt.Errorf("unable to fetch block gas limit, %w", err) } diff --git a/internal/collector/collector_test.go b/internal/collector/collector_test.go index cd1970c..154c6f3 100644 --- a/internal/collector/collector_test.go +++ b/internal/collector/collector_test.go @@ -1,6 +1,7 @@ package collector import ( + "context" "crypto/rand" "testing" "time" @@ -58,7 +59,7 @@ func TestCollector_GetRunResults(t *testing.T) { gasUsed = int64(100) mockClient = &mockClient{ - getBlockFn: func(height *int64) (*core_types.ResultBlock, error) { + getBlockFn: func(ctx context.Context, height *int64) (*core_types.ResultBlock, error) { if *height > int64(numTxs) { t.Fatalf("invalid height requested") } @@ -80,17 +81,17 @@ func TestCollector_GetRunResults(t *testing.T) { }, }, nil }, - getLatestBlockHeightFn: func() (int64, error) { + getLatestBlockHeightFn: func(ctx context.Context) (int64, error) { return int64(numTxs), nil }, - getBlockGasLimitFn: func(height int64) (int64, error) { + getBlockGasLimitFn: func(ctx context.Context, height int64) (int64, error) { if height > int64(numTxs) { t.Fatalf("invalid height requested") } return gasLimit, nil }, - getBlockGasUsedFn: func(height int64) (int64, error) { + getBlockGasUsedFn: func(ctx context.Context, height int64) (int64, error) { if height > int64(numTxs) { t.Fatalf("invalid height requested") } @@ -101,7 +102,7 @@ func TestCollector_GetRunResults(t *testing.T) { ) // Create the collector - c := NewCollector(mockClient) + c := NewCollector(context.Background(), mockClient) c.requestTimeout = time.Second * 0 // Collect the results diff --git a/internal/collector/mock_test.go b/internal/collector/mock_test.go index 0a76388..b3cd6af 100644 --- a/internal/collector/mock_test.go +++ b/internal/collector/mock_test.go @@ -1,12 +1,16 @@ package collector -import core_types "github.com/gnolang/gno/tm2/pkg/bft/rpc/core/types" +import ( + "context" + + core_types "github.com/gnolang/gno/tm2/pkg/bft/rpc/core/types" +) type ( - getBlockDelegate func(height *int64) (*core_types.ResultBlock, error) - getBlockGasUsedDelegate func(height int64) (int64, error) - getBlockGasLimitDelegate func(height int64) (int64, error) - getLatestBlockHeightDelegate func() (int64, error) + getBlockDelegate func(ctx context.Context, height *int64) (*core_types.ResultBlock, error) + getBlockGasUsedDelegate func(ctx context.Context, height int64) (int64, error) + getBlockGasLimitDelegate func(ctx context.Context, height int64) (int64, error) + getLatestBlockHeightDelegate func(ctx context.Context) (int64, error) ) type mockClient struct { @@ -16,33 +20,33 @@ type mockClient struct { getLatestBlockHeightFn getLatestBlockHeightDelegate } -func (m *mockClient) GetBlock(height *int64) (*core_types.ResultBlock, error) { +func (m *mockClient) GetBlock(ctx context.Context, height *int64) (*core_types.ResultBlock, error) { if m.getBlockFn != nil { - return m.getBlockFn(height) + return m.getBlockFn(ctx, height) } return nil, nil } -func (m *mockClient) GetBlockGasUsed(height int64) (int64, error) { +func (m *mockClient) GetBlockGasUsed(ctx context.Context, height int64) (int64, error) { if m.getBlockGasUsedFn != nil { - return m.getBlockGasUsedFn(height) + return m.getBlockGasUsedFn(ctx, height) } return 0, nil } -func (m *mockClient) GetBlockGasLimit(height int64) (int64, error) { +func (m *mockClient) GetBlockGasLimit(ctx context.Context, height int64) (int64, error) { if m.getBlockGasLimitFn != nil { - return m.getBlockGasLimitFn(height) + return m.getBlockGasLimitFn(ctx, height) } return 0, nil } -func (m *mockClient) GetLatestBlockHeight() (int64, error) { +func (m *mockClient) GetLatestBlockHeight(ctx context.Context) (int64, error) { if m.getLatestBlockHeightFn != nil { - return m.getLatestBlockHeightFn() + return m.getLatestBlockHeightFn(ctx) } return 0, nil diff --git a/internal/distributor/distributor.go b/internal/distributor/distributor.go index 263577d..48a218b 100644 --- a/internal/distributor/distributor.go +++ b/internal/distributor/distributor.go @@ -28,14 +28,17 @@ type Client interface { // that manages sub-account distributions type Distributor struct { cli Client + ctx context.Context } // NewDistributor creates a new instance of the distributor func NewDistributor( + ctx context.Context, cli Client, ) *Distributor { return &Distributor{ cli: cli, + ctx: ctx, } } @@ -86,7 +89,7 @@ func (d *Distributor) fundAccounts( // before the stress test starts for _, account := range accounts { // Fetch the account balance - subAccount, err := d.cli.GetAccount(account.String()) + subAccount, err := d.cli.GetAccount(d.ctx, account.String()) if err != nil { return nil, fmt.Errorf("unable to fetch sub-account, %w", err) } @@ -124,7 +127,7 @@ func (d *Distributor) fundAccounts( }) // Figure out how many accounts can actually be funded - distributor, err := d.cli.GetAccount(distributorKey.PubKey().Address().String()) + distributor, err := d.cli.GetAccount(d.ctx, distributorKey.PubKey().Address().String()) if err != nil { return nil, fmt.Errorf("unable to fetch distributor account, %w", err) } @@ -198,14 +201,14 @@ func (d *Distributor) fundAccounts( nonce++ // Broadcast the tx and wait for it to be committed - if err := d.cli.BroadcastTransaction(tx); err != nil { + if err := d.cli.BroadcastTransaction(d.ctx, tx); err != nil { return nil, fmt.Errorf("unable to broadcast tx with commit, %w", err) } // Since accounts can be uninitialized on the node, after the // transfer they will have acquired a storage slot, and need // to be re-fetched for their data (Sequence + Account Number) - nodeAccount, err := d.cli.GetAccount(account.address.String()) + nodeAccount, err := d.cli.GetAccount(d.ctx, account.address.String()) if err != nil { return nil, fmt.Errorf("unable to fetch account, %w", err) } diff --git a/internal/distributor/distributor_test.go b/internal/distributor/distributor_test.go index c3ae019..00246dd 100644 --- a/internal/distributor/distributor_test.go +++ b/internal/distributor/distributor_test.go @@ -1,6 +1,7 @@ package distributor import ( + "context" "testing" "github.com/gnolang/gno/gno.land/pkg/gnoland" @@ -40,7 +41,7 @@ func TestDistributor_Distribute(t *testing.T) { accounts = testutils.GenerateAccounts(t, 10) mockClient = &mockClient{ - getAccountFn: func(address string) (*gnoland.GnoAccount, error) { + getAccountFn: func(ctx context.Context, address string) (*gnoland.GnoAccount, error) { acc := getAccount(address, accounts) if acc == nil { t.Fatal("invalid account requested") @@ -60,6 +61,7 @@ func TestDistributor_Distribute(t *testing.T) { ) d := NewDistributor( + context.Background(), mockClient, ) @@ -96,7 +98,7 @@ func TestDistributor_Distribute(t *testing.T) { accounts = testutils.GenerateAccounts(t, 10) mockClient = &mockClient{ - getAccountFn: func(address string) (*gnoland.GnoAccount, error) { + getAccountFn: func(ctx context.Context, address string) (*gnoland.GnoAccount, error) { acc := getAccount(address, accounts) if acc == nil { t.Fatal("invalid account requested") @@ -116,6 +118,7 @@ func TestDistributor_Distribute(t *testing.T) { ) d := NewDistributor( + context.Background(), mockClient, ) @@ -144,7 +147,7 @@ func TestDistributor_Distribute(t *testing.T) { capturedBroadcasts = make([]*std.Tx, 0) mockClient = &mockClient{ - getAccountFn: func(address string) (*gnoland.GnoAccount, error) { + getAccountFn: func(ctx context.Context, address string) (*gnoland.GnoAccount, error) { acc := getAccount(address, accounts) if acc == nil { t.Fatal("invalid account requested") @@ -177,7 +180,7 @@ func TestDistributor_Distribute(t *testing.T) { ), }, nil }, - broadcastTransactionFn: func(tx *std.Tx) error { + broadcastTransactionFn: func(ctx context.Context, tx *std.Tx) error { capturedBroadcasts = append(capturedBroadcasts, tx) return nil @@ -186,6 +189,7 @@ func TestDistributor_Distribute(t *testing.T) { ) d := NewDistributor( + context.Background(), mockClient, ) diff --git a/internal/distributor/mock_test.go b/internal/distributor/mock_test.go index 5d30456..d73ec87 100644 --- a/internal/distributor/mock_test.go +++ b/internal/distributor/mock_test.go @@ -1,15 +1,17 @@ package distributor import ( + "context" + "github.com/gnolang/gno/gno.land/pkg/gnoland" "github.com/gnolang/gno/tm2/pkg/std" ) type ( - broadcastTransactionDelegate func(*std.Tx) error - getAccountDelegate func(string) (*gnoland.GnoAccount, error) - estimateGasDelegate func(*std.Tx) (int64, error) - fetchGasPriceDelegate func() (std.GasPrice, error) + broadcastTransactionDelegate func(context.Context, *std.Tx) error + getAccountDelegate func(context.Context, string) (*gnoland.GnoAccount, error) + estimateGasDelegate func(context.Context, *std.Tx) (int64, error) + fetchGasPriceDelegate func(context.Context) (std.GasPrice, error) ) type mockClient struct { @@ -19,33 +21,33 @@ type mockClient struct { fetchGasPriceFn fetchGasPriceDelegate } -func (m *mockClient) BroadcastTransaction(tx *std.Tx) error { +func (m *mockClient) BroadcastTransaction(ctx context.Context, tx *std.Tx) error { if m.broadcastTransactionFn != nil { - return m.broadcastTransactionFn(tx) + return m.broadcastTransactionFn(ctx, tx) } return nil } -func (m *mockClient) GetAccount(address string) (*gnoland.GnoAccount, error) { +func (m *mockClient) GetAccount(ctx context.Context, address string) (*gnoland.GnoAccount, error) { if m.getAccountFn != nil { - return m.getAccountFn(address) + return m.getAccountFn(ctx, address) } return nil, nil } -func (m *mockClient) EstimateGas(tx *std.Tx) (int64, error) { +func (m *mockClient) EstimateGas(ctx context.Context, tx *std.Tx) (int64, error) { if m.estimateGasFn != nil { - return m.estimateGasFn(tx) + return m.estimateGasFn(ctx, tx) } return 0, nil } -func (m *mockClient) FetchGasPrice() (std.GasPrice, error) { +func (m *mockClient) FetchGasPrice(ctx context.Context) (std.GasPrice, error) { if m.fetchGasPriceFn != nil { - return m.fetchGasPriceFn() + return m.fetchGasPriceFn(ctx) } return std.GasPrice{}, nil diff --git a/internal/pipeline.go b/internal/pipeline.go index 9a278ce..0569198 100644 --- a/internal/pipeline.go +++ b/internal/pipeline.go @@ -1,6 +1,7 @@ package internal import ( + "context" "fmt" "time" @@ -54,34 +55,35 @@ func NewPipeline(cfg *Config) (*Pipeline, error) { } // Execute runs the entire pipeline process -func (p *Pipeline) Execute() error { +func (p *Pipeline) Execute(ctx context.Context) error { var ( mode = runtime.Type(p.cfg.Mode) - txBatcher = batcher.NewBatcher(p.cli) - txCollector = collector.NewCollector(p.cli) - txRuntime = runtime.GetRuntime(mode) + txBatcher = batcher.NewBatcher(ctx, p.cli) + txCollector = collector.NewCollector(ctx, p.cli) + txRuntime = runtime.GetRuntime(ctx, mode) ) // Initialize the accounts for the runtime accounts := p.initializeAccounts() - gasPrice, err := p.cli.FetchGasPrice() + gasPrice, err := p.cli.FetchGasPrice(ctx) if err != nil { return err } - lastBlock, err := p.cli.GetLatestBlockHeight() + lastBlock, err := p.cli.GetLatestBlockHeight(ctx) if err != nil { return fmt.Errorf("unable to get last block, %w", err) } - maxGas, err := p.cli.GetBlockGasLimit(lastBlock) + maxGas, err := p.cli.GetBlockGasLimit(ctx, lastBlock) if err != nil { return fmt.Errorf("unable to get block gas limit, %w", err) } // Predeploy any pending transactions estimatedGas, err := prepareRuntime( + ctx, mode, accounts[0], p.cfg.ChainID, @@ -102,7 +104,7 @@ func (p *Pipeline) Execute() error { } // Distribute the funds to sub-accounts - runAccounts, err := distributor.NewDistributor(p.cli).Distribute( + runAccounts, err := distributor.NewDistributor(ctx, p.cli).Distribute( accounts[0], addresses, p.cfg.ChainID, @@ -209,6 +211,7 @@ func (p *Pipeline) handleResults(runResult *collector.RunResult) error { // prepareRuntime prepares the runtime by pre-deploying // any pending transactions func prepareRuntime( + ctx context.Context, mode runtime.Type, deployerKey crypto.PrivKey, chainID string, @@ -219,7 +222,7 @@ func prepareRuntime( transactions uint64, ) (std.Coin, error) { // Get the deployer account - deployer, err := cli.GetAccount(deployerKey.PubKey().Address().String()) + deployer, err := cli.GetAccount(ctx, deployerKey.PubKey().Address().String()) if err != nil { return std.Coin{}, fmt.Errorf("unable to fetch deployer account, %w", err) } @@ -248,7 +251,7 @@ func prepareRuntime( // Execute the predeploy transactions for _, tx := range predeployTxs { - if err := cli.BroadcastTransaction(tx); err != nil { + if err := cli.BroadcastTransaction(ctx, tx); err != nil { return std.Coin{}, fmt.Errorf("unable to broadcast predeploy tx, %w", err) } diff --git a/internal/runtime/helper.go b/internal/runtime/helper.go index 7c791df..8f85e90 100644 --- a/internal/runtime/helper.go +++ b/internal/runtime/helper.go @@ -1,6 +1,7 @@ package runtime import ( + "context" "fmt" "github.com/gnolang/gno/tm2/pkg/crypto" @@ -18,6 +19,7 @@ type msgFn func(creator std.Account, index int) std.Msg // constructTransactions constructs and signs the transactions // using the passed in message generator and signer func constructTransactions( + ctx context.Context, keys []crypto.PrivKey, accounts []std.Account, transactions uint64, @@ -67,7 +69,7 @@ func constructTransactions( return nil, fmt.Errorf("unable to sign transaction, %w", err) } - gasWanted, err := estimateFn(tx) + gasWanted, err := estimateFn(ctx, tx) if err != nil { return nil, fmt.Errorf("unable to estimate gas, %w", err) } @@ -133,6 +135,7 @@ func constructTransactions( } func calculateRuntimeCosts( + ctx context.Context, account std.Account, transactions uint64, maxBlockMaxGas int64, @@ -160,7 +163,7 @@ func calculateRuntimeCosts( return std.Coin{}, fmt.Errorf("unable to sign transaction, %w", err) } - estimatedGas, err := estimateFn(tx) + estimatedGas, err := estimateFn(ctx, tx) if err != nil { return std.Coin{}, fmt.Errorf("unable to estimate gas, %w", err) } diff --git a/internal/runtime/helper_test.go b/internal/runtime/helper_test.go index 6e4ad13..a5393e4 100644 --- a/internal/runtime/helper_test.go +++ b/internal/runtime/helper_test.go @@ -1,6 +1,7 @@ package runtime import ( + "context" "testing" "github.com/gnolang/gno/gno.land/pkg/gnoland" @@ -51,6 +52,7 @@ func TestHelper_ConstructTransactions(t *testing.T) { ) txs, err := constructTransactions( + context.Background(), accountKeys, accounts, transactions, @@ -58,7 +60,7 @@ func TestHelper_ConstructTransactions(t *testing.T) { common.DefaultGasPrice, "dummy", getMsgFn, - func(_ *std.Tx) (int64, error) { + func(_ context.Context, _ *std.Tx) (int64, error) { return 1_000_000, nil }, ) diff --git a/internal/runtime/package_deployment.go b/internal/runtime/package_deployment.go index 330dbf4..76dfd43 100644 --- a/internal/runtime/package_deployment.go +++ b/internal/runtime/package_deployment.go @@ -1,6 +1,7 @@ package runtime import ( + "context" "fmt" "time" @@ -9,10 +10,14 @@ import ( "github.com/gnolang/gno/tm2/pkg/std" ) -type packageDeployment struct{} +type packageDeployment struct { + ctx context.Context +} -func newPackageDeployment() *packageDeployment { - return &packageDeployment{} +func newPackageDeployment(ctx context.Context) *packageDeployment { + return &packageDeployment{ + ctx: ctx, + } } func (c *packageDeployment) Initialize( @@ -35,6 +40,7 @@ func (c *packageDeployment) CalculateRuntimeCosts( transactions uint64, ) (std.Coin, error) { return calculateRuntimeCosts( + c.ctx, account, transactions, currentMaxGas, @@ -55,6 +61,7 @@ func (c *packageDeployment) ConstructTransactions( estimateFn EstimateGasFn, ) ([]*std.Tx, error) { return constructTransactions( + c.ctx, keys, accounts, transactions, diff --git a/internal/runtime/realm_call.go b/internal/runtime/realm_call.go index aa3cc0e..0ba005a 100644 --- a/internal/runtime/realm_call.go +++ b/internal/runtime/realm_call.go @@ -1,6 +1,7 @@ package runtime import ( + "context" "fmt" "time" @@ -14,10 +15,13 @@ const methodName = "SayHello" type realmCall struct { realmPath string + ctx context.Context } -func newRealmCall() *realmCall { - return &realmCall{} +func newRealmCall(ctx context.Context) *realmCall { + return &realmCall{ + ctx: ctx, + } } func (r *realmCall) Initialize( @@ -67,7 +71,7 @@ func (r *realmCall) Initialize( } // Estimate the gas for the initial tx - gasWanted, err := estimateFn(tx) + gasWanted, err := estimateFn(r.ctx, tx) if err != nil { return nil, fmt.Errorf("unable to estimate gas: %w", err) } @@ -94,6 +98,7 @@ func (r *realmCall) CalculateRuntimeCosts( transactions uint64, ) (std.Coin, error) { return calculateRuntimeCosts( + r.ctx, account, transactions, currentMaxGas, @@ -114,6 +119,7 @@ func (r *realmCall) ConstructTransactions( estimateFn EstimateGasFn, ) ([]*std.Tx, error) { return constructTransactions( + r.ctx, keys, accounts, transactions, diff --git a/internal/runtime/realm_deployment.go b/internal/runtime/realm_deployment.go index daa54d5..c0f28c0 100644 --- a/internal/runtime/realm_deployment.go +++ b/internal/runtime/realm_deployment.go @@ -1,6 +1,7 @@ package runtime import ( + "context" "fmt" "time" @@ -9,10 +10,14 @@ import ( "github.com/gnolang/gno/tm2/pkg/std" ) -type realmDeployment struct{} +type realmDeployment struct { + ctx context.Context +} -func newRealmDeployment() *realmDeployment { - return &realmDeployment{} +func newRealmDeployment(ctx context.Context) *realmDeployment { + return &realmDeployment{ + ctx: ctx, + } } func (c *realmDeployment) Initialize( @@ -35,6 +40,7 @@ func (c *realmDeployment) CalculateRuntimeCosts( transactions uint64, ) (std.Coin, error) { return calculateRuntimeCosts( + c.ctx, account, transactions, currentMaxGas, @@ -84,6 +90,7 @@ func (c *realmDeployment) ConstructTransactions( estimateFn EstimateGasFn, ) ([]*std.Tx, error) { return constructTransactions( + c.ctx, keys, accounts, transactions, diff --git a/internal/runtime/runtime.go b/internal/runtime/runtime.go index 219d1b6..8edc01e 100644 --- a/internal/runtime/runtime.go +++ b/internal/runtime/runtime.go @@ -1,6 +1,8 @@ package runtime import ( + "context" + "github.com/gnolang/gno/tm2/pkg/crypto" "github.com/gnolang/gno/tm2/pkg/std" ) @@ -11,7 +13,7 @@ const ( ) // EstimateGasFn is the gas estimation callback -type EstimateGasFn func(tx *std.Tx) (int64, error) +type EstimateGasFn func(ctx context.Context, tx *std.Tx) (int64, error) // SignFn is the tx signing callback type SignFn func(tx *std.Tx) error @@ -57,14 +59,14 @@ type Runtime interface { } // GetRuntime fetches the specified runtime, if any -func GetRuntime(runtimeType Type) Runtime { +func GetRuntime(ctx context.Context, runtimeType Type) Runtime { switch runtimeType { case RealmCall: - return newRealmCall() + return newRealmCall(ctx) case RealmDeployment: - return newRealmDeployment() + return newRealmDeployment(ctx) case PackageDeployment: - return newPackageDeployment() + return newPackageDeployment(ctx) default: return nil } diff --git a/internal/runtime/runtime_test.go b/internal/runtime/runtime_test.go index f3ac770..52b3ebe 100644 --- a/internal/runtime/runtime_test.go +++ b/internal/runtime/runtime_test.go @@ -1,6 +1,7 @@ package runtime import ( + "context" "testing" "github.com/gnolang/gno/gno.land/pkg/sdk/vm" @@ -70,7 +71,7 @@ func TestRuntime_CommonDeployment(t *testing.T) { ) // Get the runtime - r := GetRuntime(testCase.mode) + r := GetRuntime(context.Background(), testCase.mode) // Make sure there is no initialization logic initialTxs, err := r.Initialize( @@ -78,7 +79,7 @@ func TestRuntime_CommonDeployment(t *testing.T) { func(_ *std.Tx) error { return nil }, - func(_ *std.Tx) (int64, error) { + func(_ context.Context, _ *std.Tx) (int64, error) { return 1_000_000, nil }, 1_000_000, @@ -96,7 +97,7 @@ func TestRuntime_CommonDeployment(t *testing.T) { 1_000_000, common.DefaultGasPrice, "dummy", - func(_ *std.Tx) (int64, error) { + func(_ context.Context, _ *std.Tx) (int64, error) { return 1_000_000, nil }, ) @@ -126,7 +127,7 @@ func TestRuntime_RealmCall(t *testing.T) { ) // Get the runtime - r := GetRuntime(RealmCall) + r := GetRuntime(context.Background(), RealmCall) // Make sure the initialization logic is present initialTxs, err := r.Initialize( @@ -134,7 +135,7 @@ func TestRuntime_RealmCall(t *testing.T) { func(_ *std.Tx) error { return nil }, - func(_ *std.Tx) (int64, error) { + func(_ context.Context, _ *std.Tx) (int64, error) { return 1_000_000, nil }, 1_000_000, @@ -160,7 +161,7 @@ func TestRuntime_RealmCall(t *testing.T) { 1_000_000, common.DefaultGasPrice, "dummy", - func(_ *std.Tx) (int64, error) { + func(_ context.Context, _ *std.Tx) (int64, error) { return 1_000_000, nil }, ) From 24954a2b48abd68c3b20f2df35c210d7f99e4cb1 Mon Sep 17 00:00:00 2001 From: Miguel Victoria Date: Thu, 4 Sep 2025 11:05:18 +0200 Subject: [PATCH 7/8] update gnomod --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 8335f5c..04ddb46 100644 --- a/go.mod +++ b/go.mod @@ -5,6 +5,7 @@ go 1.23.0 toolchain go1.24.1 require ( + github.com/gnolang/gno v0.0.0-20250903154725-71e9ac3593a9 github.com/peterbourgon/ff/v3 v3.4.0 github.com/schollz/progressbar/v3 v3.18.0 github.com/stretchr/testify v1.10.0 @@ -29,7 +30,6 @@ require ( github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect github.com/fsnotify/fsnotify v1.5.4 // indirect github.com/getsentry/sentry-go v0.27.0 // indirect - github.com/gnolang/gno v0.0.0-20250903154725-71e9ac3593a9 // indirect github.com/go-logr/logr v1.4.2 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/gofrs/flock v0.12.1 // indirect From 530c73b80bc4e099293ef6e0822cca3928278af8 Mon Sep 17 00:00:00 2001 From: Miguel Victoria Date: Thu, 4 Sep 2025 11:07:18 +0200 Subject: [PATCH 8/8] remove println --- internal/client/client.go | 1 - 1 file changed, 1 deletion(-) diff --git a/internal/client/client.go b/internal/client/client.go index 8ac57a7..b5fb292 100644 --- a/internal/client/client.go +++ b/internal/client/client.go @@ -143,7 +143,6 @@ func (h *Client) GetBlockGasLimit(ctx context.Context, height int64) (int64, err } func (h *Client) EstimateGas(ctx context.Context, tx *std.Tx) (int64, error) { - fmt.Println(tx.Fee) // Prepare the transaction. // The transaction needs to be amino-binary encoded // in order to be estimated