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
a14e19a4
Unverified
Commit
a14e19a4
authored
Aug 09, 2023
by
OptimismBot
Committed by
GitHub
Aug 09, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6683 from ethereum-optimism/aj/cannon-fixes
op-challenger: Skip oracle updates when no data to publish
parents
b32317eb
a043179a
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
26 additions
and
16 deletions
+26
-16
agent.go
op-challenger/fault/agent.go
+1
-1
updater.go
op-challenger/fault/alphabet/updater.go
+1
-1
updater_test.go
op-challenger/fault/alphabet/updater_test.go
+1
-1
provider.go
op-challenger/fault/cannon/provider.go
+1
-2
provider_test.go
op-challenger/fault/cannon/provider_test.go
+1
-1
updater.go
op-challenger/fault/cannon/updater.go
+8
-5
updater_test.go
op-challenger/fault/cannon/updater_test.go
+12
-4
types.go
op-challenger/fault/types/types.go
+1
-1
No files found.
op-challenger/fault/agent.go
View file @
a14e19a4
...
@@ -141,7 +141,7 @@ func (a *Agent) step(ctx context.Context, claim types.Claim, game types.Game) er
...
@@ -141,7 +141,7 @@ func (a *Agent) step(ctx context.Context, claim types.Claim, game types.Game) er
}
}
a
.
log
.
Info
(
"Updating oracle data"
,
"oracleKey"
,
oracleData
.
OracleKey
,
"oracleData"
,
oracleData
.
OracleData
)
a
.
log
.
Info
(
"Updating oracle data"
,
"oracleKey"
,
oracleData
.
OracleKey
,
"oracleData"
,
oracleData
.
OracleData
)
if
err
:=
a
.
updater
.
UpdateOracle
(
ctx
,
*
oracleData
);
err
!=
nil
{
if
err
:=
a
.
updater
.
UpdateOracle
(
ctx
,
oracleData
);
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to load oracle data: %w"
,
err
)
return
fmt
.
Errorf
(
"failed to load oracle data: %w"
,
err
)
}
}
...
...
op-challenger/fault/alphabet/updater.go
View file @
a14e19a4
...
@@ -21,7 +21,7 @@ func NewOracleUpdater(logger log.Logger) *alphabetUpdater {
...
@@ -21,7 +21,7 @@ func NewOracleUpdater(logger log.Logger) *alphabetUpdater {
}
}
// UpdateOracle updates the oracle with the given data.
// UpdateOracle updates the oracle with the given data.
func
(
u
*
alphabetUpdater
)
UpdateOracle
(
ctx
context
.
Context
,
data
types
.
PreimageOracleData
)
error
{
func
(
u
*
alphabetUpdater
)
UpdateOracle
(
ctx
context
.
Context
,
data
*
types
.
PreimageOracleData
)
error
{
u
.
logger
.
Info
(
"alphabet oracle updater called"
)
u
.
logger
.
Info
(
"alphabet oracle updater called"
)
return
nil
return
nil
}
}
op-challenger/fault/alphabet/updater_test.go
View file @
a14e19a4
...
@@ -15,5 +15,5 @@ import (
...
@@ -15,5 +15,5 @@ import (
func
TestAlphabetUpdater
(
t
*
testing
.
T
)
{
func
TestAlphabetUpdater
(
t
*
testing
.
T
)
{
logger
:=
testlog
.
Logger
(
t
,
log
.
LvlInfo
)
logger
:=
testlog
.
Logger
(
t
,
log
.
LvlInfo
)
updater
:=
NewOracleUpdater
(
logger
)
updater
:=
NewOracleUpdater
(
logger
)
require
.
Nil
(
t
,
updater
.
UpdateOracle
(
context
.
Background
(),
types
.
PreimageOracleData
{}))
require
.
Nil
(
t
,
updater
.
UpdateOracle
(
context
.
Background
(),
&
types
.
PreimageOracleData
{}))
}
}
op-challenger/fault/cannon/provider.go
View file @
a14e19a4
...
@@ -114,8 +114,7 @@ func (p *CannonTraceProvider) GetPreimage(ctx context.Context, i uint64) ([]byte
...
@@ -114,8 +114,7 @@ func (p *CannonTraceProvider) GetPreimage(ctx context.Context, i uint64) ([]byte
}
}
func
(
p
*
CannonTraceProvider
)
AbsolutePreState
(
ctx
context
.
Context
)
([]
byte
,
error
)
{
func
(
p
*
CannonTraceProvider
)
AbsolutePreState
(
ctx
context
.
Context
)
([]
byte
,
error
)
{
path
:=
filepath
.
Join
(
p
.
dir
,
p
.
prestate
)
state
,
err
:=
parseState
(
p
.
prestate
)
state
,
err
:=
parseState
(
path
)
if
err
!=
nil
{
if
err
!=
nil
{
return
[]
byte
{},
fmt
.
Errorf
(
"cannot load absolute pre-state: %w"
,
err
)
return
[]
byte
{},
fmt
.
Errorf
(
"cannot load absolute pre-state: %w"
,
err
)
}
}
...
...
op-challenger/fault/cannon/provider_test.go
View file @
a14e19a4
...
@@ -240,7 +240,7 @@ func setupWithTestData(t *testing.T, dataDir string, prestate string) (*CannonTr
...
@@ -240,7 +240,7 @@ func setupWithTestData(t *testing.T, dataDir string, prestate string) (*CannonTr
logger
:
testlog
.
Logger
(
t
,
log
.
LvlInfo
),
logger
:
testlog
.
Logger
(
t
,
log
.
LvlInfo
),
dir
:
dataDir
,
dir
:
dataDir
,
generator
:
generator
,
generator
:
generator
,
prestate
:
prestate
,
prestate
:
filepath
.
Join
(
dataDir
,
prestate
)
,
},
generator
},
generator
}
}
...
...
op-challenger/fault/cannon/updater.go
View file @
a14e19a4
...
@@ -86,7 +86,10 @@ func NewOracleUpdaterWithOracle(
...
@@ -86,7 +86,10 @@ func NewOracleUpdaterWithOracle(
}
}
// UpdateOracle updates the oracle with the given data.
// UpdateOracle updates the oracle with the given data.
func
(
u
*
cannonUpdater
)
UpdateOracle
(
ctx
context
.
Context
,
data
types
.
PreimageOracleData
)
error
{
func
(
u
*
cannonUpdater
)
UpdateOracle
(
ctx
context
.
Context
,
data
*
types
.
PreimageOracleData
)
error
{
if
len
(
data
.
OracleKey
)
==
0
{
return
nil
}
if
data
.
IsLocal
{
if
data
.
IsLocal
{
return
u
.
sendLocalOracleData
(
ctx
,
data
)
return
u
.
sendLocalOracleData
(
ctx
,
data
)
}
}
...
@@ -94,7 +97,7 @@ func (u *cannonUpdater) UpdateOracle(ctx context.Context, data types.PreimageOra
...
@@ -94,7 +97,7 @@ func (u *cannonUpdater) UpdateOracle(ctx context.Context, data types.PreimageOra
}
}
// sendLocalOracleData sends the local oracle data to the [txmgr].
// sendLocalOracleData sends the local oracle data to the [txmgr].
func
(
u
*
cannonUpdater
)
sendLocalOracleData
(
ctx
context
.
Context
,
data
types
.
PreimageOracleData
)
error
{
func
(
u
*
cannonUpdater
)
sendLocalOracleData
(
ctx
context
.
Context
,
data
*
types
.
PreimageOracleData
)
error
{
txData
,
err
:=
u
.
BuildLocalOracleData
(
data
)
txData
,
err
:=
u
.
BuildLocalOracleData
(
data
)
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"local oracle tx data build: %w"
,
err
)
return
fmt
.
Errorf
(
"local oracle tx data build: %w"
,
err
)
...
@@ -103,7 +106,7 @@ func (u *cannonUpdater) sendLocalOracleData(ctx context.Context, data types.Prei
...
@@ -103,7 +106,7 @@ func (u *cannonUpdater) sendLocalOracleData(ctx context.Context, data types.Prei
}
}
// sendGlobalOracleData sends the global oracle data to the [txmgr].
// sendGlobalOracleData sends the global oracle data to the [txmgr].
func
(
u
*
cannonUpdater
)
sendGlobalOracleData
(
ctx
context
.
Context
,
data
types
.
PreimageOracleData
)
error
{
func
(
u
*
cannonUpdater
)
sendGlobalOracleData
(
ctx
context
.
Context
,
data
*
types
.
PreimageOracleData
)
error
{
txData
,
err
:=
u
.
BuildGlobalOracleData
(
data
)
txData
,
err
:=
u
.
BuildGlobalOracleData
(
data
)
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"global oracle tx data build: %w"
,
err
)
return
fmt
.
Errorf
(
"global oracle tx data build: %w"
,
err
)
...
@@ -114,7 +117,7 @@ func (u *cannonUpdater) sendGlobalOracleData(ctx context.Context, data types.Pre
...
@@ -114,7 +117,7 @@ func (u *cannonUpdater) sendGlobalOracleData(ctx context.Context, data types.Pre
// BuildLocalOracleData takes the local preimage key and data
// BuildLocalOracleData takes the local preimage key and data
// and creates tx data to load the key, data pair into the
// and creates tx data to load the key, data pair into the
// PreimageOracle contract from the FaultDisputeGame contract call.
// PreimageOracle contract from the FaultDisputeGame contract call.
func
(
u
*
cannonUpdater
)
BuildLocalOracleData
(
data
types
.
PreimageOracleData
)
([]
byte
,
error
)
{
func
(
u
*
cannonUpdater
)
BuildLocalOracleData
(
data
*
types
.
PreimageOracleData
)
([]
byte
,
error
)
{
return
u
.
fdgAbi
.
Pack
(
return
u
.
fdgAbi
.
Pack
(
"addLocalData"
,
"addLocalData"
,
data
.
GetIdent
(),
data
.
GetIdent
(),
...
@@ -125,7 +128,7 @@ func (u *cannonUpdater) BuildLocalOracleData(data types.PreimageOracleData) ([]b
...
@@ -125,7 +128,7 @@ func (u *cannonUpdater) BuildLocalOracleData(data types.PreimageOracleData) ([]b
// BuildGlobalOracleData takes the global preimage key and data
// BuildGlobalOracleData takes the global preimage key and data
// and creates tx data to load the key, data pair into the
// and creates tx data to load the key, data pair into the
// PreimageOracle contract.
// PreimageOracle contract.
func
(
u
*
cannonUpdater
)
BuildGlobalOracleData
(
data
types
.
PreimageOracleData
)
([]
byte
,
error
)
{
func
(
u
*
cannonUpdater
)
BuildGlobalOracleData
(
data
*
types
.
PreimageOracleData
)
([]
byte
,
error
)
{
return
u
.
preimageOracleAbi
.
Pack
(
return
u
.
preimageOracleAbi
.
Pack
(
"loadKeccak256PreimagePart"
,
"loadKeccak256PreimagePart"
,
big
.
NewInt
(
int64
(
data
.
OracleOffset
)),
big
.
NewInt
(
int64
(
data
.
OracleOffset
)),
...
...
op-challenger/fault/cannon/updater_test.go
View file @
a14e19a4
...
@@ -74,7 +74,8 @@ func newTestCannonUpdater(t *testing.T, sendFails bool) (*cannonUpdater, *mockTx
...
@@ -74,7 +74,8 @@ func newTestCannonUpdater(t *testing.T, sendFails bool) (*cannonUpdater, *mockTx
func
TestCannonUpdater_UpdateOracle
(
t
*
testing
.
T
)
{
func
TestCannonUpdater_UpdateOracle
(
t
*
testing
.
T
)
{
t
.
Run
(
"succeeds"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"succeeds"
,
func
(
t
*
testing
.
T
)
{
updater
,
mockTxMgr
:=
newTestCannonUpdater
(
t
,
false
)
updater
,
mockTxMgr
:=
newTestCannonUpdater
(
t
,
false
)
require
.
Nil
(
t
,
updater
.
UpdateOracle
(
context
.
Background
(),
types
.
PreimageOracleData
{
require
.
NoError
(
t
,
updater
.
UpdateOracle
(
context
.
Background
(),
&
types
.
PreimageOracleData
{
OracleKey
:
common
.
Hash
{
0xaa
}
.
Bytes
(),
OracleData
:
common
.
Hex2Bytes
(
"cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc"
),
OracleData
:
common
.
Hex2Bytes
(
"cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc"
),
}))
}))
require
.
Equal
(
t
,
1
,
mockTxMgr
.
sends
)
require
.
Equal
(
t
,
1
,
mockTxMgr
.
sends
)
...
@@ -82,18 +83,25 @@ func TestCannonUpdater_UpdateOracle(t *testing.T) {
...
@@ -82,18 +83,25 @@ func TestCannonUpdater_UpdateOracle(t *testing.T) {
t
.
Run
(
"send fails"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"send fails"
,
func
(
t
*
testing
.
T
)
{
updater
,
mockTxMgr
:=
newTestCannonUpdater
(
t
,
true
)
updater
,
mockTxMgr
:=
newTestCannonUpdater
(
t
,
true
)
require
.
Error
(
t
,
updater
.
UpdateOracle
(
context
.
Background
(),
types
.
PreimageOracleData
{
require
.
Error
(
t
,
updater
.
UpdateOracle
(
context
.
Background
(),
&
types
.
PreimageOracleData
{
OracleKey
:
common
.
Hash
{
0xaa
}
.
Bytes
(),
OracleData
:
common
.
Hex2Bytes
(
"cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc"
),
OracleData
:
common
.
Hex2Bytes
(
"cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc"
),
}))
}))
require
.
Equal
(
t
,
1
,
mockTxMgr
.
failedSends
)
require
.
Equal
(
t
,
1
,
mockTxMgr
.
failedSends
)
})
})
t
.
Run
(
"skip empty data"
,
func
(
t
*
testing
.
T
)
{
updater
,
mockTxMgr
:=
newTestCannonUpdater
(
t
,
true
)
require
.
NoError
(
t
,
updater
.
UpdateOracle
(
context
.
Background
(),
&
types
.
PreimageOracleData
{}))
require
.
Equal
(
t
,
0
,
mockTxMgr
.
sends
)
})
}
}
// TestCannonUpdater_BuildLocalOracleData tests the [cannonUpdater]
// TestCannonUpdater_BuildLocalOracleData tests the [cannonUpdater]
// builds a valid tx candidate for a local oracle update.
// builds a valid tx candidate for a local oracle update.
func
TestCannonUpdater_BuildLocalOracleData
(
t
*
testing
.
T
)
{
func
TestCannonUpdater_BuildLocalOracleData
(
t
*
testing
.
T
)
{
updater
,
_
:=
newTestCannonUpdater
(
t
,
false
)
updater
,
_
:=
newTestCannonUpdater
(
t
,
false
)
oracleData
:=
types
.
PreimageOracleData
{
oracleData
:=
&
types
.
PreimageOracleData
{
OracleKey
:
common
.
Hex2Bytes
(
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
),
OracleKey
:
common
.
Hex2Bytes
(
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
),
OracleData
:
common
.
Hex2Bytes
(
"cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc"
),
OracleData
:
common
.
Hex2Bytes
(
"cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc"
),
OracleOffset
:
7
,
OracleOffset
:
7
,
...
@@ -117,7 +125,7 @@ func TestCannonUpdater_BuildLocalOracleData(t *testing.T) {
...
@@ -117,7 +125,7 @@ func TestCannonUpdater_BuildLocalOracleData(t *testing.T) {
// builds a valid tx candidate for a global oracle update.
// builds a valid tx candidate for a global oracle update.
func
TestCannonUpdater_BuildGlobalOracleData
(
t
*
testing
.
T
)
{
func
TestCannonUpdater_BuildGlobalOracleData
(
t
*
testing
.
T
)
{
updater
,
_
:=
newTestCannonUpdater
(
t
,
false
)
updater
,
_
:=
newTestCannonUpdater
(
t
,
false
)
oracleData
:=
types
.
PreimageOracleData
{
oracleData
:=
&
types
.
PreimageOracleData
{
OracleKey
:
common
.
Hex2Bytes
(
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
),
OracleKey
:
common
.
Hex2Bytes
(
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
),
OracleData
:
common
.
Hex2Bytes
(
"cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc"
),
OracleData
:
common
.
Hex2Bytes
(
"cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc"
),
OracleOffset
:
7
,
OracleOffset
:
7
,
...
...
op-challenger/fault/types/types.go
View file @
a14e19a4
...
@@ -65,7 +65,7 @@ type StepCallData struct {
...
@@ -65,7 +65,7 @@ type StepCallData struct {
// OracleUpdater is a generic interface for updating oracles.
// OracleUpdater is a generic interface for updating oracles.
type
OracleUpdater
interface
{
type
OracleUpdater
interface
{
// UpdateOracle updates the oracle with the given data.
// UpdateOracle updates the oracle with the given data.
UpdateOracle
(
ctx
context
.
Context
,
data
PreimageOracleData
)
error
UpdateOracle
(
ctx
context
.
Context
,
data
*
PreimageOracleData
)
error
}
}
// TraceProvider is a generic way to get a claim value at a specific step in the trace.
// TraceProvider is a generic way to get a claim value at a specific step in the trace.
...
...
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