Skip to content

Commit 9163b34

Browse files
authored
build(deps): bump go-da to v0.1.0 (#1446)
## Overview This PR updates go-da to v0.1.0. It updates the call to `Submit` to pass gas price, added config option which allows it to be configured. ## Checklist - [x] New and updated code has appropriate documentation - [x] New and updated code has new and/or updated testing - [x] Required CI checks are passing - [x] Visual proof for any user facing features like CLI or documentation updates - [x] Linked issues closed with keywords Fixes #1441 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Refactor** - Updated the submission process with an additional parameter to enhance functionality. - **Chores** - Modified the default configuration for the node by adding a new configuration flag and command-line flag. - Updated the initialization logic for the DAClient instance. - Modified the TestInitialState function in the block/manager_test.go file. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent fc88adc commit 9163b34

9 files changed

Lines changed: 23 additions & 17 deletions

File tree

block/manager_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func TestInitialState(t *testing.T) {
7777
t.Run(c.name, func(t *testing.T) {
7878
assert := assert.New(t)
7979
logger := test.NewFileLoggerCustom(t, test.TempLogFileName(t, c.name))
80-
dalc := &da.DAClient{DA: goDATest.NewDummyDA(), Logger: logger}
80+
dalc := &da.DAClient{DA: goDATest.NewDummyDA(), GasPrice: -1, Logger: logger}
8181
agg, err := NewManager(key, conf, c.genesis, c.store, nil, nil, dalc, nil, logger, nil)
8282
assert.NoError(err)
8383
assert.NotNil(agg)

config/config.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const (
1818
flagLight = "rollkit.light"
1919
flagTrustedHash = "rollkit.trusted_hash"
2020
flagLazyAggregator = "rollkit.lazy_aggregator"
21+
flagDAGasPrice = "rollkit.da_gas_price"
2122
)
2223

2324
// NodeConfig stores Rollkit node configuration.
@@ -33,7 +34,8 @@ type NodeConfig struct {
3334
DAAddress string `mapstructure:"da_address"`
3435
Light bool `mapstructure:"light"`
3536
HeaderConfig `mapstructure:",squash"`
36-
LazyAggregator bool `mapstructure:"lazy_aggregator"`
37+
LazyAggregator bool `mapstructure:"lazy_aggregator"`
38+
DAGasPrice float64 `mapstructure:"da_gas_price"`
3739
}
3840

3941
// HeaderConfig allows node to pass the initial trusted header hash to start the header exchange service
@@ -87,6 +89,7 @@ func (nc *NodeConfig) GetViperConfig(v *viper.Viper) error {
8789
nc.LazyAggregator = v.GetBool(flagLazyAggregator)
8890
nc.Light = v.GetBool(flagLight)
8991
nc.TrustedHash = v.GetString(flagTrustedHash)
92+
nc.DAGasPrice = v.GetFloat64(flagDAGasPrice)
9093
return nil
9194
}
9295

@@ -100,6 +103,7 @@ func AddFlags(cmd *cobra.Command) {
100103
cmd.Flags().String(flagDAAddress, def.DAAddress, "DA address (host:port)")
101104
cmd.Flags().Duration(flagBlockTime, def.BlockTime, "block time (for aggregator mode)")
102105
cmd.Flags().Duration(flagDABlockTime, def.DABlockTime, "DA chain block time (for syncing)")
106+
cmd.Flags().Float64(flagDAGasPrice, def.DAGasPrice, "DA gas price for blob transactions")
103107
cmd.Flags().Uint64(flagDAStartHeight, def.DAStartHeight, "starting DA block height (for syncing)")
104108
cmd.Flags().Bool(flagLight, def.Light, "run light client")
105109
cmd.Flags().String(flagTrustedHash, def.TrustedHash, "initial trusted hash to start the header exchange service")

config/defaults.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ var DefaultNodeConfig = NodeConfig{
2424
BlockTime: 1 * time.Second,
2525
DABlockTime: 15 * time.Second,
2626
},
27-
DAAddress: ":26650",
28-
Light: false,
27+
DAAddress: ":26650",
28+
DAGasPrice: -1,
29+
Light: false,
2930
HeaderConfig: HeaderConfig{
3031
TrustedHash: "",
3132
},

da/da.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,9 @@ type ResultRetrieveBlocks struct {
6666

6767
// DAClient is a new DA implementation.
6868
type DAClient struct {
69-
DA goDA.DA
70-
Logger log.Logger
69+
DA goDA.DA
70+
GasPrice float64
71+
Logger log.Logger
7172
}
7273

7374
// SubmitBlocks submits blocks to DA.
@@ -110,7 +111,7 @@ func (dac *DAClient) SubmitBlocks(ctx context.Context, blocks []*types.Block) Re
110111
},
111112
}
112113
}
113-
ids, _, err := dac.DA.Submit(blobs)
114+
ids, _, err := dac.DA.Submit(blobs, dac.GasPrice)
114115
if err != nil {
115116
return ResultSubmitBlocks{
116117
BaseResult: BaseResult{

da/da_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ func (m *MockDA) Commit(blobs []da.Blob) ([]da.Commitment, error) {
6565
return args.Get(0).([]da.Commitment), args.Error(1)
6666
}
6767

68-
func (m *MockDA) Submit(blobs []da.Blob) ([]da.ID, []da.Proof, error) {
69-
args := m.Called(blobs)
68+
func (m *MockDA) Submit(blobs []da.Blob, gasPrice float64) ([]da.ID, []da.Proof, error) {
69+
args := m.Called(blobs, gasPrice)
7070
return args.Get(0).([]da.ID), args.Get(1).([]da.Proof), args.Error(2)
7171
}
7272

@@ -79,14 +79,14 @@ func TestMockDA(t *testing.T) {
7979
mockDA := &MockDA{}
8080
// Set up the mock to return an error for MaxBlobSize
8181
mockDA.On("MaxBlobSize").Return(uint64(0), errors.New("mock error"))
82-
dalc := &DAClient{DA: mockDA, Logger: log.TestingLogger()}
82+
dalc := &DAClient{DA: mockDA, GasPrice: -1, Logger: log.TestingLogger()}
8383
t.Run("max_blob_size_error", func(t *testing.T) {
8484
doTestMaxBlockSizeError(t, dalc)
8585
})
8686
}
8787

8888
func TestSubmitRetrieve(t *testing.T) {
89-
dummyClient := &DAClient{DA: goDATest.NewDummyDA(), Logger: log.TestingLogger()}
89+
dummyClient := &DAClient{DA: goDATest.NewDummyDA(), GasPrice: -1, Logger: log.TestingLogger()}
9090
grpcClient, err := startMockGRPCClient()
9191
require.NoError(t, err)
9292
clients := map[string]*DAClient{
@@ -131,7 +131,7 @@ func startMockGRPCClient() (*DAClient, error) {
131131
if err != nil {
132132
return nil, err
133133
}
134-
return &DAClient{DA: client, Logger: log.TestingLogger()}, nil
134+
return &DAClient{DA: client, GasPrice: -1, Logger: log.TestingLogger()}, nil
135135
}
136136

137137
func doTestMaxBlockSizeError(t *testing.T, dalc *DAClient) {

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ require (
2020
github.com/multiformats/go-multiaddr v0.12.1
2121
github.com/pkg/errors v0.9.1
2222
github.com/prometheus/client_golang v1.18.0
23-
github.com/rollkit/go-da v0.0.0-20231207150926-93600f28d67d
23+
github.com/rollkit/go-da v0.1.0
2424
github.com/rs/cors v1.10.1
2525
github.com/spf13/cobra v1.8.0
2626
github.com/spf13/viper v1.18.2

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,8 +1350,8 @@ github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTE
13501350
github.com/rogpeppe/go-internal v1.8.1/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4nPKWu0nJ5d+o=
13511351
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
13521352
github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
1353-
github.com/rollkit/go-da v0.0.0-20231207150926-93600f28d67d h1:VeAbAkj+1+9OMc80BMIt7TokIAJudJrqI/59gTpMeuI=
1354-
github.com/rollkit/go-da v0.0.0-20231207150926-93600f28d67d/go.mod h1:cy1LA9kCyCJHgszKkTh9hJn816l5Oa87GMA2c1imfqA=
1353+
github.com/rollkit/go-da v0.1.0 h1:FAEMTNF8mTsPuiUgYt2dQSMzw8iYPjiWq7692CS2mbY=
1354+
github.com/rollkit/go-da v0.1.0/go.mod h1:Kef0XI5ecEKd3TXzI8S+9knAUJnZg0svh2DuXoCsPlM=
13551355
github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU=
13561356
github.com/rs/cors v1.8.2/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU=
13571357
github.com/rs/cors v1.10.1 h1:L0uuZVXIKlI1SShY2nhFfo44TYvDPQ1w4oFkUJNfhyo=

node/full.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ func initDALC(nodeConfig config.NodeConfig, dalcKV ds.TxnDatastore, logger log.L
220220
if err != nil {
221221
return nil, fmt.Errorf("error while establishing GRPC connection to DA layer: %w", err)
222222
}
223-
return &da.DAClient{DA: daClient, Logger: logger.With("module", "da_client")}, nil
223+
return &da.DAClient{DA: daClient, GasPrice: nodeConfig.DAGasPrice, Logger: logger.With("module", "da_client")}, nil
224224
}
225225

226226
func initMempool(logger log.Logger, proxyApp proxy.AppConns) *mempool.CListMempool {

node/helpers_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
)
1919

2020
func getMockDA() *da.DAClient {
21-
return &da.DAClient{DA: goDATest.NewDummyDA(), Logger: log.TestingLogger()}
21+
return &da.DAClient{DA: goDATest.NewDummyDA(), GasPrice: -1, Logger: log.TestingLogger()}
2222
}
2323

2424
func TestMockTester(t *testing.T) {

0 commit comments

Comments
 (0)