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
37d51876
Commit
37d51876
authored
Nov 28, 2022
by
Mark Tyneway
Committed by
Matthew Slipper
Nov 29, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-chain-ops: add comments
parent
8acece49
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
14 deletions
+23
-14
legacy_withdrawal.go
op-chain-ops/crossdomain/legacy_withdrawal.go
+9
-2
withdrawal.go
op-chain-ops/crossdomain/withdrawal.go
+14
-12
No files found.
op-chain-ops/crossdomain/legacy_withdrawal.go
View file @
37d51876
...
@@ -128,7 +128,10 @@ func (w *LegacyWithdrawal) StorageSlot() (common.Hash, error) {
...
@@ -128,7 +128,10 @@ func (w *LegacyWithdrawal) StorageSlot() (common.Hash, error) {
return
common
.
BytesToHash
(
slot
),
nil
return
common
.
BytesToHash
(
slot
),
nil
}
}
// Value returns the ETH value associated with the withdrawal.
// Value returns the ETH value associated with the withdrawal. Since
// ETH was represented as an ERC20 token before the Bedrock upgrade,
// the sender and calldata must be observed and the value must be parsed
// out if "finalizeETHWithdrawal" is the method.
func
(
w
*
LegacyWithdrawal
)
Value
()
(
*
big
.
Int
,
error
)
{
func
(
w
*
LegacyWithdrawal
)
Value
()
(
*
big
.
Int
,
error
)
{
abi
,
err
:=
bindings
.
L1StandardBridgeMetaData
.
GetAbi
()
abi
,
err
:=
bindings
.
L1StandardBridgeMetaData
.
GetAbi
()
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -137,11 +140,15 @@ func (w *LegacyWithdrawal) Value() (*big.Int, error) {
...
@@ -137,11 +140,15 @@ func (w *LegacyWithdrawal) Value() (*big.Int, error) {
method
,
err
:=
abi
.
MethodById
(
w
.
Data
)
method
,
err
:=
abi
.
MethodById
(
w
.
Data
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
fmt
.
Errorf
(
"cannot parse withdrawal value: %w"
,
err
)
}
}
value
:=
new
(
big
.
Int
)
value
:=
new
(
big
.
Int
)
if
w
.
Sender
==
nil
{
return
nil
,
errors
.
New
(
"sender is nil"
)
}
isFromL2StandardBridge
:=
*
w
.
Sender
==
predeploys
.
L2StandardBridgeAddr
isFromL2StandardBridge
:=
*
w
.
Sender
==
predeploys
.
L2StandardBridgeAddr
if
isFromL2StandardBridge
&&
method
.
Name
==
"finalizeETHWithdrawal"
{
if
isFromL2StandardBridge
&&
method
.
Name
==
"finalizeETHWithdrawal"
{
data
,
err
:=
method
.
Inputs
.
Unpack
(
w
.
Data
[
4
:
])
data
,
err
:=
method
.
Inputs
.
Unpack
(
w
.
Data
[
4
:
])
...
...
op-chain-ops/crossdomain/withdrawal.go
View file @
37d51876
...
@@ -143,27 +143,31 @@ func (w *Withdrawal) StorageSlot() (common.Hash, error) {
...
@@ -143,27 +143,31 @@ func (w *Withdrawal) StorageSlot() (common.Hash, error) {
}
}
// Compute the receipt corresponding to the withdrawal. This receipt
// Compute the receipt corresponding to the withdrawal. This receipt
// is in the bedrock transition block. It contains 3 logs
// is in the bedrock transition block. It contains 3 logs.
// - SentMessage
// SentMessage, SentMessageExtension1 and MessagePassed.
// - SentMessageExtension1
// - MessagePassed
// These logs are enough for the standard withdrawal flow to happen
// These logs are enough for the standard withdrawal flow to happen
// which is driven by events being emitted.
// which is driven by events being emitted.
func
(
w
*
Withdrawal
)
Receipt
(
hdr
*
types
.
Header
)
(
*
types
.
Receipt
,
error
)
{
func
(
w
*
Withdrawal
)
Receipt
(
hdr
*
types
.
Header
)
(
*
types
.
Receipt
,
error
)
{
// Create a new receipt with the state root, successful execution and no gas
// used
receipt
:=
types
.
NewReceipt
(
hdr
.
Root
.
Bytes
(),
false
,
0
)
receipt
:=
types
.
NewReceipt
(
hdr
.
Root
.
Bytes
(),
false
,
0
)
if
receipt
.
Logs
==
nil
{
receipt
.
Logs
=
make
([]
*
types
.
Log
,
0
)
}
// Create the SentMessage log.
args
:=
abi
.
Arguments
{
args
:=
abi
.
Arguments
{
{
Name
:
"target"
,
Type
:
AddressType
},
{
Name
:
"target"
,
Type
:
AddressType
},
{
Name
:
"sender"
,
Type
:
AddressType
},
{
Name
:
"sender"
,
Type
:
AddressType
},
{
Name
:
"data"
,
Type
:
BytesType
},
{
Name
:
"data"
,
Type
:
BytesType
},
{
Name
:
"nonce"
,
Type
:
Uint256Type
},
{
Name
:
"nonce"
,
Type
:
Uint256Type
},
}
}
data
,
err
:=
args
.
Pack
(
w
.
Target
,
w
.
Sender
,
w
.
Data
,
w
.
Nonce
)
data
,
err
:=
args
.
Pack
(
w
.
Target
,
w
.
Sender
,
w
.
Data
,
w
.
Nonce
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
// The L2CrossDomainMessenger emits this event. The target is
// indexed.
sm
:=
&
types
.
Log
{
sm
:=
&
types
.
Log
{
Address
:
predeploys
.
L2CrossDomainMessengerAddr
,
Address
:
predeploys
.
L2CrossDomainMessengerAddr
,
Topics
:
[]
common
.
Hash
{
Topics
:
[]
common
.
Hash
{
...
@@ -178,9 +182,10 @@ func (w *Withdrawal) Receipt(hdr *types.Header) (*types.Receipt, error) {
...
@@ -178,9 +182,10 @@ func (w *Withdrawal) Receipt(hdr *types.Header) (*types.Receipt, error) {
Index
:
0
,
Index
:
0
,
Removed
:
false
,
Removed
:
false
,
}
}
receipt
.
Logs
=
append
(
receipt
.
Logs
,
sm
)
receipt
.
Logs
=
append
(
receipt
.
Logs
,
sm
)
// Create the SentMessageExtension1 log. The L2CrossDomainMessenger
// emits this event. The sender is indexed.
sm1
:=
&
types
.
Log
{
sm1
:=
&
types
.
Log
{
Address
:
predeploys
.
L2CrossDomainMessengerAddr
,
Address
:
predeploys
.
L2CrossDomainMessengerAddr
,
Topics
:
[]
common
.
Hash
{
Topics
:
[]
common
.
Hash
{
...
@@ -195,26 +200,24 @@ func (w *Withdrawal) Receipt(hdr *types.Header) (*types.Receipt, error) {
...
@@ -195,26 +200,24 @@ func (w *Withdrawal) Receipt(hdr *types.Header) (*types.Receipt, error) {
Index
:
0
,
Index
:
0
,
Removed
:
false
,
Removed
:
false
,
}
}
receipt
.
Logs
=
append
(
receipt
.
Logs
,
sm1
)
receipt
.
Logs
=
append
(
receipt
.
Logs
,
sm1
)
// Create the MessagePassed log.
mpargs
:=
abi
.
Arguments
{
mpargs
:=
abi
.
Arguments
{
{
Name
:
"value"
,
Type
:
Uint256Type
},
{
Name
:
"value"
,
Type
:
Uint256Type
},
{
Name
:
"gasLimit"
,
Type
:
Uint256Type
},
{
Name
:
"gasLimit"
,
Type
:
Uint256Type
},
{
Name
:
"data"
,
Type
:
BytesType
},
{
Name
:
"data"
,
Type
:
BytesType
},
{
Name
:
"withdrawalHash"
,
Type
:
Bytes32Type
},
{
Name
:
"withdrawalHash"
,
Type
:
Bytes32Type
},
}
}
hash
,
err
:=
w
.
Hash
()
hash
,
err
:=
w
.
Hash
()
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
mpdata
,
err
:=
mpargs
.
Pack
(
w
.
Value
,
w
.
GasLimit
,
w
.
Data
,
hash
)
mpdata
,
err
:=
mpargs
.
Pack
(
w
.
Value
,
w
.
GasLimit
,
w
.
Data
,
hash
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
// The L2ToL1MessagePasser emits this event.
mp
:=
&
types
.
Log
{
mp
:=
&
types
.
Log
{
Address
:
predeploys
.
L2ToL1MessagePasserAddr
,
Address
:
predeploys
.
L2ToL1MessagePasserAddr
,
Topics
:
[]
common
.
Hash
{
Topics
:
[]
common
.
Hash
{
...
@@ -231,7 +234,6 @@ func (w *Withdrawal) Receipt(hdr *types.Header) (*types.Receipt, error) {
...
@@ -231,7 +234,6 @@ func (w *Withdrawal) Receipt(hdr *types.Header) (*types.Receipt, error) {
Index
:
0
,
Index
:
0
,
Removed
:
false
,
Removed
:
false
,
}
}
receipt
.
Logs
=
append
(
receipt
.
Logs
,
mp
)
receipt
.
Logs
=
append
(
receipt
.
Logs
,
mp
)
return
receipt
,
nil
return
receipt
,
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