diff --git a/deployment/ccip/changeset/cs_add_lane_test.go b/deployment/ccip/changeset/cs_add_lane_test.go index f7224523e3e..93f3bc2aa54 100644 --- a/deployment/ccip/changeset/cs_add_lane_test.go +++ b/deployment/ccip/changeset/cs_add_lane_test.go @@ -90,7 +90,7 @@ func TestAddLanesWithTestRouter(t *testing.T) { chain2: true, }, }, - // off + // offramp update on dest chain chain2: { OffRampUpdates: map[uint64]bool{ chain1: true, diff --git a/deployment/ccip/changeset/test_helpers.go b/deployment/ccip/changeset/test_helpers.go index 435c0a7aff2..780c28fd790 100644 --- a/deployment/ccip/changeset/test_helpers.go +++ b/deployment/ccip/changeset/test_helpers.go @@ -390,9 +390,8 @@ func MakeEVMExtraArgsV2(gasLimit uint64, allowOOO bool) []byte { return extraArgs } -func AddLaneWithDefaultPricesAndFeeQuoterConfig(t *testing.T, e *DeployedEnv, state CCIPOnChainState, from, to uint64, isTestRouter bool) { +func AddLane(t *testing.T, e *DeployedEnv, from, to uint64, isTestRouter bool, gasprice map[uint64]*big.Int, tokenPrices map[common.Address]*big.Int, fqCfg fee_quoter.FeeQuoterDestChainConfig) { var err error - stateChain1 := state.Chains[from] e.Env, err = commoncs.ApplyChangesets(t, e.Env, e.TimelockContracts(t), []commoncs.ChangesetApplication{ { Changeset: commoncs.WrapChangeSet(UpdateOnRampsDests), @@ -413,13 +412,8 @@ func AddLaneWithDefaultPricesAndFeeQuoterConfig(t *testing.T, e *DeployedEnv, st Config: UpdateFeeQuoterPricesConfig{ InitialPrices: map[uint64]FeeQuoterPriceUpdatePerSource{ from: { - TokenPrices: map[common.Address]*big.Int{ - stateChain1.LinkToken.Address(): DefaultLinkPrice, - stateChain1.Weth9.Address(): DefaultWethPrice, - }, - GasPrices: map[uint64]*big.Int{ - to: DefaultGasPrice, - }, + TokenPrices: tokenPrices, + GasPrices: gasprice, }, }, }, @@ -429,7 +423,7 @@ func AddLaneWithDefaultPricesAndFeeQuoterConfig(t *testing.T, e *DeployedEnv, st Config: UpdateFeeQuoterDestsConfig{ UpdatesByChain: map[uint64]map[uint64]fee_quoter.FeeQuoterDestChainConfig{ from: { - to: DefaultFeeQuoterDestChainConfig(), + to: fqCfg, }, }, }, @@ -441,7 +435,7 @@ func AddLaneWithDefaultPricesAndFeeQuoterConfig(t *testing.T, e *DeployedEnv, st to: { from: { IsEnabled: true, - TestRouter: true, + TestRouter: isTestRouter, }, }, }, @@ -450,7 +444,7 @@ func AddLaneWithDefaultPricesAndFeeQuoterConfig(t *testing.T, e *DeployedEnv, st { Changeset: commoncs.WrapChangeSet(UpdateRouterRamps), Config: UpdateRouterRampsConfig{ - TestRouter: true, + TestRouter: isTestRouter, UpdatesByChain: map[uint64]RouterUpdates{ // onRamp update on source chain from: { @@ -458,10 +452,10 @@ func AddLaneWithDefaultPricesAndFeeQuoterConfig(t *testing.T, e *DeployedEnv, st to: true, }, }, - // off - from: { + // offramp update on dest chain + to: { OffRampUpdates: map[uint64]bool{ - to: true, + from: true, }, }, }, @@ -471,6 +465,17 @@ func AddLaneWithDefaultPricesAndFeeQuoterConfig(t *testing.T, e *DeployedEnv, st require.NoError(t, err) } +func AddLaneWithDefaultPricesAndFeeQuoterConfig(t *testing.T, e *DeployedEnv, state CCIPOnChainState, from, to uint64, isTestRouter bool) { + stateChainFrom := state.Chains[from] + AddLane(t, e, from, to, isTestRouter, + map[uint64]*big.Int{ + to: DefaultGasPrice, + }, map[common.Address]*big.Int{ + stateChainFrom.LinkToken.Address(): DefaultLinkPrice, + stateChainFrom.Weth9.Address(): DefaultWethPrice, + }, DefaultFeeQuoterDestChainConfig()) +} + // AddLanesForAll adds densely connected lanes for all chains in the environment so that each chain // is connected to every other chain except itself. func AddLanesForAll(t *testing.T, e *DeployedEnv, state CCIPOnChainState) { diff --git a/deployment/multiclient_test.go b/deployment/multiclient_test.go index 2e10c46e33f..5faf1818a57 100644 --- a/deployment/multiclient_test.go +++ b/deployment/multiclient_test.go @@ -9,9 +9,16 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/router" "github.com/smartcontractkit/chainlink/v2/core/logger" ) +func TestRevert(t *testing.T) { + errreason, err := parseErrorFromABI("0xae236d9c0000000000000000000000000000000000000000000000004d0102030cb384f5", router.RouterABI) + require.NoError(t, err) + require.Contains(t, errreason, "error not found in ABI") +} + func TestMultiClient(t *testing.T) { lggr := logger.TestLogger(t) // Expect an error if no RPCs supplied. diff --git a/integration-tests/contracts/ccipreader_test.go b/integration-tests/contracts/ccipreader_test.go index 35668cdd369..f46a680c8a0 100644 --- a/integration-tests/contracts/ccipreader_test.go +++ b/integration-tests/contracts/ccipreader_test.go @@ -785,7 +785,7 @@ func Test_LinkPriceUSD(t *testing.T) { linkPriceUSD, err := reader.LinkPriceUSD(ctx) require.NoError(t, err) require.NotNil(t, linkPriceUSD.Int) - require.Equal(t, changeset.DefaultInitialPrices.LinkPrice, linkPriceUSD.Int) + require.Equal(t, changeset.DefaultLinkPrice, linkPriceUSD.Int) } func Test_GetMedianDataAvailabilityGasConfig(t *testing.T) { @@ -884,7 +884,7 @@ func Test_GetWrappedNativeTokenPriceUSD(t *testing.T) { // Only chainD has reader contracts bound require.Len(t, prices, 1) - require.Equal(t, changeset.DefaultInitialPrices.WethPrice, prices[cciptypes.ChainSelector(chain1)].Int) + require.Equal(t, changeset.DefaultWethPrice, prices[cciptypes.ChainSelector(chain1)].Int) } // Benchmark Results: diff --git a/integration-tests/smoke/ccip/ccip_fee_boosting_test.go b/integration-tests/smoke/ccip/ccip_fee_boosting_test.go index 576ee356fbb..831254fe835 100644 --- a/integration-tests/smoke/ccip/ccip_fee_boosting_test.go +++ b/integration-tests/smoke/ccip/ccip_fee_boosting_test.go @@ -2,15 +2,13 @@ package smoke import ( "context" - "fmt" "math/big" "testing" "time" - "github.com/pkg/errors" - "github.com/smartcontractkit/chainlink-common/pkg/config" - commonchangeset "github.com/smartcontractkit/chainlink/deployment/common/changeset" + + commoncs "github.com/smartcontractkit/chainlink/deployment/common/changeset" testsetups "github.com/smartcontractkit/chainlink/integration-tests/testsetups/ccip" "github.com/ethereum/go-ethereum/accounts/abi/bind" @@ -20,11 +18,10 @@ import ( "github.com/smartcontractkit/chainlink-testing-framework/lib/utils/testcontext" - "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/ccipevm" - "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/fee_quoter" - cciptypes "github.com/smartcontractkit/chainlink-ccip/pkg/types/ccipocr3" + "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/ccipevm" + "github.com/smartcontractkit/chainlink/deployment" "github.com/smartcontractkit/chainlink/deployment/ccip/changeset" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/onramp" @@ -84,32 +81,31 @@ func Test_CCIPFeeBoosting(t *testing.T) { ) t.Log("Adjusted gas price on dest chain:", adjustedGasPriceDest) - initialPrices := changeset.InitialPrices{ - LinkPrice: linkPrice, - WethPrice: wethPrice, - GasPrice: changeset.ToPackedFee(adjustedGasPriceDest, big.NewInt(0)), - } - - laneCfg := changeset.LaneConfig{ - SourceSelector: sourceChain, - DestSelector: destChain, - InitialPricesBySource: initialPrices, - FeeQuoterDestChain: changeset.DefaultFeeQuoterDestChainConfig(), - TestRouter: false, - } - - e.Env, err = commonchangeset.ApplyChangesets(t, e.Env, nil, []commonchangeset.ChangesetApplication{ - { - Changeset: commonchangeset.WrapChangeSet(changeset.AddLanes), - Config: changeset.AddLanesConfig{LaneConfigs: []changeset.LaneConfig{laneCfg}}, + changeset.AddLane(t, &e, sourceChain, destChain, false, + map[uint64]*big.Int{ + destChain: changeset.ToPackedFee(adjustedGasPriceDest, big.NewInt(0)), }, - }) - require.NoError(t, err) + map[common.Address]*big.Int{ + state.Chains[sourceChain].LinkToken.Address(): linkPrice, + state.Chains[sourceChain].Weth9.Address(): wethPrice, + }, + changeset.DefaultFeeQuoterDestChainConfig()) // Update token prices in destination chain FeeQuoter - err = updateTokensPrices(e, state, destChain, map[common.Address]*big.Int{ - state.Chains[destChain].LinkToken.Address(): linkPrice, - state.Chains[destChain].Weth9.Address(): wethPrice, + e.Env, err = commoncs.ApplyChangesets(t, e.Env, e.TimelockContracts(t), []commoncs.ChangesetApplication{ + { + Changeset: commoncs.WrapChangeSet(changeset.UpdateFeeQuoterPricesCS), + Config: changeset.UpdateFeeQuoterPricesConfig{ + InitialPrices: map[uint64]changeset.FeeQuoterPriceUpdatePerSource{ + destChain: { + TokenPrices: map[common.Address]*big.Int{ + state.Chains[destChain].LinkToken.Address(): linkPrice, + state.Chains[destChain].Weth9.Address(): wethPrice, + }, + }, + }, + }, + }, }) require.NoError(t, err) @@ -137,7 +133,20 @@ func Test_CCIPFeeBoosting(t *testing.T) { DestChainSelector: destChain, }] = []uint64{msgSentEvent.SequenceNumber} - err = updateGasPrice(e, state, sourceChain, destChain, originalGasPriceDestUSD) + e.Env, err = commoncs.ApplyChangesets(t, e.Env, e.TimelockContracts(t), []commoncs.ChangesetApplication{ + { + Changeset: commoncs.WrapChangeSet(changeset.UpdateFeeQuoterPricesCS), + Config: changeset.UpdateFeeQuoterPricesConfig{ + InitialPrices: map[uint64]changeset.FeeQuoterPriceUpdatePerSource{ + sourceChain: { + GasPrices: map[uint64]*big.Int{ + destChain: originalGasPriceDestUSD, + }, + }, + }, + }, + }, + }) require.NoError(t, err) // Confirm gas prices are updated @@ -270,61 +279,3 @@ func convertToMessage(msg onramp.InternalEVM2AnyRampMessage) cciptypes.Message { TokenAmounts: tokenAmounts, } } - -func updateGasPrice(env changeset.DeployedEnv, state changeset.CCIPOnChainState, srcChain, destChain uint64, gasPrice *big.Int) error { - chainState, exists := state.Chains[srcChain] - if !exists { - return fmt.Errorf("chain state not found for selector: %d", srcChain) - } - - feeQuoter := chainState.FeeQuoter - // Update gas price - auth := env.Env.Chains[srcChain].DeployerKey - tx, err := feeQuoter.UpdatePrices(auth, fee_quoter.InternalPriceUpdates{ - TokenPriceUpdates: nil, - GasPriceUpdates: []fee_quoter.InternalGasPriceUpdate{ - { - DestChainSelector: destChain, - UsdPerUnitGas: gasPrice, - }, - }, - }) - if err != nil { - return errors.Wrapf(err, "updating gas price on chain %d", srcChain) - } - if _, err := deployment.ConfirmIfNoError(env.Env.Chains[srcChain], tx, err); err != nil { - return err - } - - return nil -} - -func updateTokensPrices(env changeset.DeployedEnv, state changeset.CCIPOnChainState, chain uint64, tokenPrices map[common.Address]*big.Int) error { - chainState, exists := state.Chains[chain] - if !exists { - return fmt.Errorf("chain state not found for selector: %d", chain) - } - - feeQuoter := chainState.FeeQuoter - // Update token prices - auth := env.Env.Chains[chain].DeployerKey - tokenPricesUpdates := make([]fee_quoter.InternalTokenPriceUpdate, 0, len(tokenPrices)) - for token, price := range tokenPrices { - tokenPricesUpdates = append(tokenPricesUpdates, fee_quoter.InternalTokenPriceUpdate{ - SourceToken: token, - UsdPerToken: price, - }) - } - tx, err := feeQuoter.UpdatePrices(auth, fee_quoter.InternalPriceUpdates{ - TokenPriceUpdates: tokenPricesUpdates, - GasPriceUpdates: nil, - }) - if err != nil { - return errors.Wrapf(err, "updating token prices on chain %d", chain) - } - if _, err := deployment.ConfirmIfNoError(env.Env.Chains[chain], tx, err); err != nil { - return err - } - - return nil -}