From 3dd3e9a7255221957150aece96b72b1bfb0b9bc8 Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Tue, 19 Nov 2024 23:41:04 +0100 Subject: [PATCH] merge fix --- block/submit_loop_test.go | 23 ++++++++++++-------- rpc/client/client_test.go | 44 +++++++-------------------------------- 2 files changed, 22 insertions(+), 45 deletions(-) diff --git a/block/submit_loop_test.go b/block/submit_loop_test.go index a4a88808b..80cc9ce2f 100644 --- a/block/submit_loop_test.go +++ b/block/submit_loop_test.go @@ -60,10 +60,15 @@ func testSubmitLoopInner( nProducedBytes := atomic.Uint64{} // tracking how many actual bytes have been produced but not submitted so far producedBytesC := make(chan int) // producer sends on here, and can be blocked by not consuming from here - lastSettlementBlockTime := time.Now() - lastBlockTime := time.Now() + lastSettlementBlockTime := atomic.Int64{} + lastBlockTime := atomic.Int64{} + lastSettlementBlockTime.Store(time.Now().UTC().UnixNano()) + lastBlockTime.Store(time.Now().UTC().UnixNano()) + skewTime := func() time.Duration { - return lastBlockTime.Sub(lastSettlementBlockTime) + blockTime := time.Unix(0, lastBlockTime.Load()) + settlementTime := time.Unix(0, lastSettlementBlockTime.Load()) + return blockTime.Sub(settlementTime) } go func() { // simulate block production go func() { // another thread to check system properties @@ -93,7 +98,8 @@ func testSubmitLoopInner( nBytes := rand.Intn(args.produceBytes) // simulate block production nProducedBytes.Add(uint64(nBytes)) producedBytesC <- nBytes - lastBlockTime = time.Now() + lastBlockTime.Store(time.Now().UTC().UnixNano()) + pendingBlocks.Add(1) // increase pending blocks to be submitted counter } }() @@ -106,8 +112,7 @@ func testSubmitLoopInner( consumed := rand.Intn(int(maxSize)) nProducedBytes.Add(^uint64(consumed - 1)) // subtract pendingBlocks.Store(0) // no pending blocks to be submitted - lastSettlementBlockTime = lastBlockTime - + lastSettlementBlockTime.Store(lastBlockTime.Load()) return consumed, nil } accumulatedBlocks := func() uint64 { @@ -125,7 +130,7 @@ func TestSubmitLoopFastProducerHaltingSubmitter(t *testing.T) { testSubmitLoop( t, testArgs{ - nParallel: 1, + nParallel: 50, testDuration: 2 * time.Second, batchSkew: 100 * time.Millisecond, skewMargin: 10 * time.Millisecond, @@ -136,7 +141,7 @@ func TestSubmitLoopFastProducerHaltingSubmitter(t *testing.T) { produceTime: 2 * time.Millisecond, // a relatively long possibility of the submitter halting // tests the case where we need to stop the producer getting too far ahead - submissionHaltTime: 200 * time.Millisecond, + submissionHaltTime: 150 * time.Millisecond, submissionHaltProbability: 0.05, }, ) @@ -148,7 +153,7 @@ func TestSubmitLoopTimer(t *testing.T) { t, testArgs{ nParallel: 50, - testDuration: 2 * time.Second, + testDuration: 4 * time.Second, batchSkew: 100 * time.Millisecond, skewMargin: 10 * time.Millisecond, batchBytes: 100, diff --git a/rpc/client/client_test.go b/rpc/client/client_test.go index c51b91d53..a86c43ebf 100644 --- a/rpc/client/client_test.go +++ b/rpc/client/client_test.go @@ -106,10 +106,10 @@ func TestGenesisChunked(t *testing.T) { }, RPC: config.RPCConfig{}, BlockManagerConfig: config.BlockManagerConfig{ - BlockTime: 100 * time.Millisecond, - BatchSubmitTime: 60 * time.Second, - BatchSubmitBytes: 1000, - MaxBatchSkewTime: 24 * time.Hour, + BlockTime: 100 * time.Millisecond, + BatchSubmitTime: 60 * time.Second, + BatchSubmitBytes: 1000, + MaxBatchSkewTime: 24 * time.Hour, SequencerSetUpdateInterval: config.DefaultSequencerSetUpdateInterval, }, DAConfig: "", @@ -855,18 +855,11 @@ func TestValidatorSetHandling(t *testing.T) { BlockSyncRequestIntervalTime: 30 * time.Second, }, BlockManagerConfig: config.BlockManagerConfig{ -<<<<<<< HEAD - BlockTime: 10 * time.Millisecond, - BatchSubmitTime: 60 * time.Second, - BatchSubmitBytes: 1000, - MaxBatchSkewTime: 24 * time.Hour, -======= BlockTime: 10 * time.Millisecond, BatchSubmitTime: 60 * time.Second, BatchSubmitBytes: 1000, - BatchSkew: 10, + MaxBatchSkewTime: 24 * time.Hour, SequencerSetUpdateInterval: config.DefaultSequencerSetUpdateInterval, ->>>>>>> main }, SettlementConfig: settlement.Config{ ProposerPubKey: hex.EncodeToString(proposerPubKeyBytes), @@ -1026,18 +1019,11 @@ func getRPCInternal(t *testing.T, sequencer bool) (*tmmocks.MockApplication, *cl RPC: config.RPCConfig{}, MempoolConfig: *tmcfg.DefaultMempoolConfig(), BlockManagerConfig: config.BlockManagerConfig{ -<<<<<<< HEAD - BlockTime: 100 * time.Millisecond, - BatchSubmitTime: 60 * time.Second, - BatchSubmitBytes: 1000, - MaxBatchSkewTime: 24 * time.Hour, -======= BlockTime: 100 * time.Millisecond, BatchSubmitTime: 60 * time.Second, BatchSubmitBytes: 1000, - BatchSkew: 10, + MaxBatchSkewTime: 24 * time.Hour, SequencerSetUpdateInterval: config.DefaultSequencerSetUpdateInterval, ->>>>>>> main }, DAConfig: "", SettlementLayer: "mock", @@ -1140,18 +1126,11 @@ func TestMempool2Nodes(t *testing.T) { BlockSyncRequestIntervalTime: 30 * time.Second, }, BlockManagerConfig: config.BlockManagerConfig{ -<<<<<<< HEAD - BlockTime: 100 * time.Millisecond, - BatchSubmitTime: 60 * time.Second, - BatchSubmitBytes: 1000, - MaxBatchSkewTime: 24 * time.Hour, -======= BlockTime: 100 * time.Millisecond, BatchSubmitTime: 60 * time.Second, BatchSubmitBytes: 1000, - BatchSkew: 10, + MaxBatchSkewTime: 24 * time.Hour, SequencerSetUpdateInterval: config.DefaultSequencerSetUpdateInterval, ->>>>>>> main }, MempoolConfig: *tmcfg.DefaultMempoolConfig(), }, key1, signingKey1, proxy.NewLocalClientCreator(app), genesis, "", log.TestingLogger(), mempool.NopMetrics()) @@ -1164,18 +1143,11 @@ func TestMempool2Nodes(t *testing.T) { ProposerPubKey: hex.EncodeToString(proposerPK), }, BlockManagerConfig: config.BlockManagerConfig{ -<<<<<<< HEAD - BlockTime: 100 * time.Millisecond, - BatchSubmitTime: 60 * time.Second, - BatchSubmitBytes: 1000, - MaxBatchSkewTime: 24 * time.Hour, -======= BlockTime: 100 * time.Millisecond, BatchSubmitTime: 60 * time.Second, BatchSubmitBytes: 1000, - BatchSkew: 10, + MaxBatchSkewTime: 24 * time.Hour, SequencerSetUpdateInterval: config.DefaultSequencerSetUpdateInterval, ->>>>>>> main }, P2PConfig: config.P2PConfig{ ListenAddress: "/ip4/127.0.0.1/tcp/9002",