-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Changes from 3 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 b41bebe
just start
AnieeG 91bbfe5
placeholders
AnieeG 9a29a00
state
AnieeG a4bebba
change
AnieeG 86d3947
updates
AnieeG 4a143bf
updates
AnieeG 7aaa0ef
all updates
AnieeG c4ab875
change
AnieeG 774c933
include views
AnieeG aabba80
comments
AnieeG 24dd0c9
progress so far
AnieeG 74063c9
Merge branch 'develop' of github.com:smartcontractkit/chainlink into …
AnieeG 9b85a7b
add test
AnieeG cb923b0
more updates
AnieeG 6bb2a6d
updates
AnieeG 8d2ea2a
changes
AnieeG 669fba6
Merge branch 'develop' of github.com:smartcontractkit/chainlink into …
AnieeG 5861532
updates
AnieeG 572fe53
formatting
AnieeG 37ac6e9
fix crib
AnieeG edd1ef1
fix more tests
AnieeG ea81972
lint fix
AnieeG 599bb5c
comments
AnieeG 4669024
fix format
AnieeG c119985
Merge branch 'develop' of github.com:smartcontractkit/chainlink into …
AnieeG b76b6fc
multichain
AnieeG 88301f3
fix lint
AnieeG 4032b96
merge with develop
AnieeG 347a775
fix lint
AnieeG 207a6bc
change func name
AnieeG d64279b
review comments
AnieeG 08d138c
lint fix
AnieeG 514aefc
removed legacyjobclient
AnieeG cd17fe1
review comments
AnieeG File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package v1_5 | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/smartcontractkit/ccip-owner-contracts/pkg/proposal/timelock" | ||
|
||
"github.com/smartcontractkit/chainlink/deployment" | ||
) | ||
|
||
var _ deployment.ChangeSet[DeployChainContractsConfig] = DeployChainContracts | ||
|
||
type DeployChainContractsConfig struct { | ||
ChainSelectors []uint64 | ||
} | ||
|
||
func DeployChainContracts(env deployment.Environment, c DeployChainContractsConfig) (deployment.ChangesetOutput, error) { | ||
if err := c.Validate(); err != nil { | ||
return deployment.ChangesetOutput{}, fmt.Errorf("invalid DeployChainContractsConfig: %w", err) | ||
} | ||
newAddresses := deployment.NewMemoryAddressBook() | ||
err := deployChainContractsForChains(env, newAddresses, c.ChainSelectors) | ||
if err != nil { | ||
env.Logger.Errorw("Failed to deploy CCIP contracts", "err", err, "newAddresses", newAddresses) | ||
return deployment.ChangesetOutput{AddressBook: newAddresses}, deployment.MaybeDataErr(err) | ||
} | ||
return deployment.ChangesetOutput{ | ||
Proposals: []timelock.MCMSWithTimelockProposal{}, | ||
AddressBook: newAddresses, | ||
JobSpecs: nil, | ||
}, nil | ||
} | ||
|
||
func (c DeployChainContractsConfig) Validate() error { | ||
for _, cs := range c.ChainSelectors { | ||
if err := deployment.IsValidChainSelector(cs); err != nil { | ||
return fmt.Errorf("invalid chain selector: %d - %w", cs, err) | ||
} | ||
} | ||
return nil | ||
} | ||
|
||
func deployChainContractsForChains(env deployment.Environment, ab deployment.AddressBook, selectors []uint64) error { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,315 @@ | ||
package v1_5 | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/ethereum/go-ethereum/accounts/abi/bind" | ||
"github.com/ethereum/go-ethereum/common" | ||
|
||
"github.com/smartcontractkit/chainlink/deployment" | ||
"github.com/smartcontractkit/chainlink/deployment/ccip/changeset" | ||
commoncs "github.com/smartcontractkit/chainlink/deployment/common/changeset" | ||
commontypes "github.com/smartcontractkit/chainlink/deployment/common/types" | ||
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/burn_mint_token_pool" | ||
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/ccip_config" | ||
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/ccip_home" | ||
"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/fee_quoter" | ||
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/maybe_revert_message_receiver" | ||
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/mock_rmn_contract" | ||
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/mock_usdc_token_messenger" | ||
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/mock_usdc_token_transmitter" | ||
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/nonce_manager" | ||
"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/registry_module_owner_custom" | ||
"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" | ||
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/token_admin_registry" | ||
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/usdc_token_pool" | ||
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/weth9" | ||
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/aggregator_v3_interface" | ||
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/shared/generated/burn_mint_erc677" | ||
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/shared/generated/multicall3" | ||
) | ||
|
||
// CCIPOnChainState state always derivable from an address book. | ||
// Offchain state always derivable from a list of nodeIds. | ||
// Note can translate this into Go struct needed for MCMS/Docs/UI. | ||
type CCIPOnChainState struct { | ||
// Populated go bindings for the appropriate version for all contracts. | ||
// We would hold 2 versions of each contract here. Once we upgrade we can phase out the old one. | ||
// When generating bindings, make sure the package name corresponds to the version. | ||
Chains map[uint64]CCIPChainState | ||
} | ||
|
||
// CCIPChainState holds a Go binding for all the currently deployed CCIP contracts | ||
// on a chain. If a binding is nil, it means here is no such contract on the chain. | ||
type CCIPChainState struct { | ||
commoncs.MCMSWithTimelockState | ||
commoncs.LinkTokenState | ||
commoncs.StaticLinkTokenState | ||
OnRamp map[uint64]*evm_2_evm_onramp.EVM2EVMOnRamp | ||
CommitStore map[uint64]*commit_store.CommitStore | ||
OffRamp map[uint64]*evm_2_evm_offramp.EVM2EVMOffRamp | ||
RMNProxy *rmn_proxy_contract.RMNProxyContract | ||
TokenAdminRegistry *token_admin_registry.TokenAdminRegistry | ||
RegistryModule *registry_module_owner_custom.RegistryModuleOwnerCustom | ||
FeeQuoter *fee_quoter.FeeQuoter | ||
Router *router.Router | ||
Weth9 *weth9.WETH9 | ||
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. | ||
// Not all tokens will be burn and mint tokens. | ||
BurnMintTokens677 map[changeset.TokenSymbol]*burn_mint_erc677.BurnMintERC677 | ||
BurnMintTokenPools map[changeset.TokenSymbol]*burn_mint_token_pool.BurnMintTokenPool | ||
// Map between token Symbol (e.g. LinkSymbol, WethSymbol) | ||
// and the respective aggregator USD feed contract | ||
USDFeeds map[changeset.TokenSymbol]*aggregator_v3_interface.AggregatorV3Interface | ||
|
||
// Test contracts | ||
Receiver *maybe_revert_message_receiver.MaybeRevertMessageReceiver | ||
TestRouter *router.Router | ||
USDCTokenPool *usdc_token_pool.USDCTokenPool | ||
MockUSDCTransmitter *mock_usdc_token_transmitter.MockE2EUSDCTransmitter | ||
MockUSDCTokenMessenger *mock_usdc_token_messenger.MockE2EUSDCTokenMessenger | ||
} | ||
|
||
func LoadChainState(chain deployment.Chain, addresses map[string]deployment.TypeAndVersion) (CCIPChainState, error) { | ||
var state CCIPChainState | ||
mcmsWithTimelock, err := commoncs.MaybeLoadMCMSWithTimelockState(chain, addresses) | ||
if err != nil { | ||
return state, err | ||
} | ||
state.MCMSWithTimelockState = *mcmsWithTimelock | ||
|
||
linkState, err := commoncs.MaybeLoadLinkTokenState(chain, addresses) | ||
if err != nil { | ||
return state, err | ||
} | ||
state.LinkTokenState = *linkState | ||
staticLinkState, err := commoncs.MaybeLoadStaticLinkTokenState(chain, addresses) | ||
if err != nil { | ||
return state, err | ||
} | ||
state.StaticLinkTokenState = *staticLinkState | ||
for address, tvStr := range addresses { | ||
switch tvStr.String() { | ||
case deployment.NewTypeAndVersion(commontypes.RBACTimelock, deployment.Version1_0_0).String(), | ||
deployment.NewTypeAndVersion(commontypes.ProposerManyChainMultisig, deployment.Version1_0_0).String(), | ||
deployment.NewTypeAndVersion(commontypes.CancellerManyChainMultisig, deployment.Version1_0_0).String(), | ||
deployment.NewTypeAndVersion(commontypes.BypasserManyChainMultisig, deployment.Version1_0_0).String(), | ||
deployment.NewTypeAndVersion(commontypes.LinkToken, deployment.Version1_0_0).String(), | ||
deployment.NewTypeAndVersion(commontypes.StaticLinkToken, deployment.Version1_0_0).String(): | ||
// Skip common contracts, they are already loaded. | ||
continue | ||
case deployment.NewTypeAndVersion(changeset.OnRamp, deployment.Version1_5_0).String(): | ||
onRampC, err := onramp.NewOnRamp(common.HexToAddress(address), chain.Client) | ||
if err != nil { | ||
return state, err | ||
} | ||
state.OnRamp = onRampC | ||
case deployment.NewTypeAndVersion(OffRamp, deployment.Version1_6_0_dev).String(): | ||
offRamp, err := offramp.NewOffRamp(common.HexToAddress(address), chain.Client) | ||
if err != nil { | ||
return state, err | ||
} | ||
state.OffRamp = offRamp | ||
case deployment.NewTypeAndVersion(ARMProxy, deployment.Version1_0_0).String(): | ||
armProxy, err := rmn_proxy_contract.NewRMNProxyContract(common.HexToAddress(address), chain.Client) | ||
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 | ||
case deployment.NewTypeAndVersion(RMNRemote, deployment.Version1_6_0_dev).String(): | ||
rmnRemote, err := rmn_remote.NewRMNRemote(common.HexToAddress(address), chain.Client) | ||
if err != nil { | ||
return state, err | ||
} | ||
state.RMNRemote = rmnRemote | ||
case deployment.NewTypeAndVersion(RMNHome, deployment.Version1_6_0_dev).String(): | ||
rmnHome, err := rmn_home.NewRMNHome(common.HexToAddress(address), chain.Client) | ||
if err != nil { | ||
return state, err | ||
} | ||
state.RMNHome = rmnHome | ||
case deployment.NewTypeAndVersion(WETH9, deployment.Version1_0_0).String(): | ||
weth9, err := weth9.NewWETH9(common.HexToAddress(address), chain.Client) | ||
if err != nil { | ||
return state, err | ||
} | ||
state.Weth9 = weth9 | ||
case deployment.NewTypeAndVersion(NonceManager, deployment.Version1_6_0_dev).String(): | ||
nm, err := nonce_manager.NewNonceManager(common.HexToAddress(address), chain.Client) | ||
if err != nil { | ||
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 { | ||
return state, err | ||
} | ||
state.TokenAdminRegistry = tm | ||
case deployment.NewTypeAndVersion(RegistryModule, deployment.Version1_5_0).String(): | ||
rm, err := registry_module_owner_custom.NewRegistryModuleOwnerCustom(common.HexToAddress(address), chain.Client) | ||
if err != nil { | ||
return state, err | ||
} | ||
state.RegistryModule = rm | ||
case deployment.NewTypeAndVersion(Router, deployment.Version1_2_0).String(): | ||
r, err := router.NewRouter(common.HexToAddress(address), chain.Client) | ||
if err != nil { | ||
return state, err | ||
} | ||
state.Router = r | ||
case deployment.NewTypeAndVersion(TestRouter, deployment.Version1_2_0).String(): | ||
r, err := router.NewRouter(common.HexToAddress(address), chain.Client) | ||
if err != nil { | ||
return state, err | ||
} | ||
state.TestRouter = r | ||
case deployment.NewTypeAndVersion(FeeQuoter, deployment.Version1_6_0_dev).String(): | ||
fq, err := fee_quoter.NewFeeQuoter(common.HexToAddress(address), chain.Client) | ||
if err != nil { | ||
return state, err | ||
} | ||
state.FeeQuoter = fq | ||
case deployment.NewTypeAndVersion(USDCToken, deployment.Version1_0_0).String(): | ||
ut, err := burn_mint_erc677.NewBurnMintERC677(common.HexToAddress(address), chain.Client) | ||
if err != nil { | ||
return state, err | ||
} | ||
state.BurnMintTokens677 = map[TokenSymbol]*burn_mint_erc677.BurnMintERC677{ | ||
USDCSymbol: ut, | ||
} | ||
case deployment.NewTypeAndVersion(USDCTokenPool, deployment.Version1_0_0).String(): | ||
utp, err := usdc_token_pool.NewUSDCTokenPool(common.HexToAddress(address), chain.Client) | ||
if err != nil { | ||
return state, err | ||
} | ||
state.USDCTokenPool = utp | ||
case deployment.NewTypeAndVersion(USDCMockTransmitter, deployment.Version1_0_0).String(): | ||
umt, err := mock_usdc_token_transmitter.NewMockE2EUSDCTransmitter(common.HexToAddress(address), chain.Client) | ||
if err != nil { | ||
return state, err | ||
} | ||
state.MockUSDCTransmitter = umt | ||
case deployment.NewTypeAndVersion(USDCTokenMessenger, deployment.Version1_0_0).String(): | ||
utm, err := mock_usdc_token_messenger.NewMockE2EUSDCTokenMessenger(common.HexToAddress(address), chain.Client) | ||
if err != nil { | ||
return state, err | ||
} | ||
state.MockUSDCTokenMessenger = utm | ||
case deployment.NewTypeAndVersion(CCIPHome, deployment.Version1_6_0_dev).String(): | ||
ccipHome, err := ccip_home.NewCCIPHome(common.HexToAddress(address), chain.Client) | ||
if err != nil { | ||
return state, err | ||
} | ||
state.CCIPHome = ccipHome | ||
case deployment.NewTypeAndVersion(CCIPConfig, deployment.Version1_0_0).String(): | ||
// TODO: Remove once staging upgraded. | ||
ccipConfig, err := ccip_config.NewCCIPConfig(common.HexToAddress(address), chain.Client) | ||
if err != nil { | ||
return state, err | ||
} | ||
state.CCIPConfig = ccipConfig | ||
case deployment.NewTypeAndVersion(CCIPReceiver, deployment.Version1_0_0).String(): | ||
mr, err := maybe_revert_message_receiver.NewMaybeRevertMessageReceiver(common.HexToAddress(address), chain.Client) | ||
if err != nil { | ||
return state, err | ||
} | ||
state.Receiver = mr | ||
case deployment.NewTypeAndVersion(Multicall3, deployment.Version1_0_0).String(): | ||
mc, err := multicall3.NewMulticall3(common.HexToAddress(address), chain.Client) | ||
if err != nil { | ||
return state, err | ||
} | ||
state.Multicall3 = mc | ||
case deployment.NewTypeAndVersion(PriceFeed, deployment.Version1_0_0).String(): | ||
feed, err := aggregator_v3_interface.NewAggregatorV3Interface(common.HexToAddress(address), chain.Client) | ||
if err != nil { | ||
return state, err | ||
} | ||
if state.USDFeeds == nil { | ||
state.USDFeeds = make(map[TokenSymbol]*aggregator_v3_interface.AggregatorV3Interface) | ||
} | ||
desc, err := feed.Description(&bind.CallOpts{}) | ||
if err != nil { | ||
return state, err | ||
} | ||
key, ok := MockDescriptionToTokenSymbol[desc] | ||
if !ok { | ||
return state, fmt.Errorf("unknown feed description %s", desc) | ||
} | ||
state.USDFeeds[key] = feed | ||
case deployment.NewTypeAndVersion(BurnMintTokenPool, deployment.Version1_5_1).String(): | ||
pool, err := burn_mint_token_pool.NewBurnMintTokenPool(common.HexToAddress(address), chain.Client) | ||
if err != nil { | ||
return state, err | ||
} | ||
if state.BurnMintTokenPools == nil { | ||
state.BurnMintTokenPools = make(map[TokenSymbol]*burn_mint_token_pool.BurnMintTokenPool) | ||
} | ||
tokAddress, err := pool.GetToken(nil) | ||
if err != nil { | ||
return state, err | ||
} | ||
tok, err := erc20.NewERC20(tokAddress, chain.Client) | ||
if err != nil { | ||
return state, err | ||
} | ||
symbol, err := tok.Symbol(nil) | ||
if err != nil { | ||
return state, err | ||
} | ||
state.BurnMintTokenPools[TokenSymbol(symbol)] = pool | ||
case deployment.NewTypeAndVersion(BurnMintToken, deployment.Version1_0_0).String(): | ||
tok, err := burn_mint_erc677.NewBurnMintERC677(common.HexToAddress(address), chain.Client) | ||
if err != nil { | ||
return state, err | ||
} | ||
if state.BurnMintTokens677 == nil { | ||
state.BurnMintTokens677 = make(map[TokenSymbol]*burn_mint_erc677.BurnMintERC677) | ||
} | ||
symbol, err := tok.Symbol(nil) | ||
if err != nil { | ||
return state, fmt.Errorf("failed to get token symbol of token at %s: %w", address, err) | ||
} | ||
state.BurnMintTokens677[TokenSymbol(symbol)] = tok | ||
default: | ||
return state, fmt.Errorf("unknown contract %s", tvStr) | ||
} | ||
} | ||
return state, nil | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it'll be simpler if we have a single monster CCIPChainState, but embed the legacy one like
Since ultimately they'll be in the same address book. Then we can still just LoadCCIPChainState in a changeset, and take actions on the old contracts and the new ones if needed for migration