@@ -29,7 +29,6 @@ type UpdateFeeQuoterInput struct {
2929}
3030
3131type UpdateFeeQuoterInputPerChain struct {
32- PopulateConfig bool
3332 ImportFeeQuoterConfigFromVersions []* semver.Version
3433 FeeQuoterVersion * semver.Version
3534 RampsVersion * semver.Version
@@ -143,6 +142,7 @@ func NewFQUpdaterRegistry() *FQAndRampUpdaterRegistry {
143142 return & FQAndRampUpdaterRegistry {
144143 FeeQuoterUpdater : make (map [string ]FeeQuoterUpdater [any ]),
145144 RampUpdater : make (map [string ]RampUpdater ),
145+ ConfigImporter : make (map [string ]ConfigImporter ),
146146 }
147147}
148148
@@ -157,7 +157,7 @@ func GetFQAndRampUpdaterRegistry() *FQAndRampUpdaterRegistry {
157157// It first optionally populates configuration values, then creates FeeQuoterUpdateInput,
158158// deploys or updates the FeeQuoter contract, and finally updates the Ramps contracts to use the new FeeQuoter address.
159159// If needed, it also updates OffRamp source chain configs ( specifically used when during updating feequoter only specific source chain needs to be added to offramp).
160- func UpdateFeeQuoterChangeset (mcmsRegistry * changesets. MCMSReaderRegistry , fquRegistry * FQAndRampUpdaterRegistry ) cldf.ChangeSetV2 [UpdateFeeQuoterInput ] {
160+ func UpdateFeeQuoterChangeset (fquRegistry * FQAndRampUpdaterRegistry , mcmsRegistry * changesets. MCMSReaderRegistry ) cldf.ChangeSetV2 [UpdateFeeQuoterInput ] {
161161 return cldf .CreateChangeSet (updateFeeQuoterApply (fquRegistry , mcmsRegistry ), updateFeeQuoterVerify (fquRegistry , mcmsRegistry ))
162162}
163163
@@ -194,41 +194,36 @@ func updateFeeQuoterApply(fquRegistry *FQAndRampUpdaterRegistry, mcmsRegistry *c
194194 return cldf.ChangesetOutput {}, utils .ErrNoAdapterRegistered ("RampUpdater" , perChainInput .RampsVersion )
195195 }
196196 contractMeta := e .DataStore .ContractMetadata ().Filter (datastore .ContractMetadataByChainSelector (chainSel ))
197- // If PopulateConfig is true, need to first populate config values in contract metadata
198- // otherwise proceed to create FeeQuoterUpdateInput directly from existing contract metadata - in this case
199- // we assume that the config values are already present in the contract metadata
200- if perChainInput .PopulateConfig {
201- for _ , version := range perChainInput .ImportFeeQuoterConfigFromVersions {
202- configImporter , ok := fquRegistry .GetConfigImporter (chainSel , version )
203- if ! ok {
204- return cldf.ChangesetOutput {}, utils .ErrNoAdapterRegistered ("ConfigImporter" , perChainInput .FeeQuoterVersion )
205- }
206- err := configImporter .InitializeAdapter (e , chainSel )
207- if err != nil {
208- return cldf.ChangesetOutput {}, fmt .Errorf ("failed to initialize config importer for chain %d: %w" , chainSel , err )
209- }
210- supportedTokensPerRemoteChain , err := configImporter .SupportedTokensPerRemoteChain (e , chainSel )
211- if err != nil {
212- return cldf.ChangesetOutput {}, fmt .Errorf ("failed to get supported tokens per remote chain for chain %d: %w" , chainSel , err )
213- }
214- connectedChains , err := configImporter .ConnectedChains (e , chainSel )
215- if err != nil {
216- return cldf.ChangesetOutput {}, fmt .Errorf ("failed to get connected chains for chain %d: %w" , chainSel , err )
217- }
218- populateConfigReport , err := cldf_ops .ExecuteSequence (e .OperationsBundle , configImporter .SequenceImportConfig (), e .BlockChains , ImportConfigPerChainInput {
219- ChainSelector : chainSel ,
220- RemoteChains : connectedChains ,
221- TokensPerRemoteChain : supportedTokensPerRemoteChain ,
222- })
223- if err != nil {
224- return cldf.ChangesetOutput {}, fmt .Errorf ("failed to populate config for FeeQuoter on chain %d: %w" , chainSel , err )
225- }
226- if len (populateConfigReport .Output .Metadata .Contracts ) == 0 {
227- return cldf.ChangesetOutput {}, fmt .Errorf ("no contract metadata returned from populate config for FeeQuoter on chain %d" , chainSel )
228- }
229- contractMeta = append (contractMeta , populateConfigReport .Output .Metadata .Contracts ... )
230- contractMetadata = append (contractMetadata , populateConfigReport .Output .Metadata .Contracts ... )
197+ for _ , version := range perChainInput .ImportFeeQuoterConfigFromVersions {
198+ configImporter , ok := fquRegistry .GetConfigImporter (chainSel , version )
199+ if ! ok {
200+ return cldf.ChangesetOutput {}, utils .ErrNoAdapterRegistered ("ConfigImporter" , perChainInput .FeeQuoterVersion )
231201 }
202+ err := configImporter .InitializeAdapter (e , chainSel )
203+ if err != nil {
204+ return cldf.ChangesetOutput {}, fmt .Errorf ("failed to initialize config importer for chain %d: %w" , chainSel , err )
205+ }
206+ supportedTokensPerRemoteChain , err := configImporter .SupportedTokensPerRemoteChain (e , chainSel )
207+ if err != nil {
208+ return cldf.ChangesetOutput {}, fmt .Errorf ("failed to get supported tokens per remote chain for chain %d: %w" , chainSel , err )
209+ }
210+ connectedChains , err := configImporter .ConnectedChains (e , chainSel )
211+ if err != nil {
212+ return cldf.ChangesetOutput {}, fmt .Errorf ("failed to get connected chains for chain %d: %w" , chainSel , err )
213+ }
214+ populateConfigReport , err := cldf_ops .ExecuteSequence (e .OperationsBundle , configImporter .SequenceImportConfig (), e .BlockChains , ImportConfigPerChainInput {
215+ ChainSelector : chainSel ,
216+ RemoteChains : connectedChains ,
217+ TokensPerRemoteChain : supportedTokensPerRemoteChain ,
218+ })
219+ if err != nil {
220+ return cldf.ChangesetOutput {}, fmt .Errorf ("failed to populate config for FeeQuoter on chain %d: %w" , chainSel , err )
221+ }
222+ if len (populateConfigReport .Output .Metadata .Contracts ) == 0 {
223+ return cldf.ChangesetOutput {}, fmt .Errorf ("no contract metadata returned from populate config for FeeQuoter on chain %d" , chainSel )
224+ }
225+ contractMeta = append (contractMeta , populateConfigReport .Output .Metadata .Contracts ... )
226+ contractMetadata = append (contractMetadata , populateConfigReport .Output .Metadata .Contracts ... )
232227 }
233228 // Create FeeQuoterUpdateInput
234229 reportFQInputCreation , err := cldf_ops .ExecuteSequence (e .OperationsBundle , fquUpdater .SequenceFeeQuoterInputCreation (), e .BlockChains , FeeQuoterUpdateInput {
@@ -253,27 +248,29 @@ func updateFeeQuoterApply(fquRegistry *FQAndRampUpdaterRegistry, mcmsRegistry *c
253248 // Update Ramps with new FeeQuoter address
254249 // fetch the address refs
255250 feeQuoterAddrRef := reportFQUpdate .Output .Addresses [len (reportFQUpdate .Output .Addresses )- 1 ]
256- rampsInput := UpdateRampsInput {
257- ChainSelector : chainSel ,
258- FeeQuoterAddress : feeQuoterAddrRef ,
259- SourceChains : make (map [uint64 ]SourceChainConfig ),
260- }
261- for _ , srcChainSel := range perChainInput .SourceChainAddsToOffRamp {
262- rampsInput .SourceChains [srcChainSel ] = SourceChainConfig {}
263- }
264- // Resolve Ramps input
265- resolvedRampsInput , err := rampUpdater .ResolveRampsInput (e , rampsInput )
266- if err != nil {
267- return cldf.ChangesetOutput {}, fmt .Errorf ("failed to resolve ramps input for chain %d: %w" , chainSel , err )
268- }
269- // Execute Ramps update sequence
270- reportRampsUpdate , err := cldf_ops .ExecuteSequence (e .OperationsBundle , rampUpdater .SequenceUpdateRampsWithFeeQuoter (), e .BlockChains , resolvedRampsInput )
271- if err != nil {
272- return cldf.ChangesetOutput {}, fmt .Errorf ("failed to update ramps with FeeQuoter for chain %d: %w" , chainSel , err )
251+ if perChainInput .RampsVersion != nil {
252+ rampsInput := UpdateRampsInput {
253+ ChainSelector : chainSel ,
254+ FeeQuoterAddress : feeQuoterAddrRef ,
255+ SourceChains : make (map [uint64 ]SourceChainConfig ),
256+ }
257+ for _ , srcChainSel := range perChainInput .SourceChainAddsToOffRamp {
258+ rampsInput .SourceChains [srcChainSel ] = SourceChainConfig {}
259+ }
260+ // Resolve Ramps input
261+ resolvedRampsInput , err := rampUpdater .ResolveRampsInput (e , rampsInput )
262+ if err != nil {
263+ return cldf.ChangesetOutput {}, fmt .Errorf ("failed to resolve ramps input for chain %d: %w" , chainSel , err )
264+ }
265+ // Execute Ramps update sequence
266+ reportRampsUpdate , err := cldf_ops .ExecuteSequence (e .OperationsBundle , rampUpdater .SequenceUpdateRampsWithFeeQuoter (), e .BlockChains , resolvedRampsInput )
267+ if err != nil {
268+ return cldf.ChangesetOutput {}, fmt .Errorf ("failed to update ramps with FeeQuoter for chain %d: %w" , chainSel , err )
269+ }
270+ batchOps = append (batchOps , reportRampsUpdate .Output .BatchOps ... )
271+ addressRefs = append (addressRefs , reportRampsUpdate .Output .Addresses ... )
272+ reports = append (reports , reportRampsUpdate .ExecutionReports ... )
273273 }
274- batchOps = append (batchOps , reportRampsUpdate .Output .BatchOps ... )
275- addressRefs = append (addressRefs , reportRampsUpdate .Output .Addresses ... )
276- reports = append (reports , reportRampsUpdate .ExecutionReports ... )
277274 }
278275 // Prepare datastore with all address refs
279276 ds := datastore .NewMemoryDataStore ()
0 commit comments