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
998b8de8
Unverified
Commit
998b8de8
authored
Aug 12, 2024
by
Inphi
Committed by
GitHub
Aug 12, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-e2e: Test Granite EVM rules in op-program (#11391)
parent
995ddcfb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
80 additions
and
0 deletions
+80
-0
precompile_test.go
op-e2e/faultproofs/precompile_test.go
+79
-0
setup.go
op-e2e/setup.go
+1
-0
No files found.
op-e2e/faultproofs/precompile_test.go
View file @
998b8de8
...
@@ -5,12 +5,15 @@ import (
...
@@ -5,12 +5,15 @@ import (
"encoding/json"
"encoding/json"
"fmt"
"fmt"
"math"
"math"
"math/big"
"path/filepath"
"path/filepath"
"testing"
"testing"
"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"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/rpc"
"github.com/ethereum/go-ethereum/rpc"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/require"
...
@@ -134,6 +137,82 @@ func TestPrecompiles(t *testing.T) {
...
@@ -134,6 +137,82 @@ func TestPrecompiles(t *testing.T) {
}
}
}
}
func
TestGranitePrecompiles
(
t
*
testing
.
T
)
{
op_e2e
.
InitParallel
(
t
,
op_e2e
.
UsesCannon
)
ctx
:=
context
.
Background
()
genesisTime
:=
hexutil
.
Uint64
(
0
)
cfg
:=
op_e2e
.
GraniteSystemConfig
(
t
,
&
genesisTime
)
// We don't need a verifier - just the sequencer is enough
delete
(
cfg
.
Nodes
,
"verifier"
)
// Use a small sequencer window size to avoid test timeout while waiting for empty blocks
// But not too small to ensure that our claim and subsequent state change is published
cfg
.
DeployConfig
.
SequencerWindowSize
=
16
sys
,
err
:=
cfg
.
Start
(
t
)
require
.
Nil
(
t
,
err
,
"Error starting up system"
)
defer
sys
.
Close
()
log
:=
testlog
.
Logger
(
t
,
log
.
LevelInfo
)
log
.
Info
(
"genesis"
,
"l2"
,
sys
.
RollupConfig
.
Genesis
.
L2
,
"l1"
,
sys
.
RollupConfig
.
Genesis
.
L1
,
"l2_time"
,
sys
.
RollupConfig
.
Genesis
.
L2Time
)
l1Client
:=
sys
.
Clients
[
"l1"
]
l2Seq
:=
sys
.
Clients
[
"sequencer"
]
rollupRPCClient
,
err
:=
rpc
.
DialContext
(
context
.
Background
(),
sys
.
RollupNodes
[
"sequencer"
]
.
HTTPEndpoint
())
require
.
Nil
(
t
,
err
)
rollupClient
:=
sources
.
NewRollupClient
(
client
.
NewBaseRPCClient
(
rollupRPCClient
))
aliceKey
:=
cfg
.
Secrets
.
Alice
t
.
Log
(
"Capture current L2 head as agreed starting point"
)
latestBlock
,
err
:=
l2Seq
.
BlockByNumber
(
ctx
,
nil
)
require
.
NoError
(
t
,
err
)
agreedL2Output
,
err
:=
rollupClient
.
OutputAtBlock
(
ctx
,
latestBlock
.
NumberU64
())
require
.
NoError
(
t
,
err
,
"could not retrieve l2 agreed block"
)
l2Head
:=
agreedL2Output
.
BlockRef
.
Hash
l2OutputRoot
:=
agreedL2Output
.
OutputRoot
precompile
:=
common
.
BytesToAddress
([]
byte
{
0x08
})
input
:=
make
([]
byte
,
113
_000
)
tx
:=
types
.
MustSignNewTx
(
aliceKey
,
types
.
LatestSignerForChainID
(
cfg
.
L2ChainIDBig
()),
&
types
.
DynamicFeeTx
{
ChainID
:
cfg
.
L2ChainIDBig
(),
Nonce
:
0
,
GasTipCap
:
big
.
NewInt
(
1
*
params
.
GWei
),
GasFeeCap
:
big
.
NewInt
(
10
*
params
.
GWei
),
Gas
:
25
_000_000
,
To
:
&
precompile
,
Value
:
big
.
NewInt
(
0
),
Data
:
input
,
})
err
=
l2Seq
.
SendTransaction
(
ctx
,
tx
)
require
.
NoError
(
t
,
err
,
"Should send bn256Pairing transaction"
)
// Expect a successful receipt to retrieve the EVM call trace so we can inspect the revert reason
receipt
,
err
:=
wait
.
ForReceiptMaybe
(
ctx
,
l2Seq
,
tx
.
Hash
(),
types
.
ReceiptStatusSuccessful
,
false
)
require
.
NotNil
(
t
,
err
)
require
.
Contains
(
t
,
err
.
Error
(),
"bad elliptic curve pairing input size"
)
t
.
Logf
(
"Transaction hash %v"
,
tx
.
Hash
())
t
.
Log
(
"Determine L2 claim"
)
l2ClaimBlockNumber
:=
receipt
.
BlockNumber
l2Output
,
err
:=
rollupClient
.
OutputAtBlock
(
ctx
,
l2ClaimBlockNumber
.
Uint64
())
require
.
NoError
(
t
,
err
,
"could not get expected output"
)
l2Claim
:=
l2Output
.
OutputRoot
t
.
Log
(
"Determine L1 head that includes all batches required for L2 claim block"
)
require
.
NoError
(
t
,
wait
.
ForSafeBlock
(
ctx
,
rollupClient
,
l2ClaimBlockNumber
.
Uint64
()))
l1HeadBlock
,
err
:=
l1Client
.
BlockByNumber
(
ctx
,
nil
)
require
.
NoError
(
t
,
err
,
"get l1 head block"
)
l1Head
:=
l1HeadBlock
.
Hash
()
inputs
:=
utils
.
LocalGameInputs
{
L1Head
:
l1Head
,
L2Head
:
l2Head
,
L2Claim
:
common
.
Hash
(
l2Claim
),
L2OutputRoot
:
common
.
Hash
(
l2OutputRoot
),
L2BlockNumber
:
l2ClaimBlockNumber
,
}
runCannon
(
t
,
ctx
,
sys
,
inputs
,
"sequencer"
)
}
func
runCannon
(
t
*
testing
.
T
,
ctx
context
.
Context
,
sys
*
op_e2e
.
System
,
inputs
utils
.
LocalGameInputs
,
l2Node
string
,
extraVmArgs
...
string
)
{
func
runCannon
(
t
*
testing
.
T
,
ctx
context
.
Context
,
sys
*
op_e2e
.
System
,
inputs
utils
.
LocalGameInputs
,
l2Node
string
,
extraVmArgs
...
string
)
{
l1Endpoint
:=
sys
.
NodeEndpoint
(
"l1"
)
l1Endpoint
:=
sys
.
NodeEndpoint
(
"l1"
)
l1Beacon
:=
sys
.
L1BeaconEndpoint
()
l1Beacon
:=
sys
.
L1BeaconEndpoint
()
...
...
op-e2e/setup.go
View file @
998b8de8
...
@@ -218,6 +218,7 @@ func FjordSystemConfig(t *testing.T, fjordTimeOffset *hexutil.Uint64) SystemConf
...
@@ -218,6 +218,7 @@ func FjordSystemConfig(t *testing.T, fjordTimeOffset *hexutil.Uint64) SystemConf
func
GraniteSystemConfig
(
t
*
testing
.
T
,
graniteTimeOffset
*
hexutil
.
Uint64
)
SystemConfig
{
func
GraniteSystemConfig
(
t
*
testing
.
T
,
graniteTimeOffset
*
hexutil
.
Uint64
)
SystemConfig
{
cfg
:=
FjordSystemConfig
(
t
,
&
genesisTime
)
cfg
:=
FjordSystemConfig
(
t
,
&
genesisTime
)
cfg
.
DeployConfig
.
L2GenesisGraniteTimeOffset
=
graniteTimeOffset
cfg
.
DeployConfig
.
L2GenesisGraniteTimeOffset
=
graniteTimeOffset
cfg
.
DeployConfig
.
ChannelTimeoutGranite
=
20
return
cfg
return
cfg
}
}
...
...
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