Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
2b91cc6d
Unverified
Commit
2b91cc6d
authored
Jun 29, 2022
by
protolambda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
batch Epoch() method, improve logging of batch filter
parent
df4d4eea
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
4 deletions
+16
-4
batch.go
op-node/rollup/derive/batch.go
+6
-0
batches.go
op-node/rollup/derive/batches.go
+10
-4
No files found.
op-node/rollup/derive/batch.go
View file @
2b91cc6d
...
@@ -7,6 +7,8 @@ import (
...
@@ -7,6 +7,8 @@ import (
"io"
"io"
"sync"
"sync"
"github.com/ethereum-optimism/optimism/op-node/eth"
"github.com/ethereum-optimism/optimism/op-node/rollup"
"github.com/ethereum-optimism/optimism/op-node/rollup"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/common/hexutil"
...
@@ -45,6 +47,10 @@ type BatchData struct {
...
@@ -45,6 +47,10 @@ type BatchData struct {
// batches may contain additional data with new upgrades
// batches may contain additional data with new upgrades
}
}
func
(
b
*
BatchV1
)
Epoch
()
eth
.
BlockID
{
return
eth
.
BlockID
{
Hash
:
b
.
EpochHash
,
Number
:
uint64
(
b
.
EpochNum
)}
}
// EncodeRLP implements rlp.Encoder
// EncodeRLP implements rlp.Encoder
func
(
b
*
BatchData
)
EncodeRLP
(
w
io
.
Writer
)
error
{
func
(
b
*
BatchData
)
EncodeRLP
(
w
io
.
Writer
)
error
{
buf
:=
encodeBufferPool
.
Get
()
.
(
*
bytes
.
Buffer
)
buf
:=
encodeBufferPool
.
Get
()
.
(
*
bytes
.
Buffer
)
...
...
op-node/rollup/derive/batches.go
View file @
2b91cc6d
...
@@ -17,15 +17,17 @@ func FilterBatches(log log.Logger, config *rollup.Config, epoch eth.BlockID, min
...
@@ -17,15 +17,17 @@ func FilterBatches(log log.Logger, config *rollup.Config, epoch eth.BlockID, min
for
_
,
batch
:=
range
batches
{
for
_
,
batch
:=
range
batches
{
if
err
:=
ValidBatch
(
batch
,
config
,
epoch
,
minL2Time
,
maxL2Time
);
err
!=
nil
{
if
err
:=
ValidBatch
(
batch
,
config
,
epoch
,
minL2Time
,
maxL2Time
);
err
!=
nil
{
if
err
==
DifferentEpoch
{
if
err
==
DifferentEpoch
{
log
.
Trace
(
"ignoring batch of different epoch"
,
"epoch"
,
batch
.
EpochNum
,
"expected_epoch"
,
epoch
,
"timestamp"
,
batch
.
Timestamp
,
"txs"
,
len
(
batch
.
Transactions
))
log
.
Trace
(
"ignoring batch of different epoch"
,
"expected_epoch"
,
epoch
,
"epoch"
,
batch
.
Epoch
(),
"timestamp"
,
batch
.
Timestamp
,
"txs"
,
len
(
batch
.
Transactions
))
}
else
{
}
else
{
log
.
Warn
(
"filtered batch"
,
"epoch"
,
batch
.
EpochNum
,
"timestamp"
,
batch
.
Timestamp
,
"txs"
,
len
(
batch
.
Transactions
),
"err"
,
err
)
log
.
Warn
(
"filtered batch"
,
"expected_epoch"
,
epoch
,
"min"
,
minL2Time
,
"max"
,
maxL2Time
,
"epoch"
,
batch
.
Epoch
(),
"timestamp"
,
batch
.
Timestamp
,
"txs"
,
len
(
batch
.
Transactions
),
"err"
,
err
)
}
}
continue
continue
}
}
// Check if we have already seen a batch for this L2 block
// Check if we have already seen a batch for this L2 block
if
_
,
ok
:=
uniqueTime
[
batch
.
Timestamp
];
ok
{
if
_
,
ok
:=
uniqueTime
[
batch
.
Timestamp
];
ok
{
log
.
Warn
(
"duplicate batch"
,
"epoch"
,
batch
.
Epoch
Num
,
"timestamp"
,
batch
.
Timestamp
,
"txs"
,
len
(
batch
.
Transactions
))
log
.
Warn
(
"duplicate batch"
,
"epoch"
,
batch
.
Epoch
()
,
"timestamp"
,
batch
.
Timestamp
,
"txs"
,
len
(
batch
.
Transactions
))
// block already exists, batch is duplicate (first batch persists, others are ignored)
// block already exists, batch is duplicate (first batch persists, others are ignored)
continue
continue
}
}
...
@@ -36,11 +38,15 @@ func FilterBatches(log log.Logger, config *rollup.Config, epoch eth.BlockID, min
...
@@ -36,11 +38,15 @@ func FilterBatches(log log.Logger, config *rollup.Config, epoch eth.BlockID, min
}
}
func
ValidBatch
(
batch
*
BatchData
,
config
*
rollup
.
Config
,
epoch
eth
.
BlockID
,
minL2Time
uint64
,
maxL2Time
uint64
)
error
{
func
ValidBatch
(
batch
*
BatchData
,
config
*
rollup
.
Config
,
epoch
eth
.
BlockID
,
minL2Time
uint64
,
maxL2Time
uint64
)
error
{
if
batch
.
EpochNum
!=
rollup
.
Epoch
(
epoch
.
Number
)
||
batch
.
EpochHash
!=
epoch
.
Hash
{
if
batch
.
EpochNum
!=
rollup
.
Epoch
(
epoch
.
Number
)
{
// Batch was tagged for past or future epoch,
// Batch was tagged for past or future epoch,
// i.e. it was included too late or depends on the given L1 block to be processed first.
// i.e. it was included too late or depends on the given L1 block to be processed first.
// This is a very common error, batches may just be buffered for a later epoch.
return
DifferentEpoch
return
DifferentEpoch
}
}
if
batch
.
EpochHash
!=
epoch
.
Hash
{
return
fmt
.
Errorf
(
"batch was meant for alternative L1 chain"
)
}
if
(
batch
.
Timestamp
-
config
.
Genesis
.
L2Time
)
%
config
.
BlockTime
!=
0
{
if
(
batch
.
Timestamp
-
config
.
Genesis
.
L2Time
)
%
config
.
BlockTime
!=
0
{
return
fmt
.
Errorf
(
"bad timestamp %d, not a multiple of the block time"
,
batch
.
Timestamp
)
return
fmt
.
Errorf
(
"bad timestamp %d, not a multiple of the block time"
,
batch
.
Timestamp
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment