Skip to content

Commit

Permalink
more review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
AnieeG committed Nov 21, 2024
1 parent 8d4a5bb commit 9ca4940
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 24 deletions.
2 changes: 1 addition & 1 deletion deployment/ccip/changeset/add_chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func TestAddChainInbound(t *testing.T) {
require.NoError(t, e.Env.ExistingAddresses.Merge(out.AddressBook))
newAddresses = deployment.NewMemoryAddressBook()
tokenConfig := NewTestTokenConfig(state.Chains[e.FeedChainSel].USDFeeds)
err = DeployCCIPContracts(e.Env, newAddresses, NewChainsConfig{
err = deployCCIPContracts(e.Env, newAddresses, NewChainsConfig{
HomeChainSel: e.HomeChainSel,
FeedChainSel: e.FeedChainSel,
ChainsToDeploy: initialDeploy,
Expand Down
8 changes: 4 additions & 4 deletions deployment/ccip/changeset/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ func configureChain(
return nil
}

// DeployCCIPContracts assumes the following contracts are deployed:
// deployCCIPContracts assumes the following contracts are deployed:
// - Capability registry
// - CCIP home
// - RMN home
Expand All @@ -414,11 +414,11 @@ func configureChain(
// It then deploys the rest of the CCIP chain contracts to the selected chains
// registers the nodes with the capability registry and creates a DON for
// each new chain.
func DeployCCIPContracts(
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.ChainsToDeploy)
if err != nil {
e.Logger.Errorw("Failed to deploy chain contracts", "err", err)
return err
Expand All @@ -437,7 +437,7 @@ func DeployCCIPContracts(
return nil
}

func DeployChainContractsForChains(
func deployChainContractsForChains(
e deployment.Environment,
ab deployment.AddressBook,
homeChainSel uint64,
Expand Down
4 changes: 2 additions & 2 deletions deployment/ccip/changeset/deploy_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ var _ deployment.ChangeSet[DeployChainContractsConfig] = DeployChainContracts

// DeployChainContracts deploys all new CCIP v1.6 or later contracts for the given chains.
// It returns the new addresses for the contracts.
// If there is an error, it will return the successfully deployed addresses and the error so that the caller can call the
// DeployChainContracts is idempotent. If there is an error, it will return the successfully deployed addresses and the error so that the caller can call the
// changeset again with the same input to retry the failed deployment.
// Caller should update the environment's address book with the returned addresses.
func DeployChainContracts(env deployment.Environment, c DeployChainContractsConfig) (deployment.ChangesetOutput, error) {
newAddresses := deployment.NewMemoryAddressBook()
err := DeployChainContractsForChains(env, newAddresses, c.HomeChainSelector, c.ChainSelectors)
err := deployChainContractsForChains(env, newAddresses, c.HomeChainSelector, 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)
Expand Down
19 changes: 13 additions & 6 deletions deployment/common/changeset/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/smartcontractkit/ccip-owner-contracts/pkg/gethwrappers"
jobv1 "github.com/smartcontractkit/chainlink-protos/job-distributor/v1/job"
"github.com/smartcontractkit/chainlink-testing-framework/lib/utils/testcontext"
"github.com/stretchr/testify/require"

"github.com/smartcontractkit/chainlink/deployment"
)
Expand All @@ -34,12 +35,18 @@ func WrapChangeSet[C any](fn deployment.ChangeSet[C]) func(e deployment.Environm

// ApplyChangesets applies the changeset applications to the environment and returns the updated environment.
func ApplyChangesets(t *testing.T, e deployment.Environment, timelocksPerChain map[uint64]*gethwrappers.RBACTimelock, changesetApplications []ChangesetApplication) (deployment.Environment, error) {
currentEnv, err := e.Copy()
if err != nil {
return e, fmt.Errorf("failed to copy environment: %w", err)
}
addrBook := deployment.NewMemoryAddressBook()
require.NoError(t, addrBook.Merge(e.ExistingAddresses))
currentEnv := deployment.NewEnvironment(
e.Name,
e.Logger,
addrBook,
e.Chains,
e.NodeIDs,
e.Offchain,
)
for i, csa := range changesetApplications {
out, err := csa.Changeset(currentEnv, csa.Config)
out, err := csa.Changeset(*currentEnv, csa.Config)
if err != nil {
return e, fmt.Errorf("failed to apply changeset at index %d: %w", i, err)
}
Expand Down Expand Up @@ -83,5 +90,5 @@ func ApplyChangesets(t *testing.T, e deployment.Environment, timelocksPerChain m
}
}
}
return currentEnv, nil
return *currentEnv, nil
}
11 changes: 0 additions & 11 deletions deployment/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,6 @@ type Environment struct {
Offchain OffchainClient
}

func (e Environment) Copy() (Environment, error) {
newEnv := e
addr := NewMemoryAddressBook()
err := addr.Merge(e.ExistingAddresses)
if err != nil {
return Environment{}, err
}
newEnv.ExistingAddresses = addr
return newEnv, nil
}

func NewEnvironment(
name string,
logger logger.Logger,
Expand Down

0 comments on commit 9ca4940

Please sign in to comment.