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

CCIP-4152 Token transfer test #15130

Merged
merged 36 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
0f16c5f
CCIP-3591: Adding e2e test for USDC transfer
b-gopalswami Oct 15, 2024
a9ac59a
Merge branch 'develop' of github.com:smartcontractkit/chainlink into …
b-gopalswami Oct 15, 2024
6088dfe
Merge develop
b-gopalswami Oct 16, 2024
d7bbb4a
debug
b-gopalswami Oct 16, 2024
eaadf30
Merge develop and update chainlink-ccip reference
b-gopalswami Oct 17, 2024
9725e96
temp change
b-gopalswami Oct 23, 2024
397bfd7
Merge develop
b-gopalswami Oct 23, 2024
287c1ec
Merge develop
b-gopalswami Oct 25, 2024
9053740
resolve conflict
b-gopalswami Oct 28, 2024
301bc15
Fixing chain reader init for USDC integration
mateusz-sekara Oct 29, 2024
b5ea14a
Minor fix to the debug logs
mateusz-sekara Oct 29, 2024
417742d
Approving token
b-gopalswami Oct 29, 2024
966c1c7
Merge branch 'ccip-3591' of github.com:smartcontractkit/chainlink int…
b-gopalswami Oct 29, 2024
a3667fd
Merge develop and resolve conflicts
b-gopalswami Oct 30, 2024
6517368
Send tokens in send request
b-gopalswami Nov 4, 2024
a8ca4f6
Merge develop and fix conflicts
b-gopalswami Nov 4, 2024
adf2afe
Add registry module and register pool
b-gopalswami Nov 4, 2024
1a0eecc
Bump
mateusz-sekara Nov 5, 2024
c241523
Bump
mateusz-sekara Nov 5, 2024
e9ffe2a
Burn/Mint permissions
mateusz-sekara Nov 6, 2024
6b28d60
Proper addresses
mateusz-sekara Nov 6, 2024
c8d854f
Working test
mateusz-sekara Nov 6, 2024
ef31938
Working test
mateusz-sekara Nov 6, 2024
e5cabab
Working test
mateusz-sekara Nov 6, 2024
5740e6d
Removing USDC part
mateusz-sekara Nov 6, 2024
e8823af
Removing USDC part
mateusz-sekara Nov 6, 2024
7ca40a9
Removing USDC part
mateusz-sekara Nov 6, 2024
985a236
Removing USDC part
mateusz-sekara Nov 6, 2024
a8aa253
Merge remote-tracking branch 'origin/develop' into ms/token-transfer
mateusz-sekara Nov 6, 2024
0f95208
Removing USDC part
mateusz-sekara Nov 6, 2024
0a35be9
Removing USDC part
mateusz-sekara Nov 6, 2024
be245a4
Removing USDC part
mateusz-sekara Nov 6, 2024
3762416
Removing USDC part
mateusz-sekara Nov 6, 2024
6aff29a
Removing USDC part
mateusz-sekara Nov 6, 2024
61932fc
Removing USDC part
mateusz-sekara Nov 6, 2024
5b4f78b
Post review fixes
mateusz-sekara Nov 6, 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
5 changes: 5 additions & 0 deletions .changeset/six-wombats-shake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": patch
---

CCIP token transfer integration tests #internal
14 changes: 7 additions & 7 deletions core/capabilities/ccip/oraclecreator/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ func (i *pluginOracleCreator) createReadersAndWriters(
return nil, nil, fmt.Errorf("failed to get chain selector from chain ID %s: %w", chainID.String(), err1)
}

chainReaderConfig, err1 := getChainReaderConfig(chainID.Uint64(), destChainID, homeChainID, ofc, chainSelector)
chainReaderConfig, err1 := getChainReaderConfig(i.lggr, chainID.Uint64(), destChainID, homeChainID, ofc, chainSelector)
if err1 != nil {
return nil, nil, fmt.Errorf("failed to get chain reader config: %w", err1)
}
Expand Down Expand Up @@ -430,6 +430,7 @@ func (i *pluginOracleCreator) getChainID(chainSelector cciptypes.ChainSelector)
}

func getChainReaderConfig(
lggr logger.Logger,
chainID uint64,
destChainID uint64,
homeChainID uint64,
Expand All @@ -444,14 +445,17 @@ func getChainReaderConfig(
}

if !ofc.commitEmpty() && ofc.commit().PriceFeedChainSelector == chainSelector {
lggr.Debugw("Adding feed reader config", "chainID", chainID)
chainReaderConfig = evmconfig.MergeReaderConfigs(chainReaderConfig, evmconfig.FeedReaderConfig)
}

if isUSDCEnabled(chainID, destChainID, ofc) {
if isUSDCEnabled(ofc) {
lggr.Debugw("Adding USDC reader config", "chainID", chainID)
chainReaderConfig = evmconfig.MergeReaderConfigs(chainReaderConfig, evmconfig.USDCReaderConfig)
}

if chainID == homeChainID {
lggr.Debugw("Adding home chain reader config", "chainID", chainID)
chainReaderConfig = evmconfig.MergeReaderConfigs(chainReaderConfig, evmconfig.HomeChainReaderConfigRaw)
}

Expand All @@ -463,11 +467,7 @@ func getChainReaderConfig(
return marshaledConfig, nil
}

func isUSDCEnabled(chainID uint64, destChainID uint64, ofc offChainConfig) bool {
if chainID == destChainID {
return false
}

func isUSDCEnabled(ofc offChainConfig) bool {
if ofc.execEmpty() {
return false
}
Expand Down
4 changes: 2 additions & 2 deletions deployment/ccip/add_lane_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func TestAddLane(t *testing.T) {
startBlock := latesthdr.Number.Uint64()
// Send traffic on the first lane and it should not be processed by the plugin as onRamp is disabled
// we will check this by confirming that the message is not executed by the end of the test
seqNum1 := TestSendRequest(t, e.Env, state, chain1, chain2, false)
seqNum1 := TestSendRequest(t, e.Env, state, chain1, chain2, false, nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

Potentially simple abstraction here might be a RequestBuilder or similar, and then a simple SendRequest function that literally just sends it to the router.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, let's have that in a followup

require.Equal(t, uint64(1), seqNum1)

// Add another lane
Expand All @@ -103,7 +103,7 @@ func TestAddLane(t *testing.T) {
latesthdr, err = e.Env.Chains[chain1].Client.HeaderByNumber(testcontext.Get(t), nil)
require.NoError(t, err)
startBlock2 := latesthdr.Number.Uint64()
seqNum2 := TestSendRequest(t, e.Env, state, chain2, chain1, false)
seqNum2 := TestSendRequest(t, e.Env, state, chain2, chain1, false, nil)
require.Equal(t, uint64(1), seqNum2)
require.NoError(t, ConfirmExecWithSeqNr(t, e.Env.Chains[chain2], e.Env.Chains[chain1], state.Chains[chain1].OffRamp, &startBlock2, seqNum2))

Expand Down
1 change: 0 additions & 1 deletion deployment/ccip/changeset/active_candidate.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ func SetCandidatePluginChangeset(
pluginType cctypes.PluginType,
) (deployment.ChangesetOutput, error) {
newDONArgs, err := ccdeploy.BuildOCR3ConfigForCCIPHome(
e.Logger,
ocrSecrets,
state.Chains[newChainSel].OffRamp,
e.Chains[newChainSel],
Expand Down
3 changes: 1 addition & 2 deletions deployment/ccip/changeset/active_candidate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func TestActiveCandidate(t *testing.T) {
require.NoError(t, err)
block := latesthdr.Number.Uint64()
startBlocks[dest] = &block
seqNum := ccdeploy.TestSendRequest(t, e, state, src, dest, false)
seqNum := ccdeploy.TestSendRequest(t, e, state, src, dest, false, nil)
expectedSeqNum[dest] = seqNum
}
}
Expand Down Expand Up @@ -145,7 +145,6 @@ func TestActiveCandidate(t *testing.T) {
// commit and exec plugin we will be using
rmnHomeAddress := state.Chains[homeCS].RMNHome.Address()
ocr3ConfigMap, err := ccdeploy.BuildOCR3ConfigForCCIPHome(
e.Logger,
deployment.XXXGenerateTestOCRSecrets(),
state.Chains[destCS].OffRamp,
e.Chains[destCS],
Expand Down
1 change: 0 additions & 1 deletion deployment/ccip/changeset/add_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ func AddDonAndSetCandidateChangeset(
pluginType types.PluginType,
) (deployment.ChangesetOutput, error) {
newDONArgs, err := ccipdeployment.BuildOCR3ConfigForCCIPHome(
e.Logger,
ocrSecrets,
state.Chains[newChainSel].OffRamp,
e.Chains[newChainSel],
Expand Down
2 changes: 1 addition & 1 deletion deployment/ccip/changeset/add_chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ func TestAddChainInbound(t *testing.T) {
latesthdr, err := e.Env.Chains[newChain].Client.HeaderByNumber(testcontext.Get(t), nil)
require.NoError(t, err)
startBlock := latesthdr.Number.Uint64()
seqNr := ccipdeployment.TestSendRequest(t, e.Env, state, initialDeploy[0], newChain, true)
seqNr := ccipdeployment.TestSendRequest(t, e.Env, state, initialDeploy[0], newChain, true, nil)
require.NoError(t,
ccipdeployment.ConfirmCommitWithExpectedSeqNumRange(t, e.Env.Chains[initialDeploy[0]], e.Env.Chains[newChain], state.Chains[newChain].OffRamp, &startBlock, cciptypes.SeqNumRange{
cciptypes.SeqNum(1),
Expand Down
2 changes: 1 addition & 1 deletion deployment/ccip/changeset/initial_deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func TestInitialDeploy(t *testing.T) {
require.NoError(t, err)
block := latesthdr.Number.Uint64()
startBlocks[dest] = &block
seqNum := ccdeploy.TestSendRequest(t, e, state, src, dest, false)
seqNum := ccdeploy.TestSendRequest(t, e, state, src, dest, false, nil)
expectedSeqNum[dest] = seqNum
}
}
Expand Down
41 changes: 35 additions & 6 deletions deployment/ccip/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,22 @@ package ccipdeployment

import (
"fmt"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/burn_mint_token_pool"
mateusz-sekara marked this conversation as resolved.
Show resolved Hide resolved
"math/big"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/core/types"
"github.com/smartcontractkit/ccip-owner-contracts/pkg/config"

owner_helpers "github.com/smartcontractkit/ccip-owner-contracts/pkg/gethwrappers"

"github.com/smartcontractkit/chainlink-common/pkg/logger"

"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/fee_quoter"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/registry_module_owner_custom"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/rmn_home"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/aggregator_v3_interface"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/shared/generated/erc20"

"github.com/smartcontractkit/chainlink/deployment"

Expand All @@ -42,6 +43,7 @@ var (
Router deployment.ContractType = "Router"
CommitStore deployment.ContractType = "CommitStore"
TokenAdminRegistry deployment.ContractType = "TokenAdminRegistry"
RegistryModule deployment.ContractType = "RegistryModule"
mateusz-sekara marked this conversation as resolved.
Show resolved Hide resolved
NonceManager deployment.ContractType = "NonceManager"
FeeQuoter deployment.ContractType = "FeeQuoter"
AdminManyChainMultisig deployment.ContractType = "AdminManyChainMultiSig"
Expand All @@ -57,8 +59,10 @@ var (
CapabilitiesRegistry deployment.ContractType = "CapabilitiesRegistry"
PriceFeed deployment.ContractType = "PriceFeed"
// Note test router maps to a regular router contract.
TestRouter deployment.ContractType = "TestRouter"
CCIPReceiver deployment.ContractType = "CCIPReceiver"
TestRouter deployment.ContractType = "TestRouter"
CCIPReceiver deployment.ContractType = "CCIPReceiver"
BurnMintToken deployment.ContractType = "BurnMintToken"
BurnMintTokenPool deployment.ContractType = "BurnMintTokenPool"
)

type Contracts interface {
Expand All @@ -70,15 +74,18 @@ type Contracts interface {
*fee_quoter.FeeQuoter |
*router.Router |
*token_admin_registry.TokenAdminRegistry |
*registry_module_owner_custom.RegistryModuleOwnerCustom |
*weth9.WETH9 |
*rmn_remote.RMNRemote |
*owner_helpers.ManyChainMultiSig |
*owner_helpers.RBACTimelock |
*offramp.OffRamp |
*onramp.OnRamp |
*burn_mint_erc677.BurnMintERC677 |
*burn_mint_token_pool.BurnMintTokenPool |
*maybe_revert_message_receiver.MaybeRevertMessageReceiver |
*aggregator_v3_interface.AggregatorV3Interface
*aggregator_v3_interface.AggregatorV3Interface |
*erc20.ERC20
}

type ContractDeploy[C Contracts] struct {
Expand Down Expand Up @@ -233,7 +240,6 @@ func DeployCCIPContracts(e deployment.Environment, ab deployment.AddressBook, c
if err != nil {
return err
}

// For each chain, we create a DON on the home chain (2 OCR instances)
if err := AddDON(
e.Logger,
Expand Down Expand Up @@ -556,6 +562,29 @@ func DeployChainContracts(
}
e.Logger.Infow("deployed tokenAdminRegistry", "addr", tokenAdminRegistry)

customRegistryModule, err := deployContract(e.Logger, chain, ab,
func(chain deployment.Chain) ContractDeploy[*registry_module_owner_custom.RegistryModuleOwnerCustom] {
regModAddr, tx2, regMod, err2 := registry_module_owner_custom.DeployRegistryModuleOwnerCustom(
chain.DeployerKey,
chain.Client,
tokenAdminRegistry.Address)
return ContractDeploy[*registry_module_owner_custom.RegistryModuleOwnerCustom]{
regModAddr, regMod, tx2, deployment.NewTypeAndVersion(RegistryModule, deployment.Version1_5_0), err2,
}
})
if err != nil {
e.Logger.Errorw("Failed to deploy custom registry module", "err", err)
return err
}
e.Logger.Infow("deployed custom registry module", "addr", tokenAdminRegistry)

tx, err = tokenAdminRegistry.Contract.AddRegistryModule(chain.DeployerKey, customRegistryModule.Address)
if err != nil {
e.Logger.Errorw("Failed to assign registry module on token admin registry", "err", err)
return err
}
e.Logger.Infow("assigned registry module on token admin registry")

nonceManager, err := deployContract(e.Logger, chain, ab,
func(chain deployment.Chain) ContractDeploy[*nonce_manager.NonceManager] {
nonceManagerAddr, tx2, nonceManager, err2 := nonce_manager.DeployNonceManager(
Expand Down
5 changes: 2 additions & 3 deletions deployment/ccip/deploy_home_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,12 +308,10 @@ func AddChainConfig(
}

func BuildOCR3ConfigForCCIPHome(
lggr logger.Logger,
ocrSecrets deployment.OCRSecrets,
offRamp *offramp.OffRamp,
dest deployment.Chain,
feedChainSel uint64,
// Token address on Dest chain to aggregate address on feed chain
tokenInfo map[ccipocr3.UnknownEncodedAddress]pluginconfig.TokenInfo,
nodes deployment.Nodes,
rmnHomeAddress common.Address,
Expand Down Expand Up @@ -360,6 +358,7 @@ func BuildOCR3ConfigForCCIPHome(
InflightCacheExpiry: *commonconfig.MustNewDuration(InflightCacheExpiry),
RootSnoozeTime: *commonconfig.MustNewDuration(RootSnoozeTime),
BatchingStrategyID: BatchingStrategyID,
TokenDataObservers: []pluginconfig.TokenDataObserverConfig{},
})
}
if err2 != nil {
Expand Down Expand Up @@ -891,7 +890,7 @@ func AddDON(
home deployment.Chain,
nodes deployment.Nodes,
) error {
ocrConfigs, err := BuildOCR3ConfigForCCIPHome(lggr, ocrSecrets, offRamp, dest, feedChainSel, tokenInfo, nodes, rmnHomeAddress)
ocrConfigs, err := BuildOCR3ConfigForCCIPHome(ocrSecrets, offRamp, dest, feedChainSel, tokenInfo, nodes, rmnHomeAddress)
if err != nil {
return err
}
Expand Down
17 changes: 12 additions & 5 deletions deployment/ccip/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ import (
chainsel "github.com/smartcontractkit/chain-selectors"

"github.com/smartcontractkit/chainlink/deployment"
"github.com/smartcontractkit/chainlink/deployment/ccip/view"
"github.com/smartcontractkit/chainlink/deployment/ccip/view/v1_0"
"github.com/smartcontractkit/chainlink/deployment/ccip/view/v1_2"
"github.com/smartcontractkit/chainlink/deployment/ccip/view/v1_5"
"github.com/smartcontractkit/chainlink/deployment/ccip/view/v1_6"
common_v1_0 "github.com/smartcontractkit/chainlink/deployment/common/view/v1_0"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/ccip_config"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/commit_store"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/registry_module_owner_custom"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/rmn_home"

"github.com/smartcontractkit/chainlink/deployment/ccip/view"
"github.com/smartcontractkit/chainlink/deployment/ccip/view/v1_2"
"github.com/smartcontractkit/chainlink/deployment/ccip/view/v1_5"
"github.com/smartcontractkit/chainlink/deployment/ccip/view/v1_6"

"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/ccip_home"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/fee_quoter"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/maybe_revert_message_receiver"
Expand Down Expand Up @@ -48,6 +48,7 @@ type CCIPChainState struct {
RMNProxy *rmn_proxy_contract.RMNProxyContract
NonceManager *nonce_manager.NonceManager
TokenAdminRegistry *token_admin_registry.TokenAdminRegistry
RegistryModule *registry_module_owner_custom.RegistryModuleOwnerCustom
Router *router.Router
CommitStore *commit_store.CommitStore
Weth9 *weth9.WETH9
Expand Down Expand Up @@ -320,6 +321,12 @@ func LoadChainState(chain deployment.Chain, addresses map[string]deployment.Type
return state, err
}
state.TokenAdminRegistry = tm
case deployment.NewTypeAndVersion(RegistryModule, deployment.Version1_5_0).String():
rm, err := registry_module_owner_custom.NewRegistryModuleOwnerCustom(common.HexToAddress(address), chain.Client)
if err != nil {
return state, err
}
state.RegistryModule = rm
case deployment.NewTypeAndVersion(Router, deployment.Version1_2_0).String():
r, err := router.NewRouter(common.HexToAddress(address), chain.Client)
if err != nil {
Expand Down
Loading
Loading