From 3e92814f0db6e4914bcac1faf93747e6680b8024 Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Tue, 15 Oct 2024 18:13:20 +0200 Subject: [PATCH] test fix --- block/submit.go | 27 ++++++++++----------------- block/submit_loop_test.go | 4 ++-- block/submit_test.go | 2 +- config/config_test.go | 2 +- config/defaults.go | 2 +- node/node_test.go | 2 +- rpc/client/client_test.go | 10 +++++----- rpc/json/service_test.go | 2 +- testutil/block.go | 2 +- testutil/node.go | 2 +- 10 files changed, 24 insertions(+), 31 deletions(-) diff --git a/block/submit.go b/block/submit.go index 9eb2d1021..d99b9b2fd 100644 --- a/block/submit.go +++ b/block/submit.go @@ -46,7 +46,7 @@ func SubmitLoopInner( bytesProduced chan int, // a channel of block and commit bytes produced maxBatchSkew time.Duration, // max number of blocks that submitter is allowed to have pending unsubmittedBlocksNum func() uint64, - unsubmittedBlocksTime func() (time.Duration, error), + unsubmittedBlocksTime func() time.Duration, maxBatchTime time.Duration, // max time to allow between batches maxBatchBytes uint64, // max size of serialised batch in bytes createAndSubmitBatch func(maxSizeBytes uint64) (sizeBlocksCommits uint64, err error), @@ -62,10 +62,7 @@ func SubmitLoopInner( // 'trigger': this thread is responsible for waking up the submitter when a new block arrives, and back-pressures the block production loop // if it gets too far ahead. for { - skewTime, err := unsubmittedBlocksTime() - if err != nil { - return err - } + skewTime := unsubmittedBlocksTime() if maxBatchSkew < skewTime { // too much stuff is pending submission // we block here until we get a progress nudge from the submitter thread @@ -103,10 +100,8 @@ func SubmitLoopInner( case <-submitter.C: } pending := pendingBytes.Load() - skewTime, err := unsubmittedBlocksTime() - if err != nil { - return err - } + skewTime := unsubmittedBlocksTime() + types.RollappPendingSubmissionsSkewBytes.Set(float64(pendingBytes.Load())) types.RollappPendingSubmissionsSkewBlocks.Set(float64(unsubmittedBlocksNum())) types.RollappPendingSubmissionsSkewTimeHours.Set(float64(skewTime.Hours())) @@ -115,10 +110,8 @@ func SubmitLoopInner( for { done := ctx.Err() != nil nothingToSubmit := pending == 0 - skewTime, err := unsubmittedBlocksTime() - if err != nil { - return err - } + skewTime := unsubmittedBlocksTime() + lastSubmissionIsRecent := skewTime < maxBatchTime maxDataNotExceeded := pending <= maxBatchBytes if done || nothingToSubmit || (lastSubmissionIsRecent && maxDataNotExceeded) { @@ -294,16 +287,16 @@ func (m *Manager) GetUnsubmittedBlocks() uint64 { return m.State.Height() - m.LastSettlementHeight.Load() } -func (m *Manager) GetTimeSkew() (time.Duration, error) { +func (m *Manager) GetTimeSkew() time.Duration { currentBlock, err := m.Store.LoadBlock(m.State.Height()) if err != nil { - return time.Duration(0), err + return time.Duration(0) } lastSubmittedBlock, err := m.Store.LoadBlock(m.LastSubmittedHeight.Load()) if err != nil { - return time.Duration(0), err + return time.Duration(0) } - return currentBlock.Header.GetTimestamp().Sub(lastSubmittedBlock.Header.GetTimestamp()), nil + return currentBlock.Header.GetTimestamp().Sub(lastSubmittedBlock.Header.GetTimestamp()) } diff --git a/block/submit_loop_test.go b/block/submit_loop_test.go index c2f526300..c687430a2 100644 --- a/block/submit_loop_test.go +++ b/block/submit_loop_test.go @@ -114,8 +114,8 @@ func testSubmitLoopInner( return pendingBlocks.Load() } - skewTime := func() (time.Duration, error) { - return 1 * time.Hour, nil + skewTime := func() time.Duration { + return time.Duration(0) } block.SubmitLoopInner(ctx, log.NewNopLogger(), producedBytesC, args.batchSkew, accumulatedBlocks, skewTime, args.maxTime, args.batchBytes, submitBatch) diff --git a/block/submit_test.go b/block/submit_test.go index bcdd37772..f07d16a45 100644 --- a/block/submit_test.go +++ b/block/submit_test.go @@ -248,7 +248,7 @@ func TestSubmissionByTime(t *testing.T) { managerConfig := config.BlockManagerConfig{ BlockTime: blockTime, MaxIdleTime: 0, - BatchSkew: 10, + BatchSkew: 24 * time.Hour, BatchSubmitTime: submitTimeout, BatchSubmitBytes: 1000, } diff --git a/config/config_test.go b/config/config_test.go index f2eea6fd2..ff9ffd7a6 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -187,7 +187,7 @@ func fullNodeConfig() config.NodeConfig { MaxIdleTime: 20 * time.Second, MaxProofTime: 20 * time.Second, BatchSubmitTime: 20 * time.Second, - BatchSkew: 10, + BatchSkew: 24 * time.Hour, BatchSubmitBytes: 10000, }, DAConfig: "da-config", diff --git a/config/defaults.go b/config/defaults.go index 4342be555..c90956f3a 100644 --- a/config/defaults.go +++ b/config/defaults.go @@ -26,7 +26,7 @@ func DefaultConfig(home string) *NodeConfig { MaxIdleTime: 3600 * time.Second, MaxProofTime: 100 * time.Second, BatchSubmitTime: 3600 * time.Second, - BatchSkew: 10, + BatchSkew: 1 * time.Hour, BatchSubmitBytes: 500000, }, SettlementLayer: "mock", diff --git a/node/node_test.go b/node/node_test.go index 57aecf762..ce1103ae5 100644 --- a/node/node_test.go +++ b/node/node_test.go @@ -78,7 +78,7 @@ func TestMempoolDirectly(t *testing.T) { BlockTime: 1 * time.Second, BatchSubmitTime: 60 * time.Second, BatchSubmitBytes: 100000, - BatchSkew: 10, + BatchSkew: 24 * time.Hour, }, DAConfig: "", SettlementLayer: "mock", diff --git a/rpc/client/client_test.go b/rpc/client/client_test.go index afb1a915c..f8eca6c0c 100644 --- a/rpc/client/client_test.go +++ b/rpc/client/client_test.go @@ -108,7 +108,7 @@ func TestGenesisChunked(t *testing.T) { BlockTime: 100 * time.Millisecond, BatchSubmitTime: 60 * time.Second, BatchSubmitBytes: 1000, - BatchSkew: 10, + BatchSkew: 24 * time.Hour, }, DAConfig: "", SettlementLayer: "mock", @@ -856,7 +856,7 @@ func TestValidatorSetHandling(t *testing.T) { BlockTime: 10 * time.Millisecond, BatchSubmitTime: 60 * time.Second, BatchSubmitBytes: 1000, - BatchSkew: 10, + BatchSkew: 24 * time.Hour, }, SettlementConfig: settlement.Config{ ProposerPubKey: hex.EncodeToString(proposerPubKeyBytes), @@ -1018,7 +1018,7 @@ func getRPCInternal(t *testing.T, sequencer bool) (*tmmocks.MockApplication, *cl BlockTime: 100 * time.Millisecond, BatchSubmitTime: 60 * time.Second, BatchSubmitBytes: 1000, - BatchSkew: 10, + BatchSkew: 24 * time.Hour, }, DAConfig: "", SettlementLayer: "mock", @@ -1124,7 +1124,7 @@ func TestMempool2Nodes(t *testing.T) { BlockTime: 100 * time.Millisecond, BatchSubmitTime: 60 * time.Second, BatchSubmitBytes: 1000, - BatchSkew: 10, + BatchSkew: 24 * time.Hour, }, MempoolConfig: *tmcfg.DefaultMempoolConfig(), }, key1, signingKey1, proxy.NewLocalClientCreator(app), genesis, "", log.TestingLogger(), mempool.NopMetrics()) @@ -1140,7 +1140,7 @@ func TestMempool2Nodes(t *testing.T) { BlockTime: 100 * time.Millisecond, BatchSubmitTime: 60 * time.Second, BatchSubmitBytes: 1000, - BatchSkew: 10, + BatchSkew: 24 * time.Hour, }, P2PConfig: config.P2PConfig{ ListenAddress: "/ip4/127.0.0.1/tcp/9002", diff --git a/rpc/json/service_test.go b/rpc/json/service_test.go index 41500d1ad..deadd025a 100644 --- a/rpc/json/service_test.go +++ b/rpc/json/service_test.go @@ -317,7 +317,7 @@ func getRPC(t *testing.T) (*tmmocks.MockApplication, *client.Client) { BlockManagerConfig: config.BlockManagerConfig{ BlockTime: 1 * time.Second, MaxIdleTime: 0, - BatchSkew: 10, + BatchSkew: 24 * time.Hour, BatchSubmitTime: 30 * time.Minute, BatchSubmitBytes: 1000, }, diff --git a/testutil/block.go b/testutil/block.go index 0080bab7a..bbfee679f 100644 --- a/testutil/block.go +++ b/testutil/block.go @@ -171,7 +171,7 @@ func GetManagerConfig() config.BlockManagerConfig { BlockTime: 100 * time.Millisecond, BatchSubmitBytes: 1000000, BatchSubmitTime: 30 * time.Minute, - BatchSkew: 10, + BatchSkew: 24 * time.Hour, } } diff --git a/testutil/node.go b/testutil/node.go index 2c8d88d0c..7c66f0181 100644 --- a/testutil/node.go +++ b/testutil/node.go @@ -56,7 +56,7 @@ func CreateNode(isSequencer bool, blockManagerConfig *config.BlockManagerConfig, BlockTime: 100 * time.Millisecond, BatchSubmitTime: 60 * time.Second, BatchSubmitBytes: 1000, - BatchSkew: 10, + BatchSkew: 24 * time.Hour, } } nodeConfig.BlockManagerConfig = *blockManagerConfig