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
ea0d4bdb
Unverified
Commit
ea0d4bdb
authored
Jul 16, 2023
by
mergify[bot]
Committed by
GitHub
Jul 16, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into jg/remove_dead_code
parents
33939e42
72c9e7a2
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
51 additions
and
26 deletions
+51
-26
agent.go
op-challenger/fault/agent.go
+3
-9
alphabet_provider.go
op-challenger/fault/alphabet_provider.go
+8
-0
solver.go
op-challenger/fault/solver.go
+20
-9
solver_test.go
op-challenger/fault/solver_test.go
+15
-5
types.go
op-challenger/fault/types.go
+3
-1
devnetL1.json
packages/contracts-bedrock/deploy-config/devnetL1.json
+2
-2
No files found.
op-challenger/fault/agent.go
View file @
ea0d4bdb
...
@@ -102,19 +102,13 @@ func (a *Agent) step(claim Claim, game Game) error {
...
@@ -102,19 +102,13 @@ func (a *Agent) step(claim Claim, game Game) error {
a
.
log
.
Warn
(
"Failed to get a step"
,
"err"
,
err
)
a
.
log
.
Warn
(
"Failed to get a step"
,
"err"
,
err
)
return
err
return
err
}
}
stateData
,
err
:=
a
.
trace
.
GetPreimage
(
step
.
PreStateTraceIndex
)
if
err
!=
nil
{
a
.
log
.
Warn
(
"Failed to get a state data"
,
"err"
,
err
)
return
err
}
a
.
log
.
Info
(
"Performing step"
,
a
.
log
.
Info
(
"Performing step"
,
"is_attack"
,
step
.
IsAttack
,
"depth"
,
step
.
LeafClaim
.
Depth
(),
"index_at_depth"
,
step
.
LeafClaim
.
IndexAtDepth
(),
"value"
,
step
.
LeafClaim
.
Value
,
"depth"
,
step
.
LeafClaim
.
Depth
(),
"index_at_depth"
,
step
.
LeafClaim
.
IndexAtDepth
(),
"value"
,
step
.
LeafClaim
.
Value
)
"is_attack"
,
step
.
IsAttack
,
"prestate_trace_index"
,
step
.
PreStateTraceIndex
)
callData
:=
StepCallData
{
callData
:=
StepCallData
{
ClaimIndex
:
uint64
(
step
.
LeafClaim
.
ContractIndex
),
ClaimIndex
:
uint64
(
step
.
LeafClaim
.
ContractIndex
),
IsAttack
:
step
.
IsAttack
,
IsAttack
:
step
.
IsAttack
,
StateData
:
st
ateData
,
StateData
:
st
ep
.
PreState
,
}
}
return
a
.
responder
.
Step
(
context
.
TODO
(),
callData
)
return
a
.
responder
.
Step
(
context
.
TODO
(),
callData
)
}
}
op-challenger/fault/alphabet_provider.go
View file @
ea0d4bdb
...
@@ -8,6 +8,8 @@ import (
...
@@ -8,6 +8,8 @@ import (
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/crypto"
)
)
var
_
TraceProvider
=
(
*
AlphabetProvider
)(
nil
)
// AlphabetProvider is a [TraceProvider] that provides claims for specific
// AlphabetProvider is a [TraceProvider] that provides claims for specific
// indices in the given trace.
// indices in the given trace.
type
AlphabetProvider
struct
{
type
AlphabetProvider
struct
{
...
@@ -45,6 +47,12 @@ func (ap *AlphabetProvider) Get(i uint64) (common.Hash, error) {
...
@@ -45,6 +47,12 @@ func (ap *AlphabetProvider) Get(i uint64) (common.Hash, error) {
return
crypto
.
Keccak256Hash
(
claimBytes
),
nil
return
crypto
.
Keccak256Hash
(
claimBytes
),
nil
}
}
func
(
ap
*
AlphabetProvider
)
AbsolutePreState
()
[]
byte
{
out
:=
make
([]
byte
,
32
)
out
[
31
]
=
140
// ascii character 140 is "`"
return
out
}
// BuildAlphabetPreimage constructs the claim bytes for the index and state item.
// BuildAlphabetPreimage constructs the claim bytes for the index and state item.
func
BuildAlphabetPreimage
(
i
uint64
,
letter
string
)
[]
byte
{
func
BuildAlphabetPreimage
(
i
uint64
,
letter
string
)
[]
byte
{
return
append
(
IndexToBytes
(
i
),
LetterToBytes
(
letter
)
...
)
return
append
(
IndexToBytes
(
i
),
LetterToBytes
(
letter
)
...
)
...
...
op-challenger/fault/solver.go
View file @
ea0d4bdb
...
@@ -64,9 +64,9 @@ func (s *Solver) handleMiddle(claim Claim) (*Claim, error) {
...
@@ -64,9 +64,9 @@ func (s *Solver) handleMiddle(claim Claim) (*Claim, error) {
}
}
type
StepData
struct
{
type
StepData
struct
{
LeafClaim
Claim
LeafClaim
Claim
IsAttack
bool
IsAttack
bool
PreState
TraceIndex
uint64
PreState
[]
byte
}
}
// AttemptStep determines what step should occur for a given leaf claim.
// AttemptStep determines what step should occur for a given leaf claim.
...
@@ -80,14 +80,25 @@ func (s *Solver) AttemptStep(claim Claim) (StepData, error) {
...
@@ -80,14 +80,25 @@ func (s *Solver) AttemptStep(claim Claim) (StepData, error) {
return
StepData
{},
err
return
StepData
{},
err
}
}
index
:=
claim
.
TraceIndex
(
s
.
gameDepth
)
index
:=
claim
.
TraceIndex
(
s
.
gameDepth
)
// TODO(CLI-4198): Handle case where we dispute trace index 0
var
preState
[]
byte
if
!
claimCorrect
{
// If we are attacking index 0, we provide the absolute pre-state, not an intermediate state
index
-=
1
if
index
==
0
&&
!
claimCorrect
{
preState
=
s
.
AbsolutePreState
()
}
else
{
// If attacking, get the state just before, other get the state after
if
!
claimCorrect
{
index
=
index
-
1
}
preState
,
err
=
s
.
GetPreimage
(
index
)
if
err
!=
nil
{
return
StepData
{},
err
}
}
}
return
StepData
{
return
StepData
{
LeafClaim
:
claim
,
LeafClaim
:
claim
,
IsAttack
:
!
claimCorrect
,
IsAttack
:
!
claimCorrect
,
PreState
TraceIndex
:
index
,
PreState
:
preState
,
},
nil
},
nil
}
}
...
...
op-challenger/fault/solver_test.go
View file @
ea0d4bdb
...
@@ -102,17 +102,27 @@ func TestAttemptStep(t *testing.T) {
...
@@ -102,17 +102,27 @@ func TestAttemptStep(t *testing.T) {
maxDepth
:=
3
maxDepth
:=
3
canonicalProvider
:=
NewAlphabetProvider
(
"abcdefgh"
,
uint64
(
maxDepth
))
canonicalProvider
:=
NewAlphabetProvider
(
"abcdefgh"
,
uint64
(
maxDepth
))
solver
:=
NewSolver
(
maxDepth
,
canonicalProvider
)
solver
:=
NewSolver
(
maxDepth
,
canonicalProvider
)
root
,
top
,
middle
,
bottom
:=
createTestClaims
()
_
,
_
,
middle
,
bottom
:=
createTestClaims
()
g
:=
NewGameState
(
false
,
root
,
testMaxDepth
)
require
.
NoError
(
t
,
g
.
Put
(
top
))
zero
:=
Claim
{
require
.
NoError
(
t
,
g
.
Put
(
middle
))
ClaimData
:
ClaimData
{
require
.
NoError
(
t
,
g
.
Put
(
bottom
))
// Zero value is a purposely disagree with claim value "a"
Position
:
NewPosition
(
3
,
0
),
},
}
step
,
err
:=
solver
.
AttemptStep
(
bottom
)
step
,
err
:=
solver
.
AttemptStep
(
bottom
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
require
.
Equal
(
t
,
bottom
,
step
.
LeafClaim
)
require
.
Equal
(
t
,
bottom
,
step
.
LeafClaim
)
require
.
True
(
t
,
step
.
IsAttack
)
require
.
True
(
t
,
step
.
IsAttack
)
require
.
Equal
(
t
,
step
.
PreState
,
BuildAlphabetPreimage
(
3
,
"d"
))
_
,
err
=
solver
.
AttemptStep
(
middle
)
_
,
err
=
solver
.
AttemptStep
(
middle
)
require
.
Error
(
t
,
err
)
require
.
Error
(
t
,
err
)
step
,
err
=
solver
.
AttemptStep
(
zero
)
require
.
NoError
(
t
,
err
)
require
.
Equal
(
t
,
zero
,
step
.
LeafClaim
)
require
.
True
(
t
,
step
.
IsAttack
)
require
.
Equal
(
t
,
canonicalProvider
.
AbsolutePreState
(),
step
.
PreState
)
}
}
op-challenger/fault/types.go
View file @
ea0d4bdb
...
@@ -22,10 +22,12 @@ type StepCallData struct {
...
@@ -22,10 +22,12 @@ type StepCallData struct {
// TraceProvider is a generic way to get a claim value at a specific
// TraceProvider is a generic way to get a claim value at a specific
// step in the trace.
// step in the trace.
// The [AlphabetProvider] is a minimal implementation of this interface.
// Get(i) = Keccak256(GetPreimage(i))
// AbsolutePreState is the value of the trace that transitions to the trace value at index 0
type
TraceProvider
interface
{
type
TraceProvider
interface
{
Get
(
i
uint64
)
(
common
.
Hash
,
error
)
Get
(
i
uint64
)
(
common
.
Hash
,
error
)
GetPreimage
(
i
uint64
)
([]
byte
,
error
)
GetPreimage
(
i
uint64
)
([]
byte
,
error
)
AbsolutePreState
()
[]
byte
}
}
// ClaimData is the core of a claim. It must be unique inside a specific game.
// ClaimData is the core of a claim. It must be unique inside a specific game.
...
...
packages/contracts-bedrock/deploy-config/devnetL1.json
View file @
ea0d4bdb
...
@@ -44,6 +44,6 @@
...
@@ -44,6 +44,6 @@
"l1GenesisBlockTimestamp"
:
"0x64935846"
,
"l1GenesisBlockTimestamp"
:
"0x64935846"
,
"l1StartingBlockTag"
:
"earliest"
,
"l1StartingBlockTag"
:
"earliest"
,
"l2GenesisRegolithTimeOffset"
:
"0x0"
,
"l2GenesisRegolithTimeOffset"
:
"0x0"
,
"faultGameAbsolutePrestate"
:
1
5
,
"faultGameAbsolutePrestate"
:
1
40
,
"faultGameMaxDepth"
:
4
"faultGameMaxDepth"
:
4
}
}
\ No newline at end of file
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