Skip to content

Commit

Permalink
fix errors
Browse files Browse the repository at this point in the history
  • Loading branch information
AnieeG committed Apr 8, 2024
1 parent f2759e4 commit d796cb8
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 126 deletions.
66 changes: 32 additions & 34 deletions integration-tests/ccip-tests/contracts/contract_deployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"golang.org/x/crypto/curve25519"

"github.com/smartcontractkit/chainlink-common/pkg/config"
"golang.org/x/crypto/curve25519"

ocrconfighelper2 "github.com/smartcontractkit/libocr/offchainreporting2/confighelper"
ocrtypes2 "github.com/smartcontractkit/libocr/offchainreporting2/types"
Expand All @@ -28,7 +27,6 @@ import (

"github.com/smartcontractkit/chainlink/integration-tests/client"
"github.com/smartcontractkit/chainlink/integration-tests/contracts"
"github.com/smartcontractkit/chainlink/integration-tests/wrappers"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/arm_contract"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/commit_store"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/evm_2_evm_offramp"
Expand Down Expand Up @@ -78,7 +76,7 @@ func (e *CCIPContractsDeployer) DeployMultiCallContract() (common.Address, error
auth *bind.TransactOpts,
backend bind.ContractBackend,
) (common.Address, *types.Transaction, interface{}, error) {
address, tx, contract, err := bind.DeployContract(auth, multiCallABI, common.FromHex(MultiCallBIN), wrappers.MustNewWrappedContractBackend(e.evmClient, nil))
address, tx, contract, err := bind.DeployContract(auth, multiCallABI, common.FromHex(MultiCallBIN), backend)
if err != nil {
return common.Address{}, nil, nil, err
}
Expand All @@ -102,7 +100,7 @@ func (e *CCIPContractsDeployer) DeployTokenMessenger(tokenTransmitter common.Add
auth *bind.TransactOpts,
backend bind.ContractBackend,
) (common.Address, *types.Transaction, interface{}, error) {
address, tx, contract, err := mock_usdc_token_messenger.DeployMockE2EUSDCTokenMessenger(auth, wrappers.MustNewWrappedContractBackend(e.evmClient, nil), 0, tokenTransmitter)
address, tx, contract, err := mock_usdc_token_messenger.DeployMockE2EUSDCTokenMessenger(auth, backend, 0, tokenTransmitter)
if err != nil {
return common.Address{}, nil, nil, err
}
Expand All @@ -113,7 +111,7 @@ func (e *CCIPContractsDeployer) DeployTokenMessenger(tokenTransmitter common.Add
}

func (e *CCIPContractsDeployer) NewTokenTransmitter(addr common.Address) (*TokenTransmitter, error) {
transmitter, err := mock_usdc_token_transmitter.NewMockE2EUSDCTransmitter(addr, wrappers.MustNewWrappedContractBackend(e.evmClient, nil))
transmitter, err := mock_usdc_token_transmitter.NewMockE2EUSDCTransmitter(addr, e.evmClient.Backend())

if err != nil {
return nil, err
Expand All @@ -136,7 +134,7 @@ func (e *CCIPContractsDeployer) DeployTokenTransmitter(domain uint32) (*TokenTra
auth *bind.TransactOpts,
backend bind.ContractBackend,
) (common.Address, *types.Transaction, interface{}, error) {
address, tx, contract, err := mock_usdc_token_transmitter.DeployMockE2EUSDCTransmitter(auth, wrappers.MustNewWrappedContractBackend(e.evmClient, nil), 0, domain)
address, tx, contract, err := mock_usdc_token_transmitter.DeployMockE2EUSDCTransmitter(auth, backend, 0, domain)
if err != nil {
return common.Address{}, nil, nil, err
}
Expand All @@ -155,7 +153,7 @@ func (e *CCIPContractsDeployer) DeployLinkTokenContract() (*LinkToken, error) {
auth *bind.TransactOpts,
backend bind.ContractBackend,
) (common.Address, *types.Transaction, interface{}, error) {
return link_token_interface.DeployLinkToken(auth, wrappers.MustNewWrappedContractBackend(e.evmClient, nil))
return link_token_interface.DeployLinkToken(auth, backend)
})

if err != nil {
Expand All @@ -174,7 +172,7 @@ func (e *CCIPContractsDeployer) DeployBurnMintERC677(ownerMintingAmount *big.Int
auth *bind.TransactOpts,
backend bind.ContractBackend,
) (common.Address, *types.Transaction, interface{}, error) {
return burn_mint_erc677.DeployBurnMintERC677(auth, wrappers.MustNewWrappedContractBackend(e.evmClient, nil), "Test Token ERC677", "TERC677", 6, new(big.Int).Mul(big.NewInt(1e18), big.NewInt(1e9)))
return burn_mint_erc677.DeployBurnMintERC677(auth, backend, "Test Token ERC677", "TERC677", 6, new(big.Int).Mul(big.NewInt(1e18), big.NewInt(1e9)))
})
if err != nil {
return nil, err
Expand Down Expand Up @@ -216,7 +214,7 @@ func (e *CCIPContractsDeployer) DeployERC20TokenContract(deployerFn blockchain.C
}

func (e *CCIPContractsDeployer) NewLinkTokenContract(addr common.Address) (*LinkToken, error) {
token, err := link_token_interface.NewLinkToken(addr, wrappers.MustNewWrappedContractBackend(e.evmClient, nil))
token, err := link_token_interface.NewLinkToken(addr, e.evmClient.Backend())

if err != nil {
return nil, err
Expand All @@ -235,7 +233,7 @@ func (e *CCIPContractsDeployer) NewLinkTokenContract(addr common.Address) (*Link
}

func (e *CCIPContractsDeployer) NewERC20TokenContract(addr common.Address) (*ERC20Token, error) {
token, err := erc20.NewERC20(addr, wrappers.MustNewWrappedContractBackend(e.evmClient, nil))
token, err := erc20.NewERC20(addr, e.evmClient.Backend())

if err != nil {
return nil, err
Expand All @@ -257,7 +255,7 @@ func (e *CCIPContractsDeployer) NewLockReleaseTokenPoolContract(addr common.Addr
*TokenPool,
error,
) {
pool, err := lock_release_token_pool.NewLockReleaseTokenPool(addr, wrappers.MustNewWrappedContractBackend(e.evmClient, nil))
pool, err := lock_release_token_pool.NewLockReleaseTokenPool(addr, e.evmClient.Backend())

if err != nil {
return nil, err
Expand All @@ -268,7 +266,7 @@ func (e *CCIPContractsDeployer) NewLockReleaseTokenPoolContract(addr common.Addr
Str("From", e.evmClient.GetDefaultWallet().Address()).
Str("Network Name", e.evmClient.GetNetworkConfig().Name).
Msg("New contract")
poolInstance, err := token_pool.NewTokenPool(addr, wrappers.MustNewWrappedContractBackend(e.evmClient, nil))
poolInstance, err := token_pool.NewTokenPool(addr, e.evmClient.Backend())
if err != nil {
return nil, err
}
Expand All @@ -284,7 +282,7 @@ func (e *CCIPContractsDeployer) NewUSDCTokenPoolContract(addr common.Address) (
*TokenPool,
error,
) {
pool, err := usdc_token_pool.NewUSDCTokenPool(addr, wrappers.MustNewWrappedContractBackend(e.evmClient, nil))
pool, err := usdc_token_pool.NewUSDCTokenPool(addr, e.evmClient.Backend())

if err != nil {
return nil, err
Expand All @@ -295,7 +293,7 @@ func (e *CCIPContractsDeployer) NewUSDCTokenPoolContract(addr common.Address) (
Str("From", e.evmClient.GetDefaultWallet().Address()).
Str("Network Name", e.evmClient.GetNetworkConfig().Name).
Msg("New contract")
poolInterface, err := token_pool.NewTokenPool(addr, wrappers.MustNewWrappedContractBackend(e.evmClient, nil))
poolInterface, err := token_pool.NewTokenPool(addr, e.evmClient.Backend())
if err != nil {
return nil, err
}
Expand All @@ -319,7 +317,7 @@ func (e *CCIPContractsDeployer) DeployUSDCTokenPoolContract(tokenAddr string, to
) (common.Address, *types.Transaction, interface{}, error) {
return usdc_token_pool.DeployUSDCTokenPool(
auth,
wrappers.MustNewWrappedContractBackend(e.evmClient, nil),
backend,
tokenMessenger,
token,
[]common.Address{},
Expand All @@ -346,7 +344,7 @@ func (e *CCIPContractsDeployer) DeployLockReleaseTokenPoolContract(tokenAddr str
) (common.Address, *types.Transaction, interface{}, error) {
return lock_release_token_pool.DeployLockReleaseTokenPool(
auth,
wrappers.MustNewWrappedContractBackend(e.evmClient, nil),
backend,
token,
[]common.Address{},
armProxy,
Expand All @@ -365,13 +363,13 @@ func (e *CCIPContractsDeployer) DeployMockARMContract() (*common.Address, error)
auth *bind.TransactOpts,
backend bind.ContractBackend,
) (common.Address, *types.Transaction, interface{}, error) {
return mock_arm_contract.DeployMockARMContract(auth, wrappers.MustNewWrappedContractBackend(e.evmClient, nil))
return mock_arm_contract.DeployMockARMContract(auth, backend)
})
return address, err
}

func (e *CCIPContractsDeployer) NewARMContract(addr common.Address) (*ARM, error) {
arm, err := arm_contract.NewARMContract(addr, wrappers.MustNewWrappedContractBackend(e.evmClient, nil))
arm, err := arm_contract.NewARMContract(addr, e.evmClient.Backend())
if err != nil {
return nil, err
}
Expand All @@ -393,7 +391,7 @@ func (e *CCIPContractsDeployer) NewCommitStore(addr common.Address) (
*CommitStore,
error,
) {
ins, err := commit_store.NewCommitStore(addr, wrappers.MustNewWrappedContractBackend(e.evmClient, nil))
ins, err := commit_store.NewCommitStore(addr, e.evmClient.Backend())
log.Info().
Str("Contract Address", addr.Hex()).
Str("Contract Name", "CommitStore").
Expand All @@ -414,7 +412,7 @@ func (e *CCIPContractsDeployer) DeployCommitStore(sourceChainSelector, destChain
) (common.Address, *types.Transaction, interface{}, error) {
return commit_store.DeployCommitStore(
auth,
wrappers.MustNewWrappedContractBackend(e.evmClient, nil),
backend,
commit_store.CommitStoreStaticConfig{
ChainSelector: destChainSelector,
SourceChainSelector: sourceChainSelector,
Expand All @@ -441,7 +439,7 @@ func (e *CCIPContractsDeployer) DeployReceiverDapp(revert bool) (
auth *bind.TransactOpts,
backend bind.ContractBackend,
) (common.Address, *types.Transaction, interface{}, error) {
return maybe_revert_message_receiver.DeployMaybeRevertMessageReceiver(auth, wrappers.MustNewWrappedContractBackend(e.evmClient, nil), revert)
return maybe_revert_message_receiver.DeployMaybeRevertMessageReceiver(auth, backend, revert)
})
if err != nil {
return nil, err
Expand All @@ -457,7 +455,7 @@ func (e *CCIPContractsDeployer) NewReceiverDapp(addr common.Address) (
*ReceiverDapp,
error,
) {
ins, err := maybe_revert_message_receiver.NewMaybeRevertMessageReceiver(addr, wrappers.MustNewWrappedContractBackend(e.evmClient, nil))
ins, err := maybe_revert_message_receiver.NewMaybeRevertMessageReceiver(addr, e.evmClient.Backend())
log.Info().
Str("Contract Address", addr.Hex()).
Str("Contract Name", "ReceiverDapp").
Expand All @@ -479,7 +477,7 @@ func (e *CCIPContractsDeployer) DeployRouter(wrappedNative common.Address, armAd
auth *bind.TransactOpts,
backend bind.ContractBackend,
) (common.Address, *types.Transaction, interface{}, error) {
return router.DeployRouter(auth, wrappers.MustNewWrappedContractBackend(e.evmClient, nil), wrappedNative, armAddress)
return router.DeployRouter(auth, backend, wrappedNative, armAddress)
})
if err != nil {
return nil, err
Expand All @@ -495,7 +493,7 @@ func (e *CCIPContractsDeployer) NewRouter(addr common.Address) (
*Router,
error,
) {
r, err := router.NewRouter(addr, wrappers.MustNewWrappedContractBackend(e.evmClient, nil))
r, err := router.NewRouter(addr, e.evmClient.Backend())
log.Info().
Str("Contract Address", addr.Hex()).
Str("Contract Name", "Router").
Expand All @@ -516,7 +514,7 @@ func (e *CCIPContractsDeployer) NewPriceRegistry(addr common.Address) (
*PriceRegistry,
error,
) {
ins, err := price_registry.NewPriceRegistry(addr, wrappers.MustNewWrappedContractBackend(e.evmClient, nil))
ins, err := price_registry.NewPriceRegistry(addr, e.evmClient.Backend())
log.Info().
Str("Contract Address", addr.Hex()).
Str("Contract Name", "PriceRegistry").
Expand All @@ -535,7 +533,7 @@ func (e *CCIPContractsDeployer) DeployPriceRegistry(tokens []common.Address) (*P
auth *bind.TransactOpts,
backend bind.ContractBackend,
) (common.Address, *types.Transaction, interface{}, error) {
return price_registry.DeployPriceRegistry(auth, wrappers.MustNewWrappedContractBackend(e.evmClient, nil), nil, tokens, 60*60*24*14)
return price_registry.DeployPriceRegistry(auth, backend, nil, tokens, 60*60*24*14)
})
if err != nil {
return nil, err
Expand All @@ -551,7 +549,7 @@ func (e *CCIPContractsDeployer) NewOnRamp(addr common.Address) (
*OnRamp,
error,
) {
ins, err := evm_2_evm_onramp.NewEVM2EVMOnRamp(addr, wrappers.MustNewWrappedContractBackend(e.evmClient, nil))
ins, err := evm_2_evm_onramp.NewEVM2EVMOnRamp(addr, e.evmClient.Backend())
log.Info().
Str("Contract Address", addr.Hex()).
Str("Contract Name", "OnRamp").
Expand Down Expand Up @@ -583,7 +581,7 @@ func (e *CCIPContractsDeployer) DeployOnRamp(
) (common.Address, *types.Transaction, interface{}, error) {
return evm_2_evm_onramp.DeployEVM2EVMOnRamp(
auth,
wrappers.MustNewWrappedContractBackend(e.evmClient, nil),
backend,
evm_2_evm_onramp.EVM2EVMOnRampStaticConfig{
LinkToken: linkTokenAddress,
ChainSelector: sourceChainSelector, // source chain id
Expand Down Expand Up @@ -629,7 +627,7 @@ func (e *CCIPContractsDeployer) NewOffRamp(addr common.Address) (
*OffRamp,
error,
) {
ins, err := evm_2_evm_offramp.NewEVM2EVMOffRamp(addr, wrappers.MustNewWrappedContractBackend(e.evmClient, nil))
ins, err := evm_2_evm_offramp.NewEVM2EVMOffRamp(addr, e.evmClient.Backend())
log.Info().
Str("Contract Address", addr.Hex()).
Str("Contract Name", "OffRamp").
Expand All @@ -650,7 +648,7 @@ func (e *CCIPContractsDeployer) DeployOffRamp(sourceChainSelector, destChainSele
) (common.Address, *types.Transaction, interface{}, error) {
return evm_2_evm_offramp.DeployEVM2EVMOffRamp(
auth,
wrappers.MustNewWrappedContractBackend(e.evmClient, nil),
backend,
evm_2_evm_offramp.EVM2EVMOffRampStaticConfig{
CommitStore: commitStore,
ChainSelector: destChainSelector,
Expand Down Expand Up @@ -683,7 +681,7 @@ func (e *CCIPContractsDeployer) DeployWrappedNative() (*common.Address, error) {
auth *bind.TransactOpts,
backend bind.ContractBackend,
) (common.Address, *types.Transaction, interface{}, error) {
return weth9.DeployWETH9(auth, wrappers.MustNewWrappedContractBackend(e.evmClient, nil))
return weth9.DeployWETH9(auth, backend)
})
if err != nil {
return nil, err
Expand All @@ -696,7 +694,7 @@ func (e *CCIPContractsDeployer) DeployMockAggregator(decimals uint8, initialAns
auth *bind.TransactOpts,
backend bind.ContractBackend,
) (common.Address, *types.Transaction, interface{}, error) {
return mock_v3_aggregator_contract.DeployMockV3Aggregator(auth, wrappers.MustNewWrappedContractBackend(e.evmClient, nil), decimals, initialAns)
return mock_v3_aggregator_contract.DeployMockV3Aggregator(auth, backend, decimals, initialAns)
})
if err != nil {
return nil, fmt.Errorf("deploying mock aggregator: %w", err)
Expand All @@ -715,7 +713,7 @@ func (e *CCIPContractsDeployer) DeployMockAggregator(decimals uint8, initialAns
}

func (e *CCIPContractsDeployer) NewMockAggregator(addr common.Address) (*MockAggregator, error) {
ins, err := mock_v3_aggregator_contract.NewMockV3Aggregator(addr, wrappers.MustNewWrappedContractBackend(e.evmClient, nil))
ins, err := mock_v3_aggregator_contract.NewMockV3Aggregator(addr, e.evmClient.Backend())
if err != nil {
return nil, fmt.Errorf("creating mock aggregator: %w", err)
}
Expand Down
27 changes: 5 additions & 22 deletions integration-tests/ccip-tests/testsetups/ccip.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,21 +222,6 @@ func (c *CCIPTestConfig) SetNetworkPairs(lggr zerolog.Logger) error {
DefaultGasLimit: n.DefaultGasLimit,
FinalityDepth: n.FinalityDepth,
})
chainConfig := &ctftestenv.EthereumChainConfig{}
err := chainConfig.Default()
if err != nil {
allError = multierr.Append(allError, fmt.Errorf("failed to get default chain config: %w", err))
} else {
chainConfig.ChainID = int(chainID)
eth1 := ctftestenv.EthereumVersion_Eth1
geth := ctftestenv.ExecutionLayer_Geth

c.EnvInput.PrivateEthereumNetworks[fmt.Sprint(chainID)] = &ctftestenv.EthereumNetwork{
EthereumVersion: &eth1,
ExecutionLayer: &geth,
EthereumChainConfig: chainConfig,
}
}
}
}

Expand Down Expand Up @@ -963,13 +948,11 @@ func (o *CCIPTestSetUpOutputs) CreateEnvironment(
chainByChainID := make(map[int64]blockchain.EVMClient)
if pointer.GetBool(testConfig.TestGroupInput.LocalCluster) {
require.NotNil(t, ccipEnv.LocalCluster, "Local cluster shouldn't be nil")
for _, n := range ccipEnv.LocalCluster.EVMNetworks {
if evmClient, err := blockchain.NewEVMClientFromNetwork(*n, lggr); err == nil {
chainByChainID[evmClient.GetChainID().Int64()] = evmClient
chains = append(chains, evmClient)
} else {
lggr.Error().Err(err).Msgf("EVMClient for chainID %d not found", n.ChainID)
}
for _, n := range ccipEnv.LocalCluster.PrivateChain {
primaryNode := n.GetPrimaryNode()
require.NotNil(t, primaryNode, "Primary node is nil in PrivateChain interface")
chainByChainID[primaryNode.GetEVMClient().GetChainID().Int64()] = primaryNode.GetEVMClient()
chains = append(chains, primaryNode.GetEVMClient())
}
} else {
for _, n := range testConfig.SelectedNetworks {
Expand Down
Loading

0 comments on commit d796cb8

Please sign in to comment.