Skip to content

Commit

Permalink
fix conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
AnieeG committed Dec 3, 2024
2 parents 1d93e3b + 88a6c75 commit 6854e09
Show file tree
Hide file tree
Showing 10 changed files with 132 additions and 252 deletions.
42 changes: 3 additions & 39 deletions deployment/ccip/changeset/accept_ownership_test.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
package changeset

import (
"math/big"
"testing"
"time"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/smartcontractkit/ccip-owner-contracts/pkg/gethwrappers"

"github.com/smartcontractkit/chainlink-common/pkg/utils/tests"

"github.com/smartcontractkit/chainlink/deployment"
commonchangeset "github.com/smartcontractkit/chainlink/deployment/common/changeset"
commontypes "github.com/smartcontractkit/chainlink/deployment/common/types"
"github.com/smartcontractkit/chainlink/deployment/environment/memory"

"github.com/stretchr/testify/require"
Expand All @@ -22,53 +20,19 @@ import (
)

func Test_NewAcceptOwnershipChangeset(t *testing.T) {
e := NewMemoryEnvironmentWithJobs(t, logger.TestLogger(t), memory.MemoryEnvironmentConfig{
e := NewMemoryEnvironmentWithJobsAndContracts(t, logger.TestLogger(t), memory.MemoryEnvironmentConfig{
Chains: 2,
NumOfUsersPerChain: 1,
Nodes: 4,
Bootstraps: 1,
})
}, &TestConfigs{})
state, err := LoadOnchainState(e.Env)
require.NoError(t, err)

allChains := maps.Keys(e.Env.Chains)
source := allChains[0]
dest := allChains[1]

newAddresses := deployment.NewMemoryAddressBook()
err = deployPrerequisiteChainContracts(e.Env, newAddresses, allChains, nil)
require.NoError(t, err)
require.NoError(t, e.Env.ExistingAddresses.Merge(newAddresses))

mcmConfig := commontypes.MCMSWithTimelockConfig{
Canceller: commonchangeset.SingleGroupMCMS(t),
Bypasser: commonchangeset.SingleGroupMCMS(t),
Proposer: commonchangeset.SingleGroupMCMS(t),
TimelockExecutors: e.Env.AllDeployerKeys(),
TimelockMinDelay: big.NewInt(0),
}
out, err := commonchangeset.DeployMCMSWithTimelock(e.Env, map[uint64]commontypes.MCMSWithTimelockConfig{
source: mcmConfig,
dest: mcmConfig,
})
require.NoError(t, err)
require.NoError(t, e.Env.ExistingAddresses.Merge(out.AddressBook))
newAddresses = deployment.NewMemoryAddressBook()
tokenConfig := NewTestTokenConfig(state.Chains[e.FeedChainSel].USDFeeds)
ocrParams := make(map[uint64]CCIPOCRParams)
for _, chain := range allChains {
ocrParams[chain] = DefaultOCRParams(e.FeedChainSel, nil)
}
err = deployCCIPContracts(e.Env, newAddresses, NewChainsConfig{
HomeChainSel: e.HomeChainSel,
FeedChainSel: e.FeedChainSel,
ChainsToDeploy: allChains,
TokenConfig: tokenConfig,
OCRSecrets: deployment.XXXGenerateTestOCRSecrets(),
OCRParams: ocrParams,
})
require.NoError(t, err)

// at this point we have the initial deploys done, now we need to transfer ownership
// to the timelock contract
state, err = LoadOnchainState(e.Env)
Expand Down
1 change: 1 addition & 0 deletions deployment/ccip/changeset/active_candidate.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func SetCandidatePluginChangeset(
ccipOCRParams := DefaultOCRParams(
feedChainSel,
tokenConfig.GetTokenInfo(e.Logger, state.Chains[newChainSel].LinkToken, state.Chains[newChainSel].Weth9),
nil,
)
newDONArgs, err := internal.BuildOCR3ConfigForCCIPHome(
ocrSecrets,
Expand Down
1 change: 1 addition & 0 deletions deployment/ccip/changeset/active_candidate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ func TestActiveCandidate(t *testing.T) {
ccipOCRParams := DefaultOCRParams(
tenv.FeedChainSel,
tokenConfig.GetTokenInfo(e.Logger, state.Chains[tenv.FeedChainSel].LinkToken, state.Chains[tenv.FeedChainSel].Weth9),
nil,
)
ocr3ConfigMap, err := internal.BuildOCR3ConfigForCCIPHome(
deployment.XXXGenerateTestOCRSecrets(),
Expand Down
3 changes: 3 additions & 0 deletions deployment/ccip/changeset/add_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"math/big"

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

"github.com/smartcontractkit/chainlink/deployment/ccip/changeset/internal"
"github.com/smartcontractkit/chainlink/deployment/common/proposalutils"
"github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/types"
Expand Down Expand Up @@ -119,6 +120,8 @@ func AddDonAndSetCandidateChangeset(
ccipOCRParams := DefaultOCRParams(
feedChainSel,
tokenConfig.GetTokenInfo(e.Logger, state.Chains[newChainSel].LinkToken, state.Chains[newChainSel].Weth9),
// TODO: Need USDC support.
nil,
)
newDONArgs, err := internal.BuildOCR3ConfigForCCIPHome(
ocrSecrets,
Expand Down
13 changes: 8 additions & 5 deletions deployment/ccip/changeset/add_chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,15 @@ func TestAddChainInbound(t *testing.T) {
newAddresses = deployment.NewMemoryAddressBook()
tokenConfig := NewTestTokenConfig(state.Chains[e.FeedChainSel].USDFeeds)

chainConfig := make(map[uint64]CCIPOCRParams)
for _, chain := range initialDeploy {
chainConfig[chain] = DefaultOCRParams(e.FeedChainSel, nil, nil)
}
err = deployCCIPContracts(e.Env, newAddresses, NewChainsConfig{
HomeChainSel: e.HomeChainSel,
FeedChainSel: e.FeedChainSel,
ChainsToDeploy: initialDeploy,
TokenConfig: tokenConfig,
OCRSecrets: deployment.XXXGenerateTestOCRSecrets(),
HomeChainSel: e.HomeChainSel,
FeedChainSel: e.FeedChainSel,
ChainConfigByChain: chainConfig,
OCRSecrets: deployment.XXXGenerateTestOCRSecrets(),
})
require.NoError(t, err)

Expand Down
28 changes: 3 additions & 25 deletions deployment/ccip/changeset/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"golang.org/x/sync/errgroup"

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

"github.com/smartcontractkit/chainlink/deployment/ccip/changeset/internal"

"github.com/smartcontractkit/chainlink/deployment"
Expand Down Expand Up @@ -372,16 +370,12 @@ func configureChain(
return fmt.Errorf("rmn home not found")
}

for _, chainSel := range c.ChainsToDeploy {
for chainSel, chainConfig := range c.ChainConfigByChain {
chain, _ := e.Chains[chainSel]
chainState, ok := existingState.Chains[chain.Selector]
if !ok {
return fmt.Errorf("chain state not found for chain %d", chain.Selector)
}
ocrParams, ok := c.OCRParams[chain.Selector]
if !ok {
return fmt.Errorf("OCR params not found for chain %d", chain.Selector)
}
if chainState.OffRamp == nil {
return fmt.Errorf("off ramp not found for chain %d", chain.Selector)
}
Expand All @@ -394,10 +388,6 @@ func configureChain(
if err != nil {
return err
}
if enabled, ok := c.USDCConfig.EnabledChainMap()[chainSel]; ok && enabled {
ocrParams.ExecuteOffChainConfig.TokenDataObservers = c.USDCConfig.ToTokenDataObserverConfig()
}
ocrParams.CommitOffChainConfig.PriceFeedChainSelector = cciptypes.ChainSelector(c.FeedChainSel)
// For each chain, we create a DON on the home chain (2 OCR instances)
if err := addDON(
e.Logger,
Expand All @@ -409,7 +399,7 @@ func configureChain(
chain,
e.Chains[c.HomeChainSel],
nodes.NonBootstraps(),
ocrParams,
chainConfig,
); err != nil {
e.Logger.Errorw("Failed to add DON", "err", err)
return err
Expand All @@ -432,7 +422,7 @@ func deployCCIPContracts(
e deployment.Environment,
ab deployment.AddressBook,
c NewChainsConfig) error {
err := deployChainContractsForChains(e, ab, c.HomeChainSel, c.ChainsToDeploy)
err := deployChainContractsForChains(e, ab, c.HomeChainSel, c.Chains())
if err != nil {
e.Logger.Errorw("Failed to deploy chain contracts", "err", err)
return err
Expand All @@ -442,18 +432,6 @@ func deployCCIPContracts(
e.Logger.Errorw("Failed to merge address book", "err", err)
return err
}
state, err := LoadOnchainState(e)
if err != nil {
e.Logger.Errorw("Failed to load existing onchain state", "err", err)
return err
}

ocrParams := make(map[uint64]CCIPOCRParams)
for _, chain := range c.ChainsToDeploy {
tokenInfo := c.TokenConfig.GetTokenInfo(e.Logger, state.Chains[chain].LinkToken, state.Chains[chain].Weth9)
ocrParams[chain] = DefaultOCRParams(c.FeedChainSel, tokenInfo)
}
c.OCRParams = ocrParams
err = configureChain(e, c)
if err != nil {
e.Logger.Errorw("Failed to add chain", "err", err)
Expand Down
2 changes: 1 addition & 1 deletion deployment/ccip/changeset/deploy_home_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ func AddChainConfig(
chainSelector uint64,
p2pIDs [][32]byte,
) (ccip_home.CCIPHomeChainConfigArgs, error) {
// First Add ChainConfig that includes all p2pIDs as readers
// First Add CCIPOCRParams that includes all p2pIDs as readers
encodedExtraChainConfig, err := chainconfig.EncodeChainConfig(chainconfig.ChainConfig{
GasPriceDeviationPPB: ccipocr3.NewBigIntFromInt64(1000),
DAGasPriceDeviationPPB: ccipocr3.NewBigIntFromInt64(0),
Expand Down
Loading

0 comments on commit 6854e09

Please sign in to comment.