contracts

package
v0.0.0-...-5d12baa Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2024 License: MIT Imports: 25 Imported by: 0

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

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

func NewDelayedWETHContract

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

func (*DelayedWETHContract) Addr

func (*DelayedWETHContract) GetBalanceAndDelay

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

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

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

func (*DisputeGameFactoryContract) DecodeDisputeGameCreatedLog

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

func (*DisputeGameFactoryContract) GetAllGames

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

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

func (*DisputeGameFactoryContract) GetGameImpl

func (f *DisputeGameFactoryContract) GetGameImpl(ctx context.Context, gameType uint32) (common.Address, error)

func (*DisputeGameFactoryContract) GetGamesAtOrAfter

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)
	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, gameAddr common.Address, 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

type FaultDisputeGameContract0180 struct {
	FaultDisputeGameContractLatest
}

func (*FaultDisputeGameContract0180) AttackTx

func (*FaultDisputeGameContract0180) ChallengeL2BlockNumberTx

func (*FaultDisputeGameContract0180) DefendTx

func (*FaultDisputeGameContract0180) GetGameMetadata

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

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

type FaultDisputeGameContract080

type FaultDisputeGameContract080 struct {
	FaultDisputeGameContractLatest
}

func (*FaultDisputeGameContract080) AttackTx

func (*FaultDisputeGameContract080) CallResolveClaim

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

func (*FaultDisputeGameContract080) ChallengeL2BlockNumberTx

func (*FaultDisputeGameContract080) DefendTx

func (*FaultDisputeGameContract080) GetAllClaims

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

func (*FaultDisputeGameContract080) GetClaim

func (*FaultDisputeGameContract080) GetGameMetadata

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

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

func (*FaultDisputeGameContract080) IsL2BlockNumberChallenged

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

func (*FaultDisputeGameContract080) IsResolved

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

func (*FaultDisputeGameContract080) ResolveClaimTx

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

type FaultDisputeGameContract111

type FaultDisputeGameContract111 struct {
	FaultDisputeGameContractLatest
}

func (*FaultDisputeGameContract111) AttackTx

func (*FaultDisputeGameContract111) DefendTx

type FaultDisputeGameContractLatest

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

func (*FaultDisputeGameContractLatest) AttackTx

func (*FaultDisputeGameContractLatest) CallResolve

func (*FaultDisputeGameContractLatest) CallResolveClaim

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

func (*FaultDisputeGameContractLatest) ChallengeL2BlockNumberTx

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

func (*FaultDisputeGameContractLatest) ClaimCreditTx

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

func (*FaultDisputeGameContractLatest) DefendTx

func (*FaultDisputeGameContractLatest) GetAbsolutePrestateHash

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

func (*FaultDisputeGameContractLatest) GetAllClaims

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

func (*FaultDisputeGameContractLatest) GetBalanceAndDelay

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

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

func (*FaultDisputeGameContractLatest) GetClaimCount

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

func (*FaultDisputeGameContractLatest) GetCredit

func (*FaultDisputeGameContractLatest) GetCredits

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

func (*FaultDisputeGameContractLatest) GetGameMetadata

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

func (*FaultDisputeGameContractLatest) GetMaxClockDuration

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

func (*FaultDisputeGameContractLatest) GetMaxGameDepth

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

func (*FaultDisputeGameContractLatest) GetOracle

func (*FaultDisputeGameContractLatest) GetRequiredBond

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

func (*FaultDisputeGameContractLatest) GetRequiredBonds

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

func (*FaultDisputeGameContractLatest) GetSplitDepth

func (*FaultDisputeGameContractLatest) GetStartingRootHash

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

func (*FaultDisputeGameContractLatest) GetStatus

func (*FaultDisputeGameContractLatest) GetWithdrawals

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

func (*FaultDisputeGameContractLatest) IsL2BlockNumberChallenged

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

func (*FaultDisputeGameContractLatest) IsResolved

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

func (*FaultDisputeGameContractLatest) ResolveClaimTx

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

func (*FaultDisputeGameContractLatest) ResolveTx

func (*FaultDisputeGameContractLatest) StepTx

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

func (*FaultDisputeGameContractLatest) UpdateOracleTx

func (*FaultDisputeGameContractLatest) Vm

type GameMetadata

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 struct {
	// contains filtered or unexported fields
}

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

func NewPreimageOracleContract

func NewPreimageOracleContract(addr common.Address, caller *batching.MultiCaller) *PreimageOracleContract

func (*PreimageOracleContract) AddGlobalDataTx

func (*PreimageOracleContract) AddLeaves

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

func (*PreimageOracleContract) Addr

func (*PreimageOracleContract) CallSqueeze

func (c *PreimageOracleContract) 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 (*PreimageOracleContract) ChallengePeriod

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

ChallengePeriod returns the challenge period for large preimages.

func (*PreimageOracleContract) ChallengeTx

func (*PreimageOracleContract) DecodeInputData

func (c *PreimageOracleContract) 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 (*PreimageOracleContract) GetActivePreimages

func (c *PreimageOracleContract) GetActivePreimages(ctx context.Context, blockHash common.Hash) ([]keccakTypes.LargePreimageMetaData, error)

func (*PreimageOracleContract) GetInputDataBlocks

func (c *PreimageOracleContract) GetInputDataBlocks(ctx context.Context, block rpcblock.Block, ident keccakTypes.LargePreimageIdent) ([]uint64, error)

func (*PreimageOracleContract) GetMinBondLPP

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

func (*PreimageOracleContract) GetProposalMetadata

func (*PreimageOracleContract) GetProposalTreeRoot

func (c *PreimageOracleContract) GetProposalTreeRoot(ctx context.Context, block rpcblock.Block, ident keccakTypes.LargePreimageIdent) (common.Hash, error)

func (*PreimageOracleContract) GlobalDataExists

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

func (*PreimageOracleContract) InitLargePreimage

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

func (*PreimageOracleContract) MinLargePreimageSize

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

MinLargePreimageSize returns the minimum size of a large preimage.

func (*PreimageOracleContract) Squeeze

func (c *PreimageOracleContract) 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

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

func (*VMContract) Oracle

type WithdrawalRequest

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