-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Add feed chain deployment test #14461
Conversation
* Add deploy_feed_chain * Refactor deployCapReg to take the chain directly without the selector * Deploy mock link feed
LINK_PRICE = big.NewInt(5e18) | ||
) | ||
|
||
func DeployFeeds(lggr logger.Logger, chain deployment.Chain) (deployment.AddressBook, map[string]common.Address, 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.
just to clarify this would only be for testing - on mainnet we'd leverage existing feed deployment stack
func DeployFeeds(lggr logger.Logger, chain deployment.Chain) (deployment.AddressBook, map[string]common.Address, error) { | ||
ab := deployment.NewMemoryAddressBook() | ||
//TODO: Maybe append LINK to the contract name | ||
linkTV := deployment.NewTypeAndVersion(PriceFeed, deployment.Version1_0_0) |
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.
hm this should be whatever typeAndVersion is actually in the contract - does the mock aggregator not have one?
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.
mock aggregator doesn't have one. That's why I added the TODO to make it unique with different aggregators later.
if state.Feeds == nil { | ||
state.Feeds = make(map[string]*aggregator_v3_interface.AggregatorV3Interface) | ||
} | ||
state.Feeds[tvStr.String()] = feed |
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.
I don't think tvStr will be unique here, they'll all be of the type OffchainAggregator (https://github.com/smartcontractkit/libocr/blob/1a7e0789ba965e9a1cdfe6fb4d5e31acd1627025/contract/OffchainAggregator.sol#L112) or something. Maybe best to key them on description()
e.g. "LINK / USD" see an example here of a real feed https://sepolia.arbiscan.io/address/0x0FB99723Aee6f420beAD13e6bBB79b7E6F034298#readContract
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.
I like the idea of using description 👍. I was going to prefix it with the token name but description is cleaner in this case.
@@ -119,6 +122,7 @@ func deployContract[C Contracts]( | |||
|
|||
type DeployCCIPContractConfig struct { | |||
HomeChainSel uint64 | |||
FeedChainSel uint64 |
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.
I think since on mainnet/testnet we would not deploy the feeds (mock or o/w), probably best to leave it out of the DeployCCIPContracts function and just keep it separate which we only deploy in tests.
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.
I need to pass it as the deployment offchain config needs it
token_info facilitates sending tokenConfig to CCIPDeployConfig
DECIMALS, // decimals | ||
MockLinkPrice, // initialAnswer | ||
) | ||
aggregatorCr, err2 := aggregator_v3_interface.NewAggregatorV3Interface(linkFeed, chain.Client) |
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.
This code is unidiomatic; typically this NewAggregatorV3Interface
will never return an error unless the ABI is not well formed (which is impossible - guaranteed by the compilation process). Better to check err immediately.
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.
We're inside a function that's passed as a parameter and needs to return ContractDeploy[*aggregator_v3_interface.AggregatorV3Interface]{
. You suggest just return the ContractDeploy twice with different errors after each?
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.
hm might be simpler to just have MockFeeds map[TokenSymbol]*mock_aggregator_v3.MockAggregator then when we add real feeds separately have the full OffchainAggregator wrapper
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.
We'll give away the flexibility of the tests though with deploying any mock contract by description.
return ab, nil, err | ||
} | ||
|
||
if desc != MockLinkAggregatorDescription { |
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.
Having a proper description would make this assertion more useful, cuz right now the description of a mock link feed and a mock weth feed will be the same right?
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.
Nope, I'm gonna use this: MockWETHAggregatorDescription = "MockETHUSDAggregator"
. Didn't want to use same with same description as it will cause issues.
return "MockETHUSDAggregator"; |
@@ -367,11 +370,15 @@ func AddDON( | |||
capReg *capabilities_registry.CapabilitiesRegistry, | |||
ccipConfig *ccip_config.CCIPConfig, | |||
offRamp *offramp.OffRamp, | |||
feedChainSel uint64, | |||
// Token on Dest chain to aggregate address on feed chain | |||
//tokenCfg TokenConfig, |
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.
remove commented code?
// Map between token Descriptor (e.g. LinkSymbol, WethSymbol) | ||
// and the respective token contract | ||
// This is more of an illustration of how we'll have tokens, and it might need some work later to work properly. | ||
BurnMintTokens677 map[TokenSymbol]*burn_mint_erc677.BurnMintERC677 |
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.
are these intended to non-fee priced tokens like custom BPS tokens (fee tokens should already be captured with the Weth9 and LinkToken wrappers)? If so they won't necessarily be B/M 677
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.
are these intended to non-fee priced tokens like custom BPS tokens
This was the intention. What are your suggestions? We can have multiple maps for different kinds as well. For now this is for illustrative purpose. Maybe I can add more comments to explain this.
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.
This doesn't seem to be used, any reason we have them here?
DECIMALS, // decimals | ||
MockLinkPrice, // initialAnswer | ||
) | ||
aggregatorCr, err2 := aggregator_v3_interface.NewAggregatorV3Interface(linkFeed, chain.Client) |
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.
hm might be simpler to just have MockFeeds map[TokenSymbol]*mock_aggregator_v3.MockAggregator then when we add real feeds separately have the full OffchainAggregator wrapper
t.Logf("Received commit report on selector %d from source selector %d expected seq nr range %s, token prices: %v", | ||
dest.Selector, src.Selector, expectedSeqNumRange.String(), report.Report.PriceUpdates.TokenPriceUpdates) |
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.
Do we want to have at least one assertion per chain that a token price gets posted? I don't see any assertions right now regarding this.
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.
We do assert per chain in the main tests. This is just for printing no more.
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.
Quality Gate passedIssues Measures |
Start with token_info which has the config map of
TokenDescriptor
to tokenInfo that will be used in commit off chain plugin.GetTokenInfo
to map the token address on dest chain to the info added in previous step.DeployFeed
to test_helpers to deploy mock feeds while testing.