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
a59cae17
Unverified
Commit
a59cae17
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_examples
parents
8c25ad4a
f6ae9f02
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
56 additions
and
117 deletions
+56
-117
agent.go
op-challenger/fault/agent.go
+3
-9
alphabet_provider.go
op-challenger/fault/alphabet_provider.go
+8
-0
game.go
op-challenger/fault/game.go
+0
-50
game_test.go
op-challenger/fault/game_test.go
+0
-40
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
client.go
op-node/node/client.go
+5
-1
devnetL1.json
packages/contracts-bedrock/deploy-config/devnetL1.json
+2
-2
No files found.
op-challenger/fault/agent.go
View file @
a59cae17
...
...
@@ -102,19 +102,13 @@ func (a *Agent) step(claim Claim, game Game) error {
a
.
log
.
Warn
(
"Failed to get a step"
,
"err"
,
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"
,
"depth"
,
step
.
LeafClaim
.
Depth
(),
"index_at_depth"
,
step
.
LeafClaim
.
IndexAtDepth
(),
"value"
,
step
.
LeafClaim
.
Value
,
"is_attack"
,
step
.
IsAttack
,
"prestate_trace_index"
,
step
.
PreStateTraceIndex
)
a
.
log
.
Info
(
"Performing step"
,
"is_attack"
,
step
.
IsAttack
,
"depth"
,
step
.
LeafClaim
.
Depth
(),
"index_at_depth"
,
step
.
LeafClaim
.
IndexAtDepth
(),
"value"
,
step
.
LeafClaim
.
Value
)
callData
:=
StepCallData
{
ClaimIndex
:
uint64
(
step
.
LeafClaim
.
ContractIndex
),
IsAttack
:
step
.
IsAttack
,
StateData
:
st
ateData
,
StateData
:
st
ep
.
PreState
,
}
return
a
.
responder
.
Step
(
context
.
TODO
(),
callData
)
}
op-challenger/fault/alphabet_provider.go
View file @
a59cae17
...
...
@@ -8,6 +8,8 @@ import (
"github.com/ethereum/go-ethereum/crypto"
)
var
_
TraceProvider
=
(
*
AlphabetProvider
)(
nil
)
// AlphabetProvider is a [TraceProvider] that provides claims for specific
// indices in the given trace.
type
AlphabetProvider
struct
{
...
...
@@ -45,6 +47,12 @@ func (ap *AlphabetProvider) Get(i uint64) (common.Hash, error) {
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.
func
BuildAlphabetPreimage
(
i
uint64
,
letter
string
)
[]
byte
{
return
append
(
IndexToBytes
(
i
),
LetterToBytes
(
letter
)
...
)
...
...
op-challenger/fault/game.go
View file @
a59cae17
...
...
@@ -26,14 +26,6 @@ type Game interface {
// 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
)
// AgreeWithLevel returns if the game state agrees with the provided claim level.
AgreeWithClaimLevel
(
claim
Claim
)
bool
}
...
...
@@ -140,45 +132,3 @@ func (g *gameState) getParent(claim Claim) (Claim, error) {
return
parent
.
self
,
nil
}
}
func
(
g
*
gameState
)
PreStateClaim
(
claim
Claim
)
(
Claim
,
error
)
{
// Do checks in PreStateClaim because these do not hold while walking the tree
if
claim
.
Depth
()
!=
int
(
g
.
depth
)
{
return
Claim
{},
errors
.
New
(
"Only leaf claims have pre or post state"
)
}
// If the claim is the far left most claim, the pre-state is pulled from the contracts & we can supply at contract index.
if
claim
.
IndexAtDepth
()
==
0
{
return
Claim
{
ContractIndex
:
-
1
,
},
nil
}
return
g
.
preStateClaim
(
claim
)
}
// preStateClaim is the internal tree walker which does not do error handling
func
(
g
*
gameState
)
preStateClaim
(
claim
Claim
)
(
Claim
,
error
)
{
parent
,
_
:=
g
.
getParent
(
claim
)
if
claim
.
DefendsParent
()
{
return
parent
,
nil
}
else
{
return
g
.
preStateClaim
(
parent
)
}
}
func
(
g
*
gameState
)
PostStateClaim
(
claim
Claim
)
(
Claim
,
error
)
{
// Do checks in PostStateClaim because these do not hold while walking the tree
if
claim
.
Depth
()
!=
int
(
g
.
depth
)
{
return
Claim
{},
errors
.
New
(
"Only leaf claims have pre or post state"
)
}
return
g
.
postStateClaim
(
claim
)
}
// postStateClaim is the internal tree walker which does not do error handling
func
(
g
*
gameState
)
postStateClaim
(
claim
Claim
)
(
Claim
,
error
)
{
parent
,
_
:=
g
.
getParent
(
claim
)
if
claim
.
DefendsParent
()
{
return
g
.
postStateClaim
(
parent
)
}
else
{
return
parent
,
nil
}
}
op-challenger/fault/game_test.go
View file @
a59cae17
...
...
@@ -195,46 +195,6 @@ func TestGame_ClaimPairs(t *testing.T) {
require
.
ElementsMatch
(
t
,
expected
,
claims
)
}
// TestPrePostStateOnlyOnLeafClaim tests that if PreStateClaim or PostStateClaim is called with an non-leaf claim
// those functions return an error.
func
TestPrePostStateOnlyOnLeafClaim
(
t
*
testing
.
T
)
{
root
,
top
,
middle
,
bottom
:=
createTestClaims
()
g
:=
NewGameState
(
false
,
root
,
testMaxDepth
)
require
.
NoError
(
t
,
g
.
PutAll
([]
Claim
{
top
,
middle
,
bottom
}))
_
,
err
:=
g
.
PreStateClaim
(
middle
)
require
.
Error
(
t
,
err
)
_
,
err
=
g
.
PostStateClaim
(
middle
)
require
.
Error
(
t
,
err
)
}
func
TestPreStateClaim
(
t
*
testing
.
T
)
{
root
,
top
,
middle
,
bottom
:=
createTestClaims
()
g
:=
NewGameState
(
false
,
root
,
testMaxDepth
)
require
.
NoError
(
t
,
g
.
Put
(
top
))
require
.
NoError
(
t
,
g
.
Put
(
middle
))
require
.
NoError
(
t
,
g
.
Put
(
bottom
))
// Bottom trace index is 4. Pre trace index is then 3
pre
,
err
:=
g
.
PreStateClaim
(
bottom
)
require
.
NoError
(
t
,
err
)
require
.
Equal
(
t
,
top
,
pre
)
}
func
TestPostStateClaim
(
t
*
testing
.
T
)
{
root
,
top
,
middle
,
bottom
:=
createTestClaims
()
g
:=
NewGameState
(
false
,
root
,
testMaxDepth
)
require
.
NoError
(
t
,
g
.
Put
(
top
))
require
.
NoError
(
t
,
g
.
Put
(
middle
))
require
.
NoError
(
t
,
g
.
Put
(
bottom
))
// Bottom trace index is 4. Post trace index is then 5
post
,
err
:=
g
.
PostStateClaim
(
bottom
)
require
.
NoError
(
t
,
err
)
require
.
Equal
(
t
,
middle
,
post
)
}
func
TestAgreeWithClaimLevelDisagreeWithOutput
(
t
*
testing
.
T
)
{
// Setup the game state.
root
,
top
,
middle
,
bottom
:=
createTestClaims
()
...
...
op-challenger/fault/solver.go
View file @
a59cae17
...
...
@@ -64,9 +64,9 @@ func (s *Solver) handleMiddle(claim Claim) (*Claim, error) {
}
type
StepData
struct
{
LeafClaim
Claim
IsAttack
bool
PreState
TraceIndex
uint64
LeafClaim
Claim
IsAttack
bool
PreState
[]
byte
}
// AttemptStep determines what step should occur for a given leaf claim.
...
...
@@ -80,14 +80,25 @@ func (s *Solver) AttemptStep(claim Claim) (StepData, error) {
return
StepData
{},
err
}
index
:=
claim
.
TraceIndex
(
s
.
gameDepth
)
// TODO(CLI-4198): Handle case where we dispute trace index 0
if
!
claimCorrect
{
index
-=
1
var
preState
[]
byte
// If we are attacking index 0, we provide the absolute pre-state, not an intermediate state
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
{
LeafClaim
:
claim
,
IsAttack
:
!
claimCorrect
,
PreState
TraceIndex
:
index
,
LeafClaim
:
claim
,
IsAttack
:
!
claimCorrect
,
PreState
:
preState
,
},
nil
}
...
...
op-challenger/fault/solver_test.go
View file @
a59cae17
...
...
@@ -102,17 +102,27 @@ func TestAttemptStep(t *testing.T) {
maxDepth
:=
3
canonicalProvider
:=
NewAlphabetProvider
(
"abcdefgh"
,
uint64
(
maxDepth
))
solver
:=
NewSolver
(
maxDepth
,
canonicalProvider
)
root
,
top
,
middle
,
bottom
:=
createTestClaims
()
g
:=
NewGameState
(
false
,
root
,
testMaxDepth
)
require
.
NoError
(
t
,
g
.
Put
(
top
))
require
.
NoError
(
t
,
g
.
Put
(
middle
))
require
.
NoError
(
t
,
g
.
Put
(
bottom
))
_
,
_
,
middle
,
bottom
:=
createTestClaims
()
zero
:=
Claim
{
ClaimData
:
ClaimData
{
// Zero value is a purposely disagree with claim value "a"
Position
:
NewPosition
(
3
,
0
),
},
}
step
,
err
:=
solver
.
AttemptStep
(
bottom
)
require
.
NoError
(
t
,
err
)
require
.
Equal
(
t
,
bottom
,
step
.
LeafClaim
)
require
.
True
(
t
,
step
.
IsAttack
)
require
.
Equal
(
t
,
step
.
PreState
,
BuildAlphabetPreimage
(
3
,
"d"
))
_
,
err
=
solver
.
AttemptStep
(
middle
)
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 @
a59cae17
...
...
@@ -22,10 +22,12 @@ type StepCallData struct {
// 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.
// Get(i) = Keccak256(GetPreimage(i))
// AbsolutePreState is the value of the trace that transitions to the trace value at index 0
type
TraceProvider
interface
{
Get
(
i
uint64
)
(
common
.
Hash
,
error
)
GetPreimage
(
i
uint64
)
([]
byte
,
error
)
AbsolutePreState
()
[]
byte
}
// ClaimData is the core of a claim. It must be unique inside a specific game.
...
...
op-node/node/client.go
View file @
a59cae17
...
...
@@ -59,7 +59,11 @@ func (cfg *L2EndpointConfig) Setup(ctx context.Context, log log.Logger, rollupCf
return
nil
,
nil
,
err
}
auth
:=
rpc
.
WithHTTPAuth
(
gn
.
NewJWTAuth
(
cfg
.
L2EngineJWTSecret
))
l2Node
,
err
:=
client
.
NewRPC
(
ctx
,
log
,
cfg
.
L2EngineAddr
,
client
.
WithGethRPCOptions
(
auth
))
opts
:=
[]
client
.
RPCOption
{
client
.
WithGethRPCOptions
(
auth
),
client
.
WithDialBackoff
(
10
),
}
l2Node
,
err
:=
client
.
NewRPC
(
ctx
,
log
,
cfg
.
L2EngineAddr
,
opts
...
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
...
...
packages/contracts-bedrock/deploy-config/devnetL1.json
View file @
a59cae17
...
...
@@ -44,6 +44,6 @@
"l1GenesisBlockTimestamp"
:
"0x64935846"
,
"l1StartingBlockTag"
:
"earliest"
,
"l2GenesisRegolithTimeOffset"
:
"0x0"
,
"faultGameAbsolutePrestate"
:
1
5
,
"faultGameAbsolutePrestate"
:
1
40
,
"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