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
f5495cfe
Unverified
Commit
f5495cfe
authored
Jul 16, 2023
by
OptimismBot
Committed by
GitHub
Jul 16, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6308 from ethereum-optimism/jg/remove_examples
op-challenger: Remove unused examples
parents
f6ae9f02
a59cae17
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
0 additions
and
226 deletions
+0
-226
full.go
op-challenger/fault/cmd/examples/full.go
+0
-31
position.go
op-challenger/fault/cmd/examples/position.go
+0
-35
solver.go
op-challenger/fault/cmd/examples/solver.go
+0
-73
main.go
op-challenger/fault/cmd/main.go
+0
-12
orchestrator.go
op-challenger/fault/orchestrator.go
+0
-75
No files found.
op-challenger/fault/cmd/examples/full.go
deleted
100644 → 0
View file @
f6ae9f02
package
examples
import
(
"os"
"github.com/ethereum-optimism/optimism/op-challenger/fault"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"
)
func
FullGame
()
{
log
.
Root
()
.
SetHandler
(
log
.
LvlFilterHandler
(
log
.
LvlInfo
,
log
.
StreamHandler
(
os
.
Stdout
,
log
.
TerminalFormat
(
true
))),
)
canonical
:=
"abcdefgh"
disputed
:=
"abcdexyz"
maxDepth
:=
uint64
(
3
)
canonicalProvider
:=
fault
.
NewAlphabetProvider
(
canonical
,
maxDepth
)
disputedProvider
:=
fault
.
NewAlphabetProvider
(
disputed
,
maxDepth
)
root
:=
fault
.
Claim
{
ClaimData
:
fault
.
ClaimData
{
Value
:
common
.
HexToHash
(
"0x000000000000000000000000000000000000000000000000000000000000077a"
),
Position
:
fault
.
NewPosition
(
0
,
0
),
},
}
o
:=
fault
.
NewOrchestrator
(
maxDepth
,
[]
fault
.
TraceProvider
{
canonicalProvider
,
disputedProvider
},
[]
string
{
"charlie"
,
"mallory"
},
[]
bool
{
false
,
true
},
root
)
o
.
Start
()
}
op-challenger/fault/cmd/examples/position.go
deleted
100644 → 0
View file @
f6ae9f02
package
examples
import
(
"github.com/ethereum-optimism/optimism/op-challenger/fault"
)
func
PositionExampleOne
()
{
// Example 1
// abcdefgh
// abcdexyz
// go left to d, then right to f, then left to e
p
:=
fault
.
Position
{}
p
.
Print
(
3
)
p
=
p
.
Attack
()
p
.
Print
(
3
)
p
=
p
.
Defend
()
p
.
Print
(
3
)
p
=
p
.
Attack
()
p
.
Print
(
3
)
}
func
PositionExampleTwo
()
{
// Example 2
// abcdefgh
// abqrstuv
// go left r, then left to b, then right to q
p
:=
fault
.
Position
{}
p
.
Print
(
3
)
p
=
p
.
Attack
()
p
.
Print
(
3
)
p
=
p
.
Attack
()
p
.
Print
(
3
)
p
=
p
.
Defend
()
p
.
Print
(
3
)
}
op-challenger/fault/cmd/examples/solver.go
deleted
100644 → 0
View file @
f6ae9f02
package
examples
import
(
"fmt"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum-optimism/optimism/op-challenger/fault"
)
func
PrettyPrintAlphabetClaim
(
name
string
,
claim
fault
.
Claim
)
{
value
:=
claim
.
Value
idx
:=
value
[
30
]
letter
:=
value
[
31
]
if
claim
.
IsRoot
()
{
fmt
.
Printf
(
"%s
\t
trace %v letter %c
\n
"
,
name
,
idx
,
letter
)
}
else
{
fmt
.
Printf
(
"%s
\t
trace %v letter %c is attack %v
\n
"
,
name
,
idx
,
letter
,
!
claim
.
DefendsParent
())
}
}
// SolverExampleOne uses the [fault.Solver] with a [fault.AlphabetProvider]
// to print out fault game traces for the "abcdexyz" counter-state.
func
SolverExampleOne
()
{
fmt
.
Println
(
"Solver: Example 1"
)
// Construct the fault position.
canonical
:=
"abcdefgh"
disputed
:=
"abcdexyz"
maxDepth
:=
3
// Root claim is z at trace index 7 from the disputed provider
root
:=
fault
.
Claim
{
ClaimData
:
fault
.
ClaimData
{
Value
:
common
.
HexToHash
(
"0x000000000000000000000000000000000000000000000000000000000000077a"
),
Position
:
fault
.
NewPosition
(
0
,
0
),
},
}
canonicalProvider
:=
fault
.
NewAlphabetProvider
(
canonical
,
uint64
(
maxDepth
))
disputedProvider
:=
fault
.
NewAlphabetProvider
(
disputed
,
uint64
(
maxDepth
))
// Create a solver with the canonical provider.
cannonicalSolver
:=
fault
.
NewSolver
(
maxDepth
,
canonicalProvider
)
disputedSolver
:=
fault
.
NewSolver
(
maxDepth
,
disputedProvider
)
// Print the initial state.
fmt
.
Println
(
"Canonical state: "
,
canonical
)
fmt
.
Println
(
"Disputed state: "
,
disputed
)
fmt
.
Println
()
fmt
.
Println
(
"Proceeding with the following moves:"
)
fmt
.
Println
(
"go left to d, then right to x (cannonical is f), then left to e"
)
fmt
.
Println
()
PrettyPrintAlphabetClaim
(
"Root claim"
,
root
)
claim1
,
err
:=
cannonicalSolver
.
NextMove
(
root
,
false
)
if
err
!=
nil
{
fmt
.
Printf
(
"error getting claim from provider: %v"
,
err
)
}
PrettyPrintAlphabetClaim
(
"Cannonical move"
,
*
claim1
)
claim2
,
err
:=
disputedSolver
.
NextMove
(
*
claim1
,
false
)
if
err
!=
nil
{
fmt
.
Printf
(
"error getting claim from provider: %v"
,
err
)
}
PrettyPrintAlphabetClaim
(
"Disputed moved"
,
*
claim2
)
claim3
,
err
:=
cannonicalSolver
.
NextMove
(
*
claim2
,
false
)
if
err
!=
nil
{
fmt
.
Printf
(
"error getting claim from provider: %v"
,
err
)
}
PrettyPrintAlphabetClaim
(
"Cannonical move"
,
*
claim3
)
}
op-challenger/fault/cmd/main.go
deleted
100644 → 0
View file @
f6ae9f02
package
main
import
(
"github.com/ethereum-optimism/optimism/op-challenger/fault/cmd/examples"
)
func
main
()
{
examples
.
FullGame
()
// examples.SolverExampleOne()
// examples.PositionExampleOne()
// examples.PositionExampleTwo()
}
op-challenger/fault/orchestrator.go
deleted
100644 → 0
View file @
f6ae9f02
package
fault
import
(
"context"
"github.com/ethereum/go-ethereum/log"
)
type
Orchestrator
struct
{
agents
[]
Agent
claims
[]
Claim
steps
[]
StepCallData
// tracking when to exit
claimLen
,
stepLen
,
step
int
}
func
NewOrchestrator
(
maxDepth
uint64
,
traces
[]
TraceProvider
,
names
[]
string
,
agreeWithProposedOutput
[]
bool
,
root
Claim
)
Orchestrator
{
o
:=
Orchestrator
{
agents
:
make
([]
Agent
,
len
(
traces
)),
claims
:
[]
Claim
{
root
},
steps
:
make
([]
StepCallData
,
0
),
}
log
.
Info
(
"Starting game"
,
"root_letter"
,
string
(
root
.
Value
[
31
:
]))
for
i
,
trace
:=
range
traces
{
o
.
agents
[
i
]
=
NewAgent
(
&
o
,
int
(
maxDepth
),
trace
,
&
o
,
agreeWithProposedOutput
[
i
],
log
.
New
(
"role"
,
names
[
i
]))
}
return
o
}
func
(
o
*
Orchestrator
)
Respond
(
_
context
.
Context
,
response
Claim
)
error
{
response
.
ContractIndex
=
len
(
o
.
claims
)
o
.
claims
=
append
(
o
.
claims
,
response
)
return
nil
}
func
(
o
*
Orchestrator
)
Step
(
_
context
.
Context
,
stepData
StepCallData
)
error
{
log
.
Info
(
"Step recorded"
,
"step"
,
stepData
)
o
.
steps
=
append
(
o
.
steps
,
stepData
)
return
nil
}
func
(
o
*
Orchestrator
)
FetchClaims
(
ctx
context
.
Context
)
([]
Claim
,
error
)
{
c
:=
make
([]
Claim
,
len
(
o
.
claims
))
copy
(
c
,
o
.
claims
)
return
c
,
nil
}
func
(
o
*
Orchestrator
)
Start
()
{
for
{
for
_
,
a
:=
range
o
.
agents
{
_
=
a
.
Act
()
}
if
o
.
shouldExit
()
{
log
.
Info
(
"exiting"
)
return
}
}
}
func
(
o
*
Orchestrator
)
shouldExit
()
bool
{
cl
:=
o
.
claimLen
sl
:=
o
.
stepLen
o
.
claimLen
=
len
(
o
.
claims
)
o
.
stepLen
=
len
(
o
.
steps
)
noProgress
:=
o
.
claimLen
==
cl
&&
o
.
stepLen
==
sl
if
noProgress
{
o
.
step
=
o
.
step
+
1
}
else
{
o
.
step
=
0
}
return
noProgress
&&
o
.
step
==
1
}
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