Skip to content

Commit d9fd9f2

Browse files
committed
fix: use new gas boost types and use familyregistry
1 parent 0594dd9 commit d9fd9f2

9 files changed

Lines changed: 105 additions & 201 deletions

File tree

mcms/changesets/deploy-custom-topology/changeset.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func (Changeset) Apply(e cldf.Environment, input Input) (cldf.ChangesetOutput, e
4343
var agg sequenceutils.OnChainOutput
4444

4545
for _, chainSelector := range maputil.SortedMapKeys(input.Cfg.ChainConfigs) {
46-
seq, seqErr := Sequences.SequenceForChainSelector(chainSelector)
46+
seq, seqErr := Registry.SequenceForChainSelector(chainSelector)
4747
if seqErr != nil {
4848
return buildOutput(e, input.Cfg, input.MCMS, agg, fmt.Errorf("chain selector %d: %w", chainSelector, seqErr))
4949
}
@@ -159,7 +159,7 @@ func validateConfig(e cldf.Environment, cfg Config, mcms *cldf.MCMSTimelockPropo
159159
slices.Sort(families)
160160

161161
for _, family := range families {
162-
if err := Sequences.VerifyForFamily(family, e, byFamily[family]); err != nil {
162+
if err := Registry.VerifyForFamily(family, e, byFamily[family]); err != nil {
163163
return err
164164
}
165165
}

mcms/changesets/deploy-custom-topology/changeset_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ var fakeEVMTopologySeq = operations.NewSequence(
6161
)
6262

6363
func init() {
64-
Sequences.Register(Registration{Family: chain_selectors.FamilyEVM, Sequence: fakeEVMTopologySeq})
64+
Registry.Register(Registration{Family: chain_selectors.FamilyEVM, Sequence: fakeEVMTopologySeq})
6565
}
6666

6767
func testEnv(t *testing.T) cldf.Environment {

mcms/changesets/deploy-custom-topology/doc.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,18 @@
4242
// Implement a family under mcms/<family>/deploy-custom-topology and register it at
4343
// process startup. Follow this layout:
4444
//
45-
// - register.go — exports Registration() and calls [Register] in init()
45+
// - register.go — exports Registration() and calls [Registry.Register] in init()
4646
// - sequence.go — operations.Sequence that deploys the topology for one chain
4747
// - addresses.go — datastore ref resolution / AddressRef construction
4848
// - extra_args.go — optional, parses family-specific [ChainTopologyConfig.ExtraArgs]
4949
//
5050
// The sequence must match [Sequence]: it receives [ChainInput] and [Deps] and returns
5151
// [sequenceutils.OnChainOutput].
5252
//
53+
// Register at startup from init (recommended, mirrors EVM and Solana):
54+
//
55+
// func init() { deploycustomtopology.Registry.Register(Registration()) }
56+
//
5357
// Each family may only be registered once; duplicate registration panics. Use
54-
// [Sequences.RegisteredFamilies] to inspect the registry in tests.
58+
// [Registry.RegisteredFamilies] to inspect the registry in tests.
5559
package deploycustomtopology
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package deploycustomtopology
22

33
import (
4-
"github.com/smartcontractkit/cld-changesets/mcms/changesets/familyregistry"
4+
"github.com/smartcontractkit/cld-changesets/internal/familyregistry"
55
)
66

7-
// Sequences is the deploy-custom-topology family sequence registry.
8-
var Sequences = familyregistry.New[Sequence, ChainInput](familyregistry.Options{
9-
Name: "deploy-custom-topology",
10-
NoneRegisteredHint: "blank-import mcms/<family>/deploy-custom-topology or mcms/changesets/deploy-custom-topology/all",
11-
})
7+
// Registration describes one chain family's deploy-custom-topology implementation.
8+
type Registration = familyregistry.Registration[Sequence, ChainInput]
9+
10+
// Registry holds per-family deploy-custom-topology sequences.
11+
var Registry = familyregistry.New[Sequence, ChainInput]("mcms deploy-custom-topology")

mcms/changesets/deploy-custom-topology/registry_test.go

Lines changed: 62 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import (
1111
"github.com/smartcontractkit/chainlink-deployments-framework/changeset/sequenceutils"
1212
cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment"
1313
"github.com/smartcontractkit/chainlink-deployments-framework/operations"
14+
15+
"github.com/smartcontractkit/cld-changesets/internal/familyregistry"
1416
)
1517

1618
func testSequence(id string) *Sequence {
@@ -24,19 +26,39 @@ func testSequence(id string) *Sequence {
2426
)
2527
}
2628

29+
func newTestRegistry() *familyregistry.Registry[Sequence, ChainInput] {
30+
return familyregistry.New[Sequence, ChainInput]("test deploy-custom-topology")
31+
}
32+
2733
func TestSequenceForChainSelector(t *testing.T) {
2834
t.Parallel()
2935

30-
_, err := Sequences.SequenceForChainSelector(0)
31-
require.Error(t, err)
36+
reg := newTestRegistry()
37+
38+
tests := []struct {
39+
name string
40+
chainSelector uint64
41+
}{
42+
{name: "invalid selector", chainSelector: 0},
43+
}
44+
45+
for _, tt := range tests {
46+
t.Run(tt.name, func(t *testing.T) {
47+
t.Parallel()
48+
49+
_, err := reg.SequenceForChainSelector(tt.chainSelector)
50+
require.Error(t, err)
51+
})
52+
}
3253
}
3354

3455
func TestRegister_andLookup(t *testing.T) {
3556
t.Parallel()
3657

37-
const family = "test-topology-family-a"
58+
reg := newTestRegistry()
59+
const family = "test-deploy-custom-topology-family-a"
3860

39-
Sequences.Register(Registration{
61+
reg.Register(Registration{
4062
Family: family,
4163
Sequence: testSequence("test-topology-seq-a"),
4264
Verify: func(_ cldf.Environment, chains []ChainInput) error {
@@ -48,9 +70,9 @@ func TestRegister_andLookup(t *testing.T) {
4870
},
4971
})
5072

51-
require.Contains(t, Sequences.RegisteredFamilies(), family)
73+
require.Contains(t, reg.RegisteredFamilies(), family)
5274

53-
seq, err := Sequences.SequenceForFamily(family)
75+
seq, err := reg.SequenceForFamily(family)
5476
require.NoError(t, err)
5577
require.NotNil(t, seq)
5678

@@ -67,7 +89,7 @@ func TestRegister_andLookup(t *testing.T) {
6789
t.Run(tt.name, func(t *testing.T) {
6890
t.Parallel()
6991

70-
err := Sequences.VerifyForFamily(family, cldf.Environment{}, tt.chains)
92+
err := reg.VerifyForFamily(family, cldf.Environment{}, tt.chains)
7193
if tt.wantErr {
7294
require.Error(t, err)
7395
return
@@ -81,49 +103,68 @@ func TestRegister_andLookup(t *testing.T) {
81103
func TestRegister_validationPanics(t *testing.T) {
82104
t.Parallel()
83105

106+
reg := newTestRegistry()
107+
84108
tests := []struct {
85109
name string
86110
reg Registration
87111
}{
88112
{name: "empty family", reg: Registration{Family: "", Sequence: testSequence("empty-family")}},
89-
{name: "nil sequence", reg: Registration{Family: "test-topology-family-b", Sequence: nil}},
113+
{name: "nil sequence", reg: Registration{Family: "test-deploy-custom-topology-family-b", Sequence: nil}},
90114
}
91115

92116
for _, tt := range tests {
93117
t.Run(tt.name, func(t *testing.T) {
94118
t.Parallel()
95-
require.Panics(t, func() { Sequences.Register(tt.reg) })
119+
require.Panics(t, func() { reg.Register(tt.reg) })
96120
})
97121
}
98122
}
99123

100124
func TestRegister_duplicatePanics(t *testing.T) {
101125
t.Parallel()
102126

103-
const family = "test-topology-family-c"
104-
Sequences.Register(Registration{Family: family, Sequence: testSequence("test-topology-seq-c")})
127+
reg := newTestRegistry()
128+
const family = "test-deploy-custom-topology-family-c"
129+
reg.Register(Registration{Family: family, Sequence: testSequence("test-topology-seq-c")})
105130

106131
require.Panics(t, func() {
107-
Sequences.Register(Registration{Family: family, Sequence: testSequence("test-topology-seq-c-dup")})
132+
reg.Register(Registration{Family: family, Sequence: testSequence("test-topology-seq-c-dup")})
108133
})
109134
}
110135

111136
func TestSequenceForFamily_errors(t *testing.T) {
112137
t.Parallel()
113138

114-
const family = "test-topology-family-missing"
115-
_, err := Sequences.SequenceForFamily(family)
116-
require.ErrorContains(t, err, fmt.Sprintf(`no sequence registered for family %q`, family))
139+
reg := newTestRegistry()
140+
141+
tests := []struct {
142+
name string
143+
family string
144+
}{
145+
{name: "missing family", family: "test-deploy-custom-topology-family-missing"},
146+
}
147+
148+
for _, tt := range tests {
149+
t.Run(tt.name, func(t *testing.T) {
150+
t.Parallel()
151+
152+
_, err := reg.SequenceForFamily(tt.family)
153+
require.ErrorContains(t, err, fmt.Sprintf(`no sequence registered for family %q`, tt.family))
154+
})
155+
}
117156
}
118157

119158
func TestVerifyForFamily(t *testing.T) {
120159
t.Parallel()
121160

122-
const nilHookFamily = "test-topology-family-d"
123-
Sequences.Register(Registration{Family: nilHookFamily, Sequence: testSequence("test-topology-seq-d")})
161+
reg := newTestRegistry()
162+
163+
const nilHookFamily = "test-deploy-custom-topology-family-d"
164+
reg.Register(Registration{Family: nilHookFamily, Sequence: testSequence("test-topology-seq-d")})
124165

125-
const wrapFamily = "test-topology-family-e"
126-
Sequences.Register(Registration{
166+
const wrapFamily = "test-deploy-custom-topology-family-e"
167+
reg.Register(Registration{
127168
Family: wrapFamily,
128169
Sequence: testSequence("test-topology-seq-e"),
129170
Verify: func(_ cldf.Environment, _ []ChainInput) error {
@@ -137,7 +178,7 @@ func TestVerifyForFamily(t *testing.T) {
137178
chains []ChainInput
138179
wantErr string
139180
}{
140-
{name: "missing family", family: "test-topology-family-missing-verify", wantErr: "no sequence registered for family"},
181+
{name: "missing family", family: "test-deploy-custom-topology-family-missing-verify", wantErr: "no sequence registered for family"},
141182
{name: "nil verify hook", family: nilHookFamily},
142183
{name: "wrapped verify error", family: wrapFamily, chains: []ChainInput{{ChainSelector: 1}}, wantErr: "boom"},
143184
}
@@ -146,7 +187,7 @@ func TestVerifyForFamily(t *testing.T) {
146187
t.Run(tt.name, func(t *testing.T) {
147188
t.Parallel()
148189

149-
err := Sequences.VerifyForFamily(tt.family, cldf.Environment{}, tt.chains)
190+
err := reg.VerifyForFamily(tt.family, cldf.Environment{}, tt.chains)
150191
if tt.wantErr == "" {
151192
require.NoError(t, err)
152193
return

mcms/changesets/deploy-custom-topology/types.go

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@ import (
66
"github.com/ethereum/go-ethereum/common"
77

88
"github.com/smartcontractkit/chainlink-deployments-framework/chain"
9+
opscontract "github.com/smartcontractkit/chainlink-deployments-framework/chain/evm/operations2/contract"
910
"github.com/smartcontractkit/chainlink-deployments-framework/changeset/sequenceutils"
1011
cldfdatastore "github.com/smartcontractkit/chainlink-deployments-framework/datastore"
1112
cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment"
12-
cldfproposalutils "github.com/smartcontractkit/chainlink-deployments-framework/engine/cld/mcms/proposalutils"
1313
"github.com/smartcontractkit/chainlink-deployments-framework/operations"
1414
mcmstypes "github.com/smartcontractkit/mcms/types"
15-
16-
"github.com/smartcontractkit/cld-changesets/mcms/changesets/familyregistry"
1715
)
1816

1917
// Config is the changeset payload: the custom MCMS topology to deploy per chain.
@@ -31,9 +29,9 @@ type MCMSTopologyConfig struct {
3129

3230
// ChainTopologyConfig describes the MCMS topology to deploy on a single chain.
3331
type ChainTopologyConfig struct {
34-
MCMs []MCMSpec `json:"mcms"`
35-
Timelocks []TimelockSpec `json:"timelocks"`
36-
GasBoostConfig *cldfproposalutils.GasBoostConfig `json:"gasBoostConfig,omitempty"`
32+
MCMs []MCMSpec `json:"mcms"`
33+
Timelocks []TimelockSpec `json:"timelocks"`
34+
GasBoostConfig *opscontract.GasBoostConfig `json:"gasBoostConfig,omitempty"`
3735

3836
// ExtraArgs carries chain-family-specific input that the default per-chain
3937
// parameters above cannot express. It is forwarded verbatim to the family
@@ -119,9 +117,6 @@ type Deps struct {
119117
// Sequence is the required operations sequence type for all family implementations.
120118
type Sequence = operations.Sequence[ChainInput, sequenceutils.OnChainOutput, Deps]
121119

122-
// Registration describes one chain family's deploy-custom-topology implementation.
123-
type Registration = familyregistry.Registration[Sequence, ChainInput]
124-
125120
// EnvFromDeps reconstructs the environment fields sequences need for ref and
126121
// MCMS resolution.
127122
func EnvFromDeps(deps Deps) cldf.Environment {

0 commit comments

Comments
 (0)