Skip to content
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

deprecate kslib #15759

Merged
merged 11 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/sour-hairs-cross.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": patch
---

#internal depreciate keystone deployment library
4 changes: 2 additions & 2 deletions core/scripts/keystone/src/01_deploy_contracts_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/ethereum/go-ethereum/common"

helpers "github.com/smartcontractkit/chainlink/core/scripts/common"
ksdeploy "github.com/smartcontractkit/chainlink/deployment/keystone"
"github.com/smartcontractkit/chainlink/deployment/keystone/changeset"
forwarder "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/keystone/generated/forwarder_1_0_0"
ocr3_capability "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/keystone/generated/ocr3_capability_1_0_0"
)
Expand Down Expand Up @@ -157,7 +157,7 @@ func deploy(

func setOCR3Config(
env helpers.Environment,
ocrConfig ksdeploy.OCR2OracleConfig,
ocrConfig changeset.OCR3OnchainConfig,
artefacts string,
) {
loadedContracts, err := LoadDeployedContracts(artefacts)
Expand Down
4 changes: 2 additions & 2 deletions core/scripts/keystone/src/88_gen_jobspecs.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strings"

helpers "github.com/smartcontractkit/chainlink/core/scripts/common"
ksdeploy "github.com/smartcontractkit/chainlink/deployment/keystone"
"github.com/smartcontractkit/chainlink/deployment/keystone/changeset"
)

type spec []string
Expand Down Expand Up @@ -74,7 +74,7 @@ func replacePlaceholders(

chainID, p2pPort int64,
contractAddress, bootHost string,
boot, node ksdeploy.NodeKeys,
boot, node changeset.NodeKeys,
) (output []string) {
chainIDStr := strconv.FormatInt(chainID, 10)
bootstrapper := fmt.Sprintf("%s@%s:%d", boot.P2PPeerID, bootHost, p2pPort)
Expand Down
4 changes: 2 additions & 2 deletions core/scripts/keystone/src/88_gen_ocr3_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ package src
import (
helpers "github.com/smartcontractkit/chainlink/core/scripts/common"
"github.com/smartcontractkit/chainlink/deployment"
ksdeploy "github.com/smartcontractkit/chainlink/deployment/keystone"
ksdeploy "github.com/smartcontractkit/chainlink/deployment/keystone/changeset"
)

func mustReadConfig(fileName string) (output ksdeploy.TopLevelConfigSource) {
return mustParseJSON[ksdeploy.TopLevelConfigSource](fileName)
}

func generateOCR3Config(nodeList string, configFile string, chainID int64, pubKeysPath string) ksdeploy.OCR2OracleConfig {
func generateOCR3Config(nodeList string, configFile string, chainID int64, pubKeysPath string) ksdeploy.OCR3OnchainConfig {
topLevelCfg := mustReadConfig(configFile)
cfg := topLevelCfg.OracleConfig
nca := downloadNodePubKeys(nodeList, chainID, pubKeysPath)
Expand Down
10 changes: 5 additions & 5 deletions core/scripts/keystone/src/99_fetch_keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ import (
"github.com/urfave/cli"

helpers "github.com/smartcontractkit/chainlink/core/scripts/common"
ksdeploy "github.com/smartcontractkit/chainlink/deployment/keystone"
"github.com/smartcontractkit/chainlink/deployment/keystone/changeset"
ubig "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils/big"
"github.com/smartcontractkit/chainlink/v2/core/cmd"
"github.com/smartcontractkit/chainlink/v2/core/web/presenters"
)

func downloadNodePubKeys(nodeList string, chainID int64, pubKeysPath string) []ksdeploy.NodeKeys {
func downloadNodePubKeys(nodeList string, chainID int64, pubKeysPath string) []changeset.NodeKeys {
// Check if file exists already, and if so, return the keys
if _, err := os.Stat(pubKeysPath); err == nil {
fmt.Println("Loading existing public keys at:", pubKeysPath)
return mustParseJSON[[]ksdeploy.NodeKeys](pubKeysPath)
return mustParseJSON[[]changeset.NodeKeys](pubKeysPath)
}

nodes := downloadNodeAPICredentials(nodeList)
Expand Down Expand Up @@ -97,7 +97,7 @@ type ocr2Bundle struct {
ConfigPublicKey string `json:"configPublicKey"`
}

func mustFetchNodesKeys(chainID int64, nodes []*node) (nca []ksdeploy.NodeKeys) {
func mustFetchNodesKeys(chainID int64, nodes []*node) (nca []changeset.NodeKeys) {
for _, n := range nodes {
output := &bytes.Buffer{}
client, app := newApp(n, output)
Expand Down Expand Up @@ -209,7 +209,7 @@ func mustFetchNodesKeys(chainID int64, nodes []*node) (nca []ksdeploy.NodeKeys)
helpers.PanicErr(err)
output.Reset()

nc := ksdeploy.NodeKeys{
nc := changeset.NodeKeys{
EthAddress: ethAddress,
AptosAccount: aptosAccount,
P2PPeerID: peerID,
Expand Down
2 changes: 1 addition & 1 deletion deployment/keystone/changeset/accept_ownership.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

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

kslib "github.com/smartcontractkit/chainlink/deployment/keystone"
kslib "github.com/smartcontractkit/chainlink/deployment/keystone/changeset/internal"

"github.com/smartcontractkit/chainlink/deployment"
"github.com/smartcontractkit/chainlink/deployment/common/changeset"
Expand Down
2 changes: 1 addition & 1 deletion deployment/keystone/changeset/accept_ownership_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func TestAcceptAllOwnership(t *testing.T) {
},
{
Changeset: commonchangeset.WrapChangeSet(changeset.DeployForwarder),
Config: registrySel,
Config: changeset.DeployForwarderRequest{},
},
{
Changeset: commonchangeset.WrapChangeSet(changeset.DeployFeedsConsumer),
Expand Down
15 changes: 8 additions & 7 deletions deployment/keystone/changeset/addrbook_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import (
ccipowner "github.com/smartcontractkit/ccip-owner-contracts/pkg/gethwrappers"

"github.com/smartcontractkit/chainlink/deployment"
"github.com/smartcontractkit/chainlink/deployment/keystone"

"github.com/smartcontractkit/chainlink/deployment/keystone/changeset/internal"
capReg "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/keystone/generated/capabilities_registry_1_1_0"
feeds_consumer "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/keystone/generated/feeds_consumer_1_0_0"
keystoneForwarder "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/keystone/generated/forwarder_1_0_0"
Expand Down Expand Up @@ -56,7 +57,7 @@ func capRegistriesFromAddrBook(addrBook deployment.AddressBook, chain deployment
return getContractsFromAddrBook[capReg.CapabilitiesRegistry](
addrBook,
chain,
keystone.CapabilitiesRegistry,
internal.CapabilitiesRegistry,
capReg.NewCapabilitiesRegistry,
)
}
Expand All @@ -66,7 +67,7 @@ func ocr3FromAddrBook(addrBook deployment.AddressBook, chain deployment.Chain) (
return getContractsFromAddrBook[ocr3Capability.OCR3Capability](
addrBook,
chain,
keystone.OCR3Capability,
internal.OCR3Capability,
ocr3Capability.NewOCR3Capability,
)
}
Expand All @@ -76,7 +77,7 @@ func forwardersFromAddrBook(addrBook deployment.AddressBook, chain deployment.Ch
return getContractsFromAddrBook[keystoneForwarder.KeystoneForwarder](
addrBook,
chain,
keystone.KeystoneForwarder,
internal.KeystoneForwarder,
keystoneForwarder.NewKeystoneForwarder,
)
}
Expand All @@ -86,7 +87,7 @@ func feedsConsumersFromAddrBook(addrBook deployment.AddressBook, chain deploymen
return getContractsFromAddrBook[feeds_consumer.KeystoneFeedsConsumer](
addrBook,
chain,
keystone.FeedConsumer,
internal.FeedConsumer,
feeds_consumer.NewKeystoneFeedsConsumer,
)
}
Expand All @@ -96,7 +97,7 @@ func proposersFromAddrBook(addrBook deployment.AddressBook, chain deployment.Cha
return getContractsFromAddrBook[ccipowner.ManyChainMultiSig](
addrBook,
chain,
keystone.ProposerManyChainMultiSig,
internal.ProposerManyChainMultiSig,
ccipowner.NewManyChainMultiSig,
)
}
Expand All @@ -106,7 +107,7 @@ func timelocksFromAddrBook(addrBook deployment.AddressBook, chain deployment.Cha
return getContractsFromAddrBook[ccipowner.RBACTimelock](
addrBook,
chain,
keystone.RBACTimelock,
internal.RBACTimelock,
ccipowner.NewRBACTimelock,
)
}
3 changes: 1 addition & 2 deletions deployment/keystone/changeset/append_node_capabilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/smartcontractkit/ccip-owner-contracts/pkg/proposal/timelock"
"github.com/smartcontractkit/chainlink/deployment"
"github.com/smartcontractkit/chainlink/deployment/common/proposalutils"
kslib "github.com/smartcontractkit/chainlink/deployment/keystone"
"github.com/smartcontractkit/chainlink/deployment/keystone/changeset/internal"
)

Expand Down Expand Up @@ -63,7 +62,7 @@ func (req *AppendNodeCapabilitiesRequest) convert(e deployment.Environment) (*in
if !ok {
return nil, fmt.Errorf("registry chain selector %d does not exist in environment", req.RegistryChainSel)
}
resp, err := kslib.GetContractSets(e.Logger, &kslib.GetContractSetsRequest{
resp, err := internal.GetContractSets(e.Logger, &internal.GetContractSetsRequest{
Chains: map[uint64]deployment.Chain{req.RegistryChainSel: registryChain},
AddressBook: e.ExistingAddresses,
})
Expand Down
95 changes: 95 additions & 0 deletions deployment/keystone/changeset/compatiblity.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
package changeset

import "github.com/smartcontractkit/chainlink/deployment/keystone/changeset/internal"

//TODO: KS-673 refactor internal package to reduce and remove the duplication

// OracleConfig is the configuration for an oracle
type OracleConfig = internal.OracleConfig

// OCR3OnchainConfig is the onchain configuration of an OCR2 contract
type OCR3OnchainConfig = internal.OCR2OracleConfig

// NodeKeys is a set of public keys for a node
type NodeKeys = internal.NodeKeys

// TopLevelConfigSource is the top level configuration source
type TopLevelConfigSource = internal.TopLevelConfigSource

// GenerateOCR3Config generates an OCR3 config
var GenerateOCR3Config = internal.GenerateOCR3Config

// FeedConsumer is a feed consumer contract type
var FeedConsumer = internal.FeedConsumer

// KeystoneForwarder is a keystone forwarder contract type
var KeystoneForwarder = internal.KeystoneForwarder

// GetContractSetsRequest is a request to get contract sets
type GetContractSetsRequest = internal.GetContractSetsRequest

// GetContractSetsResponse is a response to get contract sets
type GetContractSetsResponse = internal.GetContractSetsResponse

// GetContractSets gets contract sets
var GetContractSets = internal.GetContractSets

// RegisterCapabilitiesRequest is a request to register capabilities
type RegisterCapabilitiesRequest = internal.RegisterCapabilitiesRequest

// RegisterCapabilitiesResponse is a response to register capabilities
type RegisterCapabilitiesResponse = internal.RegisterCapabilitiesResponse

// RegisterCapabilities registers capabilities
var RegisterCapabilities = internal.RegisterCapabilities

// RegisterNOPSRequest is a request to register NOPS
type RegisterNOPSRequest = internal.RegisterNOPSRequest

// RegisterNOPSResponse is a response to register NOPS
type RegisterNOPSResponse = internal.RegisterNOPSResponse

// RegisterNOPS registers NOPS
var RegisterNOPS = internal.RegisterNOPS

// RegisterNodesRequest is a request to register nodes with the capabilities registry
type RegisterNodesRequest = internal.RegisterNodesRequest

// RegisterNodesResponse is a response to register nodes with the capabilities registry
type RegisterNodesResponse = internal.RegisterNodesResponse

// RegisterNodes registers nodes with the capabilities registry
var RegisterNodes = internal.RegisterNodes

// RegisteredCapability is a wrapper of a capability and its ID
type RegisteredCapability = internal.RegisteredCapability

// FromCapabilitiesRegistryCapability converts a capabilities registry capability to a registered capability
var FromCapabilitiesRegistryCapability = internal.FromCapabilitiesRegistryCapability

// RegisterDonsRequest is a request to register Dons with the capabilities registry
type RegisterDonsRequest = internal.RegisterDonsRequest

// RegisterDonsResponse is a response to register Dons with the capabilities registry
type RegisterDonsResponse = internal.RegisterDonsResponse

// RegisterDons registers Dons with the capabilities registry
var RegisterDons = internal.RegisterDons

// DONToRegister is the minimal information needed to register a DON with the capabilities registry
type DONToRegister = internal.DONToRegister

// ConfigureContractsRequest is a request to configure ALL the contracts
type ConfigureContractsRequest = internal.ConfigureContractsRequest

// ConfigureContractsResponse is a response to configure ALL the contracts
type ConfigureContractsResponse = internal.ConfigureContractsResponse

// DonCapabilities is a set of capabilities hosted by a set of node operators
// in is in a convenient form to handle the CLO representation of the nop data
type DonCapabilities = internal.DonCapabilities

type DeployRequest = internal.DeployRequest
type DeployResponse = internal.DeployResponse

type ContractSet = internal.ContractSet
2 changes: 1 addition & 1 deletion deployment/keystone/changeset/configure_contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/smartcontractkit/chainlink-common/pkg/logger"

"github.com/smartcontractkit/chainlink/deployment"
kslib "github.com/smartcontractkit/chainlink/deployment/keystone"
kslib "github.com/smartcontractkit/chainlink/deployment/keystone/changeset/internal"
)

var _ deployment.ChangeSet[InitialContractsCfg] = ConfigureInitialContractsChangeset
Expand Down
2 changes: 1 addition & 1 deletion deployment/keystone/changeset/deploy_consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"

"github.com/smartcontractkit/chainlink/deployment"
kslib "github.com/smartcontractkit/chainlink/deployment/keystone"
kslib "github.com/smartcontractkit/chainlink/deployment/keystone/changeset/internal"
)

type DeployFeedsConsumerRequest struct {
Expand Down
32 changes: 23 additions & 9 deletions deployment/keystone/changeset/deploy_forwarder.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,40 @@ package changeset

import (
"fmt"
"maps"
"slices"

"github.com/ethereum/go-ethereum/common"
"github.com/smartcontractkit/ccip-owner-contracts/pkg/gethwrappers"
"github.com/smartcontractkit/ccip-owner-contracts/pkg/proposal/timelock"
"github.com/smartcontractkit/chainlink/deployment"
"github.com/smartcontractkit/chainlink/deployment/common/proposalutils"
kslib "github.com/smartcontractkit/chainlink/deployment/keystone"
"github.com/smartcontractkit/chainlink/deployment/keystone/changeset/internal"
)

var _ deployment.ChangeSet[uint64] = DeployForwarder
var _ deployment.ChangeSet[DeployForwarderRequest] = DeployForwarder

type DeployForwarderRequest struct {
ChainSelectors []uint64 // filter to only deploy to these chains; if empty, deploy to all chains
}

// DeployForwarder deploys the KeystoneForwarder contract to all chains in the environment
// callers must merge the output addressbook with the existing one
// TODO: add selectors to deploy only to specific chains
func DeployForwarder(env deployment.Environment, _ uint64) (deployment.ChangesetOutput, error) {
func DeployForwarder(env deployment.Environment, cfg DeployForwarderRequest) (deployment.ChangesetOutput, error) {
lggr := env.Logger
ab := deployment.NewMemoryAddressBook()
for _, chain := range env.Chains {
selectors := cfg.ChainSelectors
if len(selectors) == 0 {
selectors = slices.Collect(maps.Keys(env.Chains))
}
for _, sel := range selectors {
chain, ok := env.Chains[sel]
if !ok {
return deployment.ChangesetOutput{}, fmt.Errorf("chain with selector %d not found", sel)
}
lggr.Infow("deploying forwarder", "chainSelector", chain.Selector)
forwarderResp, err := kslib.DeployForwarder(chain, ab)
forwarderResp, err := internal.DeployForwarder(chain, ab)
if err != nil {
return deployment.ChangesetOutput{}, fmt.Errorf("failed to deploy KeystoneForwarder to chain selector %d: %w", chain.Selector, err)
}
Expand Down Expand Up @@ -55,23 +69,23 @@ func (r ConfigureForwardContractsRequest) UseMCMS() bool {
}

func ConfigureForwardContracts(env deployment.Environment, req ConfigureForwardContractsRequest) (deployment.ChangesetOutput, error) {
wfDon, err := kslib.NewRegisteredDon(env, kslib.RegisteredDonConfig{
wfDon, err := internal.NewRegisteredDon(env, internal.RegisteredDonConfig{
NodeIDs: req.WFNodeIDs,
Name: req.WFDonName,
RegistryChainSel: req.RegistryChainSel,
})
if err != nil {
return deployment.ChangesetOutput{}, fmt.Errorf("failed to create registered don: %w", err)
}
r, err := kslib.ConfigureForwardContracts(&env, kslib.ConfigureForwarderContractsRequest{
Dons: []kslib.RegisteredDon{*wfDon},
r, err := internal.ConfigureForwardContracts(&env, internal.ConfigureForwarderContractsRequest{
Dons: []internal.RegisteredDon{*wfDon},
UseMCMS: req.UseMCMS(),
})
if err != nil {
return deployment.ChangesetOutput{}, fmt.Errorf("failed to configure forward contracts: %w", err)
}

cresp, err := kslib.GetContractSets(env.Logger, &kslib.GetContractSetsRequest{
cresp, err := internal.GetContractSets(env.Logger, &internal.GetContractSetsRequest{
Chains: env.Chains,
AddressBook: env.ExistingAddresses,
})
Expand Down
2 changes: 1 addition & 1 deletion deployment/keystone/changeset/deploy_forwarder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestDeployForwarder(t *testing.T) {

// deploy forwarder
env.ExistingAddresses = ab
resp, err := changeset.DeployForwarder(env, registrySel)
resp, err := changeset.DeployForwarder(env, changeset.DeployForwarderRequest{})
require.NoError(t, err)
require.NotNil(t, resp)
// registry, ocr3, forwarder should be deployed on registry chain
Expand Down
Loading
Loading