Documentation ¶
Index ¶
- Variables
- func ApplyL1ToL2Alias(address common.Address) common.Address
- func DecodeVersionedNonce(versioned *big.Int) (*big.Int, *big.Int)
- func EncodeCrossDomainMessageV0(target common.Address, sender common.Address, message []byte, nonce *big.Int) ([]byte, error)
- func EncodeCrossDomainMessageV1(nonce *big.Int, sender common.Address, target common.Address, ...) ([]byte, error)
- func EncodeVersionedNonce(nonce, version *big.Int) *big.Int
- func HashCrossDomainMessageV0(target common.Address, sender common.Address, data []byte, nonce *big.Int) (common.Hash, error)
- func HashCrossDomainMessageV1(nonce *big.Int, sender common.Address, target common.Address, ...) (common.Hash, error)
- func MigrateWithdrawalGasLimit(data []byte, chainID *big.Int) uint64
- func MigrateWithdrawals(withdrawals SafeFilteredWithdrawals, db vm.StateDB, ...) error
- func ReadWitnessData(path string) ([]*SentMessage, OVMETHAddresses, error)
- func UndoL1ToL2Alias(address common.Address) common.Address
- type Allowance
- type Backends
- type CrossDomainMessage
- type DangerousUnfilteredWithdrawals
- type InvalidMessage
- type L1SystemContracts
- type LegacyReceipt
- type LegacyWithdrawal
- func (w *LegacyWithdrawal) CrossDomainMessage() *CrossDomainMessage
- func (w *LegacyWithdrawal) Decode(data []byte) error
- func (w *LegacyWithdrawal) ETHValue() (*big.Int, error)
- func (w *LegacyWithdrawal) Encode() ([]byte, error)
- func (w *LegacyWithdrawal) Hash() (common.Hash, error)
- func (w *LegacyWithdrawal) MNTValue() (*big.Int, error)
- func (w *LegacyWithdrawal) StorageSlot() (common.Hash, error)
- type Messengers
- type MigrationData
- type OVMETHAddresses
- type Params
- type PendingWithdrawal
- type SafeFilteredWithdrawals
- type SentMessage
- type Withdrawal
- type WithdrawalMessage
Constants ¶
This section is empty.
Variables ¶
var ( RelayConstantOverhead uint64 = 200_000 RelayPerByteDataCost uint64 = params.TxDataNonZeroGasEIP2028 MinGasDynamicOverheadNumerator uint64 = 64 MinGasDynamicOverheadDenominator uint64 = 63 RelayCallOverhead uint64 = 40_000 RelayReservedGas uint64 = 40_000 RelayGasCheckBuffer uint64 = 5_000 )
Constants used by `CrossDomainMessenger.baseGas`
var ( // Standard ABI types Uint256Type, _ = abi.NewType("uint256", "", nil) BytesType, _ = abi.NewType("bytes", "", nil) AddressType, _ = abi.NewType("address", "", nil) Bytes32Type, _ = abi.NewType("bytes32", "", nil) )
var ( SentMessageEventABI = "SentMessage(address,address,bytes,uint256)" SentMessageEventABIHash = crypto.Keccak256Hash([]byte(SentMessageEventABI)) SentMessageExtension1EventABI = "SentMessage(address,uint256,uint256)" SentMessageExtension1EventABIHash = crypto.Keccak256Hash([]byte(SentMessageExtension1EventABI)) MessagePassedEventABI = "MessagePassed(uint256,address,address,uint256,uint256,uint256,bytes,bytes32)" MessagePassedEventABIHash = crypto.Keccak256Hash([]byte(MessagePassedEventABI)) )
var (
// NonceMask represents a mask used to extract version bytes from the nonce
NonceMask, _ = new(big.Int).SetString("0000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 16)
)
Functions ¶
func ApplyL1ToL2Alias ¶
ApplyL1ToL2Alias will apply the alias applied to L1 to L2 messages when it originates from a contract address
func DecodeVersionedNonce ¶
DecodeVersionedNonce will decode the version that is encoded in the nonce
func EncodeCrossDomainMessageV0 ¶
func EncodeCrossDomainMessageV0( target common.Address, sender common.Address, message []byte, nonce *big.Int, ) ([]byte, error)
EncodeCrossDomainMessageV0 will encode the calldata for "relayMessage(address,address,bytes,uint256)",
func EncodeCrossDomainMessageV1 ¶
func EncodeCrossDomainMessageV1( nonce *big.Int, sender common.Address, target common.Address, mntValue *big.Int, ethValue *big.Int, gasLimit *big.Int, data []byte, ) ([]byte, error)
EncodeCrossDomainMessageV1 will encode the calldata for "relayMessage(uint256,address,address,uint256,uint256,bytes)",
func EncodeVersionedNonce ¶
EncodeVersionedNonce will encode the version into the nonce
func HashCrossDomainMessageV0 ¶
func HashCrossDomainMessageV0( target common.Address, sender common.Address, data []byte, nonce *big.Int, ) (common.Hash, error)
HashCrossDomainMessageV0 computes the pre bedrock cross domain messaging hashing scheme.
func HashCrossDomainMessageV1 ¶
func HashCrossDomainMessageV1( nonce *big.Int, sender common.Address, target common.Address, mntValue *big.Int, ethValue *big.Int, gasLimit *big.Int, data []byte, ) (common.Hash, error)
HashCrossDomainMessageV1 computes the first post bedrock cross domain messaging hashing scheme.
func MigrateWithdrawalGasLimit ¶
MigrateWithdrawalGasLimit computes the gas limit for the migrated withdrawal. The chain id is used to determine the overhead.
func MigrateWithdrawals ¶
func MigrateWithdrawals( withdrawals SafeFilteredWithdrawals, db vm.StateDB, l1CrossDomainMessenger *common.Address, noCheck bool, chainID *big.Int, ) error
MigrateWithdrawals will migrate a list of pending withdrawals given a StateDB.
func ReadWitnessData ¶
func ReadWitnessData(path string) ([]*SentMessage, OVMETHAddresses, error)
ReadWitnessData will read messages and addresses from a raw l2geth state dump file.
Types ¶
type Allowance ¶
Allowance represents the allowances that were set in the legacy ERC20 representation of ether
func NewAllowances ¶
NewAllowances will read the ovm-allowances.json from the file system.
type Backends ¶
type Backends struct { L1 bind.ContractBackend L2 bind.ContractBackend }
Backends represents a set of backends for L1 and L2. These are used as the backends for the Messengers
func NewBackends ¶
func NewBackends(l1, l2 bind.ContractBackend) *Backends
type CrossDomainMessage ¶
type CrossDomainMessage struct { Nonce *big.Int `json:"nonce"` Sender common.Address `json:"sender"` Target common.Address `json:"target"` MntValue *big.Int `json:"mntValue"` EthValue *big.Int `json:"ethValue"` GasLimit *big.Int `json:"gasLimit"` Data []byte `json:"data"` }
CrossDomainMessage represents a cross domain message used by the CrossDomainMessenger. The version is encoded in the nonce. Version 0 messages do not have a value, version 1 messages have a value and the most significant byte of the nonce is a 1
func NewCrossDomainMessage ¶
func NewCrossDomainMessage( nonce *big.Int, sender, target common.Address, mntValue, ethValue, gasLimit *big.Int, data []byte, ) *CrossDomainMessage
NewCrossDomainMessage creates a CrossDomainMessage.
func (*CrossDomainMessage) Encode ¶
func (c *CrossDomainMessage) Encode() ([]byte, error)
Encode will encode a cross domain message based on the version.
func (*CrossDomainMessage) Hash ¶
func (c *CrossDomainMessage) Hash() (common.Hash, error)
Hash will compute the hash of the CrossDomainMessage
func (*CrossDomainMessage) HashV1 ¶
func (c *CrossDomainMessage) HashV1() (common.Hash, error)
HashV1 forces using the V1 hash even if its a legacy hash. This is used for the migration process.
func (*CrossDomainMessage) Version ¶
func (c *CrossDomainMessage) Version() uint64
Version will return the version of the CrossDomainMessage. It does this by looking at the first byte of the nonce.
type DangerousUnfilteredWithdrawals ¶
type DangerousUnfilteredWithdrawals []*LegacyWithdrawal
DangerousUnfilteredWithdrawals is a list of raw withdrawal witness data. It has not been filtered for messages from sources other than the
type InvalidMessage ¶
type InvalidMessage SentMessage
InvalidMessage represents a message to the L1 message passer that cannot be decoded as a withdrawal. They are defined as a separate type in order to completely disambiguate them from any other message.
func (*InvalidMessage) Encode ¶
func (msg *InvalidMessage) Encode() ([]byte, error)
func (*InvalidMessage) StorageSlot ¶
func (msg *InvalidMessage) StorageSlot() (common.Hash, error)
type L1SystemContracts ¶
type L1SystemContracts struct { L1StandardBridgeProxy common.Address `json:"l1_standard_bridge_proxy"` L1CrossDomainMessengerProxy common.Address `json:"l1_cross_domain_messenger_proxy"` L1ERC721BridgeProxy common.Address `json:"l1_erc721_bridge_proxy"` SystemConfigProxy common.Address `json:"system_config_proxy"` OptimismPortalProxy common.Address `json:"optimism_portal_proxy"` }
L1SystemContracts represents a sets of system contracts on L1
func NewL1SystemContracts ¶
func NewL1SystemContracts(path string) (*L1SystemContracts, error)
NewL1SystemContracts will read the l1-system-contracts.json from the file system.
type LegacyReceipt ¶
type LegacyReceipt struct { // Consensus fields: These fields are defined by the Yellow Paper PostState []byte `json:"root"` Status uint64 `json:"status"` CumulativeGasUsed uint64 `json:"cumulativeGasUsed" gencodec:"required"` Bloom types.Bloom `json:"logsBloom" gencodec:"required"` Logs []*types.Log `json:"logs" gencodec:"required"` // Implementation fields: These fields are added by geth when processing a transaction. // They are stored in the chain database. TxHash common.Hash `json:"transactionHash" gencodec:"required"` ContractAddress common.Address `json:"contractAddress"` GasUsed uint64 `json:"gasUsed" gencodec:"required"` // Inclusion information: These fields provide information about the inclusion of the // transaction corresponding to this receipt. BlockHash common.Hash `json:"blockHash,omitempty"` BlockNumber *big.Int `json:"blockNumber,omitempty"` TransactionIndex uint `json:"transactionIndex"` // UsingOVM L1GasPrice *big.Int `json:"l1GasPrice" gencodec:"required"` L1GasUsed *big.Int `json:"l1GasUsed" gencodec:"required"` L1Fee *big.Int `json:"l1Fee" gencodec:"required"` FeeScalar *big.Float `json:"l1FeeScalar" gencodec:"required"` }
func ReadLegacyReceipts ¶
type LegacyWithdrawal ¶
type LegacyWithdrawal struct { // MessageSender is the caller of the message passer MessageSender common.Address `json:"who"` // XDomainTarget is the L1 target of the withdrawal message XDomainTarget common.Address `json:"target"` // XDomainSender is the L2 withdrawing account XDomainSender common.Address `json:"sender"` // XDomainData represents the calldata of the withdrawal message XDomainData hexutil.Bytes `json:"data"` // XDomainNonce represents the nonce of the withdrawal XDomainNonce *big.Int `json:"nonce"` }
LegacyWithdrawal represents a pre bedrock upgrade withdrawal.
func NewLegacyWithdrawal ¶
func NewLegacyWithdrawal(msgSender, target, sender common.Address, data []byte, nonce *big.Int) *LegacyWithdrawal
NewLegacyWithdrawal will construct a LegacyWithdrawal
func (*LegacyWithdrawal) CrossDomainMessage ¶
func (w *LegacyWithdrawal) CrossDomainMessage() *CrossDomainMessage
CrossDomainMessage turns the LegacyWithdrawal into a CrossDomainMessage. LegacyWithdrawals do not have the concept of value or gaslimit, so set them to 0.
func (*LegacyWithdrawal) Decode ¶
func (w *LegacyWithdrawal) Decode(data []byte) error
Decode will decode a serialized LegacyWithdrawal. There is a known inconsistency where the decoded `msg.sender` is not authenticated. A round trip of encoding and decoding with a spoofed withdrawal will result in a different message being recovered.
func (*LegacyWithdrawal) ETHValue ¶
func (w *LegacyWithdrawal) ETHValue() (*big.Int, error)
ETHValue 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 (*LegacyWithdrawal) Encode ¶
func (w *LegacyWithdrawal) Encode() ([]byte, error)
Encode will serialze the Withdrawal in the legacy format so that it is suitable for hashing. This assumes that the message is being withdrawn through the standard optimism cross domain messaging system by hashing in the L2CrossDomainMessenger address.
func (*LegacyWithdrawal) Hash ¶
func (w *LegacyWithdrawal) Hash() (common.Hash, error)
Hash will compute the legacy style hash that is computed in the OVM_L2ToL1MessagePasser.
func (*LegacyWithdrawal) MNTValue ¶
func (w *LegacyWithdrawal) MNTValue() (*big.Int, error)
MNTValue returns the MNT 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 (*LegacyWithdrawal) StorageSlot ¶
func (w *LegacyWithdrawal) StorageSlot() (common.Hash, error)
StorageSlot will compute the storage slot that is set to true in the legacy L2ToL1MessagePasser.
type Messengers ¶
type Messengers struct { L1 *bindings.L1CrossDomainMessenger L2 *bindings.L2CrossDomainMessenger }
Messengers represents a pair of L1 and L2 cross domain messengers that are connected to the correct contract addresses
func NewMessengers ¶
func NewMessengers(backends *Backends, l1CrossDomainMessenger common.Address) (*Messengers, error)
NewMessengers constructs Messengers. Passing in the address of the L1CrossDomainMessenger is required to connect to the
type MigrationData ¶
type MigrationData struct { // OvmAddresses represents the set of addresses that interacted with the // LegacyERC20ETH contract before the evm equivalence upgrade OvmAddresses OVMETHAddresses // EvmAddresses represents the set of addresses that interacted with the // LegacyERC20ETH contract after the evm equivalence upgrade EvmAddresses OVMETHAddresses // OvmAllowances represents the set of allowances in the LegacyERC20ETH from // before the evm equivalence upgrade OvmAllowances []*Allowance // OvmMessages represents the set of withdrawals through the // L2CrossDomainMessenger from before the evm equivalence upgrade OvmMessages []*SentMessage // OvmMessages represents the set of withdrawals through the // L2CrossDomainMessenger from after the evm equivalence upgrade EvmMessages []*SentMessage }
MigrationData represents all of the data required to do a migration
func (*MigrationData) Addresses ¶
func (m *MigrationData) Addresses() []common.Address
func (*MigrationData) ToWithdrawals ¶
func (m *MigrationData) ToWithdrawals() (DangerousUnfilteredWithdrawals, []InvalidMessage, error)
type OVMETHAddresses ¶
OVMETHAddresses represents a list of addresses that interacted with the ERC20 representation of ether in the pre-bedrock system.
func NewAddresses ¶
func NewAddresses(path string) (OVMETHAddresses, error)
NewAddresses will read an addresses.json file from the filesystem.
type Params ¶
type Params struct { // ExpectedSupplyDelta is the expected delta between the total supply of OVM ETH, // and ETH we were able to migrate. This is used to account for supply bugs in //previous regenesis events. ExpectedSupplyDelta *big.Int }
Params contains the configuration parameters used for verifying the integrity of the migration.
type PendingWithdrawal ¶
type PendingWithdrawal struct { LegacyWithdrawal `json:"withdrawal"` TransactionHash common.Hash `json:"transactionHash"` }
A PendingWithdrawal represents a withdrawal that has not been finalized on L1
func GetPendingWithdrawals ¶
func GetPendingWithdrawals(messengers *Messengers, version *big.Int, start, end uint64) ([]PendingWithdrawal, error)
GetPendingWithdrawals will fetch pending withdrawals by getting L2CrossDomainMessenger `SentMessage` events and then checking to see if the cross domain message hash has been finalized on L1. It will return a slice of PendingWithdrawals that have not been finalized on L1.
type SafeFilteredWithdrawals ¶
type SafeFilteredWithdrawals []*LegacyWithdrawal
SafeFilteredWithdrawals is a list of withdrawals that have been filtered to only include withdrawals that were from the L2XDM.
type SentMessage ¶
SentMessage represents an entry in the JSON file that is created by the `migration-data` package. Each entry represents a call to the `LegacyMessagePasser`. The `who` should always be the `L2CrossDomainMessenger` and the `msg` should be an abi encoded `relayMessage(address,address,bytes,uint256)`
func NewSentMessageFromJSON ¶
func NewSentMessageFromJSON(path string) ([]*SentMessage, error)
NewSentMessageFromJSON will read a JSON file from disk given a path to the JSON file. The JSON file this function reads from disk is an output from the `migration-data` package.
func (*SentMessage) ToLegacyWithdrawal ¶
func (s *SentMessage) ToLegacyWithdrawal() (*LegacyWithdrawal, error)
ToLegacyWithdrawal will convert a SentMessageJSON to a LegacyWithdrawal struct. This is useful because the LegacyWithdrawal struct has helper functions on it that can compute the withdrawal hash and the storage slot.
type Withdrawal ¶
type Withdrawal struct { Nonce *big.Int `json:"nonce"` Sender *common.Address `json:"sender"` Target *common.Address `json:"target"` MNTValue *big.Int `json:"mntValue"` ETHValue *big.Int `json:"ethValue"` GasLimit *big.Int `json:"gasLimit"` Data hexutil.Bytes `json:"data"` }
Withdrawal represents a withdrawal transaction on L2
func CalcWithdrawalHash ¶
func CalcWithdrawalHash( withdrawal *LegacyWithdrawal, l1CrossDomainMessenger *common.Address, chainID *big.Int, ) (*Withdrawal, error)
func NewWithdrawal ¶
func NewWithdrawal( nonce *big.Int, sender, target *common.Address, mntValue, ethValue, gasLimit *big.Int, data []byte, ) *Withdrawal
NewWithdrawal will create a Withdrawal
func (*Withdrawal) Decode ¶
func (w *Withdrawal) Decode(data []byte) error
Decode will deserialize a Withdrawal
func (*Withdrawal) Encode ¶
func (w *Withdrawal) Encode() ([]byte, error)
Encode will serialize the Withdrawal so that it is suitable for hashing.
func (*Withdrawal) Hash ¶
func (w *Withdrawal) Hash() (common.Hash, error)
Hash will hash the Withdrawal. This is the hash that is computed in the L2ToL1MessagePasser. The encoding is the same as the v1 cross domain message encoding without the 4byte selector prepended.
func (*Withdrawal) StorageSlot ¶
func (w *Withdrawal) StorageSlot() (common.Hash, error)
StorageSlot will compute the storage slot that will be set to true in the L2ToL1MessagePasser. The withdrawal proof sent to L1 will prove that this storage slot is set to "true".
func (*Withdrawal) WithdrawalTransaction ¶
func (w *Withdrawal) WithdrawalTransaction() bindings.TypesWithdrawalTransaction
WithdrawalTransaction will convert the Withdrawal to a type suitable for sending a transaction.