Skip to content

Commit

Permalink
test fix
Browse files Browse the repository at this point in the history
  • Loading branch information
srene committed Nov 8, 2024
1 parent 2f66f5e commit 3e92814
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 31 deletions.
27 changes: 10 additions & 17 deletions block/submit.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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
Expand Down Expand Up @@ -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()))
Expand All @@ -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) {
Expand Down Expand Up @@ -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())

}

Expand Down
4 changes: 2 additions & 2 deletions block/submit_loop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion block/submit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
2 changes: 1 addition & 1 deletion config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion config/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion node/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
10 changes: 5 additions & 5 deletions rpc/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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())
Expand All @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion rpc/json/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down
2 changes: 1 addition & 1 deletion testutil/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func GetManagerConfig() config.BlockManagerConfig {
BlockTime: 100 * time.Millisecond,
BatchSubmitBytes: 1000000,
BatchSubmitTime: 30 * time.Minute,
BatchSkew: 10,
BatchSkew: 24 * time.Hour,
}
}

Expand Down
2 changes: 1 addition & 1 deletion testutil/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3e92814

Please sign in to comment.