Skip to content

Commit

Permalink
Merge pull request dymensionxyz#17 from dymensionxyz/omritoptix/block…
Browse files Browse the repository at this point in the history
…-batch

Omritoptix/block batch
  • Loading branch information
omritoptix authored Jul 13, 2022
2 parents 546bd2f + c9abfe4 commit 96f7835
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 248 deletions.
52 changes: 0 additions & 52 deletions .github/workflows/docker-build-da-mockserv.yml

This file was deleted.

72 changes: 0 additions & 72 deletions .github/workflows/docker-build-ethermint-debug.yml

This file was deleted.

117 changes: 0 additions & 117 deletions .github/workflows/docker-build-test-ethermint.yml

This file was deleted.

20 changes: 13 additions & 7 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ import (
)

const (
flagAggregator = "optimint.aggregator"
flagDALayer = "optimint.da_layer"
flagDAConfig = "optimint.da_config"
flagBlockTime = "optimint.block_time"
flagDABlockTime = "optimint.da_block_time"
flagDAStartHeight = "optimint.da_start_height"
flagNamespaceID = "optimint.namespace_id"
flagAggregator = "optimint.aggregator"
flagDALayer = "optimint.da_layer"
flagDAConfig = "optimint.da_config"
flagBlockTime = "optimint.block_time"
flagDABlockTime = "optimint.da_block_time"
flagDAStartHeight = "optimint.da_start_height"
flagNamespaceID = "optimint.namespace_id"
flagBlockBatchSize = "optimint.block_batch_size"
)

// NodeConfig stores Optimint node configuration.
Expand All @@ -41,6 +42,8 @@ type BlockManagerConfig struct {
// DAStartHeight allows skipping first DAStartHeight-1 blocks when querying for blocks.
DAStartHeight uint64 `mapstructure:"da_start_height"`
NamespaceID [8]byte `mapstructure:"namespace_id"`
// The size of the batch in blocks. Every batch we'll write to the DA and the settlement layer.
BlockBatchSize uint64 `mapstructure:"block_batch_size"`
}

// GetViperConfig reads configuration parameters from Viper instance.
Expand All @@ -53,6 +56,7 @@ func (nc *NodeConfig) GetViperConfig(v *viper.Viper) error {
nc.DAStartHeight = v.GetUint64(flagDAStartHeight)
nc.DABlockTime = v.GetDuration(flagDABlockTime)
nc.BlockTime = v.GetDuration(flagBlockTime)
nc.BlockBatchSize = v.GetUint64(flagBlockBatchSize)
nsID := v.GetString(flagNamespaceID)
bytes, err := hex.DecodeString(nsID)
if err != nil {
Expand All @@ -67,11 +71,13 @@ func (nc *NodeConfig) GetViperConfig(v *viper.Viper) error {
// This function is called in cosmos-sdk.
func AddFlags(cmd *cobra.Command) {
def := DefaultNodeConfig

cmd.Flags().Bool(flagAggregator, def.Aggregator, "run node in aggregator mode")
cmd.Flags().String(flagDALayer, def.DALayer, "Data Availability Layer Client name (mock or grpc")
cmd.Flags().String(flagDAConfig, def.DAConfig, "Data Availability Layer Client config")
cmd.Flags().Duration(flagBlockTime, def.BlockTime, "block time (for aggregator mode)")
cmd.Flags().Duration(flagDABlockTime, def.DABlockTime, "DA chain block time (for syncing)")
cmd.Flags().Uint64(flagDAStartHeight, def.DAStartHeight, "starting DA block height (for syncing)")
cmd.Flags().BytesHex(flagNamespaceID, def.NamespaceID[:], "namespace identifies (8 bytes in hex)")
cmd.Flags().Uint64(flagBlockBatchSize, def.BlockBatchSize, "block batch size")
}
2 changes: 2 additions & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func TestViperAndCobra(t *testing.T) {
assert.NoError(cmd.Flags().Set(flagDAConfig, `{"json":true}`))
assert.NoError(cmd.Flags().Set(flagBlockTime, "1234s"))
assert.NoError(cmd.Flags().Set(flagNamespaceID, "0102030405060708"))
assert.NoError(cmd.Flags().Set(flagBlockBatchSize, "10"))

nc := DefaultNodeConfig
assert.NoError(nc.GetViperConfig(v))
Expand All @@ -33,4 +34,5 @@ func TestViperAndCobra(t *testing.T) {
assert.Equal(`{"json":true}`, nc.DAConfig)
assert.Equal(1234*time.Second, nc.BlockTime)
assert.Equal([8]byte{1, 2, 3, 4, 5, 6, 7, 8}, nc.NamespaceID)
assert.Equal(uint64(10), nc.BlockBatchSize)
}

0 comments on commit 96f7835

Please sign in to comment.