1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package pipeline
import (
"context"
"fmt"
"math/big"
"github.com/ethereum-optimism/optimism/op-chain-ops/deployer/opsm"
"github.com/ethereum-optimism/optimism/op-chain-ops/deployer/state"
"github.com/ethereum-optimism/optimism/op-chain-ops/foundry"
"github.com/ethereum-optimism/optimism/op-chain-ops/script"
)
func DeployImplementations(ctx context.Context, env *Env, artifactsFS foundry.StatDirFs, intent *state.Intent, st *state.State) error {
lgr := env.Logger.New("stage", "deploy-implementations")
if !shouldDeployImplementations(intent, st) {
lgr.Info("implementations deployment not needed")
return nil
}
lgr.Info("deploying implementations")
var dump *foundry.ForgeAllocs
var dio opsm.DeployImplementationsOutput
var err error
err = CallScriptBroadcast(
ctx,
CallScriptBroadcastOpts{
L1ChainID: big.NewInt(int64(intent.L1ChainID)),
Logger: lgr,
ArtifactsFS: artifactsFS,
Deployer: env.Deployer,
Signer: env.Signer,
Client: env.L1Client,
Broadcaster: KeyedBroadcaster,
Handler: func(host *script.Host) error {
host.SetEnvVar("IMPL_SALT", st.Create2Salt.Hex()[2:])
host.ImportState(st.SuperchainDeployment.StateDump)
dio, err = opsm.DeployImplementations(
host,
opsm.DeployImplementationsInput{
Salt: st.Create2Salt,
WithdrawalDelaySeconds: big.NewInt(604800),
MinProposalSizeBytes: big.NewInt(126000),
ChallengePeriodSeconds: big.NewInt(86400),
ProofMaturityDelaySeconds: big.NewInt(604800),
DisputeGameFinalityDelaySeconds: big.NewInt(302400),
Release: "op-contracts/v1.6.0",
SuperchainConfigProxy: st.SuperchainDeployment.SuperchainConfigProxyAddress,
ProtocolVersionsProxy: st.SuperchainDeployment.ProtocolVersionsProxyAddress,
SuperchainProxyAdmin: st.SuperchainDeployment.ProxyAdminAddress,
UseInterop: false,
},
)
if err != nil {
return fmt.Errorf("error deploying implementations: %w", err)
}
dump, err = host.StateDump()
if err != nil {
return fmt.Errorf("error dumping state: %w", err)
}
return nil
},
},
)
if err != nil {
return fmt.Errorf("error deploying implementations: %w", err)
}
st.ImplementationsDeployment = &state.ImplementationsDeployment{
OpsmProxyAddress: dio.OpsmProxy,
DelayedWETHImplAddress: dio.DelayedWETHImpl,
OptimismPortalImplAddress: dio.OptimismPortalImpl,
PreimageOracleSingletonAddress: dio.PreimageOracleSingleton,
MipsSingletonAddress: dio.MipsSingleton,
SystemConfigImplAddress: dio.SystemConfigImpl,
L1CrossDomainMessengerImplAddress: dio.L1CrossDomainMessengerImpl,
L1ERC721BridgeImplAddress: dio.L1ERC721BridgeImpl,
L1StandardBridgeImplAddress: dio.L1StandardBridgeImpl,
OptimismMintableERC20FactoryImplAddress: dio.OptimismMintableERC20FactoryImpl,
DisputeGameFactoryImplAddress: dio.DisputeGameFactoryImpl,
StateDump: dump,
}
if err := env.WriteState(st); err != nil {
return err
}
return nil
}
func shouldDeployImplementations(intent *state.Intent, st *state.State) bool {
return st.ImplementationsDeployment == nil
}