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-4573 Changesets ccip 1.5 #15588

Merged
merged 35 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
ded3f4c
Merge branch 'develop' of github.com:smartcontractkit/chainlink into …
AnieeG Dec 7, 2024
b41bebe
just start
AnieeG Dec 9, 2024
91bbfe5
placeholders
AnieeG Dec 10, 2024
9a29a00
state
AnieeG Dec 10, 2024
a4bebba
change
AnieeG Dec 10, 2024
86d3947
updates
AnieeG Dec 11, 2024
4a143bf
updates
AnieeG Dec 11, 2024
7aaa0ef
all updates
AnieeG Dec 11, 2024
c4ab875
change
AnieeG Dec 11, 2024
774c933
include views
AnieeG Dec 11, 2024
aabba80
comments
AnieeG Dec 12, 2024
24dd0c9
progress so far
AnieeG Dec 13, 2024
74063c9
Merge branch 'develop' of github.com:smartcontractkit/chainlink into …
AnieeG Dec 16, 2024
9b85a7b
add test
AnieeG Dec 17, 2024
cb923b0
more updates
AnieeG Dec 17, 2024
6bb2a6d
updates
AnieeG Dec 17, 2024
8d2ea2a
changes
AnieeG Dec 17, 2024
669fba6
Merge branch 'develop' of github.com:smartcontractkit/chainlink into …
AnieeG Dec 17, 2024
5861532
updates
AnieeG Dec 17, 2024
572fe53
formatting
AnieeG Dec 17, 2024
37ac6e9
fix crib
AnieeG Dec 17, 2024
edd1ef1
fix more tests
AnieeG Dec 17, 2024
ea81972
lint fix
AnieeG Dec 18, 2024
599bb5c
comments
AnieeG Dec 18, 2024
4669024
fix format
AnieeG Dec 18, 2024
c119985
Merge branch 'develop' of github.com:smartcontractkit/chainlink into …
AnieeG Dec 18, 2024
b76b6fc
multichain
AnieeG Dec 18, 2024
88301f3
fix lint
AnieeG Dec 18, 2024
4032b96
merge with develop
AnieeG Dec 18, 2024
347a775
fix lint
AnieeG Dec 18, 2024
207a6bc
change func name
AnieeG Dec 18, 2024
d64279b
review comments
AnieeG Dec 18, 2024
08d138c
lint fix
AnieeG Dec 18, 2024
514aefc
removed legacyjobclient
AnieeG Dec 18, 2024
cd17fe1
review comments
AnieeG Dec 19, 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
46 changes: 18 additions & 28 deletions deployment/ccip/changeset/cs_deploy_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/offramp"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/onramp"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/rmn_home"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/rmn_proxy_contract"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/rmn_remote"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/router"
)
Expand Down Expand Up @@ -173,6 +172,22 @@ func deployChainContracts(
if chainState.Router == nil {
return fmt.Errorf("router not found for chain %s, deploy the prerequisites first", chain.String())
}
rmnProxyContract := chainState.RMNProxy
if chainState.RMNProxy == nil {
e.Logger.Errorw("RMNProxy not found", "chain", chain.String())
return fmt.Errorf("rmn proxy not found for chain %s, deploy the prerequisites first", chain.String())
}
var rmnLegacyAddr common.Address
if chainState.MockRMN != nil {
rmnLegacyAddr = chainState.MockRMN.Address()
}
// If RMN is deployed, set rmnLegacyAddr to the RMN address
AnieeG marked this conversation as resolved.
Show resolved Hide resolved
if chainState.RMN != nil {
rmnLegacyAddr = chainState.RMN.Address()
}
if rmnLegacyAddr == (common.Address{}) {
e.Logger.Warnf("No legacy RMN contract found for chain %s, will not setRMN in RMNRemote", chain.String())
AnieeG marked this conversation as resolved.
Show resolved Hide resolved
}
if chainState.Receiver == nil {
_, err := deployment.DeployContract(e.Logger, chain, ab,
func(chain deployment.Chain) deployment.ContractDeploy[*maybe_revert_message_receiver.MaybeRevertMessageReceiver] {
Expand All @@ -186,7 +201,7 @@ func deployChainContracts(
}
})
if err != nil {
e.Logger.Errorw("Failed to deploy receiver", "err", err)
e.Logger.Errorw("Failed to deploy receiver", "chain", chain.String(), "err", err)
return err
}
} else {
Expand All @@ -201,8 +216,7 @@ func deployChainContracts(
chain.DeployerKey,
chain.Client,
chain.Selector,
// Indicates no legacy RMN contract
common.HexToAddress("0x0"),
rmnLegacyAddr,
)
return deployment.ContractDeploy[*rmn_remote.RMNRemote]{
rmnRemoteAddr, rmnRemote, tx, deployment.NewTypeAndVersion(RMNRemote, deployment.Version1_6_0_dev), err2,
Expand Down Expand Up @@ -235,30 +249,6 @@ func deployChainContracts(
return err
}

// we deploy a new RMNProxy so that RMNRemote can be tested first before pointing it to the main Existing RMNProxy
// To differentiate between the two RMNProxies, we will deploy new one with Version1_6_0_dev
rmnProxyContract := chainState.RMNProxyNew
if chainState.RMNProxyNew == nil {
// we deploy a new rmnproxy contract to test RMNRemote
rmnProxy, err := deployment.DeployContract(e.Logger, chain, ab,
func(chain deployment.Chain) deployment.ContractDeploy[*rmn_proxy_contract.RMNProxyContract] {
rmnProxyAddr, tx, rmnProxy, err2 := rmn_proxy_contract.DeployRMNProxyContract(
chain.DeployerKey,
chain.Client,
rmnRemoteContract.Address(),
)
return deployment.ContractDeploy[*rmn_proxy_contract.RMNProxyContract]{
rmnProxyAddr, rmnProxy, tx, deployment.NewTypeAndVersion(ARMProxy, deployment.Version1_6_0_dev), err2,
}
})
if err != nil {
e.Logger.Errorw("Failed to deploy RMNProxyNew", "chain", chain.String(), "err", err)
return err
}
rmnProxyContract = rmnProxy.Contract
} else {
e.Logger.Infow("rmn proxy already deployed", "chain", chain.String(), "addr", chainState.RMNProxyNew.Address)
}
if chainState.TestRouter == nil {
_, err := deployment.DeployContract(e.Logger, chain, ab,
func(chain deployment.Chain) deployment.ContractDeploy[*router.Router] {
Expand Down
8 changes: 4 additions & 4 deletions deployment/ccip/changeset/cs_prerequisites.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,15 @@ func deployPrerequisiteContracts(e deployment.Environment, ab deployment.Address
weth9Contract = chainState.Weth9
tokenAdminReg = chainState.TokenAdminRegistry
registryModule = chainState.RegistryModule
rmnProxy = chainState.RMNProxyExisting
rmnProxy = chainState.RMNProxy
r = chainState.Router
mc3 = chainState.Multicall3
}
if rmnProxy == nil {
// we want to replicate the mainnet scenario where RMNProxy is already deployed with some existing RMN
// This will need us to use two different RMNProxy contracts
// 1. RMNProxyNew with RMNRemote - ( deployed later in chain contracts)
// 2. RMNProxyExisting with mockRMN - ( deployed here, replicating the behavior of existing RMNProxy with already set RMN)
// 2. RMNProxy with mockRMN - ( deployed here, replicating the behavior of existing RMNProxy with already set RMN)
rmn, err := deployment.DeployContract(lggr, chain, ab,
func(chain deployment.Chain) deployment.ContractDeploy[*mock_rmn_contract.MockRMNContract] {
rmnAddr, tx2, rmn, err2 := mock_rmn_contract.DeployMockRMNContract(
Expand All @@ -168,7 +168,7 @@ func deployPrerequisiteContracts(e deployment.Environment, ab deployment.Address
}
})
if err != nil {
lggr.Errorw("Failed to deploy RMNProxyExisting", "chain", chain.String(), "err", err)
lggr.Errorw("Failed to deploy RMNProxy", "chain", chain.String(), "err", err)
return err
}
rmnProxy = rmnProxyContract.Contract
Expand Down Expand Up @@ -246,7 +246,7 @@ func deployPrerequisiteContracts(e deployment.Environment, ab deployment.Address
}
weth9Contract = weth.Contract
} else {
lggr.Infow("weth9 already deployed", "addr", weth9Contract.Address)
lggr.Infow("weth9 already deployed", "chain", chain.String(), "addr", weth9Contract.Address)
}
// if router is not already deployed, we deploy it
if r == nil {
Expand Down
184 changes: 129 additions & 55 deletions deployment/ccip/changeset/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ import (
"fmt"

burn_mint_token_pool "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/burn_mint_token_pool_1_4_0"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/commit_store"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/evm_2_evm_offramp"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/evm_2_evm_onramp"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/price_registry_1_2_0"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/rmn_contract"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/shared/generated/erc20"

"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/mock_usdc_token_messenger"
Expand All @@ -15,6 +20,7 @@ import (
"github.com/pkg/errors"

"github.com/smartcontractkit/chainlink/deployment"
legacychangeset "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/v1_5"
"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"
Expand All @@ -23,7 +29,7 @@ import (
commoncs "github.com/smartcontractkit/chainlink/deployment/common/changeset"
commontypes "github.com/smartcontractkit/chainlink/deployment/common/types"
common_v1_0 "github.com/smartcontractkit/chainlink/deployment/common/view/v1_0"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/commit_store"

"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/mock_rmn_contract"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/registry_module_owner_custom"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/rmn_home"
Expand All @@ -47,8 +53,10 @@ import (
)

var (
// Legacy
CommitStore deployment.ContractType = "CommitStore"
// Legacy
CommitStore deployment.ContractType = "CommitStore"
PriceRegistry deployment.ContractType = "PriceRegistry"
RMN deployment.ContractType = "RMN"

// Not legacy
MockRMN deployment.ContractType = "MockRMN"
Expand Down Expand Up @@ -87,26 +95,16 @@ type CCIPChainState struct {
commoncs.MCMSWithTimelockState
commoncs.LinkTokenState
commoncs.StaticLinkTokenState
OnRamp *onramp.OnRamp
OffRamp *offramp.OffRamp
FeeQuoter *fee_quoter.FeeQuoter
// We need 2 RMNProxy contracts because we are in the process of migrating to a new version.
// We will switch to the existing one once the migration is complete.
// This is the new RMNProxy contract that will be used for testing RMNRemote before migration.
// Initially RMNProxyNew will point to RMNRemote
RMNProxyNew *rmn_proxy_contract.RMNProxyContract
// Existing RMNProxy contract that is used in production, This already has existing 1.5 RMN set.
// once RMNRemote is tested with RMNProxyNew, as part of migration
// RMNProxyExisting will point to RMNRemote. This will switch over CCIP 1.5 to 1.6
RMNProxyExisting *rmn_proxy_contract.RMNProxyContract
OnRamp *onramp.OnRamp
OffRamp *offramp.OffRamp
FeeQuoter *fee_quoter.FeeQuoter
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
RMNRemote *rmn_remote.RMNRemote
MockRMN *mock_rmn_contract.MockRMNContract
// Map between token Descriptor (e.g. LinkSymbol, WethSymbol)
// and the respective token contract
// This is more of an illustration of how we'll have tokens, and it might need some work later to work properly.
Expand All @@ -129,6 +127,9 @@ type CCIPChainState struct {
MockUSDCTransmitter *mock_usdc_token_transmitter.MockE2EUSDCTransmitter
MockUSDCTokenMessenger *mock_usdc_token_messenger.MockE2EUSDCTokenMessenger
Multicall3 *multicall3.Multicall3

// Legacy contracts
legacychangeset.CCIPChainStateLegacy
}

func (c CCIPChainState) GenerateView() (view.ChainView, error) {
Expand Down Expand Up @@ -159,7 +160,7 @@ func (c CCIPChainState) GenerateView() (view.ChainView, error) {
if err != nil {
return chainView, errors.Wrapf(err, "failed to generate rmn remote view for rmn remote %s", c.RMNRemote.Address().String())
}
chainView.RMN[c.RMNRemote.Address().Hex()] = rmnView
chainView.RMNRemote[c.RMNRemote.Address().Hex()] = rmnView
}
if c.FeeQuoter != nil && c.Router != nil && c.TokenAdminRegistry != nil {
fqView, err := v1_6.GenerateFeeQuoterView(c.FeeQuoter, c.Router, c.TokenAdminRegistry)
Expand Down Expand Up @@ -192,20 +193,12 @@ func (c CCIPChainState) GenerateView() (view.ChainView, error) {
chainView.OffRamp[c.OffRamp.Address().Hex()] = offRampView
}

if c.CommitStore != nil {
commitStoreView, err := v1_5.GenerateCommitStoreView(c.CommitStore)
if c.RMNProxy != nil {
rmnProxyView, err := v1_0.GenerateRMNProxyView(c.RMNProxy)
if err != nil {
return chainView, errors.Wrapf(err, "failed to generate commit store view for commit store %s", c.CommitStore.Address().String())
return chainView, errors.Wrapf(err, "failed to generate rmn proxy view for rmn proxy %s", c.RMNProxy.Address().String())
}
chainView.CommitStore[c.CommitStore.Address().Hex()] = commitStoreView
}

if c.RMNProxyNew != nil {
rmnProxyView, err := v1_0.GenerateRMNProxyView(c.RMNProxyNew)
if err != nil {
return chainView, errors.Wrapf(err, "failed to generate rmn proxy view for rmn proxy %s", c.RMNProxyNew.Address().String())
}
chainView.RMNProxy[c.RMNProxyNew.Address().Hex()] = rmnProxyView
chainView.RMNProxy[c.RMNProxy.Address().Hex()] = rmnProxyView
}
if c.CCIPHome != nil && c.CapabilityRegistry != nil {
chView, err := v1_6.GenerateCCIPHomeView(c.CapabilityRegistry, c.CCIPHome)
Expand Down Expand Up @@ -242,6 +235,53 @@ func (c CCIPChainState) GenerateView() (view.ChainView, error) {
}
chainView.StaticLinkToken = staticLinkTokenView
}
// Legacy contracts
if c.CommitStore != nil {
for _, commitStore := range c.CommitStore {
commitStoreView, err := v1_5.GenerateCommitStoreView(commitStore)
if err != nil {
return chainView, errors.Wrapf(err, "failed to generate commit store view for commit store %s", commitStore.Address().String())
Copy link
Contributor

Choose a reason for hiding this comment

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

can include the source like the offramp

}
chainView.CommitStore[commitStore.Address().Hex()] = commitStoreView
}
}

if c.PriceRegistry != nil {
priceRegistryView, err := v1_2.GeneratePriceRegistryView(c.PriceRegistry)
if err != nil {
return chainView, errors.Wrapf(err, "failed to generate price registry view for price registry %s", c.PriceRegistry.Address().String())
}
chainView.PriceRegistry[c.PriceRegistry.Address().String()] = priceRegistryView
}

if c.RMN != nil {
rmnView, err := v1_5.GenerateRMNView(c.RMN)
if err != nil {
return chainView, errors.Wrapf(err, "failed to generate rmn view for rmn %s", c.RMN.Address().String())
}
chainView.RMN[c.RMN.Address().Hex()] = rmnView
}

if c.EVM2EVMOffRamp != nil {
for source, offRamp := range c.EVM2EVMOffRamp {
offRampView, err := v1_5.GenerateOffRampView(offRamp)
if err != nil {
return chainView, errors.Wrapf(err, "failed to generate off ramp view for off ramp %s for source %d", offRamp.Address().String(), source)
}
chainView.EVM2EVMOffRamp[offRamp.Address().Hex()] = offRampView
}
}

if c.EVM2EVMOnRamp != nil {
for dest, onRamp := range c.EVM2EVMOnRamp {
onRampView, err := v1_5.GenerateOnRampView(onRamp)
if err != nil {
return chainView, errors.Wrapf(err, "failed to generate on ramp view for on ramp %s for dest %d", onRamp.Address().String(), dest)
}
chainView.EVM2EVMOnRamp[onRamp.Address().Hex()] = onRampView
}
}

return chainView, nil
}

Expand Down Expand Up @@ -351,25 +391,7 @@ func LoadChainState(chain deployment.Chain, addresses map[string]deployment.Type
if err != nil {
return state, err
}
state.RMNProxyExisting = armProxy
case deployment.NewTypeAndVersion(ARMProxy, deployment.Version1_6_0_dev).String():
armProxy, err := rmn_proxy_contract.NewRMNProxyContract(common.HexToAddress(address), chain.Client)
if err != nil {
return state, err
}
state.RMNProxyNew = armProxy
case deployment.NewTypeAndVersion(ARMProxy, deployment.Version1_6_0_dev).String():
armProxy, err := rmn_proxy_contract.NewRMNProxyContract(common.HexToAddress(address), chain.Client)
if err != nil {
return state, err
}
state.RMNProxyNew = armProxy
case deployment.NewTypeAndVersion(MockRMN, deployment.Version1_0_0).String():
mockRMN, err := mock_rmn_contract.NewMockRMNContract(common.HexToAddress(address), chain.Client)
if err != nil {
return state, err
}
state.MockRMN = mockRMN
state.RMNProxy = armProxy
case deployment.NewTypeAndVersion(RMNRemote, deployment.Version1_6_0_dev).String():
rmnRemote, err := rmn_remote.NewRMNRemote(common.HexToAddress(address), chain.Client)
if err != nil {
Expand All @@ -394,12 +416,6 @@ func LoadChainState(chain deployment.Chain, addresses map[string]deployment.Type
return state, err
}
state.NonceManager = nm
case deployment.NewTypeAndVersion(CommitStore, deployment.Version1_5_0).String():
cs, err := commit_store.NewCommitStore(common.HexToAddress(address), chain.Client)
if err != nil {
return state, err
}
state.CommitStore = cs
case deployment.NewTypeAndVersion(TokenAdminRegistry, deployment.Version1_5_0).String():
tm, err := token_admin_registry.NewTokenAdminRegistry(common.HexToAddress(address), chain.Client)
if err != nil {
Expand Down Expand Up @@ -525,6 +541,64 @@ func LoadChainState(chain deployment.Chain, addresses map[string]deployment.Type
return state, fmt.Errorf("failed to get token symbol of token at %s: %w", address, err)
}
state.BurnMintTokens677[TokenSymbol(symbol)] = tok
// legacy addresses below
case deployment.NewTypeAndVersion(OnRamp, deployment.Version1_5_0).String():
onRampC, err := evm_2_evm_onramp.NewEVM2EVMOnRamp(common.HexToAddress(address), chain.Client)
if err != nil {
return state, err
}
sCfg, err := onRampC.GetStaticConfig(nil)
if err != nil {
return state, fmt.Errorf("failed to get static config chain %s: %w", chain.String(), err)
}
if state.EVM2EVMOnRamp == nil {
state.EVM2EVMOnRamp = make(map[uint64]*evm_2_evm_onramp.EVM2EVMOnRamp)
}
state.EVM2EVMOnRamp[sCfg.DestChainSelector] = onRampC
case deployment.NewTypeAndVersion(OffRamp, deployment.Version1_5_0).String():
offRamp, err := evm_2_evm_offramp.NewEVM2EVMOffRamp(common.HexToAddress(address), chain.Client)
if err != nil {
return state, err
}
sCfg, err := offRamp.GetStaticConfig(nil)
if err != nil {
return state, err
}
if state.EVM2EVMOffRamp == nil {
state.EVM2EVMOffRamp = make(map[uint64]*evm_2_evm_offramp.EVM2EVMOffRamp)
}
state.EVM2EVMOffRamp[sCfg.SourceChainSelector] = offRamp
case deployment.NewTypeAndVersion(CommitStore, deployment.Version1_5_0).String():
commitStore, err := commit_store.NewCommitStore(common.HexToAddress(address), chain.Client)
if err != nil {
return state, err
}
sCfg, err := commitStore.GetStaticConfig(nil)
if err != nil {
return state, err
}
if state.CommitStore == nil {
state.CommitStore = make(map[uint64]*commit_store.CommitStore)
}
state.CommitStore[sCfg.SourceChainSelector] = commitStore
case deployment.NewTypeAndVersion(PriceRegistry, deployment.Version1_2_0).String():
pr, err := price_registry_1_2_0.NewPriceRegistry(common.HexToAddress(address), chain.Client)
if err != nil {
return state, err
}
state.PriceRegistry = pr
case deployment.NewTypeAndVersion(RMN, deployment.Version1_5_0).String():
rmnC, err := rmn_contract.NewRMNContract(common.HexToAddress(address), chain.Client)
if err != nil {
return state, err
}
state.RMN = rmnC
case deployment.NewTypeAndVersion(MockRMN, deployment.Version1_0_0).String():
mockRMN, err := mock_rmn_contract.NewMockRMNContract(common.HexToAddress(address), chain.Client)
if err != nil {
return state, err
}
state.MockRMN = mockRMN
default:
return state, fmt.Errorf("unknown contract %s", tvStr)
}
Expand Down
Loading
Loading