Commit 0fe6c13a authored by Mark Tyneway's avatar Mark Tyneway

op-chain-ops: setup new predeploys

parent 73caf914
......@@ -3,6 +3,7 @@ package genesis
import (
"encoding/json"
"errors"
"math/big"
"os"
"path/filepath"
......@@ -103,7 +104,7 @@ func NewDeployConfigWithNetwork(network, path string) (*DeployConfig, error) {
// NewL2ImmutableConfig will create an ImmutableConfig given an instance of a
// Hardhat and a DeployConfig.
func NewL2ImmutableConfig(config *DeployConfig, block *types.Block, proxyL1StandardBridge common.Address, proxyL1CrossDomainMessenger common.Address) (immutables.ImmutableConfig, error) {
func NewL2ImmutableConfig(config *DeployConfig, block *types.Block, proxyL1StandardBridge, proxyL1CrossDomainMessenger, proxyL1ERC721Bridge common.Address) (immutables.ImmutableConfig, error) {
immutable := make(immutables.ImmutableConfig)
immutable["L2StandardBridge"] = immutables.ImmutableValues{
......@@ -112,6 +113,14 @@ func NewL2ImmutableConfig(config *DeployConfig, block *types.Block, proxyL1Stand
immutable["L2CrossDomainMessenger"] = immutables.ImmutableValues{
"otherMessenger": proxyL1CrossDomainMessenger,
}
immutable["L2ERC721Bridge"] = immutables.ImmutableValues{
"messenger": predeploys.L2CrossDomainMessengerAddr,
"otherBridge": proxyL1ERC721Bridge,
}
immutable["OptimismMintableERC721Factory"] = immutables.ImmutableValues{
"bridge": predeploys.L2ERC721BridgeAddr,
"remoteChainId": new(big.Int).SetUint64(config.L1ChainID),
}
return immutable, nil
}
......
......@@ -249,6 +249,9 @@ func deployL1Contracts(config *DeployConfig, backend *backends.SimulatedBackend)
{
Name: "L1StandardBridge",
},
{
Name: "L1ERC721Bridge",
},
{
Name: "OptimismMintableERC20Factory",
},
......@@ -327,6 +330,13 @@ func l1Deployer(backend *backends.SimulatedBackend, opts *bind.TransactOpts, dep
opts,
backend,
)
case "L1ERC721Bridge":
_, tx, _, err = bindings.DeployL1ERC721Bridge(
opts,
backend,
predeploys.DevL1CrossDomainMessengerAddr,
predeploys.L2ERC721BridgeAddr,
)
default:
if strings.HasSuffix(deployment.Name, "Proxy") {
_, tx, _, err = bindings.DeployProxy(opts, backend, deployer.TestAddress)
......
......@@ -13,6 +13,7 @@ type L2Addresses struct {
ProxyAdmin common.Address
L1StandardBridgeProxy common.Address
L1CrossDomainMessengerProxy common.Address
L1ERC721BridgeProxy common.Address
}
// BuildL2DeveloperGenesis will build the developer Optimism Genesis
......@@ -66,6 +67,7 @@ func BuildL2Genesis(db *state.MemoryStateDB, config *DeployConfig, l1Block *type
l1Block,
l2Addrs.L1StandardBridgeProxy,
l2Addrs.L1CrossDomainMessengerProxy,
l2Addrs.L1ERC721BridgeProxy,
)
if err != nil {
return nil, err
......
......@@ -77,7 +77,7 @@ func TestBuildL2DeveloperGenesis(t *testing.T) {
require.Equal(t, adminSlot, proxyAdmin.Address.Hash())
require.Equal(t, account.Code, depB)
}
require.Equal(t, 2339, len(gen.Alloc))
require.Equal(t, 2341, len(gen.Alloc))
if writeFile {
file, _ := json.MarshalIndent(gen, "", " ")
......@@ -102,5 +102,5 @@ func TestBuildL2DeveloperGenesisDevAccountsFunding(t *testing.T) {
ProxyAdmin: common.Address{},
})
require.NoError(t, err)
require.Equal(t, 2317, len(gen.Alloc))
require.Equal(t, 2319, len(gen.Alloc))
}
......@@ -2,6 +2,7 @@ package immutables
import (
"fmt"
"math/big"
"github.com/ethereum/go-ethereum/core/types"
......@@ -67,6 +68,20 @@ func BuildOptimism(immutable ImmutableConfig) (DeploymentResults, error) {
{
Name: "L1BlockNumber",
},
{
Name: "L2ERC721Bridge",
Args: []interface{}{
predeploys.L2CrossDomainMessengerAddr,
immutable["L2ERC721Bridge"]["otherBridge"],
},
},
{
Name: "OptimismMintableERC721Factory",
Args: []interface{}{
predeploys.L2ERC721BridgeAddr,
immutable["OptimismMintableERC721Factory"]["remoteChainId"],
},
},
}
return BuildL2(deployments)
}
......@@ -124,6 +139,27 @@ func l2Deployer(backend *backends.SimulatedBackend, opts *bind.TransactOpts, dep
_, tx, _, err = bindings.DeployLegacyMessagePasser(opts, backend)
case "L1BlockNumber":
_, tx, _, err = bindings.DeployL1BlockNumber(opts, backend)
case "L2ERC721Bridge":
// TODO(tynes): messenger should be hardcoded in the contract
messenger, ok := deployment.Args[0].(common.Address)
if !ok {
return nil, fmt.Errorf("invalid type for messenger")
}
otherBridge, ok := deployment.Args[1].(common.Address)
if !ok {
return nil, fmt.Errorf("invalid type for otherBridge")
}
_, tx, _, err = bindings.DeployL2ERC721Bridge(opts, backend, messenger, otherBridge)
case "OptimismMintableERC721Factory":
bridge, ok := deployment.Args[0].(common.Address)
if !ok {
return nil, fmt.Errorf("invalid type for bridge")
}
remoteChainId, ok := deployment.Args[1].(*big.Int)
if !ok {
return nil, fmt.Errorf("invalid type for remoteChainId")
}
_, tx, _, err = bindings.DeployOptimismMintableERC721Factory(opts, backend, bridge, remoteChainId)
default:
return tx, fmt.Errorf("unknown contract: %s", deployment.Name)
}
......
package immutables_test
import (
"math/big"
"testing"
"github.com/ethereum-optimism/optimism/op-chain-ops/immutables"
......@@ -16,21 +17,29 @@ func TestBuildOptimism(t *testing.T) {
"L2CrossDomainMessenger": {
"otherMessenger": common.HexToAddress("0x1234567890123456789012345678901234567890"),
},
"L2ERC721Bridge": {
"otherBridge": common.HexToAddress("0x1234567890123456789012345678901234567890"),
},
"OptimismMintableERC721Factory": {
"remoteChainId": big.NewInt(1),
},
})
require.Nil(t, err)
require.NotNil(t, results)
contracts := map[string]bool{
"GasPriceOracle": true,
"L1Block": true,
"L2CrossDomainMessenger": true,
"L2StandardBridge": true,
"L2ToL1MessagePasser": true,
"SequencerFeeVault": true,
"OptimismMintableERC20Factory": true,
"DeployerWhitelist": true,
"LegacyMessagePasser": true,
"L1BlockNumber": true,
"GasPriceOracle": true,
"L1Block": true,
"L2CrossDomainMessenger": true,
"L2StandardBridge": true,
"L2ToL1MessagePasser": true,
"SequencerFeeVault": true,
"OptimismMintableERC20Factory": true,
"DeployerWhitelist": true,
"LegacyMessagePasser": true,
"L1BlockNumber": true,
"L2ERC721Bridge": true,
"OptimismMintableERC721Factory": true,
}
// Only the exact contracts that we care about are being
......
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