Skip to content

Commit

Permalink
[wip] feat(deployments): synced with solana-mcms-deploy branch
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavogama-cll committed Jan 30, 2025
1 parent ac72e71 commit f762328
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 121 deletions.
9 changes: 5 additions & 4 deletions deployment/common/changeset/deploy_mcms_solana.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func DeployMCMSWithTimelockContractsSolana(
state MCMSSolanaState,
chain deployment.SolChain,
addressBook deployment.AddressBook,
config types.MCMSWithTimelockConfig,
config types.MCMSWithTimelockConfigV2,
) (any, error) { // FIXME: define return type
err := deployMCMSSolana(e, state, chain, addressBook, config)
if err != nil {
Expand All @@ -55,7 +55,7 @@ func DeployMCMSWithTimelockContractsSolana(

func deployMCMSSolana(
e deployment.Environment, state MCMSSolanaState, chain deployment.SolChain, addressBook deployment.AddressBook,
_ types.MCMSWithTimelockConfig,
_ types.MCMSWithTimelockConfigV2,
) error {
var mcmProgram solana.PublicKey
if state.MCM.IsZero() {
Expand Down Expand Up @@ -92,7 +92,7 @@ func deployMCMSSolana(

func deployTimelockSolana(
e deployment.Environment, state MCMSSolanaState, chain deployment.SolChain, addressBook deployment.AddressBook,
config types.MCMSWithTimelockConfig,
config types.MCMSWithTimelockConfigV2,
) error {
var timelockProgram solana.PublicKey
if state.Timelock.IsZero() {
Expand Down Expand Up @@ -129,7 +129,7 @@ func deployTimelockSolana(

func deployAccessControllerSolana(
e deployment.Environment, state MCMSSolanaState, chain deployment.SolChain, addressBook deployment.AddressBook,
_ types.MCMSWithTimelockConfig,
_ types.MCMSWithTimelockConfigV2,
) error {
var accessControllerProgram solana.PublicKey
if state.AccessController.IsZero() {
Expand Down Expand Up @@ -258,6 +258,7 @@ func initializeTimelock(
var bypasserRoleAccessController solana.PublicKey

instruction, err := timelockBindings.NewInitializeInstruction(
timelockID,
minDelay.Uint64(), // minDelay,
GetTimelockConfigPDA(timelockProgram, timelockID),
chain.DeployerKey.PublicKey(),
Expand Down
19 changes: 18 additions & 1 deletion deployment/common/changeset/deploy_mcms_with_timelock.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,27 @@ import (

"github.com/smartcontractkit/chainlink/deployment"
"github.com/smartcontractkit/chainlink/deployment/common/changeset/internal"
"github.com/smartcontractkit/chainlink/deployment/common/changeset/internal/mcmsnew/evm"
"github.com/smartcontractkit/chainlink/deployment/common/types"
)

var _ deployment.ChangeSet[map[uint64]types.MCMSWithTimelockConfig] = DeployMCMSWithTimelock
var _ deployment.ChangeSet[map[uint64]types.MCMSWithTimelockConfigV2] = DeployMCMSWithTimelockV2

func DeployMCMSWithTimelock(e deployment.Environment, cfgByChain map[uint64]types.MCMSWithTimelockConfig) (deployment.ChangesetOutput, error) {
newAddresses := deployment.NewMemoryAddressBook()
err := internal.DeployMCMSWithTimelockContractsBatch(
e.Logger, e.Chains, newAddresses, cfgByChain,
)
if err != nil {
return deployment.ChangesetOutput{AddressBook: newAddresses}, err
}
return deployment.ChangesetOutput{AddressBook: newAddresses}, nil
}

func DeployMCMSWithTimelockV2(
e deployment.Environment, cfgByChain map[uint64]types.MCMSWithTimelockConfigV2,
) (deployment.ChangesetOutput, error) {
newAddresses := deployment.NewMemoryAddressBook()

for chainSelector, config := range cfgByChain {
Expand All @@ -29,10 +44,11 @@ func DeployMCMSWithTimelock(e deployment.Environment, cfgByChain map[uint64]type
return deployment.ChangesetOutput{AddressBook: newAddresses}, err
}

_, err := internal.DeployMCMSWithTimelockContracts(e.Logger, chain, newAddresses, config)
_, err := evm.DeployMCMSWithTimelockContractsEVM(e.Logger, chain, newAddresses, config)
if err != nil {
return deployment.ChangesetOutput{AddressBook: newAddresses}, err
}

case chainselectors.FamilySolana:
chain, found := e.SolChains[chainSelector]
if !found {
Expand All @@ -50,6 +66,7 @@ func DeployMCMSWithTimelock(e deployment.Environment, cfgByChain map[uint64]type
if err != nil {
return deployment.ChangesetOutput{AddressBook: newAddresses}, err
}

default:
return deployment.ChangesetOutput{AddressBook: newAddresses}, fmt.Errorf("unsupported chain family: %s", family)
}
Expand Down
5 changes: 2 additions & 3 deletions deployment/common/changeset/internal/mcmsnew/evm/mcms.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
mcmsTypes "github.com/smartcontractkit/mcms/types"

"github.com/smartcontractkit/chainlink/deployment"
"github.com/smartcontractkit/chainlink/deployment/common/changeset/internal/mcmsnew"
"github.com/smartcontractkit/chainlink/deployment/common/types"
"github.com/smartcontractkit/chainlink/deployment/common/view/v1_0"
)
Expand Down Expand Up @@ -70,11 +69,11 @@ func deployMCMSWithConfigEVM(
// MCMS contracts for the given configuration
// as well as the timelock. It's not necessarily the only way to use
// the timelock and MCMS, but its reasonable pattern.
func deployMCMSWithTimelockContractsEVM(
func DeployMCMSWithTimelockContractsEVM(
lggr logger.Logger,
chain deployment.Chain,
ab deployment.AddressBook,
config mcmsnew.MCMSWithTimelockConfig,
config types.MCMSWithTimelockConfigV2,
) (*MCMSWithTimelockEVMDeploy, error) {
bypasser, err := deployMCMSWithConfigEVM(types.BypasserManyChainMultisig, lggr, chain, ab, config.Bypasser)
if err != nil {
Expand Down
51 changes: 0 additions & 51 deletions deployment/common/changeset/internal/mcmsnew/mcms.go

This file was deleted.

46 changes: 0 additions & 46 deletions deployment/common/changeset/internal/mcmsnew/solana/mcms.go

This file was deleted.

32 changes: 16 additions & 16 deletions deployment/common/changeset/mcmsnew/deploy_mcms_with_timelock.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package mcmsnew

import (
"github.com/smartcontractkit/chainlink/deployment"
"github.com/smartcontractkit/chainlink/deployment/common/changeset/internal/mcmsnew"
"github.com/smartcontractkit/chainlink/deployment/common/types"
)

var _ deployment.ChangeSet[map[uint64]types.MCMSWithTimelockConfig] = DeployMCMSWithTimelockSolana

func DeployMCMSWithTimelockSolana(e deployment.Environment, cfgByChain map[uint64]types.MCMSWithTimelockConfig) (deployment.ChangesetOutput, error) {
newAddresses := deployment.NewMemoryAddressBook()
err := mcmsnew.DeployMCMSWithTimelockContractsBatch(e.Logger, e.SolChains, newAddresses, cfgByChain)
if err != nil {
return deployment.ChangesetOutput{AddressBook: newAddresses}, err
}
return deployment.ChangesetOutput{AddressBook: newAddresses}, nil
}
// import (
// "github.com/smartcontractkit/chainlink/deployment"
// "github.com/smartcontractkit/chainlink/deployment/common/changeset/internal/mcmsnew"
// "github.com/smartcontractkit/chainlink/deployment/common/types"
// )
//
// var _ deployment.ChangeSet[map[uint64]types.MCMSWithTimelockConfig] = DeployMCMSWithTimelockSolana
//
// func DeployMCMSWithTimelockSolana(e deployment.Environment, cfgByChain map[uint64]types.MCMSWithTimelockConfig) (deployment.ChangesetOutput, error) {
// newAddresses := deployment.NewMemoryAddressBook()
// err := mcmsnew.DeployMCMSWithTimelockContractsBatch(e.Logger, e.SolChains, newAddresses, cfgByChain)
// if err != nil {
// return deployment.ChangesetOutput{AddressBook: newAddresses}, err
// }
// return deployment.ChangesetOutput{AddressBook: newAddresses}, nil
// }
9 changes: 9 additions & 0 deletions deployment/common/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"time"

"github.com/smartcontractkit/ccip-owner-contracts/pkg/config"
mcmstypes "github.com/smartcontractkit/mcms/types"

"github.com/smartcontractkit/chainlink/deployment"
)
Expand Down Expand Up @@ -35,6 +36,14 @@ type MCMSWithTimelockConfig struct {
TimelockMinDelay *big.Int
}

type MCMSWithTimelockConfigV2 struct {
Seed [16]byte // application specific identifier; must be unique per chain
Canceller mcmstypes.Config
Bypasser mcmstypes.Config
Proposer mcmstypes.Config
TimelockMinDelay *big.Int
}

type OCRParameters struct {
DeltaProgress time.Duration
DeltaResend time.Duration
Expand Down

0 comments on commit f762328

Please sign in to comment.