Documentation ¶
Index ¶
- Variables
- func ChessClock(now time.Time, claim Claim, parent Claim) time.Duration
- func NewGameState(claims []Claim, depth Depth) *gameState
- func ValidTraceType(value TraceType) bool
- type Action
- type ActionType
- type Claim
- type ClaimData
- type ClaimID
- type Clock
- type ClockReader
- type Depth
- type Game
- type GameType
- type InvalidL2BlockNumberChallenge
- type Position
- func (p Position) Attack() Position
- func (p Position) Defend() Position
- func (p Position) Depth() Depth
- func (p Position) IndexAtDepth() *big.Int
- func (p Position) IsRootPosition() bool
- func (p Position) MoveRight() Position
- func (p Position) Print(maxDepth Depth)
- func (p Position) RelativeToAncestorAtDepth(ancestor Depth) (Position, error)
- func (p Position) RightOf(parent Position) bool
- func (p Position) String() string
- func (p Position) ToGIndex() *big.Int
- func (p Position) TraceIndex(maxDepth Depth) *big.Int
- type PreimageOracleData
- func (p *PreimageOracleData) GetIdent() *big.Int
- func (p *PreimageOracleData) GetPrecompileAddress() common.Address
- func (p *PreimageOracleData) GetPrecompileInput() []byte
- func (p *PreimageOracleData) GetPrecompileRequiredGas() uint64
- func (p *PreimageOracleData) GetPreimageWithSize() []byte
- func (p *PreimageOracleData) GetPreimageWithoutSize() []byte
- type PrestateProvider
- type StepCallData
- type TraceAccessor
- type TraceProvider
- type TraceType
Constants ¶
This section is empty.
Variables ¶
var ( ErrPositionDepthTooSmall = errors.New("position depth is too small") RootPosition = NewPositionFromGIndex(big.NewInt(1)) )
var ( ErrGameDepthReached = errors.New("game depth reached") ErrL2BlockNumberValid = errors.New("l2 block number is valid") )
var ( // ErrClaimNotFound is returned when a claim does not exist in the game state. ErrClaimNotFound = errors.New("claim not found in game state") )
var TraceTypes = []TraceType{TraceTypeAlphabet, TraceTypeCannon, TraceTypePermissioned, TraceTypeAsterisc, TraceTypeAsteriscKona, TraceTypeFast}
Functions ¶
func ChessClock ¶ added in v1.7.6
func NewGameState ¶
NewGameState returns a new game state. The provided Claim is used as the root node.
func ValidTraceType ¶ added in v1.8.0
Types ¶
type Action ¶
type Action struct { Type ActionType // Moves and Steps ParentClaim Claim IsAttack bool // Moves Value common.Hash // Steps PreState []byte ProofData []byte OracleData *PreimageOracleData // Challenge L2 Block Number InvalidL2BlockNumberChallenge *InvalidL2BlockNumberChallenge }
type ActionType ¶
type ActionType string
const ( ActionTypeMove ActionType = "move" ActionTypeStep ActionType = "step" ActionTypeChallengeL2BlockNumber ActionType = "challenge-l2-block-number" )
func (ActionType) String ¶
func (a ActionType) String() string
type Claim ¶
type Claim struct { ClaimData // WARN: CounteredBy is a mutable field in the FaultDisputeGame contract // and rely on it for determining whether to step on leaf claims. // When caching is implemented for the Challenger, this will need // to be changed/removed to avoid invalid/stale contract state. CounteredBy common.Address Claimant common.Address Clock Clock // Location of the claim & it's parent inside the contract. Does not exist // for claims that have not made it to the contract. ContractIndex int ParentContractIndex int }
Claim extends ClaimData with information about the relationship between two claims. It uses ClaimData to break cyclicity without using pointers. If the position of the game is Depth 0, IndexAtDepth 0 it is the root claim and the Parent field is empty & meaningless.
type ClaimData ¶
ClaimData is the core of a claim. It must be unique inside a specific game.
func (*ClaimData) ValueBytes ¶
type Clock ¶ added in v1.7.0
type Clock struct { // Duration is the time elapsed on the chess clock at the last update. Duration time.Duration // Timestamp is the time that the clock was last updated. Timestamp time.Time }
Clock tracks the chess clock for a claim.
type ClockReader ¶ added in v1.5.1
type Depth ¶ added in v1.4.3
type Depth uint64
Depth is the depth of a position in a game tree where the root level has depth 0, the root's children have depth 1, their children have depth 2, and so on.
type Game ¶
type Game interface { // Claims returns all of the claims in the game. Claims() []Claim // GetParent returns the parent of the provided claim. GetParent(claim Claim) (Claim, error) // DefendsParent returns true if and only if the claim is a defense (i.e. goes right) of // its parent. DefendsParent(claim Claim) bool // ChessClock returns the amount of time elapsed on the chess clock of the potential challenger to the supplied claim. // Specifically, this returns the chess clock of the team that *disagrees* with the supplied claim. ChessClock(now time.Time, claim Claim) time.Duration // IsDuplicate returns true if the provided [Claim] already exists in the game state // referencing the same parent claim IsDuplicate(claim Claim) bool // AgreeWithClaimLevel returns if the game state agrees with the provided claim level. AgreeWithClaimLevel(claim Claim, agreeWithRootClaim bool) bool MaxDepth() Depth // AncestorWithTraceIndex finds the ancestor of claim with trace index idx if present. // Returns the claim and true if the ancestor is found, or Claim{}, false if not. AncestorWithTraceIndex(claim Claim, idx *big.Int) (Claim, bool) }
Game is an interface that represents the state of a dispute game.
type InvalidL2BlockNumberChallenge ¶ added in v1.7.6
type InvalidL2BlockNumberChallenge struct { Output *eth.OutputResponse Header *ethTypes.Header }
func NewInvalidL2BlockNumberProof ¶ added in v1.7.6
func NewInvalidL2BlockNumberProof(output *eth.OutputResponse, header *ethTypes.Header) *InvalidL2BlockNumberChallenge
type Position ¶
type Position struct {
// contains filtered or unexported fields
}
Position is a golang wrapper around the dispute game Position type.
func NewPositionFromGIndex ¶
NewPositionFromGIndex creates a new Position given a generalized index.
func (Position) IndexAtDepth ¶
func (Position) IsRootPosition ¶
func (Position) RelativeToAncestorAtDepth ¶ added in v1.2.0
RelativeToAncestorAtDepth returns a new position for a subtree. [ancestor] is the depth of the subtree root node.
type PreimageOracleData ¶
type PreimageOracleData struct { IsLocal bool OracleKey []byte OracleOffset uint32 // 4844 blob data BlobFieldIndex uint64 BlobCommitment []byte BlobProof []byte // contains filtered or unexported fields }
PreimageOracleData encapsulates the preimage oracle data to load into the onchain oracle.
func NewPreimageOracleBlobData ¶ added in v1.6.1
func NewPreimageOracleData ¶
func NewPreimageOracleData(key []byte, data []byte, offset uint32) *PreimageOracleData
NewPreimageOracleData creates a new PreimageOracleData instance.
func (*PreimageOracleData) GetIdent ¶
func (p *PreimageOracleData) GetIdent() *big.Int
GetIdent returns the ident for the preimage oracle data.
func (*PreimageOracleData) GetPrecompileAddress ¶ added in v1.7.2
func (p *PreimageOracleData) GetPrecompileAddress() common.Address
func (*PreimageOracleData) GetPrecompileInput ¶ added in v1.7.2
func (p *PreimageOracleData) GetPrecompileInput() []byte
func (*PreimageOracleData) GetPrecompileRequiredGas ¶ added in v1.9.1
func (p *PreimageOracleData) GetPrecompileRequiredGas() uint64
func (*PreimageOracleData) GetPreimageWithSize ¶ added in v1.5.1
func (p *PreimageOracleData) GetPreimageWithSize() []byte
GetPreimageWithSize returns the preimage with its length prefix.
func (*PreimageOracleData) GetPreimageWithoutSize ¶
func (p *PreimageOracleData) GetPreimageWithoutSize() []byte
GetPreimageWithoutSize returns the preimage for the preimage oracle data.
type PrestateProvider ¶ added in v1.4.2
type PrestateProvider interface { // AbsolutePreStateCommitment is the commitment of the pre-image value of the trace that transitions to the trace value at index 0 AbsolutePreStateCommitment(ctx context.Context) (hash common.Hash, err error) }
PrestateProvider defines an interface to request the absolute prestate.
type StepCallData ¶
StepCallData encapsulates the data needed to perform a step.
type TraceAccessor ¶ added in v1.4.2
type TraceAccessor interface { // Get returns the claim value at the requested position, evaluated in the context of the specified claim (ref). Get(ctx context.Context, game Game, ref Claim, pos Position) (common.Hash, error) // GetStepData returns the data required to execute the step at the specified position, // evaluated in the context of the specified claim (ref). GetStepData(ctx context.Context, game Game, ref Claim, pos Position) (prestate []byte, proofData []byte, preimageData *PreimageOracleData, err error) // GetL2BlockNumberChallenge returns the data required to prove the correct L2 block number of the root claim. // Returns ErrL2BlockNumberValid if the root claim is known to come from the same block as the claimed L2 block. GetL2BlockNumberChallenge(ctx context.Context, game Game) (*InvalidL2BlockNumberChallenge, error) }
TraceAccessor defines an interface to request data from a TraceProvider with additional context for the game position. This can be used to implement split games where lower layers of the game may have different values depending on claims at higher levels in the game.
type TraceProvider ¶
type TraceProvider interface { PrestateProvider // Get returns the claim value at the requested index. // Get(i) = Keccak256(GetPreimage(i)) Get(ctx context.Context, i Position) (common.Hash, error) // GetStepData returns the data required to execute the step at the specified trace index. // This includes the pre-state of the step (not hashed), the proof data required during step execution // and any pre-image data that needs to be loaded into the oracle prior to execution (may be nil) // The prestate returned from GetStepData for trace 10 should be the pre-image of the claim from trace 9 GetStepData(ctx context.Context, i Position) (prestate []byte, proofData []byte, preimageData *PreimageOracleData, err error) // GetL2BlockNumberChallenge returns the data required to prove the correct L2 block number of the root claim. // Returns ErrL2BlockNumberValid if the root claim is known to come from the same block as the claimed L2 block. GetL2BlockNumberChallenge(ctx context.Context) (*InvalidL2BlockNumberChallenge, error) }
TraceProvider is a generic way to get a claim value at a specific step in the trace.