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
d975d8a6
Unverified
Commit
d975d8a6
authored
Mar 15, 2023
by
protolambda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-node: support shanghai L1 blockhash input verification
parent
cc106630
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
130 additions
and
28 deletions
+130
-28
fork_test.go
op-e2e/actions/fork_test.go
+53
-0
l1_miner.go
op-e2e/actions/l1_miner.go
+6
-0
types.go
op-node/sources/types.go
+36
-28
types_test.go
op-node/sources/types_test.go
+35
-0
No files found.
op-e2e/actions/fork_test.go
0 → 100644
View file @
d975d8a6
package
actions
import
(
"testing"
"github.com/ethereum/go-ethereum/log"
"github.com/stretchr/testify/require"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils"
"github.com/ethereum-optimism/optimism/op-node/testlog"
)
func
TestShapellaL1Fork
(
gt
*
testing
.
T
)
{
t
:=
NewDefaultTesting
(
gt
)
dp
:=
e2eutils
.
MakeDeployParams
(
t
,
defaultRollupTestParams
)
sd
:=
e2eutils
.
Setup
(
t
,
dp
,
defaultAlloc
)
activation
:=
sd
.
L1Cfg
.
Timestamp
+
24
sd
.
L1Cfg
.
Config
.
ShanghaiTime
=
&
activation
log
:=
testlog
.
Logger
(
t
,
log
.
LvlDebug
)
_
,
_
,
miner
,
sequencer
,
_
,
verifier
,
_
,
batcher
:=
setupReorgTestActors
(
t
,
dp
,
sd
,
log
)
require
.
False
(
t
,
sd
.
L1Cfg
.
Config
.
IsShanghai
(
miner
.
l1Chain
.
CurrentBlock
()
.
Time
()),
"not active yet"
)
// start op-nodes
sequencer
.
ActL2PipelineFull
(
t
)
verifier
.
ActL2PipelineFull
(
t
)
// build empty L1 blocks, crossing the fork boundary
miner
.
ActEmptyBlock
(
t
)
miner
.
ActEmptyBlock
(
t
)
miner
.
ActEmptyBlock
(
t
)
// verify Shanghai is active
l1Head
:=
miner
.
l1Chain
.
CurrentBlock
()
require
.
True
(
t
,
sd
.
L1Cfg
.
Config
.
IsShanghai
(
l1Head
.
Time
()))
// build L2 chain up to and including L2 blocks referencing shanghai L1 blocks
sequencer
.
ActL1HeadSignal
(
t
)
sequencer
.
ActBuildToL1Head
(
t
)
miner
.
ActL1StartBlock
(
12
)(
t
)
batcher
.
ActSubmitAll
(
t
)
miner
.
ActL1IncludeTx
(
batcher
.
batcherAddr
)(
t
)
miner
.
ActL1EndBlock
(
t
)
// sync verifier
verifier
.
ActL1HeadSignal
(
t
)
verifier
.
ActL2PipelineFull
(
t
)
// verify verifier accepted shanghai L1 inputs
require
.
Equal
(
t
,
l1Head
.
Hash
(),
verifier
.
SyncStatus
()
.
SafeL2
.
L1Origin
.
Hash
,
"verifier synced L1 chain that includes shanghai headers"
)
require
.
Equal
(
t
,
sequencer
.
SyncStatus
()
.
UnsafeL2
,
verifier
.
SyncStatus
()
.
UnsafeL2
,
"verifier and sequencer agree"
)
}
op-e2e/actions/l1_miner.go
View file @
d975d8a6
...
@@ -72,6 +72,9 @@ func (s *L1Miner) ActL1StartBlock(timeDelta uint64) Action {
...
@@ -72,6 +72,9 @@ func (s *L1Miner) ActL1StartBlock(timeDelta uint64) Action {
header
.
GasLimit
=
parent
.
GasLimit
*
s
.
l1Cfg
.
Config
.
ElasticityMultiplier
()
header
.
GasLimit
=
parent
.
GasLimit
*
s
.
l1Cfg
.
Config
.
ElasticityMultiplier
()
}
}
}
}
if
s
.
l1Cfg
.
Config
.
IsShanghai
(
header
.
Time
)
{
header
.
WithdrawalsHash
=
&
types
.
EmptyWithdrawalsHash
}
s
.
l1Building
=
true
s
.
l1Building
=
true
s
.
l1BuildingHeader
=
header
s
.
l1BuildingHeader
=
header
...
@@ -135,6 +138,9 @@ func (s *L1Miner) ActL1EndBlock(t Testing) {
...
@@ -135,6 +138,9 @@ func (s *L1Miner) ActL1EndBlock(t Testing) {
s
.
l1BuildingHeader
.
GasUsed
=
s
.
l1BuildingHeader
.
GasLimit
-
uint64
(
*
s
.
l1GasPool
)
s
.
l1BuildingHeader
.
GasUsed
=
s
.
l1BuildingHeader
.
GasLimit
-
uint64
(
*
s
.
l1GasPool
)
s
.
l1BuildingHeader
.
Root
=
s
.
l1BuildingState
.
IntermediateRoot
(
s
.
l1Cfg
.
Config
.
IsEIP158
(
s
.
l1BuildingHeader
.
Number
))
s
.
l1BuildingHeader
.
Root
=
s
.
l1BuildingState
.
IntermediateRoot
(
s
.
l1Cfg
.
Config
.
IsEIP158
(
s
.
l1BuildingHeader
.
Number
))
block
:=
types
.
NewBlock
(
s
.
l1BuildingHeader
,
s
.
l1Transactions
,
nil
,
s
.
l1Receipts
,
trie
.
NewStackTrie
(
nil
))
block
:=
types
.
NewBlock
(
s
.
l1BuildingHeader
,
s
.
l1Transactions
,
nil
,
s
.
l1Receipts
,
trie
.
NewStackTrie
(
nil
))
if
s
.
l1Cfg
.
Config
.
IsShanghai
(
s
.
l1BuildingHeader
.
Time
)
{
block
=
block
.
WithWithdrawals
(
make
([]
*
types
.
Withdrawal
,
0
))
}
// Write state changes to db
// Write state changes to db
root
,
err
:=
s
.
l1BuildingState
.
Commit
(
s
.
l1Cfg
.
Config
.
IsEIP158
(
s
.
l1BuildingHeader
.
Number
))
root
,
err
:=
s
.
l1BuildingState
.
Commit
(
s
.
l1Cfg
.
Config
.
IsEIP158
(
s
.
l1BuildingHeader
.
Number
))
...
...
op-node/sources/types.go
View file @
d975d8a6
...
@@ -47,6 +47,9 @@ type HeaderInfo struct {
...
@@ -47,6 +47,9 @@ type HeaderInfo struct {
txHash
common
.
Hash
txHash
common
.
Hash
receiptHash
common
.
Hash
receiptHash
common
.
Hash
gasUsed
uint64
gasUsed
uint64
// withdrawalsRoot was added in Shapella and is thus optional
withdrawalsRoot
*
common
.
Hash
}
}
var
_
eth
.
BlockInfo
=
(
*
HeaderInfo
)(
nil
)
var
_
eth
.
BlockInfo
=
(
*
HeaderInfo
)(
nil
)
...
@@ -113,7 +116,10 @@ type rpcHeader struct {
...
@@ -113,7 +116,10 @@ type rpcHeader struct {
Nonce
types
.
BlockNonce
`json:"nonce"`
Nonce
types
.
BlockNonce
`json:"nonce"`
// BaseFee was added by EIP-1559 and is ignored in legacy headers.
// BaseFee was added by EIP-1559 and is ignored in legacy headers.
BaseFee
*
hexutil
.
Big
`json:"baseFeePerGas" rlp:"optional"`
BaseFee
*
hexutil
.
Big
`json:"baseFeePerGas"`
// WithdrawalsRoot was added by EIP-4895 and is ignored in legacy headers.
WithdrawalsRoot
*
common
.
Hash
`json:"withdrawalsRoot"`
// untrusted info included by RPC, may have to be checked
// untrusted info included by RPC, may have to be checked
Hash
common
.
Hash
`json:"hash"`
Hash
common
.
Hash
`json:"hash"`
...
@@ -144,22 +150,23 @@ func (hdr *rpcHeader) checkPostMerge() error {
...
@@ -144,22 +150,23 @@ func (hdr *rpcHeader) checkPostMerge() error {
func
(
hdr
*
rpcHeader
)
computeBlockHash
()
common
.
Hash
{
func
(
hdr
*
rpcHeader
)
computeBlockHash
()
common
.
Hash
{
gethHeader
:=
types
.
Header
{
gethHeader
:=
types
.
Header
{
ParentHash
:
hdr
.
ParentHash
,
ParentHash
:
hdr
.
ParentHash
,
UncleHash
:
hdr
.
UncleHash
,
UncleHash
:
hdr
.
UncleHash
,
Coinbase
:
hdr
.
Coinbase
,
Coinbase
:
hdr
.
Coinbase
,
Root
:
hdr
.
Root
,
Root
:
hdr
.
Root
,
TxHash
:
hdr
.
TxHash
,
TxHash
:
hdr
.
TxHash
,
ReceiptHash
:
hdr
.
ReceiptHash
,
ReceiptHash
:
hdr
.
ReceiptHash
,
Bloom
:
types
.
Bloom
(
hdr
.
Bloom
),
Bloom
:
types
.
Bloom
(
hdr
.
Bloom
),
Difficulty
:
(
*
big
.
Int
)(
&
hdr
.
Difficulty
),
Difficulty
:
(
*
big
.
Int
)(
&
hdr
.
Difficulty
),
Number
:
new
(
big
.
Int
)
.
SetUint64
(
uint64
(
hdr
.
Number
)),
Number
:
new
(
big
.
Int
)
.
SetUint64
(
uint64
(
hdr
.
Number
)),
GasLimit
:
uint64
(
hdr
.
GasLimit
),
GasLimit
:
uint64
(
hdr
.
GasLimit
),
GasUsed
:
uint64
(
hdr
.
GasUsed
),
GasUsed
:
uint64
(
hdr
.
GasUsed
),
Time
:
uint64
(
hdr
.
Time
),
Time
:
uint64
(
hdr
.
Time
),
Extra
:
hdr
.
Extra
,
Extra
:
hdr
.
Extra
,
MixDigest
:
hdr
.
MixDigest
,
MixDigest
:
hdr
.
MixDigest
,
Nonce
:
hdr
.
Nonce
,
Nonce
:
hdr
.
Nonce
,
BaseFee
:
(
*
big
.
Int
)(
hdr
.
BaseFee
),
BaseFee
:
(
*
big
.
Int
)(
hdr
.
BaseFee
),
WithdrawalsHash
:
hdr
.
WithdrawalsRoot
,
}
}
return
gethHeader
.
Hash
()
return
gethHeader
.
Hash
()
}
}
...
@@ -177,17 +184,18 @@ func (hdr *rpcHeader) Info(trustCache bool, mustBePostMerge bool) (*HeaderInfo,
...
@@ -177,17 +184,18 @@ func (hdr *rpcHeader) Info(trustCache bool, mustBePostMerge bool) (*HeaderInfo,
}
}
info
:=
HeaderInfo
{
info
:=
HeaderInfo
{
hash
:
hdr
.
Hash
,
hash
:
hdr
.
Hash
,
parentHash
:
hdr
.
ParentHash
,
parentHash
:
hdr
.
ParentHash
,
coinbase
:
hdr
.
Coinbase
,
coinbase
:
hdr
.
Coinbase
,
root
:
hdr
.
Root
,
root
:
hdr
.
Root
,
number
:
uint64
(
hdr
.
Number
),
number
:
uint64
(
hdr
.
Number
),
time
:
uint64
(
hdr
.
Time
),
time
:
uint64
(
hdr
.
Time
),
mixDigest
:
hdr
.
MixDigest
,
mixDigest
:
hdr
.
MixDigest
,
baseFee
:
(
*
big
.
Int
)(
hdr
.
BaseFee
),
baseFee
:
(
*
big
.
Int
)(
hdr
.
BaseFee
),
txHash
:
hdr
.
TxHash
,
txHash
:
hdr
.
TxHash
,
receiptHash
:
hdr
.
ReceiptHash
,
receiptHash
:
hdr
.
ReceiptHash
,
gasUsed
:
uint64
(
hdr
.
GasUsed
),
gasUsed
:
uint64
(
hdr
.
GasUsed
),
withdrawalsRoot
:
hdr
.
WithdrawalsRoot
,
}
}
return
&
info
,
nil
return
&
info
,
nil
}
}
...
...
op-node/sources/types_test.go
0 → 100644
View file @
d975d8a6
This diff is collapsed.
Click to expand it.
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