Skip to content

Commit c71b37c

Browse files
ecPablograham-chainlinkCopilot
authored
feat: fund mcms pdas [CLD-2765] (#101)
Refactors fund mcms pdas for solana to use new conventions and helpers ## AI Summary This pull request refactors the EVM operations utility usage throughout the MCMS legacy codebase. The main change is replacing references to the old `oputil` package with the new `mcms/evm/operations` package, updating both import paths and type usages. This streamlines code maintenance and ensures all EVM-related operations use the centralized, updated implementation. **Migration to new EVM operations utility:** * All imports and usages of `legacy/mcms/internal/family/evm/oputil` have been replaced with `mcms/evm/operations` across multiple files, including changes to type names and function calls. [[1]](diffhunk://#diff-b2398611f89ecae075cf3fa2ebc54fffdb5be3053e22ec48a758b897a3fe4f2eL24-R26) [[2]](diffhunk://#diff-d65ee785393e80500d9a9e10b6be88af9066f272f273b3a495ca51eb62bcf1caL14-R16) [[3]](diffhunk://#diff-01347b473bc84fecfbfd6e74fc8d3ceab6f5f46df817b98912390a91abded6e9L23-R24) [[4]](diffhunk://#diff-d06b9c5105af450ff38a3d1088e63930739725c5d769c418e049501f2a9ee774L12-R25) [[5]](diffhunk://#diff-bbc03c83b6d0480e7d8522c83792e93540a723fd77538ee68aa6f4680b91d026L14-R14) [[6]](diffhunk://#diff-2ba3562716d4f675ca494b4cdd289784a1a11084bf6819b9fe02e3b129822741L12-R20) [[7]](diffhunk://#diff-6e44b5b90b68ec00183f14c09ca6f134d53654e8ee03c3cfe811033a07ccdf1dL12-R12) [[8]](diffhunk://#diff-f7f4b27536717322f79551fe53d332068a4a60df6ec498e5b17a504932fe953cL12-R25) [[9]](diffhunk://#diff-af27581a8ad86d0f1ecc0da7328dd4557658d19be900e98f4cd95b8588c6b3f2L17-R18) [[10]](diffhunk://#diff-1fd84ce86f315635e347f82581e4070196a811f934685fa1a908b24d67089ffeL17-R18) * All usages of EVM operation types and functions (e.g., `EVMDeployInput`, `RetryDeploymentWithGasBoost`, `EVMCallOutput`, `NewEVMDeployOperation`, `NewEVMCallOperation`) have been updated to reference the new package, ensuring consistency and removing legacy dependencies. [[1]](diffhunk://#diff-d65ee785393e80500d9a9e10b6be88af9066f272f273b3a495ca51eb62bcf1caL204-R208) [[2]](diffhunk://#diff-d65ee785393e80500d9a9e10b6be88af9066f272f273b3a495ca51eb62bcf1caL245-R249) [[3]](diffhunk://#diff-b2398611f89ecae075cf3fa2ebc54fffdb5be3053e22ec48a758b897a3fe4f2eL259-R259) [[4]](diffhunk://#diff-b2398611f89ecae075cf3fa2ebc54fffdb5be3053e22ec48a758b897a3fe4f2eL271-R271) [[5]](diffhunk://#diff-01347b473bc84fecfbfd6e74fc8d3ceab6f5f46df817b98912390a91abded6e9L41-R47) [[6]](diffhunk://#diff-01347b473bc84fecfbfd6e74fc8d3ceab6f5f46df817b98912390a91abded6e9L59-R68) [[7]](diffhunk://#diff-01347b473bc84fecfbfd6e74fc8d3ceab6f5f46df817b98912390a91abded6e9L122-R122) [[8]](diffhunk://#diff-bbc03c83b6d0480e7d8522c83792e93540a723fd77538ee68aa6f4680b91d026L26-R32) [[9]](diffhunk://#diff-6e44b5b90b68ec00183f14c09ca6f134d53654e8ee03c3cfe811033a07ccdf1dL22-R22) [[10]](diffhunk://#diff-f7f4b27536717322f79551fe53d332068a4a60df6ec498e5b17a504932fe953cL35-R41) [[11]](diffhunk://#diff-f7f4b27536717322f79551fe53d332068a4a60df6ec498e5b17a504932fe953cL51-R57) [[12]](diffhunk://#diff-af27581a8ad86d0f1ecc0da7328dd4557658d19be900e98f4cd95b8588c6b3f2L48-R53) [[13]](diffhunk://#diff-af27581a8ad86d0f1ecc0da7328dd4557658d19be900e98f4cd95b8588c6b3f2L83-R94) [[14]](diffhunk://#diff-af27581a8ad86d0f1ecc0da7328dd4557658d19be900e98f4cd95b8588c6b3f2L122-R122) **Type and identifier updates:** * All relevant type references (e.g., `EVMCallOutput`, `EVMDeployInput`, operation variables) have been updated to use the new package, ensuring type compatibility and clarity. [[1]](diffhunk://#diff-01347b473bc84fecfbfd6e74fc8d3ceab6f5f46df817b98912390a91abded6e9L41-R47) [[2]](diffhunk://#diff-01347b473bc84fecfbfd6e74fc8d3ceab6f5f46df817b98912390a91abded6e9L59-R68) [[3]](diffhunk://#diff-01347b473bc84fecfbfd6e74fc8d3ceab6f5f46df817b98912390a91abded6e9L122-R122) [[4]](diffhunk://#diff-af27581a8ad86d0f1ecc0da7328dd4557658d19be900e98f4cd95b8588c6b3f2L48-R53) [[5]](diffhunk://#diff-af27581a8ad86d0f1ecc0da7328dd4557658d19be900e98f4cd95b8588c6b3f2L83-R94) [[6]](diffhunk://#diff-af27581a8ad86d0f1ecc0da7328dd4557658d19be900e98f4cd95b8588c6b3f2L122-R122) **Operation registration and execution:** * All operation variable assignments (e.g., `OpDeployCallProxy`, `OpDeployTimelock`, `OpGrantRole`, `OpEVMSetConfigMCM`, `OpDeployProposerMCM`, `OpDeployBypasserMCM`, `OpDeployCancellerMCM`) now use the new `operations` package for construction and configuration. [[1]](diffhunk://#diff-d06b9c5105af450ff38a3d1088e63930739725c5d769c418e049501f2a9ee774L12-R25) [[2]](diffhunk://#diff-bbc03c83b6d0480e7d8522c83792e93540a723fd77538ee68aa6f4680b91d026L26-R32) [[3]](diffhunk://#diff-2ba3562716d4f675ca494b4cdd289784a1a11084bf6819b9fe02e3b129822741L12-R20) [[4]](diffhunk://#diff-6e44b5b90b68ec00183f14c09ca6f134d53654e8ee03c3cfe811033a07ccdf1dL22-R22) [[5]](diffhunk://#diff-f7f4b27536717322f79551fe53d332068a4a60df6ec498e5b17a504932fe953cL35-R41) [[6]](diffhunk://#diff-f7f4b27536717322f79551fe53d332068a4a60df6ec498e5b17a504932fe953cL51-R57) This refactor ensures all EVM-related operations are routed through the updated, centralized utility, reducing technical debt and simplifying future maintenance. --------- Signed-off-by: Pablo Estrada <139084212+ecPablo@users.noreply.github.com> Co-authored-by: Graham Goh <graham.goh@smartcontract.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent e1a60bb commit c71b37c

15 files changed

Lines changed: 1484 additions & 0 deletions

File tree

mcms/changesets/doc.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Package changesets provides multi-family MCMS changesets.
2+
//
3+
// Start here when looking for a changeset to use. Each subdirectory is a
4+
// self-contained changeset with a chain-agnostic entrypoint ([Changeset], Config,
5+
// and optionally a registry for per-family sequences).
6+
//
7+
// # Multi-family changesets (this directory)
8+
//
9+
// - set-config — configure MCMS contracts across chains
10+
// - deploy — deploy the standard MCMS topology
11+
// - deploy-custom-topology — deploy an arbitrary MCMS topology
12+
// - transfer-to-timelock — transfer contract ownership to a timelock
13+
// - firedrill — MCMS firedrill operations
14+
//
15+
// Import path pattern:
16+
//
17+
// github.com/smartcontractkit/cld-changesets/mcms/changesets/<name>
18+
//
19+
// Blank-import the chain families you need, for example:
20+
//
21+
// _ "github.com/smartcontractkit/cld-changesets/mcms/evm/set-config"
22+
// _ "github.com/smartcontractkit/cld-changesets/mcms/solana/set-config"
23+
//
24+
// # Family-only changesets
25+
//
26+
// Some changesets are inherently specific to one chain family and have no
27+
// chain-agnostic wrapper. Solana-only changesets live under
28+
// mcms/solana/changesets (for example fund-mcm-pdas). EVM-only changesets
29+
// would follow mcms/evm/changesets if added in the future.
30+
//
31+
// Family implementation packages (mcms/evm/<name>, mcms/solana/<name>) contain
32+
// sequences and operations registered by multi-family changesets via init.
33+
// Solana-only changesets live under mcms/solana/changesets.
34+
package changesets

mcms/solana/changesets/doc.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Package changesets holds Solana-only MCMS changesets.
2+
//
3+
// Multi-family changesets (set-config, deploy, firedrill, and others) live under
4+
// mcms/changesets and register per-family implementations from mcms/solana/<name>
5+
// and mcms/evm/<name>. Solana-only changesets that have no chain-agnostic layer
6+
// — because the concept is inherently Solana-specific — live here instead.
7+
//
8+
// # Available changesets
9+
//
10+
// - fund-mcm-pdas — fund MCMS signer PDAs with lamports
11+
// (github.com/smartcontractkit/cld-changesets/mcms/solana/changesets/fund-mcm-pdas)
12+
//
13+
// Import path pattern:
14+
//
15+
// github.com/smartcontractkit/cld-changesets/mcms/solana/changesets/<name>
16+
package changesets
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
package fundmcmpdas
2+
3+
import (
4+
"errors"
5+
"fmt"
6+
7+
"github.com/smartcontractkit/chainlink-deployments-framework/changeset/sequenceutils"
8+
"github.com/smartcontractkit/chainlink-deployments-framework/datastore"
9+
cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment"
10+
11+
"github.com/smartcontractkit/cld-changesets/internal/maputil"
12+
)
13+
14+
var _ cldf.ChangeSetV2[Config] = Changeset{}
15+
16+
// Changeset funds MCMS signer PDAs on each configured Solana chain.
17+
type Changeset struct{}
18+
19+
func (Changeset) VerifyPreconditions(env cldf.Environment, config Config) error {
20+
if len(config.FundingPerChain) == 0 {
21+
return errors.New("no funding config provided")
22+
}
23+
24+
for chainSelector, chainCfg := range config.FundingPerChain {
25+
if _, ok := env.BlockChains.SolanaChains()[chainSelector]; !ok {
26+
return fmt.Errorf("solana chain %d not found in environment", chainSelector)
27+
}
28+
if err := validateMCMSRefs(env, chainSelector, chainCfg); err != nil {
29+
return err
30+
}
31+
if err := validateDeployerBalance(env, chainSelector, chainCfg); err != nil {
32+
return err
33+
}
34+
}
35+
36+
return nil
37+
}
38+
39+
func (Changeset) Apply(e cldf.Environment, config Config) (cldf.ChangesetOutput, error) {
40+
deps := Deps{
41+
BlockChains: e.BlockChains,
42+
DataStore: e.DataStore,
43+
}
44+
45+
var agg sequenceutils.OnChainOutput
46+
47+
for _, chainSelector := range maputil.SortedMapKeys(config.FundingPerChain) {
48+
chainCfg := config.FundingPerChain[chainSelector]
49+
50+
var mergeErr error
51+
agg, mergeErr = sequenceutils.ExecuteOnChainSequenceAndMerge(
52+
e.OperationsBundle,
53+
deps,
54+
SeqFundMCMPDAs,
55+
ChainInput{
56+
ChainSelector: chainSelector,
57+
FundingConfig: chainCfg,
58+
},
59+
agg,
60+
)
61+
if mergeErr != nil {
62+
return buildOutput(e, agg, mergeErr)
63+
}
64+
}
65+
66+
return buildOutput(e, agg, nil)
67+
}
68+
69+
func buildOutput(
70+
e cldf.Environment,
71+
agg sequenceutils.OnChainOutput,
72+
err error,
73+
) (cldf.ChangesetOutput, error) {
74+
ds := datastore.NewMemoryDataStore()
75+
if metaErr := ds.WriteMetadata(agg.Metadata); metaErr != nil {
76+
return cldf.ChangesetOutput{DataStore: ds},
77+
fmt.Errorf("failed to write metadata to datastore: %w", metaErr)
78+
}
79+
80+
partialOutput := cldf.ChangesetOutput{DataStore: ds}
81+
if err != nil {
82+
return partialOutput, err
83+
}
84+
85+
out, buildErr := cldf.NewOutputBuilder(e, ds).Build()
86+
if buildErr != nil {
87+
return out, fmt.Errorf("build changeset output: %w", buildErr)
88+
}
89+
90+
return out, nil
91+
}

0 commit comments

Comments
 (0)