withdrawals

package
v0.8.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 8, 2022 License: MIT Imports: 18 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Uint256Type, _ = abi.NewType("uint256", "", nil)
	BytesType, _   = abi.NewType("bytes", "", nil)
	AddressType, _ = abi.NewType("address", "", nil)
)

Standard ABI types copied from golang ABI tests

Functions

func GenerateProofDB

func GenerateProofDB(proof []string) *proofDB

func ParseWithdrawalInitiated added in v0.3.0

func ParseWithdrawalInitiated(receipt *types.Receipt) (*bindings.L2ToL1MessagePasserWithdrawalInitiated, error)

ParseWithdrawalInitiated parses

func ParseWithdrawalInitiatedExtension1 added in v0.4.0

func ParseWithdrawalInitiatedExtension1(receipt *types.Receipt) (*bindings.L2ToL1MessagePasserWithdrawalInitiatedExtension1, error)

ParseWithdrawalInitiatedExtension1 parses

func StorageSlotOfWithdrawalHash

func StorageSlotOfWithdrawalHash(hash common.Hash) common.Hash

StorageSlotOfWithdrawalHash determines the storage slot of the Withdrawer contract to look at given a WithdrawalHash

func VerifyAccountProof

func VerifyAccountProof(root common.Hash, address common.Address, account types.StateAccount, proof []string) error

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

WithdrawalHash computes the hash of the withdrawal that was stored in the L2 withdrawal 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 Client added in v0.3.0

type Client struct {
	// contains filtered or unexported fields
}

func NewClient added in v0.3.0

func NewClient(client *rpc.Client) *Client

NewClient wraps a RPC client with both ethclient and gethclient methods. Implements ProofClient

type FinalizedWithdrawalParameters added in v0.3.0

type FinalizedWithdrawalParameters struct {
	Nonce           *big.Int
	Sender          common.Address
	Target          common.Address
	Value           *big.Int
	GasLimit        *big.Int
	BlockNumber     *big.Int
	Data            []byte
	OutputRootProof bindings.TypesOutputRootProof
	WithdrawalProof []byte // RLP Encoded list of trie nodes to prove L2 storage
}

FinalizedWithdrawalParameters is the set of parameters to pass to the FinalizedWithdrawal function

func FinalizeWithdrawalParameters added in v0.3.0

func FinalizeWithdrawalParameters(ctx context.Context, l2client ProofClient, txHash common.Hash, header *types.Header) (FinalizedWithdrawalParameters, error)

FinalizeWithdrawalParameters queries L2 to generate all withdrawal parameters and proof necessary to finalize an 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.

type ProofClient

type ProofClient interface {
	TransactionReceipt(context.Context, common.Hash) (*types.Receipt, error)
	GetProof(context.Context, common.Address, []string, *big.Int) (*gethclient.AccountResult, error)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL