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
391c1628
Commit
391c1628
authored
Aug 01, 2022
by
Mark Tyneway
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-node: make withdrawal tooling more resilient
parent
6db66279
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
5 deletions
+51
-5
utils.go
op-node/withdrawals/utils.go
+51
-5
No files found.
op-node/withdrawals/utils.go
View file @
391c1628
package
withdrawals
package
withdrawals
import
(
import
(
"bytes"
"context"
"context"
"errors"
"errors"
"fmt"
"fmt"
...
@@ -172,8 +173,15 @@ func FinalizeWithdrawalParameters(ctx context.Context, l2client ProofClient, txH
...
@@ -172,8 +173,15 @@ func FinalizeWithdrawalParameters(ctx context.Context, l2client ProofClient, txH
if
err
!=
nil
{
if
err
!=
nil
{
return
FinalizedWithdrawalParameters
{},
err
return
FinalizedWithdrawalParameters
{},
err
}
}
ev1
,
err
:=
ParseWithdrawalInitiatedExtension1
(
receipt
)
if
err
!=
nil
{
return
FinalizedWithdrawalParameters
{},
err
}
// Generate then verify the withdrawal proof
// Generate then verify the withdrawal proof
withdrawalHash
,
err
:=
WithdrawalHash
(
ev
)
withdrawalHash
,
err
:=
WithdrawalHash
(
ev
)
if
!
bytes
.
Equal
(
withdrawalHash
[
:
],
ev1
.
Hash
[
:
])
{
return
FinalizedWithdrawalParameters
{},
errors
.
New
(
"Computed withdrawal hash incorrectly"
)
}
if
err
!=
nil
{
if
err
!=
nil
{
return
FinalizedWithdrawalParameters
{},
err
return
FinalizedWithdrawalParameters
{},
err
}
}
...
@@ -255,14 +263,52 @@ func ParseWithdrawalInitiated(receipt *types.Receipt) (*bindings.L2ToL1MessagePa
...
@@ -255,14 +263,52 @@ func ParseWithdrawalInitiated(receipt *types.Receipt) (*bindings.L2ToL1MessagePa
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
if
len
(
receipt
.
Logs
)
!=
1
{
abi
,
err
:=
bindings
.
L2ToL1MessagePasserMetaData
.
GetAbi
()
return
nil
,
errors
.
New
(
"invalid length of logs"
)
if
err
!=
nil
{
return
nil
,
err
}
for
_
,
log
:=
range
receipt
.
Logs
{
event
,
err
:=
abi
.
EventByID
(
log
.
Topics
[
0
])
if
err
!=
nil
{
return
nil
,
err
}
}
ev
,
err
:=
contract
.
ParseWithdrawalInitiated
(
*
receipt
.
Logs
[
0
])
if
event
.
Name
==
"WithdrawalInitiated"
{
ev
,
err
:=
contract
.
ParseWithdrawalInitiated
(
*
log
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"failed to parse log: %w"
,
err
)
return
nil
,
fmt
.
Errorf
(
"failed to parse log: %w"
,
err
)
}
}
return
ev
,
nil
return
ev
,
nil
}
}
return
nil
,
errors
.
New
(
"Unable to find WithdrawalInitiated event"
)
}
// ParseWithdrawalInitiatedExtension1 parses
func
ParseWithdrawalInitiatedExtension1
(
receipt
*
types
.
Receipt
)
(
*
bindings
.
L2ToL1MessagePasserWithdrawalInitiatedExtension1
,
error
)
{
contract
,
err
:=
bindings
.
NewL2ToL1MessagePasser
(
common
.
Address
{},
nil
)
if
err
!=
nil
{
return
nil
,
err
}
abi
,
err
:=
bindings
.
L2ToL1MessagePasserMetaData
.
GetAbi
()
if
err
!=
nil
{
return
nil
,
err
}
for
_
,
log
:=
range
receipt
.
Logs
{
event
,
err
:=
abi
.
EventByID
(
log
.
Topics
[
0
])
if
err
!=
nil
{
return
nil
,
err
}
if
event
.
Name
==
"WithdrawalInitiatedExtension1"
{
ev
,
err
:=
contract
.
ParseWithdrawalInitiatedExtension1
(
*
log
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"failed to parse log: %w"
,
err
)
}
return
ev
,
nil
}
}
return
nil
,
errors
.
New
(
"Unable to find WithdrawalInitiatedExtension1 event"
)
}
}
// StorageSlotOfWithdrawalHash determines the storage slot of the Withdrawer contract to look at
// StorageSlotOfWithdrawalHash determines the storage slot of the Withdrawer contract to look at
...
...
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