Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
1bf77466
Commit
1bf77466
authored
1 year ago
by
Joshua Gutow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Split out initial files
parent
4f248271
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
135 additions
and
0 deletions
+135
-0
main.go
op-challenger/fault/cmd/main.go
+43
-0
position.go
op-challenger/fault/position.go
+63
-0
position_test.go
op-challenger/fault/position_test.go
+1
-0
types.go
op-challenger/fault/types.go
+28
-0
No files found.
op-challenger/fault/cmd/main.go
0 → 100644
View file @
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
}
This diff is collapsed.
Click to expand it.
op-challenger/fault/
mai
n.go
→
op-challenger/fault/
positio
n.go
View file @
1bf77466
package
main
package
fault
import
(
"errors"
"fmt"
"github.com/ethereum/go-ethereum/common"
)
import
"fmt"
// Position is a golang wrapper around the dispute game Position type.
// Depth refers to how many bisection steps have occurred.
...
...
@@ -66,62 +61,3 @@ func (p *Position) Defend() {
func
(
p
*
Position
)
Print
(
maxDepth
int
)
{
fmt
.
Printf
(
"Trace Position is %04b
\t
Trace Depth is: %d
\t
Trace 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
}
This diff is collapsed.
Click to expand it.
op-challenger/fault/position_test.go
0 → 100644
View file @
1bf77466
package
fault
This diff is collapsed.
Click to expand it.
op-challenger/fault/types.go
0 → 100644
View file @
1bf77466
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
}
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment