Skip to content

Commit

Permalink
[INTAUTO-308] - Adding Solana specific chain client and state
Browse files Browse the repository at this point in the history
  • Loading branch information
pablolagreca committed Dec 4, 2024
1 parent 88a6c75 commit 28cf95a
Show file tree
Hide file tree
Showing 56 changed files with 3,989 additions and 1,080 deletions.
2 changes: 2 additions & 0 deletions core/gethwrappers/ccip/generated/offramp/offramp.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

68 changes: 34 additions & 34 deletions deployment/ccip/changeset/accept_ownership_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ func Test_NewAcceptOwnershipChangeset(t *testing.T) {

// compose the transfer ownership and accept ownership changesets
_, err = commonchangeset.ApplyChangesets(t, e.Env, map[uint64]*gethwrappers.RBACTimelock{
source: state.Chains[source].Timelock,
dest: state.Chains[dest].Timelock,
source: state.EVMState.Chains[source].Timelock,
dest: state.EVMState.Chains[dest].Timelock,
}, []commonchangeset.ChangesetApplication{
// note this doesn't have proposals.
{
Expand Down Expand Up @@ -66,23 +66,23 @@ func genTestTransferOwnershipConfig(

// chain contracts
for _, chain := range chains {
timelocksPerChain[chain] = state.Chains[chain].Timelock.Address()
timelocksPerChain[chain] = state.EVMState.Chains[chain].Timelock.Address()
contracts[chain] = []commonchangeset.OwnershipTransferrer{
state.Chains[chain].OnRamp,
state.Chains[chain].OffRamp,
state.Chains[chain].FeeQuoter,
state.Chains[chain].NonceManager,
state.Chains[chain].RMNRemote,
state.EVMState.Chains[chain].OnRamp,
state.EVMState.Chains[chain].OffRamp,
state.EVMState.Chains[chain].FeeQuoter,
state.EVMState.Chains[chain].NonceManager,
state.EVMState.Chains[chain].RMNRemote,
}
}

// home chain
homeChainTimelockAddress := state.Chains[e.HomeChainSel].Timelock.Address()
homeChainTimelockAddress := state.EVMState.Chains[e.HomeChainSel].Timelock.Address()
timelocksPerChain[e.HomeChainSel] = homeChainTimelockAddress
contracts[e.HomeChainSel] = append(contracts[e.HomeChainSel],
state.Chains[e.HomeChainSel].CapabilityRegistry,
state.Chains[e.HomeChainSel].CCIPHome,
state.Chains[e.HomeChainSel].RMNHome,
state.EVMState.Chains[e.HomeChainSel].CapabilityRegistry,
state.EVMState.Chains[e.HomeChainSel].CCIPHome,
state.EVMState.Chains[e.HomeChainSel].RMNHome,
)

return commonchangeset.TransferOwnershipConfig{
Expand All @@ -102,25 +102,25 @@ func genTestAcceptOwnershipConfig(
contracts = make(map[uint64][]commonchangeset.OwnershipAcceptor)
)
for _, chain := range chains {
timelocksPerChain[chain] = state.Chains[chain].Timelock.Address()
proposerMCMses[chain] = state.Chains[chain].ProposerMcm
timelocksPerChain[chain] = state.EVMState.Chains[chain].Timelock.Address()
proposerMCMses[chain] = state.EVMState.Chains[chain].ProposerMcm
contracts[chain] = []commonchangeset.OwnershipAcceptor{
state.Chains[chain].OnRamp,
state.Chains[chain].OffRamp,
state.Chains[chain].FeeQuoter,
state.Chains[chain].NonceManager,
state.Chains[chain].RMNRemote,
state.EVMState.Chains[chain].OnRamp,
state.EVMState.Chains[chain].OffRamp,
state.EVMState.Chains[chain].FeeQuoter,
state.EVMState.Chains[chain].NonceManager,
state.EVMState.Chains[chain].RMNRemote,
}
}

// add home chain contracts.
// this overwrite should be fine.
timelocksPerChain[e.HomeChainSel] = state.Chains[e.HomeChainSel].Timelock.Address()
proposerMCMses[e.HomeChainSel] = state.Chains[e.HomeChainSel].ProposerMcm
timelocksPerChain[e.HomeChainSel] = state.EVMState.Chains[e.HomeChainSel].Timelock.Address()
proposerMCMses[e.HomeChainSel] = state.EVMState.Chains[e.HomeChainSel].ProposerMcm
contracts[e.HomeChainSel] = append(contracts[e.HomeChainSel],
state.Chains[e.HomeChainSel].CapabilityRegistry,
state.Chains[e.HomeChainSel].CCIPHome,
state.Chains[e.HomeChainSel].RMNHome,
state.EVMState.Chains[e.HomeChainSel].CapabilityRegistry,
state.EVMState.Chains[e.HomeChainSel].CCIPHome,
state.EVMState.Chains[e.HomeChainSel].RMNHome,
)

return commonchangeset.AcceptOwnershipConfig{
Expand All @@ -143,26 +143,26 @@ func assertTimelockOwnership(
// check that the ownership has been transferred correctly
for _, chain := range chains {
for _, contract := range []commonchangeset.OwnershipTransferrer{
state.Chains[chain].OnRamp,
state.Chains[chain].OffRamp,
state.Chains[chain].FeeQuoter,
state.Chains[chain].NonceManager,
state.Chains[chain].RMNRemote,
state.EVMState.Chains[chain].OnRamp,
state.EVMState.Chains[chain].OffRamp,
state.EVMState.Chains[chain].FeeQuoter,
state.EVMState.Chains[chain].NonceManager,
state.EVMState.Chains[chain].RMNRemote,
} {
owner, err := contract.Owner(&bind.CallOpts{
Context: ctx,
})
require.NoError(t, err)
require.Equal(t, state.Chains[chain].Timelock.Address(), owner)
require.Equal(t, state.EVMState.Chains[chain].Timelock.Address(), owner)
}
}

// check home chain contracts ownership
homeChainTimelockAddress := state.Chains[e.HomeChainSel].Timelock.Address()
homeChainTimelockAddress := state.EVMState.Chains[e.HomeChainSel].Timelock.Address()
for _, contract := range []commonchangeset.OwnershipTransferrer{
state.Chains[e.HomeChainSel].CapabilityRegistry,
state.Chains[e.HomeChainSel].CCIPHome,
state.Chains[e.HomeChainSel].RMNHome,
state.EVMState.Chains[e.HomeChainSel].CapabilityRegistry,
state.EVMState.Chains[e.HomeChainSel].CCIPHome,
state.EVMState.Chains[e.HomeChainSel].RMNHome,
} {
owner, err := contract.Owner(&bind.CallOpts{
Context: ctx,
Expand Down
63 changes: 15 additions & 48 deletions deployment/ccip/changeset/active_candidate.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,53 +3,35 @@ package changeset
import (
"fmt"

"github.com/ethereum/go-ethereum/common"
"github.com/smartcontractkit/ccip-owner-contracts/pkg/gethwrappers"
"github.com/smartcontractkit/ccip-owner-contracts/pkg/proposal/mcms"
"github.com/smartcontractkit/ccip-owner-contracts/pkg/proposal/timelock"

"github.com/smartcontractkit/chainlink/deployment"
"github.com/smartcontractkit/chainlink/deployment/ccip/changeset/internal"
"github.com/smartcontractkit/chainlink/deployment/common/proposalutils"
cctypes "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/types"
)

// PromoteAllCandidatesChangeset generates a proposal to call promoteCandidate on the CCIPHome through CapReg.
// This needs to be called after SetCandidateProposal is executed.
// TODO: make it conform to the ChangeSet interface.
func PromoteAllCandidatesChangeset(
state CCIPOnChainState,
homeChainSel, newChainSel uint64,
nodes deployment.Nodes,
) (deployment.ChangesetOutput, error) {
promoteCandidateOps, err := PromoteAllCandidatesForChainOps(
state.Chains[homeChainSel].CapabilityRegistry,
state.Chains[homeChainSel].CCIPHome,
state.EVMState.Chains[homeChainSel].CapabilityRegistry,
state.EVMState.Chains[homeChainSel].CCIPHome,
newChainSel,
nodes.NonBootstraps(),
)
if err != nil {
return deployment.ChangesetOutput{}, err
}

var (
timelocksPerChain = map[uint64]common.Address{
homeChainSel: state.Chains[homeChainSel].Timelock.Address(),
}
proposerMCMSes = map[uint64]*gethwrappers.ManyChainMultiSig{
homeChainSel: state.Chains[homeChainSel].ProposerMcm,
}
)
prop, err := proposalutils.BuildProposalFromBatches(
timelocksPerChain,
proposerMCMSes,
[]timelock.BatchChainOperation{{
ChainIdentifier: mcms.ChainIdentifier(homeChainSel),
Batch: promoteCandidateOps,
}},
"promoteCandidate for commit and execution",
0, // minDelay
)
prop, err := BuildProposalFromBatches(state, []timelock.BatchChainOperation{{
ChainIdentifier: mcms.ChainIdentifier(homeChainSel),
Batch: promoteCandidateOps,
}}, "promoteCandidate for commit and execution", 0)
if err != nil {
return deployment.ChangesetOutput{}, err
}
Expand All @@ -61,7 +43,6 @@ func PromoteAllCandidatesChangeset(
}

// SetCandidateExecPluginProposal calls setCandidate on the CCIPHome for setting up OCR3 exec Plugin config for the new chain.
// TODO: make it conform to the ChangeSet interface.
func SetCandidatePluginChangeset(
state CCIPOnChainState,
e deployment.Environment,
Expand All @@ -73,15 +54,15 @@ func SetCandidatePluginChangeset(
) (deployment.ChangesetOutput, error) {
ccipOCRParams := DefaultOCRParams(
feedChainSel,
tokenConfig.GetTokenInfo(e.Logger, state.Chains[newChainSel].LinkToken, state.Chains[newChainSel].Weth9),
tokenConfig.GetTokenInfo(e.Logger, state.EVMState.Chains[newChainSel].LinkToken, state.EVMState.Chains[newChainSel].Weth9),
nil,
)
newDONArgs, err := internal.BuildOCR3ConfigForCCIPHome(
ocrSecrets,
state.Chains[newChainSel].OffRamp,
state.EVMState.Chains[newChainSel].OffRamp,
e.Chains[newChainSel],
nodes.NonBootstraps(),
state.Chains[homeChainSel].RMNHome.Address(),
state.EVMState.Chains[homeChainSel].RMNHome.Address(),
ccipOCRParams.OCRParameters,
ccipOCRParams.CommitOffChainConfig,
ccipOCRParams.ExecuteOffChainConfig,
Expand All @@ -97,33 +78,19 @@ func SetCandidatePluginChangeset(

setCandidateMCMSOps, err := SetCandidateOnExistingDon(
execConfig,
state.Chains[homeChainSel].CapabilityRegistry,
state.Chains[homeChainSel].CCIPHome,
state.EVMState.Chains[homeChainSel].CapabilityRegistry,
state.EVMState.Chains[homeChainSel].CCIPHome,
newChainSel,
nodes.NonBootstraps(),
)
if err != nil {
return deployment.ChangesetOutput{}, err
}

var (
timelocksPerChain = map[uint64]common.Address{
homeChainSel: state.Chains[homeChainSel].Timelock.Address(),
}
proposerMCMSes = map[uint64]*gethwrappers.ManyChainMultiSig{
homeChainSel: state.Chains[homeChainSel].ProposerMcm,
}
)
prop, err := proposalutils.BuildProposalFromBatches(
timelocksPerChain,
proposerMCMSes,
[]timelock.BatchChainOperation{{
ChainIdentifier: mcms.ChainIdentifier(homeChainSel),
Batch: setCandidateMCMSOps,
}},
"SetCandidate for execution",
0, // minDelay
)
prop, err := BuildProposalFromBatches(state, []timelock.BatchChainOperation{{
ChainIdentifier: mcms.ChainIdentifier(homeChainSel),
Batch: setCandidateMCMSOps,
}}, "SetCandidate for execution", 0)
if err != nil {
return deployment.ChangesetOutput{}, err
}
Expand Down
Loading

0 comments on commit 28cf95a

Please sign in to comment.