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
3df468ef
Unverified
Commit
3df468ef
authored
Dec 11, 2023
by
Adrian Sutton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-challenger: Remove localContext from PreimageOracleData as it's never actually used.
parent
92e86c9d
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
18 additions
and
26 deletions
+18
-26
faultdisputegame.go
op-challenger/game/fault/contracts/faultdisputegame.go
+1
-1
faultdisputegame_test.go
op-challenger/game/fault/contracts/faultdisputegame_test.go
+1
-2
outputbisectiongame_test.go
...allenger/game/fault/contracts/outputbisectiongame_test.go
+0
-1
responder_test.go
op-challenger/game/fault/responder/responder_test.go
+1
-2
alphabet.go
op-challenger/game/fault/test/alphabet.go
+1
-1
provider.go
op-challenger/game/fault/trace/alphabet/provider.go
+7
-6
provider_test.go
op-challenger/game/fault/trace/alphabet/provider_test.go
+2
-3
provider.go
op-challenger/game/fault/trace/cannon/provider.go
+1
-1
provider_test.go
op-challenger/game/fault/trace/cannon/provider_test.go
+1
-1
types.go
op-challenger/game/fault/types/types.go
+1
-3
types_test.go
op-challenger/game/fault/types/types_test.go
+2
-5
No files found.
op-challenger/game/fault/contracts/faultdisputegame.go
View file @
3df468ef
...
...
@@ -58,7 +58,7 @@ func (f *FaultDisputeGameContract) addLocalDataTx(data *types.PreimageOracleData
call
:=
f
.
contract
.
Call
(
methodAddLocalData
,
data
.
GetIdent
(),
data
.
LocalContext
,
types
.
No
LocalContext
,
new
(
big
.
Int
)
.
SetUint64
(
uint64
(
data
.
OracleOffset
)),
)
return
call
.
ToTxCandidate
()
...
...
op-challenger/game/fault/contracts/faultdisputegame_test.go
View file @
3df468ef
...
...
@@ -60,7 +60,6 @@ func TestFaultDisputeGame_UpdateOracleTx(t *testing.T) {
stubRpc
,
game
:=
setupFaultDisputeGameTest
(
t
)
data
:=
&
faultTypes
.
PreimageOracleData
{
IsLocal
:
true
,
LocalContext
:
common
.
Hash
{
0x02
},
OracleKey
:
common
.
Hash
{
0xbc
}
.
Bytes
(),
OracleData
:
[]
byte
{
1
,
2
,
3
,
4
,
5
,
6
,
7
},
OracleOffset
:
16
,
...
...
@@ -68,7 +67,7 @@ func TestFaultDisputeGame_UpdateOracleTx(t *testing.T) {
claimIdx
:=
uint64
(
6
)
stubRpc
.
SetResponse
(
fdgAddr
,
methodAddLocalData
,
batching
.
BlockLatest
,
[]
interface
{}{
data
.
GetIdent
(),
data
.
LocalContext
,
faultTypes
.
No
LocalContext
,
new
(
big
.
Int
)
.
SetUint64
(
uint64
(
data
.
OracleOffset
)),
},
nil
)
tx
,
err
:=
game
.
UpdateOracleTx
(
context
.
Background
(),
claimIdx
,
data
)
...
...
op-challenger/game/fault/contracts/outputbisectiongame_test.go
View file @
3df468ef
...
...
@@ -55,7 +55,6 @@ func TestOutputBisectionGame_UpdateOracleTx(t *testing.T) {
stubRpc
,
game
:=
setupOutputBisectionGameTest
(
t
)
data
:=
&
faultTypes
.
PreimageOracleData
{
IsLocal
:
true
,
LocalContext
:
common
.
Hash
{
0x02
},
OracleKey
:
common
.
Hash
{
0xbc
}
.
Bytes
(),
OracleData
:
[]
byte
{
1
,
2
,
3
,
4
,
5
,
6
,
7
},
OracleOffset
:
16
,
...
...
op-challenger/game/fault/responder/responder_test.go
View file @
3df468ef
...
...
@@ -180,7 +180,6 @@ func TestPerformAction(t *testing.T) {
ProofData
:
[]
byte
{
4
,
5
,
6
},
OracleData
:
&
types
.
PreimageOracleData
{
IsLocal
:
true
,
LocalContext
:
common
.
Hash
{
0x06
},
},
}
err
:=
responder
.
PerformAction
(
context
.
Background
(),
action
)
...
...
op-challenger/game/fault/test/alphabet.go
View file @
3df468ef
...
...
@@ -33,6 +33,6 @@ func (a *alphabetWithProofProvider) GetStepData(ctx context.Context, i types.Pos
return
nil
,
nil
,
nil
,
err
}
traceIndex
:=
i
.
TraceIndex
(
int
(
a
.
depth
))
.
Uint64
()
data
:=
types
.
NewPreimageOracleData
(
types
.
NoLocalContext
,
[]
byte
{
byte
(
traceIndex
)},
[]
byte
{
byte
(
traceIndex
-
1
)},
uint32
(
traceIndex
-
1
))
data
:=
types
.
NewPreimageOracleData
([]
byte
{
byte
(
traceIndex
)},
[]
byte
{
byte
(
traceIndex
-
1
)},
uint32
(
traceIndex
-
1
))
return
preimage
,
[]
byte
{
byte
(
traceIndex
-
1
)},
data
,
nil
}
op-challenger/game/fault/trace/alphabet/provider.go
View file @
3df468ef
...
...
@@ -16,6 +16,10 @@ import (
"github.com/ethereum/go-ethereum/crypto"
)
const
(
L2ClaimBlockNumberLocalIndex
=
4
)
var
(
ErrIndexTooLarge
=
errors
.
New
(
"index is larger than the maximum index"
)
)
...
...
@@ -53,12 +57,9 @@ func (ap *AlphabetTraceProvider) GetStepData(ctx context.Context, i types.Positi
if
traceIndex
.
Cmp
(
big
.
NewInt
(
int64
(
len
(
ap
.
state
))))
>=
0
{
return
ap
.
GetStepData
(
ctx
,
types
.
NewPosition
(
int
(
ap
.
depth
),
big
.
NewInt
(
int64
(
len
(
ap
.
state
)))))
}
key
:=
preimage
.
LocalIndexKey
(
4
)
.
PreimageKey
()
// For alphabet output bisection, the state is the local context - that is, the
// pre-state l2 block number. So we can just use [ap.state] as the localContext.
localContext
:=
common
.
HexToHash
(
strings
.
Join
(
ap
.
state
,
""
))
localContextData
:=
types
.
NewPreimageOracleData
(
localContext
,
key
[
:
],
nil
,
0
)
return
BuildAlphabetPreimage
(
traceIndex
,
ap
.
state
[
traceIndex
.
Uint64
()]),
[]
byte
{},
localContextData
,
nil
key
:=
preimage
.
LocalIndexKey
(
L2ClaimBlockNumberLocalIndex
)
.
PreimageKey
()
preimageData
:=
types
.
NewPreimageOracleData
(
key
[
:
],
nil
,
0
)
return
BuildAlphabetPreimage
(
traceIndex
,
ap
.
state
[
traceIndex
.
Uint64
()]),
[]
byte
{},
preimageData
,
nil
}
// Get returns the claim value at the given index in the trace.
...
...
op-challenger/game/fault/trace/alphabet/provider_test.go
View file @
3df468ef
...
...
@@ -61,9 +61,8 @@ func TestGetStepData_Succeeds(t *testing.T) {
require
.
NoError
(
t
,
err
)
require
.
Equal
(
t
,
expected
,
retrieved
)
require
.
Empty
(
t
,
proof
)
localContext
:=
common
.
HexToHash
(
"abc"
)
key
:=
preimage
.
LocalIndexKey
(
4
)
.
PreimageKey
()
expectedLocalContextData
:=
types
.
NewPreimageOracleData
(
localContext
,
key
[
:
],
nil
,
0
)
key
:=
preimage
.
LocalIndexKey
(
L2ClaimBlockNumberLocalIndex
)
.
PreimageKey
()
expectedLocalContextData
:=
types
.
NewPreimageOracleData
(
key
[
:
],
nil
,
0
)
require
.
Equal
(
t
,
expectedLocalContextData
,
data
)
}
...
...
op-challenger/game/fault/trace/cannon/provider.go
View file @
3df468ef
...
...
@@ -105,7 +105,7 @@ func (p *CannonTraceProvider) GetStepData(ctx context.Context, pos types.Positio
}
var
oracleData
*
types
.
PreimageOracleData
if
len
(
proof
.
OracleKey
)
>
0
{
oracleData
=
types
.
NewPreimageOracleData
(
p
.
localContext
,
p
roof
.
OracleKey
,
proof
.
OracleValue
,
proof
.
OracleOffset
)
oracleData
=
types
.
NewPreimageOracleData
(
proof
.
OracleKey
,
proof
.
OracleValue
,
proof
.
OracleOffset
)
}
return
value
,
data
,
oracleData
,
nil
}
...
...
op-challenger/game/fault/trace/cannon/provider_test.go
View file @
3df468ef
...
...
@@ -124,7 +124,7 @@ func TestGetStepData(t *testing.T) {
require
.
EqualValues
(
t
,
generator
.
proof
.
StateData
,
preimage
)
require
.
EqualValues
(
t
,
generator
.
proof
.
ProofData
,
proof
)
expectedData
:=
types
.
NewPreimageOracleData
(
common
.
Hash
{},
generator
.
proof
.
OracleKey
,
generator
.
proof
.
OracleValue
,
generator
.
proof
.
OracleOffset
)
expectedData
:=
types
.
NewPreimageOracleData
(
generator
.
proof
.
OracleKey
,
generator
.
proof
.
OracleValue
,
generator
.
proof
.
OracleOffset
)
require
.
EqualValues
(
t
,
expectedData
,
data
)
})
...
...
op-challenger/game/fault/types/types.go
View file @
3df468ef
...
...
@@ -20,7 +20,6 @@ var (
// to load into the onchain oracle.
type
PreimageOracleData
struct
{
IsLocal
bool
LocalContext
common
.
Hash
OracleKey
[]
byte
OracleData
[]
byte
OracleOffset
uint32
...
...
@@ -37,10 +36,9 @@ func (p *PreimageOracleData) GetPreimageWithoutSize() []byte {
}
// NewPreimageOracleData creates a new [PreimageOracleData] instance.
func
NewPreimageOracleData
(
lctx
common
.
Hash
,
key
[]
byte
,
data
[]
byte
,
offset
uint32
)
*
PreimageOracleData
{
func
NewPreimageOracleData
(
key
[]
byte
,
data
[]
byte
,
offset
uint32
)
*
PreimageOracleData
{
return
&
PreimageOracleData
{
IsLocal
:
len
(
key
)
>
0
&&
key
[
0
]
==
byte
(
1
),
LocalContext
:
lctx
,
OracleKey
:
key
,
OracleData
:
data
,
OracleOffset
:
offset
,
...
...
op-challenger/game/fault/types/types_test.go
View file @
3df468ef
...
...
@@ -4,24 +4,21 @@ import (
"math/big"
"testing"
"github.com/ethereum/go-ethereum/common"
"github.com/stretchr/testify/require"
)
func
TestNewPreimageOracleData
(
t
*
testing
.
T
)
{
t
.
Run
(
"LocalData"
,
func
(
t
*
testing
.
T
)
{
data
:=
NewPreimageOracleData
(
common
.
Hash
{
0x01
},
[]
byte
{
1
,
2
,
3
},
[]
byte
{
4
,
5
,
6
},
7
)
data
:=
NewPreimageOracleData
([]
byte
{
1
,
2
,
3
},
[]
byte
{
4
,
5
,
6
},
7
)
require
.
True
(
t
,
data
.
IsLocal
)
require
.
Equal
(
t
,
common
.
Hash
{
0x01
},
data
.
LocalContext
)
require
.
Equal
(
t
,
[]
byte
{
1
,
2
,
3
},
data
.
OracleKey
)
require
.
Equal
(
t
,
[]
byte
{
4
,
5
,
6
},
data
.
OracleData
)
require
.
Equal
(
t
,
uint32
(
7
),
data
.
OracleOffset
)
})
t
.
Run
(
"GlobalData"
,
func
(
t
*
testing
.
T
)
{
data
:=
NewPreimageOracleData
(
common
.
Hash
{
0x01
},
[]
byte
{
0
,
2
,
3
},
[]
byte
{
4
,
5
,
6
},
7
)
data
:=
NewPreimageOracleData
([]
byte
{
0
,
2
,
3
},
[]
byte
{
4
,
5
,
6
},
7
)
require
.
False
(
t
,
data
.
IsLocal
)
require
.
Equal
(
t
,
common
.
Hash
{
0x01
},
data
.
LocalContext
)
require
.
Equal
(
t
,
[]
byte
{
0
,
2
,
3
},
data
.
OracleKey
)
require
.
Equal
(
t
,
[]
byte
{
4
,
5
,
6
},
data
.
OracleData
)
require
.
Equal
(
t
,
uint32
(
7
),
data
.
OracleOffset
)
...
...
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