Skip to content

Commit

Permalink
Merge branch 'develop' into ml/v4-telemetry
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-cll committed Sep 20, 2024
2 parents 63bd174 + 22a8c99 commit 131bad5
Show file tree
Hide file tree
Showing 22 changed files with 341 additions and 74 deletions.
5 changes: 5 additions & 0 deletions .changeset/young-lions-provide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": patch
---

#added feed deployment to ccip integration tests
4 changes: 2 additions & 2 deletions core/scripts/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ require (
github.com/prometheus/client_golang v1.20.0
github.com/shopspring/decimal v1.4.0
github.com/smartcontractkit/chainlink-automation v1.0.4
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240918210534-564164004d06
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240919092417-53e784c2e420
github.com/smartcontractkit/chainlink/v2 v2.0.0-00010101000000-000000000000
github.com/smartcontractkit/libocr v0.0.0-20240717100443-f6226e09bee7
github.com/spf13/cobra v1.8.1
Expand Down Expand Up @@ -271,7 +271,7 @@ require (
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
github.com/shirou/gopsutil/v3 v3.24.3 // indirect
github.com/smartcontractkit/chain-selectors v1.0.23 // indirect
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240917180332-5a68498d1612 // indirect
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240919174352-8d485ebc0953 // indirect
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240911175228-daf2600bb7b7 // indirect
github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240916152957-433914114bd2 // indirect
github.com/smartcontractkit/chainlink-feeds v0.0.0-20240910155501-42f20443189f // indirect
Expand Down
8 changes: 4 additions & 4 deletions core/scripts/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1081,10 +1081,10 @@ github.com/smartcontractkit/chain-selectors v1.0.23 h1:D2Eaex4Cw/O7Lg3tX6WklOqnj
github.com/smartcontractkit/chain-selectors v1.0.23/go.mod h1:d4Hi+E1zqjy9HqMkjBE5q1vcG9VGgxf5VxiRHfzi2kE=
github.com/smartcontractkit/chainlink-automation v1.0.4 h1:iyW181JjKHLNMnDleI8umfIfVVlwC7+n5izbLSFgjw8=
github.com/smartcontractkit/chainlink-automation v1.0.4/go.mod h1:u4NbPZKJ5XiayfKHD/v3z3iflQWqvtdhj13jVZXj/cM=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240917180332-5a68498d1612 h1:xPEM9XbfZmv8N3NjZ7AX5salonll/LdXrbb8JCbA4FE=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240917180332-5a68498d1612/go.mod h1:Lv77O13ZxOdmlvnu2vaUC0Lg+t3JAL+N+9K8dRsgmDI=
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240918210534-564164004d06 h1:wqLXuPdiUkn7es/epKmOpB0Q0tKdA9FkYPNQZrZ+VJU=
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240918210534-564164004d06/go.mod h1:zm+l8gN4LQS1+YvwQDhRz/njirVeWGNiDJKIhCGwaoQ=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240919174352-8d485ebc0953 h1:/Bx9MUUQ+TfS8kIdER8gujpJWfYu8ft4FYzpH8gSPJY=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240919174352-8d485ebc0953/go.mod h1:KP82vFCqm+M1G1t6Vos5CewGUGYJkxxCEdxnta4uLlE=
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240919092417-53e784c2e420 h1:+xNnYYgkxzKUIkLCOfzfAKUxeLLtuxlalDI70kNJ8No=
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240919092417-53e784c2e420/go.mod h1:zm+l8gN4LQS1+YvwQDhRz/njirVeWGNiDJKIhCGwaoQ=
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240911175228-daf2600bb7b7 h1:lTGIOQYLk1Ufn++X/AvZnt6VOcuhste5yp+C157No/Q=
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240911175228-daf2600bb7b7/go.mod h1:BMYE1vC/pGmdFSsOJdPrAA0/4gZ0Xo0SxTMdGspBtRo=
github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240916152957-433914114bd2 h1:yRk4ektpx/UxwarqAfgxUXLrsYXlaNeP1NOwzHGrK2Q=
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ require (
github.com/shopspring/decimal v1.4.0
github.com/smartcontractkit/chain-selectors v1.0.23
github.com/smartcontractkit/chainlink-automation v1.0.4
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240917180332-5a68498d1612
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240918210534-564164004d06
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240919174352-8d485ebc0953
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240919092417-53e784c2e420
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240911175228-daf2600bb7b7
github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240916152957-433914114bd2
github.com/smartcontractkit/chainlink-feeds v0.0.0-20240910155501-42f20443189f
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1042,10 +1042,10 @@ github.com/smartcontractkit/chain-selectors v1.0.23 h1:D2Eaex4Cw/O7Lg3tX6WklOqnj
github.com/smartcontractkit/chain-selectors v1.0.23/go.mod h1:d4Hi+E1zqjy9HqMkjBE5q1vcG9VGgxf5VxiRHfzi2kE=
github.com/smartcontractkit/chainlink-automation v1.0.4 h1:iyW181JjKHLNMnDleI8umfIfVVlwC7+n5izbLSFgjw8=
github.com/smartcontractkit/chainlink-automation v1.0.4/go.mod h1:u4NbPZKJ5XiayfKHD/v3z3iflQWqvtdhj13jVZXj/cM=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240917180332-5a68498d1612 h1:xPEM9XbfZmv8N3NjZ7AX5salonll/LdXrbb8JCbA4FE=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240917180332-5a68498d1612/go.mod h1:Lv77O13ZxOdmlvnu2vaUC0Lg+t3JAL+N+9K8dRsgmDI=
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240918210534-564164004d06 h1:wqLXuPdiUkn7es/epKmOpB0Q0tKdA9FkYPNQZrZ+VJU=
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240918210534-564164004d06/go.mod h1:zm+l8gN4LQS1+YvwQDhRz/njirVeWGNiDJKIhCGwaoQ=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240919174352-8d485ebc0953 h1:/Bx9MUUQ+TfS8kIdER8gujpJWfYu8ft4FYzpH8gSPJY=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240919174352-8d485ebc0953/go.mod h1:KP82vFCqm+M1G1t6Vos5CewGUGYJkxxCEdxnta4uLlE=
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240919092417-53e784c2e420 h1:+xNnYYgkxzKUIkLCOfzfAKUxeLLtuxlalDI70kNJ8No=
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240919092417-53e784c2e420/go.mod h1:zm+l8gN4LQS1+YvwQDhRz/njirVeWGNiDJKIhCGwaoQ=
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240911175228-daf2600bb7b7 h1:lTGIOQYLk1Ufn++X/AvZnt6VOcuhste5yp+C157No/Q=
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240911175228-daf2600bb7b7/go.mod h1:BMYE1vC/pGmdFSsOJdPrAA0/4gZ0Xo0SxTMdGspBtRo=
github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240916152957-433914114bd2 h1:yRk4ektpx/UxwarqAfgxUXLrsYXlaNeP1NOwzHGrK2Q=
Expand Down
15 changes: 14 additions & 1 deletion integration-tests/deployment/ccip/add_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@ import (

"github.com/smartcontractkit/ccip-owner-contracts/tools/proposal/mcms"
"github.com/smartcontractkit/ccip-owner-contracts/tools/proposal/timelock"

chainsel "github.com/smartcontractkit/chain-selectors"

"github.com/smartcontractkit/chainlink-ccip/chainconfig"

"github.com/smartcontractkit/chainlink-common/pkg/types/ccipocr3"

"github.com/smartcontractkit/chainlink/integration-tests/deployment"

"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/ccip_config"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/fee_quoter"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/onramp"
Expand All @@ -22,8 +26,10 @@ func NewChainInboundProposal(
e deployment.Environment,
state CCIPOnChainState,
homeChainSel uint64,
feedChainSel uint64,
newChainSel uint64,
sources []uint64,
tokenConfig TokenConfig,
) (*timelock.MCMSWithTimelockProposal, error) {
// Generate proposal which enables new destination (from test router) on all source chains.
var batches []timelock.BatchChainOperation
Expand Down Expand Up @@ -118,7 +124,14 @@ func NewChainInboundProposal(
return nil, err
}

newDONArgs, err := BuildAddDONArgs(e.Logger, state.Chains[newChainSel].OffRamp, e.Chains[newChainSel], nodes.NonBootstraps())
newDONArgs, err := BuildAddDONArgs(
e.Logger,
state.Chains[newChainSel].OffRamp,
e.Chains[newChainSel],
feedChainSel,
tokenConfig.GetTokenInfo(e.Logger, state.Chains[newChainSel]),
nodes.NonBootstraps(),
)
if err != nil {
return nil, err
}
Expand Down
25 changes: 24 additions & 1 deletion integration-tests/deployment/ccip/add_chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,18 @@ import (
"time"

"github.com/ethereum/go-ethereum/common"

"github.com/smartcontractkit/chainlink-ccip/pluginconfig"

cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccipocr3"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/smartcontractkit/chainlink-testing-framework/lib/utils/testcontext"

"github.com/smartcontractkit/chainlink/integration-tests/deployment"

"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/offramp"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/router"
"github.com/smartcontractkit/chainlink/v2/core/logger"
Expand All @@ -27,9 +33,20 @@ func TestAddChainInbound(t *testing.T) {
// We deploy to the rest.
initialDeploy := e.Env.AllChainSelectorsExcluding([]uint64{newChain})

feeds := state.Chains[e.FeedChainSel].USDFeeds
tokenConfig := NewTokenConfig()
tokenConfig.UpsertTokenInfo(LinkSymbol,
pluginconfig.TokenInfo{
AggregatorAddress: feeds[LinkSymbol].Address().String(),
Decimals: LinkDecimals,
DeviationPPB: cciptypes.NewBigIntFromInt64(1e9),
},
)
ab, err := DeployCCIPContracts(e.Env, DeployCCIPContractConfig{
HomeChainSel: e.HomeChainSel,
FeedChainSel: e.FeedChainSel,
ChainsToDeploy: initialDeploy,
TokenConfig: tokenConfig,
CCIPOnChainState: state,
})
require.NoError(t, err)
Expand Down Expand Up @@ -103,7 +120,7 @@ func TestAddChainInbound(t *testing.T) {
require.Equal(t, state.Chains[e.HomeChainSel].Timelock.Address(), crOwner)

// Generate and sign inbound proposal to new 4th chain.
chainInboundProposal, err := NewChainInboundProposal(e.Env, state, e.HomeChainSel, newChain, initialDeploy)
chainInboundProposal, err := NewChainInboundProposal(e.Env, state, e.HomeChainSel, e.FeedChainSel, newChain, initialDeploy, tokenConfig)
require.NoError(t, err)
chainInboundExec := SignProposal(t, e.Env, chainInboundProposal)
for _, sel := range initialDeploy {
Expand Down Expand Up @@ -160,4 +177,10 @@ func TestAddChainInbound(t *testing.T) {
seqNr := SendRequest(t, e.Env, state, initialDeploy[0], newChain, true)
require.NoError(t,
ConfirmExecWithSeqNr(t, e.Env.Chains[initialDeploy[0]], e.Env.Chains[newChain], state.Chains[newChain].OffRamp, &startBlock, seqNr))

linkAddress := state.Chains[newChain].LinkToken.Address()
feeQuoter := state.Chains[newChain].FeeQuoter
timestampedPrice, err := feeQuoter.GetTokenPrice(nil, linkAddress)
require.NoError(t, err)
require.Equal(t, MockLinkPrice, timestampedPrice.Value)
}
2 changes: 2 additions & 0 deletions integration-tests/deployment/ccip/add_lane_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ func TestAddLane(t *testing.T) {
// Set up CCIP contracts and a DON per chain.
ab, err := DeployCCIPContracts(e.Env, DeployCCIPContractConfig{
HomeChainSel: e.HomeChainSel,
FeedChainSel: e.FeedChainSel,
TokenConfig: NewTokenConfig(),
CCIPOnChainState: state,
})
require.NoError(t, err)
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/deployment/ccip/changeset/1_cap_reg.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
// Separate migration because cap reg is an env var for CL nodes.
func Apply0001(env deployment.Environment, homeChainSel uint64) (deployment.ChangesetOutput, error) {
// Note we also deploy the cap reg.
ab, _, err := ccipdeployment.DeployCapReg(env.Logger, env.Chains, homeChainSel)
ab, _, err := ccipdeployment.DeployCapReg(env.Logger, env.Chains[homeChainSel])
if err != nil {
env.Logger.Errorw("Failed to deploy cap reg", "err", err, "addresses", ab)
return deployment.ChangesetOutput{}, err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,56 @@ package changeset
import (
"testing"

"github.com/smartcontractkit/chainlink-ccip/pluginconfig"

cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccipocr3"

"github.com/stretchr/testify/require"

"github.com/smartcontractkit/chainlink-testing-framework/lib/utils/testcontext"

ccipdeployment "github.com/smartcontractkit/chainlink/integration-tests/deployment/ccip"
ccdeploy "github.com/smartcontractkit/chainlink/integration-tests/deployment/ccip"
jobv1 "github.com/smartcontractkit/chainlink/integration-tests/deployment/jd/job/v1"

"github.com/smartcontractkit/chainlink/v2/core/logger"
)

func Test0002_InitialDeploy(t *testing.T) {
lggr := logger.TestLogger(t)
ctx := ccipdeployment.Context(t)
tenv := ccipdeployment.NewEnvironmentWithCR(t, lggr, 3)
ctx := ccdeploy.Context(t)
tenv := ccdeploy.NewEnvironmentWithCRAndFeeds(t, lggr, 3)
e := tenv.Env
nodes := tenv.Nodes
chains := e.Chains

state, err := ccipdeployment.LoadOnchainState(tenv.Env, tenv.Ab)
state, err := ccdeploy.LoadOnchainState(tenv.Env, tenv.Ab)
require.NoError(t, err)

feeds := state.Chains[tenv.FeedChainSel].USDFeeds
tokenConfig := ccdeploy.NewTokenConfig()
tokenConfig.UpsertTokenInfo(ccdeploy.LinkSymbol,
pluginconfig.TokenInfo{
AggregatorAddress: feeds[ccdeploy.LinkSymbol].Address().String(),
Decimals: ccdeploy.LinkDecimals,
DeviationPPB: cciptypes.NewBigIntFromInt64(1e9),
},
)
// Apply migration
output, err := Apply0002(tenv.Env, ccipdeployment.DeployCCIPContractConfig{
output, err := Apply0002(tenv.Env, ccdeploy.DeployCCIPContractConfig{
HomeChainSel: tenv.HomeChainSel,
FeedChainSel: tenv.FeedChainSel,
ChainsToDeploy: tenv.Env.AllChainSelectors(),
// Capreg/config already exist.
TokenConfig: tokenConfig,
// Capreg/config and feeds already exist.
CCIPOnChainState: state,
})
require.NoError(t, err)
// Get new state after migration.
state, err = ccipdeployment.LoadOnchainState(e, output.AddressBook)
state, err = ccdeploy.LoadOnchainState(e, output.AddressBook)
require.NoError(t, err)

// Ensure capreg logs are up to date.
require.NoError(t, ccipdeployment.ReplayAllLogs(nodes, chains))
require.NoError(t, ccdeploy.ReplayAllLogs(nodes, chains))

// Apply the jobs.
for nodeID, jobs := range output.JobSpecs {
Expand All @@ -52,7 +68,7 @@ func Test0002_InitialDeploy(t *testing.T) {
}

// Add all lanes
require.NoError(t, ccipdeployment.AddLanesForAll(e, state))
require.NoError(t, ccdeploy.AddLanesForAll(e, state))
// Need to keep track of the block number for each chain so that event subscription can be done from that block.
startBlocks := make(map[uint64]*uint64)
// Send a message from each chain to every other chain.
Expand All @@ -66,16 +82,25 @@ func Test0002_InitialDeploy(t *testing.T) {
require.NoError(t, err)
block := latesthdr.Number.Uint64()
startBlocks[dest] = &block
seqNum := ccipdeployment.SendRequest(t, e, state, src, dest, false)
seqNum := ccdeploy.SendRequest(t, e, state, src, dest, false)
expectedSeqNum[dest] = seqNum
}
}

// Wait for all commit reports to land.
ccipdeployment.ConfirmCommitForAllWithExpectedSeqNums(t, e, state, expectedSeqNum, startBlocks)
ccdeploy.ConfirmCommitForAllWithExpectedSeqNums(t, e, state, expectedSeqNum, startBlocks)

// After commit is reported on all chains, token prices should be updated in FeeQuoter.
for dest := range e.Chains {
linkAddress := state.Chains[dest].LinkToken.Address()
feeQuoter := state.Chains[dest].FeeQuoter
timestampedPrice, err := feeQuoter.GetTokenPrice(nil, linkAddress)
require.NoError(t, err)
require.Equal(t, ccdeploy.MockLinkPrice, timestampedPrice.Value)
}

// Wait for all exec reports to land
ccipdeployment.ConfirmExecWithSeqNrForAll(t, e, state, expectedSeqNum, startBlocks)
ccdeploy.ConfirmExecWithSeqNrForAll(t, e, state, expectedSeqNum, startBlocks)

// TODO: Apply the proposal.
}
10 changes: 10 additions & 0 deletions integration-tests/deployment/ccip/consts.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package ccipdeployment

type TokenSymbol string

const (
LinkSymbol TokenSymbol = "LINK"
WethSymbol TokenSymbol = "WETH"
LinkDecimals = 18
WethDecimals = 18
)
11 changes: 10 additions & 1 deletion integration-tests/deployment/ccip/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"

"github.com/smartcontractkit/ccip-owner-contracts/tools/configwrappers"
owner_helpers "github.com/smartcontractkit/ccip-owner-contracts/tools/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/generated/aggregator_v3_interface"

"github.com/smartcontractkit/chainlink/integration-tests/deployment"

Expand Down Expand Up @@ -48,6 +50,7 @@ var (
OnRamp deployment.ContractType = "OnRamp"
OffRamp deployment.ContractType = "OffRamp"
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"
Expand Down Expand Up @@ -78,7 +81,8 @@ type Contracts interface {
*offramp.OffRamp |
*onramp.OnRamp |
*burn_mint_erc677.BurnMintERC677 |
*maybe_revert_message_receiver.MaybeRevertMessageReceiver
*maybe_revert_message_receiver.MaybeRevertMessageReceiver |
*aggregator_v3_interface.AggregatorV3Interface
}

type ContractDeploy[C Contracts] struct {
Expand Down Expand Up @@ -119,7 +123,9 @@ func deployContract[C Contracts](

type DeployCCIPContractConfig struct {
HomeChainSel uint64
FeedChainSel uint64
ChainsToDeploy []uint64
TokenConfig TokenConfig
// Existing contracts which we want to skip deployment
// Leave empty if we want to deploy everything
// TODO: Add skips to deploy function.
Expand Down Expand Up @@ -178,6 +184,7 @@ func DeployCCIPContracts(e deployment.Environment, c DeployCCIPContractConfig) (
return ab, err
}

tokenInfo := c.TokenConfig.GetTokenInfo(e.Logger, chainState)
// TODO: Do we want to extract this?
// Add chain config for each chain.
_, err = AddChainConfig(
Expand All @@ -196,6 +203,8 @@ func DeployCCIPContracts(e deployment.Environment, c DeployCCIPContractConfig) (
c.Chains[c.HomeChainSel].CapabilityRegistry,
c.Chains[c.HomeChainSel].CCIPConfig,
chainState.OffRamp,
c.FeedChainSel,
tokenInfo,
chain,
e.Chains[c.HomeChainSel],
nodes.NonBootstraps(),
Expand Down
Loading

0 comments on commit 131bad5

Please sign in to comment.