@@ -88,150 +88,165 @@ var SetKeeperRegistrySequence = operations.NewSequence(
8888 "chains" , len (input .Chains ),
8989 )
9090
91- opReport , err := operations .ExecuteOperation (
92- b ,
93- SetKeeperRegistryOperation ,
94- deps ,
95- SetKeeperRegistryOperationInput {
96- Chains : input .Chains ,
97- },
98- )
91+ if len (input .Chains ) == 0 {
92+ return EthBalMonSetKeeperRegistryAddressSequenceOutput {}, fmt .Errorf ("no chains provided" )
93+ }
94+
95+ var batches []mcmstypes.BatchOperation
96+ timelockAddresses := make (map [mcmstypes.ChainSelector ]string )
97+ chainMetadata := make (map [mcmstypes.ChainSelector ]mcmstypes.ChainMetadata )
98+
99+ for chainSelector , chainConfig := range input .Chains {
100+ opReport , err := operations .ExecuteOperation (
101+ b ,
102+ SetKeeperRegistryOperation ,
103+ deps ,
104+ SetKeeperRegistryOperationInput {
105+ ChainSelector : chainSelector ,
106+ NewKeeperRegistryAddress : chainConfig .NewKeeperRegistryAddress ,
107+ },
108+ )
109+ if err != nil {
110+ return EthBalMonSetKeeperRegistryAddressSequenceOutput {},
111+ fmt .Errorf ("chain %d: failed to generate set keeper registry batch: %w" , chainSelector , err )
112+ }
113+
114+ opOut := opReport .Output
115+
116+ batches = append (batches , opOut .BatchOperation )
117+ timelockAddresses [mcmstypes .ChainSelector (chainSelector )] = opOut .TimelockAddress
118+ chainMetadata [mcmstypes .ChainSelector (chainSelector )] = mcmstypes.ChainMetadata {
119+ StartingOpCount : 0 ,
120+ MCMAddress : opOut .MCMSAddress ,
121+ }
122+ }
123+
124+ proposal , err := mcms .NewTimelockProposalBuilder ().
125+ SetVersion ("v1" ).
126+ SetAction (mcmstypes .TimelockActionBypass ).
127+ SetTimelockAddresses (timelockAddresses ).
128+ SetChainMetadata (chainMetadata ).
129+ SetOperations (batches ).
130+ SetDescription ("Set Keeper Registry address on EthBalanceMonitor across chains" ).
131+ Build ()
99132 if err != nil {
100133 return EthBalMonSetKeeperRegistryAddressSequenceOutput {},
101- fmt .Errorf ("failed to generate set keeper registry proposal: %w" , err )
134+ fmt .Errorf ("failed to build timelock proposal: %w" , err )
102135 }
103136
137+ b .Logger .Infow ("Generated EthBalMon set keeper registry proposal" ,
138+ "chains" , len (input .Chains ),
139+ "operations" , len (batches ),
140+ )
141+
104142 return EthBalMonSetKeeperRegistryAddressSequenceOutput {
105- MCMSTimelockProposals : opReport . Output . MCMSTimelockProposals ,
143+ MCMSTimelockProposals : []mcms. TimelockProposal { * proposal } ,
106144 }, nil
107145 },
108146)
109147
110148type SetKeeperRegistryOperationInput struct {
111- Chains map [uint64 ]vaulttypes.SetKeeperRegistryChainConfig `json:"chains"`
149+ ChainSelector uint64 `json:"chain_selector"`
150+ NewKeeperRegistryAddress string `json:"new_keeper_registry_address"`
112151}
113152
114153type SetKeeperRegistryOperationOutput struct {
115- MCMSTimelockProposals []mcms.TimelockProposal
154+ ChainSelector uint64
155+ BatchOperation mcmstypes.BatchOperation
156+ TimelockAddress string
157+ MCMSAddress string
116158}
117159
118160var SetKeeperRegistryOperation = operations .NewOperation (
119161 "ethbalmon-set-keeper-registry-op" ,
120162 semver .MustParse ("1.0.0" ),
121- "Generate proposal to set Keeper Registry address on the Ethereum Balance Monitor contract" ,
163+ "Generate batch operation to set Keeper Registry address on the Ethereum Balance Monitor contract" ,
122164 func (
123165 b operations.Bundle ,
124166 deps VaultDeps ,
125167 input SetKeeperRegistryOperationInput ,
126168 ) (SetKeeperRegistryOperationOutput , error ) {
127- if len (input .Chains ) == 0 {
128- return SetKeeperRegistryOperationOutput {}, fmt .Errorf ("no chains provided" )
169+ chain , ok := deps .Environment .BlockChains .EVMChains ()[input .ChainSelector ]
170+ if ! ok {
171+ return SetKeeperRegistryOperationOutput {}, fmt .Errorf ("chain not found in environment: %d" , input .ChainSelector )
129172 }
130173
131- var batches []mcmstypes.BatchOperation
132- timelockAddresses := make (map [mcmstypes.ChainSelector ]string )
133- chainMetadata := make (map [mcmstypes.ChainSelector ]mcmstypes.ChainMetadata )
134-
135- evmChains := deps .Environment .BlockChains .EVMChains ()
136-
137- // Move this to the sequence
138- for chainSelector , chainConfig := range input .Chains {
139- chain , ok := evmChains [chainSelector ]
140- if ! ok {
141- return SetKeeperRegistryOperationOutput {}, fmt .Errorf ("chain not found in environment: %d" , chainSelector )
142- }
143-
144- ethBalMonAddr , err := mustGetContractAddress (
145- deps .DataStore ,
146- chainSelector ,
147- cldf .ContractType (vaulttypes .ETHBALMON_CONTRACT_TYPE ),
148- )
149- if err != nil {
150- return SetKeeperRegistryOperationOutput {},
151- fmt .Errorf ("chain %d: failed to get EthBalMon address: %w" , chainSelector , err )
152- }
174+ ethBalMonAddr , err := mustGetContractAddress (
175+ deps .DataStore ,
176+ input .ChainSelector ,
177+ cldf .ContractType (vaulttypes .ETHBALMON_CONTRACT_TYPE ),
178+ )
179+ if err != nil {
180+ return SetKeeperRegistryOperationOutput {},
181+ fmt .Errorf ("failed to get EthBalMon address: %w" , err )
182+ }
153183
154- timelockAddr , err := mustGetContractAddress (
155- deps .DataStore ,
156- chainSelector ,
157- commontypes .RBACTimelock ,
158- )
159- if err != nil {
160- return SetKeeperRegistryOperationOutput {},
161- fmt .Errorf ("chain %d: failed to get timelock address: %w" , chainSelector , err )
162- }
184+ timelockAddr , err := mustGetContractAddress (
185+ deps .DataStore ,
186+ input . ChainSelector ,
187+ commontypes .RBACTimelock ,
188+ )
189+ if err != nil {
190+ return SetKeeperRegistryOperationOutput {},
191+ fmt .Errorf ("failed to get timelock address: %w" , err )
192+ }
163193
164- mcmsAddr , err := mustGetContractAddress (
165- deps .DataStore ,
166- chainSelector ,
167- commontypes .ManyChainMultisig ,
168- )
169- if err != nil {
170- return SetKeeperRegistryOperationOutput {},
171- fmt .Errorf ("chain %d: failed to get MCMS address: %w" , chainSelector , err )
172- }
194+ mcmsAddr , err := mustGetContractAddress (
195+ deps .DataStore ,
196+ input . ChainSelector ,
197+ commontypes .ManyChainMultisig ,
198+ )
199+ if err != nil {
200+ return SetKeeperRegistryOperationOutput {},
201+ fmt .Errorf ("failed to get MCMS address: %w" , err )
202+ }
173203
174- ethBalMon , err := eth_balance_monitor_wrapper .NewEthBalanceMonitor (
175- common .HexToAddress (ethBalMonAddr ),
176- chain .Client ,
177- )
178- if err != nil {
179- return SetKeeperRegistryOperationOutput {},
180- fmt .Errorf ("chain %d: failed to instantiate EthBalanceMonitor at %s: %w" , chainSelector , ethBalMonAddr , err )
181- }
204+ ethBalMon , err := eth_balance_monitor_wrapper .NewEthBalanceMonitor (
205+ common .HexToAddress (ethBalMonAddr ),
206+ chain .Client ,
207+ )
208+ if err != nil {
209+ return SetKeeperRegistryOperationOutput {},
210+ fmt .Errorf ("failed to instantiate EthBalanceMonitor at %s: %w" , ethBalMonAddr , err )
211+ }
182212
183- setKeeperRegistryTx , err := ethBalMon .SetKeeperRegistryAddress (
184- cldf .SimTransactOpts (),
185- common .HexToAddress (chainConfig .NewKeeperRegistryAddress ),
186- )
187- if err != nil {
188- return SetKeeperRegistryOperationOutput {},
189- fmt .Errorf ("chain %d: failed to generate setKeeperRegistryAddress calldata: %w" , chainSelector , err )
190- }
213+ setKeeperRegistryTx , err := ethBalMon .SetKeeperRegistryAddress (
214+ cldf .SimTransactOpts (),
215+ common .HexToAddress (input .NewKeeperRegistryAddress ),
216+ )
217+ if err != nil {
218+ return SetKeeperRegistryOperationOutput {},
219+ fmt .Errorf ("failed to generate setKeeperRegistryAddress calldata: %w" , err )
220+ }
191221
192- batches = append (batches , mcmstypes.BatchOperation {
193- ChainSelector : mcmstypes .ChainSelector (chainSelector ),
194- Transactions : []mcmstypes.Transaction {
195- {
196- OperationMetadata : mcmstypes.OperationMetadata {
197- ContractType : vaulttypes .ETHBALMON_CONTRACT_TYPE ,
198- Tags : []string {
199- "setKeeperRegistryAddress" ,
200- },
222+ batch := mcmstypes.BatchOperation {
223+ ChainSelector : mcmstypes .ChainSelector (input .ChainSelector ),
224+ Transactions : []mcmstypes.Transaction {
225+ {
226+ OperationMetadata : mcmstypes.OperationMetadata {
227+ ContractType : vaulttypes .ETHBALMON_CONTRACT_TYPE ,
228+ Tags : []string {
229+ "setKeeperRegistryAddress" ,
201230 },
202- To : ethBalMonAddr ,
203- Data : setKeeperRegistryTx .Data (),
204- AdditionalFields : json .RawMessage (`{"value": 0}` ),
205231 },
232+ To : ethBalMonAddr ,
233+ Data : setKeeperRegistryTx .Data (),
234+ AdditionalFields : json .RawMessage (`{"value": 0}` ),
206235 },
207- })
208-
209- timelockAddresses [mcmstypes .ChainSelector (chainSelector )] = timelockAddr
210- chainMetadata [mcmstypes .ChainSelector (chainSelector )] = mcmstypes.ChainMetadata {
211- StartingOpCount : 0 ,
212- MCMAddress : mcmsAddr ,
213- }
214- }
215-
216- proposal , err := mcms .NewTimelockProposalBuilder ().
217- SetVersion ("v1" ).
218- SetAction (mcmstypes .TimelockActionBypass ).
219- SetTimelockAddresses (timelockAddresses ).
220- SetChainMetadata (chainMetadata ).
221- SetOperations (batches ).
222- SetDescription ("Set Keeper Registry address on EthBalanceMonitor across chains" ).
223- Build ()
224- if err != nil {
225- return SetKeeperRegistryOperationOutput {}, fmt .Errorf ("failed to build timelock proposal: %w" , err )
236+ },
226237 }
227238
228- b .Logger .Infow ("Generated EthBalMon set keeper registry proposal" ,
229- "chains" , len (input .Chains ),
230- "operations" , len (batches ),
239+ b .Logger .Infow ("Generated EthBalMon set keeper registry batch" ,
240+ "chainSelector" , input .ChainSelector ,
241+ "ethBalMon" , ethBalMonAddr ,
242+ "newKeeperRegistry" , input .NewKeeperRegistryAddress ,
231243 )
232244
233245 return SetKeeperRegistryOperationOutput {
234- MCMSTimelockProposals : []mcms.TimelockProposal {* proposal },
246+ ChainSelector : input .ChainSelector ,
247+ BatchOperation : batch ,
248+ TimelockAddress : timelockAddr ,
249+ MCMSAddress : mcmsAddr ,
235250 }, nil
236251 },
237252)
0 commit comments