Commit c4d25ebc authored by OptimismBot's avatar OptimismBot Committed by GitHub

Merge pull request #6082 from ethereum-optimism/jg/organize_files

Split out initial files
parents 4f248271 1bf77466
package main
import (
"github.com/ethereum-optimism/optimism/op-challenger/fault"
)
func main() {
// Example 1
// abcdefgh
// abcdexyz
// go left to d, then right to f, then left to e
p := fault.Position{}
p.Print(3)
p.Attack()
p.Print(3)
p.Defend()
p.Print(3)
p.Attack()
p.Print(3)
// Trace Position is 0000 Trace Depth is: 0 Trace Index is: 8
// Trace Position is 0000 Trace Depth is: 1 Trace Index is: 4
// Trace Position is 0010 Trace Depth is: 2 Trace Index is: 6
// Trace Position is 0100 Trace Depth is: 3 Trace Index is: 5
// Example 2
// abcdefgh
// abqrstuv
// go left r, then left to b, then right to q
p = fault.Position{}
p.Print(3)
p.Attack()
p.Print(3)
p.Attack()
p.Print(3)
p.Defend()
p.Print(3)
// Trace Position is 0000 Trace Depth is: 0 Trace Index is: 8
// Trace Position is 0000 Trace Depth is: 1 Trace Index is: 4
// Trace Position is 0000 Trace Depth is: 2 Trace Index is: 2
// Trace Position is 0010 Trace Depth is: 3 Trace Index is: 3
}
package main package fault
import ( import "fmt"
"errors"
"fmt"
"github.com/ethereum/go-ethereum/common"
)
// Position is a golang wrapper around the dispute game Position type. // Position is a golang wrapper around the dispute game Position type.
// Depth refers to how many bisection steps have occurred. // Depth refers to how many bisection steps have occurred.
...@@ -66,62 +61,3 @@ func (p *Position) Defend() { ...@@ -66,62 +61,3 @@ func (p *Position) Defend() {
func (p *Position) Print(maxDepth int) { func (p *Position) Print(maxDepth int) {
fmt.Printf("Trace Position is %04b\tTrace Depth is: %d\tTrace Index is: %d\n", p.IndexAtDepth, p.Depth, p.TraceIndex(maxDepth)) fmt.Printf("Trace Position is %04b\tTrace Depth is: %d\tTrace Index is: %d\n", p.IndexAtDepth, p.Depth, p.TraceIndex(maxDepth))
} }
var (
ErrNegativeIndex = errors.New("index cannot be negative")
ErrIndexTooLarge = errors.New("index is larger than the maximum index")
)
// TraceProvider is a generic way to get a claim value at a specific
// step in the trace.
type TraceProvider interface {
Get(i int) (common.Hash, error)
}
type Claim struct {
Value common.Hash
Position
}
type Response struct {
Attack bool // note: can we flip this to true == going right / defending??
Value common.Hash
}
func main() {
// Example 1
// abcdefgh
// abcdexyz
// go left to d, then right to f, then left to e
p := Position{}
p.Print(3)
p.Attack()
p.Print(3)
p.Defend()
p.Print(3)
p.Attack()
p.Print(3)
// Trace Position is 0000 Trace Depth is: 0 Trace Index is: 8
// Trace Position is 0000 Trace Depth is: 1 Trace Index is: 4
// Trace Position is 0010 Trace Depth is: 2 Trace Index is: 6
// Trace Position is 0100 Trace Depth is: 3 Trace Index is: 5
// Example 2
// abcdefgh
// abqrstuv
// go left r, then left to b, then right to q
p = Position{}
p.Print(3)
p.Attack()
p.Print(3)
p.Attack()
p.Print(3)
p.Defend()
p.Print(3)
// Trace Position is 0000 Trace Depth is: 0 Trace Index is: 8
// Trace Position is 0000 Trace Depth is: 1 Trace Index is: 4
// Trace Position is 0000 Trace Depth is: 2 Trace Index is: 2
// Trace Position is 0010 Trace Depth is: 3 Trace Index is: 3
}
package fault
import (
"errors"
"github.com/ethereum/go-ethereum/common"
)
var (
ErrNegativeIndex = errors.New("index cannot be negative")
ErrIndexTooLarge = errors.New("index is larger than the maximum index")
)
// TraceProvider is a generic way to get a claim value at a specific
// step in the trace.
type TraceProvider interface {
Get(i int) (common.Hash, error)
}
type Claim struct {
Value common.Hash
Position
}
type Response struct {
Attack bool // note: can we flip this to true == going right / defending??
Value common.Hash
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment