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
ca9dfdab
Unverified
Commit
ca9dfdab
authored
Aug 03, 2023
by
mergify[bot]
Committed by
GitHub
Aug 03, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into refcell/cannon-style-touchups
parents
3111a0fa
c6afad83
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
270 additions
and
141 deletions
+270
-141
__init__.py
bedrock-devnet/devnet/__init__.py
+18
-20
run.go
cannon/cmd/run.go
+7
-5
provider.go
op-challenger/fault/cannon/provider.go
+7
-6
updater.go
op-challenger/fault/cannon/updater.go
+70
-5
updater_test.go
op-challenger/fault/cannon/updater_test.go
+68
-15
alphabet.go
op-challenger/fault/test/alphabet.go
+1
-1
types.go
op-challenger/fault/types/types.go
+25
-7
types_test.go
op-challenger/fault/types/types_test.go
+4
-2
Deploy.s.sol
packages/contracts-bedrock/scripts/Deploy.s.sol
+68
-78
setupProxyContract.ts
packages/core-utils/src/helpers/setupProxyContract.ts
+2
-2
No files found.
bedrock-devnet/devnet/__init__.py
View file @
ca9dfdab
...
@@ -72,30 +72,28 @@ def main():
...
@@ -72,30 +72,28 @@ def main():
def
deploy_contracts
(
paths
):
def
deploy_contracts
(
paths
):
def
internal
():
wait_up
(
8545
)
wait_up
(
8545
)
wait_for_rpc_server
(
'127.0.0.1:8545'
)
wait_for_rpc_server
(
'127.0.0.1:8545'
)
res
=
eth_accounts
(
'127.0.0.1:8545'
)
res
=
eth_accounts
(
'127.0.0.1:8545'
)
response
=
json
.
loads
(
res
)
response
=
json
.
loads
(
res
)
account
=
response
[
'result'
][
0
]
account
=
response
[
'result'
][
0
]
fqn
=
'scripts/Deploy.s.sol:Deploy'
fqn
=
'scripts/Deploy.s.sol:Deploy'
run_command
([
run_command
([
'forge'
,
'script'
,
fqn
,
'--sender'
,
account
,
'forge'
,
'script'
,
fqn
,
'--sender'
,
account
,
'--rpc-url'
,
'http://127.0.0.1:8545'
,
'--broadcast'
,
'--rpc-url'
,
'http://127.0.0.1:8545'
,
'--broadcast'
,
'--unlocked'
'--unlocked'
],
env
=
{},
cwd
=
paths
.
contracts_bedrock_dir
)
],
env
=
{},
cwd
=
paths
.
contracts_bedrock_dir
)
shutil
.
copy
(
paths
.
l1_deployments_path
,
paths
.
addresses_json_path
)
shutil
.
copy
(
paths
.
l1_deployments_path
,
paths
.
addresses_json_path
)
log
.
info
(
'Syncing contracts.'
)
log
.
info
(
'Syncing contracts.'
)
run_command
([
run_command
([
'forge'
,
'script'
,
fqn
,
'--sig'
,
'sync()'
,
'forge'
,
'script'
,
fqn
,
'--sig'
,
'sync()'
,
'--rpc-url'
,
'http://127.0.0.1:8545'
'--rpc-url'
,
'http://127.0.0.1:8545'
],
env
=
{},
cwd
=
paths
.
contracts_bedrock_dir
)
],
env
=
{},
cwd
=
paths
.
contracts_bedrock_dir
)
return
internal
def
devnet_l1_genesis
(
paths
):
def
devnet_l1_genesis
(
paths
):
...
@@ -105,7 +103,7 @@ def devnet_l1_genesis(paths):
...
@@ -105,7 +103,7 @@ def devnet_l1_genesis(paths):
'--verbosity'
,
'4'
,
'--gcmode'
,
'archive'
,
'--dev.gaslimit'
,
'30000000'
'--verbosity'
,
'4'
,
'--gcmode'
,
'archive'
,
'--dev.gaslimit'
,
'30000000'
])
])
forge
=
multiprocessing
.
Process
(
target
=
deploy_contracts
(
paths
))
forge
=
multiprocessing
.
Process
(
target
=
deploy_contracts
,
args
=
(
paths
,
))
forge
.
start
()
forge
.
start
()
forge
.
join
()
forge
.
join
()
...
...
cannon/cmd/run.go
View file @
ca9dfdab
...
@@ -91,8 +91,9 @@ type Proof struct {
...
@@ -91,8 +91,9 @@ type Proof struct {
StateData
hexutil
.
Bytes
`json:"state-data"`
StateData
hexutil
.
Bytes
`json:"state-data"`
ProofData
hexutil
.
Bytes
`json:"proof-data"`
ProofData
hexutil
.
Bytes
`json:"proof-data"`
OracleKey
hexutil
.
Bytes
`json:"oracle-key,omitempty"`
OracleKey
hexutil
.
Bytes
`json:"oracle-key,omitempty"`
OracleValue
hexutil
.
Bytes
`json:"oracle-value,omitempty"`
OracleValue
hexutil
.
Bytes
`json:"oracle-value,omitempty"`
OracleOffset
uint32
`json:"oracle-offset,omitempty"`
StepInput
hexutil
.
Bytes
`json:"step-input"`
StepInput
hexutil
.
Bytes
`json:"step-input"`
OracleInput
hexutil
.
Bytes
`json:"oracle-input"`
OracleInput
hexutil
.
Bytes
`json:"oracle-input"`
...
@@ -304,7 +305,7 @@ func Run(ctx *cli.Context) error {
...
@@ -304,7 +305,7 @@ func Run(ctx *cli.Context) error {
}
}
if
snapshotAt
(
state
)
{
if
snapshotAt
(
state
)
{
if
err
:=
writeJSON
[
*
mipsevm
.
State
]
(
fmt
.
Sprintf
(
snapshotFmt
,
step
),
state
,
false
);
err
!=
nil
{
if
err
:=
writeJSON
(
fmt
.
Sprintf
(
snapshotFmt
,
step
),
state
,
false
);
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to write state snapshot: %w"
,
err
)
return
fmt
.
Errorf
(
"failed to write state snapshot: %w"
,
err
)
}
}
}
}
...
@@ -332,8 +333,9 @@ func Run(ctx *cli.Context) error {
...
@@ -332,8 +333,9 @@ func Run(ctx *cli.Context) error {
proof
.
OracleInput
=
inp
proof
.
OracleInput
=
inp
proof
.
OracleKey
=
witness
.
PreimageKey
[
:
]
proof
.
OracleKey
=
witness
.
PreimageKey
[
:
]
proof
.
OracleValue
=
witness
.
PreimageValue
proof
.
OracleValue
=
witness
.
PreimageValue
proof
.
OracleOffset
=
witness
.
PreimageOffset
}
}
if
err
:=
writeJSON
[
*
Proof
]
(
fmt
.
Sprintf
(
proofFmt
,
step
),
proof
,
true
);
err
!=
nil
{
if
err
:=
writeJSON
(
fmt
.
Sprintf
(
proofFmt
,
step
),
proof
,
true
);
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to write proof data: %w"
,
err
)
return
fmt
.
Errorf
(
"failed to write proof data: %w"
,
err
)
}
}
}
else
{
}
else
{
...
@@ -344,7 +346,7 @@ func Run(ctx *cli.Context) error {
...
@@ -344,7 +346,7 @@ func Run(ctx *cli.Context) error {
}
}
}
}
if
err
:=
writeJSON
[
*
mipsevm
.
State
]
(
ctx
.
Path
(
RunOutputFlag
.
Name
),
state
,
true
);
err
!=
nil
{
if
err
:=
writeJSON
(
ctx
.
Path
(
RunOutputFlag
.
Name
),
state
,
true
);
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to write state output: %w"
,
err
)
return
fmt
.
Errorf
(
"failed to write state output: %w"
,
err
)
}
}
return
nil
return
nil
...
...
op-challenger/fault/cannon/provider.go
View file @
ca9dfdab
...
@@ -21,11 +21,12 @@ const (
...
@@ -21,11 +21,12 @@ const (
)
)
type
proofData
struct
{
type
proofData
struct
{
ClaimValue
hexutil
.
Bytes
`json:"post"`
ClaimValue
hexutil
.
Bytes
`json:"post"`
StateData
hexutil
.
Bytes
`json:"state-data"`
StateData
hexutil
.
Bytes
`json:"state-data"`
ProofData
hexutil
.
Bytes
`json:"proof-data"`
ProofData
hexutil
.
Bytes
`json:"proof-data"`
OracleKey
hexutil
.
Bytes
`json:"oracle-key,omitempty"`
OracleKey
hexutil
.
Bytes
`json:"oracle-key,omitempty"`
OracleValue
hexutil
.
Bytes
`json:"oracle-value,omitempty"`
OracleValue
hexutil
.
Bytes
`json:"oracle-value,omitempty"`
OracleOffset
uint32
`json:"oracle-offset,omitempty"`
}
}
type
ProofGenerator
interface
{
type
ProofGenerator
interface
{
...
@@ -52,7 +53,7 @@ func (p *CannonTraceProvider) GetOracleData(ctx context.Context, i uint64) (*typ
...
@@ -52,7 +53,7 @@ func (p *CannonTraceProvider) GetOracleData(ctx context.Context, i uint64) (*typ
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
data
:=
types
.
NewPreimageOracleData
(
proof
.
OracleKey
,
proof
.
OracleValue
)
data
:=
types
.
NewPreimageOracleData
(
proof
.
OracleKey
,
proof
.
OracleValue
,
proof
.
OracleOffset
)
return
&
data
,
nil
return
&
data
,
nil
}
}
...
...
op-challenger/fault/cannon/updater.go
View file @
ca9dfdab
...
@@ -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
.
GetIdent
(),
big
.
NewInt
(
int64
(
data
.
OracleOffset
)),
)
}
// 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
(
int64
(
data
.
OracleOffset
)),
data
.
GetPreimageWithoutSize
(),
)
}
// 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/cannon/updater_test.go
View file @
ca9dfdab
...
@@ -6,6 +6,7 @@ import (
...
@@ -6,6 +6,7 @@ import (
"math/big"
"math/big"
"testing"
"testing"
"github.com/ethereum-optimism/optimism/op-challenger/fault/types"
"github.com/ethereum-optimism/optimism/op-node/testlog"
"github.com/ethereum-optimism/optimism/op-node/testlog"
"github.com/ethereum-optimism/optimism/op-service/txmgr"
"github.com/ethereum-optimism/optimism/op-service/txmgr"
...
@@ -13,6 +14,7 @@ import (
...
@@ -13,6 +14,7 @@ import (
ethtypes
"github.com/ethereum/go-ethereum/core/types"
ethtypes
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/log"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/require"
...
@@ -25,14 +27,15 @@ var (
...
@@ -25,14 +27,15 @@ var (
)
)
type
mockTxManager
struct
{
type
mockTxManager
struct
{
from
common
.
Address
from
common
.
Address
sends
int
sends
int
calls
int
failedSends
int
sendFails
bool
sendFails
bool
}
}
func
(
m
*
mockTxManager
)
Send
(
ctx
context
.
Context
,
candidate
txmgr
.
TxCandidate
)
(
*
ethtypes
.
Receipt
,
error
)
{
func
(
m
*
mockTxManager
)
Send
(
ctx
context
.
Context
,
candidate
txmgr
.
TxCandidate
)
(
*
ethtypes
.
Receipt
,
error
)
{
if
m
.
sendFails
{
if
m
.
sendFails
{
m
.
failedSends
++
return
nil
,
mockSendError
return
nil
,
mockSendError
}
}
m
.
sends
++
m
.
sends
++
...
@@ -44,11 +47,7 @@ func (m *mockTxManager) Send(ctx context.Context, candidate txmgr.TxCandidate) (
...
@@ -44,11 +47,7 @@ func (m *mockTxManager) Send(ctx context.Context, candidate txmgr.TxCandidate) (
}
}
func
(
m
*
mockTxManager
)
Call
(
_
context
.
Context
,
_
ethereum
.
CallMsg
,
_
*
big
.
Int
)
([]
byte
,
error
)
{
func
(
m
*
mockTxManager
)
Call
(
_
context
.
Context
,
_
ethereum
.
CallMsg
,
_
*
big
.
Int
)
([]
byte
,
error
)
{
if
m
.
sendFails
{
panic
(
"not implemented"
)
return
nil
,
mockSendError
}
m
.
calls
++
return
[]
byte
{},
nil
}
}
func
(
m
*
mockTxManager
)
BlockNumber
(
ctx
context
.
Context
)
(
uint64
,
error
)
{
func
(
m
*
mockTxManager
)
BlockNumber
(
ctx
context
.
Context
)
(
uint64
,
error
)
{
...
@@ -74,14 +73,68 @@ func newTestCannonUpdater(t *testing.T, sendFails bool) (*cannonUpdater, *mockTx
...
@@ -74,14 +73,68 @@ func newTestCannonUpdater(t *testing.T, sendFails bool) (*cannonUpdater, *mockTx
// UpdateOracle function.
// UpdateOracle function.
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
)
{
_
,
_
=
newTestCannonUpdater
(
t
,
false
)
updater
,
mockTxMgr
:=
newTestCannonUpdater
(
t
,
false
)
// require.Nil(t, updater.UpdateOracle(context.Background(), types.PreimageOracleData{}))
require
.
Nil
(
t
,
updater
.
UpdateOracle
(
context
.
Background
(),
types
.
PreimageOracleData
{
// require.Equal(t, 1, mockTxMgr.calls)
OracleData
:
common
.
Hex2Bytes
(
"cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc"
),
}))
require
.
Equal
(
t
,
1
,
mockTxMgr
.
sends
)
})
})
t
.
Run
(
"send fails"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"send fails"
,
func
(
t
*
testing
.
T
)
{
_
,
_
=
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
{
// require.Equal(t, 1, mockTxMgr.calls)
OracleData
:
common
.
Hex2Bytes
(
"cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc"
),
}))
require
.
Equal
(
t
,
1
,
mockTxMgr
.
failedSends
)
})
})
}
}
// TestCannonUpdater_BuildLocalOracleData tests the [cannonUpdater]
// builds a valid tx candidate for a local oracle update.
func
TestCannonUpdater_BuildLocalOracleData
(
t
*
testing
.
T
)
{
updater
,
_
:=
newTestCannonUpdater
(
t
,
false
)
oracleData
:=
types
.
PreimageOracleData
{
OracleKey
:
common
.
Hex2Bytes
(
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
),
OracleData
:
common
.
Hex2Bytes
(
"cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc"
),
OracleOffset
:
7
,
}
txData
,
err
:=
updater
.
BuildLocalOracleData
(
oracleData
)
require
.
NoError
(
t
,
err
)
var
addLocalDataBytes4
=
crypto
.
Keccak256
([]
byte
(
"addLocalData(uint256,uint256)"
))[
:
4
]
// Pack the tx data manually.
var
expected
[]
byte
expected
=
append
(
expected
,
addLocalDataBytes4
...
)
expected
=
append
(
expected
,
common
.
Hex2Bytes
(
"00aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
)
...
)
expected
=
append
(
expected
,
common
.
Hex2Bytes
(
"0000000000000000000000000000000000000000000000000000000000000007"
)
...
)
require
.
Equal
(
t
,
expected
,
txData
)
}
// TestCannonUpdater_BuildGlobalOracleData tests the [cannonUpdater]
// builds a valid tx candidate for a global oracle update.
func
TestCannonUpdater_BuildGlobalOracleData
(
t
*
testing
.
T
)
{
updater
,
_
:=
newTestCannonUpdater
(
t
,
false
)
oracleData
:=
types
.
PreimageOracleData
{
OracleKey
:
common
.
Hex2Bytes
(
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
),
OracleData
:
common
.
Hex2Bytes
(
"cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc"
),
OracleOffset
:
7
,
}
txData
,
err
:=
updater
.
BuildGlobalOracleData
(
oracleData
)
require
.
NoError
(
t
,
err
)
var
loadKeccak256PreimagePartBytes4
=
crypto
.
Keccak256
([]
byte
(
"loadKeccak256PreimagePart(uint256,bytes)"
))[
:
4
]
// Pack the tx data manually.
var
expected
[]
byte
expected
=
append
(
expected
,
loadKeccak256PreimagePartBytes4
...
)
expected
=
append
(
expected
,
common
.
Hex2Bytes
(
"0000000000000000000000000000000000000000000000000000000000000007"
)
...
)
expected
=
append
(
expected
,
common
.
Hex2Bytes
(
"0000000000000000000000000000000000000000000000000000000000000040"
)
...
)
expected
=
append
(
expected
,
common
.
Hex2Bytes
(
"0000000000000000000000000000000000000000000000000000000000000018"
)
...
)
expected
=
append
(
expected
,
common
.
Hex2Bytes
(
"cccccccccccccccccccccccccccccccccccccccccccccccc0000000000000000"
)
...
)
require
.
Equal
(
t
,
expected
,
txData
)
}
op-challenger/fault/test/alphabet.go
View file @
ca9dfdab
...
@@ -37,6 +37,6 @@ func (a *alphabetWithProofProvider) GetOracleData(ctx context.Context, i uint64)
...
@@ -37,6 +37,6 @@ func (a *alphabetWithProofProvider) GetOracleData(ctx context.Context, i uint64)
if
a
.
OracleError
!=
nil
{
if
a
.
OracleError
!=
nil
{
return
&
types
.
PreimageOracleData
{},
a
.
OracleError
return
&
types
.
PreimageOracleData
{},
a
.
OracleError
}
}
data
:=
types
.
NewPreimageOracleData
([]
byte
{
byte
(
i
)},
[]
byte
{
byte
(
i
)})
data
:=
types
.
NewPreimageOracleData
([]
byte
{
byte
(
i
)},
[]
byte
{
byte
(
i
)}
,
uint32
(
i
)
)
return
&
data
,
nil
return
&
data
,
nil
}
}
op-challenger/fault/types/types.go
View file @
ca9dfdab
...
@@ -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"
)
)
...
@@ -22,17 +23,34 @@ const (
...
@@ -22,17 +23,34 @@ const (
// PreimageOracleData encapsulates the preimage oracle data
// PreimageOracleData encapsulates the preimage oracle data
// to load into the onchain oracle.
// to load into the onchain oracle.
type
PreimageOracleData
struct
{
type
PreimageOracleData
struct
{
IsLocal
bool
IsLocal
bool
OracleKey
[]
byte
OracleKey
[]
byte
OracleData
[]
byte
OracleData
[]
byte
OracleOffset
uint32
}
// GetType returns the type for the preimage oracle data.
func
(
p
*
PreimageOracleData
)
GetType
()
*
big
.
Int
{
return
big
.
NewInt
(
int64
(
p
.
OracleKey
[
0
]))
}
// GetIdent returns the ident for the preimage oracle data.
func
(
p
*
PreimageOracleData
)
GetIdent
()
*
big
.
Int
{
return
big
.
NewInt
(
0
)
.
SetBytes
(
p
.
OracleKey
[
1
:
])
}
// GetPreimageWithoutSize returns the preimage for the preimage oracle data.
func
(
p
*
PreimageOracleData
)
GetPreimageWithoutSize
()
[]
byte
{
return
p
.
OracleData
[
8
:
]
}
}
// 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
,
offset
uint32
)
PreimageOracleData
{
return
PreimageOracleData
{
return
PreimageOracleData
{
IsLocal
:
len
(
key
)
>
0
&&
key
[
0
]
==
byte
(
1
),
IsLocal
:
len
(
key
)
>
0
&&
key
[
0
]
==
byte
(
1
),
OracleKey
:
key
,
OracleKey
:
key
,
OracleData
:
data
,
OracleData
:
data
,
OracleOffset
:
offset
,
}
}
}
}
...
...
op-challenger/fault/types/types_test.go
View file @
ca9dfdab
...
@@ -8,16 +8,18 @@ import (
...
@@ -8,16 +8,18 @@ import (
func
TestNewPreimageOracleData
(
t
*
testing
.
T
)
{
func
TestNewPreimageOracleData
(
t
*
testing
.
T
)
{
t
.
Run
(
"LocalData"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"LocalData"
,
func
(
t
*
testing
.
T
)
{
data
:=
NewPreimageOracleData
([]
byte
{
1
,
2
,
3
},
[]
byte
{
4
,
5
,
6
})
data
:=
NewPreimageOracleData
([]
byte
{
1
,
2
,
3
},
[]
byte
{
4
,
5
,
6
}
,
7
)
require
.
True
(
t
,
data
.
IsLocal
)
require
.
True
(
t
,
data
.
IsLocal
)
require
.
Equal
(
t
,
[]
byte
{
1
,
2
,
3
},
data
.
OracleKey
)
require
.
Equal
(
t
,
[]
byte
{
1
,
2
,
3
},
data
.
OracleKey
)
require
.
Equal
(
t
,
[]
byte
{
4
,
5
,
6
},
data
.
OracleData
)
require
.
Equal
(
t
,
[]
byte
{
4
,
5
,
6
},
data
.
OracleData
)
require
.
Equal
(
t
,
uint32
(
7
),
data
.
OracleOffset
)
})
})
t
.
Run
(
"GlobalData"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"GlobalData"
,
func
(
t
*
testing
.
T
)
{
data
:=
NewPreimageOracleData
([]
byte
{
0
,
2
,
3
},
[]
byte
{
4
,
5
,
6
})
data
:=
NewPreimageOracleData
([]
byte
{
0
,
2
,
3
},
[]
byte
{
4
,
5
,
6
}
,
7
)
require
.
False
(
t
,
data
.
IsLocal
)
require
.
False
(
t
,
data
.
IsLocal
)
require
.
Equal
(
t
,
[]
byte
{
0
,
2
,
3
},
data
.
OracleKey
)
require
.
Equal
(
t
,
[]
byte
{
0
,
2
,
3
},
data
.
OracleKey
)
require
.
Equal
(
t
,
[]
byte
{
4
,
5
,
6
},
data
.
OracleData
)
require
.
Equal
(
t
,
[]
byte
{
4
,
5
,
6
},
data
.
OracleData
)
require
.
Equal
(
t
,
uint32
(
7
),
data
.
OracleOffset
)
})
})
}
}
packages/contracts-bedrock/scripts/Deploy.s.sol
View file @
ca9dfdab
...
@@ -109,6 +109,14 @@ contract Deploy is Deployer {
...
@@ -109,6 +109,14 @@ contract Deploy is Deployer {
vm.stopBroadcast();
vm.stopBroadcast();
}
}
/// @notice Modifier that will only allow a function to be called on devnet.
modifier onlyDevnet() {
uint256 chainid = block.chainid;
if (chainid == Chains.LocalDevnet || chainid == Chains.GethDevnet) {
_;
}
}
/// @notice Deploy the AddressManager
/// @notice Deploy the AddressManager
function deployAddressManager() broadcast() public returns (address) {
function deployAddressManager() broadcast() public returns (address) {
AddressManager manager = new AddressManager();
AddressManager manager = new AddressManager();
...
@@ -250,22 +258,19 @@ contract Deploy is Deployer {
...
@@ -250,22 +258,19 @@ contract Deploy is Deployer {
}
}
/// @notice Deploy the DisputeGameFactoryProxy
/// @notice Deploy the DisputeGameFactoryProxy
function deployDisputeGameFactoryProxy() broadcast() public returns (address) {
function deployDisputeGameFactoryProxy() onlyDevnet broadcast() public returns (address) {
if (block.chainid == Chains.LocalDevnet || block.chainid == Chains.GethDevnet) {
address proxyAdmin = mustGetAddress("ProxyAdmin");
address proxyAdmin = mustGetAddress("ProxyAdmin");
Proxy proxy = new Proxy({
Proxy proxy = new Proxy({
_admin: proxyAdmin
_admin: proxyAdmin
});
});
address admin = address(uint160(uint256(vm.load(address(proxy), OWNER_KEY))));
address admin = address(uint160(uint256(vm.load(address(proxy), OWNER_KEY))));
require(admin == proxyAdmin);
require(admin == proxyAdmin);
save("DisputeGameFactoryProxy", address(proxy));
save("DisputeGameFactoryProxy", address(proxy));
console.log("DisputeGameFactoryProxy deployed at %s", address(proxy));
console.log("DisputeGameFactoryProxy deployed at %s", address(proxy));
return address(proxy);
return address(proxy);
}
return address(0);
}
}
/// @notice Deploy the L1CrossDomainMessenger
/// @notice Deploy the L1CrossDomainMessenger
...
@@ -351,39 +356,30 @@ contract Deploy is Deployer {
...
@@ -351,39 +356,30 @@ contract Deploy is Deployer {
}
}
/// @notice Deploy the DisputeGameFactory
/// @notice Deploy the DisputeGameFactory
function deployDisputeGameFactory() broadcast() public returns (address) {
function deployDisputeGameFactory() onlyDevnet broadcast() public returns (address) {
if (block.chainid == Chains.LocalDevnet || block.chainid == Chains.GethDevnet) {
DisputeGameFactory factory = new DisputeGameFactory();
DisputeGameFactory factory = new DisputeGameFactory();
save("DisputeGameFactory", address(factory));
save("DisputeGameFactory", address(factory));
console.log("DisputeGameFactory deployed at %s", address(factory));
console.log("DisputeGameFactory deployed at %s", address(factory));
return address(factory);
return address(factory);
}
return address(0);
}
}
/// @notice Deploy the PreimageOracle
/// @notice Deploy the PreimageOracle
function deployPreimageOracle() broadcast() public returns (address) {
function deployPreimageOracle() onlyDevnet broadcast() public returns (address) {
if (block.chainid == 900) {
PreimageOracle preimageOracle = new PreimageOracle();
PreimageOracle preimageOracle = new PreimageOracle();
save("PreimageOracle", address(preimageOracle));
save("PreimageOracle", address(preimageOracle));
console.log("PreimageOracle deployed at %s", address(preimageOracle));
console.log("PreimageOracle deployed at %s", address(preimageOracle));
return address(preimageOracle);
return address(preimageOracle);
}
return address(0);
}
}
/// @notice Deploy Mips
/// @notice Deploy Mips
function deployMips() broadcast() public returns (address) {
function deployMips() onlyDevnet broadcast() public returns (address) {
if (block.chainid == 900) {
MIPS mips = new MIPS();
MIPS mips = new MIPS();
save("Mips", address(mips));
save("Mips", address(mips));
console.log("MIPS deployed at %s", address(mips));
console.log("Mips deployed at %s", address(mips));
return address(mips);
return address(mips);
}
return address(0);
}
}
/// @notice Deploy the SystemConfig
/// @notice Deploy the SystemConfig
...
@@ -470,24 +466,22 @@ contract Deploy is Deployer {
...
@@ -470,24 +466,22 @@ contract Deploy is Deployer {
}
}
/// @notice Initialize the DisputeGameFactory
/// @notice Initialize the DisputeGameFactory
function initializeDisputeGameFactory() broadcast() public {
function initializeDisputeGameFactory() onlyDevnet broadcast() public {
if (block.chainid == Chains.LocalDevnet || block.chainid == Chains.GethDevnet) {
ProxyAdmin proxyAdmin = ProxyAdmin(mustGetAddress("ProxyAdmin"));
ProxyAdmin proxyAdmin = ProxyAdmin(mustGetAddress("ProxyAdmin"));
address disputeGameFactoryProxy = mustGetAddress("DisputeGameFactoryProxy");
address disputeGameFactoryProxy = mustGetAddress("DisputeGameFactoryProxy");
address disputeGameFactory = mustGetAddress("DisputeGameFactory");
address disputeGameFactory = mustGetAddress("DisputeGameFactory");
proxyAdmin.upgradeAndCall({
_proxy: payable(disputeGameFactoryProxy),
_implementation: disputeGameFactory,
_data: abi.encodeCall(
DisputeGameFactory.initialize,
(msg.sender)
)
});
string memory version = DisputeGameFactory(disputeGameFactoryProxy).version();
proxyAdmin.upgradeAndCall({
console.log("DisputeGameFactory version: %s", version);
_proxy: payable(disputeGameFactoryProxy),
}
_implementation: disputeGameFactory,
_data: abi.encodeCall(
DisputeGameFactory.initialize,
(msg.sender)
)
});
string memory version = DisputeGameFactory(disputeGameFactoryProxy).version();
console.log("DisputeGameFactory version: %s", version);
}
}
/// @notice Initialize the SystemConfig
/// @notice Initialize the SystemConfig
...
@@ -704,34 +698,30 @@ contract Deploy is Deployer {
...
@@ -704,34 +698,30 @@ contract Deploy is Deployer {
}
}
/// @notice Transfer ownership of the DisputeGameFactory contract to the final system owner
/// @notice Transfer ownership of the DisputeGameFactory contract to the final system owner
function transferDisputeGameFactoryOwnership() broadcast() public {
function transferDisputeGameFactoryOwnership() onlyDevnet broadcast() public {
if (block.chainid == Chains.LocalDevnet || block.chainid == Chains.GethDevnet) {
DisputeGameFactory disputeGameFactory = DisputeGameFactory(mustGetAddress("DisputeGameFactoryProxy"));
DisputeGameFactory disputeGameFactory = DisputeGameFactory(mustGetAddress("DisputeGameFactoryProxy"));
address owner = disputeGameFactory.owner();
address owner = disputeGameFactory.owner();
address finalSystemOwner = cfg.finalSystemOwner();
address finalSystemOwner = cfg.finalSystemOwner();
if (owner != finalSystemOwner) {
if (owner != finalSystemOwner) {
disputeGameFactory.transferOwnership(finalSystemOwner);
disputeGameFactory.transferOwnership(finalSystemOwner);
console.log("DisputeGameFactory ownership transferred to: %s", finalSystemOwner);
console.log("DisputeGameFactory ownership transferred to: %s", finalSystemOwner);
}
}
}
}
}
/// @notice Sets the implementation for the `FAULT` game type in the `DisputeGameFactory`
/// @notice Sets the implementation for the `FAULT` game type in the `DisputeGameFactory`
function setFaultGameImplementation() broadcast() public {
function setFaultGameImplementation() onlyDevnet broadcast() public {
if (block.chainid == Chains.LocalDevnet || block.chainid == Chains.GethDevnet) {
DisputeGameFactory factory = DisputeGameFactory(mustGetAddress("DisputeGameFactoryProxy"));
DisputeGameFactory factory = DisputeGameFactory(mustGetAddress("DisputeGameFactoryProxy"));
Claim absolutePrestate = Claim.wrap(bytes32(cfg.faultGameAbsolutePrestate()));
Claim absolutePrestate = Claim.wrap(bytes32(cfg.faultGameAbsolutePrestate()));
IBigStepper faultVm = IBigStepper(new AlphabetVM(absolutePrestate));
IBigStepper faultVm = IBigStepper(new AlphabetVM(absolutePrestate));
if (address(factory.gameImpls(GameTypes.FAULT)) == address(0)) {
if (address(factory.gameImpls(GameTypes.FAULT)) == address(0)) {
factory.setImplementation(GameTypes.FAULT, new FaultDisputeGame({
factory.setImplementation(GameTypes.FAULT, new FaultDisputeGame({
_absolutePrestate: absolutePrestate,
_absolutePrestate: absolutePrestate,
_maxGameDepth: cfg.faultGameMaxDepth(),
_maxGameDepth: cfg.faultGameMaxDepth(),
_gameDuration: Duration.wrap(uint64(cfg.faultGameMaxDuration())),
_gameDuration: Duration.wrap(uint64(cfg.faultGameMaxDuration())),
_vm: faultVm,
_vm: faultVm,
_l2oo: L2OutputOracle(mustGetAddress("L2OutputOracleProxy"))
_l2oo: L2OutputOracle(mustGetAddress("L2OutputOracleProxy"))
}));
}));
console.log("DisputeGameFactory: set `FaultDisputeGame` implementation");
console.log("DisputeGameFactory: set `FaultDisputeGame` implementation");
}
}
}
}
}
}
}
...
...
packages/core-utils/src/helpers/setupProxyContract.ts
View file @
ca9dfdab
...
@@ -49,7 +49,7 @@ const setupProxyContract = async (
...
@@ -49,7 +49,7 @@ const setupProxyContract = async (
console
.
log
(
`Setting implementation to
${
targetImplAddress
}
`
)
console
.
log
(
`Setting implementation to
${
targetImplAddress
}
`
)
// The signer needs to be the current admin, otherwise we don't have permission
// The signer needs to be the current admin, otherwise we don't have permission
// to update the implmentation or admin
// to update the impl
e
mentation or admin
assert
(
assert
(
signerAddress
===
currentAdmin
,
signerAddress
===
currentAdmin
,
'
the passed signer is not the admin, cannot update implementation
'
'
the passed signer is not the admin, cannot update implementation
'
...
@@ -89,7 +89,7 @@ const setupProxyContract = async (
...
@@ -89,7 +89,7 @@ const setupProxyContract = async (
console
.
log
(
`Setting admin to
${
targetProxyOwnerAddress
}
`
)
console
.
log
(
`Setting admin to
${
targetProxyOwnerAddress
}
`
)
// The signer needs to be the current admin, otherwise we don't have permission
// The signer needs to be the current admin, otherwise we don't have permission
// to update the implmentation or admin
// to update the impl
e
mentation or admin
assert
(
assert
(
signerAddress
===
currentAdmin
,
signerAddress
===
currentAdmin
,
'
proxyOwnerSigner is not the admin, cannot update admin
'
'
proxyOwnerSigner is not the admin, cannot update admin
'
...
...
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