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
efad20b3
Unverified
Commit
efad20b3
authored
Aug 14, 2023
by
mergify[bot]
Committed by
GitHub
Aug 14, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into inphi/mips-todos
parents
7e3f51e1
0b65a7e6
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
263 additions
and
126 deletions
+263
-126
go.mod
go.mod
+1
-1
go.sum
go.sum
+2
-2
blocks_e2e_test.go
indexer/e2e_tests/blocks_e2e_test.go
+3
-4
bridge_messages_e2e_test.go
indexer/e2e_tests/bridge_messages_e2e_test.go
+9
-10
bridge_transactions_e2e_test.go
indexer/e2e_tests/bridge_transactions_e2e_test.go
+10
-11
bridge_transfers_e2e_test.go
indexer/e2e_tests/bridge_transfers_e2e_test.go
+15
-16
game_helper.go
op-e2e/e2eutils/disputegame/game_helper.go
+7
-7
helper.go
op-e2e/e2eutils/disputegame/helper.go
+5
-5
waits.go
op-e2e/e2eutils/wait/waits.go
+129
-0
withdrawals.go
op-e2e/e2eutils/wait/withdrawals.go
+71
-0
faultproof_test.go
op-e2e/faultproof_test.go
+5
-5
system_tob_test.go
op-e2e/system_tob_test.go
+3
-2
withdrawal_helper.go
op-e2e/withdrawal_helper.go
+3
-2
utils.go
op-node/withdrawals/utils.go
+0
-61
No files found.
go.mod
View file @
efad20b3
...
@@ -170,7 +170,7 @@ require (
...
@@ -170,7 +170,7 @@ require (
github.com/spaolacci/murmur3 v1.1.0 // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
github.com/status-im/keycard-go v0.2.0 // indirect
github.com/status-im/keycard-go v0.2.0 // indirect
github.com/stretchr/objx v0.5.0 // indirect
github.com/stretchr/objx v0.5.0 // indirect
github.com/supranational/blst v0.3.11
-0.20230406105308-e9dfc5ee724b
// indirect
github.com/supranational/blst v0.3.11 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a // indirect
github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a // indirect
github.com/tklauser/go-sysconf v0.3.10 // indirect
github.com/tklauser/go-sysconf v0.3.10 // indirect
github.com/tklauser/numcpus v0.5.0 // indirect
github.com/tklauser/numcpus v0.5.0 // indirect
...
...
go.sum
View file @
efad20b3
...
@@ -764,8 +764,8 @@ github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1F
...
@@ -764,8 +764,8 @@ github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1F
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/supranational/blst v0.3.11
-0.20230406105308-e9dfc5ee724b h1:u49mjRnygnB34h8OKbnNJFVUtWSKIKb1KukdV8bILUM
=
github.com/supranational/blst v0.3.11
h1:LyU6FolezeWAhvQk0k6O/d49jqgO52MSDDfYgbeoEm4
=
github.com/supranational/blst v0.3.11
-0.20230406105308-e9dfc5ee724b
/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw=
github.com/supranational/blst v0.3.11/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw=
github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ=
github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ=
github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a h1:1ur3QoCqvE5fl+nylMaIr9PVV1w343YRDtsy+Rwu7XI=
github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a h1:1ur3QoCqvE5fl+nylMaIr9PVV1w343YRDtsy+Rwu7XI=
github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a/go.mod h1:RRCYJbIwD5jmqPI9XoAFR0OcDxqUctll6zUj/+B4S48=
github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a/go.mod h1:RRCYJbIwD5jmqPI9XoAFR0OcDxqUctll6zUj/+B4S48=
...
...
indexer/e2e_tests/blocks_e2e_test.go
View file @
efad20b3
...
@@ -7,10 +7,9 @@ import (
...
@@ -7,10 +7,9 @@ import (
"time"
"time"
"github.com/ethereum-optimism/optimism/indexer/node"
"github.com/ethereum-optimism/optimism/indexer/node"
"github.com/ethereum-optimism/optimism/op-service/client/utils"
"github.com/ethereum-optimism/optimism/op-bindings/bindings"
"github.com/ethereum-optimism/optimism/op-bindings/bindings"
"github.com/ethereum-optimism/optimism/op-bindings/predeploys"
"github.com/ethereum-optimism/optimism/op-bindings/predeploys"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/wait"
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
...
@@ -28,7 +27,7 @@ func TestE2EBlockHeaders(t *testing.T) {
...
@@ -28,7 +27,7 @@ func TestE2EBlockHeaders(t *testing.T) {
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
// wait for at least 10 L2 blocks to be created & posted on L1
// wait for at least 10 L2 blocks to be created & posted on L1
require
.
NoError
(
t
,
utils
.
Wait
For
(
context
.
Background
(),
time
.
Second
,
func
()
(
bool
,
error
)
{
require
.
NoError
(
t
,
wait
.
For
(
context
.
Background
(),
time
.
Second
,
func
()
(
bool
,
error
)
{
l2Height
,
err
:=
l2OutputOracle
.
LatestBlockNumber
(
&
bind
.
CallOpts
{
Context
:
context
.
Background
()})
l2Height
,
err
:=
l2OutputOracle
.
LatestBlockNumber
(
&
bind
.
CallOpts
{
Context
:
context
.
Background
()})
return
l2Height
!=
nil
&&
l2Height
.
Uint64
()
>=
9
,
err
return
l2Height
!=
nil
&&
l2Height
.
Uint64
()
>=
9
,
err
}))
}))
...
@@ -36,7 +35,7 @@ func TestE2EBlockHeaders(t *testing.T) {
...
@@ -36,7 +35,7 @@ func TestE2EBlockHeaders(t *testing.T) {
// ensure the processors are caught up to this state
// ensure the processors are caught up to this state
l1Height
,
err
:=
testSuite
.
L1Client
.
BlockNumber
(
context
.
Background
())
l1Height
,
err
:=
testSuite
.
L1Client
.
BlockNumber
(
context
.
Background
())
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
utils
.
Wait
For
(
context
.
Background
(),
time
.
Second
,
func
()
(
bool
,
error
)
{
require
.
NoError
(
t
,
wait
.
For
(
context
.
Background
(),
time
.
Second
,
func
()
(
bool
,
error
)
{
l1Header
:=
testSuite
.
Indexer
.
L1Processor
.
LatestProcessedHeader
()
l1Header
:=
testSuite
.
Indexer
.
L1Processor
.
LatestProcessedHeader
()
l2Header
:=
testSuite
.
Indexer
.
L2Processor
.
LatestProcessedHeader
()
l2Header
:=
testSuite
.
Indexer
.
L2Processor
.
LatestProcessedHeader
()
return
(
l1Header
!=
nil
&&
l1Header
.
Number
.
Uint64
()
>=
l1Height
)
&&
(
l2Header
!=
nil
&&
l2Header
.
Number
.
Uint64
()
>=
9
),
nil
return
(
l1Header
!=
nil
&&
l1Header
.
Number
.
Uint64
()
>=
l1Height
)
&&
(
l2Header
!=
nil
&&
l2Header
.
Number
.
Uint64
()
>=
9
),
nil
...
...
indexer/e2e_tests/bridge_messages_e2e_test.go
View file @
efad20b3
...
@@ -10,9 +10,8 @@ import (
...
@@ -10,9 +10,8 @@ import (
"github.com/ethereum-optimism/optimism/op-bindings/bindings"
"github.com/ethereum-optimism/optimism/op-bindings/bindings"
"github.com/ethereum-optimism/optimism/op-bindings/predeploys"
"github.com/ethereum-optimism/optimism/op-bindings/predeploys"
op_e2e
"github.com/ethereum-optimism/optimism/op-e2e"
op_e2e
"github.com/ethereum-optimism/optimism/op-e2e"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/wait"
"github.com/ethereum-optimism/optimism/op-node/withdrawals"
"github.com/ethereum-optimism/optimism/op-node/withdrawals"
"github.com/ethereum-optimism/optimism/op-service/client/utils"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/params"
...
@@ -39,14 +38,14 @@ func TestE2EBridgeL1CrossDomainMessenger(t *testing.T) {
...
@@ -39,14 +38,14 @@ func TestE2EBridgeL1CrossDomainMessenger(t *testing.T) {
// (1) Send the Message
// (1) Send the Message
sentMsgTx
,
err
:=
l1CrossDomainMessenger
.
SendMessage
(
l1Opts
,
aliceAddr
,
calldata
,
100
_000
)
sentMsgTx
,
err
:=
l1CrossDomainMessenger
.
SendMessage
(
l1Opts
,
aliceAddr
,
calldata
,
100
_000
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
sentMsgReceipt
,
err
:=
utils
.
Wait
ReceiptOK
(
context
.
Background
(),
testSuite
.
L1Client
,
sentMsgTx
.
Hash
())
sentMsgReceipt
,
err
:=
wait
.
For
ReceiptOK
(
context
.
Background
(),
testSuite
.
L1Client
,
sentMsgTx
.
Hash
())
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
depositInfo
,
err
:=
e2etest_utils
.
ParseDepositInfo
(
sentMsgReceipt
)
depositInfo
,
err
:=
e2etest_utils
.
ParseDepositInfo
(
sentMsgReceipt
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
// wait for processor catchup
// wait for processor catchup
require
.
NoError
(
t
,
utils
.
Wait
For
(
context
.
Background
(),
500
*
time
.
Millisecond
,
func
()
(
bool
,
error
)
{
require
.
NoError
(
t
,
wait
.
For
(
context
.
Background
(),
500
*
time
.
Millisecond
,
func
()
(
bool
,
error
)
{
l1Header
:=
testSuite
.
Indexer
.
L1Processor
.
LatestProcessedHeader
()
l1Header
:=
testSuite
.
Indexer
.
L1Processor
.
LatestProcessedHeader
()
return
l1Header
!=
nil
&&
l1Header
.
Number
.
Uint64
()
>=
sentMsgReceipt
.
BlockNumber
.
Uint64
(),
nil
return
l1Header
!=
nil
&&
l1Header
.
Number
.
Uint64
()
>=
sentMsgReceipt
.
BlockNumber
.
Uint64
(),
nil
}))
}))
...
@@ -77,9 +76,9 @@ func TestE2EBridgeL1CrossDomainMessenger(t *testing.T) {
...
@@ -77,9 +76,9 @@ func TestE2EBridgeL1CrossDomainMessenger(t *testing.T) {
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
// wait for processor catchup
// wait for processor catchup
depositReceipt
,
err
:=
utils
.
Wait
ReceiptOK
(
context
.
Background
(),
testSuite
.
L2Client
,
transaction
.
L2TransactionHash
)
depositReceipt
,
err
:=
wait
.
For
ReceiptOK
(
context
.
Background
(),
testSuite
.
L2Client
,
transaction
.
L2TransactionHash
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
utils
.
Wait
For
(
context
.
Background
(),
500
*
time
.
Millisecond
,
func
()
(
bool
,
error
)
{
require
.
NoError
(
t
,
wait
.
For
(
context
.
Background
(),
500
*
time
.
Millisecond
,
func
()
(
bool
,
error
)
{
l2Header
:=
testSuite
.
Indexer
.
L2Processor
.
LatestProcessedHeader
()
l2Header
:=
testSuite
.
Indexer
.
L2Processor
.
LatestProcessedHeader
()
return
l2Header
!=
nil
&&
l2Header
.
Number
.
Uint64
()
>=
depositReceipt
.
BlockNumber
.
Uint64
(),
nil
return
l2Header
!=
nil
&&
l2Header
.
Number
.
Uint64
()
>=
depositReceipt
.
BlockNumber
.
Uint64
(),
nil
}))
}))
...
@@ -117,13 +116,13 @@ func TestE2EBridgeL2CrossDomainMessenger(t *testing.T) {
...
@@ -117,13 +116,13 @@ func TestE2EBridgeL2CrossDomainMessenger(t *testing.T) {
l1Opts
.
Value
=
l2Opts
.
Value
l1Opts
.
Value
=
l2Opts
.
Value
depositTx
,
err
:=
optimismPortal
.
Receive
(
l1Opts
)
depositTx
,
err
:=
optimismPortal
.
Receive
(
l1Opts
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
_
,
err
=
utils
.
Wait
ReceiptOK
(
context
.
Background
(),
testSuite
.
L1Client
,
depositTx
.
Hash
())
_
,
err
=
wait
.
For
ReceiptOK
(
context
.
Background
(),
testSuite
.
L1Client
,
depositTx
.
Hash
())
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
// (1) Send the Message
// (1) Send the Message
sentMsgTx
,
err
:=
l2CrossDomainMessenger
.
SendMessage
(
l2Opts
,
aliceAddr
,
calldata
,
100
_000
)
sentMsgTx
,
err
:=
l2CrossDomainMessenger
.
SendMessage
(
l2Opts
,
aliceAddr
,
calldata
,
100
_000
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
sentMsgReceipt
,
err
:=
utils
.
Wait
ReceiptOK
(
context
.
Background
(),
testSuite
.
L2Client
,
sentMsgTx
.
Hash
())
sentMsgReceipt
,
err
:=
wait
.
For
ReceiptOK
(
context
.
Background
(),
testSuite
.
L2Client
,
sentMsgTx
.
Hash
())
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
msgPassed
,
err
:=
withdrawals
.
ParseMessagePassed
(
sentMsgReceipt
)
msgPassed
,
err
:=
withdrawals
.
ParseMessagePassed
(
sentMsgReceipt
)
...
@@ -132,7 +131,7 @@ func TestE2EBridgeL2CrossDomainMessenger(t *testing.T) {
...
@@ -132,7 +131,7 @@ func TestE2EBridgeL2CrossDomainMessenger(t *testing.T) {
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
// wait for processor catchup
// wait for processor catchup
require
.
NoError
(
t
,
utils
.
Wait
For
(
context
.
Background
(),
500
*
time
.
Millisecond
,
func
()
(
bool
,
error
)
{
require
.
NoError
(
t
,
wait
.
For
(
context
.
Background
(),
500
*
time
.
Millisecond
,
func
()
(
bool
,
error
)
{
l2Header
:=
testSuite
.
Indexer
.
L2Processor
.
LatestProcessedHeader
()
l2Header
:=
testSuite
.
Indexer
.
L2Processor
.
LatestProcessedHeader
()
return
l2Header
!=
nil
&&
l2Header
.
Number
.
Uint64
()
>=
sentMsgReceipt
.
BlockNumber
.
Uint64
(),
nil
return
l2Header
!=
nil
&&
l2Header
.
Number
.
Uint64
()
>=
sentMsgReceipt
.
BlockNumber
.
Uint64
(),
nil
}))
}))
...
@@ -161,7 +160,7 @@ func TestE2EBridgeL2CrossDomainMessenger(t *testing.T) {
...
@@ -161,7 +160,7 @@ func TestE2EBridgeL2CrossDomainMessenger(t *testing.T) {
_
,
finalizedReceipt
:=
op_e2e
.
ProveAndFinalizeWithdrawal
(
t
,
*
testSuite
.
OpCfg
,
testSuite
.
L1Client
,
testSuite
.
OpSys
.
Nodes
[
"sequencer"
],
testSuite
.
OpCfg
.
Secrets
.
Alice
,
sentMsgReceipt
)
_
,
finalizedReceipt
:=
op_e2e
.
ProveAndFinalizeWithdrawal
(
t
,
*
testSuite
.
OpCfg
,
testSuite
.
L1Client
,
testSuite
.
OpSys
.
Nodes
[
"sequencer"
],
testSuite
.
OpCfg
.
Secrets
.
Alice
,
sentMsgReceipt
)
// wait for processor catchup
// wait for processor catchup
require
.
NoError
(
t
,
utils
.
Wait
For
(
context
.
Background
(),
500
*
time
.
Millisecond
,
func
()
(
bool
,
error
)
{
require
.
NoError
(
t
,
wait
.
For
(
context
.
Background
(),
500
*
time
.
Millisecond
,
func
()
(
bool
,
error
)
{
l1Header
:=
testSuite
.
Indexer
.
L1Processor
.
LatestProcessedHeader
()
l1Header
:=
testSuite
.
Indexer
.
L1Processor
.
LatestProcessedHeader
()
return
l1Header
!=
nil
&&
l1Header
.
Number
.
Uint64
()
>=
finalizedReceipt
.
BlockNumber
.
Uint64
(),
nil
return
l1Header
!=
nil
&&
l1Header
.
Number
.
Uint64
()
>=
finalizedReceipt
.
BlockNumber
.
Uint64
(),
nil
}))
}))
...
...
indexer/e2e_tests/bridge_transactions_e2e_test.go
View file @
efad20b3
...
@@ -7,13 +7,12 @@ import (
...
@@ -7,13 +7,12 @@ import (
"time"
"time"
e2etest_utils
"github.com/ethereum-optimism/optimism/indexer/e2e_tests/utils"
e2etest_utils
"github.com/ethereum-optimism/optimism/indexer/e2e_tests/utils"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/wait"
"github.com/ethereum-optimism/optimism/op-bindings/bindings"
"github.com/ethereum-optimism/optimism/op-bindings/bindings"
"github.com/ethereum-optimism/optimism/op-bindings/predeploys"
"github.com/ethereum-optimism/optimism/op-bindings/predeploys"
op_e2e
"github.com/ethereum-optimism/optimism/op-e2e"
op_e2e
"github.com/ethereum-optimism/optimism/op-e2e"
"github.com/ethereum-optimism/optimism/op-node/withdrawals"
"github.com/ethereum-optimism/optimism/op-node/withdrawals"
"github.com/ethereum-optimism/optimism/op-service/client/utils"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/params"
...
@@ -37,7 +36,7 @@ func TestE2EBridgeTransactionsOptimismPortalDeposits(t *testing.T) {
...
@@ -37,7 +36,7 @@ func TestE2EBridgeTransactionsOptimismPortalDeposits(t *testing.T) {
depositTx
,
err
:=
optimismPortal
.
DepositTransaction
(
l1Opts
,
aliceAddr
,
l1Opts
.
Value
,
100
_000
,
false
,
calldata
)
depositTx
,
err
:=
optimismPortal
.
DepositTransaction
(
l1Opts
,
aliceAddr
,
l1Opts
.
Value
,
100
_000
,
false
,
calldata
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
depositReceipt
,
err
:=
utils
.
Wait
ReceiptOK
(
context
.
Background
(),
testSuite
.
L1Client
,
depositTx
.
Hash
())
depositReceipt
,
err
:=
wait
.
For
ReceiptOK
(
context
.
Background
(),
testSuite
.
L1Client
,
depositTx
.
Hash
())
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
depositInfo
,
err
:=
e2etest_utils
.
ParseDepositInfo
(
depositReceipt
)
depositInfo
,
err
:=
e2etest_utils
.
ParseDepositInfo
(
depositReceipt
)
...
@@ -46,7 +45,7 @@ func TestE2EBridgeTransactionsOptimismPortalDeposits(t *testing.T) {
...
@@ -46,7 +45,7 @@ func TestE2EBridgeTransactionsOptimismPortalDeposits(t *testing.T) {
depositL2TxHash
:=
types
.
NewTx
(
depositInfo
.
DepositTx
)
.
Hash
()
depositL2TxHash
:=
types
.
NewTx
(
depositInfo
.
DepositTx
)
.
Hash
()
// wait for processor catchup
// wait for processor catchup
require
.
NoError
(
t
,
utils
.
Wait
For
(
context
.
Background
(),
500
*
time
.
Millisecond
,
func
()
(
bool
,
error
)
{
require
.
NoError
(
t
,
wait
.
For
(
context
.
Background
(),
500
*
time
.
Millisecond
,
func
()
(
bool
,
error
)
{
l1Header
:=
testSuite
.
Indexer
.
L1Processor
.
LatestProcessedHeader
()
l1Header
:=
testSuite
.
Indexer
.
L1Processor
.
LatestProcessedHeader
()
return
l1Header
!=
nil
&&
l1Header
.
Number
.
Uint64
()
>=
depositReceipt
.
BlockNumber
.
Uint64
(),
nil
return
l1Header
!=
nil
&&
l1Header
.
Number
.
Uint64
()
>=
depositReceipt
.
BlockNumber
.
Uint64
(),
nil
}))
}))
...
@@ -94,16 +93,16 @@ func TestE2EBridgeTransactionsL2ToL1MessagePasserWithdrawal(t *testing.T) {
...
@@ -94,16 +93,16 @@ func TestE2EBridgeTransactionsL2ToL1MessagePasserWithdrawal(t *testing.T) {
l1Opts
.
Value
=
l2Opts
.
Value
l1Opts
.
Value
=
l2Opts
.
Value
depositTx
,
err
:=
optimismPortal
.
Receive
(
l1Opts
)
depositTx
,
err
:=
optimismPortal
.
Receive
(
l1Opts
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
_
,
err
=
utils
.
Wait
ReceiptOK
(
context
.
Background
(),
testSuite
.
L1Client
,
depositTx
.
Hash
())
_
,
err
=
wait
.
For
ReceiptOK
(
context
.
Background
(),
testSuite
.
L1Client
,
depositTx
.
Hash
())
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
withdrawTx
,
err
:=
l2ToL1MessagePasser
.
InitiateWithdrawal
(
l2Opts
,
aliceAddr
,
big
.
NewInt
(
100
_000
),
calldata
)
withdrawTx
,
err
:=
l2ToL1MessagePasser
.
InitiateWithdrawal
(
l2Opts
,
aliceAddr
,
big
.
NewInt
(
100
_000
),
calldata
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
withdrawReceipt
,
err
:=
utils
.
Wait
ReceiptOK
(
context
.
Background
(),
testSuite
.
L2Client
,
withdrawTx
.
Hash
())
withdrawReceipt
,
err
:=
wait
.
For
ReceiptOK
(
context
.
Background
(),
testSuite
.
L2Client
,
withdrawTx
.
Hash
())
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
// wait for processor catchup
// wait for processor catchup
require
.
NoError
(
t
,
utils
.
Wait
For
(
context
.
Background
(),
500
*
time
.
Millisecond
,
func
()
(
bool
,
error
)
{
require
.
NoError
(
t
,
wait
.
For
(
context
.
Background
(),
500
*
time
.
Millisecond
,
func
()
(
bool
,
error
)
{
l2Header
:=
testSuite
.
Indexer
.
L2Processor
.
LatestProcessedHeader
()
l2Header
:=
testSuite
.
Indexer
.
L2Processor
.
LatestProcessedHeader
()
return
l2Header
!=
nil
&&
l2Header
.
Number
.
Uint64
()
>=
withdrawReceipt
.
BlockNumber
.
Uint64
(),
nil
return
l2Header
!=
nil
&&
l2Header
.
Number
.
Uint64
()
>=
withdrawReceipt
.
BlockNumber
.
Uint64
(),
nil
}))
}))
...
@@ -132,7 +131,7 @@ func TestE2EBridgeTransactionsL2ToL1MessagePasserWithdrawal(t *testing.T) {
...
@@ -132,7 +131,7 @@ func TestE2EBridgeTransactionsL2ToL1MessagePasserWithdrawal(t *testing.T) {
require
.
Nil
(
t
,
withdraw
.
FinalizedL1EventGUID
)
require
.
Nil
(
t
,
withdraw
.
FinalizedL1EventGUID
)
withdrawParams
,
proveReceipt
:=
op_e2e
.
ProveWithdrawal
(
t
,
*
testSuite
.
OpCfg
,
testSuite
.
L1Client
,
testSuite
.
OpSys
.
Nodes
[
"sequencer"
],
testSuite
.
OpCfg
.
Secrets
.
Alice
,
withdrawReceipt
)
withdrawParams
,
proveReceipt
:=
op_e2e
.
ProveWithdrawal
(
t
,
*
testSuite
.
OpCfg
,
testSuite
.
L1Client
,
testSuite
.
OpSys
.
Nodes
[
"sequencer"
],
testSuite
.
OpCfg
.
Secrets
.
Alice
,
withdrawReceipt
)
require
.
NoError
(
t
,
utils
.
Wait
For
(
context
.
Background
(),
500
*
time
.
Millisecond
,
func
()
(
bool
,
error
)
{
require
.
NoError
(
t
,
wait
.
For
(
context
.
Background
(),
500
*
time
.
Millisecond
,
func
()
(
bool
,
error
)
{
l1Header
:=
testSuite
.
Indexer
.
L1Processor
.
LatestProcessedHeader
()
l1Header
:=
testSuite
.
Indexer
.
L1Processor
.
LatestProcessedHeader
()
return
l1Header
!=
nil
&&
l1Header
.
Number
.
Uint64
()
>=
proveReceipt
.
BlockNumber
.
Uint64
(),
nil
return
l1Header
!=
nil
&&
l1Header
.
Number
.
Uint64
()
>=
proveReceipt
.
BlockNumber
.
Uint64
(),
nil
}))
}))
...
@@ -150,7 +149,7 @@ func TestE2EBridgeTransactionsL2ToL1MessagePasserWithdrawal(t *testing.T) {
...
@@ -150,7 +149,7 @@ func TestE2EBridgeTransactionsL2ToL1MessagePasserWithdrawal(t *testing.T) {
require
.
Nil
(
t
,
withdraw
.
FinalizedL1EventGUID
)
require
.
Nil
(
t
,
withdraw
.
FinalizedL1EventGUID
)
finalizeReceipt
:=
op_e2e
.
FinalizeWithdrawal
(
t
,
*
testSuite
.
OpCfg
,
testSuite
.
L1Client
,
testSuite
.
OpCfg
.
Secrets
.
Alice
,
proveReceipt
,
withdrawParams
)
finalizeReceipt
:=
op_e2e
.
FinalizeWithdrawal
(
t
,
*
testSuite
.
OpCfg
,
testSuite
.
L1Client
,
testSuite
.
OpCfg
.
Secrets
.
Alice
,
proveReceipt
,
withdrawParams
)
require
.
NoError
(
t
,
utils
.
Wait
For
(
context
.
Background
(),
500
*
time
.
Millisecond
,
func
()
(
bool
,
error
)
{
require
.
NoError
(
t
,
wait
.
For
(
context
.
Background
(),
500
*
time
.
Millisecond
,
func
()
(
bool
,
error
)
{
l1Header
:=
testSuite
.
Indexer
.
L1Processor
.
LatestProcessedHeader
()
l1Header
:=
testSuite
.
Indexer
.
L1Processor
.
LatestProcessedHeader
()
return
l1Header
!=
nil
&&
l1Header
.
Number
.
Uint64
()
>=
finalizeReceipt
.
BlockNumber
.
Uint64
(),
nil
return
l1Header
!=
nil
&&
l1Header
.
Number
.
Uint64
()
>=
finalizeReceipt
.
BlockNumber
.
Uint64
(),
nil
}))
}))
...
@@ -182,7 +181,7 @@ func TestE2EBridgeTransactionsL2ToL1MessagePasserFailedWithdrawal(t *testing.T)
...
@@ -182,7 +181,7 @@ func TestE2EBridgeTransactionsL2ToL1MessagePasserFailedWithdrawal(t *testing.T)
withdrawTx
,
err
:=
l2ToL1MessagePasser
.
InitiateWithdrawal
(
l2Opts
,
aliceAddr
,
big
.
NewInt
(
100
_000
),
nil
)
withdrawTx
,
err
:=
l2ToL1MessagePasser
.
InitiateWithdrawal
(
l2Opts
,
aliceAddr
,
big
.
NewInt
(
100
_000
),
nil
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
withdrawReceipt
,
err
:=
utils
.
Wait
ReceiptOK
(
context
.
Background
(),
testSuite
.
L2Client
,
withdrawTx
.
Hash
())
withdrawReceipt
,
err
:=
wait
.
For
ReceiptOK
(
context
.
Background
(),
testSuite
.
L2Client
,
withdrawTx
.
Hash
())
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
msgPassed
,
err
:=
withdrawals
.
ParseMessagePassed
(
withdrawReceipt
)
msgPassed
,
err
:=
withdrawals
.
ParseMessagePassed
(
withdrawReceipt
)
...
@@ -192,7 +191,7 @@ func TestE2EBridgeTransactionsL2ToL1MessagePasserFailedWithdrawal(t *testing.T)
...
@@ -192,7 +191,7 @@ func TestE2EBridgeTransactionsL2ToL1MessagePasserFailedWithdrawal(t *testing.T)
// Prove&Finalize withdrawal
// Prove&Finalize withdrawal
_
,
finalizeReceipt
:=
op_e2e
.
ProveAndFinalizeWithdrawal
(
t
,
*
testSuite
.
OpCfg
,
testSuite
.
L1Client
,
testSuite
.
OpSys
.
Nodes
[
"sequencer"
],
testSuite
.
OpCfg
.
Secrets
.
Alice
,
withdrawReceipt
)
_
,
finalizeReceipt
:=
op_e2e
.
ProveAndFinalizeWithdrawal
(
t
,
*
testSuite
.
OpCfg
,
testSuite
.
L1Client
,
testSuite
.
OpSys
.
Nodes
[
"sequencer"
],
testSuite
.
OpCfg
.
Secrets
.
Alice
,
withdrawReceipt
)
require
.
NoError
(
t
,
utils
.
Wait
For
(
context
.
Background
(),
500
*
time
.
Millisecond
,
func
()
(
bool
,
error
)
{
require
.
NoError
(
t
,
wait
.
For
(
context
.
Background
(),
500
*
time
.
Millisecond
,
func
()
(
bool
,
error
)
{
l1Header
:=
testSuite
.
Indexer
.
L1Processor
.
LatestProcessedHeader
()
l1Header
:=
testSuite
.
Indexer
.
L1Processor
.
LatestProcessedHeader
()
return
l1Header
!=
nil
&&
l1Header
.
Number
.
Uint64
()
>=
finalizeReceipt
.
BlockNumber
.
Uint64
(),
nil
return
l1Header
!=
nil
&&
l1Header
.
Number
.
Uint64
()
>=
finalizeReceipt
.
BlockNumber
.
Uint64
(),
nil
}))
}))
...
...
indexer/e2e_tests/bridge_transfers_e2e_test.go
View file @
efad20b3
...
@@ -9,12 +9,11 @@ import (
...
@@ -9,12 +9,11 @@ import (
e2etest_utils
"github.com/ethereum-optimism/optimism/indexer/e2e_tests/utils"
e2etest_utils
"github.com/ethereum-optimism/optimism/indexer/e2e_tests/utils"
"github.com/ethereum-optimism/optimism/indexer/processor"
"github.com/ethereum-optimism/optimism/indexer/processor"
op_e2e
"github.com/ethereum-optimism/optimism/op-e2e"
op_e2e
"github.com/ethereum-optimism/optimism/op-e2e"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/wait"
"github.com/ethereum-optimism/optimism/op-node/withdrawals"
"github.com/ethereum-optimism/optimism/op-node/withdrawals"
"github.com/ethereum-optimism/optimism/op-bindings/bindings"
"github.com/ethereum-optimism/optimism/op-bindings/bindings"
"github.com/ethereum-optimism/optimism/op-bindings/predeploys"
"github.com/ethereum-optimism/optimism/op-bindings/predeploys"
"github.com/ethereum-optimism/optimism/op-service/client/utils"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/params"
...
@@ -37,14 +36,14 @@ func TestE2EBridgeTransfersStandardBridgeETHDeposit(t *testing.T) {
...
@@ -37,14 +36,14 @@ func TestE2EBridgeTransfersStandardBridgeETHDeposit(t *testing.T) {
// (1) Test Deposit Initiation
// (1) Test Deposit Initiation
depositTx
,
err
:=
l1StandardBridge
.
DepositETH
(
l1Opts
,
200
_000
,
[]
byte
{
byte
(
1
)})
depositTx
,
err
:=
l1StandardBridge
.
DepositETH
(
l1Opts
,
200
_000
,
[]
byte
{
byte
(
1
)})
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
depositReceipt
,
err
:=
utils
.
Wait
ReceiptOK
(
context
.
Background
(),
testSuite
.
L1Client
,
depositTx
.
Hash
())
depositReceipt
,
err
:=
wait
.
For
ReceiptOK
(
context
.
Background
(),
testSuite
.
L1Client
,
depositTx
.
Hash
())
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
depositInfo
,
err
:=
e2etest_utils
.
ParseDepositInfo
(
depositReceipt
)
depositInfo
,
err
:=
e2etest_utils
.
ParseDepositInfo
(
depositReceipt
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
// wait for processor catchup
// wait for processor catchup
require
.
NoError
(
t
,
utils
.
Wait
For
(
context
.
Background
(),
500
*
time
.
Millisecond
,
func
()
(
bool
,
error
)
{
require
.
NoError
(
t
,
wait
.
For
(
context
.
Background
(),
500
*
time
.
Millisecond
,
func
()
(
bool
,
error
)
{
l1Header
:=
testSuite
.
Indexer
.
L1Processor
.
LatestProcessedHeader
()
l1Header
:=
testSuite
.
Indexer
.
L1Processor
.
LatestProcessedHeader
()
return
l1Header
!=
nil
&&
l1Header
.
Number
.
Uint64
()
>=
depositReceipt
.
BlockNumber
.
Uint64
(),
nil
return
l1Header
!=
nil
&&
l1Header
.
Number
.
Uint64
()
>=
depositReceipt
.
BlockNumber
.
Uint64
(),
nil
}))
}))
...
@@ -71,9 +70,9 @@ func TestE2EBridgeTransfersStandardBridgeETHDeposit(t *testing.T) {
...
@@ -71,9 +70,9 @@ func TestE2EBridgeTransfersStandardBridgeETHDeposit(t *testing.T) {
require
.
Zero
(
t
,
nonce
.
Uint64
())
require
.
Zero
(
t
,
nonce
.
Uint64
())
// (2) Test Deposit Finalization via CrossDomainMessenger relayed message
// (2) Test Deposit Finalization via CrossDomainMessenger relayed message
depositReceipt
,
err
=
utils
.
Wait
ReceiptOK
(
context
.
Background
(),
testSuite
.
L2Client
,
types
.
NewTx
(
depositInfo
.
DepositTx
)
.
Hash
())
depositReceipt
,
err
=
wait
.
For
ReceiptOK
(
context
.
Background
(),
testSuite
.
L2Client
,
types
.
NewTx
(
depositInfo
.
DepositTx
)
.
Hash
())
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
utils
.
Wait
For
(
context
.
Background
(),
500
*
time
.
Millisecond
,
func
()
(
bool
,
error
)
{
require
.
NoError
(
t
,
wait
.
For
(
context
.
Background
(),
500
*
time
.
Millisecond
,
func
()
(
bool
,
error
)
{
l2Header
:=
testSuite
.
Indexer
.
L2Processor
.
LatestProcessedHeader
()
l2Header
:=
testSuite
.
Indexer
.
L2Processor
.
LatestProcessedHeader
()
return
l2Header
!=
nil
&&
l2Header
.
Number
.
Uint64
()
>=
depositReceipt
.
BlockNumber
.
Uint64
(),
nil
return
l2Header
!=
nil
&&
l2Header
.
Number
.
Uint64
()
>=
depositReceipt
.
BlockNumber
.
Uint64
(),
nil
}))
}))
...
@@ -99,14 +98,14 @@ func TestE2EBridgeTransfersOptimismPortalETHReceive(t *testing.T) {
...
@@ -99,14 +98,14 @@ func TestE2EBridgeTransfersOptimismPortalETHReceive(t *testing.T) {
// (1) Test Deposit Initiation
// (1) Test Deposit Initiation
portalDepositTx
,
err
:=
optimismPortal
.
Receive
(
l1Opts
)
portalDepositTx
,
err
:=
optimismPortal
.
Receive
(
l1Opts
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
portalDepositReceipt
,
err
:=
utils
.
Wait
ReceiptOK
(
context
.
Background
(),
testSuite
.
L1Client
,
portalDepositTx
.
Hash
())
portalDepositReceipt
,
err
:=
wait
.
For
ReceiptOK
(
context
.
Background
(),
testSuite
.
L1Client
,
portalDepositTx
.
Hash
())
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
depositInfo
,
err
:=
e2etest_utils
.
ParseDepositInfo
(
portalDepositReceipt
)
depositInfo
,
err
:=
e2etest_utils
.
ParseDepositInfo
(
portalDepositReceipt
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
// wait for processor catchup
// wait for processor catchup
require
.
NoError
(
t
,
utils
.
Wait
For
(
context
.
Background
(),
500
*
time
.
Millisecond
,
func
()
(
bool
,
error
)
{
require
.
NoError
(
t
,
wait
.
For
(
context
.
Background
(),
500
*
time
.
Millisecond
,
func
()
(
bool
,
error
)
{
l1Header
:=
testSuite
.
Indexer
.
L1Processor
.
LatestProcessedHeader
()
l1Header
:=
testSuite
.
Indexer
.
L1Processor
.
LatestProcessedHeader
()
return
l1Header
!=
nil
&&
l1Header
.
Number
.
Uint64
()
>=
portalDepositReceipt
.
BlockNumber
.
Uint64
(),
nil
return
l1Header
!=
nil
&&
l1Header
.
Number
.
Uint64
()
>=
portalDepositReceipt
.
BlockNumber
.
Uint64
(),
nil
}))
}))
...
@@ -152,17 +151,17 @@ func TestE2EBridgeTransfersStandardBridgeETHWithdrawal(t *testing.T) {
...
@@ -152,17 +151,17 @@ func TestE2EBridgeTransfersStandardBridgeETHWithdrawal(t *testing.T) {
l1Opts
.
Value
=
l2Opts
.
Value
l1Opts
.
Value
=
l2Opts
.
Value
depositTx
,
err
:=
optimismPortal
.
Receive
(
l1Opts
)
depositTx
,
err
:=
optimismPortal
.
Receive
(
l1Opts
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
_
,
err
=
utils
.
Wait
ReceiptOK
(
context
.
Background
(),
testSuite
.
L1Client
,
depositTx
.
Hash
())
_
,
err
=
wait
.
For
ReceiptOK
(
context
.
Background
(),
testSuite
.
L1Client
,
depositTx
.
Hash
())
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
// (1) Test Withdrawal Initiation
// (1) Test Withdrawal Initiation
withdrawTx
,
err
:=
l2StandardBridge
.
Withdraw
(
l2Opts
,
predeploys
.
LegacyERC20ETHAddr
,
l2Opts
.
Value
,
200
_000
,
[]
byte
{
byte
(
1
)})
withdrawTx
,
err
:=
l2StandardBridge
.
Withdraw
(
l2Opts
,
predeploys
.
LegacyERC20ETHAddr
,
l2Opts
.
Value
,
200
_000
,
[]
byte
{
byte
(
1
)})
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
withdrawReceipt
,
err
:=
utils
.
Wait
ReceiptOK
(
context
.
Background
(),
testSuite
.
L2Client
,
withdrawTx
.
Hash
())
withdrawReceipt
,
err
:=
wait
.
For
ReceiptOK
(
context
.
Background
(),
testSuite
.
L2Client
,
withdrawTx
.
Hash
())
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
// wait for processor catchup
// wait for processor catchup
require
.
NoError
(
t
,
utils
.
Wait
For
(
context
.
Background
(),
500
*
time
.
Millisecond
,
func
()
(
bool
,
error
)
{
require
.
NoError
(
t
,
wait
.
For
(
context
.
Background
(),
500
*
time
.
Millisecond
,
func
()
(
bool
,
error
)
{
l2Header
:=
testSuite
.
Indexer
.
L2Processor
.
LatestProcessedHeader
()
l2Header
:=
testSuite
.
Indexer
.
L2Processor
.
LatestProcessedHeader
()
return
l2Header
!=
nil
&&
l2Header
.
Number
.
Uint64
()
>=
withdrawReceipt
.
BlockNumber
.
Uint64
(),
nil
return
l2Header
!=
nil
&&
l2Header
.
Number
.
Uint64
()
>=
withdrawReceipt
.
BlockNumber
.
Uint64
(),
nil
}))
}))
...
@@ -198,7 +197,7 @@ func TestE2EBridgeTransfersStandardBridgeETHWithdrawal(t *testing.T) {
...
@@ -198,7 +197,7 @@ func TestE2EBridgeTransfersStandardBridgeETHWithdrawal(t *testing.T) {
// wait for processor catchup
// wait for processor catchup
proveReceipt
,
finalizeReceipt
:=
op_e2e
.
ProveAndFinalizeWithdrawal
(
t
,
*
testSuite
.
OpCfg
,
testSuite
.
L1Client
,
testSuite
.
OpSys
.
Nodes
[
"sequencer"
],
testSuite
.
OpCfg
.
Secrets
.
Alice
,
withdrawReceipt
)
proveReceipt
,
finalizeReceipt
:=
op_e2e
.
ProveAndFinalizeWithdrawal
(
t
,
*
testSuite
.
OpCfg
,
testSuite
.
L1Client
,
testSuite
.
OpSys
.
Nodes
[
"sequencer"
],
testSuite
.
OpCfg
.
Secrets
.
Alice
,
withdrawReceipt
)
require
.
NoError
(
t
,
utils
.
Wait
For
(
context
.
Background
(),
500
*
time
.
Millisecond
,
func
()
(
bool
,
error
)
{
require
.
NoError
(
t
,
wait
.
For
(
context
.
Background
(),
500
*
time
.
Millisecond
,
func
()
(
bool
,
error
)
{
l1Header
:=
testSuite
.
Indexer
.
L1Processor
.
LatestProcessedHeader
()
l1Header
:=
testSuite
.
Indexer
.
L1Processor
.
LatestProcessedHeader
()
return
l1Header
!=
nil
&&
l1Header
.
Number
.
Uint64
()
>=
finalizeReceipt
.
BlockNumber
.
Uint64
(),
nil
return
l1Header
!=
nil
&&
l1Header
.
Number
.
Uint64
()
>=
finalizeReceipt
.
BlockNumber
.
Uint64
(),
nil
}))
}))
...
@@ -229,17 +228,17 @@ func TestE2EBridgeTransfersL2ToL1MessagePasserReceive(t *testing.T) {
...
@@ -229,17 +228,17 @@ func TestE2EBridgeTransfersL2ToL1MessagePasserReceive(t *testing.T) {
l1Opts
.
Value
=
l2Opts
.
Value
l1Opts
.
Value
=
l2Opts
.
Value
depositTx
,
err
:=
optimismPortal
.
Receive
(
l1Opts
)
depositTx
,
err
:=
optimismPortal
.
Receive
(
l1Opts
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
_
,
err
=
utils
.
Wait
ReceiptOK
(
context
.
Background
(),
testSuite
.
L1Client
,
depositTx
.
Hash
())
_
,
err
=
wait
.
For
ReceiptOK
(
context
.
Background
(),
testSuite
.
L1Client
,
depositTx
.
Hash
())
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
// (1) Test Withdrawal Initiation
// (1) Test Withdrawal Initiation
l2ToL1MessagePasserWithdrawTx
,
err
:=
l2ToL1MessagePasser
.
Receive
(
l2Opts
)
l2ToL1MessagePasserWithdrawTx
,
err
:=
l2ToL1MessagePasser
.
Receive
(
l2Opts
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
l2ToL1WithdrawReceipt
,
err
:=
utils
.
Wait
ReceiptOK
(
context
.
Background
(),
testSuite
.
L2Client
,
l2ToL1MessagePasserWithdrawTx
.
Hash
())
l2ToL1WithdrawReceipt
,
err
:=
wait
.
For
ReceiptOK
(
context
.
Background
(),
testSuite
.
L2Client
,
l2ToL1MessagePasserWithdrawTx
.
Hash
())
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
// wait for processor catchup
// wait for processor catchup
require
.
NoError
(
t
,
utils
.
Wait
For
(
context
.
Background
(),
500
*
time
.
Millisecond
,
func
()
(
bool
,
error
)
{
require
.
NoError
(
t
,
wait
.
For
(
context
.
Background
(),
500
*
time
.
Millisecond
,
func
()
(
bool
,
error
)
{
l2Header
:=
testSuite
.
Indexer
.
L2Processor
.
LatestProcessedHeader
()
l2Header
:=
testSuite
.
Indexer
.
L2Processor
.
LatestProcessedHeader
()
return
l2Header
!=
nil
&&
l2Header
.
Number
.
Uint64
()
>=
l2ToL1WithdrawReceipt
.
BlockNumber
.
Uint64
(),
nil
return
l2Header
!=
nil
&&
l2Header
.
Number
.
Uint64
()
>=
l2ToL1WithdrawReceipt
.
BlockNumber
.
Uint64
(),
nil
}))
}))
...
@@ -271,7 +270,7 @@ func TestE2EBridgeTransfersL2ToL1MessagePasserReceive(t *testing.T) {
...
@@ -271,7 +270,7 @@ func TestE2EBridgeTransfersL2ToL1MessagePasserReceive(t *testing.T) {
// wait for processor catchup
// wait for processor catchup
proveReceipt
,
finalizeReceipt
:=
op_e2e
.
ProveAndFinalizeWithdrawal
(
t
,
*
testSuite
.
OpCfg
,
testSuite
.
L1Client
,
testSuite
.
OpSys
.
Nodes
[
"sequencer"
],
testSuite
.
OpCfg
.
Secrets
.
Alice
,
l2ToL1WithdrawReceipt
)
proveReceipt
,
finalizeReceipt
:=
op_e2e
.
ProveAndFinalizeWithdrawal
(
t
,
*
testSuite
.
OpCfg
,
testSuite
.
L1Client
,
testSuite
.
OpSys
.
Nodes
[
"sequencer"
],
testSuite
.
OpCfg
.
Secrets
.
Alice
,
l2ToL1WithdrawReceipt
)
require
.
NoError
(
t
,
utils
.
Wait
For
(
context
.
Background
(),
500
*
time
.
Millisecond
,
func
()
(
bool
,
error
)
{
require
.
NoError
(
t
,
wait
.
For
(
context
.
Background
(),
500
*
time
.
Millisecond
,
func
()
(
bool
,
error
)
{
l1Header
:=
testSuite
.
Indexer
.
L1Processor
.
LatestProcessedHeader
()
l1Header
:=
testSuite
.
Indexer
.
L1Processor
.
LatestProcessedHeader
()
return
l1Header
!=
nil
&&
l1Header
.
Number
.
Uint64
()
>=
finalizeReceipt
.
BlockNumber
.
Uint64
(),
nil
return
l1Header
!=
nil
&&
l1Header
.
Number
.
Uint64
()
>=
finalizeReceipt
.
BlockNumber
.
Uint64
(),
nil
}))
}))
...
...
op-e2e/e2eutils/disputegame/game_helper.go
View file @
efad20b3
...
@@ -9,7 +9,7 @@ import (
...
@@ -9,7 +9,7 @@ import (
"github.com/ethereum-optimism/optimism/op-bindings/bindings"
"github.com/ethereum-optimism/optimism/op-bindings/bindings"
"github.com/ethereum-optimism/optimism/op-challenger/fault/types"
"github.com/ethereum-optimism/optimism/op-challenger/fault/types"
"github.com/ethereum-optimism/optimism/op-
service/client/utils
"
"github.com/ethereum-optimism/optimism/op-
e2e/e2eutils/wait
"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/ethclient"
...
@@ -34,7 +34,7 @@ func (g *FaultGameHelper) GameDuration(ctx context.Context) time.Duration {
...
@@ -34,7 +34,7 @@ func (g *FaultGameHelper) GameDuration(ctx context.Context) time.Duration {
func
(
g
*
FaultGameHelper
)
WaitForClaimCount
(
ctx
context
.
Context
,
count
int64
)
{
func
(
g
*
FaultGameHelper
)
WaitForClaimCount
(
ctx
context
.
Context
,
count
int64
)
{
ctx
,
cancel
:=
context
.
WithTimeout
(
ctx
,
2
*
time
.
Minute
)
ctx
,
cancel
:=
context
.
WithTimeout
(
ctx
,
2
*
time
.
Minute
)
defer
cancel
()
defer
cancel
()
err
:=
utils
.
Wait
For
(
ctx
,
time
.
Second
,
func
()
(
bool
,
error
)
{
err
:=
wait
.
For
(
ctx
,
time
.
Second
,
func
()
(
bool
,
error
)
{
actual
,
err
:=
g
.
game
.
ClaimDataLen
(
&
bind
.
CallOpts
{
Context
:
ctx
})
actual
,
err
:=
g
.
game
.
ClaimDataLen
(
&
bind
.
CallOpts
{
Context
:
ctx
})
if
err
!=
nil
{
if
err
!=
nil
{
return
false
,
err
return
false
,
err
...
@@ -62,7 +62,7 @@ func (g *FaultGameHelper) MaxDepth(ctx context.Context) int64 {
...
@@ -62,7 +62,7 @@ func (g *FaultGameHelper) MaxDepth(ctx context.Context) int64 {
func
(
g
*
FaultGameHelper
)
WaitForClaim
(
ctx
context
.
Context
,
predicate
func
(
claim
ContractClaim
)
bool
)
{
func
(
g
*
FaultGameHelper
)
WaitForClaim
(
ctx
context
.
Context
,
predicate
func
(
claim
ContractClaim
)
bool
)
{
ctx
,
cancel
:=
context
.
WithTimeout
(
ctx
,
time
.
Minute
)
ctx
,
cancel
:=
context
.
WithTimeout
(
ctx
,
time
.
Minute
)
defer
cancel
()
defer
cancel
()
err
:=
utils
.
Wait
For
(
ctx
,
time
.
Second
,
func
()
(
bool
,
error
)
{
err
:=
wait
.
For
(
ctx
,
time
.
Second
,
func
()
(
bool
,
error
)
{
count
,
err
:=
g
.
game
.
ClaimDataLen
(
&
bind
.
CallOpts
{
Context
:
ctx
})
count
,
err
:=
g
.
game
.
ClaimDataLen
(
&
bind
.
CallOpts
{
Context
:
ctx
})
if
err
!=
nil
{
if
err
!=
nil
{
return
false
,
fmt
.
Errorf
(
"retrieve number of claims: %w"
,
err
)
return
false
,
fmt
.
Errorf
(
"retrieve number of claims: %w"
,
err
)
...
@@ -105,7 +105,7 @@ func (g *FaultGameHelper) Resolve(ctx context.Context) {
...
@@ -105,7 +105,7 @@ func (g *FaultGameHelper) Resolve(ctx context.Context) {
defer
cancel
()
defer
cancel
()
tx
,
err
:=
g
.
game
.
Resolve
(
g
.
opts
)
tx
,
err
:=
g
.
game
.
Resolve
(
g
.
opts
)
g
.
require
.
NoError
(
err
)
g
.
require
.
NoError
(
err
)
_
,
err
=
utils
.
Wait
ReceiptOK
(
ctx
,
g
.
client
,
tx
.
Hash
())
_
,
err
=
wait
.
For
ReceiptOK
(
ctx
,
g
.
client
,
tx
.
Hash
())
g
.
require
.
NoError
(
err
)
g
.
require
.
NoError
(
err
)
}
}
...
@@ -113,7 +113,7 @@ func (g *FaultGameHelper) WaitForGameStatus(ctx context.Context, expected Status
...
@@ -113,7 +113,7 @@ func (g *FaultGameHelper) WaitForGameStatus(ctx context.Context, expected Status
g
.
t
.
Logf
(
"Waiting for game %v to have status %v"
,
g
.
addr
,
expected
)
g
.
t
.
Logf
(
"Waiting for game %v to have status %v"
,
g
.
addr
,
expected
)
ctx
,
cancel
:=
context
.
WithTimeout
(
ctx
,
time
.
Minute
)
ctx
,
cancel
:=
context
.
WithTimeout
(
ctx
,
time
.
Minute
)
defer
cancel
()
defer
cancel
()
err
:=
utils
.
Wait
For
(
ctx
,
time
.
Second
,
func
()
(
bool
,
error
)
{
err
:=
wait
.
For
(
ctx
,
time
.
Second
,
func
()
(
bool
,
error
)
{
ctx
,
cancel
:=
context
.
WithTimeout
(
ctx
,
30
*
time
.
Second
)
ctx
,
cancel
:=
context
.
WithTimeout
(
ctx
,
30
*
time
.
Second
)
defer
cancel
()
defer
cancel
()
status
,
err
:=
g
.
game
.
Status
(
&
bind
.
CallOpts
{
Context
:
ctx
})
status
,
err
:=
g
.
game
.
Status
(
&
bind
.
CallOpts
{
Context
:
ctx
})
...
@@ -129,14 +129,14 @@ func (g *FaultGameHelper) WaitForGameStatus(ctx context.Context, expected Status
...
@@ -129,14 +129,14 @@ func (g *FaultGameHelper) WaitForGameStatus(ctx context.Context, expected Status
func
(
g
*
FaultGameHelper
)
Attack
(
ctx
context
.
Context
,
claimIdx
int64
,
claim
common
.
Hash
)
{
func
(
g
*
FaultGameHelper
)
Attack
(
ctx
context
.
Context
,
claimIdx
int64
,
claim
common
.
Hash
)
{
tx
,
err
:=
g
.
game
.
Attack
(
g
.
opts
,
big
.
NewInt
(
claimIdx
),
claim
)
tx
,
err
:=
g
.
game
.
Attack
(
g
.
opts
,
big
.
NewInt
(
claimIdx
),
claim
)
g
.
require
.
NoError
(
err
,
"Attack transaction did not send"
)
g
.
require
.
NoError
(
err
,
"Attack transaction did not send"
)
_
,
err
=
utils
.
Wait
ReceiptOK
(
ctx
,
g
.
client
,
tx
.
Hash
())
_
,
err
=
wait
.
For
ReceiptOK
(
ctx
,
g
.
client
,
tx
.
Hash
())
g
.
require
.
NoError
(
err
,
"Attack transaction was not OK"
)
g
.
require
.
NoError
(
err
,
"Attack transaction was not OK"
)
}
}
func
(
g
*
FaultGameHelper
)
Defend
(
ctx
context
.
Context
,
claimIdx
int64
,
claim
common
.
Hash
)
{
func
(
g
*
FaultGameHelper
)
Defend
(
ctx
context
.
Context
,
claimIdx
int64
,
claim
common
.
Hash
)
{
tx
,
err
:=
g
.
game
.
Defend
(
g
.
opts
,
big
.
NewInt
(
claimIdx
),
claim
)
tx
,
err
:=
g
.
game
.
Defend
(
g
.
opts
,
big
.
NewInt
(
claimIdx
),
claim
)
g
.
require
.
NoError
(
err
,
"Defend transaction did not send"
)
g
.
require
.
NoError
(
err
,
"Defend transaction did not send"
)
_
,
err
=
utils
.
Wait
ReceiptOK
(
ctx
,
g
.
client
,
tx
.
Hash
())
_
,
err
=
wait
.
For
ReceiptOK
(
ctx
,
g
.
client
,
tx
.
Hash
())
g
.
require
.
NoError
(
err
,
"Defend transaction was not OK"
)
g
.
require
.
NoError
(
err
,
"Defend transaction was not OK"
)
}
}
...
...
op-e2e/e2eutils/disputegame/helper.go
View file @
efad20b3
...
@@ -12,7 +12,7 @@ import (
...
@@ -12,7 +12,7 @@ import (
"github.com/ethereum-optimism/optimism/op-chain-ops/deployer"
"github.com/ethereum-optimism/optimism/op-chain-ops/deployer"
"github.com/ethereum-optimism/optimism/op-chain-ops/genesis"
"github.com/ethereum-optimism/optimism/op-chain-ops/genesis"
"github.com/ethereum-optimism/optimism/op-challenger/fault/alphabet"
"github.com/ethereum-optimism/optimism/op-challenger/fault/alphabet"
"github.com/ethereum-optimism/optimism/op-
service/client/utils
"
"github.com/ethereum-optimism/optimism/op-
e2e/e2eutils/wait
"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/ethclient"
...
@@ -98,7 +98,7 @@ func (h *FactoryHelper) StartAlphabetGame(ctx context.Context, claimedAlphabet s
...
@@ -98,7 +98,7 @@ func (h *FactoryHelper) StartAlphabetGame(ctx context.Context, claimedAlphabet s
binary
.
BigEndian
.
PutUint64
(
extraData
[
56
:
],
l1Head
.
Uint64
())
binary
.
BigEndian
.
PutUint64
(
extraData
[
56
:
],
l1Head
.
Uint64
())
tx
,
err
:=
h
.
factory
.
Create
(
h
.
opts
,
alphabetGameType
,
rootClaim
,
extraData
)
tx
,
err
:=
h
.
factory
.
Create
(
h
.
opts
,
alphabetGameType
,
rootClaim
,
extraData
)
h
.
require
.
NoError
(
err
,
"create fault dispute game"
)
h
.
require
.
NoError
(
err
,
"create fault dispute game"
)
rcpt
,
err
:=
utils
.
Wait
ReceiptOK
(
ctx
,
h
.
client
,
tx
.
Hash
())
rcpt
,
err
:=
wait
.
For
ReceiptOK
(
ctx
,
h
.
client
,
tx
.
Hash
())
h
.
require
.
NoError
(
err
,
"wait for create fault dispute game receipt to be OK"
)
h
.
require
.
NoError
(
err
,
"wait for create fault dispute game receipt to be OK"
)
h
.
require
.
Len
(
rcpt
.
Logs
,
1
,
"should have emitted a single DisputeGameCreated event"
)
h
.
require
.
Len
(
rcpt
.
Logs
,
1
,
"should have emitted a single DisputeGameCreated event"
)
createdEvent
,
err
:=
h
.
factory
.
ParseDisputeGameCreated
(
*
rcpt
.
Logs
[
0
])
createdEvent
,
err
:=
h
.
factory
.
ParseDisputeGameCreated
(
*
rcpt
.
Logs
[
0
])
...
@@ -131,7 +131,7 @@ func (h *FactoryHelper) StartCannonGame(ctx context.Context, rootClaim common.Ha
...
@@ -131,7 +131,7 @@ func (h *FactoryHelper) StartCannonGame(ctx context.Context, rootClaim common.Ha
binary
.
BigEndian
.
PutUint64
(
extraData
[
56
:
],
l1Head
.
Uint64
())
binary
.
BigEndian
.
PutUint64
(
extraData
[
56
:
],
l1Head
.
Uint64
())
tx
,
err
:=
h
.
factory
.
Create
(
h
.
opts
,
cannonGameType
,
rootClaim
,
extraData
)
tx
,
err
:=
h
.
factory
.
Create
(
h
.
opts
,
cannonGameType
,
rootClaim
,
extraData
)
h
.
require
.
NoError
(
err
,
"create fault dispute game"
)
h
.
require
.
NoError
(
err
,
"create fault dispute game"
)
rcpt
,
err
:=
utils
.
Wait
ReceiptOK
(
ctx
,
h
.
client
,
tx
.
Hash
())
rcpt
,
err
:=
wait
.
For
ReceiptOK
(
ctx
,
h
.
client
,
tx
.
Hash
())
h
.
require
.
NoError
(
err
,
"wait for create fault dispute game receipt to be OK"
)
h
.
require
.
NoError
(
err
,
"wait for create fault dispute game receipt to be OK"
)
h
.
require
.
Len
(
rcpt
.
Logs
,
1
,
"should have emitted a single DisputeGameCreated event"
)
h
.
require
.
Len
(
rcpt
.
Logs
,
1
,
"should have emitted a single DisputeGameCreated event"
)
createdEvent
,
err
:=
h
.
factory
.
ParseDisputeGameCreated
(
*
rcpt
.
Logs
[
0
])
createdEvent
,
err
:=
h
.
factory
.
ParseDisputeGameCreated
(
*
rcpt
.
Logs
[
0
])
...
@@ -158,7 +158,7 @@ func (h *FactoryHelper) waitForProposals(ctx context.Context) uint64 {
...
@@ -158,7 +158,7 @@ func (h *FactoryHelper) waitForProposals(ctx context.Context) uint64 {
ctx
,
cancel
:=
context
.
WithTimeout
(
ctx
,
2
*
time
.
Minute
)
ctx
,
cancel
:=
context
.
WithTimeout
(
ctx
,
2
*
time
.
Minute
)
defer
cancel
()
defer
cancel
()
opts
:=
&
bind
.
CallOpts
{
Context
:
ctx
}
opts
:=
&
bind
.
CallOpts
{
Context
:
ctx
}
latestOutputIndex
,
err
:=
utils
.
Wait
AndGet
(
latestOutputIndex
,
err
:=
wait
.
AndGet
(
ctx
,
ctx
,
time
.
Second
,
time
.
Second
,
func
()
(
*
big
.
Int
,
error
)
{
func
()
(
*
big
.
Int
,
error
)
{
...
@@ -187,7 +187,7 @@ func (h *FactoryHelper) checkpointL1Block(ctx context.Context) *big.Int {
...
@@ -187,7 +187,7 @@ func (h *FactoryHelper) checkpointL1Block(ctx context.Context) *big.Int {
// Store the current block in the oracle
// Store the current block in the oracle
tx
,
err
:=
h
.
blockOracle
.
Checkpoint
(
h
.
opts
)
tx
,
err
:=
h
.
blockOracle
.
Checkpoint
(
h
.
opts
)
h
.
require
.
NoError
(
err
)
h
.
require
.
NoError
(
err
)
r
,
err
:=
utils
.
Wait
ReceiptOK
(
ctx
,
h
.
client
,
tx
.
Hash
())
r
,
err
:=
wait
.
For
ReceiptOK
(
ctx
,
h
.
client
,
tx
.
Hash
())
h
.
require
.
NoError
(
err
,
"failed to store block in block oracle"
)
h
.
require
.
NoError
(
err
,
"failed to store block in block oracle"
)
return
new
(
big
.
Int
)
.
Sub
(
r
.
BlockNumber
,
big
.
NewInt
(
1
))
return
new
(
big
.
Int
)
.
Sub
(
r
.
BlockNumber
,
big
.
NewInt
(
1
))
}
}
op-
service/client/utils
/waits.go
→
op-
e2e/e2eutils/wait
/waits.go
View file @
efad20b3
package
utils
package
wait
import
(
import
(
"context"
"context"
...
@@ -8,19 +8,20 @@ import (
...
@@ -8,19 +8,20 @@ import (
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/ethclient"
)
)
func
Wait
ReceiptOK
(
ctx
context
.
Context
,
client
*
ethclient
.
Client
,
hash
common
.
Hash
)
(
*
types
.
Receipt
,
error
)
{
func
For
ReceiptOK
(
ctx
context
.
Context
,
client
*
ethclient
.
Client
,
hash
common
.
Hash
)
(
*
types
.
Receipt
,
error
)
{
return
Wait
Receipt
(
ctx
,
client
,
hash
,
types
.
ReceiptStatusSuccessful
)
return
For
Receipt
(
ctx
,
client
,
hash
,
types
.
ReceiptStatusSuccessful
)
}
}
func
Wait
ReceiptFail
(
ctx
context
.
Context
,
client
*
ethclient
.
Client
,
hash
common
.
Hash
)
(
*
types
.
Receipt
,
error
)
{
func
For
ReceiptFail
(
ctx
context
.
Context
,
client
*
ethclient
.
Client
,
hash
common
.
Hash
)
(
*
types
.
Receipt
,
error
)
{
return
Wait
Receipt
(
ctx
,
client
,
hash
,
types
.
ReceiptStatusFailed
)
return
For
Receipt
(
ctx
,
client
,
hash
,
types
.
ReceiptStatusFailed
)
}
}
func
Wait
Receipt
(
ctx
context
.
Context
,
client
*
ethclient
.
Client
,
hash
common
.
Hash
,
status
uint64
)
(
*
types
.
Receipt
,
error
)
{
func
For
Receipt
(
ctx
context
.
Context
,
client
*
ethclient
.
Client
,
hash
common
.
Hash
,
status
uint64
)
(
*
types
.
Receipt
,
error
)
{
ticker
:=
time
.
NewTicker
(
100
*
time
.
Millisecond
)
ticker
:=
time
.
NewTicker
(
100
*
time
.
Millisecond
)
defer
ticker
.
Stop
()
defer
ticker
.
Stop
()
for
{
for
{
...
@@ -34,16 +35,35 @@ func WaitReceipt(ctx context.Context, client *ethclient.Client, hash common.Hash
...
@@ -34,16 +35,35 @@ func WaitReceipt(ctx context.Context, client *ethclient.Client, hash common.Hash
}
}
}
}
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
fmt
.
Errorf
(
"failed to get receipt: %w"
,
err
)
}
}
if
receipt
.
Status
!=
status
{
if
receipt
.
Status
!=
status
{
return
receipt
,
fmt
.
Errorf
(
"expected status %d, but got %d"
,
status
,
receipt
.
Status
)
return
receipt
,
addDebugTrace
(
ctx
,
client
,
hash
,
fmt
.
Errorf
(
"expected status %d, but got %d"
,
status
,
receipt
.
Status
)
)
}
}
return
receipt
,
nil
return
receipt
,
nil
}
}
}
}
func
WaitBlock
(
ctx
context
.
Context
,
client
*
ethclient
.
Client
,
n
uint64
)
error
{
type
jsonRawString
string
func
(
s
*
jsonRawString
)
UnmarshalJSON
(
input
[]
byte
)
error
{
str
:=
jsonRawString
(
input
)
*
s
=
str
return
nil
}
// addDebugTrace adds debug_traceTransaction output to the original error to make debugging
func
addDebugTrace
(
ctx
context
.
Context
,
client
*
ethclient
.
Client
,
txHash
common
.
Hash
,
origErr
error
)
error
{
var
result
jsonRawString
options
:=
map
[
string
]
string
{}
err
:=
client
.
Client
()
.
CallContext
(
ctx
,
&
result
,
"debug_traceTransaction"
,
hexutil
.
Bytes
(
txHash
.
Bytes
()),
options
)
if
err
!=
nil
{
return
errors
.
Join
(
origErr
,
fmt
.
Errorf
(
"tx trace unavailable: %w"
,
err
))
}
return
fmt
.
Errorf
(
"%w
\n
TxTrace: %v"
,
origErr
,
result
)
}
func
ForBlock
(
ctx
context
.
Context
,
client
*
ethclient
.
Client
,
n
uint64
)
error
{
for
{
for
{
height
,
err
:=
client
.
BlockNumber
(
ctx
)
height
,
err
:=
client
.
BlockNumber
(
ctx
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -59,15 +79,15 @@ func WaitBlock(ctx context.Context, client *ethclient.Client, n uint64) error {
...
@@ -59,15 +79,15 @@ func WaitBlock(ctx context.Context, client *ethclient.Client, n uint64) error {
return
nil
return
nil
}
}
func
Wait
NextBlock
(
ctx
context
.
Context
,
client
*
ethclient
.
Client
)
error
{
func
For
NextBlock
(
ctx
context
.
Context
,
client
*
ethclient
.
Client
)
error
{
current
,
err
:=
client
.
BlockNumber
(
ctx
)
current
,
err
:=
client
.
BlockNumber
(
ctx
)
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"get starting block number: %w"
,
err
)
return
fmt
.
Errorf
(
"get starting block number: %w"
,
err
)
}
}
return
Wait
Block
(
ctx
,
client
,
current
+
1
)
return
For
Block
(
ctx
,
client
,
current
+
1
)
}
}
func
Wait
For
(
ctx
context
.
Context
,
rate
time
.
Duration
,
cb
func
()
(
bool
,
error
))
error
{
func
For
(
ctx
context
.
Context
,
rate
time
.
Duration
,
cb
func
()
(
bool
,
error
))
error
{
tick
:=
time
.
NewTicker
(
rate
)
tick
:=
time
.
NewTicker
(
rate
)
defer
tick
.
Stop
()
defer
tick
.
Stop
()
...
@@ -87,7 +107,7 @@ func WaitFor(ctx context.Context, rate time.Duration, cb func() (bool, error)) e
...
@@ -87,7 +107,7 @@ func WaitFor(ctx context.Context, rate time.Duration, cb func() (bool, error)) e
}
}
}
}
func
Wait
AndGet
[
T
interface
{}](
ctx
context
.
Context
,
pollRate
time
.
Duration
,
get
func
()
(
T
,
error
),
predicate
func
(
T
)
bool
)
(
T
,
error
)
{
func
AndGet
[
T
interface
{}](
ctx
context
.
Context
,
pollRate
time
.
Duration
,
get
func
()
(
T
,
error
),
predicate
func
(
T
)
bool
)
(
T
,
error
)
{
tick
:=
time
.
NewTicker
(
pollRate
)
tick
:=
time
.
NewTicker
(
pollRate
)
defer
tick
.
Stop
()
defer
tick
.
Stop
()
...
...
op-e2e/e2eutils/wait/withdrawals.go
0 → 100644
View file @
efad20b3
package
wait
import
(
"context"
"fmt"
"math/big"
"time"
"github.com/ethereum-optimism/optimism/op-bindings/bindings"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"
)
// ForOutputRootPublished waits until there is an output published for an L2 block number larger than the supplied l2BlockNumber
// This function polls and can block for a very long time if used on mainnet.
// This returns the block number to use for proof generation.
func
ForOutputRootPublished
(
ctx
context
.
Context
,
client
*
ethclient
.
Client
,
l2OutputOracleAddr
common
.
Address
,
l2BlockNumber
*
big
.
Int
)
(
uint64
,
error
)
{
l2BlockNumber
=
new
(
big
.
Int
)
.
Set
(
l2BlockNumber
)
// Don't clobber caller owned l2BlockNumber
opts
:=
&
bind
.
CallOpts
{
Context
:
ctx
}
l2OO
,
err
:=
bindings
.
NewL2OutputOracleCaller
(
l2OutputOracleAddr
,
client
)
if
err
!=
nil
{
return
0
,
err
}
getL2BlockFromLatestOutput
:=
func
()
(
*
big
.
Int
,
error
)
{
return
l2OO
.
LatestBlockNumber
(
opts
)
}
outputBlockNum
,
err
:=
AndGet
(
ctx
,
time
.
Second
,
getL2BlockFromLatestOutput
,
func
(
latest
*
big
.
Int
)
bool
{
return
latest
.
Cmp
(
l2BlockNumber
)
>=
0
})
if
err
!=
nil
{
return
0
,
err
}
return
outputBlockNum
.
Uint64
(),
nil
}
// ForFinalizationPeriod waits until the L1 chain has progressed far enough that l1ProvingBlockNum has completed
// the finalization period.
// This functions polls and can block for a very long time if used on mainnet.
func
ForFinalizationPeriod
(
ctx
context
.
Context
,
client
*
ethclient
.
Client
,
l1ProvingBlockNum
*
big
.
Int
,
l2OutputOracleAddr
common
.
Address
)
error
{
l1ProvingBlockNum
=
new
(
big
.
Int
)
.
Set
(
l1ProvingBlockNum
)
// Don't clobber caller owned l1ProvingBlockNum
opts
:=
&
bind
.
CallOpts
{
Context
:
ctx
}
// Load finalization period
l2OO
,
err
:=
bindings
.
NewL2OutputOracleCaller
(
l2OutputOracleAddr
,
client
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"create L2OOCaller: %w"
,
err
)
}
finalizationPeriod
,
err
:=
l2OO
.
FINALIZATIONPERIODSECONDS
(
opts
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"get finalization period: %w"
,
err
)
}
provingHeader
,
err
:=
client
.
HeaderByNumber
(
ctx
,
l1ProvingBlockNum
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"retrieve proving header: %w"
,
err
)
}
targetTimestamp
:=
new
(
big
.
Int
)
.
Add
(
new
(
big
.
Int
)
.
SetUint64
(
provingHeader
.
Time
),
finalizationPeriod
)
targetTime
:=
time
.
Unix
(
targetTimestamp
.
Int64
(),
0
)
// Assume clock is relatively correct
time
.
Sleep
(
time
.
Until
(
targetTime
))
// Poll for L1 Block to have a time greater than the target time
return
For
(
ctx
,
time
.
Second
,
func
()
(
bool
,
error
)
{
header
,
err
:=
client
.
HeaderByNumber
(
ctx
,
nil
)
if
err
!=
nil
{
return
false
,
fmt
.
Errorf
(
"retrieve latest header: %w"
,
err
)
}
return
header
.
Time
>
targetTimestamp
.
Uint64
(),
nil
})
}
op-e2e/faultproof_test.go
View file @
efad20b3
...
@@ -7,7 +7,7 @@ import (
...
@@ -7,7 +7,7 @@ import (
"github.com/ethereum-optimism/optimism/op-challenger/config"
"github.com/ethereum-optimism/optimism/op-challenger/config"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/disputegame"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/disputegame"
"github.com/ethereum-optimism/optimism/op-
service/client/utils
"
"github.com/ethereum-optimism/optimism/op-
e2e/e2eutils/wait
"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/require"
...
@@ -37,7 +37,7 @@ func TestResolveDisputeGame(t *testing.T) {
...
@@ -37,7 +37,7 @@ func TestResolveDisputeGame(t *testing.T) {
game
.
WaitForClaimCount
(
ctx
,
2
)
game
.
WaitForClaimCount
(
ctx
,
2
)
sys
.
TimeTravelClock
.
AdvanceTime
(
gameDuration
)
sys
.
TimeTravelClock
.
AdvanceTime
(
gameDuration
)
require
.
NoError
(
t
,
utils
.
Wait
NextBlock
(
ctx
,
l1Client
))
require
.
NoError
(
t
,
wait
.
For
NextBlock
(
ctx
,
l1Client
))
// Challenger should resolve the game now that the clocks have expired.
// Challenger should resolve the game now that the clocks have expired.
game
.
WaitForGameStatus
(
ctx
,
disputegame
.
StatusChallengerWins
)
game
.
WaitForGameStatus
(
ctx
,
disputegame
.
StatusChallengerWins
)
...
@@ -138,7 +138,7 @@ func TestChallengerCompleteDisputeGame(t *testing.T) {
...
@@ -138,7 +138,7 @@ func TestChallengerCompleteDisputeGame(t *testing.T) {
game
.
WaitForClaimAtMaxDepth
(
ctx
,
test
.
expectStep
)
game
.
WaitForClaimAtMaxDepth
(
ctx
,
test
.
expectStep
)
sys
.
TimeTravelClock
.
AdvanceTime
(
gameDuration
)
sys
.
TimeTravelClock
.
AdvanceTime
(
gameDuration
)
require
.
NoError
(
t
,
utils
.
Wait
NextBlock
(
ctx
,
l1Client
))
require
.
NoError
(
t
,
wait
.
For
NextBlock
(
ctx
,
l1Client
))
game
.
WaitForGameStatus
(
ctx
,
test
.
expectedResult
)
game
.
WaitForGameStatus
(
ctx
,
test
.
expectedResult
)
})
})
...
@@ -198,7 +198,7 @@ func TestCannonDisputeGame(t *testing.T) {
...
@@ -198,7 +198,7 @@ func TestCannonDisputeGame(t *testing.T) {
game
.
WaitForClaimAtMaxDepth
(
ctx
,
true
)
game
.
WaitForClaimAtMaxDepth
(
ctx
,
true
)
sys
.
TimeTravelClock
.
AdvanceTime
(
game
.
GameDuration
(
ctx
))
sys
.
TimeTravelClock
.
AdvanceTime
(
game
.
GameDuration
(
ctx
))
require
.
NoError
(
t
,
utils
.
Wait
NextBlock
(
ctx
,
l1Client
))
require
.
NoError
(
t
,
wait
.
For
NextBlock
(
ctx
,
l1Client
))
game
.
WaitForGameStatus
(
ctx
,
disputegame
.
StatusChallengerWins
)
game
.
WaitForGameStatus
(
ctx
,
disputegame
.
StatusChallengerWins
)
game
.
LogGameData
(
ctx
)
game
.
LogGameData
(
ctx
)
...
@@ -253,7 +253,7 @@ func TestCannonDefendStep(t *testing.T) {
...
@@ -253,7 +253,7 @@ func TestCannonDefendStep(t *testing.T) {
game
.
WaitForClaimAtMaxDepth
(
ctx
,
true
)
game
.
WaitForClaimAtMaxDepth
(
ctx
,
true
)
sys
.
TimeTravelClock
.
AdvanceTime
(
game
.
GameDuration
(
ctx
))
sys
.
TimeTravelClock
.
AdvanceTime
(
game
.
GameDuration
(
ctx
))
require
.
NoError
(
t
,
utils
.
Wait
NextBlock
(
ctx
,
l1Client
))
require
.
NoError
(
t
,
wait
.
For
NextBlock
(
ctx
,
l1Client
))
game
.
WaitForGameStatus
(
ctx
,
disputegame
.
StatusChallengerWins
)
game
.
WaitForGameStatus
(
ctx
,
disputegame
.
StatusChallengerWins
)
game
.
LogGameData
(
ctx
)
game
.
LogGameData
(
ctx
)
...
...
op-e2e/system_tob_test.go
View file @
efad20b3
...
@@ -13,6 +13,7 @@ import (
...
@@ -13,6 +13,7 @@ import (
"github.com/ethereum-optimism/optimism/op-bindings/bindings"
"github.com/ethereum-optimism/optimism/op-bindings/bindings"
"github.com/ethereum-optimism/optimism/op-bindings/predeploys"
"github.com/ethereum-optimism/optimism/op-bindings/predeploys"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/wait"
"github.com/ethereum-optimism/optimism/op-node/testutils/fuzzerutils"
"github.com/ethereum-optimism/optimism/op-node/testutils/fuzzerutils"
"github.com/ethereum-optimism/optimism/op-node/withdrawals"
"github.com/ethereum-optimism/optimism/op-node/withdrawals"
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/accounts"
...
@@ -534,7 +535,7 @@ func TestMixedWithdrawalValidity(t *testing.T) {
...
@@ -534,7 +535,7 @@ func TestMixedWithdrawalValidity(t *testing.T) {
// Wait for the finalization period, then we can finalize this withdrawal.
// Wait for the finalization period, then we can finalize this withdrawal.
ctx
,
cancel
=
context
.
WithTimeout
(
context
.
Background
(),
40
*
time
.
Duration
(
cfg
.
DeployConfig
.
L1BlockTime
)
*
time
.
Second
)
ctx
,
cancel
=
context
.
WithTimeout
(
context
.
Background
(),
40
*
time
.
Duration
(
cfg
.
DeployConfig
.
L1BlockTime
)
*
time
.
Second
)
require
.
NotEqual
(
t
,
cfg
.
L1Deployments
.
L2OutputOracleProxy
,
common
.
Address
{})
require
.
NotEqual
(
t
,
cfg
.
L1Deployments
.
L2OutputOracleProxy
,
common
.
Address
{})
blockNumber
,
err
:=
w
ithdrawals
.
Wait
ForOutputRootPublished
(
ctx
,
l1Client
,
cfg
.
L1Deployments
.
L2OutputOracleProxy
,
receipt
.
BlockNumber
)
blockNumber
,
err
:=
w
ait
.
ForOutputRootPublished
(
ctx
,
l1Client
,
cfg
.
L1Deployments
.
L2OutputOracleProxy
,
receipt
.
BlockNumber
)
cancel
()
cancel
()
require
.
Nil
(
t
,
err
)
require
.
Nil
(
t
,
err
)
...
@@ -662,7 +663,7 @@ func TestMixedWithdrawalValidity(t *testing.T) {
...
@@ -662,7 +663,7 @@ func TestMixedWithdrawalValidity(t *testing.T) {
// Wait for finalization and then create the Finalized Withdrawal Transaction
// Wait for finalization and then create the Finalized Withdrawal Transaction
ctx
,
cancel
=
context
.
WithTimeout
(
context
.
Background
(),
45
*
time
.
Duration
(
cfg
.
DeployConfig
.
L1BlockTime
)
*
time
.
Second
)
ctx
,
cancel
=
context
.
WithTimeout
(
context
.
Background
(),
45
*
time
.
Duration
(
cfg
.
DeployConfig
.
L1BlockTime
)
*
time
.
Second
)
defer
cancel
()
defer
cancel
()
err
=
w
ithdrawals
.
Wait
ForFinalizationPeriod
(
ctx
,
l1Client
,
header
.
Number
,
cfg
.
L1Deployments
.
L2OutputOracleProxy
)
err
=
w
ait
.
ForFinalizationPeriod
(
ctx
,
l1Client
,
header
.
Number
,
cfg
.
L1Deployments
.
L2OutputOracleProxy
)
require
.
Nil
(
t
,
err
)
require
.
Nil
(
t
,
err
)
// Finalize withdrawal
// Finalize withdrawal
...
...
op-e2e/withdrawal_helper.go
View file @
efad20b3
...
@@ -10,6 +10,7 @@ import (
...
@@ -10,6 +10,7 @@ import (
"github.com/ethereum-optimism/optimism/op-bindings/bindings"
"github.com/ethereum-optimism/optimism/op-bindings/bindings"
"github.com/ethereum-optimism/optimism/op-bindings/predeploys"
"github.com/ethereum-optimism/optimism/op-bindings/predeploys"
"github.com/ethereum-optimism/optimism/op-e2e/config"
"github.com/ethereum-optimism/optimism/op-e2e/config"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/wait"
"github.com/ethereum-optimism/optimism/op-node/withdrawals"
"github.com/ethereum-optimism/optimism/op-node/withdrawals"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
...
@@ -89,7 +90,7 @@ func ProveWithdrawal(t *testing.T, cfg SystemConfig, l1Client *ethclient.Client,
...
@@ -89,7 +90,7 @@ func ProveWithdrawal(t *testing.T, cfg SystemConfig, l1Client *ethclient.Client,
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
40
*
time
.
Duration
(
cfg
.
DeployConfig
.
L1BlockTime
)
*
time
.
Second
)
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
40
*
time
.
Duration
(
cfg
.
DeployConfig
.
L1BlockTime
)
*
time
.
Second
)
defer
cancel
()
defer
cancel
()
blockNumber
,
err
:=
w
ithdrawals
.
Wait
ForOutputRootPublished
(
ctx
,
l1Client
,
config
.
L1Deployments
.
L2OutputOracleProxy
,
l2WithdrawalReceipt
.
BlockNumber
)
blockNumber
,
err
:=
w
ait
.
ForOutputRootPublished
(
ctx
,
l1Client
,
config
.
L1Deployments
.
L2OutputOracleProxy
,
l2WithdrawalReceipt
.
BlockNumber
)
require
.
Nil
(
t
,
err
)
require
.
Nil
(
t
,
err
)
rpcClient
,
err
:=
rpc
.
Dial
(
l2Node
.
WSEndpoint
())
rpcClient
,
err
:=
rpc
.
Dial
(
l2Node
.
WSEndpoint
())
...
@@ -145,7 +146,7 @@ func FinalizeWithdrawal(t *testing.T, cfg SystemConfig, l1Client *ethclient.Clie
...
@@ -145,7 +146,7 @@ func FinalizeWithdrawal(t *testing.T, cfg SystemConfig, l1Client *ethclient.Clie
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
30
*
time
.
Duration
(
cfg
.
DeployConfig
.
L1BlockTime
)
*
time
.
Second
)
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
30
*
time
.
Duration
(
cfg
.
DeployConfig
.
L1BlockTime
)
*
time
.
Second
)
defer
cancel
()
defer
cancel
()
err
:=
w
ithdrawals
.
Wait
ForFinalizationPeriod
(
ctx
,
l1Client
,
withdrawalProofReceipt
.
BlockNumber
,
config
.
L1Deployments
.
L2OutputOracleProxy
)
err
:=
w
ait
.
ForFinalizationPeriod
(
ctx
,
l1Client
,
withdrawalProofReceipt
.
BlockNumber
,
config
.
L1Deployments
.
L2OutputOracleProxy
)
require
.
Nil
(
t
,
err
)
require
.
Nil
(
t
,
err
)
opts
,
err
:=
bind
.
NewKeyedTransactorWithChainID
(
privKey
,
cfg
.
L1ChainIDBig
())
opts
,
err
:=
bind
.
NewKeyedTransactorWithChainID
(
privKey
,
cfg
.
L1ChainIDBig
())
...
...
op-node/withdrawals/utils.go
View file @
efad20b3
...
@@ -6,81 +6,20 @@ import (
...
@@ -6,81 +6,20 @@ import (
"errors"
"errors"
"fmt"
"fmt"
"math/big"
"math/big"
"time"
"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/ethclient/gethclient"
"github.com/ethereum/go-ethereum/ethclient/gethclient"
"github.com/ethereum-optimism/optimism/op-bindings/bindings"
"github.com/ethereum-optimism/optimism/op-bindings/bindings"
"github.com/ethereum-optimism/optimism/op-bindings/predeploys"
"github.com/ethereum-optimism/optimism/op-bindings/predeploys"
"github.com/ethereum-optimism/optimism/op-service/client/utils"
)
)
var
MessagePassedTopic
=
crypto
.
Keccak256Hash
([]
byte
(
"MessagePassed(uint256,address,address,uint256,uint256,bytes,bytes32)"
))
var
MessagePassedTopic
=
crypto
.
Keccak256Hash
([]
byte
(
"MessagePassed(uint256,address,address,uint256,uint256,bytes,bytes32)"
))
// WaitForOutputRootPublished waits until there is an output published for an L2 block number larger than the supplied l2BlockNumber
// This function polls and can block for a very long time if used on mainnet.
// This returns the block number to use for proof generation.
func
WaitForOutputRootPublished
(
ctx
context
.
Context
,
client
*
ethclient
.
Client
,
l2OutputOracleAddr
common
.
Address
,
l2BlockNumber
*
big
.
Int
)
(
uint64
,
error
)
{
l2BlockNumber
=
new
(
big
.
Int
)
.
Set
(
l2BlockNumber
)
// Don't clobber caller owned l2BlockNumber
opts
:=
&
bind
.
CallOpts
{
Context
:
ctx
}
l2OO
,
err
:=
bindings
.
NewL2OutputOracleCaller
(
l2OutputOracleAddr
,
client
)
if
err
!=
nil
{
return
0
,
err
}
getL2BlockFromLatestOutput
:=
func
()
(
*
big
.
Int
,
error
)
{
return
l2OO
.
LatestBlockNumber
(
opts
)
}
outputBlockNum
,
err
:=
utils
.
WaitAndGet
(
ctx
,
time
.
Second
,
getL2BlockFromLatestOutput
,
func
(
latest
*
big
.
Int
)
bool
{
return
latest
.
Cmp
(
l2BlockNumber
)
>=
0
})
if
err
!=
nil
{
return
0
,
err
}
return
outputBlockNum
.
Uint64
(),
nil
}
// WaitForFinalizationPeriod waits until the L1 chain has progressed far enough that l1ProvingBlockNum has completed
// the finalization period.
// This functions polls and can block for a very long time if used on mainnet.
func
WaitForFinalizationPeriod
(
ctx
context
.
Context
,
client
*
ethclient
.
Client
,
l1ProvingBlockNum
*
big
.
Int
,
l2OutputOracleAddr
common
.
Address
)
error
{
l1ProvingBlockNum
=
new
(
big
.
Int
)
.
Set
(
l1ProvingBlockNum
)
// Don't clobber caller owned l1ProvingBlockNum
opts
:=
&
bind
.
CallOpts
{
Context
:
ctx
}
// Load finalization period
l2OO
,
err
:=
bindings
.
NewL2OutputOracleCaller
(
l2OutputOracleAddr
,
client
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"create L2OOCaller: %w"
,
err
)
}
finalizationPeriod
,
err
:=
l2OO
.
FINALIZATIONPERIODSECONDS
(
opts
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"get finalization period: %w"
,
err
)
}
provingHeader
,
err
:=
client
.
HeaderByNumber
(
ctx
,
l1ProvingBlockNum
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"retrieve proving header: %w"
,
err
)
}
targetTimestamp
:=
new
(
big
.
Int
)
.
Add
(
new
(
big
.
Int
)
.
SetUint64
(
provingHeader
.
Time
),
finalizationPeriod
)
targetTime
:=
time
.
Unix
(
targetTimestamp
.
Int64
(),
0
)
// Assume clock is relatively correct
time
.
Sleep
(
time
.
Until
(
targetTime
))
// Poll for L1 Block to have a time greater than the target time
return
utils
.
WaitFor
(
ctx
,
time
.
Second
,
func
()
(
bool
,
error
)
{
header
,
err
:=
client
.
HeaderByNumber
(
ctx
,
nil
)
if
err
!=
nil
{
return
false
,
fmt
.
Errorf
(
"retrieve latest header: %w"
,
err
)
}
return
header
.
Time
>
targetTimestamp
.
Uint64
(),
nil
})
}
type
ProofClient
interface
{
type
ProofClient
interface
{
GetProof
(
context
.
Context
,
common
.
Address
,
[]
string
,
*
big
.
Int
)
(
*
gethclient
.
AccountResult
,
error
)
GetProof
(
context
.
Context
,
common
.
Address
,
[]
string
,
*
big
.
Int
)
(
*
gethclient
.
AccountResult
,
error
)
}
}
...
...
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