Documentation ¶
Index ¶
- Variables
- func IndexToBytes(i uint64) []byte
- func MSBIndex(x uint64) int
- func NewFaultResponder(logger log.Logger, txManagr txmgr.TxManager, fdgAddr common.Address) (*faultResponder, error)
- func NewGameState(root Claim, depth uint64) *gameState
- func NewLoader(log log.Logger, state Game, claimFetcher ClaimFetcher) *loader
- type Agent
- type AlphabetProvider
- type Claim
- type ClaimData
- type ClaimFetcher
- type Game
- type Loader
- type Orchestrator
- 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 Responder
- type Solver
- type StepCallData
- type StepData
- 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 ( ErrNegativeIndex = errors.New("index cannot be negative") ErrIndexTooLarge = errors.New("index is larger than the maximum index") )
Functions ¶
func IndexToBytes ¶
IndexToBytes converts an index to a byte slice big endian
func NewFaultResponder ¶
func NewFaultResponder(logger log.Logger, txManagr txmgr.TxManager, fdgAddr common.Address) (*faultResponder, error)
NewFaultResponder returns a new [faultResponder].
func NewGameState ¶
NewGameState returns a new game state. The provided Claim is used as the root node.
Types ¶
type Agent ¶
type Agent struct {
// contains filtered or unexported fields
}
func (*Agent) AddClaim ¶
AddClaim stores a claim in the local state. This function shares a lock with PerformActions.
func (*Agent) PerformActions ¶
func (a *Agent) PerformActions()
PerformActions iterates the game & performs all of the next actions. Note: PerformActions & AddClaim share a lock so the responder cannot call AddClaim on the same thread.
type AlphabetProvider ¶
type AlphabetProvider struct {
// contains filtered or unexported fields
}
AlphabetProvider is a TraceProvider that provides claims for specific indices in the given trace.
func NewAlphabetProvider ¶
func NewAlphabetProvider(state string, depth uint64) *AlphabetProvider
NewAlphabetProvider returns a new AlphabetProvider.
func (*AlphabetProvider) Get ¶
func (ap *AlphabetProvider) Get(i uint64) (common.Hash, error)
Get returns the claim value at the given index in the trace.
func (*AlphabetProvider) GetPreimage ¶
func (ap *AlphabetProvider) GetPreimage(i uint64) ([]byte, error)
GetPreimage returns the preimage for the given hash.
type Claim ¶
type Claim struct { ClaimData 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 ClaimFetcher ¶
type ClaimFetcher interface { ClaimData(opts *bind.CallOpts, arg0 *big.Int) (struct { ParentIndex uint32 Countered bool Claim [32]byte Position *big.Int Clock *big.Int }, error) ClaimDataLen(opts *bind.CallOpts) (*big.Int, error) }
ClaimFetcher is a minimal interface around bindings.FaultDisputeGameCaller. This needs to be updated if the bindings.FaultDisputeGameCaller interface changes.
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 // IsDuplicate returns true if the provided [Claim] already exists in the game state. IsDuplicate(claim Claim) bool // PreStateClaim gets the claim which commits to the pre-state of this specific claim. // This will return an error if it is called with a non-leaf claim. PreStateClaim(claim Claim) (Claim, error) // PostStateClaim gets the claim which commits to the post-state of this specific claim. // This will return an error if it is called with a non-leaf claim. PostStateClaim(claim Claim) (Claim, error) }
Game is an interface that represents the state of a dispute game.
type Orchestrator ¶
type Orchestrator struct {
// contains filtered or unexported fields
}
func NewOrchestrator ¶
func NewOrchestrator(maxDepth uint64, traces []TraceProvider, names []string, root Claim) Orchestrator
func (*Orchestrator) Respond ¶
func (o *Orchestrator) Respond(_ context.Context, response Claim) error
func (*Orchestrator) Start ¶
func (o *Orchestrator) Start()
func (*Orchestrator) Step ¶
func (o *Orchestrator) Step(ctx context.Context, stepData StepCallData) error
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 Responder ¶
type Responder interface { Respond(ctx context.Context, response Claim) error Step(ctx context.Context, stepData StepCallData) error }
Responder takes a response action & executes. For full op-challenger this means executing the transaction on chain.
type Solver ¶
type Solver struct { TraceProvider // contains filtered or unexported fields }
Solver uses a TraceProvider to determine the moves to make in a dispute game.
func NewSolver ¶
func NewSolver(gameDepth int, traceProvider TraceProvider) *Solver
NewSolver creates a new Solver using the provided TraceProvider.
func (*Solver) AttemptStep ¶
AttemptStep determines what step should occur for a given leaf claim. An error will be returned if the claim is not at the max depth.
type StepCallData ¶
type StepCallData struct { StateIndex uint64 ClaimIndex uint64 IsAttack bool StateData []byte Proof []byte }
StepCallData encapsulates the data needed to perform a step.
type TraceProvider ¶
type TraceProvider interface { Get(i uint64) (common.Hash, error) GetPreimage(i uint64) ([]byte, error) }
TraceProvider is a generic way to get a claim value at a specific step in the trace. The AlphabetProvider is a minimal implementation of this interface.