Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(refactor): Filter out destination chain bridgeable tokens that are not configured on pricegetter #686

Merged
merged 9 commits into from
Apr 10, 2024

Conversation

justinkaseman
Copy link
Member

@justinkaseman justinkaseman commented Apr 5, 2024

Motivation

Self serve token pools will enable many new TransferTokens to be used across CCIP, most of which may not have a readily available price.

Context

The current procedure (as of batched price updates) is for a single lane to be designated as the "leader lane". It reports all prices that other lanes use. Other lanes have their price reporting disabled. To enable this, the leader lane has all supported tokens configured in the CommitJobSpec.

The source of truth for which tokens are supported comes from on-chain: queried from the leader lane's destination price registry (FeeTokens) and from each OffRamp's supportedTokens. The combined set is given to the price getter, and if the number of resulting prices is different from the CommitJobSpec's tokens then the observation is thrown out.

Solution

For v1.4 (current) contracts:

Use the CommitJobSpec's configured tokens as the source of truth for which TransferTokens need a price update. Filter out TransferTokens that are not configured on the pricegetter before they reach pricegetter.TokenPricesUSD().

// IsTokenConfigured implements the PriceGetter interface.
// It returns if a token has a pipeline job configured on the TokenPricesUSDPipeline
func (d *PipelineGetter) IsTokenConfigured(ctx context.Context, token cciptypes.Address) (bool, error) {
contains := strings.Contains(d.source, string(token))
Copy link
Collaborator

Choose a reason for hiding this comment

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

@dimkouv are the addresses in token pipeline definition always in checksum format, or there isn't a case requirement?

Copy link
Member Author

Choose a reason for hiding this comment

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

Based on what Piotr says about old job specs, I'll normalize casing just to be defensive

Copy link
Collaborator

@RensR RensR Apr 8, 2024

Choose a reason for hiding this comment

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

They are 100% random and could be checksummed and not checksummed in the same pipeline

// GetChainTokens returns union of all tokens supported on the destination chain, including fee tokens from the provided price registry
// and the bridgeable tokens from all the offRamps living on the chain.
func getSortedChainTokensWithBatchLimit(ctx context.Context, offRamps []ccipdata.OffRampReader, priceRegistry cciptypes.PriceRegistryReader, batchSize int) (chainTokens []cciptypes.Address, err error) {
// Bridgeable tokens are only included if they are configured on the pricegetter
func GetSortedChainTokens(ctx context.Context, offRamps []ccipdata.OffRampReader, priceRegistry cciptypes.PriceRegistryReader, priceGetter cciptypes.PriceGetter) (chainTokens []cciptypes.Address, err error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

let's extra it into a separate function, like FilterForPricedTokens(), and let this just stay as a function that gets all chain tokens

GNUmakefile Outdated
@@ -149,7 +149,7 @@ telemetry-protobuf: $(telemetry-protobuf) ## Generate telemetry protocol buffers
config-docs: ## Generate core node configuration documentation
go run ./core/config/docs/cmd/generate -o ./docs/

.PHONY: golangci-lint
.PHONY: golintlangci-
Copy link
Collaborator

Choose a reason for hiding this comment

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

what's this for?

Copy link
Member Author

Choose a reason for hiding this comment

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

Shouldn't be there. Removed

// IsTokenConfigured implements the PriceGetter interface.
// It returns if a token has a pipeline job configured on the TokenPricesUSDPipeline
func (d *PipelineGetter) IsTokenConfigured(ctx context.Context, token cciptypes.Address) (bool, error) {
contains := strings.Contains(d.source, string(token))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Per Rens' comment: #686 (comment) ,
lets's be a bit paranoid and defensive, pls make this a case-insenstive match

Also, can we make the PriceGetter interface become something like filterForConfiguredTokens(ctx, tokens) tokens? Not certain about LOOPPS migration, the call to PriceGetter could be migrated to a grpc call, in that case loop with call per token is not ideal.

Copy link
Member Author

Choose a reason for hiding this comment

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

lets's be a bit paranoid and defensive, pls make this a case-insenstive match

Weird, had a commit for that which didn't get pushed up. Adding.

@justinkaseman justinkaseman merged commit dff8083 into ccip-develop Apr 10, 2024
79 checks passed
@justinkaseman justinkaseman deleted the CCIP-1945-offchain-2 branch April 10, 2024 23:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants