Documentation ¶
Index ¶
- Variables
- func MSBIndex(x uint64) int
- func NewGameState(agreeWithProposedOutput bool, root Claim, depth uint64) *gameState
- type Action
- type ActionType
- type Claim
- type ClaimData
- type Game
- type OracleUpdater
- type Position
- func (p Position) Attack() Position
- func (p Position) Defend() Position
- func (p Position) Depth() int
- func (p Position) IndexAtDepth() int
- func (p Position) IsRootPosition() bool
- func (p Position) Print(maxDepth int)
- func (p Position) ToGIndex() uint64
- func (p Position) TraceIndex(maxDepth int) uint64
- type PreimageOracleData
- type StepCallData
- type TraceProvider
Constants ¶
This section is empty.
Variables ¶
var ( // ErrClaimExists is returned when a claim already exists in the game state. ErrClaimExists = errors.New("claim exists in game state") // ErrClaimNotFound is returned when a claim does not exist in the game state. ErrClaimNotFound = errors.New("claim not found in game state") )
var (
ErrGameDepthReached = errors.New("game depth reached")
)
Functions ¶
Types ¶
type Action ¶
type Action struct { Type ActionType ParentIdx int IsAttack bool // Moves Value common.Hash // Steps PreState []byte ProofData []byte OracleData *PreimageOracleData }
type ActionType ¶
type ActionType string
const ( ActionTypeMove ActionType = "move" ActionTypeStep ActionType = "step" )
func (ActionType) String ¶
func (a ActionType) String() string
type Claim ¶
type Claim struct { ClaimData // WARN: Countered 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. Countered bool Clock uint64 Parent ClaimData // 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.
func (*Claim) DefendsParent ¶
DefendsParent returns true if the the claim is a defense (i.e. goes right) of the parent. It returns false if the claim is an attack (i.e. goes left) of the parent.
type ClaimData ¶
ClaimData is the core of a claim. It must be unique inside a specific game.
func (*ClaimData) ValueBytes ¶
type Game ¶
type Game interface { // Put adds a claim into the game state. Put(claim Claim) error // PutAll adds a list of claims into the game state. PutAll(claims []Claim) error // Claims returns all of the claims in the game. Claims() []Claim // GetParent returns the parent of the provided claim. GetParent(claim Claim) (Claim, error) // 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) bool MaxDepth() uint64 }
Game is an interface that represents the state of a dispute game.
type OracleUpdater ¶
type OracleUpdater interface { // UpdateOracle updates the oracle with the given data. UpdateOracle(ctx context.Context, data *PreimageOracleData) error }
OracleUpdater is a generic interface for updating oracles.
type Position ¶
type Position struct {
// contains filtered or unexported fields
}
Position is a golang wrapper around the dispute game Position type.
func NewPosition ¶
func NewPositionFromGIndex ¶
func (Position) IndexAtDepth ¶
func (Position) IsRootPosition ¶
func (Position) TraceIndex ¶
TraceIndex calculates the what the index of the claim value would be inside the trace. It is equivalent to going right until the final depth has been reached.
type PreimageOracleData ¶
type PreimageOracleData struct { IsLocal bool OracleKey []byte OracleData []byte OracleOffset uint32 }
PreimageOracleData encapsulates the preimage oracle data to load into the onchain oracle.
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) GetPreimageWithoutSize ¶
func (p *PreimageOracleData) GetPreimageWithoutSize() []byte
GetPreimageWithoutSize returns the preimage for the preimage oracle data.
func (*PreimageOracleData) GetType ¶
func (p *PreimageOracleData) GetType() *big.Int
GetType returns the type for the preimage oracle data.
type StepCallData ¶
StepCallData encapsulates the data needed to perform a step.
type TraceProvider ¶
type TraceProvider interface { // Get returns the claim value at the requested index. // Get(i) = Keccak256(GetPreimage(i)) Get(ctx context.Context, i uint64) (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 uint64) (prestate []byte, proofData []byte, preimageData *PreimageOracleData, err error) // AbsolutePreState is the pre-image value of the trace that transitions to the trace value at index 0 AbsolutePreState(ctx context.Context) (preimage []byte, err error) // 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) }
TraceProvider is a generic way to get a claim value at a specific step in the trace.