Skip to content

Commit

Permalink
merge fix
Browse files Browse the repository at this point in the history
  • Loading branch information
srene committed Nov 19, 2024
1 parent 4405eb5 commit 3dd3e9a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 45 deletions.
23 changes: 14 additions & 9 deletions block/submit_loop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
}()
Expand All @@ -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 {
Expand All @@ -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,
Expand All @@ -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,
},
)
Expand All @@ -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,
Expand Down
44 changes: 8 additions & 36 deletions rpc/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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: "",
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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())
Expand All @@ -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",
Expand Down

0 comments on commit 3dd3e9a

Please sign in to comment.