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

Add feed chain deployment test #14461

Merged
merged 22 commits into from
Sep 20, 2024
Merged

Add feed chain deployment test #14461

merged 22 commits into from
Sep 20, 2024

Conversation

asoliman92
Copy link
Contributor

@asoliman92 asoliman92 commented Sep 17, 2024

Start with token_info which has the config map of TokenDescriptor to tokenInfo that will be used in commit off chain plugin.

  • In production the token_info will be populated with all token descriptors we're interested in with their respective on-chain aggregator address.
  • In tests we do 2 things:
    • We Deploy feeds and add them to tokenInfo with the correct descriptors (Assuming for now that same token won't have different info across different chains)
    • Once we deploy tokens on simulated chain (e.g. LinkToken). We use GetTokenInfo to map the token address on dest chain to the info added in previous step.
  • Add function DeployFeed to test_helpers to deploy mock feeds while testing.

* Add deploy_feed_chain
* Refactor deployCapReg to take the chain directly without the selector
* Deploy mock link feed
@asoliman92 asoliman92 changed the title Initial Commit Add feed chain deployment Sep 17, 2024
LINK_PRICE = big.NewInt(5e18)
)

func DeployFeeds(lggr logger.Logger, chain deployment.Chain) (deployment.AddressBook, map[string]common.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.

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)
Copy link
Contributor

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?

Copy link
Contributor Author

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
Copy link
Contributor

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

Copy link
Contributor Author

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
Copy link
Contributor

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.

Copy link
Contributor Author

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

@asoliman92 asoliman92 marked this pull request as ready for review September 18, 2024 17:35
@asoliman92 asoliman92 requested review from a team as code owners September 18, 2024 17:35
@asoliman92 asoliman92 requested review from EasterTheBunny and removed request for a team September 18, 2024 17:35
integration-tests/deployment/ccip/consts.go Outdated Show resolved Hide resolved
integration-tests/deployment/ccip/consts.go Outdated Show resolved Hide resolved
integration-tests/deployment/ccip/state.go Show resolved Hide resolved
integration-tests/deployment/ccip/test_helpers.go Outdated Show resolved Hide resolved
DECIMALS, // decimals
MockLinkPrice, // initialAnswer
)
aggregatorCr, err2 := aggregator_v3_interface.NewAggregatorV3Interface(linkFeed, chain.Client)
Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Contributor

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

Copy link
Contributor Author

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 {
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@@ -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,
Copy link
Contributor

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
Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor

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)
Copy link
Contributor

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

integration-tests/deployment/ccip/state.go Outdated Show resolved Hide resolved
integration-tests/deployment/ccip/test_assertions.go Outdated Show resolved Hide resolved
integration-tests/deployment/ccip/token_info.go Outdated Show resolved Hide resolved
Comment on lines +118 to +119
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)
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

makramkd
makramkd previously approved these changes Sep 19, 2024
@cl-sonarqube-production
Copy link

@asoliman92 asoliman92 changed the title Add feed chain deployment Add feed chain deployment test Sep 20, 2024
@asoliman92 asoliman92 added this pull request to the merge queue Sep 20, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Sep 20, 2024
@asoliman92 asoliman92 added this pull request to the merge queue Sep 20, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Sep 20, 2024
@asoliman92 asoliman92 added this pull request to the merge queue Sep 20, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Sep 20, 2024
@asoliman92 asoliman92 added this pull request to the merge queue Sep 20, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Sep 20, 2024
@asoliman92 asoliman92 added this pull request to the merge queue Sep 20, 2024
Merged via the queue into develop with commit 22a8c99 Sep 20, 2024
156 checks passed
@asoliman92 asoliman92 deleted the feed-chain-deployment branch September 20, 2024 15:22
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.

5 participants