contracts

package
v1.9.5 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2024 License: MIT Imports: 25 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSimulationFailed             = errors.New("tx simulation failed")
	ErrChallengeL2BlockNotSupported = errors.New("contract version does not support challenging L2 block number")
)
View Source
var (
	ErrInvalidAddLeavesCall = errors.New("tx is not a valid addLeaves call")
	ErrInvalidPreimageKey   = errors.New("invalid preimage key")
	ErrUnsupportedKeyType   = errors.New("unsupported preimage key type")
)
View Source
var (
	ErrEventNotFound = errors.New("event not found")
)

Functions

This section is empty.

Types

type DelayedWETHContract added in v1.7.3

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

func NewDelayedWETHContract added in v1.7.3

func NewDelayedWETHContract(metrics metrics.ContractMetricer, addr common.Address, caller *batching.MultiCaller) *DelayedWETHContract

func (*DelayedWETHContract) Addr added in v1.7.7

func (*DelayedWETHContract) GetBalanceAndDelay added in v1.7.7

func (d *DelayedWETHContract) GetBalanceAndDelay(ctx context.Context, block rpcblock.Block) (*big.Int, time.Duration, error)

GetBalanceAndDelay returns the total amount of ETH controlled by this contract and the configured withdrawal delay.

func (*DelayedWETHContract) GetWithdrawals added in v1.7.3

func (d *DelayedWETHContract) GetWithdrawals(ctx context.Context, block rpcblock.Block, gameAddr common.Address, recipients ...common.Address) ([]*WithdrawalRequest, error)

GetWithdrawals returns all withdrawals made from the contract since the given block.

type DisputeGameFactoryContract

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

func (*DisputeGameFactoryContract) CreateTx added in v1.5.1

func (f *DisputeGameFactoryContract) CreateTx(ctx context.Context, traceType uint32, outputRoot common.Hash, l2BlockNum uint64) (txmgr.TxCandidate, error)

func (*DisputeGameFactoryContract) DecodeDisputeGameCreatedLog added in v1.7.6

func (f *DisputeGameFactoryContract) DecodeDisputeGameCreatedLog(rcpt *ethTypes.Receipt) (common.Address, uint32, common.Hash, error)

func (*DisputeGameFactoryContract) GetAllGames added in v1.5.0

func (f *DisputeGameFactoryContract) GetAllGames(ctx context.Context, blockHash common.Hash) ([]types.GameMetadata, error)

func (*DisputeGameFactoryContract) GetGame

func (f *DisputeGameFactoryContract) GetGame(ctx context.Context, idx uint64, blockHash common.Hash) (types.GameMetadata, error)

func (*DisputeGameFactoryContract) GetGameCount

func (f *DisputeGameFactoryContract) GetGameCount(ctx context.Context, blockHash common.Hash) (uint64, error)

func (*DisputeGameFactoryContract) GetGameFromParameters added in v1.5.1

func (f *DisputeGameFactoryContract) GetGameFromParameters(ctx context.Context, traceType uint32, outputRoot common.Hash, l2BlockNum uint64) (common.Address, error)

func (*DisputeGameFactoryContract) GetGameImpl added in v1.5.0

func (*DisputeGameFactoryContract) GetGamesAtOrAfter added in v1.5.1

func (f *DisputeGameFactoryContract) GetGamesAtOrAfter(ctx context.Context, blockHash common.Hash, earliestTimestamp uint64) ([]types.GameMetadata, error)

type FaultDisputeGameContract

type FaultDisputeGameContract interface {
	GetBalanceAndDelay(ctx context.Context, block rpcblock.Block) (*big.Int, time.Duration, common.Address, error)
	GetBlockRange(ctx context.Context) (prestateBlock uint64, poststateBlock uint64, retErr error)
	GetGameMetadata(ctx context.Context, block rpcblock.Block) (GameMetadata, error)
	GetResolvedAt(ctx context.Context, block rpcblock.Block) (time.Time, error)
	GetStartingRootHash(ctx context.Context) (common.Hash, error)
	GetSplitDepth(ctx context.Context) (types.Depth, error)
	GetCredit(ctx context.Context, recipient common.Address) (*big.Int, gameTypes.GameStatus, error)
	GetRequiredBonds(ctx context.Context, block rpcblock.Block, positions ...*big.Int) ([]*big.Int, error)
	GetCredits(ctx context.Context, block rpcblock.Block, recipients ...common.Address) ([]*big.Int, error)
	ClaimCreditTx(ctx context.Context, recipient common.Address) (txmgr.TxCandidate, error)
	GetRequiredBond(ctx context.Context, position types.Position) (*big.Int, error)
	UpdateOracleTx(ctx context.Context, claimIdx uint64, data *types.PreimageOracleData) (txmgr.TxCandidate, error)
	GetWithdrawals(ctx context.Context, block rpcblock.Block, recipients ...common.Address) ([]*WithdrawalRequest, error)
	GetOracle(ctx context.Context) (PreimageOracleContract, error)
	GetMaxClockDuration(ctx context.Context) (time.Duration, error)
	GetMaxGameDepth(ctx context.Context) (types.Depth, error)
	GetAbsolutePrestateHash(ctx context.Context) (common.Hash, error)
	GetL1Head(ctx context.Context) (common.Hash, error)
	GetStatus(ctx context.Context) (gameTypes.GameStatus, error)
	GetClaimCount(ctx context.Context) (uint64, error)
	GetClaim(ctx context.Context, idx uint64) (types.Claim, error)
	GetAllClaims(ctx context.Context, block rpcblock.Block) ([]types.Claim, error)
	IsResolved(ctx context.Context, block rpcblock.Block, claims ...types.Claim) ([]bool, error)
	IsL2BlockNumberChallenged(ctx context.Context, block rpcblock.Block) (bool, error)
	ChallengeL2BlockNumberTx(challenge *types.InvalidL2BlockNumberChallenge) (txmgr.TxCandidate, error)
	AttackTx(ctx context.Context, parent types.Claim, pivot common.Hash) (txmgr.TxCandidate, error)
	DefendTx(ctx context.Context, parent types.Claim, pivot common.Hash) (txmgr.TxCandidate, error)
	StepTx(claimIdx uint64, isAttack bool, stateData []byte, proof []byte) (txmgr.TxCandidate, error)
	CallResolveClaim(ctx context.Context, claimIdx uint64) error
	ResolveClaimTx(claimIdx uint64) (txmgr.TxCandidate, error)
	CallResolve(ctx context.Context) (gameTypes.GameStatus, error)
	ResolveTx() (txmgr.TxCandidate, error)
	Vm(ctx context.Context) (*VMContract, error)
}

type FaultDisputeGameContract0180 added in v1.7.6

type FaultDisputeGameContract0180 struct {
	FaultDisputeGameContractLatest
}

func (*FaultDisputeGameContract0180) AttackTx added in v1.7.6

func (*FaultDisputeGameContract0180) ChallengeL2BlockNumberTx added in v1.7.6

func (*FaultDisputeGameContract0180) DefendTx added in v1.7.6

func (*FaultDisputeGameContract0180) GetGameMetadata added in v1.7.6

func (f *FaultDisputeGameContract0180) GetGameMetadata(ctx context.Context, block rpcblock.Block) (GameMetadata, error)

GetGameMetadata returns the game's L1 head, L2 block number, root claim, status, and max clock duration.

func (*FaultDisputeGameContract0180) IsL2BlockNumberChallenged added in v1.7.6

func (f *FaultDisputeGameContract0180) IsL2BlockNumberChallenged(_ context.Context, _ rpcblock.Block) (bool, error)

type FaultDisputeGameContract080 added in v1.7.6

type FaultDisputeGameContract080 struct {
	FaultDisputeGameContractLatest
}

func (*FaultDisputeGameContract080) AttackTx added in v1.7.6

func (*FaultDisputeGameContract080) CallResolveClaim added in v1.7.6

func (f *FaultDisputeGameContract080) CallResolveClaim(ctx context.Context, claimIdx uint64) error

func (*FaultDisputeGameContract080) ChallengeL2BlockNumberTx added in v1.7.6

func (*FaultDisputeGameContract080) DefendTx added in v1.7.6

func (*FaultDisputeGameContract080) GetAllClaims added in v1.7.6

func (f *FaultDisputeGameContract080) GetAllClaims(ctx context.Context, block rpcblock.Block) ([]types.Claim, error)

func (*FaultDisputeGameContract080) GetClaim added in v1.7.6

func (*FaultDisputeGameContract080) GetGameMetadata added in v1.7.6

func (f *FaultDisputeGameContract080) GetGameMetadata(ctx context.Context, block rpcblock.Block) (GameMetadata, error)

GetGameMetadata returns the game's L1 head, L2 block number, root claim, status, and max clock duration.

func (*FaultDisputeGameContract080) GetMaxClockDuration added in v1.7.6

func (f *FaultDisputeGameContract080) GetMaxClockDuration(ctx context.Context) (time.Duration, error)

func (*FaultDisputeGameContract080) IsL2BlockNumberChallenged added in v1.7.6

func (f *FaultDisputeGameContract080) IsL2BlockNumberChallenged(_ context.Context, _ rpcblock.Block) (bool, error)

func (*FaultDisputeGameContract080) IsResolved added in v1.7.6

func (f *FaultDisputeGameContract080) IsResolved(ctx context.Context, block rpcblock.Block, claims ...types.Claim) ([]bool, error)

func (*FaultDisputeGameContract080) ResolveClaimTx added in v1.7.6

func (f *FaultDisputeGameContract080) ResolveClaimTx(claimIdx uint64) (txmgr.TxCandidate, error)

type FaultDisputeGameContract111 added in v1.7.6

type FaultDisputeGameContract111 struct {
	FaultDisputeGameContractLatest
}

func (*FaultDisputeGameContract111) AttackTx added in v1.7.6

func (*FaultDisputeGameContract111) DefendTx added in v1.7.6

type FaultDisputeGameContractLatest added in v1.7.6

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

func (*FaultDisputeGameContractLatest) AttackTx added in v1.7.6

func (*FaultDisputeGameContractLatest) CallResolve added in v1.7.6

func (*FaultDisputeGameContractLatest) CallResolveClaim added in v1.7.6

func (f *FaultDisputeGameContractLatest) CallResolveClaim(ctx context.Context, claimIdx uint64) error

func (*FaultDisputeGameContractLatest) ChallengeL2BlockNumberTx added in v1.7.6

func (f *FaultDisputeGameContractLatest) ChallengeL2BlockNumberTx(challenge *types.InvalidL2BlockNumberChallenge) (txmgr.TxCandidate, error)

func (*FaultDisputeGameContractLatest) ClaimCreditTx added in v1.7.6

func (f *FaultDisputeGameContractLatest) ClaimCreditTx(ctx context.Context, recipient common.Address) (txmgr.TxCandidate, error)

func (*FaultDisputeGameContractLatest) DefendTx added in v1.7.6

func (*FaultDisputeGameContractLatest) GetAbsolutePrestateHash added in v1.7.6

func (f *FaultDisputeGameContractLatest) GetAbsolutePrestateHash(ctx context.Context) (common.Hash, error)

func (*FaultDisputeGameContractLatest) GetAllClaims added in v1.7.6

func (f *FaultDisputeGameContractLatest) GetAllClaims(ctx context.Context, block rpcblock.Block) ([]types.Claim, error)

func (*FaultDisputeGameContractLatest) GetBalanceAndDelay added in v1.7.7

GetBalanceAndDelay returns the total amount of ETH controlled by this contract. Note that the ETH is actually held by the DelayedWETH contract which may be shared by multiple games. Returns the balance and the address of the contract that actually holds the balance.

func (*FaultDisputeGameContractLatest) GetBlockRange added in v1.7.6

func (f *FaultDisputeGameContractLatest) GetBlockRange(ctx context.Context) (prestateBlock uint64, poststateBlock uint64, retErr error)

GetBlockRange returns the block numbers of the absolute pre-state block (typically genesis or the bedrock activation block) and the post-state block (that the proposed output root is for).

func (*FaultDisputeGameContractLatest) GetClaim added in v1.7.6

func (*FaultDisputeGameContractLatest) GetClaimCount added in v1.7.6

func (f *FaultDisputeGameContractLatest) GetClaimCount(ctx context.Context) (uint64, error)

func (*FaultDisputeGameContractLatest) GetCredit added in v1.7.6

func (*FaultDisputeGameContractLatest) GetCredits added in v1.7.6

func (f *FaultDisputeGameContractLatest) GetCredits(ctx context.Context, block rpcblock.Block, recipients ...common.Address) ([]*big.Int, error)

func (*FaultDisputeGameContractLatest) GetGameMetadata added in v1.7.6

GetGameMetadata returns the game's L1 head, L2 block number, root claim, status, max clock duration, and is l2 block number challenged.

func (*FaultDisputeGameContractLatest) GetL1Head added in v1.7.6

func (*FaultDisputeGameContractLatest) GetMaxClockDuration added in v1.7.6

func (f *FaultDisputeGameContractLatest) GetMaxClockDuration(ctx context.Context) (time.Duration, error)

func (*FaultDisputeGameContractLatest) GetMaxGameDepth added in v1.7.6

func (f *FaultDisputeGameContractLatest) GetMaxGameDepth(ctx context.Context) (types.Depth, error)

func (*FaultDisputeGameContractLatest) GetOracle added in v1.7.6

func (*FaultDisputeGameContractLatest) GetRequiredBond added in v1.7.6

func (f *FaultDisputeGameContractLatest) GetRequiredBond(ctx context.Context, position types.Position) (*big.Int, error)

func (*FaultDisputeGameContractLatest) GetRequiredBonds added in v1.7.6

func (f *FaultDisputeGameContractLatest) GetRequiredBonds(ctx context.Context, block rpcblock.Block, positions ...*big.Int) ([]*big.Int, error)

func (*FaultDisputeGameContractLatest) GetResolvedAt added in v1.8.0

func (f *FaultDisputeGameContractLatest) GetResolvedAt(ctx context.Context, block rpcblock.Block) (time.Time, error)

func (*FaultDisputeGameContractLatest) GetSplitDepth added in v1.7.6

func (*FaultDisputeGameContractLatest) GetStartingRootHash added in v1.7.6

func (f *FaultDisputeGameContractLatest) GetStartingRootHash(ctx context.Context) (common.Hash, error)

func (*FaultDisputeGameContractLatest) GetStatus added in v1.7.6

func (*FaultDisputeGameContractLatest) GetWithdrawals added in v1.7.6

func (f *FaultDisputeGameContractLatest) GetWithdrawals(ctx context.Context, block rpcblock.Block, recipients ...common.Address) ([]*WithdrawalRequest, error)

func (*FaultDisputeGameContractLatest) IsL2BlockNumberChallenged added in v1.7.6

func (f *FaultDisputeGameContractLatest) IsL2BlockNumberChallenged(ctx context.Context, block rpcblock.Block) (bool, error)

func (*FaultDisputeGameContractLatest) IsResolved added in v1.7.6

func (f *FaultDisputeGameContractLatest) IsResolved(ctx context.Context, block rpcblock.Block, claims ...types.Claim) ([]bool, error)

func (*FaultDisputeGameContractLatest) ResolveClaimTx added in v1.7.6

func (f *FaultDisputeGameContractLatest) ResolveClaimTx(claimIdx uint64) (txmgr.TxCandidate, error)

func (*FaultDisputeGameContractLatest) ResolveTx added in v1.7.6

func (*FaultDisputeGameContractLatest) StepTx added in v1.7.6

func (f *FaultDisputeGameContractLatest) StepTx(claimIdx uint64, isAttack bool, stateData []byte, proof []byte) (txmgr.TxCandidate, error)

func (*FaultDisputeGameContractLatest) UpdateOracleTx added in v1.7.6

func (*FaultDisputeGameContractLatest) Vm added in v1.7.7

type GameMetadata added in v1.7.6

type GameMetadata struct {
	L1Head                  common.Hash
	L2BlockNum              uint64
	RootClaim               common.Hash
	Status                  gameTypes.GameStatus
	MaxClockDuration        uint64
	L2BlockNumberChallenged bool
	L2BlockNumberChallenger common.Address
}

type PreimageOracleContract

type PreimageOracleContract interface {
	Addr() common.Address
	AddGlobalDataTx(data *types.PreimageOracleData) (txmgr.TxCandidate, error)
	InitLargePreimage(uuid *big.Int, partOffset uint32, claimedSize uint32) (txmgr.TxCandidate, error)
	AddLeaves(uuid *big.Int, startingBlockIndex *big.Int, input []byte, commitments []common.Hash, finalize bool) (txmgr.TxCandidate, error)
	MinLargePreimageSize(ctx context.Context) (uint64, error)
	ChallengePeriod(ctx context.Context) (uint64, error)
	CallSqueeze(
		ctx context.Context,
		claimant common.Address,
		uuid *big.Int,
		prestateMatrix keccakTypes.StateSnapshot,
		preState keccakTypes.Leaf,
		preStateProof merkle.Proof,
		postState keccakTypes.Leaf,
		postStateProof merkle.Proof,
	) error
	Squeeze(
		claimant common.Address,
		uuid *big.Int,
		prestateMatrix keccakTypes.StateSnapshot,
		preState keccakTypes.Leaf,
		preStateProof merkle.Proof,
		postState keccakTypes.Leaf,
		postStateProof merkle.Proof,
	) (txmgr.TxCandidate, error)
	GetActivePreimages(ctx context.Context, blockHash common.Hash) ([]keccakTypes.LargePreimageMetaData, error)
	GetProposalMetadata(ctx context.Context, block rpcblock.Block, idents ...keccakTypes.LargePreimageIdent) ([]keccakTypes.LargePreimageMetaData, error)
	GetProposalTreeRoot(ctx context.Context, block rpcblock.Block, ident keccakTypes.LargePreimageIdent) (common.Hash, error)
	GetInputDataBlocks(ctx context.Context, block rpcblock.Block, ident keccakTypes.LargePreimageIdent) ([]uint64, error)
	DecodeInputData(data []byte) (*big.Int, keccakTypes.InputData, error)
	GlobalDataExists(ctx context.Context, data *types.PreimageOracleData) (bool, error)
	ChallengeTx(ident keccakTypes.LargePreimageIdent, challenge keccakTypes.Challenge) (txmgr.TxCandidate, error)
	GetMinBondLPP(ctx context.Context) (*big.Int, error)
}

func NewPreimageOracleContract

func NewPreimageOracleContract(ctx context.Context, addr common.Address, caller *batching.MultiCaller) (PreimageOracleContract, error)

type PreimageOracleContract100 added in v1.9.1

type PreimageOracleContract100 struct {
	PreimageOracleContractLatest
}

func (*PreimageOracleContract100) AddGlobalDataTx added in v1.9.1

type PreimageOracleContractLatest added in v1.9.1

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

PreimageOracleContractLatest is a binding that works with contracts implementing the IPreimageOracle interface

func (*PreimageOracleContractLatest) AddGlobalDataTx added in v1.9.1

func (*PreimageOracleContractLatest) AddLeaves added in v1.9.1

func (c *PreimageOracleContractLatest) AddLeaves(uuid *big.Int, startingBlockIndex *big.Int, input []byte, commitments []common.Hash, finalize bool) (txmgr.TxCandidate, error)

func (*PreimageOracleContractLatest) Addr added in v1.9.1

func (*PreimageOracleContractLatest) CallSqueeze added in v1.9.1

func (c *PreimageOracleContractLatest) CallSqueeze(
	ctx context.Context,
	claimant common.Address,
	uuid *big.Int,
	prestateMatrix keccakTypes.StateSnapshot,
	preState keccakTypes.Leaf,
	preStateProof merkle.Proof,
	postState keccakTypes.Leaf,
	postStateProof merkle.Proof,
) error

func (*PreimageOracleContractLatest) ChallengePeriod added in v1.9.1

func (c *PreimageOracleContractLatest) ChallengePeriod(ctx context.Context) (uint64, error)

ChallengePeriod returns the challenge period for large preimages.

func (*PreimageOracleContractLatest) ChallengeTx added in v1.9.1

func (*PreimageOracleContractLatest) DecodeInputData added in v1.9.1

func (c *PreimageOracleContractLatest) DecodeInputData(data []byte) (*big.Int, keccakTypes.InputData, error)

DecodeInputData returns the UUID and keccakTypes.InputData being added to the preimage via a addLeavesLPP call. An ErrInvalidAddLeavesCall error is returned if the call is not a valid call to addLeavesLPP. Otherwise, the uuid and input data is returned. The raw data supplied is returned so long as it can be parsed. Specifically the length of the input data is not validated to ensure it is consistent with the number of commitments.

func (*PreimageOracleContractLatest) GetActivePreimages added in v1.9.1

func (*PreimageOracleContractLatest) GetInputDataBlocks added in v1.9.1

func (*PreimageOracleContractLatest) GetMinBondLPP added in v1.9.1

func (c *PreimageOracleContractLatest) GetMinBondLPP(ctx context.Context) (*big.Int, error)

func (*PreimageOracleContractLatest) GetProposalMetadata added in v1.9.1

func (*PreimageOracleContractLatest) GetProposalTreeRoot added in v1.9.1

func (*PreimageOracleContractLatest) GlobalDataExists added in v1.9.1

func (c *PreimageOracleContractLatest) GlobalDataExists(ctx context.Context, data *types.PreimageOracleData) (bool, error)

func (*PreimageOracleContractLatest) InitLargePreimage added in v1.9.1

func (c *PreimageOracleContractLatest) InitLargePreimage(uuid *big.Int, partOffset uint32, claimedSize uint32) (txmgr.TxCandidate, error)

func (*PreimageOracleContractLatest) MinLargePreimageSize added in v1.9.1

func (c *PreimageOracleContractLatest) MinLargePreimageSize(ctx context.Context) (uint64, error)

MinLargePreimageSize returns the minimum size of a large preimage.

func (*PreimageOracleContractLatest) Squeeze added in v1.9.1

func (c *PreimageOracleContractLatest) Squeeze(
	claimant common.Address,
	uuid *big.Int,
	prestateMatrix keccakTypes.StateSnapshot,
	preState keccakTypes.Leaf,
	preStateProof merkle.Proof,
	postState keccakTypes.Leaf,
	postStateProof merkle.Proof,
) (txmgr.TxCandidate, error)

type Proposal

type Proposal struct {
	L2BlockNumber *big.Int
	OutputRoot    common.Hash
}

type VMContract

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

VMContract is a binding that works with contracts implementing the IBigStepper interface

func NewVMContract

func NewVMContract(addr common.Address, caller *batching.MultiCaller) *VMContract

func (*VMContract) Addr added in v1.7.7

func (c *VMContract) Addr() common.Address

func (*VMContract) Oracle

type VersionedBuilder added in v1.9.1

type VersionedBuilder[C any] struct {
	// contains filtered or unexported fields
}

func (*VersionedBuilder[C]) AddVersion added in v1.9.1

func (v *VersionedBuilder[C]) AddVersion(major int, minor int, factory func() (C, error))

func (*VersionedBuilder[C]) Build added in v1.9.1

func (v *VersionedBuilder[C]) Build(ctx context.Context, caller *batching.MultiCaller, contractAbi *abi.ABI, addr common.Address, defaultVersion func() (C, error)) (C, error)

type WithdrawalRequest added in v1.7.3

type WithdrawalRequest struct {
	Amount    *big.Int
	Timestamp *big.Int
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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