Skip to content

Commit 21118d9

Browse files
authored
add deploy api (#1314)
* add deploy api * change versioning * tests * package name * top level * top level
1 parent c79ffea commit 21118d9

File tree

22 files changed

+315
-288
lines changed

22 files changed

+315
-288
lines changed

chains/evm/deployment/v1_0_0/deployer.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,18 @@ import (
1212
"github.com/smartcontractkit/chainlink-ccip/chains/evm/deployment/utils/operations/contract"
1313
ops "github.com/smartcontractkit/chainlink-ccip/chains/evm/deployment/v1_0_0/operations"
1414
seq "github.com/smartcontractkit/chainlink-ccip/chains/evm/deployment/v1_0_0/sequences"
15+
ccipapi "github.com/smartcontractkit/chainlink-ccip/deployment/deploy"
1516
"github.com/smartcontractkit/chainlink-ccip/deployment/utils"
1617
sequtil "github.com/smartcontractkit/chainlink-ccip/deployment/utils/sequences"
17-
ccipapi "github.com/smartcontractkit/chainlink-ccip/deployment/v1_0"
1818
)
1919

2020
type EVMDeployer struct{}
2121

22+
func (a *EVMDeployer) DeployChainContracts() *cldf_ops.Sequence[ccipapi.ContractDeploymentConfigPerChainWithAddress, sequtil.OnChainOutput, cldf_chain.BlockChains] {
23+
// Not implemented for the 1.0.0 deployer
24+
return nil
25+
}
26+
2227
func (d *EVMDeployer) DeployMCMS() *cldf_ops.Sequence[ccipapi.MCMSDeploymentConfigPerChainWithAddress, sequtil.OnChainOutput, cldf_chain.BlockChains] {
2328
return cldf_ops.NewSequence(
2429
"deploy-mcms",

chains/evm/deployment/v1_0_0/deployer_test.go

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"math/big"
55
"testing"
66

7+
"github.com/Masterminds/semver/v3"
78
"github.com/aws/smithy-go/ptr"
89
"github.com/ethereum/go-ethereum/accounts/abi/bind"
910
"github.com/ethereum/go-ethereum/common"
@@ -13,8 +14,8 @@ import (
1314
"github.com/smartcontractkit/mcms/sdk/evm/bindings"
1415
"github.com/stretchr/testify/require"
1516

17+
deployops "github.com/smartcontractkit/chainlink-ccip/deployment/deploy"
1618
"github.com/smartcontractkit/chainlink-ccip/deployment/utils"
17-
"github.com/smartcontractkit/chainlink-ccip/deployment/v1_0"
1819
)
1920

2021
func TestDeployMCMS(t *testing.T) {
@@ -27,15 +28,17 @@ func TestDeployMCMS(t *testing.T) {
2728
evmChain := env.BlockChains.EVMChains()[selector]
2829

2930
evmDeployer := &EVMDeployer{}
30-
dReg := v1_0.GetRegistry()
31-
dReg.RegisterDeployer(chainsel.FamilyEVM, v1_0.MCMSVersion, evmDeployer)
32-
cs := v1_0.DeployMCMS(dReg)
33-
output, err := cs.Apply(*env, v1_0.MCMSDeploymentConfig{
34-
Chains: map[uint64]v1_0.MCMSDeploymentConfigPerChain{
31+
dReg := deployops.GetRegistry()
32+
version := semver.MustParse("1.0.0")
33+
dReg.RegisterDeployer(chainsel.FamilyEVM, version, evmDeployer)
34+
cs := deployops.DeployMCMS(dReg)
35+
output, err := cs.Apply(*env, deployops.MCMSDeploymentConfig{
36+
Version: version,
37+
Chains: map[uint64]deployops.MCMSDeploymentConfigPerChain{
3538
selector: {
36-
Canceller: v1_0.SingleGroupMCMSV2(),
37-
Bypasser: v1_0.SingleGroupMCMSV2(),
38-
Proposer: v1_0.SingleGroupMCMSV2(),
39+
Canceller: deployops.SingleGroupMCMSV2(),
40+
Bypasser: deployops.SingleGroupMCMSV2(),
41+
Proposer: deployops.SingleGroupMCMSV2(),
3942
TimelockMinDelay: big.NewInt(0),
4043
Qualifier: ptr.String("test"),
4144
TimelockAdmin: evmChain.DeployerKey.From,

chains/evm/deployment/v1_6_0/changesets/connect_chains_test.go

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@ import (
44
"encoding/hex"
55
"math/big"
66
"testing"
7+
"time"
78

89
"github.com/Masterminds/semver/v3"
910
"github.com/ethereum/go-ethereum/common"
1011
chain_selectors "github.com/smartcontractkit/chain-selectors"
11-
"github.com/smartcontractkit/chainlink-ccip/chains/evm/deployment/v1_6_0/changesets"
12-
fqops "github.com/smartcontractkit/chainlink-ccip/chains/evm/deployment/v1_6_0/operations/fee_quoter"
13-
offrampops "github.com/smartcontractkit/chainlink-ccip/chains/evm/deployment/v1_6_0/operations/offramp"
1412
"github.com/smartcontractkit/chainlink-ccip/chains/evm/deployment/v1_6_0/sequences"
1513
"github.com/smartcontractkit/chainlink-ccip/chains/evm/gobindings/generated/v1_2_0/router"
1614
"github.com/smartcontractkit/chainlink-ccip/chains/evm/gobindings/generated/v1_6_0/fee_quoter"
@@ -22,6 +20,7 @@ import (
2220
"github.com/stretchr/testify/require"
2321

2422
ccipapi "github.com/smartcontractkit/chainlink-ccip/deployment"
23+
deployops "github.com/smartcontractkit/chainlink-ccip/deployment/deploy"
2524
lanesapi "github.com/smartcontractkit/chainlink-ccip/deployment/lanes"
2625
fdeployment "github.com/smartcontractkit/chainlink-deployments-framework/deployment"
2726
)
@@ -141,14 +140,22 @@ func TestConnectChains_EVM2EVM_NoMCMS(t *testing.T) {
141140
require.NotNil(t, e, "Environment should be created")
142141

143142
mcmsRegistry := cs_core.NewMCMSReaderRegistry()
143+
dReg := deployops.GetRegistry()
144+
version := semver.MustParse("1.6.0")
144145
for _, chainSel := range chains {
145-
out, err := changesets.DeployChainContracts(mcmsRegistry).Apply(*e, cs_core.WithMCMS[changesets.DeployChainContractsCfg]{
146+
out, err := deployops.DeployContracts(dReg).Apply(*e, deployops.ContractDeploymentConfig{
146147
MCMS: mcms.Input{},
147-
Cfg: changesets.DeployChainContractsCfg{
148-
ChainSel: chainSel,
149-
Params: sequences.ContractParams{
150-
FeeQuoter: fqops.DefaultFeeQuoterParams(),
151-
OffRamp: offrampops.DefaultOffRampParams(),
148+
Chains: map[uint64]deployops.ContractDeploymentConfigPerChain{
149+
chainSel: {
150+
Version: version,
151+
// FEE QUOTER CONFIG
152+
MaxFeeJuelsPerMsg: big.NewInt(0).Mul(big.NewInt(200), big.NewInt(1e18)),
153+
TokenPriceStalenessThreshold: uint32(24 * 60 * 60),
154+
LinkPremiumMultiplier: 9e17, // 0.9 ETH
155+
NativeTokenPremiumMultiplier: 1e18, // 1.0 ETH
156+
// OFFRAMP CONFIG
157+
PermissionLessExecutionThresholdSeconds: uint32((20 * time.Minute).Seconds()),
158+
GasForCallExactCheck: uint16(5000),
152159
},
153160
},
154161
})
@@ -158,7 +165,6 @@ func TestConnectChains_EVM2EVM_NoMCMS(t *testing.T) {
158165
}
159166
evmEncoded, err := hex.DecodeString(ccipapi.EVMFamilySelector)
160167
require.NoError(t, err, "Failed to decode EVM family selector")
161-
laneVersion := semver.MustParse("1.6.0")
162168
chain1 := lanesapi.ChainDefinition{
163169
Selector: chain_selectors.ETHEREUM_MAINNET.Selector,
164170
GasPrice: big.NewInt(1e17),
@@ -173,7 +179,7 @@ func TestConnectChains_EVM2EVM_NoMCMS(t *testing.T) {
173179
_, err = lanesapi.ConnectChains(lanesapi.GetLaneAdapterRegistry(), mcmsRegistry).Apply(*e, lanesapi.ConnectChainsConfig{
174180
Lanes: []lanesapi.LaneConfig{
175181
{
176-
Version: laneVersion,
182+
Version: version,
177183
Source: chain1,
178184
Dest: chain2,
179185
},
@@ -184,11 +190,11 @@ func TestConnectChains_EVM2EVM_NoMCMS(t *testing.T) {
184190
src, dest := chains[0], chains[1]
185191
srcFamily, err := chain_selectors.GetSelectorFamily(src)
186192
require.NoError(t, err, "must get selector family for src")
187-
srcAdapter, exists := laneRegistry.GetLaneAdapter(srcFamily, laneVersion)
193+
srcAdapter, exists := laneRegistry.GetLaneAdapter(srcFamily, version)
188194
require.True(t, exists, "must have ChainAdapter registered for src chain family")
189195
destFamily, err := chain_selectors.GetSelectorFamily(dest)
190196
require.NoError(t, err, "must get selector family for dest")
191-
destAdapter, exists := laneRegistry.GetLaneAdapter(destFamily, laneVersion)
197+
destAdapter, exists := laneRegistry.GetLaneAdapter(destFamily, version)
192198
require.True(t, exists, "must have ChainAdapter registered for dest chain family")
193199
checkBidirectionalLaneConnectivity(t, e, chain1, chain2, srcAdapter, destAdapter, false, false)
194200
}

chains/evm/deployment/v1_6_0/changesets/deploy_chain_contracts.go

Lines changed: 0 additions & 36 deletions
This file was deleted.

chains/evm/deployment/v1_6_0/changesets/deploy_chain_contracts_test.go

Lines changed: 41 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
package changesets_test
22

33
import (
4+
"math/big"
45
"testing"
6+
"time"
57

68
"github.com/Masterminds/semver/v3"
79
"github.com/ethereum/go-ethereum/common"
810
chain_selectors "github.com/smartcontractkit/chain-selectors"
911
"github.com/smartcontractkit/chainlink-ccip/chains/evm/deployment/v1_0_0/operations/link"
1012
"github.com/smartcontractkit/chainlink-ccip/chains/evm/deployment/v1_0_0/operations/weth"
11-
"github.com/smartcontractkit/chainlink-ccip/chains/evm/deployment/v1_6_0/changesets"
12-
"github.com/smartcontractkit/chainlink-ccip/chains/evm/deployment/v1_6_0/operations/fee_quoter"
13-
"github.com/smartcontractkit/chainlink-ccip/chains/evm/deployment/v1_6_0/operations/offramp"
14-
"github.com/smartcontractkit/chainlink-ccip/chains/evm/deployment/v1_6_0/sequences"
15-
cs_core "github.com/smartcontractkit/chainlink-ccip/deployment/utils/changesets"
13+
deployops "github.com/smartcontractkit/chainlink-ccip/deployment/deploy"
1614
"github.com/smartcontractkit/chainlink-ccip/deployment/utils/mcms"
1715
"github.com/smartcontractkit/chainlink-deployments-framework/datastore"
1816
"github.com/smartcontractkit/chainlink-deployments-framework/engine/test/environment"
@@ -28,36 +26,48 @@ func TestDeployChainContracts_VerifyPreconditions(t *testing.T) {
2826

2927
tests := []struct {
3028
desc string
31-
input cs_core.WithMCMS[changesets.DeployChainContractsCfg]
29+
input deployops.ContractDeploymentConfig
3230
expectedErr string
3331
}{
3432
{
3533
desc: "valid input",
36-
input: cs_core.WithMCMS[changesets.DeployChainContractsCfg]{
34+
input: deployops.ContractDeploymentConfig{
3735
MCMS: mcms.Input{},
38-
Cfg: changesets.DeployChainContractsCfg{
39-
ChainSel: chain_selectors.ETHEREUM_MAINNET.Selector,
40-
Params: sequences.ContractParams{},
36+
Chains: map[uint64]deployops.ContractDeploymentConfigPerChain{
37+
chain_selectors.ETHEREUM_MAINNET.Selector: {
38+
Version: semver.MustParse("1.6.0"),
39+
},
40+
},
41+
},
42+
},
43+
{
44+
desc: "invalid version nil",
45+
input: deployops.ContractDeploymentConfig{
46+
MCMS: mcms.Input{},
47+
Chains: map[uint64]deployops.ContractDeploymentConfigPerChain{
48+
chain_selectors.ETHEREUM_MAINNET.Selector: {
49+
Version: nil,
50+
},
4151
},
4252
},
53+
expectedErr: "no version specified for chain with selector 5009297550715157269",
4354
},
4455
{
4556
desc: "invalid chain selector",
46-
input: cs_core.WithMCMS[changesets.DeployChainContractsCfg]{
57+
input: deployops.ContractDeploymentConfig{
4758
MCMS: mcms.Input{},
48-
Cfg: changesets.DeployChainContractsCfg{
49-
ChainSel: 12345,
50-
Params: sequences.ContractParams{},
59+
Chains: map[uint64]deployops.ContractDeploymentConfigPerChain{
60+
12345: {},
5161
},
5262
},
53-
expectedErr: "no EVM chain with selector 12345 found in environment",
63+
expectedErr: "no selector 12345 found in environment: unknown chain selector 12345",
5464
},
5565
}
5666

5767
for _, test := range tests {
5868
t.Run(test.desc, func(t *testing.T) {
59-
mcmsRegistry := cs_core.NewMCMSReaderRegistry()
60-
err := changesets.DeployChainContracts(mcmsRegistry).VerifyPreconditions(*e, test.input)
69+
dReg := deployops.GetRegistry()
70+
err := deployops.DeployContracts(dReg).VerifyPreconditions(*e, test.input)
6171
if test.expectedErr != "" {
6272
require.ErrorContains(t, err, test.expectedErr, "Expected error containing %q but got none", test.expectedErr)
6373
} else {
@@ -112,14 +122,21 @@ func TestDeployChainContracts_Apply(t *testing.T) {
112122
require.NoError(t, err, "Failed to fetch addresses from datastore")
113123
e.DataStore = ds.Seal() // Override datastore in environment to include existing addresses
114124

115-
mcmsRegistry := cs_core.NewMCMSReaderRegistry()
116-
out, err := changesets.DeployChainContracts(mcmsRegistry).Apply(*e, cs_core.WithMCMS[changesets.DeployChainContractsCfg]{
125+
dReg := deployops.GetRegistry()
126+
version := semver.MustParse("1.6.0")
127+
out, err := deployops.DeployContracts(dReg).Apply(*e, deployops.ContractDeploymentConfig{
117128
MCMS: mcms.Input{},
118-
Cfg: changesets.DeployChainContractsCfg{
119-
ChainSel: chain_selectors.ETHEREUM_MAINNET.Selector,
120-
Params: sequences.ContractParams{
121-
FeeQuoter: fee_quoter.DefaultFeeQuoterParams(),
122-
OffRamp: offramp.DefaultOffRampParams(),
129+
Chains: map[uint64]deployops.ContractDeploymentConfigPerChain{
130+
chain_selectors.ETHEREUM_MAINNET.Selector: {
131+
Version: version,
132+
// FEE QUOTER CONFIG
133+
MaxFeeJuelsPerMsg: big.NewInt(0).Mul(big.NewInt(200), big.NewInt(1e18)),
134+
TokenPriceStalenessThreshold: uint32(24 * 60 * 60),
135+
LinkPremiumMultiplier: 9e17, // 0.9 ETH
136+
NativeTokenPremiumMultiplier: 1e18, // 1.0 ETH
137+
// OFFRAMP CONFIG
138+
PermissionLessExecutionThresholdSeconds: uint32((20 * time.Minute).Seconds()),
139+
GasForCallExactCheck: uint16(5000),
123140
},
124141
},
125142
})

chains/evm/deployment/v1_6_0/operations/fee_quoter/fee_quoter.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,3 @@ func (c FeeQuoterParams) Validate() error {
9292
}
9393
return nil
9494
}
95-
96-
func DefaultFeeQuoterParams() FeeQuoterParams {
97-
return FeeQuoterParams{
98-
MaxFeeJuelsPerMsg: big.NewInt(0).Mul(big.NewInt(2e2), big.NewInt(1e18)),
99-
TokenPriceStalenessThreshold: uint32(24 * 60 * 60),
100-
LinkPremiumMultiplierWeiPerEth: 9e17, // 0.9 ETH
101-
WethPremiumMultiplierWeiPerEth: 1e18, // 1.0 ETH
102-
TokenPriceFeedUpdates: []fee_quoter.FeeQuoterTokenPriceFeedUpdate{},
103-
TokenTransferFeeConfigArgs: []fee_quoter.FeeQuoterTokenTransferFeeConfigArgs{},
104-
MorePremiumMultiplierWeiPerEth: []fee_quoter.FeeQuoterPremiumMultiplierWeiPerEthArgs{},
105-
DestChainConfigArgs: []fee_quoter.FeeQuoterDestChainConfigArgs{},
106-
}
107-
}

chains/evm/deployment/v1_6_0/operations/offramp/offramp.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package offramp
22

33
import (
4-
"time"
5-
64
"github.com/Masterminds/semver/v3"
75
"github.com/ethereum/go-ethereum/accounts/abi/bind"
86
"github.com/ethereum/go-ethereum/common"
@@ -59,10 +57,3 @@ var OffRampApplySourceChainConfigUpdates = contract.NewWrite(contract.WriteParam
5957
return offRamp.ApplySourceChainConfigUpdates(opts, args)
6058
},
6159
})
62-
63-
func DefaultOffRampParams() OffRampParams {
64-
return OffRampParams{
65-
GasForCallExactCheck: uint16(5000),
66-
PermissionLessExecutionThresholdSeconds: uint32((1 * time.Hour).Seconds()),
67-
}
68-
}

chains/evm/deployment/v1_6_0/sequences/adapter.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"github.com/smartcontractkit/chainlink-deployments-framework/datastore"
1414
cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment"
1515

16+
deployops "github.com/smartcontractkit/chainlink-ccip/deployment/deploy"
1617
ccipapi "github.com/smartcontractkit/chainlink-ccip/deployment/lanes"
1718
)
1819

@@ -22,6 +23,7 @@ func init() {
2223
panic(err)
2324
}
2425
ccipapi.GetLaneAdapterRegistry().RegisterLaneAdapter(chain_selectors.FamilyEVM, v, &EVMAdapter{})
26+
deployops.GetRegistry().RegisterDeployer(chain_selectors.FamilyEVM, v, &EVMAdapter{})
2527
}
2628

2729
type EVMAdapter struct{}

0 commit comments

Comments
 (0)