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
2b0c5664
Commit
2b0c5664
authored
Aug 02, 2023
by
Andreas Bigger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update the cannon oracle updater with apriori data tx crafting
parent
9fa619e7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
76 additions
and
5 deletions
+76
-5
updater.go
op-challenger/fault/cannon/updater.go
+70
-5
types.go
op-challenger/fault/types/types.go
+6
-0
No files found.
op-challenger/fault/cannon/updater.go
View file @
2b0c5664
...
@@ -2,6 +2,8 @@ package cannon
...
@@ -2,6 +2,8 @@ package cannon
import
(
import
(
"context"
"context"
"fmt"
"math/big"
"github.com/ethereum-optimism/optimism/op-bindings/bindings"
"github.com/ethereum-optimism/optimism/op-bindings/bindings"
"github.com/ethereum-optimism/optimism/op-challenger/fault/types"
"github.com/ethereum-optimism/optimism/op-challenger/fault/types"
...
@@ -9,14 +11,15 @@ import (
...
@@ -9,14 +11,15 @@ import (
"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
ethtypes
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/log"
)
)
// cannonUpdater is a [types.OracleUpdater] that exposes a method
// cannonUpdater is a [types.OracleUpdater] that exposes a method
// to update onchain cannon oracles with required data.
// to update onchain cannon oracles with required data.
type
cannonUpdater
struct
{
type
cannonUpdater
struct
{
log
ger
log
.
Logger
log
log
.
Logger
txMgr
txmgr
.
TxManager
txMgr
txmgr
.
TxManager
fdgAbi
abi
.
ABI
fdgAbi
abi
.
ABI
fdgAddr
common
.
Address
fdgAddr
common
.
Address
...
@@ -42,8 +45,8 @@ func NewOracleUpdater(
...
@@ -42,8 +45,8 @@ func NewOracleUpdater(
}
}
return
&
cannonUpdater
{
return
&
cannonUpdater
{
log
ger
:
logger
,
log
:
logger
,
txMgr
:
txMgr
,
txMgr
:
txMgr
,
fdgAbi
:
*
fdgAbi
,
fdgAbi
:
*
fdgAbi
,
fdgAddr
:
fdgAddr
,
fdgAddr
:
fdgAddr
,
...
@@ -55,5 +58,67 @@ func NewOracleUpdater(
...
@@ -55,5 +58,67 @@ func NewOracleUpdater(
// 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
{
panic
(
"oracle updates not implemented"
)
if
data
.
IsLocal
{
return
u
.
sendLocalOracleData
(
ctx
,
data
)
}
return
u
.
sendGlobalOracleData
(
ctx
,
data
)
}
// sendLocalOracleData sends the local oracle data to the [txmgr].
func
(
u
*
cannonUpdater
)
sendLocalOracleData
(
ctx
context
.
Context
,
data
types
.
PreimageOracleData
)
error
{
txData
,
err
:=
u
.
buildLocalOracleData
(
data
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"local oracle tx data build: %w"
,
err
)
}
return
u
.
sendTxAndWait
(
ctx
,
u
.
fdgAddr
,
txData
)
}
// sendGlobalOracleData sends the global oracle data to the [txmgr].
func
(
u
*
cannonUpdater
)
sendGlobalOracleData
(
ctx
context
.
Context
,
data
types
.
PreimageOracleData
)
error
{
txData
,
err
:=
u
.
buildGlobalOracleData
(
data
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"global oracle tx data build: %w"
,
err
)
}
return
u
.
sendTxAndWait
(
ctx
,
u
.
fdgAddr
,
txData
)
}
// buildLocalOracleData takes the local preimage key and data
// and creates tx data to load the key, data pair into the
// PreimageOracle contract from the FaultDisputeGame contract call.
func
(
u
*
cannonUpdater
)
buildLocalOracleData
(
data
types
.
PreimageOracleData
)
([]
byte
,
error
)
{
return
u
.
fdgAbi
.
Pack
(
"addLocalData"
,
data
.
OracleKey
,
big
.
NewInt
(
0
),
)
}
// buildGlobalOracleData takes the global preimage key and data
// and creates tx data to load the key, data pair into the
// PreimageOracle contract.
func
(
u
*
cannonUpdater
)
buildGlobalOracleData
(
data
types
.
PreimageOracleData
)
([]
byte
,
error
)
{
return
u
.
preimageOracleAbi
.
Pack
(
"loadKeccak256PreimagePart"
,
big
.
NewInt
(
0
),
data
.
OracleData
,
)
}
// sendTxAndWait sends a transaction through the [txmgr] and waits for a receipt.
// This sets the tx GasLimit to 0, performing gas estimation online through the [txmgr].
func
(
u
*
cannonUpdater
)
sendTxAndWait
(
ctx
context
.
Context
,
addr
common
.
Address
,
txData
[]
byte
)
error
{
receipt
,
err
:=
u
.
txMgr
.
Send
(
ctx
,
txmgr
.
TxCandidate
{
To
:
&
addr
,
TxData
:
txData
,
GasLimit
:
0
,
})
if
err
!=
nil
{
return
err
}
if
receipt
.
Status
==
ethtypes
.
ReceiptStatusFailed
{
u
.
log
.
Error
(
"Responder tx successfully published but reverted"
,
"tx_hash"
,
receipt
.
TxHash
)
}
else
{
u
.
log
.
Debug
(
"Responder tx successfully published"
,
"tx_hash"
,
receipt
.
TxHash
)
}
return
nil
}
}
op-challenger/fault/types/types.go
View file @
2b0c5664
...
@@ -3,6 +3,7 @@ package types
...
@@ -3,6 +3,7 @@ package types
import
(
import
(
"context"
"context"
"errors"
"errors"
"math/big"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
)
)
...
@@ -27,6 +28,11 @@ type PreimageOracleData struct {
...
@@ -27,6 +28,11 @@ type PreimageOracleData struct {
OracleData
[]
byte
OracleData
[]
byte
}
}
// GetIdent returns the ident for the preimage oracle data.
func
(
p
*
PreimageOracleData
)
GetIdent
()
*
big
.
Int
{
return
big
.
NewInt
(
int64
(
p
.
OracleData
[
0
]))
}
// NewPreimageOracleData creates a new [PreimageOracleData] instance.
// NewPreimageOracleData creates a new [PreimageOracleData] instance.
func
NewPreimageOracleData
(
key
[]
byte
,
data
[]
byte
)
PreimageOracleData
{
func
NewPreimageOracleData
(
key
[]
byte
,
data
[]
byte
)
PreimageOracleData
{
return
PreimageOracleData
{
return
PreimageOracleData
{
...
...
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