Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
afadf61
chore: refine some trivals
2020xibao Mar 20, 2025
cf07370
chore: fix batcher ut
2020xibao Mar 20, 2025
27904cb
chore: fix node ut
2020xibao Mar 21, 2025
955c756
chore: try fix node ut
2020xibao Mar 21, 2025
092e3c4
chore: try fix node ut
2020xibao Mar 21, 2025
aee7876
chore: try fix node ut
2020xibao Mar 21, 2025
d1390b3
chore: try fix node ut
2020xibao Mar 21, 2025
ed05d6f
chore: try fix node ut
2020xibao Mar 21, 2025
a970e48
chore: try fix node ut
2020xibao Mar 21, 2025
87a4f2a
chore: try fix ut
2020xibao Mar 21, 2025
59d3053
chore: try fix ut
2020xibao Mar 21, 2025
2b5ef70
chore: try fix node ut
2020xibao Mar 21, 2025
68536da
chore: try fix node ut
2020xibao Mar 21, 2025
6760da8
chore: try fix node ut
2020xibao Mar 21, 2025
86ac43b
chore: try fix node ut
2020xibao Mar 21, 2025
e9d9dcd
chore: try fix node ut
2020xibao Mar 21, 2025
e2df7d6
chore: try fix node ut
2020xibao Mar 21, 2025
4033bf5
chore: try fix node ut
2020xibao Mar 21, 2025
cb0b19b
chore: try fix node ut
2020xibao Mar 21, 2025
0051b25
chore: try fix node ut
2020xibao Mar 21, 2025
9ccd7a5
chore: try fix node ut
2020xibao Mar 21, 2025
b2202d0
fix: debug batches ut
2020xibao Mar 21, 2025
9d75b4b
fix: debug batches ut
2020xibao Mar 21, 2025
15db178
chore: debug batch ut
2020xibao Mar 21, 2025
8c98752
chore: update ci
2020xibao Mar 21, 2025
b335c48
chore: try fix batch ut
2020xibao Mar 21, 2025
8cb3a2f
chore: try fix batch ut
2020xibao Mar 21, 2025
1ed03f3
chore: try fix batch ut
2020xibao Mar 21, 2025
05e0a11
chore: try fix batch ut
2020xibao Mar 21, 2025
045af1d
chore: try fix batch ut
2020xibao Mar 21, 2025
d3d4c2e
chore: try fix batch ut
2020xibao Mar 21, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ jobs:

op-node-test:
runs-on: ubuntu-latest
needs: op-node-lint

steps:
- name: Check out code
Expand Down
2 changes: 1 addition & 1 deletion op-batcher/batcher/channel_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ func ChannelBuilder_InputBytes(t *testing.T, batchType uint) {
require.NoError(err)
err = spanBatch.AppendSingularBatch(singularBatch, l1Info.SequenceNumber)
require.NoError(err)
rawSpanBatch, err := spanBatch.ToRawSpanBatch()
rawSpanBatch, err := spanBatch.ToRawSpanBatch(&defaultTestRollupConfig)
require.NoError(err)
batch := derive.NewBatchData(rawSpanBatch)
var buf bytes.Buffer
Expand Down
2 changes: 1 addition & 1 deletion op-chain-ops/genesis/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ func (d *DeployConfig) RollupConfig(l1StartBlock *types.Block, l2GenesisBlockHas
GasLimit: uint64(d.L2GenesisBlockGasLimit),
},
},
//BlockTime: d.L2BlockTime,
BlockTime: d.L2BlockTime,
MaxSequencerDrift: d.MaxSequencerDrift,
SeqWindowSize: d.SequencerWindowSize,
ChannelTimeout: d.ChannelTimeout,
Expand Down
16 changes: 11 additions & 5 deletions op-node/benchmarks/batchbuilding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"time"

"github.com/ethereum-optimism/optimism/op-batcher/compressor"
"github.com/ethereum-optimism/optimism/op-node/rollup"
"github.com/ethereum-optimism/optimism/op-node/rollup/derive"
"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -171,13 +172,15 @@ func BenchmarkFinalBatchChannelOut(b *testing.B) {
cout, _ := channelOutByType(b, tc.BatchType, tc.cd)
// add all but the final batch to the channel out
for i := 0; i < tc.BatchCount-1; i++ {
err := cout.AddSingularBatch(batches[i], 0)
var cfg rollup.Config
err := cout.AddSingularBatch(&cfg, batches[i], 0)
require.NoError(b, err)
}
// measure the time to add the final batch
b.StartTimer()
// add the final batch to the channel out
err := cout.AddSingularBatch(batches[tc.BatchCount-1], 0)
var cfg rollup.Config
err := cout.AddSingularBatch(&cfg, batches[tc.BatchCount-1], 0)
require.NoError(b, err)
}
})
Expand Down Expand Up @@ -233,7 +236,8 @@ func BenchmarkIncremental(b *testing.B) {
}
b.StartTimer()
for i := 0; i < tc.BatchCount; i++ {
err := cout.AddSingularBatch(batches[i], 0)
var cfg rollup.Config
err := cout.AddSingularBatch(&cfg, batches[i], 0)
if err != nil {
done = true
return
Expand Down Expand Up @@ -297,7 +301,8 @@ func BenchmarkAllBatchesChannelOut(b *testing.B) {
b.StartTimer()
// add all batches to the channel out
for i := 0; i < tc.BatchCount; i++ {
err := cout.AddSingularBatch(batches[i], 0)
var cfg rollup.Config
err := cout.AddSingularBatch(&cfg, batches[i], 0)
require.NoError(b, err)
}
}
Expand Down Expand Up @@ -347,7 +352,8 @@ func BenchmarkGetRawSpanBatch(b *testing.B) {
require.NoError(b, err)
}
b.StartTimer()
_, err := spanBatch.ToRawSpanBatch()
var cfg rollup.Config
_, err := spanBatch.ToRawSpanBatch(&cfg)
require.NoError(b, err)
}
})
Expand Down
6 changes: 3 additions & 3 deletions op-node/chaincfg/chains.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ var OPBNBMainnet = rollup.Config{
GasLimit: 100000000,
},
},
//BlockTime: 1,
BlockTime: 1,
MaxSequencerDrift: 600,
SeqWindowSize: 14400,
ChannelTimeout: 1200,
Expand Down Expand Up @@ -163,7 +163,7 @@ var OPBNBTestnet = rollup.Config{
GasLimit: 100000000,
},
},
//BlockTime: 1,
BlockTime: 1,
MaxSequencerDrift: 600,
SeqWindowSize: 14400,
ChannelTimeout: 1200,
Expand Down Expand Up @@ -199,7 +199,7 @@ var OPBNBQANet = rollup.Config{
GasLimit: 100000000,
},
},
//BlockTime: 1,
BlockTime: 1,
MaxSequencerDrift: 600,
SeqWindowSize: 14400,
ChannelTimeout: 1200,
Expand Down
2 changes: 1 addition & 1 deletion op-node/cmd/batch_decoder/reassemble/reassemble.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func processFrames(cfg Config, rollupCfg *rollup.Config, id derive.ChannelID, fr
// singularBatch will be nil when errored
batches = append(batches, singularBatch)
case derive.SpanBatchType:
spanBatch, err := derive.DeriveSpanBatch(batchData, cfg.L2BlockTime, cfg.L2GenesisTime, cfg.L2ChainID)
spanBatch, err := derive.DeriveSpanBatch(batchData, rollupCfg, cfg.L2GenesisTime, cfg.L2ChainID)
if err != nil {
invalidBatches = true
fmt.Printf("Error deriving spanBatch from batchData for channel %v. Err: %v\n", id.String(), err)
Expand Down
2 changes: 1 addition & 1 deletion op-node/p2p/app_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type ApplicationScoreParams struct {
}

func LightApplicationScoreParams(cfg *rollup.Config) ApplicationScoreParams {
slot := time.Duration(rollup.VoltBlockTime) * time.Millisecond
slot := time.Duration(cfg.BlockTime) * time.Second
if slot == 0 {
slot = 2 * time.Second
}
Expand Down
2 changes: 1 addition & 1 deletion op-node/p2p/peer_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func ScoreDecay(duration time.Duration, slot time.Duration) float64 {
//
// [PeerScoreParams]: https://pkg.go.dev/github.com/libp2p/go-libp2p-pubsub@v0.8.1#PeerScoreParams
func LightPeerScoreParams(cfg *rollup.Config) pubsub.PeerScoreParams {
slot := time.Duration(rollup.VoltBlockTime) * time.Millisecond
slot := time.Duration(cfg.BlockTime) * time.Second
if slot == 0 {
slot = 2 * time.Second
}
Expand Down
2 changes: 1 addition & 1 deletion op-node/rollup/chain_spec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var testConfig = Config{
GasLimit: 30_000_000,
},
},
BlockTime: 2000,
BlockTime: 2,
MaxSequencerDrift: 600,
SeqWindowSize: 3600,
ChannelTimeout: 300,
Expand Down
46 changes: 23 additions & 23 deletions op-node/rollup/derive/batch_queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func b(chainId *big.Int, timestamp uint64, epoch eth.L1BlockRef) *SingularBatch
txData, _ := tx.MarshalBinary()
return &SingularBatch{
ParentHash: mockHash(timestamp-2, 2),
Timestamp: timestamp * 1000,
Timestamp: timestamp * 1000, // after derive, this is millisecond timestamp, mock ut
EpochNum: rollup.Epoch(epoch.Number),
EpochHash: epoch.Hash,
Transactions: []hexutil.Bytes{txData},
Expand Down Expand Up @@ -115,7 +115,7 @@ func singularBatchToBlockRef(t *testing.T, batch *SingularBatch, blockNumber uin
Hash: mockHash(batch.Timestamp/1000, 2),
Number: blockNumber,
ParentHash: batch.ParentHash,
Time: batch.Timestamp,
Time: batch.Timestamp / 1000, // second timestamp
L1Origin: eth.BlockID{Hash: batch.EpochHash, Number: uint64(batch.EpochNum)},
}
}
Expand Down Expand Up @@ -242,7 +242,7 @@ func BatchQueueEager(t *testing.T, batchType int) {
Genesis: rollup.Genesis{
L2Time: 10,
},
BlockTime: 2000,
BlockTime: 2,
MaxSequencerDrift: 600,
SeqWindowSize: 30,
DeltaTime: getDeltaTime(batchType),
Expand Down Expand Up @@ -295,7 +295,7 @@ func BatchQueueEager(t *testing.T, batchType int) {
} else {
require.Equal(t, expectedOutputBatches[i], b)
safeHead.Number += 1
safeHead.Time += cfg.SecondBlockInterval()
safeHead.Time += cfg.BlockTime
safeHead.Hash = mockHash(b.Timestamp/1000, 2)
safeHead.L1Origin = b.Epoch()
}
Expand All @@ -320,7 +320,7 @@ func BatchQueueInvalidInternalAdvance(t *testing.T, batchType int) {
Genesis: rollup.Genesis{
L2Time: 10,
},
BlockTime: 2000,
BlockTime: 2,
MaxSequencerDrift: 600,
SeqWindowSize: 2,
DeltaTime: getDeltaTime(batchType),
Expand Down Expand Up @@ -396,11 +396,11 @@ func BatchQueueInvalidInternalAdvance(t *testing.T, batchType int) {
b, _, e = bq.NextBatch(context.Background(), safeHead)
require.Nil(t, e)
require.NotNil(t, b)
require.Equal(t, (safeHead.Time+2)*1000, b.Timestamp)
require.Equal(t, safeHead.Time+2, b.Timestamp/1000)
require.Equal(t, rollup.Epoch(1), b.EpochNum)
safeHead.Number += 1
safeHead.Time += 2
safeHead.Hash = mockHash(b.Timestamp, 2)
safeHead.Hash = mockHash(b.Timestamp/1000, 2)
safeHead.L1Origin = b.Epoch()
b, _, e = bq.NextBatch(context.Background(), safeHead)
require.ErrorIs(t, e, io.EOF)
Expand All @@ -412,10 +412,10 @@ func BatchQueueInvalidInternalAdvance(t *testing.T, batchType int) {
require.Nil(t, e)
require.NotNil(t, b)
require.Equal(t, rollup.Epoch(2), b.EpochNum)
require.Equal(t, (safeHead.Time+2)*1000, b.Timestamp)
require.Equal(t, safeHead.Time+2, b.Timestamp/1000)
safeHead.Number += 1
safeHead.Time += 2
safeHead.Hash = mockHash(b.Timestamp, 2)
safeHead.Hash = mockHash(b.Timestamp/1000, 2)
safeHead.L1Origin = b.Epoch()
b, _, e = bq.NextBatch(context.Background(), safeHead)
require.ErrorIs(t, e, io.EOF)
Expand All @@ -440,7 +440,7 @@ func BatchQueueMissing(t *testing.T, batchType int) {
Genesis: rollup.Genesis{
L2Time: 10,
},
BlockTime: 2000,
BlockTime: 2,
MaxSequencerDrift: 600,
SeqWindowSize: 2,
DeltaTime: getDeltaTime(batchType),
Expand Down Expand Up @@ -498,7 +498,7 @@ func BatchQueueMissing(t *testing.T, batchType int) {
// Check for a generated batch at t = 12
b, _, e = bq.NextBatch(context.Background(), safeHead)
require.Nil(t, e)
require.Equal(t, b.Timestamp, uint64(12000))
require.Equal(t, b.Timestamp/1000, uint64(12))
require.Empty(t, b.Transactions)
require.Equal(t, rollup.Epoch(0), b.EpochNum)
safeHead.Number += 1
Expand All @@ -508,7 +508,7 @@ func BatchQueueMissing(t *testing.T, batchType int) {
// Check for generated batch at t = 14
b, _, e = bq.NextBatch(context.Background(), safeHead)
require.Nil(t, e)
require.Equal(t, b.Timestamp, uint64(14000))
require.Equal(t, b.Timestamp/1000, uint64(14))
require.Empty(t, b.Transactions)
require.Equal(t, rollup.Epoch(0), b.EpochNum)
safeHead.Number += 1
Expand All @@ -534,7 +534,7 @@ func BatchQueueMissing(t *testing.T, batchType int) {
require.Equal(t, e, io.EOF)
b, _, e = bq.NextBatch(context.Background(), safeHead)
require.Nil(t, e)
require.Equal(t, b.Timestamp, uint64(18000))
require.Equal(t, b.Timestamp/1000, uint64(18))
require.Empty(t, b.Transactions)
require.Equal(t, rollup.Epoch(1), b.EpochNum)
}
Expand All @@ -557,7 +557,7 @@ func BatchQueueAdvancedEpoch(t *testing.T, batchType int) {
Genesis: rollup.Genesis{
L2Time: 10,
},
BlockTime: 2000,
BlockTime: 2,
MaxSequencerDrift: 600,
SeqWindowSize: 30,
DeltaTime: getDeltaTime(batchType),
Expand Down Expand Up @@ -620,7 +620,7 @@ func BatchQueueAdvancedEpoch(t *testing.T, batchType int) {
} else {
require.Equal(t, expectedOutput, b)
safeHead.Number += 1
safeHead.Time += cfg.SecondBlockInterval()
safeHead.Time += cfg.BlockTime
safeHead.Hash = mockHash(b.Timestamp/1000, 2)
safeHead.L1Origin = b.Epoch()
}
Expand All @@ -644,7 +644,7 @@ func BatchQueueShuffle(t *testing.T, batchType int) {
Genesis: rollup.Genesis{
L2Time: 10,
},
BlockTime: 2000,
BlockTime: 2,
MaxSequencerDrift: 600,
SeqWindowSize: 30,
DeltaTime: getDeltaTime(batchType),
Expand Down Expand Up @@ -719,7 +719,7 @@ func BatchQueueShuffle(t *testing.T, batchType int) {
} else {
require.Equal(t, expectedOutput, b)
safeHead.Number += 1
safeHead.Time += cfg.SecondBlockInterval()
safeHead.Time += cfg.BlockTime
safeHead.Hash = mockHash(b.Timestamp/1000, 2)
safeHead.L1Origin = b.Epoch()
}
Expand All @@ -742,7 +742,7 @@ func TestBatchQueueOverlappingSpanBatch(t *testing.T) {
Genesis: rollup.Genesis{
L2Time: 10,
},
BlockTime: 2000,
BlockTime: 2,
MaxSequencerDrift: 600,
SeqWindowSize: 30,
DeltaTime: getDeltaTime(SpanBatchType),
Expand Down Expand Up @@ -822,7 +822,7 @@ func TestBatchQueueOverlappingSpanBatch(t *testing.T) {
} else {
require.Equal(t, expectedOutputBatches[i], b)
safeHead.Number += 1
safeHead.Time += cfg.SecondBlockInterval()
safeHead.Time += cfg.BlockTime
safeHead.Hash = mockHash(b.Timestamp/1000, 2)
safeHead.L1Origin = b.Epoch()
}
Expand All @@ -847,7 +847,7 @@ func TestBatchQueueComplex(t *testing.T) {
Genesis: rollup.Genesis{
L2Time: 10,
},
BlockTime: 2000,
BlockTime: 2,
MaxSequencerDrift: 600,
SeqWindowSize: 30,
DeltaTime: getDeltaTime(SpanBatchType),
Expand Down Expand Up @@ -940,7 +940,7 @@ func TestBatchQueueComplex(t *testing.T) {
} else {
require.Equal(t, expectedOutput, b)
safeHead.Number += 1
safeHead.Time += cfg.SecondBlockInterval()
safeHead.Time += cfg.BlockTime
safeHead.Hash = mockHash(b.Timestamp/1000, 2)
safeHead.L1Origin = b.Epoch()
}
Expand All @@ -965,7 +965,7 @@ func TestBatchQueueResetSpan(t *testing.T) {
Genesis: rollup.Genesis{
L2Time: 10,
},
BlockTime: 2000,
BlockTime: 2,
MaxSequencerDrift: 600,
SeqWindowSize: 30,
DeltaTime: getDeltaTime(SpanBatchType),
Expand Down Expand Up @@ -998,7 +998,7 @@ func TestBatchQueueResetSpan(t *testing.T) {

// This NextBatch() will return the second singular batch.
safeHead.Number += 1
safeHead.Time += cfg.SecondBlockInterval()
safeHead.Time += cfg.BlockTime
safeHead.Hash = mockHash(nextBatch.Timestamp/1000, 2)
safeHead.L1Origin = nextBatch.Epoch()
nextBatch, _, err = bq.NextBatch(context.Background(), safeHead)
Expand Down
12 changes: 8 additions & 4 deletions op-node/rollup/derive/batch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func RandomRawSpanBatch(rng *rand.Rand, chainId *big.Int) *RawSpanBatch {

func RandomValidConsecutiveSingularBatches(rng *rand.Rand, chainID *big.Int) []*SingularBatch {
blockCount := 2 + rng.Intn(128)
l2BlockTime := uint64(2) * 1000 // ms
l2BlockTime := uint64(2)

var singularBatches []*SingularBatch
for i := 0; i < blockCount; i++ {
Expand All @@ -87,7 +87,7 @@ func RandomValidConsecutiveSingularBatches(rng *rand.Rand, chainID *big.Int) []*
}
l1BlockNum := rng.Uint64()
// make sure oldest timestamp is large enough
singularBatches[0].Timestamp += 256 * 1000 // ms
singularBatches[0].Timestamp += 256
for i := 0; i < blockCount; i++ {
originChangedBit := rng.Intn(2)
if originChangedBit == 1 {
Expand Down Expand Up @@ -160,7 +160,9 @@ func TestBatchRoundTrip(t *testing.T) {
err = dec.UnmarshalBinary(enc)
require.NoError(t, err)
if dec.GetBatchType() == SpanBatchType {
_, err := DeriveSpanBatch(&dec, blockTime, genesisTimestamp, chainID)
var cfg rollup.Config
cfg.BlockTime = blockTime
_, err := DeriveSpanBatch(&dec, &cfg, genesisTimestamp, chainID)
require.NoError(t, err)
}
require.Equal(t, batch, &dec, "Batch not equal test case %v", i)
Expand Down Expand Up @@ -208,7 +210,9 @@ func TestBatchRoundTripRLP(t *testing.T) {
err = dec.DecodeRLP(s)
require.NoError(t, err)
if dec.GetBatchType() == SpanBatchType {
_, err = DeriveSpanBatch(&dec, blockTime, genesisTimestamp, chainID)
var cfg rollup.Config
cfg.BlockTime = blockTime
_, err = DeriveSpanBatch(&dec, &cfg, genesisTimestamp, chainID)
require.NoError(t, err)
}
require.Equal(t, batch, &dec, "Batch not equal test case %v", i)
Expand Down
Loading