Documentation ¶
Index ¶
- Variables
- func GenerateProofDB(proof []string) *proofDB
- func ParseMessagePassed(receipt *types.Receipt) (*bindings.L2ToL1MessagePasserMessagePassed, error)
- func StorageSlotOfWithdrawalHash(hash common.Hash) common.Hash
- func VerifyAccountProof(root common.Hash, address common.Address, account types.StateAccount, ...) error
- func VerifyProof(stateRoot common.Hash, proof *gethclient.AccountResult) error
- func VerifyStorageProof(root common.Hash, proof gethclient.StorageResult) error
- func WaitForFinalizationPeriod(ctx context.Context, client *ethclient.Client, portalAddr common.Address, ...) (uint64, error)
- func WithdrawalHash(ev *bindings.L2ToL1MessagePasserMessagePassed) (common.Hash, error)
- type ProofClient
- type ProvenWithdrawalParameters
- type ReceiptClient
Constants ¶
This section is empty.
Variables ¶
var (
Uint256Type, _ = abi.NewType("uint256", "", nil)
BytesType, _ = abi.NewType("bytes", "", nil)
AddressType, _ = abi.NewType("address", "", nil)
)
Standard ABI types copied from golang ABI tests
var MessagePassedTopic = crypto.Keccak256Hash([]byte("MessagePassed(uint256,address,address,uint256,uint256,bytes,bytes32)"))
Functions ¶
func GenerateProofDB ¶
func GenerateProofDB(proof []string) *proofDB
func ParseMessagePassed ¶
func ParseMessagePassed(receipt *types.Receipt) (*bindings.L2ToL1MessagePasserMessagePassed, error)
ParseMessagePassed parses MessagePassed events from a transaction receipt. It does not support multiple withdrawals per receipt.
func StorageSlotOfWithdrawalHash ¶
StorageSlotOfWithdrawalHash determines the storage slot of the Withdrawer contract to look at given a WithdrawalHash
func VerifyAccountProof ¶
func VerifyProof ¶
func VerifyProof(stateRoot common.Hash, proof *gethclient.AccountResult) error
func VerifyStorageProof ¶
func VerifyStorageProof(root common.Hash, proof gethclient.StorageResult) error
func WaitForFinalizationPeriod ¶
func WaitForFinalizationPeriod(ctx context.Context, client *ethclient.Client, portalAddr common.Address, l2BlockNumber *big.Int) (uint64, error)
WaitForFinalizationPeriod waits until there is OutputProof for an L2 block number larger than the supplied l2BlockNumber and that the output is finalized. This functions polls and can block for a very long time if used on mainnet. This returns the block number to use for the proof generation.
func WithdrawalHash ¶
func WithdrawalHash(ev *bindings.L2ToL1MessagePasserMessagePassed) (common.Hash, error)
WithdrawalHash computes the hash of the withdrawal that was stored in the L2toL1MessagePasser contract state. TODO:
- I don't like having to use the ABI Generated struct
- There should be a better way to run the ABI encoding
- These needs to be fuzzed against the solidity
Types ¶
type ProofClient ¶
type ProofClient interface {
GetProof(context.Context, common.Address, []string, *big.Int) (*gethclient.AccountResult, error)
}
type ProvenWithdrawalParameters ¶
type ProvenWithdrawalParameters struct { Nonce *big.Int Sender common.Address Target common.Address Value *big.Int GasLimit *big.Int L2OutputIndex *big.Int Data []byte OutputRootProof bindings.TypesOutputRootProof WithdrawalProof [][]byte // List of trie nodes to prove L2 storage }
ProvenWithdrawalParameters is the set of parameters to pass to the ProveWithdrawalTransaction and FinalizeWithdrawalTransaction functions
func ProveWithdrawalParameters ¶
func ProveWithdrawalParameters(ctx context.Context, proofCl ProofClient, l2ReceiptCl ReceiptClient, txHash common.Hash, header *types.Header, l2OutputOracleContract *bindings.L2OutputOracleCaller) (ProvenWithdrawalParameters, error)
ProveWithdrawalParameters queries L1 & L2 to generate all withdrawal parameters and proof necessary to prove a withdrawal on L1. The header provided is very important. It should be a block (timestamp) for which there is a submitted output in the L2 Output Oracle contract. If not, the withdrawal will fail as it the storage proof cannot be verified if there is no submitted state root.