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

Enable add chain test #14904

Merged
merged 40 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
be45932
Add FeeQuoter to SourceConfig
asoliman92 Oct 17, 2024
0f8fc41
Merge branch 'develop' into fix-fee-quoter
asoliman92 Oct 17, 2024
c276a80
cl-ccip bump
asoliman92 Oct 17, 2024
39e6338
Merge branch 'develop' into fix-fee-quoter
asoliman92 Oct 18, 2024
009f334
Debugging
asoliman92 Oct 18, 2024
ad5635f
Fix OnRamp.GetDestChainConfig
asoliman92 Oct 18, 2024
e58e79c
Cleaning
asoliman92 Oct 21, 2024
1adc8c0
Clean contract configs
asoliman92 Oct 21, 2024
085bd48
Clean contract configs
asoliman92 Oct 21, 2024
397420e
Add Gas Price test in initial_deploy_test.go
asoliman92 Oct 21, 2024
98e5ac2
Bump chainlink-ccip
asoliman92 Oct 21, 2024
ef99468
Merge branch 'develop' into fix-fee-quoter
asoliman92 Oct 21, 2024
157e441
Bump chainlink-ccip
asoliman92 Oct 21, 2024
3a68a95
Merge branch 'develop' into fix-fee-quoter
asoliman92 Oct 22, 2024
d2e5ac0
cleaning cmoments
asoliman92 Oct 22, 2024
83fa7c8
linting
asoliman92 Oct 22, 2024
36169af
skip failing test for now
asoliman92 Oct 22, 2024
3bb786a
unskip
asoliman92 Oct 22, 2024
ea86129
Add FeeQuoter to SourceConfig
asoliman92 Oct 17, 2024
c6230b4
Bump chainlink-ccip
winder Oct 22, 2024
0614569
Add weth feed
asoliman92 Oct 22, 2024
f95de90
Remove deprecated thing.
winder Oct 22, 2024
131211a
Add assertions for weth
asoliman92 Oct 22, 2024
0120ff5
Remove replacement.
winder Oct 22, 2024
e9d9681
linting
asoliman92 Oct 22, 2024
d84c55a
gomodtidy
winder Oct 22, 2024
21a5c0a
Make TestAddChainInbound test Bidirectional and rename to TestAddChain
asoliman92 Oct 22, 2024
fe8ff1f
Merge branch 'fix-fee-quoter' into add-weth-feed
asoliman92 Oct 22, 2024
596033f
updates
AnieeG Oct 22, 2024
7e0bfe0
enable testaddchain
AnieeG Oct 22, 2024
0dc1a11
changes
AnieeG Oct 22, 2024
355005a
more changes
AnieeG Oct 22, 2024
6b65996
updates
AnieeG Oct 22, 2024
739cedf
go mod update
AnieeG Oct 22, 2024
a6da0cd
more fix
AnieeG Oct 22, 2024
2952a0c
fix lint
AnieeG Oct 22, 2024
b4b7913
fix lint
AnieeG Oct 22, 2024
62a0290
fix conflicts
AnieeG Oct 23, 2024
201ea59
go mod
AnieeG Oct 23, 2024
bd58ad7
merge
AnieeG Oct 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add weth feed
  • Loading branch information
asoliman92 committed Oct 22, 2024
commit 06145692842c867916c3a1d147e44d8428cdc55f
2 changes: 1 addition & 1 deletion integration-tests/deployment/ccip/add_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func AddDonAndSetCandidateForCommitProposal(
state.Chains[newChainSel].OffRamp,
e.Chains[newChainSel],
feedChainSel,
tokenConfig.GetTokenInfo(e.Logger, state.Chains[newChainSel].LinkToken),
tokenConfig.GetLinkInfo(e.Logger, state.Chains[newChainSel].LinkToken, state.Chains[newChainSel].Weth9),
nodes.NonBootstraps(),
rmnHomeAddress,
)
Expand Down
7 changes: 7 additions & 0 deletions integration-tests/deployment/ccip/add_chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ func TestAddChainInbound(t *testing.T) {
DeviationPPB: cciptypes.NewBigIntFromInt64(1e9),
},
)
tokenConfig.UpsertTokenInfo(WethSymbol,
pluginconfig.TokenInfo{
AggregatorAddress: feeds[WethSymbol].Address().String(),
Decimals: WethDecimals,
DeviationPPB: cciptypes.NewBigIntFromInt64(1e9),
},
)
err = DeployCCIPContracts(e.Env, e.Ab, DeployCCIPContractConfig{
HomeChainSel: e.HomeChainSel,
FeedChainSel: e.FeedChainSel,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ func TestInitialDeploy(t *testing.T) {
DeviationPPB: cciptypes.NewBigIntFromInt64(1e9),
},
)
tokenConfig.UpsertTokenInfo(ccdeploy.WethSymbol,
pluginconfig.TokenInfo{
AggregatorAddress: feeds[ccdeploy.WethSymbol].Address().String(),
Decimals: ccdeploy.WethDecimals,
DeviationPPB: cciptypes.NewBigIntFromInt64(1e9),
},
)

output, err := InitialDeployChangeSet(tenv.Ab, tenv.Env, ccdeploy.DeployCCIPContractConfig{
HomeChainSel: tenv.HomeChainSel,
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/deployment/ccip/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ func DeployCCIPContracts(e deployment.Environment, ab deployment.AddressBook, c
return err
}

tokenInfo := c.TokenConfig.GetTokenInfo(e.Logger, c.FeeTokenContracts[chainSel].LinkToken)
tokenInfo := c.TokenConfig.GetLinkInfo(e.Logger, c.FeeTokenContracts[chainSel].LinkToken, c.FeeTokenContracts[chainSel].Weth9)
// TODO: Do we want to extract this?
// Add chain config for each chain.
_, err = AddChainConfig(
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/deployment/ccip/propose_home_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func SetCandidateExecPluginProposal(
state.Chains[newChainSel].OffRamp,
e.Chains[newChainSel],
feedChainSel,
tokenConfig.GetTokenInfo(e.Logger, state.Chains[newChainSel].LinkToken),
tokenConfig.GetLinkInfo(e.Logger, state.Chains[newChainSel].LinkToken, state.Chains[newChainSel].Weth9),
nodes.NonBootstraps(),
rmnHomeAddress,
)
Expand Down
102 changes: 77 additions & 25 deletions integration-tests/deployment/ccip/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package ccipdeployment
import (
"context"
"fmt"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/mock_ethusd_aggregator_wrapper"
"math/big"
"sort"
"testing"
Expand Down Expand Up @@ -316,6 +317,13 @@ func NewLocalDevEnvironmentWithRMN(t *testing.T, lggr logger.Logger) (DeployedEn
DeviationPPB: cciptypes.NewBigIntFromInt64(1e9),
},
)
tokenConfig.UpsertTokenInfo(WethSymbol,
pluginconfig.TokenInfo{
AggregatorAddress: feeds[WethSymbol].Address().String(),
Decimals: WethDecimals,
DeviationPPB: cciptypes.NewBigIntFromInt64(1e9),
},
)
// Deploy CCIP contracts.
err = DeployCCIPContracts(tenv.Env, tenv.Ab, DeployCCIPContractConfig{
HomeChainSel: tenv.HomeChainSel,
Expand Down Expand Up @@ -458,49 +466,93 @@ const (

var (
MockLinkPrice = big.NewInt(5e18)
MockWethPrice = big.NewInt(9e18)
// MockDescriptionToTokenSymbol maps a mock feed description to token descriptor
MockDescriptionToTokenSymbol = map[string]TokenSymbol{
MockLinkAggregatorDescription: LinkSymbol,
MockWETHAggregatorDescription: WethSymbol,
}
MockSymbolToDescription = map[TokenSymbol]string{
LinkSymbol: MockLinkAggregatorDescription,
WethSymbol: MockWETHAggregatorDescription,
}
MockSymbolToDecimals = map[TokenSymbol]uint8{
LinkSymbol: LinkDecimals,
WethSymbol: WethDecimals,
}
)

func DeployFeeds(lggr logger.Logger, ab deployment.AddressBook, chain deployment.Chain) (map[string]common.Address, error) {
linkTV := deployment.NewTypeAndVersion(PriceFeed, deployment.Version1_0_0)
mockLinkFeed, err := deployContract(lggr, chain, ab,
func(chain deployment.Chain) ContractDeploy[*aggregator_v3_interface.AggregatorV3Interface] {
linkFeed, tx, _, err1 := mock_v3_aggregator_contract.DeployMockV3Aggregator(
chain.DeployerKey,
chain.Client,
LinkDecimals, // decimals
MockLinkPrice, // initialAnswer
)
aggregatorCr, err2 := aggregator_v3_interface.NewAggregatorV3Interface(linkFeed, chain.Client)

return ContractDeploy[*aggregator_v3_interface.AggregatorV3Interface]{
Address: linkFeed, Contract: aggregatorCr, Tv: linkTV, Tx: tx, Err: multierr.Append(err1, err2),
}
})
mockLinkFeed := func(chain deployment.Chain) ContractDeploy[*aggregator_v3_interface.AggregatorV3Interface] {
linkFeed, tx, _, err1 := mock_v3_aggregator_contract.DeployMockV3Aggregator(
chain.DeployerKey,
chain.Client,
LinkDecimals, // decimals
MockLinkPrice, // initialAnswer
)
aggregatorCr, err2 := aggregator_v3_interface.NewAggregatorV3Interface(linkFeed, chain.Client)

return ContractDeploy[*aggregator_v3_interface.AggregatorV3Interface]{
Address: linkFeed, Contract: aggregatorCr, Tv: linkTV, Tx: tx, Err: multierr.Append(err1, err2),
}
}

mockWethFeed := func(chain deployment.Chain) ContractDeploy[*aggregator_v3_interface.AggregatorV3Interface] {
wethFeed, tx, _, err1 := mock_ethusd_aggregator_wrapper.DeployMockETHUSDAggregator(
chain.DeployerKey,
chain.Client,
MockWethPrice, // initialAnswer
)
aggregatorCr, err2 := aggregator_v3_interface.NewAggregatorV3Interface(wethFeed, chain.Client)

return ContractDeploy[*aggregator_v3_interface.AggregatorV3Interface]{
Address: wethFeed, Contract: aggregatorCr, Tv: linkTV, Tx: tx, Err: multierr.Append(err1, err2),
}
}

linkFeedAddress, linkFeedDescription, err := deploySingleFeed(lggr, ab, chain, mockLinkFeed, LinkSymbol)
if err != nil {
lggr.Errorw("Failed to deploy link feed", "err", err)
return nil, err
}

lggr.Infow("deployed mockLinkFeed", "addr", mockLinkFeed.Address)
wethFeedAddress, wethFeedDescription, err := deploySingleFeed(lggr, ab, chain, mockWethFeed, WethSymbol)

descriptionToAddress := map[string]common.Address{
linkFeedDescription: linkFeedAddress,
wethFeedDescription: wethFeedAddress,
}

desc, err := mockLinkFeed.Contract.Description(&bind.CallOpts{})
return descriptionToAddress, nil
}

func deploySingleFeed(
lggr logger.Logger,
ab deployment.AddressBook,
chain deployment.Chain,
deployFunc func(deployment.Chain) ContractDeploy[*aggregator_v3_interface.AggregatorV3Interface],
symbol TokenSymbol,
) (common.Address, string, error) {
//tokenTV := deployment.NewTypeAndVersion(PriceFeed, deployment.Version1_0_0)
mockTokenFeed, err := deployContract(lggr, chain, ab, deployFunc)
if err != nil {
lggr.Errorw("Failed to get description", "err", err)
return nil, err
lggr.Errorw("Failed to deploy token feed", "err", err, "symbol", symbol)
return common.Address{}, "", err
}

if desc != MockLinkAggregatorDescription {
lggr.Errorw("Unexpected description for Link token", "desc", desc)
return nil, fmt.Errorf("unexpected description: %s", desc)
lggr.Infow("deployed mockTokenFeed", "addr", mockTokenFeed.Address)

desc, err := mockTokenFeed.Contract.Description(&bind.CallOpts{})
if err != nil {
lggr.Errorw("Failed to get description", "err", err, "symbol", symbol)
return common.Address{}, "", err
}

tvToAddress := map[string]common.Address{
desc: mockLinkFeed.Address,
if desc != MockSymbolToDescription[symbol] {
lggr.Errorw("Unexpected description for token", "symbol", symbol, "desc", desc)
return common.Address{}, "", fmt.Errorf("unexpected description: %s", desc)
}
return tvToAddress, nil

return mockTokenFeed.Address, desc, nil

}
14 changes: 11 additions & 3 deletions integration-tests/deployment/ccip/token_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package ccipdeployment

import (
"github.com/smartcontractkit/chainlink-ccip/pluginconfig"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/weth9"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/shared/generated/burn_mint_erc677"

"github.com/smartcontractkit/chainlink-common/pkg/logger"
Expand All @@ -28,10 +29,11 @@ func (tc *TokenConfig) UpsertTokenInfo(
tc.TokenSymbolToInfo[symbol] = info
}

// GetTokenInfo Adds mapping between dest chain tokens and their respective aggregators on feed chain.
func (tc *TokenConfig) GetTokenInfo(
// GetLinkInfo Adds mapping between dest chain tokens and their respective aggregators on feed chain.
func (tc *TokenConfig) GetLinkInfo(
lggr logger.Logger,
linkToken *burn_mint_erc677.BurnMintERC677,
wethToken *weth9.WETH9,
) map[ocrtypes.Account]pluginconfig.TokenInfo {
tokenToAggregate := make(map[ocrtypes.Account]pluginconfig.TokenInfo)
if _, ok := tc.TokenSymbolToInfo[LinkSymbol]; !ok {
Expand All @@ -42,7 +44,13 @@ func (tc *TokenConfig) GetTokenInfo(
tokenToAggregate[acc] = tc.TokenSymbolToInfo[LinkSymbol]
}

// TODO: Populate tokenInfo with weth and the token map in destState
if _, ok := tc.TokenSymbolToInfo[WethSymbol]; !ok {
lggr.Debugw("Weth aggregator not found, deploy without mapping link token")
} else {
lggr.Debugw("Mapping WethToken to Weth aggregator")
acc := ocrtypes.Account(wethToken.Address().String())
tokenToAggregate[acc] = tc.TokenSymbolToInfo[WethSymbol]
}

return tokenToAggregate
}