withdrawals

package
v1.16.6 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2026 License: MIT, MIT Imports: 21 Imported by: 8

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

View Source
var MessagePassedTopic = crypto.Keccak256Hash([]byte("MessagePassed(uint256,address,address,uint256,uint256,bytes,bytes32)"))

Functions

func FindLatestGame added in v1.6.1

func FindLatestGame(ctx context.Context, disputeGameFactoryContract *bindings.DisputeGameFactoryCaller, optimismPortal2Contract *bindingspreview.OptimismPortal2Caller) (*bindings.IDisputeGameFactoryGameSearchResult, error)

FindLatestGame finds the latest game in the DisputeGameFactory contract.

func GenerateProofDB

func GenerateProofDB(proof []string) *proofDB

func GetWithdrawalProof added in v1.13.5

func GetWithdrawalProof(ctx context.Context, proofCl ProofClient, ev *bindings.L2ToL1MessagePasserMessagePassed, l2Header *types.Header) ([][]byte, common.Hash, error)

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 ParseMessagesPassed added in v1.11.0

func ParseMessagesPassed(receipt *types.Receipt) ([]*bindings.L2ToL1MessagePasserMessagePassed, error)

ParseMessagesPassed parses MessagePassed events from a transaction receipt. It supports multiple withdrawals per receipt.

func StorageSlotOfWithdrawalHash

func StorageSlotOfWithdrawalHash(hash common.Hash) common.Hash

StorageSlotOfWithdrawalHash determines the storage slot of the L2ToL1MessagePasser 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 WithdrawalHash

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 HeaderClient added in v1.11.0

type HeaderClient interface {
	HeaderByNumber(context.Context, *big.Int) (*types.Header, error)
}

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 ProveWithdrawalParametersFaultProofs added in v1.7.7

func ProveWithdrawalParametersFaultProofs(ctx context.Context, proofCl ProofClient, l2ReceiptCl ReceiptClient, l2HeaderCl HeaderClient, txHash common.Hash, disputeGameFactoryContract *bindings.DisputeGameFactoryCaller, optimismPortal2Contract *bindingspreview.OptimismPortal2Caller) (ProvenWithdrawalParameters, error)

ProveWithdrawalParametersFaultProofs calls ProveWithdrawalParametersForBlock with the most recent L2 output after the latest game.

func ProveWithdrawalParametersForBlock added in v1.7.2

func ProveWithdrawalParametersForBlock(ctx context.Context, proofCl ProofClient, l2ReceiptCl ReceiptClient, txHash common.Hash, l2Header *types.Header, l2OutputIndex *big.Int) (ProvenWithdrawalParameters, error)

ProveWithdrawalParametersForBlock queries L1 & L2 to generate all withdrawal parameters and proof necessary to prove a withdrawal on L1. The l2Header provided is very important. It should be a block 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.

func ProveWithdrawalParametersForEvent added in v1.11.0

func ProveWithdrawalParametersForEvent(ctx context.Context, proofCl ProofClient, ev *bindings.L2ToL1MessagePasserMessagePassed, l2Header *types.Header, l2OutputIndex *big.Int) (ProvenWithdrawalParameters, error)

ProveWithdrawalParametersForEvent queries L1 to generate all withdrawal parameters and proof necessary to prove a withdrawal on L1. The l2Header provided is very important. It should be a block 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 ProvenWithdrawalParametersSuperRoots added in v1.13.5

type ProvenWithdrawalParametersSuperRoots struct {
	Nonce            *big.Int
	Sender           common.Address
	Target           common.Address
	Value            *big.Int
	GasLimit         *big.Int
	Data             []byte
	DisputeGameProxy common.Address
	OutputRootIndex  *big.Int // index of the output root in the super root
	SuperRootProof   SuperRootProof
	OutputRootProof  bindings.TypesOutputRootProof
	WithdrawalProof  [][]byte // List of trie nodes to prove L2 storage
}

func ProveWithdrawalParametersSuperRoots added in v1.13.5

func ProveWithdrawalParametersSuperRoots(
	ctx context.Context,
	rollupCfg *rollup.Config,
	depSet depset.DependencySet,
	proofCl ProofClient,
	l2ReceiptCl ReceiptClient,
	l2HeaderCl HeaderClient,
	txHash common.Hash,
	supervisorClient SupervisorClient,
	disputeGameFactoryContract *bindings.DisputeGameFactoryCaller,
	optimismPortal2Contract *bindingspreview.OptimismPortal2Caller,
) (ProvenWithdrawalParametersSuperRoots, error)

type ReceiptClient

type ReceiptClient interface {
	TransactionReceipt(context.Context, common.Hash) (*types.Receipt, error)
}

type SuperRootProof added in v1.13.5

type SuperRootProof struct {
	Version     [1]byte
	Timestamp   uint64
	OutputRoots []SuperRootProofOutputRoot
}

type SuperRootProofOutputRoot added in v1.13.5

type SuperRootProofOutputRoot struct {
	ChainID *big.Int
	Root    common.Hash
}

type SupervisorClient added in v1.13.5

type SupervisorClient interface {
	SuperRootAtTimestamp(context.Context, hexutil.Uint64) (eth.SuperRootResponse, error)
}

Jump to

Keyboard shortcuts

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