disputegame

package
v1.4.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2023 License: MIT Imports: 33 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CorrectAlphabet = "abcdefghijklmnop"

Functions

This section is empty.

Types

type AlphabetGameHelper added in v1.1.4

type AlphabetGameHelper struct {
	FaultGameHelper
	// contains filtered or unexported fields
}

func (*AlphabetGameHelper) CreateDishonestHelper added in v1.2.0

func (g *AlphabetGameHelper) CreateDishonestHelper(alphabetTrace string, depth uint64, defender bool) *DishonestHelper

func (*AlphabetGameHelper) CreateHonestActor added in v1.1.6

func (g *AlphabetGameHelper) CreateHonestActor(alphabetTrace string, depth uint64) *HonestHelper

func (*AlphabetGameHelper) StartChallenger added in v1.1.4

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

type CannonGameHelper added in v1.1.4

type CannonGameHelper struct {
	FaultGameHelper
}

func (*CannonGameHelper) CreateHonestActor added in v1.1.4

func (g *CannonGameHelper) CreateHonestActor(ctx context.Context, rollupCfg *rollup.Config, l2Genesis *core.Genesis, l1Client *ethclient.Client, l1Endpoint string, l2Endpoint string, options ...challenger.Option) *HonestHelper

func (*CannonGameHelper) StartChallenger added in v1.1.4

func (g *CannonGameHelper) StartChallenger(ctx context.Context, rollupCfg *rollup.Config, l2Genesis *core.Genesis, l1Endpoint string, l2Endpoint string, name string, options ...challenger.Option) *challenger.Helper

type ContractClaim

type ContractClaim struct {
	ParentIndex uint32
	Countered   bool
	Claim       [32]byte
	Position    *big.Int
	Clock       *big.Int
}

type DishonestHelper added in v1.1.6

type DishonestHelper struct {
	*FaultGameHelper
	*HonestHelper
	// contains filtered or unexported fields
}

func (*DishonestHelper) Attack added in v1.1.6

func (t *DishonestHelper) Attack(ctx context.Context, claimIndex int64)

func (*DishonestHelper) AttackCorrect added in v1.1.6

func (t *DishonestHelper) AttackCorrect(ctx context.Context, claimIndex int64)

func (*DishonestHelper) Defend added in v1.1.6

func (t *DishonestHelper) Defend(ctx context.Context, claimIndex int64)

func (*DishonestHelper) DefendCorrect added in v1.1.6

func (t *DishonestHelper) DefendCorrect(ctx context.Context, claimIndex int64)

func (*DishonestHelper) ExhaustDishonestClaims added in v1.1.6

func (d *DishonestHelper) ExhaustDishonestClaims(ctx context.Context)

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 ErrWithData added in v1.1.6

type ErrWithData interface {
	ErrorData() interface{}
}

type FactoryHelper

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

func NewFactoryHelper

func NewFactoryHelper(t *testing.T, ctx context.Context, deployments *genesis.L1Deployments, client *ethclient.Client) *FactoryHelper

func (*FactoryHelper) StartAlphabetGame

func (h *FactoryHelper) StartAlphabetGame(ctx context.Context, claimedAlphabet string) *AlphabetGameHelper

func (*FactoryHelper) StartCannonGame added in v1.1.4

func (h *FactoryHelper) StartCannonGame(ctx context.Context, rootClaim common.Hash) *CannonGameHelper

func (*FactoryHelper) StartCannonGameWithCorrectRoot added in v1.1.6

func (h *FactoryHelper) StartCannonGameWithCorrectRoot(ctx context.Context, rollupCfg *rollup.Config, l2Genesis *core.Genesis, l1Endpoint string, l2Endpoint string, options ...challenger.Option) (*CannonGameHelper, *HonestHelper)

func (*FactoryHelper) StartChallenger added in v1.1.4

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

func (*FactoryHelper) StartOutputCannonGame added in v1.4.2

func (h *FactoryHelper) StartOutputCannonGame(ctx context.Context, rollupEndpoint string, rootClaim common.Hash) *OutputCannonGameHelper

type FaultGameHelper

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

func (*FaultGameHelper) Addr added in v1.1.6

func (g *FaultGameHelper) Addr() common.Address

func (*FaultGameHelper) Attack added in v1.1.4

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

func (*FaultGameHelper) ChallengeRootClaim added in v1.1.6

func (g *FaultGameHelper) ChallengeRootClaim(ctx context.Context, performMove Mover, attemptStep Stepper)

ChallengeRootClaim uses the supplied Mover and Stepper to perform moves and steps in an attempt to challenge the root claim. It is assumed that the output root being disputed is invalid 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 invalid, it should not be possible for the Stepper to call step successfully.

func (*FaultGameHelper) Defend added in v1.1.4

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

func (*FaultGameHelper) DefendRootClaim added in v1.1.6

func (g *FaultGameHelper) DefendRootClaim(ctx context.Context, performMove Mover)

DefendRootClaim uses the supplied Mover to perform moves in an attempt to defend the root claim. It is assumed that the output root being disputed is valid 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.

func (*FaultGameHelper) GameDuration added in v1.1.4

func (g *FaultGameHelper) GameDuration(ctx context.Context) time.Duration

func (*FaultGameHelper) GetClaimPosition added in v1.2.0

func (g *FaultGameHelper) GetClaimPosition(ctx context.Context, claimIdx int64) types.Position

func (*FaultGameHelper) GetClaimValue added in v1.1.6

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

func (*FaultGameHelper) LogGameData added in v1.1.4

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

func (*FaultGameHelper) MaxDepth added in v1.1.4

func (g *FaultGameHelper) MaxDepth(ctx context.Context) int64

func (*FaultGameHelper) Resolve

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

func (*FaultGameHelper) ResolveClaim added in v1.1.6

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

ResolveClaim resolves a single subgame

func (*FaultGameHelper) Status added in v1.1.6

func (g *FaultGameHelper) Status(ctx context.Context) Status

func (*FaultGameHelper) StepFails added in v1.1.6

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

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

func (*FaultGameHelper) WaitForAllClaimsCountered added in v1.1.6

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

func (*FaultGameHelper) WaitForClaimAtDepth added in v1.1.6

func (g *FaultGameHelper) WaitForClaimAtDepth(ctx context.Context, depth int)

func (*FaultGameHelper) WaitForClaimAtMaxDepth

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

func (*FaultGameHelper) WaitForClaimCount

func (g *FaultGameHelper) 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 (*FaultGameHelper) WaitForGameStatus

func (g *FaultGameHelper) WaitForGameStatus(ctx context.Context, expected Status)

func (*FaultGameHelper) WaitForInactivity added in v1.1.6

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

func (*FaultGameHelper) WaitForNewClaim added in v1.1.6

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

type HonestHelper added in v1.1.4

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

func (*HonestHelper) Attack added in v1.1.4

func (h *HonestHelper) Attack(ctx context.Context, claimIdx int64)

func (*HonestHelper) Defend added in v1.1.4

func (h *HonestHelper) Defend(ctx context.Context, claimIdx int64)

func (*HonestHelper) StepFails added in v1.1.6

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

type Mover added in v1.1.6

type Mover func(parentClaimIdx int64)

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

type OutputCannonGameHelper added in v1.4.2

type OutputCannonGameHelper struct {
	FaultGameHelper
	// contains filtered or unexported fields
}

func (*OutputCannonGameHelper) StartChallenger added in v1.4.2

func (g *OutputCannonGameHelper) StartChallenger(
	ctx context.Context,
	rollupCfg *rollup.Config,
	l2Genesis *core.Genesis,
	rollupEndpoint string,
	l1Endpoint string,
	l2Endpoint string,
	name string,
	options ...challenger.Option,
) *challenger.Helper

func (*OutputCannonGameHelper) WaitForCorrectOutputRoot

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

type Status

type Status uint8
const (
	StatusInProgress Status = iota
	StatusChallengerWins
	StatusDefenderWins
)

func (Status) String added in v1.1.4

func (s Status) String() string

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

Jump to

Keyboard shortcuts

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