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
508fbf35
Commit
508fbf35
authored
Sep 06, 2023
by
clabby
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
:broom:
parent
b59b8710
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
16 additions
and
39 deletions
+16
-39
state.go
cannon/mipsevm/state.go
+2
-3
player_test.go
op-challenger/game/fault/player_test.go
+0
-5
provider.go
op-challenger/game/fault/trace/alphabet/provider.go
+0
-4
provider_test.go
op-challenger/game/fault/trace/alphabet/provider_test.go
+6
-6
provider.go
op-challenger/game/fault/trace/cannon/provider.go
+0
-8
provider_test.go
op-challenger/game/fault/trace/cannon/provider_test.go
+1
-1
types.go
op-challenger/game/fault/types/types.go
+0
-3
MIPS.t.sol
packages/contracts-bedrock/test/MIPS.t.sol
+7
-9
No files found.
cannon/mipsevm/state.go
View file @
508fbf35
...
@@ -80,13 +80,12 @@ const (
...
@@ -80,13 +80,12 @@ const (
)
)
func
(
sw
StateWitness
)
StateHash
()
(
common
.
Hash
,
error
)
{
func
(
sw
StateWitness
)
StateHash
()
(
common
.
Hash
,
error
)
{
hash
:=
crypto
.
Keccak256Hash
(
sw
)
offset
:=
32
*
2
+
4
*
6
if
len
(
sw
)
!=
226
{
if
len
(
sw
)
!=
226
{
return
common
.
Hash
{},
fmt
.
Errorf
(
"Invalid witness length. Got %d, expected at least 88"
,
len
(
sw
))
return
common
.
Hash
{},
fmt
.
Errorf
(
"Invalid witness length. Got %d, expected at least 88"
,
len
(
sw
))
}
}
hash
:=
crypto
.
Keccak256Hash
(
sw
)
offset
:=
32
*
2
+
4
*
6
exitCode
:=
sw
[
offset
]
exitCode
:=
sw
[
offset
]
exited
:=
sw
[
offset
+
1
]
exited
:=
sw
[
offset
+
1
]
status
:=
vmStatus
(
exited
==
1
,
exitCode
)
status
:=
vmStatus
(
exited
==
1
,
exitCode
)
...
...
op-challenger/game/fault/player_test.go
View file @
508fbf35
...
@@ -222,11 +222,6 @@ func (m *mockTraceProvider) AbsolutePreStateCommitment(ctx context.Context) (com
...
@@ -222,11 +222,6 @@ func (m *mockTraceProvider) AbsolutePreStateCommitment(ctx context.Context) (com
return
hash
,
nil
return
hash
,
nil
}
}
// StateHash computes the state-hash of the given state, or returns an error if the state is invalid.
func
(
m
*
mockTraceProvider
)
StateHash
(
ctx
context
.
Context
,
state
[]
byte
)
(
common
.
Hash
,
error
)
{
panic
(
"not implemented"
)
}
type
mockLoader
struct
{
type
mockLoader
struct
{
prestateError
bool
prestateError
bool
prestate
common
.
Hash
prestate
common
.
Hash
...
...
op-challenger/game/fault/trace/alphabet/provider.go
View file @
508fbf35
...
@@ -77,10 +77,6 @@ func (ap *AlphabetTraceProvider) AbsolutePreStateCommitment(ctx context.Context)
...
@@ -77,10 +77,6 @@ func (ap *AlphabetTraceProvider) AbsolutePreStateCommitment(ctx context.Context)
return
hash
,
nil
return
hash
,
nil
}
}
func
(
ap
*
AlphabetTraceProvider
)
StateHash
(
ctx
context
.
Context
,
state
[]
byte
)
(
common
.
Hash
,
error
)
{
return
alphabetStateHash
(
state
),
nil
}
// 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/game/fault/trace/alphabet/provider_test.go
View file @
508fbf35
...
@@ -9,7 +9,7 @@ import (
...
@@ -9,7 +9,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/require"
)
)
func
alphabetClaim
(
index
uint64
,
letter
string
,
provider
*
AlphabetTraceProvider
)
common
.
Hash
{
func
alphabetClaim
(
index
uint64
,
letter
string
)
common
.
Hash
{
return
alphabetStateHash
(
BuildAlphabetPreimage
(
index
,
letter
))
return
alphabetStateHash
(
BuildAlphabetPreimage
(
index
,
letter
))
}
}
...
@@ -25,15 +25,15 @@ func TestAlphabetProvider_Get_ClaimsByTraceIndex(t *testing.T) {
...
@@ -25,15 +25,15 @@ func TestAlphabetProvider_Get_ClaimsByTraceIndex(t *testing.T) {
}{
}{
{
{
7
,
7
,
alphabetClaim
(
7
,
"h"
,
canonicalProvider
),
alphabetClaim
(
7
,
"h"
),
},
},
{
{
3
,
3
,
alphabetClaim
(
3
,
"d"
,
canonicalProvider
),
alphabetClaim
(
3
,
"d"
),
},
},
{
{
5
,
5
,
alphabetClaim
(
5
,
"f"
,
canonicalProvider
),
alphabetClaim
(
5
,
"f"
),
},
},
}
}
...
@@ -80,7 +80,7 @@ func TestGet_Succeeds(t *testing.T) {
...
@@ -80,7 +80,7 @@ func TestGet_Succeeds(t *testing.T) {
ap
:=
NewTraceProvider
(
"abc"
,
2
)
ap
:=
NewTraceProvider
(
"abc"
,
2
)
claim
,
err
:=
ap
.
Get
(
context
.
Background
(),
0
)
claim
,
err
:=
ap
.
Get
(
context
.
Background
(),
0
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
expected
:=
alphabetClaim
(
0
,
"a"
,
ap
)
expected
:=
alphabetClaim
(
0
,
"a"
)
require
.
Equal
(
t
,
expected
,
claim
)
require
.
Equal
(
t
,
expected
,
claim
)
}
}
...
@@ -98,6 +98,6 @@ func TestGet_Extends(t *testing.T) {
...
@@ -98,6 +98,6 @@ func TestGet_Extends(t *testing.T) {
ap
:=
NewTraceProvider
(
"abc"
,
2
)
ap
:=
NewTraceProvider
(
"abc"
,
2
)
claim
,
err
:=
ap
.
Get
(
context
.
Background
(),
3
)
claim
,
err
:=
ap
.
Get
(
context
.
Background
(),
3
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
expected
:=
alphabetClaim
(
2
,
"c"
,
ap
)
expected
:=
alphabetClaim
(
2
,
"c"
)
require
.
Equal
(
t
,
expected
,
claim
)
require
.
Equal
(
t
,
expected
,
claim
)
}
}
op-challenger/game/fault/trace/cannon/provider.go
View file @
508fbf35
...
@@ -194,11 +194,3 @@ func (p *CannonTraceProvider) loadProof(ctx context.Context, i uint64) (*proofDa
...
@@ -194,11 +194,3 @@ func (p *CannonTraceProvider) loadProof(ctx context.Context, i uint64) (*proofDa
}
}
return
&
proof
,
nil
return
&
proof
,
nil
}
}
func
(
p
*
CannonTraceProvider
)
StateHash
(
ctx
context
.
Context
,
state
[]
byte
)
(
common
.
Hash
,
error
)
{
hash
,
err
:=
mipsevm
.
StateWitness
(
state
)
.
StateHash
()
if
err
!=
nil
{
return
common
.
Hash
{},
fmt
.
Errorf
(
"cannot hash state: %w"
,
err
)
}
return
hash
,
nil
}
op-challenger/game/fault/trace/cannon/provider_test.go
View file @
508fbf35
...
@@ -42,7 +42,7 @@ func TestGet(t *testing.T) {
...
@@ -42,7 +42,7 @@ func TestGet(t *testing.T) {
value
,
err
:=
provider
.
Get
(
context
.
Background
(),
7000
)
value
,
err
:=
provider
.
Get
(
context
.
Background
(),
7000
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
require
.
Contains
(
t
,
generator
.
generated
,
7000
,
"should have tried to generate the proof"
)
require
.
Contains
(
t
,
generator
.
generated
,
7000
,
"should have tried to generate the proof"
)
stateHash
,
err
:=
provider
.
StateHash
(
context
.
Background
(),
generator
.
finalState
.
EncodeWitness
()
)
stateHash
,
err
:=
generator
.
finalState
.
EncodeWitness
()
.
StateHash
(
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
require
.
Equal
(
t
,
stateHash
,
value
)
require
.
Equal
(
t
,
stateHash
,
value
)
})
})
...
...
op-challenger/game/fault/types/types.go
View file @
508fbf35
...
@@ -108,9 +108,6 @@ type TraceProvider interface {
...
@@ -108,9 +108,6 @@ type TraceProvider interface {
// AbsolutePreStateCommitment is the commitment of the pre-image value of the trace that transitions to the trace value at index 0
// AbsolutePreStateCommitment is the commitment of the pre-image value of the trace that transitions to the trace value at index 0
AbsolutePreStateCommitment
(
ctx
context
.
Context
)
(
hash
common
.
Hash
,
err
error
)
AbsolutePreStateCommitment
(
ctx
context
.
Context
)
(
hash
common
.
Hash
,
err
error
)
// StateHash computes the state-hash of the given state, or returns an error if the state is invalid.
StateHash
(
ctx
context
.
Context
,
state
[]
byte
)
(
common
.
Hash
,
error
)
}
}
// 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/test/MIPS.t.sol
View file @
508fbf35
...
@@ -1560,17 +1560,15 @@ contract MIPS_Test is CommonTest {
...
@@ -1560,17 +1560,15 @@ contract MIPS_Test is CommonTest {
/// 2. Exited with failure (Panic)
/// 2. Exited with failure (Panic)
/// 3. Unfinished
/// 3. Unfinished
function vmStatus(MIPS.State memory state) internal pure returns (VMStatus out_) {
function vmStatus(MIPS.State memory state) internal pure returns (VMStatus out_) {
if (state.exited) {
if (!state.exited) {
if (state.exitCode == 0) {
return VMStatuses.UNFINISHED;
} else if (state.exitCode == 0) {
return VMStatuses.VALID;
return VMStatuses.VALID;
} else if (state.exitCode == 1) {
} else if (state.exitCode == 1) {
return VMStatuses.INVALID;
return VMStatuses.INVALID;
} else {
} else {
return VMStatuses.PANIC;
return VMStatuses.PANIC;
}
}
} else {
return VMStatuses.UNFINISHED;
}
}
}
function outputState(MIPS.State memory state) internal pure returns (bytes32 out_) {
function outputState(MIPS.State memory state) internal pure returns (bytes32 out_) {
...
...
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