Skip to content

Commit 1a59872

Browse files
Feat/dagger multimode (#91)
* dagger multimode * trying self hosted runner * back to ubuntu gh runner * upgrading gnolang dep * broken missing context - TO BE fixed * add context everywhere * update gnomod * remove println --------- Co-authored-by: sw360cab <[email protected]>
1 parent b7860c8 commit 1a59872

25 files changed

+213
-118
lines changed

.github/workflows/dagger.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ jobs:
99
supernova:
1010
name: supernova-ci
1111
runs-on: ubuntu-latest
12+
# runs-on: [ self-hosted, Linux, X64, dagger ]
13+
strategy:
14+
matrix:
15+
env: [PACKAGE_DEPLOYMENT, REALM_DEPLOYMENT, REALM_CALL]
16+
max-parallel: 1
17+
1218
steps:
1319
- name: Checkout
1420
uses: actions/checkout@v5
@@ -28,4 +34,4 @@ jobs:
2834
version: ${{ steps.dagger_version.outputs.version }}
2935
verb: call
3036
module: ci/dagger/run-supernova/
31-
args: run-stress-test --src-dir . --chain-id ${CHAIN_ID} --rpc-endpoint ${RPC_URL} --sub-accounts 2 --transactions 10
37+
args: run-stress-test --src-dir . --chain-id ${CHAIN_ID} --rpc-endpoint ${RPC_URL} --mode ${{ matrix.env }} --sub-accounts 2 --transactions 100

ci/dagger/run-supernova/main.go

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ const (
1313
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"
1414
)
1515

16+
type supernovaMode string
17+
18+
const (
19+
PACKAGE_DEPLOYMENT supernovaMode = "PACKAGE_DEPLOYMENT"
20+
REALM_DEPLOYMENT supernovaMode = "REALM_DEPLOYMENT"
21+
REALM_CALL supernovaMode = "REALM_CALL"
22+
)
23+
1624
type Supernova struct{}
1725

1826
// Builds Supernova image from code passed into a *dagger.Directory item
@@ -51,7 +59,9 @@ func (s *Supernova) RunStressTest(
5159
subAccounts int,
5260
// +optional
5361
transactions int,
54-
// + optional
62+
// +default="REALM_DEPLOYMENT"
63+
mode string,
64+
// +optional
5565
srcDir *dagger.Directory,
5666
) (int, error) {
5767

@@ -65,10 +75,16 @@ func (s *Supernova) RunStressTest(
6575
transactions = DEFAULT_TRANSACTIONS
6676
}
6777

78+
runningMode, err := toSupernovaMode(mode)
79+
if err != nil {
80+
return -1, err
81+
}
82+
6883
return s.buildOrPull(srcDir).
6984
WithExec([]string{
7085
"-sub-accounts", fmt.Sprintf("%d", subAccounts),
7186
"-transactions", fmt.Sprintf("%d", transactions),
87+
"-mode", string(runningMode),
7288
"-chain-id", chainId,
7389
"-url", rpcEndpoint,
7490
"-mnemonic", MNEMONIC},
@@ -77,3 +93,16 @@ func (s *Supernova) RunStressTest(
7793
}).
7894
ExitCode(ctx)
7995
}
96+
97+
func toSupernovaMode(s string) (supernovaMode, error) {
98+
switch s {
99+
case string(PACKAGE_DEPLOYMENT):
100+
return PACKAGE_DEPLOYMENT, nil
101+
case string(REALM_DEPLOYMENT):
102+
return REALM_DEPLOYMENT, nil
103+
case string(REALM_CALL):
104+
return REALM_CALL, nil
105+
default:
106+
return "", fmt.Errorf("invalid supernova oode: %s", s)
107+
}
108+
}

cmd/root.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,5 +111,5 @@ func execMain(cfg *internal.Config) error {
111111
return fmt.Errorf("unable to create pipeline, %w", err)
112112
}
113113

114-
return pipeline.Execute()
114+
return pipeline.Execute(context.Background())
115115
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.23.0
55
toolchain go1.24.1
66

77
require (
8-
github.com/gnolang/gno v0.0.0-20250826105341-fba926958b6b
8+
github.com/gnolang/gno v0.0.0-20250903154725-71e9ac3593a9
99
github.com/peterbourgon/ff/v3 v3.4.0
1010
github.com/schollz/progressbar/v3 v3.18.0
1111
github.com/stretchr/testify v1.10.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwV
7676
github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU=
7777
github.com/getsentry/sentry-go v0.27.0 h1:Pv98CIbtB3LkMWmXi4Joa5OOcwbmnX88sF5qbK3r3Ps=
7878
github.com/getsentry/sentry-go v0.27.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY=
79-
github.com/gnolang/gno v0.0.0-20250826105341-fba926958b6b h1:z0iw3ObgSnibeOpORPzRZjnx6v5eeSbQ35zgdoZndjE=
80-
github.com/gnolang/gno v0.0.0-20250826105341-fba926958b6b/go.mod h1:j9wKq29meqwktEj2ReqPbSkeYUwoisfxHHVeV20lhtw=
79+
github.com/gnolang/gno v0.0.0-20250903154725-71e9ac3593a9 h1:ijDZP1N5mHhedtGlIinq9IsNy3GpG3MTcw6V+s10WT8=
80+
github.com/gnolang/gno v0.0.0-20250903154725-71e9ac3593a9/go.mod h1:j9wKq29meqwktEj2ReqPbSkeYUwoisfxHHVeV20lhtw=
8181
github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA=
8282
github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og=
8383
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=

internal/batcher/batcher.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package batcher
22

33
import (
4+
"context"
45
"errors"
56
"fmt"
67
"math"
@@ -16,12 +17,14 @@ import (
1617
// to the Gno Tendermint node
1718
type Batcher struct {
1819
cli Client
20+
ctx context.Context
1921
}
2022

2123
// NewBatcher creates a new Batcher instance
22-
func NewBatcher(cli Client) *Batcher {
24+
func NewBatcher(ctx context.Context, cli Client) *Batcher {
2325
return &Batcher{
2426
cli: cli,
27+
ctx: ctx,
2528
}
2629
}
2730

@@ -31,7 +34,7 @@ func (b *Batcher) BatchTransactions(txs []*std.Tx, batchSize int) (*TxBatchResul
3134
fmt.Printf("\n📦 Batching Transactions 📦\n\n")
3235

3336
// Note the current latest block
34-
latest, err := b.cli.GetLatestBlockHeight()
37+
latest, err := b.cli.GetLatestBlockHeight(b.ctx)
3538
if err != nil {
3639
return nil, fmt.Errorf("unable to fetch latest block %w", err)
3740
}

internal/batcher/batcher_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package batcher
22

33
import (
44
"bytes"
5+
"context"
56
"crypto/rand"
67
"fmt"
78
"testing"
@@ -85,7 +86,7 @@ func TestBatcher_BatchTransactions(t *testing.T) {
8586
)
8687

8788
// Create the batcher
88-
b := NewBatcher(mockClient)
89+
b := NewBatcher(context.Background(), mockClient)
8990

9091
// Batch the transactions
9192
res, err := b.BatchTransactions(txs, batchSize)

internal/batcher/mock_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
package batcher
22

33
import (
4+
"context"
5+
46
"github.com/gnolang/supernova/internal/common"
57
)
68

79
type (
810
createBatchDelegate func() common.Batch
9-
getLatestBlockHeightDelegate func() (int64, error)
11+
getLatestBlockHeightDelegate func(context.Context) (int64, error)
1012
)
1113

1214
type mockClient struct {
@@ -22,9 +24,9 @@ func (m *mockClient) CreateBatch() common.Batch {
2224
return nil
2325
}
2426

25-
func (m *mockClient) GetLatestBlockHeight() (int64, error) {
27+
func (m *mockClient) GetLatestBlockHeight(ctx context.Context) (int64, error) {
2628
if m.getLatestBlockHeightFn != nil {
27-
return m.getLatestBlockHeightFn()
29+
return m.getLatestBlockHeightFn(ctx)
2830
}
2931

3032
return 0, nil

internal/batcher/types.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
package batcher
22

33
import (
4+
"context"
5+
46
"github.com/gnolang/supernova/internal/common"
57
)
68

79
type Client interface {
810
CreateBatch() common.Batch
9-
GetLatestBlockHeight() (int64, error)
11+
GetLatestBlockHeight(ctx context.Context) (int64, error)
1012
}
1113

1214
// TxBatchResult contains batching results

internal/client/client.go

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package client
22

33
import (
4+
"context"
45
"fmt"
56

67
"github.com/gnolang/gno/gno.land/pkg/gnoland"
@@ -49,38 +50,38 @@ func (h *Client) CreateBatch() common.Batch {
4950
return &Batch{batch: h.conn.NewBatch()}
5051
}
5152

52-
func (h *Client) ExecuteABCIQuery(path string, data []byte) (*core_types.ResultABCIQuery, error) {
53-
return h.conn.ABCIQuery(path, data)
53+
func (h *Client) ExecuteABCIQuery(ctx context.Context, path string, data []byte) (*core_types.ResultABCIQuery, error) {
54+
return h.conn.ABCIQuery(ctx, path, data)
5455
}
5556

56-
func (h *Client) GetLatestBlockHeight() (int64, error) {
57-
status, err := h.conn.Status()
57+
func (h *Client) GetLatestBlockHeight(ctx context.Context) (int64, error) {
58+
status, err := h.conn.Status(ctx, nil)
5859
if err != nil {
5960
return 0, fmt.Errorf("unable to fetch status, %w", err)
6061
}
6162

6263
return status.SyncInfo.LatestBlockHeight, nil
6364
}
6465

65-
func (h *Client) GetBlock(height *int64) (*core_types.ResultBlock, error) {
66-
return h.conn.Block(height)
66+
func (h *Client) GetBlock(ctx context.Context, height *int64) (*core_types.ResultBlock, error) {
67+
return h.conn.Block(ctx, height)
6768
}
6869

69-
func (h *Client) GetBlockResults(height *int64) (*core_types.ResultBlockResults, error) {
70-
return h.conn.BlockResults(height)
70+
func (h *Client) GetBlockResults(ctx context.Context, height *int64) (*core_types.ResultBlockResults, error) {
71+
return h.conn.BlockResults(ctx, height)
7172
}
7273

73-
func (h *Client) GetConsensusParams(height *int64) (*core_types.ResultConsensusParams, error) {
74-
return h.conn.ConsensusParams(height)
74+
func (h *Client) GetConsensusParams(ctx context.Context, height *int64) (*core_types.ResultConsensusParams, error) {
75+
return h.conn.ConsensusParams(ctx, height)
7576
}
7677

77-
func (h *Client) BroadcastTransaction(tx *std.Tx) error {
78+
func (h *Client) BroadcastTransaction(ctx context.Context, tx *std.Tx) error {
7879
marshalledTx, err := amino.Marshal(tx)
7980
if err != nil {
8081
return fmt.Errorf("unable to marshal transaction, %w", err)
8182
}
8283

83-
res, err := h.conn.BroadcastTxCommit(marshalledTx)
84+
res, err := h.conn.BroadcastTxCommit(ctx, marshalledTx)
8485
if err != nil {
8586
return fmt.Errorf("unable to broadcast transaction, %w", err)
8687
}
@@ -96,8 +97,9 @@ func (h *Client) BroadcastTransaction(tx *std.Tx) error {
9697
return nil
9798
}
9899

99-
func (h *Client) GetAccount(address string) (*gnoland.GnoAccount, error) {
100+
func (h *Client) GetAccount(ctx context.Context, address string) (*gnoland.GnoAccount, error) {
100101
queryResult, err := h.conn.ABCIQuery(
102+
ctx,
101103
fmt.Sprintf("auth/accounts/%s", address),
102104
[]byte{},
103105
)
@@ -117,8 +119,8 @@ func (h *Client) GetAccount(address string) (*gnoland.GnoAccount, error) {
117119
return &acc, nil
118120
}
119121

120-
func (h *Client) GetBlockGasUsed(height int64) (int64, error) {
121-
blockRes, err := h.conn.BlockResults(&height)
122+
func (h *Client) GetBlockGasUsed(ctx context.Context, height int64) (int64, error) {
123+
blockRes, err := h.conn.BlockResults(ctx, &height)
122124
if err != nil {
123125
return 0, fmt.Errorf("unable to fetch block results, %w", err)
124126
}
@@ -131,16 +133,16 @@ func (h *Client) GetBlockGasUsed(height int64) (int64, error) {
131133
return gasUsed, nil
132134
}
133135

134-
func (h *Client) GetBlockGasLimit(height int64) (int64, error) {
135-
consensusParams, err := h.conn.ConsensusParams(&height)
136+
func (h *Client) GetBlockGasLimit(ctx context.Context, height int64) (int64, error) {
137+
consensusParams, err := h.conn.ConsensusParams(ctx, &height)
136138
if err != nil {
137139
return 0, fmt.Errorf("unable to fetch block info, %w", err)
138140
}
139141

140142
return consensusParams.ConsensusParams.Block.MaxGas, nil
141143
}
142144

143-
func (h *Client) EstimateGas(tx *std.Tx) (int64, error) {
145+
func (h *Client) EstimateGas(ctx context.Context, tx *std.Tx) (int64, error) {
144146
// Prepare the transaction.
145147
// The transaction needs to be amino-binary encoded
146148
// in order to be estimated
@@ -150,7 +152,7 @@ func (h *Client) EstimateGas(tx *std.Tx) (int64, error) {
150152
}
151153

152154
// Perform the simulation query
153-
resp, err := h.conn.ABCIQuery(simulatePath, encodedTx)
155+
resp, err := h.conn.ABCIQuery(ctx, simulatePath, encodedTx)
154156
if err != nil {
155157
return 0, fmt.Errorf("unable to perform ABCI query: %w", err)
156158
}
@@ -174,11 +176,11 @@ func (h *Client) EstimateGas(tx *std.Tx) (int64, error) {
174176
return deliverTx.GasUsed, nil
175177
}
176178

177-
func (h *Client) FetchGasPrice() (std.GasPrice, error) {
179+
func (h *Client) FetchGasPrice(ctx context.Context) (std.GasPrice, error) {
178180
// Perform auth/gasprice
179181
gp := std.GasPrice{}
180182

181-
qres, err := h.conn.ABCIQuery(gaspricePath, []byte{})
183+
qres, err := h.conn.ABCIQuery(ctx, gaspricePath, []byte{})
182184
if err != nil {
183185
return gp, err
184186
}

0 commit comments

Comments
 (0)