Skip to content
This repository was archived by the owner on Mar 14, 2025. It is now read-only.

Detect onramp dynamic config changes#544

Merged
jarnaud merged 27 commits intoccip-developfrom
CCIP-1646
Mar 6, 2024
Merged

Detect onramp dynamic config changes#544
jarnaud merged 27 commits intoccip-developfrom
CCIP-1646

Conversation

@jarnaud
Copy link
Contributor

@jarnaud jarnaud commented Feb 22, 2024

Motivation

If onRamp price getter configuration changes, the exec plugin won't be notified and we will need to restart the plugin manually.

Solution

  • dynamically get the proper priceregistry from the onChain when needed (if its address changed in the onchain config).
  • replaced the sourcePriceRegistry by a provider in the exec report plugin.

@jarnaud jarnaud self-assigned this Feb 22, 2024
@jarnaud jarnaud added do not merge Do not merge at this time and removed do not merge Do not merge at this time labels Feb 22, 2024
@jarnaud jarnaud marked this pull request as ready for review February 23, 2024 13:52
@jarnaud jarnaud requested a review from a team as a code owner February 23, 2024 13:52
Copy link
Contributor

@mateusz-sekara mateusz-sekara left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would love to see some tests for that ;)

@jarnaud jarnaud requested a review from mateusz-sekara March 5, 2024 09:12
Copy link
Contributor

@mateusz-sekara mateusz-sekara left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have a dedicated test suite for that logic?

@mateusz-sekara mateusz-sekara self-requested a review March 5, 2024 13:15
@jarnaud jarnaud requested a review from mateusz-sekara March 5, 2024 14:04
@jarnaud jarnaud merged commit 9442992 into ccip-develop Mar 6, 2024
@jarnaud jarnaud deleted the CCIP-1646 branch March 6, 2024 09:34
}

// Ensure that the source price registry is synchronized with the onRamp.
if err = r.ensurePriceRegistrySynchronization(ctx); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this call be made when the observation round starts?
Otherwise we might miss price registry getting synchronized.
For example going one step back:

	if len(unexpiredReports) == 0 {
		return []ccip.ObservedMessage{}, nil
	}

	getExecTokenData := cache.LazyFunction[execTokenData](func() (execTokenData, error) {
		return r.prepareTokenExecData(ctx)
	})

in that case prepareTokenExecData and eventually ensurePriceRegistrySynchronization are never called.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created another PR to move the sync code: https://github.com/smartcontractkit/ccip/pull/586/files

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in that case prepareTokenExecData and eventually ensurePriceRegistrySynchronization are never called.

@dimkouv @jarnaud why is that a problem? At this moment, the source price registry is used only in a single place, so what's the point of eagerly synchronizing that? I understand that in case of adding any other reference to the source price registry might end up trying to call stale object.

GetDynamicConfig() (OnRampDynamicConfig, error)

// SourcePriceRegistryAddress returns the address of the current price registry configured on the onRamp.
SourcePriceRegistryAddress(ctx context.Context) (Address, error)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be include under chainlink-common:
https://github.com/smartcontractkit/chainlink-common/tree/main/pkg/types/ccip

I will get rid of cciptypes package and import chainlink-common very soon

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This refactoring doesn't seem immediately related to this ticket

sendRequestedEventSig: CCIPSendRequestEventSig,
cachedSourcePriceRegistryAddress: cache.NewLogpollerEventsBased[cciptypes.Address](
sourceLP,
[]common.Hash{abihelpers.MustGetEventID("ConfigSet", onRampABI)},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lot's of "ConfigSet". Can we use a constant?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, added some const here: #586

asoliman92 pushed a commit that referenced this pull request Jul 31, 2024
## Motivation

If onRamp price getter configuration changes, the exec plugin won't be
notified and we will need to restart the plugin manually.

## Solution

- dynamically get the proper priceregistry from the onChain when needed
(if its address changed in the onchain config).
- replaced the sourcePriceRegistry by a provider in the exec report
plugin.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants