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
1130da7d
Commit
1130da7d
authored
Dec 05, 2022
by
Mark Tyneway
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-chain-ops: more withdrawals development
parent
4812aa19
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
3 deletions
+58
-3
main.go
op-chain-ops/cmd/withdrawals/main.go
+58
-3
No files found.
op-chain-ops/cmd/withdrawals/main.go
View file @
1130da7d
...
...
@@ -10,7 +10,6 @@ import (
"github.com/mattn/go-isatty"
"github.com/urfave/cli/v2"
"github.com/ethereum-optimism/optimism/l2geth/crypto"
"github.com/ethereum-optimism/optimism/op-bindings/bindings"
"github.com/ethereum-optimism/optimism/op-bindings/predeploys"
"github.com/ethereum-optimism/optimism/op-chain-ops/crossdomain"
...
...
@@ -19,6 +18,8 @@ import (
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/ethclient/gethclient"
"github.com/ethereum/go-ethereum/log"
...
...
@@ -92,6 +93,11 @@ func main() {
}
log
.
Info
(
"Set up L2 RPC Client"
,
"chain-id"
,
l2ChainID
)
l1RpcClient
,
err
:=
rpc
.
DialContext
(
context
.
Background
(),
l1RpcURL
)
if
err
!=
nil
{
return
err
}
l2RpcClient
,
err
:=
rpc
.
DialContext
(
context
.
Background
(),
l2RpcURL
)
if
err
!=
nil
{
return
err
...
...
@@ -221,10 +227,59 @@ func main() {
return
err
}
receipt
,
err
:=
bind
.
WaitMined
(
context
.
Background
(),
l1Client
,
tx
)
if
err
!=
nil
{
return
err
}
if
receipt
.
Status
!=
types
.
ReceiptStatusSuccessful
{
return
errors
.
New
(
"withdrawal proof unsuccessful"
)
}
log
.
Info
(
"Withdrawal proven"
,
"tx-hash"
,
tx
.
Hash
(),
"withdrawal-hash"
,
hash
)
// TODO: - warp forward the L1 timestamp
// - finalize the tx
block
,
err
:=
l1Client
.
BlockByHash
(
context
.
Background
(),
receipt
.
BlockHash
)
if
err
!=
nil
{
return
err
}
// Get the finalization period
finalizationPeriod
,
err
:=
portal
.
FINALIZATIONPERIODSECONDS
(
&
bind
.
CallOpts
{})
if
err
!=
nil
{
return
err
}
future
:=
block
.
Time
()
+
finalizationPeriod
.
Uint64
()
+
1
var
result
bool
// TODO: double check this is the correct RPC
err
=
l1RpcClient
.
Call
(
&
result
,
"hardhat_setTimestamp"
,
future
)
if
err
!=
nil
{
return
err
}
// Finalize withdrawal
tx
,
err
=
portal
.
FinalizeWithdrawalTransaction
(
opts
,
bindings
.
TypesWithdrawalTransaction
{
Nonce
:
withdrawal
.
Nonce
,
Sender
:
*
withdrawal
.
Sender
,
Target
:
*
withdrawal
.
Target
,
Value
:
withdrawal
.
Value
,
GasLimit
:
withdrawal
.
GasLimit
,
Data
:
withdrawal
.
Data
,
},
)
receipt
,
err
=
bind
.
WaitMined
(
context
.
Background
(),
l1Client
,
tx
)
if
err
!=
nil
{
return
err
}
if
receipt
.
Status
!=
types
.
ReceiptStatusSuccessful
{
return
errors
.
New
(
"withdrawal finalize unsuccessful"
)
}
// TODO: next we want to be sure that the execution was correct.
// to do so we can do a debug_traceTransaction with the call
// tracer and then ensure that the expected target is called.
return
nil
},
...
...
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