disputegame

package
v0.0.0-...-86af830 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CorrectAlphabet = "abcdefghijklmnop"

Functions

This section is empty.

Types

type AlphabetGameHelper

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

func (*AlphabetGameHelper) CreateDishonestHelper

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

func (*AlphabetGameHelper) CreateHonestActor

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

func (*AlphabetGameHelper) StartChallenger

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

type CannonGameHelper

type CannonGameHelper struct {
	FaultGameHelper
}

func (*CannonGameHelper) CreateHonestActor

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

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

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

func (*DishonestHelper) Attack

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

func (*DishonestHelper) AttackCorrect

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

func (*DishonestHelper) Defend

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

func (*DishonestHelper) DefendCorrect

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

func (*DishonestHelper) ExhaustDishonestClaims

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

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

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

func (*FactoryHelper) StartCannonGameWithCorrectRoot

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

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

func (*FactoryHelper) StartOutputCannonGame

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

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

func (*FaultGameHelper) Attack

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

func (*FaultGameHelper) ChallengeRootClaim

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 bl-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

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

func (*FaultGameHelper) DefendRootClaim

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 bl-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

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

func (*FaultGameHelper) GetClaimPosition

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

func (*FaultGameHelper) GetClaimValue

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

func (*FaultGameHelper) LogGameData

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

func (*FaultGameHelper) MaxDepth

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

func (*FaultGameHelper) Resolve

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

func (*FaultGameHelper) ResolveClaim

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

ResolveClaim resolves a single subgame

func (*FaultGameHelper) Status

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

func (*FaultGameHelper) StepFails

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

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

func (*FaultGameHelper) WaitForClaimAtDepth

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

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

func (*FaultGameHelper) WaitForNewClaim

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

type HonestHelper

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

func (*HonestHelper) Attack

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

func (*HonestHelper) Defend

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

func (*HonestHelper) StepFails

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

type Mover

type Mover func(parentClaimIdx int64)

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

type OutputCannonGameHelper

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

func (*OutputCannonGameHelper) StartChallenger

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

func (s Status) String() string

type Stepper

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