Commit ca9dfdab authored by mergify[bot]'s avatar mergify[bot] Committed by GitHub

Merge branch 'develop' into refcell/cannon-style-touchups

parents 3111a0fa c6afad83
...@@ -72,7 +72,6 @@ def main(): ...@@ -72,7 +72,6 @@ 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')
...@@ -95,7 +94,6 @@ def deploy_contracts(paths): ...@@ -95,7 +94,6 @@ def deploy_contracts(paths):
'--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()
......
...@@ -93,6 +93,7 @@ type Proof struct { ...@@ -93,6 +93,7 @@ type Proof struct {
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
......
...@@ -26,6 +26,7 @@ type proofData struct { ...@@ -26,6 +26,7 @@ type proofData struct {
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
} }
......
...@@ -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,13 +11,14 @@ import ( ...@@ -9,13 +11,14 @@ 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 {
logger log.Logger log log.Logger
txMgr txmgr.TxManager txMgr txmgr.TxManager
fdgAbi abi.ABI fdgAbi abi.ABI
...@@ -42,7 +45,7 @@ func NewOracleUpdater( ...@@ -42,7 +45,7 @@ func NewOracleUpdater(
} }
return &cannonUpdater{ return &cannonUpdater{
logger: logger, log: logger,
txMgr: txMgr, txMgr: txMgr,
fdgAbi: *fdgAbi, fdgAbi: *fdgAbi,
...@@ -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
} }
...@@ -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"
...@@ -27,12 +29,13 @@ var ( ...@@ -27,12 +29,13 @@ 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)
}
...@@ -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
} }
...@@ -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"
) )
...@@ -25,14 +26,31 @@ type PreimageOracleData struct { ...@@ -25,14 +26,31 @@ 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,
} }
} }
......
...@@ -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)
}) })
} }
...@@ -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,8 +258,7 @@ contract Deploy is Deployer { ...@@ -250,8 +258,7 @@ 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
...@@ -265,8 +272,6 @@ contract Deploy is Deployer { ...@@ -265,8 +272,6 @@ contract Deploy is Deployer {
return address(proxy); return address(proxy);
} }
return address(0);
}
/// @notice Deploy the L1CrossDomainMessenger /// @notice Deploy the L1CrossDomainMessenger
function deployL1CrossDomainMessenger() broadcast() public returns (address) { function deployL1CrossDomainMessenger() broadcast() public returns (address) {
...@@ -351,40 +356,31 @@ contract Deploy is Deployer { ...@@ -351,40 +356,31 @@ 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
function deploySystemConfig() broadcast() public returns (address) { function deploySystemConfig() broadcast() public returns (address) {
...@@ -470,8 +466,7 @@ contract Deploy is Deployer { ...@@ -470,8 +466,7 @@ 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");
...@@ -488,7 +483,6 @@ contract Deploy is Deployer { ...@@ -488,7 +483,6 @@ contract Deploy is Deployer {
string memory version = DisputeGameFactory(disputeGameFactoryProxy).version(); string memory version = DisputeGameFactory(disputeGameFactoryProxy).version();
console.log("DisputeGameFactory version: %s", version); console.log("DisputeGameFactory version: %s", version);
} }
}
/// @notice Initialize the SystemConfig /// @notice Initialize the SystemConfig
function initializeSystemConfig() broadcast() public { function initializeSystemConfig() broadcast() public {
...@@ -704,8 +698,7 @@ contract Deploy is Deployer { ...@@ -704,8 +698,7 @@ 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();
...@@ -714,11 +707,9 @@ contract Deploy is Deployer { ...@@ -714,11 +707,9 @@ contract Deploy is Deployer {
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));
...@@ -733,6 +724,5 @@ contract Deploy is Deployer { ...@@ -733,6 +724,5 @@ contract Deploy is Deployer {
console.log("DisputeGameFactory: set `FaultDisputeGame` implementation"); console.log("DisputeGameFactory: set `FaultDisputeGame` implementation");
} }
} }
}
} }
...@@ -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 implementation 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 implementation or admin
assert( assert(
signerAddress === currentAdmin, signerAddress === currentAdmin,
'proxyOwnerSigner is not the admin, cannot update admin' 'proxyOwnerSigner is not the admin, cannot update admin'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment