disputegame

package
v1.7.6 Latest Latest
Warning

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

Go to latest
Published: May 23, 2024 License: MIT Imports: 45 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// TestKey is the same test key that geth uses
	TestKey, _  = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
	TestAddress = crypto.PubkeyToAddress(TestKey.PublicKey)
)

Functions

This section is empty.

Types

type ClaimHelper added in v1.4.2

type ClaimHelper struct {
	Index       int64
	ParentIndex int
	Position    types.Position
	// contains filtered or unexported fields
}

func (*ClaimHelper) AgreesWithOutputRoot added in v1.4.2

func (c *ClaimHelper) AgreesWithOutputRoot() bool

func (*ClaimHelper) Attack added in v1.4.2

func (c *ClaimHelper) Attack(ctx context.Context, value common.Hash, opts ...MoveOpt) *ClaimHelper

func (*ClaimHelper) Defend added in v1.4.2

func (c *ClaimHelper) Defend(ctx context.Context, value common.Hash, opts ...MoveOpt) *ClaimHelper

func (*ClaimHelper) Depth added in v1.4.3

func (c *ClaimHelper) Depth() types.Depth

func (*ClaimHelper) IsBottomGameRoot added in v1.4.3

func (c *ClaimHelper) IsBottomGameRoot(ctx context.Context) bool

func (*ClaimHelper) IsMaxDepth added in v1.4.2

func (c *ClaimHelper) IsMaxDepth(ctx context.Context) bool

func (*ClaimHelper) IsOutputRoot added in v1.4.2

func (c *ClaimHelper) IsOutputRoot(ctx context.Context) bool

func (*ClaimHelper) IsOutputRootLeaf added in v1.4.2

func (c *ClaimHelper) IsOutputRootLeaf(ctx context.Context) bool

func (*ClaimHelper) IsRootClaim added in v1.4.3

func (c *ClaimHelper) IsRootClaim() bool

func (*ClaimHelper) RequireCorrectOutputRoot added in v1.4.2

func (c *ClaimHelper) RequireCorrectOutputRoot(ctx context.Context)

func (*ClaimHelper) RequireDifferentClaimValue added in v1.4.2

func (c *ClaimHelper) RequireDifferentClaimValue(other *ClaimHelper)

func (*ClaimHelper) RequireOnlyCounteredBy added in v1.4.3

func (c *ClaimHelper) RequireOnlyCounteredBy(ctx context.Context, expected ...*ClaimHelper)

func (*ClaimHelper) WaitForCounterClaim added in v1.4.2

func (c *ClaimHelper) WaitForCounterClaim(ctx context.Context, ignoreClaims ...*ClaimHelper) *ClaimHelper

WaitForCounterClaim waits for the claim to be countered by another claim being posted. It returns a helper for the claim that countered this one.

func (*ClaimHelper) WaitForCountered added in v1.4.2

func (c *ClaimHelper) WaitForCountered(ctx context.Context)

WaitForCountered waits until the claim is countered either by a child claim or by a step call.

type ContractClaim

type ContractClaim struct {
	ParentIndex uint32
	CounteredBy common.Address
	Claimant    common.Address
	Bond        *big.Int
	Claim       [32]byte
	Position    *big.Int
	Clock       *big.Int
}

type DefendClaimOpt added in v1.5.1

type DefendClaimOpt func(cfg *defendClaimCfg)

func WithoutWaitingForStep added in v1.5.1

func WithoutWaitingForStep() DefendClaimOpt

type DishonestHelper added in v1.1.6

type DishonestHelper struct {
	*OutputGameHelper
	*OutputHonestHelper
	// contains filtered or unexported fields
}

func (*DishonestHelper) ExhaustDishonestClaims added in v1.1.6

func (d *DishonestHelper) ExhaustDishonestClaims(ctx context.Context, rootClaim *ClaimHelper)

ExhaustDishonestClaims makes all possible significant moves (mod honest challenger's) in a game. It is very inefficient and should NOT be used on games with large depths

type DisputeSystem added in v1.4.2

type DisputeSystem interface {
	L1BeaconEndpoint() string
	NodeEndpoint(name string) string
	NodeClient(name string) *ethclient.Client
	RollupEndpoint(name string) string
	RollupClient(name string) *sources.RollupClient

	L1Deployments() *genesis.L1Deployments
	RollupCfg() *rollup.Config
	L2Genesis() *core.Genesis

	AdvanceTime(time.Duration)
}

type ErrWithData added in v1.1.6

type ErrWithData interface {
	ErrorData() interface{}
}

type FactoryHelper

type FactoryHelper struct {
	T           *testing.T
	Require     *require.Assertions
	System      DisputeSystem
	Client      *ethclient.Client
	Opts        *bind.TransactOpts
	FactoryAddr common.Address
	Factory     *bindings.DisputeGameFactory
}

func NewFactoryHelper

func NewFactoryHelper(t *testing.T, ctx context.Context, system DisputeSystem) *FactoryHelper

func (*FactoryHelper) CreateBisectionGameExtraData added in v1.7.6

func (h *FactoryHelper) CreateBisectionGameExtraData(l2Node string, l2BlockNumber uint64, cfg *GameCfg) []byte

func (*FactoryHelper) GetL1Head added in v1.7.6

func (*FactoryHelper) PreimageHelper added in v1.5.0

func (h *FactoryHelper) PreimageHelper(ctx context.Context) *preimage.Helper

func (*FactoryHelper) StartChallenger added in v1.1.4

func (h *FactoryHelper) StartChallenger(ctx context.Context, name string, options ...challenger.Option) *challenger.Helper

func (*FactoryHelper) StartOutputAlphabetGame added in v1.4.2

func (h *FactoryHelper) StartOutputAlphabetGame(ctx context.Context, l2Node string, l2BlockNumber uint64, rootClaim common.Hash, opts ...GameOpt) *OutputAlphabetGameHelper

func (*FactoryHelper) StartOutputAlphabetGameWithCorrectRoot added in v1.4.3

func (h *FactoryHelper) StartOutputAlphabetGameWithCorrectRoot(ctx context.Context, l2Node string, l2BlockNumber uint64, opts ...GameOpt) *OutputAlphabetGameHelper

func (*FactoryHelper) StartOutputCannonGame added in v1.4.2

func (h *FactoryHelper) StartOutputCannonGame(ctx context.Context, l2Node string, l2BlockNumber uint64, rootClaim common.Hash, opts ...GameOpt) *OutputCannonGameHelper

func (*FactoryHelper) StartOutputCannonGameWithCorrectRoot added in v1.4.2

func (h *FactoryHelper) StartOutputCannonGameWithCorrectRoot(ctx context.Context, l2Node string, l2BlockNumber uint64, opts ...GameOpt) *OutputCannonGameHelper

func (*FactoryHelper) WaitForBlock added in v1.7.6

func (h *FactoryHelper) WaitForBlock(l2Node string, l2BlockNumber uint64, cfg *GameCfg)

type GameCfg added in v1.7.6

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

func NewGameCfg added in v1.7.6

func NewGameCfg(opts ...GameOpt) *GameCfg

type GameOpt added in v1.7.2

type GameOpt interface {
	Apply(cfg *GameCfg)
}

func WithFutureProposal added in v1.7.2

func WithFutureProposal() GameOpt

func WithUnsafeProposal added in v1.7.2

func WithUnsafeProposal() GameOpt

type MoveOpt added in v1.7.2

type MoveOpt interface {
	Apply(cfg *moveCfg)
}

func WithIgnoreDuplicates added in v1.7.2

func WithIgnoreDuplicates() MoveOpt

func WithTransactOpts added in v1.7.2

func WithTransactOpts(Opts *bind.TransactOpts) MoveOpt

type Mover added in v1.1.6

type Mover func(parent *ClaimHelper) *ClaimHelper

Mover is a function that either attacks or defends the claim at parentClaimIdx

type OutputAlphabetGameHelper added in v1.4.2

type OutputAlphabetGameHelper struct {
	OutputGameHelper
}

func (*OutputAlphabetGameHelper) CreateDishonestHelper added in v1.4.3

func (g *OutputAlphabetGameHelper) CreateDishonestHelper(ctx context.Context, l2Node string, defender bool) *DishonestHelper

func (*OutputAlphabetGameHelper) CreateHonestActor added in v1.4.3

func (g *OutputAlphabetGameHelper) CreateHonestActor(ctx context.Context, l2Node string) *OutputHonestHelper

func (*OutputAlphabetGameHelper) StartChallenger added in v1.4.2

func (g *OutputAlphabetGameHelper) StartChallenger(
	ctx context.Context,
	l2Node string,
	name string,
	options ...challenger.Option,
) *challenger.Helper

type OutputCannonGameHelper added in v1.4.2

type OutputCannonGameHelper struct {
	OutputGameHelper
}

func (*OutputCannonGameHelper) ChallengeToPreimageLoad added in v1.5.1

func (g *OutputCannonGameHelper) ChallengeToPreimageLoad(ctx context.Context, outputRootClaim *ClaimHelper, challengerKey *ecdsa.PrivateKey, preimage utils.PreimageOpt, preimageCheck PreimageLoadCheck, preloadPreimage bool)

ChallengeToPreimageLoad challenges the supplied execution root claim by inducing a step that requires a preimage to be loaded It does this by: 1. Identifying the first state transition that loads a global preimage 2. Descending the execution game tree to reach the step that loads the preimage 3. Asserting that the preimage was indeed loaded by an honest challenger (assuming the preimage is not preloaded) This expects an odd execution game depth in order for the honest challenger to step on our leaf claim

func (*OutputCannonGameHelper) CreateHonestActor added in v1.4.2

func (g *OutputCannonGameHelper) CreateHonestActor(ctx context.Context, l2Node string, options ...challenger.Option) *OutputHonestHelper

func (*OutputCannonGameHelper) CreateStepLargePreimageLoadCheck added in v1.5.1

func (g *OutputCannonGameHelper) CreateStepLargePreimageLoadCheck(ctx context.Context, sender common.Address) PreimageLoadCheck

func (*OutputCannonGameHelper) CreateStepPreimageLoadCheck added in v1.5.1

func (g *OutputCannonGameHelper) CreateStepPreimageLoadCheck(ctx context.Context) PreimageLoadCheck

func (*OutputCannonGameHelper) StartChallenger added in v1.4.2

func (g *OutputCannonGameHelper) StartChallenger(ctx context.Context, name string, options ...challenger.Option) *challenger.Helper

func (*OutputCannonGameHelper) VerifyPreimage added in v1.7.2

func (g *OutputCannonGameHelper) VerifyPreimage(ctx context.Context, outputRootClaim *ClaimHelper, preimageKey preimage.Key)

type OutputGameHelper added in v1.4.2

type OutputGameHelper struct {
	T                     *testing.T
	Require               *require.Assertions
	Client                *ethclient.Client
	Opts                  *bind.TransactOpts
	Game                  contracts.FaultDisputeGameContract
	GameBindings          *bindings.FaultDisputeGame
	FactoryAddr           common.Address
	Addr                  common.Address
	CorrectOutputProvider *outputs.OutputTraceProvider
	System                DisputeSystem
}

func NewOutputGameHelper added in v1.7.6

func NewOutputGameHelper(t *testing.T, require *require.Assertions, client *ethclient.Client, opts *bind.TransactOpts,
	game contracts.FaultDisputeGameContract, gameBindings *bindings.FaultDisputeGame, factoryAddr common.Address, addr common.Address, correctOutputProvider *outputs.OutputTraceProvider, system DisputeSystem) *OutputGameHelper

func (*OutputGameHelper) Attack added in v1.4.2

func (g *OutputGameHelper) Attack(ctx context.Context, claimIdx int64, claim common.Hash, Opts ...MoveOpt)

func (*OutputGameHelper) AvailableCredit added in v1.7.2

func (g *OutputGameHelper) AvailableCredit(ctx context.Context, addr common.Address) *big.Int

func (*OutputGameHelper) ChallengeClaim added in v1.4.3

func (g *OutputGameHelper) ChallengeClaim(ctx context.Context, claim *ClaimHelper, performMove Mover, attemptStep Stepper)

ChallengeClaim uses the supplied functions to perform moves and steps in an attempt to challenge the supplied claim. It is assumed that the claim being disputed is valid and that an honest op-challenger is already running. When the game has reached the maximum depth it calls the Stepper to attempt to counter the leaf claim. Since the output root is valid, it should not be possible for the Stepper to call step successfully.

func (*OutputGameHelper) ChallengePeriod added in v1.5.1

func (g *OutputGameHelper) ChallengePeriod(ctx context.Context) uint64

ChallengePeriod returns the challenge period fetched from the PreimageOracle contract. The returned uint64 value is the number of seconds for the challenge period.

func (*OutputGameHelper) ChallengePeriodStartTime added in v1.5.1

func (g *OutputGameHelper) ChallengePeriodStartTime(ctx context.Context, sender common.Address, data *types.PreimageOracleData) uint64

ChallengePeriodStartTime returns the start time of the challenge period for a given large preimage claim. If the returned start time is 0, the challenge period has not started.

func (*OutputGameHelper) Credit added in v1.5.1

func (g *OutputGameHelper) Credit(ctx context.Context, addr common.Address) *big.Int

func (*OutputGameHelper) CreditUnlockDuration added in v1.7.2

func (g *OutputGameHelper) CreditUnlockDuration(ctx context.Context) time.Duration

func (*OutputGameHelper) Defend added in v1.4.2

func (g *OutputGameHelper) Defend(ctx context.Context, claimIdx int64, claim common.Hash, Opts ...MoveOpt)

func (*OutputGameHelper) DefendClaim added in v1.4.3

func (g *OutputGameHelper) DefendClaim(ctx context.Context, claim *ClaimHelper, performMove Mover, Opts ...DefendClaimOpt) *ClaimHelper

DefendClaim uses the supplied Mover to perform moves in an attempt to defend the supplied claim. It is assumed that the specified claim is invalid and that an honest op-challenger is already running. When the game has reached the maximum depth it waits for the honest challenger to counter the leaf claim with step. Returns the final leaf claim

func (*OutputGameHelper) DisputeBlock added in v1.5.1

func (g *OutputGameHelper) DisputeBlock(ctx context.Context, disputeBlockNum uint64) *ClaimHelper

DisputeBlock posts claims from both the honest and dishonest actor to progress the output root part of the game through to the split depth and the claims are setup such that the last block in the game range is the block to execute cannon on. ie the first block the honest and dishonest actors disagree about is the l2 block of the game.

func (*OutputGameHelper) DisputeLastBlock added in v1.4.2

func (g *OutputGameHelper) DisputeLastBlock(ctx context.Context) *ClaimHelper

func (*OutputGameHelper) ExecDepth added in v1.5.0

func (g *OutputGameHelper) ExecDepth(ctx context.Context) types.Depth

func (*OutputGameHelper) GameData added in v1.7.6

func (g *OutputGameHelper) GameData(ctx context.Context) string

func (*OutputGameHelper) GetClaimValue added in v1.4.2

func (g *OutputGameHelper) GetClaimValue(ctx context.Context, claimIdx int64) common.Hash

func (*OutputGameHelper) GetL1Head added in v1.7.6

func (g *OutputGameHelper) GetL1Head(ctx context.Context) eth.BlockID

func (*OutputGameHelper) L2BlockNum added in v1.4.2

func (g *OutputGameHelper) L2BlockNum(ctx context.Context) uint64

func (*OutputGameHelper) LogGameData added in v1.4.2

func (g *OutputGameHelper) LogGameData(ctx context.Context)

func (*OutputGameHelper) MaxClockDuration added in v1.7.4

func (g *OutputGameHelper) MaxClockDuration(ctx context.Context) time.Duration

func (*OutputGameHelper) MaxDepth added in v1.4.2

func (g *OutputGameHelper) MaxDepth(ctx context.Context) types.Depth

func (*OutputGameHelper) Resolve added in v1.4.2

func (g *OutputGameHelper) Resolve(ctx context.Context)

func (*OutputGameHelper) ResolveClaim added in v1.4.2

func (g *OutputGameHelper) ResolveClaim(ctx context.Context, claimIdx int64)

ResolveClaim resolves a single subgame

func (*OutputGameHelper) RootClaim added in v1.4.2

func (g *OutputGameHelper) RootClaim(ctx context.Context) *ClaimHelper

func (*OutputGameHelper) SplitDepth added in v1.4.2

func (g *OutputGameHelper) SplitDepth(ctx context.Context) types.Depth

func (*OutputGameHelper) StartingBlockNum added in v1.7.2

func (g *OutputGameHelper) StartingBlockNum(ctx context.Context) uint64

func (*OutputGameHelper) Status added in v1.4.2

func (*OutputGameHelper) StepFails added in v1.4.2

func (g *OutputGameHelper) StepFails(claimIdx int64, isAttack bool, stateData []byte, proof []byte)

StepFails attempts to call step and verifies that it fails with ValidStep()

func (*OutputGameHelper) UploadPreimage added in v1.7.6

func (g *OutputGameHelper) UploadPreimage(ctx context.Context, data *types.PreimageOracleData, privateKey *ecdsa.PrivateKey)

func (*OutputGameHelper) WaitForAllClaimsCountered added in v1.4.2

func (g *OutputGameHelper) WaitForAllClaimsCountered(ctx context.Context)

func (*OutputGameHelper) WaitForChallengePeriodStart added in v1.5.1

func (g *OutputGameHelper) WaitForChallengePeriodStart(ctx context.Context, sender common.Address, data *types.PreimageOracleData)

WaitForChallengePeriodStart waits for the challenge period to start for a given large preimage claim.

func (*OutputGameHelper) WaitForClaimAtDepth added in v1.4.2

func (g *OutputGameHelper) WaitForClaimAtDepth(ctx context.Context, depth types.Depth)

func (*OutputGameHelper) WaitForClaimAtMaxDepth added in v1.4.2

func (g *OutputGameHelper) WaitForClaimAtMaxDepth(ctx context.Context, countered bool)

func (*OutputGameHelper) WaitForClaimCount added in v1.4.2

func (g *OutputGameHelper) WaitForClaimCount(ctx context.Context, count int64)

WaitForClaimCount waits until there are at least count claims in the game. This does not check that the number of claims is exactly the specified count to avoid intermittent failures where a challenger posts an additional claim before this method sees the number of claims it was waiting for.

func (*OutputGameHelper) WaitForCorrectOutputRoot added in v1.4.2

func (g *OutputGameHelper) WaitForCorrectOutputRoot(ctx context.Context, claimIdx int64)

func (*OutputGameHelper) WaitForGameStatus added in v1.4.2

func (g *OutputGameHelper) WaitForGameStatus(ctx context.Context, expected gameTypes.GameStatus)

func (*OutputGameHelper) WaitForInactivity added in v1.4.2

func (g *OutputGameHelper) WaitForInactivity(ctx context.Context, numInactiveBlocks int, untilGameEnds bool)

func (*OutputGameHelper) WaitForL2BlockNumberChallenged added in v1.7.6

func (g *OutputGameHelper) WaitForL2BlockNumberChallenged(ctx context.Context)

func (*OutputGameHelper) WaitForNewClaim added in v1.4.2

func (g *OutputGameHelper) WaitForNewClaim(ctx context.Context, checkPoint int64) (int64, error)

func (*OutputGameHelper) WaitForNoAvailableCredit added in v1.7.2

func (g *OutputGameHelper) WaitForNoAvailableCredit(ctx context.Context, addr common.Address)

func (*OutputGameHelper) WaitForPreimageInOracle added in v1.7.6

func (g *OutputGameHelper) WaitForPreimageInOracle(ctx context.Context, data *types.PreimageOracleData)

func (*OutputGameHelper) WethBalance added in v1.7.2

func (g *OutputGameHelper) WethBalance(ctx context.Context, addr common.Address) *big.Int

type OutputHonestHelper added in v1.4.2

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

func NewOutputHonestHelper added in v1.7.6

func NewOutputHonestHelper(t *testing.T, require *require.Assertions, game *OutputGameHelper, contract contracts.FaultDisputeGameContract, correctTrace types.TraceAccessor) *OutputHonestHelper

func (*OutputHonestHelper) Attack added in v1.4.2

func (h *OutputHonestHelper) Attack(ctx context.Context, claimIdx int64, opts ...MoveOpt)

func (*OutputHonestHelper) AttackClaim added in v1.4.3

func (h *OutputHonestHelper) AttackClaim(ctx context.Context, claim *ClaimHelper, opts ...MoveOpt) *ClaimHelper

func (*OutputHonestHelper) CounterClaim added in v1.7.2

func (h *OutputHonestHelper) CounterClaim(ctx context.Context, claim *ClaimHelper, opts ...MoveOpt) *ClaimHelper

func (*OutputHonestHelper) Defend added in v1.4.2

func (h *OutputHonestHelper) Defend(ctx context.Context, claimIdx int64, opts ...MoveOpt)

func (*OutputHonestHelper) DefendClaim added in v1.4.3

func (h *OutputHonestHelper) DefendClaim(ctx context.Context, claim *ClaimHelper, opts ...MoveOpt) *ClaimHelper

func (*OutputHonestHelper) StepClaimFails added in v1.4.3

func (h *OutputHonestHelper) StepClaimFails(ctx context.Context, claim *ClaimHelper, isAttack bool)

func (*OutputHonestHelper) StepFails added in v1.4.2

func (h *OutputHonestHelper) StepFails(ctx context.Context, claimIdx int64, isAttack bool)

type PreimageLoadCheck added in v1.5.1

type PreimageLoadCheck func(types.TraceProvider, uint64) error

type Stepper added in v1.1.6

type Stepper func(parentClaimIdx int64)

Stepper is a function that attempts to perform a step against the claim at parentClaimIdx

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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