-
Notifications
You must be signed in to change notification settings - Fork 56
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
Conversation
df543db
to
7c03179
Compare
// 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)) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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
…ot configured on pricegetter
…okenConfigured more robust
954bdd4
to
bc4ca4e
Compare
30b40f7
to
a8992a5
Compare
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- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's this for?
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
b55d2ef
to
5822f17
Compare
26cfa2b
to
7abde98
Compare
…ot configured on pricegetter (#686) ## Motivation Self service 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](#623)) 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()`. Risks: - Compatability with [shared job specs](#683) ### _For v1.5 (next) contracts:_ Return to on-chain being the source of truth for which tokens need a price update. The list of TransferTokens that need pricing will be created from querying the OnRamps for tokens that have either BPS set and/or Aggregate Rate Limits. FeeTokens will still be taken from the destination Price Registry.
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 theprice 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 thepricegetter
before they reachpricegetter.TokenPricesUSD()
.