Skip to content

Commit

Permalink
opcm-redesign: opcm targets a single release (#12851)
Browse files Browse the repository at this point in the history
* fix: semver locking.

* fix: semver locking.

* feat: opcm impl contracts now type safe.

* feat: fixing test.

* fix: removing unused imports.

* fix: address didn't need to be payable.

* fix: moving all smart contract changes to first pr.

* fix: pr comments addressed.

* fix: removed InputContracts struct.

* fix: ran pre-pr

* fix: deploy implementations renaming version.

* fix: adding solidity changes to this pr.

* fix: adding v160 initializer back in.

* fix: removed branching logic from opcm.

* fix: removed SystemConfigV160.

* opcm-redesign: op-deployer changes

* fix: linting fix.

* fix: semver lock

---------

Co-authored-by: Matthew Slipper <[email protected]>
  • Loading branch information
blmalone and mslipper authored Nov 15, 2024
1 parent c267d98 commit 8f0a9b2
Show file tree
Hide file tree
Showing 32 changed files with 666 additions and 1,185 deletions.
2 changes: 1 addition & 1 deletion op-chain-ops/interopgen/configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type SuperFaultProofConfig struct {
}

type OPCMImplementationsConfig struct {
Release string
L1ContractsRelease string

FaultProof SuperFaultProofConfig

Expand Down
5 changes: 2 additions & 3 deletions op-chain-ops/interopgen/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,9 @@ func DeploySuperchainToL1(l1Host *script.Host, superCfg *SuperchainConfig) (*Sup
ProofMaturityDelaySeconds: superCfg.Implementations.FaultProof.ProofMaturityDelaySeconds,
DisputeGameFinalityDelaySeconds: superCfg.Implementations.FaultProof.DisputeGameFinalityDelaySeconds,
MipsVersion: superCfg.Implementations.FaultProof.MipsVersion,
Release: superCfg.Implementations.Release,
L1ContractsRelease: superCfg.Implementations.L1ContractsRelease,
SuperchainConfigProxy: superDeployment.SuperchainConfigProxy,
ProtocolVersionsProxy: superDeployment.ProtocolVersionsProxy,
OpcmProxyOwner: superDeployment.SuperchainProxyAdmin,
UseInterop: superCfg.Implementations.UseInterop,
StandardVersionsToml: standard.VersionsMainnetData,
})
Expand Down Expand Up @@ -210,7 +209,7 @@ func DeployL2ToL1(l1Host *script.Host, superCfg *SuperchainConfig, superDeployme
BasefeeScalar: cfg.GasPriceOracleBaseFeeScalar,
BlobBaseFeeScalar: cfg.GasPriceOracleBlobBaseFeeScalar,
L2ChainId: new(big.Int).SetUint64(cfg.L2ChainID),
OpcmProxy: superDeployment.OpcmProxy,
Opcm: superDeployment.Opcm,
SaltMixer: cfg.SaltMixer,
GasLimit: cfg.GasLimit,
DisputeGameType: cfg.DisputeGameType,
Expand Down
3 changes: 1 addition & 2 deletions op-chain-ops/interopgen/deployments.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ type L1Deployment struct {
}

type Implementations struct {
OpcmProxy common.Address `json:"OPCMProxy"`
OpcmImpl common.Address `json:"OPCMImpl"`
Opcm common.Address `json:"OPCM"`
DelayedWETHImpl common.Address `json:"DelayedWETHImpl"`
OptimismPortalImpl common.Address `json:"OptimismPortalImpl"`
PreimageOracleSingleton common.Address `json:"PreimageOracleSingleton"`
Expand Down
2 changes: 1 addition & 1 deletion op-chain-ops/interopgen/recipe.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (r *InteropDevRecipe) Build(addrs devkeys.Addresses) (*WorldConfig, error)
ProtocolVersionsOwner: superchainProtocolVersionsOwner,
Deployer: superchainDeployer,
Implementations: OPCMImplementationsConfig{
Release: "dev",
L1ContractsRelease: "dev",
FaultProof: SuperFaultProofConfig{
WithdrawalDelaySeconds: big.NewInt(604800),
MinProposalSizeBytes: big.NewInt(10000),
Expand Down
15 changes: 5 additions & 10 deletions op-deployer/pkg/deployer/bootstrap/opcm.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,6 @@ func OPCM(ctx context.Context, cfg OPCMConfig) error {
if err != nil {
return fmt.Errorf("error getting standard versions TOML: %w", err)
}
opcmProxyOwnerAddr, err := standard.ManagerOwnerAddrFor(chainIDU64)
if err != nil {
return fmt.Errorf("error getting superchain proxy admin: %w", err)
}

signer := opcrypto.SignerFnFromBind(opcrypto.PrivateKeySignerFn(cfg.privateKeyECDSA, chainID))
chainDeployer := crypto.PubkeyToAddress(cfg.privateKeyECDSA.PublicKey)
Expand Down Expand Up @@ -199,14 +195,14 @@ func OPCM(ctx context.Context, cfg OPCMConfig) error {
}
host.SetNonce(chainDeployer, nonce)

var release string
var l1ContractsRelease string
if cfg.ArtifactsLocator.IsTag() {
release = cfg.ArtifactsLocator.Tag
l1ContractsRelease = cfg.ArtifactsLocator.Tag
} else {
release = "dev"
l1ContractsRelease = "dev"
}

lgr.Info("deploying OPCM", "release", release)
lgr.Info("deploying OPCM", "l1ContractsRelease", l1ContractsRelease)

// We need to etch the Superchain addresses so that they have nonzero code
// and the checks in the OPCM constructor pass.
Expand Down Expand Up @@ -238,10 +234,9 @@ func OPCM(ctx context.Context, cfg OPCMConfig) error {
ProofMaturityDelaySeconds: new(big.Int).SetUint64(cfg.ProofMaturityDelaySeconds),
DisputeGameFinalityDelaySeconds: new(big.Int).SetUint64(cfg.DisputeGameFinalityDelaySeconds),
MipsVersion: new(big.Int).SetUint64(cfg.MIPSVersion),
Release: release,
L1ContractsRelease: l1ContractsRelease,
SuperchainConfigProxy: superchainConfigAddr,
ProtocolVersionsProxy: protocolVersionsAddr,
OpcmProxyOwner: opcmProxyOwnerAddr,
StandardVersionsToml: standardVersionsTOML,
UseInterop: false,
},
Expand Down
4 changes: 2 additions & 2 deletions op-deployer/pkg/deployer/inspect/l1.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ type OpChainDeployment struct {
}

type ImplementationsDeployment struct {
OpcmProxyAddress common.Address `json:"opcmProxyAddress"`
OpcmAddress common.Address `json:"opcmAddress"`
DelayedWETHImplAddress common.Address `json:"delayedWETHImplAddress"`
OptimismPortalImplAddress common.Address `json:"optimismPortalImplAddress"`
PreimageOracleSingletonAddress common.Address `json:"preimageOracleSingletonAddress"`
Expand Down Expand Up @@ -113,7 +113,7 @@ func L1(globalState *state.State, chainID common.Hash) (*L1Contracts, error) {
// DelayedWETHPermissionlessGameProxyAddress: chainState.DelayedWETHPermissionlessGameProxyAddress,
},
ImplementationsDeployment: ImplementationsDeployment{
OpcmProxyAddress: globalState.ImplementationsDeployment.OpcmProxyAddress,
OpcmAddress: globalState.ImplementationsDeployment.OpcmAddress,
DelayedWETHImplAddress: globalState.ImplementationsDeployment.DelayedWETHImplAddress,
OptimismPortalImplAddress: globalState.ImplementationsDeployment.OptimismPortalImplAddress,
PreimageOracleSingletonAddress: globalState.ImplementationsDeployment.PreimageOracleSingletonAddress,
Expand Down
26 changes: 25 additions & 1 deletion op-deployer/pkg/deployer/integration_test/apply_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,30 @@ func TestApplyExistingOPCM(t *testing.T) {
))

validateOPChainDeployment(t, ethClientCodeGetter(ctx, l1Client), st, intent)

releases := standard.L1VersionsSepolia.Releases["op-contracts/v1.6.0"]

implTests := []struct {
name string
expAddr common.Address
actAddr common.Address
}{
{"OptimismPortal", releases.OptimismPortal.ImplementationAddress, st.ImplementationsDeployment.OptimismPortalImplAddress},
{"SystemConfig,", releases.SystemConfig.ImplementationAddress, st.ImplementationsDeployment.SystemConfigImplAddress},
{"L1CrossDomainMessenger", releases.L1CrossDomainMessenger.ImplementationAddress, st.ImplementationsDeployment.L1CrossDomainMessengerImplAddress},
{"L1ERC721Bridge", releases.L1ERC721Bridge.ImplementationAddress, st.ImplementationsDeployment.L1ERC721BridgeImplAddress},
{"L1StandardBridge", releases.L1StandardBridge.ImplementationAddress, st.ImplementationsDeployment.L1StandardBridgeImplAddress},
{"OptimismMintableERC20Factory", releases.OptimismMintableERC20Factory.ImplementationAddress, st.ImplementationsDeployment.OptimismMintableERC20FactoryImplAddress},
{"DisputeGameFactory", releases.DisputeGameFactory.ImplementationAddress, st.ImplementationsDeployment.DisputeGameFactoryImplAddress},
{"MIPS", releases.MIPS.Address, st.ImplementationsDeployment.MipsSingletonAddress},
{"PreimageOracle", releases.PreimageOracle.Address, st.ImplementationsDeployment.PreimageOracleSingletonAddress},
{"DelayedWETH", releases.DelayedWETH.ImplementationAddress, st.ImplementationsDeployment.DelayedWETHImplAddress},
}
for _, tt := range implTests {
t.Run(tt.name, func(t *testing.T) {
require.Equal(t, tt.expAddr, tt.actAddr)
})
}
}

func TestL2BlockTimeOverride(t *testing.T) {
Expand Down Expand Up @@ -571,7 +595,7 @@ func validateSuperchainDeployment(t *testing.T, st *state.State, cg codeGetter)
{"SuperchainConfigImpl", st.SuperchainDeployment.SuperchainConfigImplAddress},
{"ProtocolVersionsProxy", st.SuperchainDeployment.ProtocolVersionsProxyAddress},
{"ProtocolVersionsImpl", st.SuperchainDeployment.ProtocolVersionsImplAddress},
{"OpcmProxy", st.ImplementationsDeployment.OpcmProxyAddress},
{"Opcm", st.ImplementationsDeployment.OpcmAddress},
{"PreimageOracleSingleton", st.ImplementationsDeployment.PreimageOracleSingletonAddress},
{"MipsSingleton", st.ImplementationsDeployment.MipsSingletonAddress},
}
Expand Down
51 changes: 0 additions & 51 deletions op-deployer/pkg/deployer/opcm/contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,57 +48,6 @@ func (c *Contract) GenericAddressGetter(ctx context.Context, functionName string
return c.callContractMethod(ctx, functionName, abi.Arguments{})
}

// GetImplementation retrieves the Implementation struct for a given release and contract name.
func (c *Contract) GetOPCMImplementationAddress(ctx context.Context, release, contractName string) (common.Address, error) {
methodName := "implementations"
method := abi.NewMethod(
methodName,
methodName,
abi.Function,
"view",
true,
false,
abi.Arguments{
{Name: "release", Type: mustType("string")},
{Name: "contractName", Type: mustType("string")},
},
abi.Arguments{
{Name: "logic", Type: mustType("address")},
{Name: "initializer", Type: mustType("bytes4")},
},
)

calldata, err := method.Inputs.Pack(release, contractName)
if err != nil {
return common.Address{}, fmt.Errorf("failed to pack inputs: %w", err)
}

msg := ethereum.CallMsg{
To: &c.addr,
Data: append(bytes.Clone(method.ID), calldata...),
}

result, err := c.client.CallContract(ctx, msg, nil)
if err != nil {
return common.Address{}, fmt.Errorf("failed to call contract: %w", err)
}

out, err := method.Outputs.Unpack(result)
if err != nil {
return common.Address{}, fmt.Errorf("failed to unpack result: %w", err)
}
if len(out) != 2 {
return common.Address{}, fmt.Errorf("unexpected output length: %d", len(out))
}

logic, ok := out[0].(common.Address)
if !ok {
return common.Address{}, fmt.Errorf("unexpected type for logic: %T", out[0])
}

return logic, nil
}

func (c *Contract) callContractMethod(ctx context.Context, methodName string, inputs abi.Arguments, args ...interface{}) (common.Address, error) {
method := abi.NewMethod(
methodName,
Expand Down
6 changes: 2 additions & 4 deletions op-deployer/pkg/deployer/opcm/implementations.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@ type DeployImplementationsInput struct {
DisputeGameFinalityDelaySeconds *big.Int
MipsVersion *big.Int
// Release version to set OPCM implementations for, of the format `op-contracts/vX.Y.Z`.
Release string
L1ContractsRelease string
SuperchainConfigProxy common.Address
ProtocolVersionsProxy common.Address
UseInterop bool // if true, deploy Interop implementations

OpcmProxyOwner common.Address
StandardVersionsToml string // contents of 'standard-versions-mainnet.toml' or 'standard-versions-sepolia.toml' file
}

Expand All @@ -32,8 +31,7 @@ func (input *DeployImplementationsInput) InputSet() bool {
}

type DeployImplementationsOutput struct {
OpcmProxy common.Address
OpcmImpl common.Address
Opcm common.Address
DelayedWETHImpl common.Address
OptimismPortalImpl common.Address
PreimageOracleSingleton common.Address
Expand Down
6 changes: 3 additions & 3 deletions op-deployer/pkg/deployer/opcm/opchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type DeployOPChainInputV160 struct {
BasefeeScalar uint32
BlobBaseFeeScalar uint32
L2ChainId *big.Int
OpcmProxy common.Address
Opcm common.Address
SaltMixer string
GasLimit uint64

Expand Down Expand Up @@ -122,8 +122,8 @@ func deployOPChain[T any](host *script.Host, input T) (DeployOPChainOutput, erro

type ReadImplementationAddressesInput struct {
DeployOPChainOutput
OpcmProxy common.Address
Release string
Opcm common.Address
Release string
}

type ReadImplementationAddressesOutput struct {
Expand Down
2 changes: 1 addition & 1 deletion op-deployer/pkg/deployer/pipeline/alt_da.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func DeployAltDA(env *Env, intent *state.Intent, st *state.State, chainID common
lgr.Info("deploying alt-da contracts")
dao, err = opcm.DeployAltDA(env.L1ScriptHost, opcm.DeployAltDAInput{
Salt: st.Create2Salt,
ProxyAdmin: st.ImplementationsDeployment.OpcmProxyAddress,
ProxyAdmin: chainState.ProxyAdminAddress,
ChallengeContractOwner: chainIntent.Roles.L1ProxyAdminOwner,
ChallengeWindow: new(big.Int).SetUint64(chainIntent.DangerousAltDAConfig.DAChallengeWindow),
ResolveWindow: new(big.Int).SetUint64(chainIntent.DangerousAltDAConfig.DAResolveWindow),
Expand Down
5 changes: 2 additions & 3 deletions op-deployer/pkg/deployer/pipeline/implementations.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,9 @@ func DeployImplementations(env *Env, intent *state.Intent, st *state.State) erro
ProofMaturityDelaySeconds: new(big.Int).SetUint64(proofParams.ProofMaturityDelaySeconds),
DisputeGameFinalityDelaySeconds: new(big.Int).SetUint64(proofParams.DisputeGameFinalityDelaySeconds),
MipsVersion: new(big.Int).SetUint64(proofParams.MIPSVersion),
Release: contractsRelease,
L1ContractsRelease: contractsRelease,
SuperchainConfigProxy: st.SuperchainDeployment.SuperchainConfigProxyAddress,
ProtocolVersionsProxy: st.SuperchainDeployment.ProtocolVersionsProxyAddress,
OpcmProxyOwner: st.SuperchainDeployment.ProxyAdminAddress,
StandardVersionsToml: standardVersionsTOML,
UseInterop: intent.UseInterop,
},
Expand All @@ -81,7 +80,7 @@ func DeployImplementations(env *Env, intent *state.Intent, st *state.State) erro
}

st.ImplementationsDeployment = &state.ImplementationsDeployment{
OpcmProxyAddress: dio.OpcmProxy,
OpcmAddress: dio.Opcm,
DelayedWETHImplAddress: dio.DelayedWETHImpl,
OptimismPortalImplAddress: dio.OptimismPortalImpl,
PreimageOracleSingletonAddress: dio.PreimageOracleSingleton,
Expand Down
4 changes: 2 additions & 2 deletions op-deployer/pkg/deployer/pipeline/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ func InitLiveStrategy(ctx context.Context, env *Env, intent *state.Intent, st *s
SuperchainConfigProxyAddress: common.Address(*superCfg.Config.SuperchainConfigAddr),
}

opcmProxy, err := standard.ManagerImplementationAddrFor(intent.L1ChainID)
opcmAddress, err := standard.ManagerImplementationAddrFor(intent.L1ChainID)
if err != nil {
return fmt.Errorf("error getting OPCM proxy address: %w", err)
}
st.ImplementationsDeployment = &state.ImplementationsDeployment{
OpcmProxyAddress: opcmProxy,
OpcmAddress: opcmAddress,
}
}

Expand Down
8 changes: 4 additions & 4 deletions op-deployer/pkg/deployer/pipeline/opchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func DeployOPChain(env *Env, intent *state.Intent, st *state.State, chainID comm
return opcm.DeployOPChainOutput{}, fmt.Errorf("error making deploy OP chain input: %w", err)
}

opcmAddr = input.OpcmProxy
opcmAddr = input.Opcm
return opcm.DeployOPChainV160(env.L1ScriptHost, input)
}
default:
Expand All @@ -44,7 +44,7 @@ func DeployOPChain(env *Env, intent *state.Intent, st *state.State, chainID comm
return opcm.DeployOPChainOutput{}, fmt.Errorf("error making deploy OP chain input: %w", err)
}

opcmAddr = input.OpcmProxy
opcmAddr = input.Opcm
return opcm.DeployOPChainIsthmus(env.L1ScriptHost, input)
}
}
Expand All @@ -67,7 +67,7 @@ func DeployOPChain(env *Env, intent *state.Intent, st *state.State, chainID comm

readInput := opcm.ReadImplementationAddressesInput{
DeployOPChainOutput: dco,
OpcmProxy: opcmAddr,
Opcm: opcmAddr,
Release: release,
}
impls, err := opcm.ReadImplementationAddresses(env.L1ScriptHost, readInput)
Expand Down Expand Up @@ -126,7 +126,7 @@ func makeDCIV160(intent *state.Intent, thisIntent *state.ChainIntent, chainID co
BasefeeScalar: standard.BasefeeScalar,
BlobBaseFeeScalar: standard.BlobBaseFeeScalar,
L2ChainId: chainID.Big(),
OpcmProxy: st.ImplementationsDeployment.OpcmProxyAddress,
Opcm: st.ImplementationsDeployment.OpcmAddress,
SaltMixer: st.Create2Salt.String(), // passing through salt generated at state initialization
GasLimit: standard.GasLimit,
DisputeGameType: proofParams.DisputeGameType,
Expand Down
9 changes: 5 additions & 4 deletions op-deployer/pkg/deployer/standard/standard.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,11 @@ func ManagerImplementationAddrFor(chainID uint64) (common.Address, error) {
switch chainID {
case 1:
// Generated using the bootstrap command on 10/18/2024.
return common.HexToAddress("0x18cec91779995ad14c880e4095456b9147160790"), nil
// TODO: @blmalone this needs re-bootstrapped because it's still proxied
return common.HexToAddress(""), nil
case 11155111:
// Generated using the bootstrap command on 10/18/2024.
return common.HexToAddress("0xf564eea7960ea244bfebcbbb17858748606147bf"), nil
// Generated using the bootstrap command on 11/15/2024.
return common.HexToAddress("0xde9eacb994a6eb12997445f8a63a22772c5c4313"), nil
default:
return common.Address{}, fmt.Errorf("unsupported chain ID: %d", chainID)
}
Expand Down Expand Up @@ -172,7 +173,7 @@ func SystemOwnerAddrFor(chainID uint64) (common.Address, error) {
func ArtifactsURLForTag(tag string) (*url.URL, error) {
switch tag {
case "op-contracts/v1.6.0":
return url.Parse(standardArtifactsURL("3a27c6dc0cb61b36feaac26def98c64b4a48ec8f5c5ba6965e8ae3157606043c"))
return url.Parse(standardArtifactsURL("e1f0c4020618c4a98972e7124c39686cab2e31d5d7846f9ce5e0d5eed0f5ff32"))
case "op-contracts/v1.7.0-beta.1+l2-contracts":
return url.Parse(standardArtifactsURL("b0fb1f6f674519d637cff39a22187a5993d7f81a6d7b7be6507a0b50a5e38597"))
default:
Expand Down
2 changes: 1 addition & 1 deletion op-deployer/pkg/deployer/state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ type SuperchainDeployment struct {
}

type ImplementationsDeployment struct {
OpcmProxyAddress common.Address `json:"opcmProxyAddress"`
OpcmAddress common.Address `json:"opcmAddress"`
DelayedWETHImplAddress common.Address `json:"delayedWETHImplAddress"`
OptimismPortalImplAddress common.Address `json:"optimismPortalImplAddress"`
PreimageOracleSingletonAddress common.Address `json:"preimageOracleSingletonAddress"`
Expand Down
Loading

0 comments on commit 8f0a9b2

Please sign in to comment.