Skip to content

Commit

Permalink
feat(sequencers): make sequencer set updates interval configurable (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
artemijspavlovs authored Nov 19, 2024
1 parent 377dc7c commit 82f60ad
Show file tree
Hide file tree
Showing 11 changed files with 75 additions and 56 deletions.
1 change: 0 additions & 1 deletion .tool-versions

This file was deleted.

2 changes: 1 addition & 1 deletion block/sequencers.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (m *Manager) MonitorProposerRotation(ctx context.Context) {
}

func (m *Manager) MonitorSequencerSetUpdates(ctx context.Context) error {
ticker := time.NewTicker(3 * time.Minute) // TODO: make this configurable
ticker := time.NewTicker(m.Conf.SequencerSetUpdateInterval)
defer ticker.Stop()

for {
Expand Down
11 changes: 6 additions & 5 deletions block/submit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,12 @@ func TestSubmissionByTime(t *testing.T) {

// Init manager with empty blocks feature enabled
managerConfig := config.BlockManagerConfig{
BlockTime: blockTime,
MaxIdleTime: 0,
BatchSkew: 10,
BatchSubmitTime: submitTimeout,
BatchSubmitBytes: 1000,
BlockTime: blockTime,
MaxIdleTime: 0,
BatchSkew: 10,
BatchSubmitTime: submitTimeout,
BatchSubmitBytes: 1000,
SequencerSetUpdateInterval: config.DefaultSequencerSetUpdateInterval,
}

manager, err := testutil.GetManager(managerConfig, nil, 1, 1, 0, proxyApp, nil)
Expand Down
6 changes: 6 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ type BlockManagerConfig struct {
BatchSkew uint64 `mapstructure:"max_batch_skew"`
// The size of the batch of blocks and commits in Bytes. We'll write every batch to the DA and the settlement layer.
BatchSubmitBytes uint64 `mapstructure:"batch_submit_bytes"`
// SequencerSetUpdateInterval defines the interval at which to fetch sequencer updates from the settlement layer
SequencerSetUpdateInterval time.Duration `mapstructure:"sequencer_update_interval"`
}

// GetViperConfig reads configuration parameters from Viper instance.
Expand Down Expand Up @@ -163,6 +165,10 @@ func (c BlockManagerConfig) Validate() error {
return fmt.Errorf("max_batch_skew must be positive")
}

if c.SequencerSetUpdateInterval <= 0 {
return fmt.Errorf("sequencer_update_interval must be positive")
}

return nil
}

Expand Down
13 changes: 7 additions & 6 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,13 @@ func TestNodeConfig_Validate(t *testing.T) {
func fullNodeConfig() config.NodeConfig {
return config.NodeConfig{
BlockManagerConfig: config.BlockManagerConfig{
BlockTime: 1 * time.Second,
MaxIdleTime: 20 * time.Second,
MaxProofTime: 20 * time.Second,
BatchSubmitTime: 20 * time.Second,
BatchSkew: 10,
BatchSubmitBytes: 10000,
BlockTime: 1 * time.Second,
MaxIdleTime: 20 * time.Second,
MaxProofTime: 20 * time.Second,
BatchSubmitTime: 20 * time.Second,
BatchSkew: 10,
BatchSubmitBytes: 10000,
SequencerSetUpdateInterval: config.DefaultSequencerSetUpdateInterval,
},
DAConfig: "da-config",
SettlementLayer: "dymension",
Expand Down
15 changes: 9 additions & 6 deletions config/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ const (
DefaultListenAddress = "/ip4/0.0.0.0/tcp/26656"

DefaultHomeDir = "sequencer_keys"

DefaultSequencerSetUpdateInterval = 3 * time.Minute
)

// DefaultNodeConfig keeps default values of NodeConfig
Expand All @@ -22,12 +24,13 @@ var DefaultNodeConfig = *DefaultConfig("")
func DefaultConfig(home string) *NodeConfig {
cfg := &NodeConfig{
BlockManagerConfig: BlockManagerConfig{
BlockTime: 200 * time.Millisecond,
MaxIdleTime: 3600 * time.Second,
MaxProofTime: 100 * time.Second,
BatchSubmitTime: 3600 * time.Second,
BatchSkew: 10,
BatchSubmitBytes: 500000,
BlockTime: 200 * time.Millisecond,
MaxIdleTime: 3600 * time.Second,
MaxProofTime: 100 * time.Second,
BatchSubmitTime: 3600 * time.Second,
BatchSkew: 10,
BatchSubmitBytes: 500000,
SequencerSetUpdateInterval: DefaultSequencerSetUpdateInterval,
},
SettlementLayer: "mock",
Instrumentation: &InstrumentationConfig{
Expand Down
9 changes: 5 additions & 4 deletions node/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,11 @@ func TestMempoolDirectly(t *testing.T) {
RPC: config.RPCConfig{},
MempoolConfig: *tmcfg.DefaultMempoolConfig(),
BlockManagerConfig: config.BlockManagerConfig{
BlockTime: 1 * time.Second,
BatchSubmitTime: 60 * time.Second,
BatchSubmitBytes: 100000,
BatchSkew: 10,
BlockTime: 1 * time.Second,
BatchSubmitTime: 60 * time.Second,
BatchSubmitBytes: 100000,
BatchSkew: 10,
SequencerSetUpdateInterval: config.DefaultSequencerSetUpdateInterval,
},
DAConfig: "",
SettlementLayer: "mock",
Expand Down
45 changes: 25 additions & 20 deletions rpc/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,11 @@ func TestGenesisChunked(t *testing.T) {
},
RPC: config.RPCConfig{},
BlockManagerConfig: config.BlockManagerConfig{
BlockTime: 100 * time.Millisecond,
BatchSubmitTime: 60 * time.Second,
BatchSubmitBytes: 1000,
BatchSkew: 10,
BlockTime: 100 * time.Millisecond,
BatchSubmitTime: 60 * time.Second,
BatchSubmitBytes: 1000,
BatchSkew: 10,
SequencerSetUpdateInterval: config.DefaultSequencerSetUpdateInterval,
},
DAConfig: "",
SettlementLayer: "mock",
Expand Down Expand Up @@ -854,10 +855,11 @@ func TestValidatorSetHandling(t *testing.T) {
BlockSyncRequestIntervalTime: 30 * time.Second,
},
BlockManagerConfig: config.BlockManagerConfig{
BlockTime: 10 * time.Millisecond,
BatchSubmitTime: 60 * time.Second,
BatchSubmitBytes: 1000,
BatchSkew: 10,
BlockTime: 10 * time.Millisecond,
BatchSubmitTime: 60 * time.Second,
BatchSubmitBytes: 1000,
BatchSkew: 10,
SequencerSetUpdateInterval: config.DefaultSequencerSetUpdateInterval,
},
SettlementConfig: settlement.Config{
ProposerPubKey: hex.EncodeToString(proposerPubKeyBytes),
Expand Down Expand Up @@ -1017,10 +1019,11 @@ func getRPCInternal(t *testing.T, sequencer bool) (*tmmocks.MockApplication, *cl
RPC: config.RPCConfig{},
MempoolConfig: *tmcfg.DefaultMempoolConfig(),
BlockManagerConfig: config.BlockManagerConfig{
BlockTime: 100 * time.Millisecond,
BatchSubmitTime: 60 * time.Second,
BatchSubmitBytes: 1000,
BatchSkew: 10,
BlockTime: 100 * time.Millisecond,
BatchSubmitTime: 60 * time.Second,
BatchSubmitBytes: 1000,
BatchSkew: 10,
SequencerSetUpdateInterval: config.DefaultSequencerSetUpdateInterval,
},
DAConfig: "",
SettlementLayer: "mock",
Expand Down Expand Up @@ -1123,10 +1126,11 @@ func TestMempool2Nodes(t *testing.T) {
BlockSyncRequestIntervalTime: 30 * time.Second,
},
BlockManagerConfig: config.BlockManagerConfig{
BlockTime: 100 * time.Millisecond,
BatchSubmitTime: 60 * time.Second,
BatchSubmitBytes: 1000,
BatchSkew: 10,
BlockTime: 100 * time.Millisecond,
BatchSubmitTime: 60 * time.Second,
BatchSubmitBytes: 1000,
BatchSkew: 10,
SequencerSetUpdateInterval: config.DefaultSequencerSetUpdateInterval,
},
MempoolConfig: *tmcfg.DefaultMempoolConfig(),
}, key1, signingKey1, proxy.NewLocalClientCreator(app), genesis, "", log.TestingLogger(), mempool.NopMetrics())
Expand All @@ -1139,10 +1143,11 @@ func TestMempool2Nodes(t *testing.T) {
ProposerPubKey: hex.EncodeToString(proposerPK),
},
BlockManagerConfig: config.BlockManagerConfig{
BlockTime: 100 * time.Millisecond,
BatchSubmitTime: 60 * time.Second,
BatchSubmitBytes: 1000,
BatchSkew: 10,
BlockTime: 100 * time.Millisecond,
BatchSubmitTime: 60 * time.Second,
BatchSubmitBytes: 1000,
BatchSkew: 10,
SequencerSetUpdateInterval: config.DefaultSequencerSetUpdateInterval,
},
P2PConfig: config.P2PConfig{
ListenAddress: "/ip4/127.0.0.1/tcp/9002",
Expand Down
11 changes: 6 additions & 5 deletions rpc/json/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,11 +314,12 @@ func getRPC(t *testing.T) (*tmmocks.MockApplication, *client.Client) {
config := config.NodeConfig{
SettlementLayer: "mock",
BlockManagerConfig: config.BlockManagerConfig{
BlockTime: 1 * time.Second,
MaxIdleTime: 0,
BatchSkew: 10,
BatchSubmitTime: 30 * time.Minute,
BatchSubmitBytes: 1000,
BlockTime: 1 * time.Second,
MaxIdleTime: 0,
BatchSkew: 10,
BatchSubmitTime: 30 * time.Minute,
BatchSubmitBytes: 1000,
SequencerSetUpdateInterval: config.DefaultSequencerSetUpdateInterval,
},
SettlementConfig: settlement.Config{
ProposerPubKey: hex.EncodeToString(proposerPubKeyBytes),
Expand Down
9 changes: 5 additions & 4 deletions testutil/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,11 @@ func initSettlementLayerMock(rollappId string, settlementlc settlement.ClientI,

func GetManagerConfig() config.BlockManagerConfig {
return config.BlockManagerConfig{
BlockTime: 100 * time.Millisecond,
BatchSubmitBytes: 1000000,
BatchSubmitTime: 30 * time.Minute,
BatchSkew: 10,
BlockTime: 100 * time.Millisecond,
BatchSubmitBytes: 1000000,
BatchSubmitTime: 30 * time.Minute,
BatchSkew: 10,
SequencerSetUpdateInterval: config.DefaultSequencerSetUpdateInterval,
}
}

Expand Down
9 changes: 5 additions & 4 deletions testutil/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,11 @@ func CreateNode(isSequencer bool, blockManagerConfig *config.BlockManagerConfig,

if blockManagerConfig == nil {
blockManagerConfig = &config.BlockManagerConfig{
BlockTime: 100 * time.Millisecond,
BatchSubmitTime: 60 * time.Second,
BatchSubmitBytes: 1000,
BatchSkew: 10,
BlockTime: 100 * time.Millisecond,
BatchSubmitTime: 60 * time.Second,
BatchSubmitBytes: 1000,
BatchSkew: 10,
SequencerSetUpdateInterval: config.DefaultSequencerSetUpdateInterval,
}
}
nodeConfig.BlockManagerConfig = *blockManagerConfig
Expand Down

0 comments on commit 82f60ad

Please sign in to comment.