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

Fix static link issue in tooling #16174

Merged
merged 28 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
ded3f4c
Merge branch 'develop' of github.com:smartcontractkit/chainlink into …
AnieeG Dec 7, 2024
10314c8
Merge branch 'develop' of github.com:smartcontractkit/chainlink into …
AnieeG Dec 10, 2024
5f14bf0
remove deployCCIPContracts
AnieeG Dec 10, 2024
75c676f
Merge branch 'develop' of github.com:smartcontractkit/chainlink into …
AnieeG Dec 10, 2024
b31ec5a
Merge branch 'develop' of github.com:smartcontractkit/chainlink into …
AnieeG Dec 10, 2024
5f6d2d5
Merge branch 'develop' of github.com:smartcontractkit/chainlink into …
AnieeG Dec 13, 2024
65616ff
Merge branch 'develop' of github.com:smartcontractkit/chainlink into …
AnieeG Dec 13, 2024
6dd9c4a
Merge branch 'develop' of github.com:smartcontractkit/chainlink into …
AnieeG Dec 13, 2024
813cc6e
Merge branch 'develop' of github.com:smartcontractkit/chainlink into …
AnieeG Dec 18, 2024
a299e7c
Merge branch 'develop' of github.com:smartcontractkit/chainlink into …
AnieeG Dec 19, 2024
1837b21
deprecate existing add lane
AnieeG Dec 20, 2024
bda53fc
Merge branch 'develop' of github.com:smartcontractkit/chainlink into …
AnieeG Jan 3, 2025
e171316
Merge branch 'develop' of github.com:smartcontractkit/chainlink into …
AnieeG Jan 6, 2025
52422ba
Merge branch 'develop' of github.com:smartcontractkit/chainlink into …
AnieeG Jan 9, 2025
56b0ff1
Merge branch 'develop' of github.com:smartcontractkit/chainlink into …
AnieeG Jan 10, 2025
e261d27
Merge branch 'develop' of github.com:smartcontractkit/chainlink into …
AnieeG Jan 14, 2025
35d936e
Merge branch 'develop' of github.com:smartcontractkit/chainlink into …
AnieeG Jan 15, 2025
1c1c31a
Merge branch 'develop' of github.com:smartcontractkit/chainlink into …
AnieeG Jan 17, 2025
637f6a2
Merge branch 'develop' of github.com:smartcontractkit/chainlink into …
AnieeG Jan 23, 2025
a290364
Merge branch 'develop' of github.com:smartcontractkit/chainlink into …
AnieeG Jan 27, 2025
8722ae8
Merge branch 'develop' of github.com:smartcontractkit/chainlink into …
AnieeG Jan 29, 2025
8e54c04
Merge branch 'develop' of github.com:smartcontractkit/chainlink into …
AnieeG Jan 29, 2025
03dd894
Merge branch 'develop' of github.com:smartcontractkit/chainlink into …
AnieeG Jan 31, 2025
1be2a06
add a test for static link
AnieeG Jan 31, 2025
22c38b4
fix go import error
AnieeG Jan 31, 2025
6d82409
include solana chains
AnieeG Jan 31, 2025
6805b89
more fixes
AnieeG Jan 31, 2025
632ee0e
more fix
AnieeG Jan 31, 2025
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: 4 additions & 1 deletion deployment/ccip/changeset/cs_active_candidate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,10 @@ func Test_ActiveCandidate(t *testing.T) {
// NOTE: this is technically not a new chain, but needed for validation.
OCRConfigPerRemoteChainSelector: map[uint64]changeset.CCIPOCRParams{
dest: changeset.DeriveCCIPOCRParams(
changeset.WithDefaultCommitOffChainConfig(tenv.FeedChainSel, tokenConfig.GetTokenInfo(logger.TestLogger(t), state.Chains[dest].LinkToken, state.Chains[dest].Weth9)),
changeset.WithDefaultCommitOffChainConfig(tenv.FeedChainSel,
tokenConfig.GetTokenInfo(logger.TestLogger(t),
state.Chains[dest].LinkToken.Address(),
state.Chains[dest].Weth9.Address())),
),
},
PluginType: types.PluginTypeCCIPCommit,
Expand Down
12 changes: 10 additions & 2 deletions deployment/ccip/changeset/cs_ccip_home_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,11 @@ func Test_SetCandidate(t *testing.T) {
{
OCRConfigPerRemoteChainSelector: map[uint64]changeset.CCIPOCRParams{
dest: changeset.DeriveCCIPOCRParams(
changeset.WithDefaultCommitOffChainConfig(tenv.FeedChainSel, tokenConfig.GetTokenInfo(logger.TestLogger(t), state.Chains[dest].LinkToken, state.Chains[dest].Weth9)),
changeset.WithDefaultCommitOffChainConfig(
tenv.FeedChainSel,
tokenConfig.GetTokenInfo(logger.TestLogger(t),
state.Chains[dest].LinkToken.Address(),
state.Chains[dest].Weth9.Address())),
),
},
PluginType: types.PluginTypeCCIPCommit,
Expand Down Expand Up @@ -377,7 +381,11 @@ func Test_RevokeCandidate(t *testing.T) {
{
OCRConfigPerRemoteChainSelector: map[uint64]changeset.CCIPOCRParams{
dest: changeset.DeriveCCIPOCRParams(
changeset.WithDefaultCommitOffChainConfig(tenv.FeedChainSel, tokenConfig.GetTokenInfo(logger.TestLogger(t), state.Chains[dest].LinkToken, state.Chains[dest].Weth9)),
changeset.WithDefaultCommitOffChainConfig(
tenv.FeedChainSel,
tokenConfig.GetTokenInfo(logger.TestLogger(t),
state.Chains[dest].LinkToken.Address(),
state.Chains[dest].Weth9.Address())),
),
},
PluginType: types.PluginTypeCCIPCommit,
Expand Down
3 changes: 0 additions & 3 deletions deployment/ccip/changeset/cs_deploy_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,6 @@ func deployChainContractsForChains(
return fmt.Errorf("fee tokens not valid for chain %d, staticLinkExists: %t, linkExists: %t, weth9Exists: %t", chainSel, staticLinkExists, linkExists, weth9Exists)
}
chain := e.Chains[chainSel]
if existingState.Chains[chainSel].LinkToken == nil || existingState.Chains[chainSel].Weth9 == nil {
return fmt.Errorf("fee tokens not found for chain %d", chainSel)
}
deployFn = func() error { return deployChainContractsEVM(e, chain, ab, rmnHome, contractParams) }

case chainsel.FamilySolana:
Expand Down
11 changes: 11 additions & 0 deletions deployment/ccip/changeset/cs_deploy_chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,14 @@ func TestDeployCCIPContracts(t *testing.T) {
t.Parallel()
testhelpers.DeployCCIPContractsTest(t, 0)
}

func TestDeployStaticLinkToken(t *testing.T) {
t.Parallel()
e, _ := testhelpers.NewMemoryEnvironment(t, testhelpers.WithStaticLink())
// load onchain state
state, err := changeset.LoadOnchainState(e.Env)
require.NoError(t, err)
for _, chain := range e.Env.AllChainSelectors() {
require.NotNil(t, state.Chains[chain].StaticLinkToken)
}
}
97 changes: 46 additions & 51 deletions deployment/ccip/changeset/testhelpers/test_environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"time"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/stretchr/testify/require"
"go.uber.org/zap/zapcore"

Expand All @@ -22,6 +23,7 @@ import (
cciptypes "github.com/smartcontractkit/chainlink-ccip/pkg/types/ccipocr3"
"github.com/smartcontractkit/chainlink-ccip/pluginconfig"
commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config"

"github.com/smartcontractkit/chainlink/deployment"
"github.com/smartcontractkit/chainlink/deployment/ccip/changeset/globals"
changeset_solana "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/solana"
Expand Down Expand Up @@ -56,6 +58,7 @@ type TestConfigs struct {
IsUSDC bool
IsUSDCAttestationMissing bool
IsMultiCall3 bool
IsStaticLink bool
OCRConfigOverride func(*changeset.CCIPOCRParams)
RMNEnabled bool
NumOfRMNNodes int
Expand Down Expand Up @@ -118,6 +121,12 @@ func WithMultiCall3() TestOps {
}
}

func WithStaticLink() TestOps {
return func(testCfg *TestConfigs) {
testCfg.IsStaticLink = true
}
}

func WithPrerequisiteDeploymentOnly(v1_5Cfg *changeset.V1_5DeploymentConfig) TestOps {
return func(testCfg *TestConfigs) {
testCfg.PrerequisiteDeploymentOnly = true
Expand Down Expand Up @@ -400,14 +409,19 @@ func NewEnvironmentWithPrerequisitesContracts(t *testing.T, tEnv TestEnvironment
var err error
tc := tEnv.TestConfigs()
e := NewEnvironment(t, tEnv)
allChains := e.Env.AllChainSelectors()

evmChains := e.Env.AllChainSelectors()
solChains := e.Env.AllChainSelectorsSolana()
//nolint:gocritic // we need to segregate EVM and Solana chains
allChains := append(evmChains, solChains...)
if len(solChains) > 0 {
SavePreloadedSolAddresses(t, e.Env, solChains[0])
}
mcmsCfg := make(map[uint64]commontypes.MCMSWithTimelockConfig)
for _, c := range e.Env.AllChainSelectors() {
mcmsCfg[c] = proposalutils.SingleGroupTimelockConfig(t)
}
prereqCfg := make([]changeset.DeployPrerequisiteConfigPerChain, 0)
for _, chain := range allChains {
for _, chain := range evmChains {
var opts []changeset.PrerequisiteOpt
if tc != nil {
if tc.IsUSDC {
Expand All @@ -425,12 +439,18 @@ func NewEnvironmentWithPrerequisitesContracts(t *testing.T, tEnv TestEnvironment
Opts: opts,
})
}

e.Env, err = commonchangeset.ApplyChangesets(t, e.Env, nil, []commonchangeset.ChangesetApplication{
{
Changeset: commonchangeset.WrapChangeSet(commonchangeset.DeployLinkToken),
deployLinkApp := commonchangeset.ChangesetApplication{
Changeset: commonchangeset.WrapChangeSet(commonchangeset.DeployLinkToken),
Config: allChains,
}
if tc.IsStaticLink {
deployLinkApp = commonchangeset.ChangesetApplication{
Changeset: commonchangeset.WrapChangeSet(commonchangeset.DeployStaticLinkToken),
Config: allChains,
},
}
}
e.Env, err = commonchangeset.ApplyChangesets(t, e.Env, nil, []commonchangeset.ChangesetApplication{
deployLinkApp,
{
Changeset: commonchangeset.WrapChangeSet(changeset.DeployPrerequisitesChangeset),
Config: changeset.DeployPrerequisiteConfig{
Expand Down Expand Up @@ -465,56 +485,17 @@ func NewEnvironment(t *testing.T, tEnv TestEnvironment) DeployedEnv {

func NewEnvironmentWithJobsAndContracts(t *testing.T, tEnv TestEnvironment) DeployedEnv {
var err error
tc := tEnv.TestConfigs()
e := NewEnvironment(t, tEnv)
e := NewEnvironmentWithPrerequisitesContracts(t, tEnv)
evmChains := e.Env.AllChainSelectors()
solChains := e.Env.AllChainSelectorsSolana()
//nolint:gocritic // we need to segregate EVM and Solana chains
allChains := append(evmChains, solChains...)
if len(solChains) > 0 {
SavePreloadedSolAddresses(t, e.Env, solChains[0])
}
mcmsCfg := make(map[uint64]commontypes.MCMSWithTimelockConfig)

for _, c := range e.Env.AllChainSelectors() {
mcmsCfg[c] = proposalutils.SingleGroupTimelockConfig(t)
}

prereqCfg := make([]changeset.DeployPrerequisiteConfigPerChain, 0)
for _, chain := range evmChains {
var opts []changeset.PrerequisiteOpt
if tc != nil {
if tc.IsUSDC {
opts = append(opts, changeset.WithUSDCEnabled())
}
if tc.IsMultiCall3 {
opts = append(opts, changeset.WithMultiCall3Enabled())
}
}
prereqCfg = append(prereqCfg, changeset.DeployPrerequisiteConfigPerChain{
ChainSelector: chain,
Opts: opts,
})
}
// Need to deploy prerequisites first so that we can form the USDC config
// no proposals to be made, timelock can be passed as nil here
e.Env, err = commonchangeset.ApplyChangesets(t, e.Env, nil, []commonchangeset.ChangesetApplication{
{
Changeset: commonchangeset.WrapChangeSet(commonchangeset.DeployLinkToken),
Config: allChains,
},
{
Changeset: commonchangeset.WrapChangeSet(changeset.DeployPrerequisitesChangeset),
Config: changeset.DeployPrerequisiteConfig{
Configs: prereqCfg,
},
},
{
Changeset: commonchangeset.WrapChangeSet(commonchangeset.DeployMCMSWithTimelock),
Config: mcmsCfg,
},
})
require.NoError(t, err)
tEnv.UpdateDeployedEnvironment(e)

e = AddCCIPContractsToEnvironment(t, allChains, tEnv, false)
Expand Down Expand Up @@ -590,7 +571,11 @@ func AddCCIPContractsToEnvironment(t *testing.T, allChains []uint64, tEnv TestEn
state, err := changeset.LoadOnchainState(e.Env)
require.NoError(t, err)
// Assert link present
require.NotNil(t, state.Chains[e.FeedChainSel].LinkToken)
if tc.IsStaticLink {
require.NotNil(t, state.Chains[e.FeedChainSel].StaticLinkToken)
} else {
require.NotNil(t, state.Chains[e.FeedChainSel].LinkToken)
}
require.NotNil(t, state.Chains[e.FeedChainSel].Weth9)

tokenConfig := changeset.NewTestTokenConfig(state.Chains[e.FeedChainSel].USDFeeds)
Expand Down Expand Up @@ -633,7 +618,13 @@ func AddCCIPContractsToEnvironment(t *testing.T, allChains []uint64, tEnv TestEn
Timelock: state.Chains[chain].Timelock,
CallProxy: state.Chains[chain].CallProxy,
}
tokenInfo := tokenConfig.GetTokenInfo(e.Env.Logger, state.Chains[chain].LinkToken, state.Chains[chain].Weth9)
var linkTokenAddr common.Address
if tc.IsStaticLink {
linkTokenAddr = state.Chains[chain].StaticLinkToken.Address()
} else {
linkTokenAddr = state.Chains[chain].LinkToken.Address()
}
tokenInfo := tokenConfig.GetTokenInfo(e.Env.Logger, linkTokenAddr, state.Chains[chain].Weth9.Address())
ocrOverride := tc.OCRConfigOverride
if tc.RMNEnabled {
ocrOverride = func(ocrParams *changeset.CCIPOCRParams) {
Expand Down Expand Up @@ -783,7 +774,11 @@ func AddCCIPContractsToEnvironment(t *testing.T, allChains []uint64, tEnv TestEn
require.NotNil(t, state.Chains[e.HomeChainSel].CCIPHome)
require.NotNil(t, state.Chains[e.HomeChainSel].RMNHome)
for _, chain := range evmChains {
require.NotNil(t, state.Chains[chain].LinkToken)
if tc.IsStaticLink {
require.NotNil(t, state.Chains[chain].StaticLinkToken)
} else {
require.NotNil(t, state.Chains[chain].LinkToken)
}
require.NotNil(t, state.Chains[chain].Weth9)
require.NotNil(t, state.Chains[chain].TokenAdminRegistry)
require.NotNil(t, state.Chains[chain].RegistryModule)
Expand Down
16 changes: 8 additions & 8 deletions deployment/ccip/changeset/token_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ package changeset
import (
"math/big"

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

"github.com/smartcontractkit/chainlink-ccip/pkg/types/ccipocr3"
"github.com/smartcontractkit/chainlink-ccip/pluginconfig"

"github.com/smartcontractkit/chainlink/deployment"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/shared/generated/link_token"

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

"github.com/smartcontractkit/chainlink/deployment"

"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/shared/generated/aggregator_v3_interface"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/shared/generated/weth9"
)

type TokenSymbol string
Expand Down Expand Up @@ -105,23 +105,23 @@ func (tc *TokenConfig) UpsertTokenInfo(
// GetTokenInfo Adds mapping between dest chain tokens and their respective aggregators on feed chain.
func (tc *TokenConfig) GetTokenInfo(
lggr logger.Logger,
linkToken *link_token.LinkToken,
wethToken *weth9.WETH9,
linkTokenAddr,
wethTokenAddr common.Address,
) map[ccipocr3.UnknownEncodedAddress]pluginconfig.TokenInfo {
tokenToAggregate := make(map[ccipocr3.UnknownEncodedAddress]pluginconfig.TokenInfo)
if _, ok := tc.TokenSymbolToInfo[LinkSymbol]; !ok {
lggr.Debugw("Link aggregator not found, deploy without mapping link token")
} else {
lggr.Debugw("Mapping LinkToken to Link aggregator")
acc := ccipocr3.UnknownEncodedAddress(linkToken.Address().String())
acc := ccipocr3.UnknownEncodedAddress(linkTokenAddr.String())
tokenToAggregate[acc] = tc.TokenSymbolToInfo[LinkSymbol]
}

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 := ccipocr3.UnknownEncodedAddress(wethToken.Address().String())
acc := ccipocr3.UnknownEncodedAddress(wethTokenAddr.String())
tokenToAggregate[acc] = tc.TokenSymbolToInfo[WethSymbol]
}

Expand Down
36 changes: 36 additions & 0 deletions deployment/common/changeset/deploy_link_token.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package changeset

import (
"context"
"fmt"

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

Expand All @@ -13,6 +14,7 @@ import (

"github.com/smartcontractkit/chainlink/deployment"
"github.com/smartcontractkit/chainlink/deployment/common/types"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/link_token_interface"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/shared/generated/link_token"
)

Expand Down Expand Up @@ -56,6 +58,40 @@ func DeployLinkToken(e deployment.Environment, chains []uint64) (deployment.Chan
return deployment.ChangesetOutput{AddressBook: newAddresses}, nil
}

// DeployStaticLinkToken deploys a static link token contract to the chain identified by the ChainSelector.
func DeployStaticLinkToken(e deployment.Environment, chains []uint64) (deployment.ChangesetOutput, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be unexported? Function sig does not exactly match that of a changeset.

Copy link
Contributor

Choose a reason for hiding this comment

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

Nvm, thrown off by primitive type as "config"

err := deployment.ValidateSelectorsInEnvironment(e, chains)
if err != nil {
return deployment.ChangesetOutput{}, err
}
newAddresses := deployment.NewMemoryAddressBook()
for _, chainSel := range chains {
chain, ok := e.Chains[chainSel]
if !ok {
return deployment.ChangesetOutput{}, fmt.Errorf("chain not found in environment: %d", chainSel)
}
_, err := deployment.DeployContract[*link_token_interface.LinkToken](e.Logger, chain, newAddresses,
func(chain deployment.Chain) deployment.ContractDeploy[*link_token_interface.LinkToken] {
linkTokenAddr, tx, linkToken, err2 := link_token_interface.DeployLinkToken(
chain.DeployerKey,
chain.Client,
)
return deployment.ContractDeploy[*link_token_interface.LinkToken]{
Address: linkTokenAddr,
Contract: linkToken,
Tx: tx,
Tv: deployment.NewTypeAndVersion(types.StaticLinkToken, deployment.Version1_0_0),
Err: err2,
}
})
if err != nil {
e.Logger.Errorw("Failed to deploy static link token", "chain", chain.String(), "err", err)
return deployment.ChangesetOutput{}, err
}
}
return deployment.ChangesetOutput{AddressBook: newAddresses}, nil
}

func deployLinkTokenContractEVM(
lggr logger.Logger,
chain deployment.Chain,
Expand Down
Loading