From 325c42cc975cfe0ed359e1a7b8bc87fffa7911b6 Mon Sep 17 00:00:00 2001 From: vyzaldysanchez Date: Thu, 9 Jan 2025 11:17:21 -0400 Subject: [PATCH 01/23] Refactors `DefaultCapConfig` into multiple funcs --- .../keystone/changeset/internal/deploy.go | 136 ++++++++++++------ .../keystone/changeset/internal/update_don.go | 21 ++- 2 files changed, 102 insertions(+), 55 deletions(-) diff --git a/deployment/keystone/changeset/internal/deploy.go b/deployment/keystone/changeset/internal/deploy.go index acaabd22131..6609555e281 100644 --- a/deployment/keystone/changeset/internal/deploy.go +++ b/deployment/keystone/changeset/internal/deploy.go @@ -19,6 +19,7 @@ import ( "github.com/smartcontractkit/ccip-owner-contracts/pkg/proposal/mcms" "github.com/smartcontractkit/ccip-owner-contracts/pkg/proposal/timelock" + "github.com/smartcontractkit/chainlink/deployment" "google.golang.org/protobuf/proto" @@ -424,7 +425,36 @@ type RegisterCapabilitiesResponse struct { type RegisteredCapability struct { capabilities_registry.CapabilitiesRegistryCapability - ID [32]byte + ID [32]byte + config RegisteredCapabilityConfig +} + +type RegisteredCapabilityConfig struct { + DefaultConfig map[string]any + RemoteConfig RegisteredCapabilityRemoteConfig +} + +type RegisteredCapabilityRemoteConfig struct { + TargetConfig *RegisteredCapabilityRemoteTargetConfig + TriggerConfig *RegisteredCapabilityRemoteTriggerConfig + ExecutableConfig *RegisteredCapabilityRemoteExecutableConfig +} + +type RegisteredCapabilityRemoteTriggerConfig struct { + RegistrationRefresh time.Duration + RegistrationExpiry time.Duration + MinResponsesToAggregate uint32 + MessageExpiry time.Duration + MaxBatchSize uint32 + BatchCollectionPeriod time.Duration +} + +type RegisteredCapabilityRemoteTargetConfig struct { + RequestHashExcludedAttributes []string +} + +type RegisteredCapabilityRemoteExecutableConfig struct { + RequestHashExcludedAttributes []string } func FromCapabilitiesRegistryCapability(cap *capabilities_registry.CapabilitiesRegistryCapability, e deployment.Environment, registryChainSelector uint64) (*RegisteredCapability, error) { @@ -575,39 +605,46 @@ func RegisterNOPS(ctx context.Context, lggr logger.Logger, req RegisterNOPSReque return resp, nil } -func DefaultCapConfig(capType uint8, nNodes int) *capabilitiespb.CapabilityConfig { - switch capType { - // TODO: use the enum defined in ?? - case uint8(0): // trigger - return &capabilitiespb.CapabilityConfig{ - DefaultConfig: values.Proto(values.EmptyMap()).GetMapValue(), - RemoteConfig: &capabilitiespb.CapabilityConfig_RemoteTriggerConfig{ - RemoteTriggerConfig: &capabilitiespb.RemoteTriggerConfig{ - RegistrationRefresh: durationpb.New(20 * time.Second), - RegistrationExpiry: durationpb.New(60 * time.Second), - // F + 1; assuming n = 3f+1 - MinResponsesToAggregate: uint32(nNodes/3) + 1, - }, - }, - } - case uint8(2): // consensus - return &capabilitiespb.CapabilityConfig{ - DefaultConfig: values.Proto(values.EmptyMap()).GetMapValue(), - } - case uint8(3): // target - return &capabilitiespb.CapabilityConfig{ - DefaultConfig: values.Proto(values.EmptyMap()).GetMapValue(), - RemoteConfig: &capabilitiespb.CapabilityConfig_RemoteTargetConfig{ - RemoteTargetConfig: &capabilitiespb.RemoteTargetConfig{ - RequestHashExcludedAttributes: []string{"signed_report.Signatures"}, // TODO: const defn in a common place - }, +func GetTriggerCapConfig(refresh time.Duration, expiry time.Duration, minResponsesToAggregate uint32, defaultCfg map[string]any) (*capabilitiespb.CapabilityConfig, error) { + dCfg, err := values.WrapMap(defaultCfg) + if err != nil { + return nil, err + } + return &capabilitiespb.CapabilityConfig{ + DefaultConfig: values.Proto(dCfg).GetMapValue(), + RemoteConfig: &capabilitiespb.CapabilityConfig_RemoteTriggerConfig{ + RemoteTriggerConfig: &capabilitiespb.RemoteTriggerConfig{ + RegistrationRefresh: durationpb.New(refresh), + RegistrationExpiry: durationpb.New(expiry), + MinResponsesToAggregate: minResponsesToAggregate, }, - } - default: - return &capabilitiespb.CapabilityConfig{ - DefaultConfig: values.Proto(values.EmptyMap()).GetMapValue(), - } + }, + }, nil +} + +func GetConsensusCapConfig(defaultCfg map[string]any) (*capabilitiespb.CapabilityConfig, error) { + dCfg, err := values.WrapMap(defaultCfg) + if err != nil { + return nil, err + } + return &capabilitiespb.CapabilityConfig{ + DefaultConfig: values.Proto(dCfg).GetMapValue(), + }, nil +} + +func GetTargetCapConfig(defaultCfg map[string]any) (*capabilitiespb.CapabilityConfig, error) { + dCfg, err := values.WrapMap(defaultCfg) + if err != nil { + return nil, err } + return &capabilitiespb.CapabilityConfig{ + DefaultConfig: values.Proto(dCfg).GetMapValue(), + RemoteConfig: &capabilitiespb.CapabilityConfig_RemoteTargetConfig{ + RemoteTargetConfig: &capabilitiespb.RemoteTargetConfig{ + RequestHashExcludedAttributes: []string{"signed_report.Signatures"}, // TODO: const defn in a common place + }, + }, + }, nil } // register nodes @@ -836,24 +873,39 @@ func RegisterDons(lggr logger.Logger, req RegisterDonsRequest) (*RegisterDonsRes continue } - caps, ok := req.DonToCapabilities[don.Name] + regCaps, ok := req.DonToCapabilities[don.Name] if !ok { return nil, fmt.Errorf("capabilities not found for DON %s", don.Name) } wfSupported := false var cfgs []capabilities_registry.CapabilitiesRegistryCapabilityConfiguration - for _, cap := range caps { - if cap.CapabilityType == 2 { // OCR3 capability => WF supported - wfSupported = true + for _, regCap := range regCaps { + var capErr error + var capCfg *capabilitiespb.CapabilityConfig + switch regCap.CapabilityType { + case uint8(0): // trigger + cfg := regCap.config.RemoteConfig.TriggerConfig + if cfg == nil { + return nil, fmt.Errorf("no trigger config found for %v", regCap) + } + capCfg, capErr = GetTriggerCapConfig(cfg.RegistrationRefresh, cfg.RegistrationExpiry, cfg.MinResponsesToAggregate, regCap.config.DefaultConfig) + case uint8(2): // consensus + wfSupported = true // OCR3 capability => WF supported + capCfg, capErr = GetConsensusCapConfig(regCap.config.DefaultConfig) + case uint8(3): // target + capCfg, capErr = GetTargetCapConfig(regCap.config.DefaultConfig) + default: + return nil, fmt.Errorf("unsupported capability type %d for %v", regCap.CapabilityType, regCap) } - // TODO: accept configuration from external source for each (don,capability) - capCfg := DefaultCapConfig(cap.CapabilityType, len(p2pIds)) - cfgb, err := proto.Marshal(capCfg) - if err != nil { - return nil, fmt.Errorf("failed to marshal capability config for %v: %w", cap, err) + if capErr != nil { + return nil, fmt.Errorf("failed to get capability config for %v: %w", regCap, capErr) + } + cfgb, capErr := proto.Marshal(capCfg) + if capErr != nil { + return nil, fmt.Errorf("failed to marshal capability config for %v: %w", regCap, capErr) } cfgs = append(cfgs, capabilities_registry.CapabilitiesRegistryCapabilityConfiguration{ - CapabilityId: cap.ID, + CapabilityId: regCap.ID, Config: cfgb, }) } diff --git a/deployment/keystone/changeset/internal/update_don.go b/deployment/keystone/changeset/internal/update_don.go index 3cfc386b2ba..8479bafc601 100644 --- a/deployment/keystone/changeset/internal/update_don.go +++ b/deployment/keystone/changeset/internal/update_don.go @@ -13,9 +13,9 @@ import ( "github.com/smartcontractkit/ccip-owner-contracts/pkg/proposal/mcms" "github.com/smartcontractkit/ccip-owner-contracts/pkg/proposal/timelock" "github.com/smartcontractkit/chainlink-common/pkg/logger" + "github.com/smartcontractkit/chainlink/deployment" "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/p2pkey" - "google.golang.org/protobuf/proto" kcr "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/keystone/generated/capabilities_registry_1_1_0" ) @@ -69,7 +69,7 @@ type UpdateDonResponse struct { Ops *timelock.BatchChainOperation } -func UpdateDon(lggr logger.Logger, req *UpdateDonRequest) (*UpdateDonResponse, error) { +func UpdateDon(_ logger.Logger, req *UpdateDonRequest) (*UpdateDonResponse, error) { if err := req.Validate(); err != nil { return nil, fmt.Errorf("failed to validate request: %w", err) } @@ -84,7 +84,7 @@ func UpdateDon(lggr logger.Logger, req *UpdateDonRequest) (*UpdateDonResponse, e if err != nil { return nil, fmt.Errorf("failed to lookup don by p2pIDs: %w", err) } - cfgs, err := computeConfigs(registry, req.CapabilityConfigs, don) + cfgs, err := computeConfigs(registry, req.CapabilityConfigs) if err != nil { return nil, fmt.Errorf("failed to compute configs: %w", err) } @@ -138,22 +138,17 @@ func BytesToPeerIDs(p2pIDs [][32]byte) []p2pkey.PeerID { return out } -func computeConfigs(registry *kcr.CapabilitiesRegistry, caps []CapabilityConfig, donInfo kcr.CapabilitiesRegistryDONInfo) ([]kcr.CapabilitiesRegistryCapabilityConfiguration, error) { - out := make([]kcr.CapabilitiesRegistryCapabilityConfiguration, len(caps)) - for i, cap := range caps { +func computeConfigs(registry *kcr.CapabilitiesRegistry, capCfgs []CapabilityConfig) ([]kcr.CapabilitiesRegistryCapabilityConfiguration, error) { + out := make([]kcr.CapabilitiesRegistryCapabilityConfiguration, len(capCfgs)) + for i, capCfg := range capCfgs { out[i] = kcr.CapabilitiesRegistryCapabilityConfiguration{} - id, err := registry.GetHashedCapabilityId(&bind.CallOpts{}, cap.Capability.LabelledName, cap.Capability.Version) + id, err := registry.GetHashedCapabilityId(&bind.CallOpts{}, capCfg.Capability.LabelledName, capCfg.Capability.Version) if err != nil { return nil, fmt.Errorf("failed to get capability id: %w", err) } out[i].CapabilityId = id if out[i].Config == nil { - c := DefaultCapConfig(cap.Capability.CapabilityType, int(donInfo.F)) - cb, err := proto.Marshal(c) - if err != nil { - return nil, fmt.Errorf("failed to marshal capability config for %v: %w", c, err) - } - out[i].Config = cb + return nil, fmt.Errorf("config is required for capability %s", capCfg.Capability.LabelledName) } } return out, nil From 6bf725d5455ee25c105b1bb6240dbd964adbdc78 Mon Sep 17 00:00:00 2001 From: vyzaldysanchez Date: Thu, 9 Jan 2025 11:25:09 -0400 Subject: [PATCH 02/23] Fixes lint --- deployment/keystone/changeset/internal/update_don.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deployment/keystone/changeset/internal/update_don.go b/deployment/keystone/changeset/internal/update_don.go index 8479bafc601..a96c9658aa5 100644 --- a/deployment/keystone/changeset/internal/update_don.go +++ b/deployment/keystone/changeset/internal/update_don.go @@ -10,14 +10,14 @@ import ( "sort" "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/smartcontractkit/ccip-owner-contracts/pkg/proposal/mcms" "github.com/smartcontractkit/ccip-owner-contracts/pkg/proposal/timelock" "github.com/smartcontractkit/chainlink-common/pkg/logger" "github.com/smartcontractkit/chainlink/deployment" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/p2pkey" - kcr "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/keystone/generated/capabilities_registry_1_1_0" + "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/p2pkey" ) // CapabilityConfig is a struct that holds a capability and its configuration From eecfd333a18920d378a2ffc891b3d2ca59072550 Mon Sep 17 00:00:00 2001 From: vyzaldysanchez Date: Thu, 9 Jan 2025 11:37:57 -0400 Subject: [PATCH 03/23] Expects a `config` on `FromCapabilitiesRegistryCapability` calls --- deployment/keystone/changeset/internal/deploy.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/deployment/keystone/changeset/internal/deploy.go b/deployment/keystone/changeset/internal/deploy.go index 05b6cacb9c7..f7215f79a52 100644 --- a/deployment/keystone/changeset/internal/deploy.go +++ b/deployment/keystone/changeset/internal/deploy.go @@ -425,7 +425,7 @@ type RegisterCapabilitiesResponse struct { type RegisteredCapability struct { capabilities_registry.CapabilitiesRegistryCapability ID [32]byte - config RegisteredCapabilityConfig + Config RegisteredCapabilityConfig } type RegisteredCapabilityConfig struct { @@ -456,7 +456,7 @@ type RegisteredCapabilityRemoteExecutableConfig struct { RequestHashExcludedAttributes []string } -func FromCapabilitiesRegistryCapability(cap *capabilities_registry.CapabilitiesRegistryCapability, e deployment.Environment, registryChainSelector uint64) (*RegisteredCapability, error) { +func FromCapabilitiesRegistryCapability(cap *capabilities_registry.CapabilitiesRegistryCapability, e deployment.Environment, registryChainSelector uint64, cfg RegisteredCapabilityConfig) (*RegisteredCapability, error) { registry, _, err := GetRegistryContract(&e, registryChainSelector) if err != nil { return nil, fmt.Errorf("failed to get registry: %w", err) @@ -468,6 +468,7 @@ func FromCapabilitiesRegistryCapability(cap *capabilities_registry.CapabilitiesR return &RegisteredCapability{ CapabilitiesRegistryCapability: *cap, ID: id, + Config: cfg, }, nil } @@ -883,16 +884,16 @@ func RegisterDons(lggr logger.Logger, req RegisterDonsRequest) (*RegisterDonsRes var capCfg *capabilitiespb.CapabilityConfig switch regCap.CapabilityType { case uint8(0): // trigger - cfg := regCap.config.RemoteConfig.TriggerConfig + cfg := regCap.Config.RemoteConfig.TriggerConfig if cfg == nil { return nil, fmt.Errorf("no trigger config found for %v", regCap) } - capCfg, capErr = GetTriggerCapConfig(cfg.RegistrationRefresh, cfg.RegistrationExpiry, cfg.MinResponsesToAggregate, regCap.config.DefaultConfig) + capCfg, capErr = GetTriggerCapConfig(cfg.RegistrationRefresh, cfg.RegistrationExpiry, cfg.MinResponsesToAggregate, regCap.Config.DefaultConfig) case uint8(2): // consensus wfSupported = true // OCR3 capability => WF supported - capCfg, capErr = GetConsensusCapConfig(regCap.config.DefaultConfig) + capCfg, capErr = GetConsensusCapConfig(regCap.Config.DefaultConfig) case uint8(3): // target - capCfg, capErr = GetTargetCapConfig(regCap.config.DefaultConfig) + capCfg, capErr = GetTargetCapConfig(regCap.Config.DefaultConfig) default: return nil, fmt.Errorf("unsupported capability type %d for %v", regCap.CapabilityType, regCap) } From 56b82c73366346c4c39297ee0bcc4c561999b643 Mon Sep 17 00:00:00 2001 From: vyzaldysanchez Date: Thu, 9 Jan 2025 11:43:38 -0400 Subject: [PATCH 04/23] Exposes `RegisteredCapabilityConfig` to consumers --- deployment/keystone/changeset/compatiblity.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/deployment/keystone/changeset/compatiblity.go b/deployment/keystone/changeset/compatiblity.go index 7f80b6ab53d..48cdfc80f12 100644 --- a/deployment/keystone/changeset/compatiblity.go +++ b/deployment/keystone/changeset/compatiblity.go @@ -64,6 +64,9 @@ var RegisterNodes = internal.RegisterNodes // RegisteredCapability is a wrapper of a capability and its ID type RegisteredCapability = internal.RegisteredCapability +// RegisteredCapabilityConfig is the configuration of a RegisteredCapability +type RegisteredCapabilityConfig = internal.RegisteredCapabilityConfig + // FromCapabilitiesRegistryCapability converts a capabilities registry capability to a registered capability var FromCapabilitiesRegistryCapability = internal.FromCapabilitiesRegistryCapability From 1a39088239e6aa94c9d3bcc1500eeff8bffeb8e7 Mon Sep 17 00:00:00 2001 From: vyzaldysanchez Date: Thu, 9 Jan 2025 11:44:38 -0400 Subject: [PATCH 05/23] Fixes lint --- deployment/keystone/changeset/internal/deploy.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/deployment/keystone/changeset/internal/deploy.go b/deployment/keystone/changeset/internal/deploy.go index f7215f79a52..5d6eea0cc45 100644 --- a/deployment/keystone/changeset/internal/deploy.go +++ b/deployment/keystone/changeset/internal/deploy.go @@ -456,17 +456,17 @@ type RegisteredCapabilityRemoteExecutableConfig struct { RequestHashExcludedAttributes []string } -func FromCapabilitiesRegistryCapability(cap *capabilities_registry.CapabilitiesRegistryCapability, e deployment.Environment, registryChainSelector uint64, cfg RegisteredCapabilityConfig) (*RegisteredCapability, error) { +func FromCapabilitiesRegistryCapability(capReg *capabilities_registry.CapabilitiesRegistryCapability, e deployment.Environment, registryChainSelector uint64, cfg RegisteredCapabilityConfig) (*RegisteredCapability, error) { registry, _, err := GetRegistryContract(&e, registryChainSelector) if err != nil { return nil, fmt.Errorf("failed to get registry: %w", err) } - id, err := registry.GetHashedCapabilityId(&bind.CallOpts{}, cap.LabelledName, cap.Version) + id, err := registry.GetHashedCapabilityId(&bind.CallOpts{}, capReg.LabelledName, capReg.Version) if err != nil { - return nil, fmt.Errorf("failed to call GetHashedCapabilityId for capability %v: %w", cap, err) + return nil, fmt.Errorf("failed to call GetHashedCapabilityId for capability %v: %w", capReg, err) } return &RegisteredCapability{ - CapabilitiesRegistryCapability: *cap, + CapabilitiesRegistryCapability: *capReg, ID: id, Config: cfg, }, nil From 940ec375a15b29ef1e877008c9e84c56f3f5d32b Mon Sep 17 00:00:00 2001 From: vyzaldysanchez Date: Thu, 9 Jan 2025 12:04:59 -0400 Subject: [PATCH 06/23] Exposes more needed types --- deployment/keystone/changeset/compatiblity.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/deployment/keystone/changeset/compatiblity.go b/deployment/keystone/changeset/compatiblity.go index 48cdfc80f12..aa82100aba7 100644 --- a/deployment/keystone/changeset/compatiblity.go +++ b/deployment/keystone/changeset/compatiblity.go @@ -67,6 +67,18 @@ type RegisteredCapability = internal.RegisteredCapability // RegisteredCapabilityConfig is the configuration of a RegisteredCapability type RegisteredCapabilityConfig = internal.RegisteredCapabilityConfig +// RegisteredCapabilityRemoteConfig is the remote configuration of a RegisteredCapability +type RegisteredCapabilityRemoteConfig = internal.RegisteredCapabilityRemoteConfig + +// RegisteredCapabilityRemoteTargetConfig is the configuration of target capabilities +type RegisteredCapabilityRemoteTargetConfig = internal.RegisteredCapabilityRemoteTargetConfig + +// RegisteredCapabilityRemoteTriggerConfig is the configuration of trigger capabilities +type RegisteredCapabilityRemoteTriggerConfig = internal.RegisteredCapabilityRemoteTriggerConfig + +// RegisteredCapabilityRemoteExecutableConfig is the configuration of executable capabilities +type RegisteredCapabilityRemoteExecutableConfig = internal.RegisteredCapabilityRemoteExecutableConfig + // FromCapabilitiesRegistryCapability converts a capabilities registry capability to a registered capability var FromCapabilitiesRegistryCapability = internal.FromCapabilitiesRegistryCapability From 9333162b8c55c3d5bf7b253b7567ba74a125f7bd Mon Sep 17 00:00:00 2001 From: vyzaldysanchez Date: Fri, 10 Jan 2025 13:59:03 -0400 Subject: [PATCH 07/23] Expects bytes config as part of the `RegisteredCapability` struct --- deployment/keystone/changeset/compatiblity.go | 15 ------ .../keystone/changeset/internal/deploy.go | 53 ++----------------- 2 files changed, 5 insertions(+), 63 deletions(-) diff --git a/deployment/keystone/changeset/compatiblity.go b/deployment/keystone/changeset/compatiblity.go index aa82100aba7..7f80b6ab53d 100644 --- a/deployment/keystone/changeset/compatiblity.go +++ b/deployment/keystone/changeset/compatiblity.go @@ -64,21 +64,6 @@ var RegisterNodes = internal.RegisterNodes // RegisteredCapability is a wrapper of a capability and its ID type RegisteredCapability = internal.RegisteredCapability -// RegisteredCapabilityConfig is the configuration of a RegisteredCapability -type RegisteredCapabilityConfig = internal.RegisteredCapabilityConfig - -// RegisteredCapabilityRemoteConfig is the remote configuration of a RegisteredCapability -type RegisteredCapabilityRemoteConfig = internal.RegisteredCapabilityRemoteConfig - -// RegisteredCapabilityRemoteTargetConfig is the configuration of target capabilities -type RegisteredCapabilityRemoteTargetConfig = internal.RegisteredCapabilityRemoteTargetConfig - -// RegisteredCapabilityRemoteTriggerConfig is the configuration of trigger capabilities -type RegisteredCapabilityRemoteTriggerConfig = internal.RegisteredCapabilityRemoteTriggerConfig - -// RegisteredCapabilityRemoteExecutableConfig is the configuration of executable capabilities -type RegisteredCapabilityRemoteExecutableConfig = internal.RegisteredCapabilityRemoteExecutableConfig - // FromCapabilitiesRegistryCapability converts a capabilities registry capability to a registered capability var FromCapabilitiesRegistryCapability = internal.FromCapabilitiesRegistryCapability diff --git a/deployment/keystone/changeset/internal/deploy.go b/deployment/keystone/changeset/internal/deploy.go index 5d6eea0cc45..af1c7d72975 100644 --- a/deployment/keystone/changeset/internal/deploy.go +++ b/deployment/keystone/changeset/internal/deploy.go @@ -425,38 +425,10 @@ type RegisterCapabilitiesResponse struct { type RegisteredCapability struct { capabilities_registry.CapabilitiesRegistryCapability ID [32]byte - Config RegisteredCapabilityConfig + Config []byte } -type RegisteredCapabilityConfig struct { - DefaultConfig map[string]any - RemoteConfig RegisteredCapabilityRemoteConfig -} - -type RegisteredCapabilityRemoteConfig struct { - TargetConfig *RegisteredCapabilityRemoteTargetConfig - TriggerConfig *RegisteredCapabilityRemoteTriggerConfig - ExecutableConfig *RegisteredCapabilityRemoteExecutableConfig -} - -type RegisteredCapabilityRemoteTriggerConfig struct { - RegistrationRefresh time.Duration - RegistrationExpiry time.Duration - MinResponsesToAggregate uint32 - MessageExpiry time.Duration - MaxBatchSize uint32 - BatchCollectionPeriod time.Duration -} - -type RegisteredCapabilityRemoteTargetConfig struct { - RequestHashExcludedAttributes []string -} - -type RegisteredCapabilityRemoteExecutableConfig struct { - RequestHashExcludedAttributes []string -} - -func FromCapabilitiesRegistryCapability(capReg *capabilities_registry.CapabilitiesRegistryCapability, e deployment.Environment, registryChainSelector uint64, cfg RegisteredCapabilityConfig) (*RegisteredCapability, error) { +func FromCapabilitiesRegistryCapability(capReg *capabilities_registry.CapabilitiesRegistryCapability, e deployment.Environment, registryChainSelector uint64, cfg []byte) (*RegisteredCapability, error) { registry, _, err := GetRegistryContract(&e, registryChainSelector) if err != nil { return nil, fmt.Errorf("failed to get registry: %w", err) @@ -880,26 +852,11 @@ func RegisterDons(lggr logger.Logger, req RegisterDonsRequest) (*RegisterDonsRes wfSupported := false var cfgs []capabilities_registry.CapabilitiesRegistryCapabilityConfiguration for _, regCap := range regCaps { + if regCap.CapabilityType == 2 { // OCR3 capability => WF supported + wfSupported = true + } var capErr error var capCfg *capabilitiespb.CapabilityConfig - switch regCap.CapabilityType { - case uint8(0): // trigger - cfg := regCap.Config.RemoteConfig.TriggerConfig - if cfg == nil { - return nil, fmt.Errorf("no trigger config found for %v", regCap) - } - capCfg, capErr = GetTriggerCapConfig(cfg.RegistrationRefresh, cfg.RegistrationExpiry, cfg.MinResponsesToAggregate, regCap.Config.DefaultConfig) - case uint8(2): // consensus - wfSupported = true // OCR3 capability => WF supported - capCfg, capErr = GetConsensusCapConfig(regCap.Config.DefaultConfig) - case uint8(3): // target - capCfg, capErr = GetTargetCapConfig(regCap.Config.DefaultConfig) - default: - return nil, fmt.Errorf("unsupported capability type %d for %v", regCap.CapabilityType, regCap) - } - if capErr != nil { - return nil, fmt.Errorf("failed to get capability config for %v: %w", regCap, capErr) - } cfgb, capErr := proto.Marshal(capCfg) if capErr != nil { return nil, fmt.Errorf("failed to marshal capability config for %v: %w", regCap, capErr) From 1961f959322ec1fb55c0cb6733394c8ff8672246 Mon Sep 17 00:00:00 2001 From: vyzaldysanchez Date: Fri, 10 Jan 2025 14:01:51 -0400 Subject: [PATCH 08/23] Uses bytes cap config on `RegisterDons()` calls --- .../keystone/changeset/internal/deploy.go | 57 +------------------ 1 file changed, 3 insertions(+), 54 deletions(-) diff --git a/deployment/keystone/changeset/internal/deploy.go b/deployment/keystone/changeset/internal/deploy.go index af1c7d72975..27e4d3c93be 100644 --- a/deployment/keystone/changeset/internal/deploy.go +++ b/deployment/keystone/changeset/internal/deploy.go @@ -22,14 +22,8 @@ import ( "github.com/smartcontractkit/chainlink/deployment" - "google.golang.org/protobuf/proto" - "google.golang.org/protobuf/types/known/durationpb" - chainsel "github.com/smartcontractkit/chain-selectors" - capabilitiespb "github.com/smartcontractkit/chainlink-common/pkg/capabilities/pb" - "github.com/smartcontractkit/chainlink-common/pkg/values" - capabilities_registry "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/keystone/generated/capabilities_registry_1_1_0" kf "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/keystone/generated/forwarder_1_0_0" @@ -577,48 +571,6 @@ func RegisterNOPS(ctx context.Context, lggr logger.Logger, req RegisterNOPSReque return resp, nil } -func GetTriggerCapConfig(refresh time.Duration, expiry time.Duration, minResponsesToAggregate uint32, defaultCfg map[string]any) (*capabilitiespb.CapabilityConfig, error) { - dCfg, err := values.WrapMap(defaultCfg) - if err != nil { - return nil, err - } - return &capabilitiespb.CapabilityConfig{ - DefaultConfig: values.Proto(dCfg).GetMapValue(), - RemoteConfig: &capabilitiespb.CapabilityConfig_RemoteTriggerConfig{ - RemoteTriggerConfig: &capabilitiespb.RemoteTriggerConfig{ - RegistrationRefresh: durationpb.New(refresh), - RegistrationExpiry: durationpb.New(expiry), - MinResponsesToAggregate: minResponsesToAggregate, - }, - }, - }, nil -} - -func GetConsensusCapConfig(defaultCfg map[string]any) (*capabilitiespb.CapabilityConfig, error) { - dCfg, err := values.WrapMap(defaultCfg) - if err != nil { - return nil, err - } - return &capabilitiespb.CapabilityConfig{ - DefaultConfig: values.Proto(dCfg).GetMapValue(), - }, nil -} - -func GetTargetCapConfig(defaultCfg map[string]any) (*capabilitiespb.CapabilityConfig, error) { - dCfg, err := values.WrapMap(defaultCfg) - if err != nil { - return nil, err - } - return &capabilitiespb.CapabilityConfig{ - DefaultConfig: values.Proto(dCfg).GetMapValue(), - RemoteConfig: &capabilitiespb.CapabilityConfig_RemoteTargetConfig{ - RemoteTargetConfig: &capabilitiespb.RemoteTargetConfig{ - RequestHashExcludedAttributes: []string{"signed_report.Signatures"}, // TODO: const defn in a common place - }, - }, - }, nil -} - // register nodes type RegisterNodesRequest struct { Env *deployment.Environment @@ -855,15 +807,12 @@ func RegisterDons(lggr logger.Logger, req RegisterDonsRequest) (*RegisterDonsRes if regCap.CapabilityType == 2 { // OCR3 capability => WF supported wfSupported = true } - var capErr error - var capCfg *capabilitiespb.CapabilityConfig - cfgb, capErr := proto.Marshal(capCfg) - if capErr != nil { - return nil, fmt.Errorf("failed to marshal capability config for %v: %w", regCap, capErr) + if regCap.Config == nil { + return nil, fmt.Errorf("config not found for capability %v", regCap) } cfgs = append(cfgs, capabilities_registry.CapabilitiesRegistryCapabilityConfiguration{ CapabilityId: regCap.ID, - Config: cfgb, + Config: regCap.Config, }) } From c97ed1ec6ca18ae0da7b158a4fd408bbfd2c0537 Mon Sep 17 00:00:00 2001 From: vyzaldysanchez Date: Fri, 10 Jan 2025 15:12:40 -0400 Subject: [PATCH 09/23] Fixes test --- .../keystone/changeset/internal/deploy.go | 42 ++++++++++++++++--- .../keystone/changeset/internal/test/utils.go | 26 +++++++----- .../keystone/changeset/internal/types.go | 17 ++++++-- .../keystone/changeset/internal/update_don.go | 1 + .../changeset/internal/update_nodes_test.go | 20 ++++++++- deployment/keystone/changeset/test/helpers.go | 23 +++++++--- .../keystone/changeset/update_don_test.go | 11 ++++- 7 files changed, 111 insertions(+), 29 deletions(-) diff --git a/deployment/keystone/changeset/internal/deploy.go b/deployment/keystone/changeset/internal/deploy.go index 27e4d3c93be..cc5c963c514 100644 --- a/deployment/keystone/changeset/internal/deploy.go +++ b/deployment/keystone/changeset/internal/deploy.go @@ -15,7 +15,11 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" + capabilitiespb "github.com/smartcontractkit/chainlink-common/pkg/capabilities/pb" + "github.com/smartcontractkit/chainlink-common/pkg/values" "golang.org/x/exp/maps" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/types/known/durationpb" "github.com/smartcontractkit/ccip-owner-contracts/pkg/proposal/mcms" "github.com/smartcontractkit/ccip-owner-contracts/pkg/proposal/timelock" @@ -136,7 +140,7 @@ type DonInfo struct { Name string F uint8 Nodes []deployment.Node - Capabilities []capabilities_registry.CapabilitiesRegistryCapability // every capability is hosted on each node + Capabilities []DONCapabilityWithConfig // every capability is hosted on each node } func DonInfos(dons []DonCapabilities, jd deployment.OffchainClient) ([]DonInfo, error) { @@ -409,7 +413,7 @@ func ConfigureOCR3ContractFromJD(env *deployment.Environment, cfg ConfigureOCR3C type RegisterCapabilitiesRequest struct { Env *deployment.Environment RegistryChainSelector uint64 - DonToCapabilities map[string][]capabilities_registry.CapabilitiesRegistryCapability + DonToCapabilities map[string][]DONCapabilityWithConfig } type RegisterCapabilitiesResponse struct { @@ -461,18 +465,19 @@ func RegisterCapabilities(lggr logger.Logger, req RegisterCapabilitiesRequest) ( for don, caps := range req.DonToCapabilities { var registerCaps []RegisteredCapability for _, cap := range caps { - id, ok := uniqueCaps[cap] + id, ok := uniqueCaps[cap.Capability] if !ok { var err error - id, err = registry.GetHashedCapabilityId(&bind.CallOpts{}, cap.LabelledName, cap.Version) + id, err = registry.GetHashedCapabilityId(&bind.CallOpts{}, cap.Capability.LabelledName, cap.Capability.Version) if err != nil { return nil, fmt.Errorf("failed to call GetHashedCapabilityId for capability %v: %w", cap, err) } - uniqueCaps[cap] = id + uniqueCaps[cap.Capability] = id } registerCap := RegisteredCapability{ - CapabilitiesRegistryCapability: cap, ID: id, + Config: cap.Config, + CapabilitiesRegistryCapability: cap.Capability, } lggr.Debugw("hashed capability id", "capability", cap, "id", id) registerCaps = append(registerCaps, registerCap) @@ -928,3 +933,28 @@ func configureForwarder(lggr logger.Logger, chain deployment.Chain, contractSet } return opMap, nil } + +func GetDefaultCapConfig(capability capabilities_registry.CapabilitiesRegistryCapability) ([]byte, error) { + defaultCfg := &capabilitiespb.CapabilityConfig{ + DefaultConfig: values.Proto(values.EmptyMap()).GetMapValue(), + } + switch capability.CapabilityType { + case uint8(0): // trigger + defaultCfg.RemoteConfig = &capabilitiespb.CapabilityConfig_RemoteTriggerConfig{ + RemoteTriggerConfig: &capabilitiespb.RemoteTriggerConfig{ + RegistrationRefresh: durationpb.New(20 * time.Second), + RegistrationExpiry: durationpb.New(60 * time.Second), + MinResponsesToAggregate: uint32(10), + }, + } + case uint8(3): // target + defaultCfg.RemoteConfig = &capabilitiespb.CapabilityConfig_RemoteTargetConfig{ + RemoteTargetConfig: &capabilitiespb.RemoteTargetConfig{ + RequestHashExcludedAttributes: []string{"signed_report.Signatures"}, + }, + } + case uint8(2): // consensus + default: + } + return proto.Marshal(defaultCfg) +} diff --git a/deployment/keystone/changeset/internal/test/utils.go b/deployment/keystone/changeset/internal/test/utils.go index cc7e3b27160..0075000adc6 100644 --- a/deployment/keystone/changeset/internal/test/utils.go +++ b/deployment/keystone/changeset/internal/test/utils.go @@ -7,16 +7,14 @@ import ( "testing" "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/stretchr/testify/require" - "google.golang.org/protobuf/proto" - capabilitiespb "github.com/smartcontractkit/chainlink-common/pkg/capabilities/pb" "github.com/smartcontractkit/chainlink-common/pkg/logger" "github.com/smartcontractkit/chainlink-common/pkg/values" + "github.com/stretchr/testify/require" + "google.golang.org/protobuf/proto" "github.com/smartcontractkit/chainlink/deployment" "github.com/smartcontractkit/chainlink/deployment/environment/memory" - "github.com/smartcontractkit/chainlink/deployment/keystone/changeset/internal" capabilities_registry "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/keystone/generated/capabilities_registry_1_1_0" "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/p2pkey" @@ -211,25 +209,28 @@ func (cc *CapabilityCache) Get(cap capabilities_registry.CapabilitiesRegistryCap // AddCapabilities adds the capabilities to the registry and returns the registered capabilities // if the capability is already registered, it will not be re-registered // if duplicate capabilities are passed, they will be deduped -func (cc *CapabilityCache) AddCapabilities(lggr logger.Logger, chain deployment.Chain, registry *capabilities_registry.CapabilitiesRegistry, capabilities []capabilities_registry.CapabilitiesRegistryCapability) []internal.RegisteredCapability { +func (cc *CapabilityCache) AddCapabilities(_ logger.Logger, chain deployment.Chain, registry *capabilities_registry.CapabilitiesRegistry, capabilities []capabilities_registry.CapabilitiesRegistryCapability) []internal.RegisteredCapability { t := cc.t var out []internal.RegisteredCapability // get the registered capabilities & dedup seen := make(map[capabilities_registry.CapabilitiesRegistryCapability]struct{}) var toRegister []capabilities_registry.CapabilitiesRegistryCapability - for _, cap := range capabilities { - id, cached := cc.nameToId[internal.CapabilityID(cap)] + for _, c := range capabilities { + id, cached := cc.nameToId[internal.CapabilityID(c)] if cached { + cfgB, err := internal.GetDefaultCapConfig(c) + require.NoError(t, err) out = append(out, internal.RegisteredCapability{ - CapabilitiesRegistryCapability: cap, + CapabilitiesRegistryCapability: c, ID: id, + Config: cfgB, }) continue } // dedup - if _, exists := seen[cap]; !exists { - seen[cap] = struct{}{} - toRegister = append(toRegister, cap) + if _, exists := seen[c]; !exists { + seen[c] = struct{}{} + toRegister = append(toRegister, c) } } if len(toRegister) == 0 { @@ -248,9 +249,12 @@ func (cc *CapabilityCache) AddCapabilities(lggr logger.Logger, chain deployment. capb := capb id, err := registry.GetHashedCapabilityId(&bind.CallOpts{}, capb.LabelledName, capb.Version) require.NoError(t, err) + cfgB, err := internal.GetDefaultCapConfig(capb) + require.NoError(t, err) out = append(out, internal.RegisteredCapability{ CapabilitiesRegistryCapability: capb, ID: id, + Config: cfgB, }) // cache the id cc.nameToId[internal.CapabilityID(capb)] = id diff --git a/deployment/keystone/changeset/internal/types.go b/deployment/keystone/changeset/internal/types.go index cffd69f85e6..6e08023e1da 100644 --- a/deployment/keystone/changeset/internal/types.go +++ b/deployment/keystone/changeset/internal/types.go @@ -131,7 +131,12 @@ type DonCapabilities struct { Name string F uint8 Nops []NOP - Capabilities []kcr.CapabilitiesRegistryCapability // every capability is hosted on each nop + Capabilities []DONCapabilityWithConfig // every capability is hosted on each nop +} + +type DONCapabilityWithConfig struct { + Capability kcr.CapabilitiesRegistryCapability + Config []byte } func (v DonCapabilities) Validate() error { @@ -195,10 +200,14 @@ func nopsToNodes(donInfos []DonInfo, dons []DonCapabilities, chainSelector uint6 } // mapDonsToCaps converts a list of DonCapabilities to a map of don name to capabilities -func mapDonsToCaps(dons []DonInfo) map[string][]kcr.CapabilitiesRegistryCapability { - out := make(map[string][]kcr.CapabilitiesRegistryCapability) +func mapDonsToCaps(dons []DonInfo) map[string][]DONCapabilityWithConfig { + out := make(map[string][]DONCapabilityWithConfig) for _, don := range dons { - out[don.Name] = don.Capabilities + var donCaps []DONCapabilityWithConfig + for _, donCap := range don.Capabilities { + donCaps = append(donCaps, donCap) + } + out[don.Name] = donCaps } return out } diff --git a/deployment/keystone/changeset/internal/update_don.go b/deployment/keystone/changeset/internal/update_don.go index 08e09f4999f..b5006358f77 100644 --- a/deployment/keystone/changeset/internal/update_don.go +++ b/deployment/keystone/changeset/internal/update_don.go @@ -148,6 +148,7 @@ func computeConfigs(registry *kcr.CapabilitiesRegistry, capCfgs []CapabilityConf return nil, fmt.Errorf("failed to get capability id: %w", err) } out[i].CapabilityId = id + out[i].Config = capCfg.Config if out[i].Config == nil { return nil, fmt.Errorf("config is required for capability %s", capCfg.Capability.LabelledName) } diff --git a/deployment/keystone/changeset/internal/update_nodes_test.go b/deployment/keystone/changeset/internal/update_nodes_test.go index 1b532129e48..19cc78463b1 100644 --- a/deployment/keystone/changeset/internal/update_nodes_test.go +++ b/deployment/keystone/changeset/internal/update_nodes_test.go @@ -7,11 +7,16 @@ import ( "fmt" "sort" "testing" + "time" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" + capabilitiespb "github.com/smartcontractkit/chainlink-common/pkg/capabilities/pb" + "github.com/smartcontractkit/chainlink-common/pkg/values" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/types/known/durationpb" "github.com/smartcontractkit/chainlink-common/pkg/logger" @@ -448,6 +453,19 @@ func TestUpdateNodes(t *testing.T) { Version: "1.0.0", CapabilityType: 0, } + phonyCapCfg := &capabilitiespb.CapabilityConfig{ + DefaultConfig: values.Proto(values.EmptyMap()).GetMapValue(), + RemoteConfig: &capabilitiespb.CapabilityConfig_RemoteTriggerConfig{ + RemoteTriggerConfig: &capabilitiespb.RemoteTriggerConfig{ + RegistrationRefresh: durationpb.New(20 * time.Second), + RegistrationExpiry: durationpb.New(60 * time.Second), + // F + 1; assuming n = 3f+1 + MinResponsesToAggregate: uint32(10), + }, + }, + } + phonyCapCfgBytes, err := proto.Marshal(phonyCapCfg) + require.NoError(t, err) initMap := make(map[p2pkey.PeerID][]kcr.CapabilitiesRegistryCapability) for p2pID := range tt.args.req.P2pToUpdates { initMap[p2pID] = []kcr.CapabilitiesRegistryCapability{phonyCap} @@ -472,7 +490,7 @@ func TestUpdateNodes(t *testing.T) { expectedUpdatedCaps[p2p] = expectedCaps } else { expectedUpdatedCaps[p2p] = []internal.RegisteredCapability{ - {CapabilitiesRegistryCapability: phonyCap, ID: id}, + {CapabilitiesRegistryCapability: phonyCap, ID: id, Config: phonyCapCfgBytes}, } } } diff --git a/deployment/keystone/changeset/test/helpers.go b/deployment/keystone/changeset/test/helpers.go index 5ddaeda524e..212cf90ccaf 100644 --- a/deployment/keystone/changeset/test/helpers.go +++ b/deployment/keystone/changeset/test/helpers.go @@ -150,6 +150,13 @@ func SetupTestEnv(t *testing.T, c TestConfig) TestEnv { assetNodes := memory.NewNodes(t, zapcore.InfoLevel, assetChains, c.AssetDonConfig.N, 0, crConfig) require.Len(t, assetNodes, c.AssetDonConfig.N) + ocr3CapCfg, err := internal.GetDefaultCapConfig(internal.OCR3Cap) + require.NoError(t, err) + writerChainCapCfg, err := internal.GetDefaultCapConfig(internal.WriteChainCap) + require.NoError(t, err) + streamTriggerChainCapCfg, err := internal.GetDefaultCapConfig(internal.StreamTriggerCap) + require.NoError(t, err) + // TODO: partition nodes into multiple nops wfDon := internal.DonCapabilities{ @@ -160,7 +167,9 @@ func SetupTestEnv(t *testing.T, c TestConfig) TestEnv { Nodes: maps.Keys(wfNodes), }, }, - Capabilities: []kcr.CapabilitiesRegistryCapability{internal.OCR3Cap}, + Capabilities: []internal.DONCapabilityWithConfig{ + {Capability: internal.OCR3Cap, Config: ocr3CapCfg}, + }, } cwDon := internal.DonCapabilities{ Name: internal.TargetDonName, @@ -170,7 +179,9 @@ func SetupTestEnv(t *testing.T, c TestConfig) TestEnv { Nodes: maps.Keys(cwNodes), }, }, - Capabilities: []kcr.CapabilitiesRegistryCapability{internal.WriteChainCap}, + Capabilities: []internal.DONCapabilityWithConfig{ + {Capability: internal.WriteChainCap, Config: writerChainCapCfg}, + }, } assetDon := internal.DonCapabilities{ Name: internal.StreamDonName, @@ -180,7 +191,9 @@ func SetupTestEnv(t *testing.T, c TestConfig) TestEnv { Nodes: maps.Keys(assetNodes), }, }, - Capabilities: []kcr.CapabilitiesRegistryCapability{internal.StreamTriggerCap}, + Capabilities: []internal.DONCapabilityWithConfig{ + {Capability: internal.StreamTriggerCap, Config: streamTriggerChainCapCfg}, + }, } allChains := make(map[uint64]deployment.Chain) @@ -372,8 +385,8 @@ func p2pIDs(t *testing.T, vals []string) [][32]byte { func expectedHashedCapabilities(t *testing.T, registry *kcr.CapabilitiesRegistry, don internal.DonCapabilities) [][32]byte { out := make([][32]byte, len(don.Capabilities)) var err error - for i, cap := range don.Capabilities { - out[i], err = registry.GetHashedCapabilityId(nil, cap.LabelledName, cap.Version) + for i, capWithCfg := range don.Capabilities { + out[i], err = registry.GetHashedCapabilityId(nil, capWithCfg.Capability.LabelledName, capWithCfg.Capability.Version) require.NoError(t, err) } return out diff --git a/deployment/keystone/changeset/update_don_test.go b/deployment/keystone/changeset/update_don_test.go index 74e2609b0a1..0c985420619 100644 --- a/deployment/keystone/changeset/update_don_test.go +++ b/deployment/keystone/changeset/update_don_test.go @@ -29,6 +29,11 @@ func TestUpdateDon(t *testing.T) { } caps = []kcr.CapabilitiesRegistryCapability{capA, capB} ) + capACfg, err := internal.GetDefaultCapConfig(capA) + require.NoError(t, err) + capBCfg, err := internal.GetDefaultCapConfig(capB) + require.NoError(t, err) + t.Run("no mcms", func(t *testing.T) { te := test.SetupTestEnv(t, test.TestConfig{ WFDonConfig: test.DonConfig{N: 4}, @@ -54,10 +59,10 @@ func TestUpdateDon(t *testing.T) { P2PIDs: p2pIDs, CapabilityConfigs: []changeset.CapabilityConfig{ { - Capability: capA, + Capability: capA, Config: capACfg, }, { - Capability: capB, + Capability: capB, Config: capBCfg, }, }, } @@ -94,9 +99,11 @@ func TestUpdateDon(t *testing.T) { CapabilityConfigs: []changeset.CapabilityConfig{ { Capability: capA, + Config: capACfg, }, { Capability: capB, + Config: capBCfg, }, }, MCMSConfig: &changeset.MCMSConfig{MinDuration: 0}, From e406844bada4dab50e109ca0748d257db0631ccc Mon Sep 17 00:00:00 2001 From: vyzaldysanchez Date: Fri, 10 Jan 2025 16:54:30 -0400 Subject: [PATCH 10/23] Fixes CI --- .../changeset/internal/update_don_test.go | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/deployment/keystone/changeset/internal/update_don_test.go b/deployment/keystone/changeset/internal/update_don_test.go index bf9ab96fecb..819c1e36d53 100644 --- a/deployment/keystone/changeset/internal/update_don_test.go +++ b/deployment/keystone/changeset/internal/update_don_test.go @@ -15,6 +15,7 @@ import ( "github.com/stretchr/testify/require" "github.com/smartcontractkit/chainlink-common/pkg/logger" + "github.com/smartcontractkit/chainlink/deployment" kscs "github.com/smartcontractkit/chainlink/deployment/keystone/changeset" "github.com/smartcontractkit/chainlink/deployment/keystone/changeset/internal" @@ -95,6 +96,11 @@ func TestUpdateDon(t *testing.T) { } ) + initialCapCfg, err := internal.GetDefaultCapConfig(initialCap) + require.NoError(t, err) + capToAddCfg, err := internal.GetDefaultCapConfig(capToAdd) + require.NoError(t, err) + lggr := logger.Test(t) t.Run("empty", func(t *testing.T) { @@ -103,7 +109,7 @@ func TestUpdateDon(t *testing.T) { { Name: "don 1", Nodes: []deployment.Node{node_1, node_2, node_3, node_4}, - Capabilities: []kcr.CapabilitiesRegistryCapability{initialCap}, + Capabilities: []internal.DONCapabilityWithConfig{{Capability: initialCap, Config: initialCapCfg}}, }, }, nops: []internal.NOP{ @@ -133,7 +139,7 @@ func TestUpdateDon(t *testing.T) { Chain: testCfg.Chain, P2PIDs: []p2pkey.PeerID{p2p_1.PeerID(), p2p_2.PeerID(), p2p_3.PeerID(), p2p_4.PeerID()}, CapabilityConfigs: []internal.CapabilityConfig{ - {Capability: initialCap}, {Capability: capToAdd}, + {Capability: initialCap, Config: initialCapCfg}, {Capability: capToAdd, Config: capToAddCfg}, }, } want := &internal.UpdateDonResponse{ @@ -142,8 +148,8 @@ func TestUpdateDon(t *testing.T) { ConfigCount: 1, NodeP2PIds: internal.PeerIDsToBytes([]p2pkey.PeerID{p2p_1.PeerID(), p2p_2.PeerID(), p2p_3.PeerID(), p2p_4.PeerID()}), CapabilityConfigurations: []kcr.CapabilitiesRegistryCapabilityConfiguration{ - {CapabilityId: kstest.MustCapabilityId(t, testCfg.Registry, initialCap)}, - {CapabilityId: kstest.MustCapabilityId(t, testCfg.Registry, capToAdd)}, + {CapabilityId: kstest.MustCapabilityId(t, testCfg.Registry, initialCap), Config: initialCapCfg}, + {CapabilityId: kstest.MustCapabilityId(t, testCfg.Registry, capToAdd), Config: capToAddCfg}, }, }, } @@ -286,7 +292,7 @@ func makeP2PToCapabilities(t *testing.T, dons []internal.DonInfo) map[p2pkey.Pee for _, cap := range don.Capabilities { p, err := kscs.NewP2PSignerEnc(&node, registryChain.Selector) require.NoError(t, err, "failed to make p2p signer enc from clo nod %s", node.NodeID) - p2pToCapabilities[p.P2PKey] = append(p2pToCapabilities[p.P2PKey], cap) + p2pToCapabilities[p.P2PKey] = append(p2pToCapabilities[p.P2PKey], cap.Capability) } } } @@ -314,7 +320,7 @@ func testDon(t *testing.T, don internal.DonInfo) kstest.Don { var capabilityConfigs []internal.CapabilityConfig for _, cap := range don.Capabilities { capabilityConfigs = append(capabilityConfigs, internal.CapabilityConfig{ - Capability: cap, + Capability: cap.Capability, Config: cap.Config, }) } return kstest.Don{ From c74668e07dec95ff7c989c7cd0565c8e09dc425f Mon Sep 17 00:00:00 2001 From: vyzaldysanchez Date: Fri, 10 Jan 2025 17:03:07 -0400 Subject: [PATCH 11/23] Fixes CI --- deployment/keystone/changeset/internal/types.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/deployment/keystone/changeset/internal/types.go b/deployment/keystone/changeset/internal/types.go index 6e08023e1da..b4f5b55e547 100644 --- a/deployment/keystone/changeset/internal/types.go +++ b/deployment/keystone/changeset/internal/types.go @@ -203,11 +203,7 @@ func nopsToNodes(donInfos []DonInfo, dons []DonCapabilities, chainSelector uint6 func mapDonsToCaps(dons []DonInfo) map[string][]DONCapabilityWithConfig { out := make(map[string][]DONCapabilityWithConfig) for _, don := range dons { - var donCaps []DONCapabilityWithConfig - for _, donCap := range don.Capabilities { - donCaps = append(donCaps, donCap) - } - out[don.Name] = donCaps + out[don.Name] = don.Capabilities } return out } From 66ec8912e3342e04f897782f217b7a9f10d7deb8 Mon Sep 17 00:00:00 2001 From: vyzaldysanchez Date: Fri, 10 Jan 2025 17:09:32 -0400 Subject: [PATCH 12/23] Takes proto object instead of bytes on `FromCapabilitiesRegistryCapability` --- deployment/keystone/changeset/internal/deploy.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/deployment/keystone/changeset/internal/deploy.go b/deployment/keystone/changeset/internal/deploy.go index cc5c963c514..af5579615d2 100644 --- a/deployment/keystone/changeset/internal/deploy.go +++ b/deployment/keystone/changeset/internal/deploy.go @@ -426,7 +426,7 @@ type RegisteredCapability struct { Config []byte } -func FromCapabilitiesRegistryCapability(capReg *capabilities_registry.CapabilitiesRegistryCapability, e deployment.Environment, registryChainSelector uint64, cfg []byte) (*RegisteredCapability, error) { +func FromCapabilitiesRegistryCapability(capReg *capabilities_registry.CapabilitiesRegistryCapability, cfg *capabilitiespb.CapabilityConfig, e deployment.Environment, registryChainSelector uint64) (*RegisteredCapability, error) { registry, _, err := GetRegistryContract(&e, registryChainSelector) if err != nil { return nil, fmt.Errorf("failed to get registry: %w", err) @@ -435,10 +435,17 @@ func FromCapabilitiesRegistryCapability(capReg *capabilities_registry.Capabiliti if err != nil { return nil, fmt.Errorf("failed to call GetHashedCapabilityId for capability %v: %w", capReg, err) } + if cfg == nil { + return nil, fmt.Errorf("config is required for capability %v", capReg) + } + cfgB, err := proto.Marshal(cfg) + if err != nil { + return nil, fmt.Errorf("failed to marshal config for capability %v: %w", capReg, err) + } return &RegisteredCapability{ CapabilitiesRegistryCapability: *capReg, ID: id, - Config: cfg, + Config: cfgB, }, nil } From 64e92221d9c0adb23ea24c8f371d48ad1c1cbe0f Mon Sep 17 00:00:00 2001 From: vyzaldysanchez Date: Fri, 10 Jan 2025 17:15:19 -0400 Subject: [PATCH 13/23] Exposes `DONCapabilityWithConfig` --- deployment/keystone/changeset/compatiblity.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/deployment/keystone/changeset/compatiblity.go b/deployment/keystone/changeset/compatiblity.go index 7f80b6ab53d..67b799a02ce 100644 --- a/deployment/keystone/changeset/compatiblity.go +++ b/deployment/keystone/changeset/compatiblity.go @@ -89,6 +89,8 @@ type ConfigureContractsResponse = internal.ConfigureContractsResponse // in is in a convenient form to handle the CLO representation of the nop data type DonCapabilities = internal.DonCapabilities +type DONCapabilityWithConfig = internal.DONCapabilityWithConfig + type DeployRequest = internal.DeployRequest type DeployResponse = internal.DeployResponse From c33ab50ac8c0ac8a37c5a56c61bef11b09227ec2 Mon Sep 17 00:00:00 2001 From: vyzaldysanchez Date: Mon, 13 Jan 2025 14:04:50 -0400 Subject: [PATCH 14/23] Fixes lint --- deployment/keystone/changeset/internal/deploy.go | 11 ++++------- deployment/keystone/changeset/internal/test/utils.go | 5 +++-- .../keystone/changeset/internal/update_nodes_test.go | 7 +++---- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/deployment/keystone/changeset/internal/deploy.go b/deployment/keystone/changeset/internal/deploy.go index af5579615d2..2a345dcd098 100644 --- a/deployment/keystone/changeset/internal/deploy.go +++ b/deployment/keystone/changeset/internal/deploy.go @@ -15,23 +15,20 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" - capabilitiespb "github.com/smartcontractkit/chainlink-common/pkg/capabilities/pb" - "github.com/smartcontractkit/chainlink-common/pkg/values" "golang.org/x/exp/maps" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/known/durationpb" "github.com/smartcontractkit/ccip-owner-contracts/pkg/proposal/mcms" "github.com/smartcontractkit/ccip-owner-contracts/pkg/proposal/timelock" - - "github.com/smartcontractkit/chainlink/deployment" - chainsel "github.com/smartcontractkit/chain-selectors" + capabilitiespb "github.com/smartcontractkit/chainlink-common/pkg/capabilities/pb" + "github.com/smartcontractkit/chainlink-common/pkg/logger" + "github.com/smartcontractkit/chainlink-common/pkg/values" + "github.com/smartcontractkit/chainlink/deployment" capabilities_registry "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/keystone/generated/capabilities_registry_1_1_0" kf "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/keystone/generated/forwarder_1_0_0" - - "github.com/smartcontractkit/chainlink-common/pkg/logger" ) type ConfigureContractsRequest struct { diff --git a/deployment/keystone/changeset/internal/test/utils.go b/deployment/keystone/changeset/internal/test/utils.go index 0075000adc6..b5d1a6c0c6b 100644 --- a/deployment/keystone/changeset/internal/test/utils.go +++ b/deployment/keystone/changeset/internal/test/utils.go @@ -7,11 +7,12 @@ import ( "testing" "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/stretchr/testify/require" + "google.golang.org/protobuf/proto" + capabilitiespb "github.com/smartcontractkit/chainlink-common/pkg/capabilities/pb" "github.com/smartcontractkit/chainlink-common/pkg/logger" "github.com/smartcontractkit/chainlink-common/pkg/values" - "github.com/stretchr/testify/require" - "google.golang.org/protobuf/proto" "github.com/smartcontractkit/chainlink/deployment" "github.com/smartcontractkit/chainlink/deployment/environment/memory" diff --git a/deployment/keystone/changeset/internal/update_nodes_test.go b/deployment/keystone/changeset/internal/update_nodes_test.go index 19cc78463b1..68c14499b75 100644 --- a/deployment/keystone/changeset/internal/update_nodes_test.go +++ b/deployment/keystone/changeset/internal/update_nodes_test.go @@ -11,20 +11,19 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" - capabilitiespb "github.com/smartcontractkit/chainlink-common/pkg/capabilities/pb" - "github.com/smartcontractkit/chainlink-common/pkg/values" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/known/durationpb" + capabilitiespb "github.com/smartcontractkit/chainlink-common/pkg/capabilities/pb" "github.com/smartcontractkit/chainlink-common/pkg/logger" + "github.com/smartcontractkit/chainlink-common/pkg/values" "github.com/smartcontractkit/chainlink/deployment" + "github.com/smartcontractkit/chainlink/deployment/environment/memory" "github.com/smartcontractkit/chainlink/deployment/keystone/changeset/internal" kstest "github.com/smartcontractkit/chainlink/deployment/keystone/changeset/internal/test" - - "github.com/smartcontractkit/chainlink/deployment/environment/memory" kcr "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/keystone/generated/capabilities_registry_1_1_0" "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/p2pkey" ) From efed67887c0554d2b2854d6677b8b509aca9d7d8 Mon Sep 17 00:00:00 2001 From: vyzaldysanchez Date: Mon, 13 Jan 2025 15:11:31 -0400 Subject: [PATCH 15/23] Fixes lint --- deployment/keystone/changeset/internal/deploy.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deployment/keystone/changeset/internal/deploy.go b/deployment/keystone/changeset/internal/deploy.go index 07d4e9b6e41..cd0b22569c1 100644 --- a/deployment/keystone/changeset/internal/deploy.go +++ b/deployment/keystone/changeset/internal/deploy.go @@ -412,7 +412,7 @@ type RegisterCapabilitiesRequest struct { RegistryChainSelector uint64 DonToCapabilities map[string][]DONCapabilityWithConfig - // if UseMCMS is true, a batch proposal is returned and no transaction is confirmed on chain. + // if UseMCMS is true, a batch proposal is returned and no transaction is confirmed on chain. UseMCMS bool } @@ -886,7 +886,7 @@ func RegisterDons(lggr logger.Logger, req RegisterDonsRequest) (*RegisterDonsRes } lggr.Debugw("registering DON", "don", don.Name, "p2p sorted hash", p2pSortedHash) - regCaps, ok := req.DonToCapabilities[don.Name] + regCaps, ok := req.DonToCapabilities[don.Name] if !ok { return nil, fmt.Errorf("capabilities not found for DON %s", don.Name) } From 73c2aff304135b3f13d99f34d71d3de12f53f82a Mon Sep 17 00:00:00 2001 From: vyzaldysanchez Date: Mon, 13 Jan 2025 16:31:34 -0400 Subject: [PATCH 16/23] gomods tidy --- deployment/go.mod | 2 +- integration-tests/go.mod | 2 +- integration-tests/load/go.mod | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/deployment/go.mod b/deployment/go.mod index 111539fc2b5..063633decfb 100644 --- a/deployment/go.mod +++ b/deployment/go.mod @@ -9,7 +9,7 @@ replace github.com/smartcontractkit/chainlink/v2 => ../ // Using a separate inline `require` here to avoid surrounding line changes // creating potential merge conflicts. -require github.com/smartcontractkit/chainlink/v2 v2.0.0-20241212011003-de1a8f5e5b42 +require github.com/smartcontractkit/chainlink/v2 v2.0.0-20250113180450-c33ab50ac8c0 require ( github.com/Khan/genqlient v0.7.0 diff --git a/integration-tests/go.mod b/integration-tests/go.mod index 88eeb3e7fe6..e2b76c33881 100644 --- a/integration-tests/go.mod +++ b/integration-tests/go.mod @@ -13,7 +13,7 @@ replace github.com/smartcontractkit/chainlink/deployment => ../deployment // creating potential merge conflicts. require ( github.com/smartcontractkit/chainlink/deployment v0.0.0-20241212011003-de1a8f5e5b42 - github.com/smartcontractkit/chainlink/v2 v2.0.0-20241212011003-de1a8f5e5b42 + github.com/smartcontractkit/chainlink/v2 v2.0.0-20250113180450-c33ab50ac8c0 ) require ( diff --git a/integration-tests/load/go.mod b/integration-tests/load/go.mod index f6da8952689..b315662a1f4 100644 --- a/integration-tests/load/go.mod +++ b/integration-tests/load/go.mod @@ -16,7 +16,7 @@ replace github.com/smartcontractkit/chainlink/integration-tests => ../ require ( github.com/smartcontractkit/chainlink/deployment v0.0.0-20241212011003-de1a8f5e5b42 github.com/smartcontractkit/chainlink/integration-tests v0.0.0-20241212011003-de1a8f5e5b42 - github.com/smartcontractkit/chainlink/v2 v2.0.0-20241212011003-de1a8f5e5b42 + github.com/smartcontractkit/chainlink/v2 v2.0.0-20250113180450-c33ab50ac8c0 ) require ( From 391ce07cdc33593a0ab02b9fb299598bfd03f49e Mon Sep 17 00:00:00 2001 From: vyzaldysanchez Date: Tue, 14 Jan 2025 13:02:54 -0400 Subject: [PATCH 17/23] Fixes CI --- integration-tests/go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-tests/go.mod b/integration-tests/go.mod index e2b76c33881..88eeb3e7fe6 100644 --- a/integration-tests/go.mod +++ b/integration-tests/go.mod @@ -13,7 +13,7 @@ replace github.com/smartcontractkit/chainlink/deployment => ../deployment // creating potential merge conflicts. require ( github.com/smartcontractkit/chainlink/deployment v0.0.0-20241212011003-de1a8f5e5b42 - github.com/smartcontractkit/chainlink/v2 v2.0.0-20250113180450-c33ab50ac8c0 + github.com/smartcontractkit/chainlink/v2 v2.0.0-20241212011003-de1a8f5e5b42 ) require ( From 67680f895501010eb69f1fec723a0c2bee9d8e39 Mon Sep 17 00:00:00 2001 From: vyzaldysanchez Date: Tue, 14 Jan 2025 13:03:28 -0400 Subject: [PATCH 18/23] Fixes CI --- integration-tests/load/go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-tests/load/go.mod b/integration-tests/load/go.mod index b315662a1f4..f6da8952689 100644 --- a/integration-tests/load/go.mod +++ b/integration-tests/load/go.mod @@ -16,7 +16,7 @@ replace github.com/smartcontractkit/chainlink/integration-tests => ../ require ( github.com/smartcontractkit/chainlink/deployment v0.0.0-20241212011003-de1a8f5e5b42 github.com/smartcontractkit/chainlink/integration-tests v0.0.0-20241212011003-de1a8f5e5b42 - github.com/smartcontractkit/chainlink/v2 v2.0.0-20250113180450-c33ab50ac8c0 + github.com/smartcontractkit/chainlink/v2 v2.0.0-20241212011003-de1a8f5e5b42 ) require ( From 2ff2c55217207217c9dbd828e452939071e90398 Mon Sep 17 00:00:00 2001 From: vyzaldysanchez Date: Tue, 14 Jan 2025 13:16:31 -0400 Subject: [PATCH 19/23] gomods tidy --- integration-tests/go.mod | 2 +- integration-tests/load/go.mod | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/integration-tests/go.mod b/integration-tests/go.mod index 88eeb3e7fe6..e2b76c33881 100644 --- a/integration-tests/go.mod +++ b/integration-tests/go.mod @@ -13,7 +13,7 @@ replace github.com/smartcontractkit/chainlink/deployment => ../deployment // creating potential merge conflicts. require ( github.com/smartcontractkit/chainlink/deployment v0.0.0-20241212011003-de1a8f5e5b42 - github.com/smartcontractkit/chainlink/v2 v2.0.0-20241212011003-de1a8f5e5b42 + github.com/smartcontractkit/chainlink/v2 v2.0.0-20250113180450-c33ab50ac8c0 ) require ( diff --git a/integration-tests/load/go.mod b/integration-tests/load/go.mod index f6da8952689..b315662a1f4 100644 --- a/integration-tests/load/go.mod +++ b/integration-tests/load/go.mod @@ -16,7 +16,7 @@ replace github.com/smartcontractkit/chainlink/integration-tests => ../ require ( github.com/smartcontractkit/chainlink/deployment v0.0.0-20241212011003-de1a8f5e5b42 github.com/smartcontractkit/chainlink/integration-tests v0.0.0-20241212011003-de1a8f5e5b42 - github.com/smartcontractkit/chainlink/v2 v2.0.0-20241212011003-de1a8f5e5b42 + github.com/smartcontractkit/chainlink/v2 v2.0.0-20250113180450-c33ab50ac8c0 ) require ( From 7d1fc24d87cbaad8e251981ac5d0d6eb1cde712d Mon Sep 17 00:00:00 2001 From: vyzaldysanchez Date: Mon, 20 Jan 2025 14:07:29 -0400 Subject: [PATCH 20/23] Updates typing --- .../keystone/changeset/internal/deploy.go | 23 ++++++++++--------- .../keystone/changeset/internal/test/utils.go | 8 ++----- .../keystone/changeset/internal/types.go | 3 ++- .../changeset/internal/update_don_test.go | 22 +++++++++++------- .../changeset/internal/update_nodes_test.go | 5 +--- deployment/keystone/changeset/test/helpers.go | 15 +++++------- .../keystone/changeset/update_don_test.go | 15 +++++++----- 7 files changed, 46 insertions(+), 45 deletions(-) diff --git a/deployment/keystone/changeset/internal/deploy.go b/deployment/keystone/changeset/internal/deploy.go index cd0b22569c1..6453523a2da 100644 --- a/deployment/keystone/changeset/internal/deploy.go +++ b/deployment/keystone/changeset/internal/deploy.go @@ -424,7 +424,7 @@ type RegisterCapabilitiesResponse struct { type RegisteredCapability struct { capabilities_registry.CapabilitiesRegistryCapability ID [32]byte - Config []byte + Config *capabilitiespb.CapabilityConfig } func FromCapabilitiesRegistryCapability(capReg *capabilities_registry.CapabilitiesRegistryCapability, cfg *capabilitiespb.CapabilityConfig, e deployment.Environment, registryChainSelector uint64) (*RegisteredCapability, error) { @@ -439,14 +439,10 @@ func FromCapabilitiesRegistryCapability(capReg *capabilities_registry.Capabiliti if cfg == nil { return nil, fmt.Errorf("config is required for capability %v", capReg) } - cfgB, err := proto.Marshal(cfg) - if err != nil { - return nil, fmt.Errorf("failed to marshal config for capability %v: %w", capReg, err) - } return &RegisteredCapability{ CapabilitiesRegistryCapability: *capReg, ID: id, - Config: cfgB, + Config: cfg, }, nil } @@ -472,7 +468,8 @@ func RegisterCapabilities(lggr logger.Logger, req RegisterCapabilitiesRequest) ( uniqueCaps := make(map[capabilities_registry.CapabilitiesRegistryCapability][32]byte) for don, caps := range req.DonToCapabilities { var registerCaps []RegisteredCapability - for _, cap := range caps { + for i := range caps { + cap := &caps[i] id, ok := uniqueCaps[cap.Capability] if !ok { var err error @@ -484,7 +481,7 @@ func RegisterCapabilities(lggr logger.Logger, req RegisterCapabilitiesRequest) ( } registerCap := RegisteredCapability{ ID: id, - Config: cap.Config, + Config: &cap.Config, CapabilitiesRegistryCapability: cap.Capability, } lggr.Debugw("hashed capability id", "capability", cap, "id", id) @@ -899,9 +896,13 @@ func RegisterDons(lggr logger.Logger, req RegisterDonsRequest) (*RegisterDonsRes if regCap.Config == nil { return nil, fmt.Errorf("config not found for capability %v", regCap) } + cfgB, capErr := proto.Marshal(regCap.Config) + if capErr != nil { + return nil, fmt.Errorf("failed to marshal config for capability %v: %w", regCap, capErr) + } cfgs = append(cfgs, capabilities_registry.CapabilitiesRegistryCapabilityConfiguration{ CapabilityId: regCap.ID, - Config: regCap.Config, + Config: cfgB, }) } @@ -1046,7 +1047,7 @@ func configureForwarder(lggr logger.Logger, chain deployment.Chain, contractSet return opMap, nil } -func GetDefaultCapConfig(capability capabilities_registry.CapabilitiesRegistryCapability) ([]byte, error) { +func GetDefaultCapConfig(capability capabilities_registry.CapabilitiesRegistryCapability) *capabilitiespb.CapabilityConfig { defaultCfg := &capabilitiespb.CapabilityConfig{ DefaultConfig: values.Proto(values.EmptyMap()).GetMapValue(), } @@ -1068,5 +1069,5 @@ func GetDefaultCapConfig(capability capabilities_registry.CapabilitiesRegistryCa case uint8(2): // consensus default: } - return proto.Marshal(defaultCfg) + return defaultCfg } diff --git a/deployment/keystone/changeset/internal/test/utils.go b/deployment/keystone/changeset/internal/test/utils.go index b5d1a6c0c6b..451f0d2fa55 100644 --- a/deployment/keystone/changeset/internal/test/utils.go +++ b/deployment/keystone/changeset/internal/test/utils.go @@ -219,12 +219,10 @@ func (cc *CapabilityCache) AddCapabilities(_ logger.Logger, chain deployment.Cha for _, c := range capabilities { id, cached := cc.nameToId[internal.CapabilityID(c)] if cached { - cfgB, err := internal.GetDefaultCapConfig(c) - require.NoError(t, err) out = append(out, internal.RegisteredCapability{ CapabilitiesRegistryCapability: c, ID: id, - Config: cfgB, + Config: internal.GetDefaultCapConfig(c), }) continue } @@ -250,12 +248,10 @@ func (cc *CapabilityCache) AddCapabilities(_ logger.Logger, chain deployment.Cha capb := capb id, err := registry.GetHashedCapabilityId(&bind.CallOpts{}, capb.LabelledName, capb.Version) require.NoError(t, err) - cfgB, err := internal.GetDefaultCapConfig(capb) - require.NoError(t, err) out = append(out, internal.RegisteredCapability{ CapabilitiesRegistryCapability: capb, ID: id, - Config: cfgB, + Config: internal.GetDefaultCapConfig(capb), }) // cache the id cc.nameToId[internal.CapabilityID(capb)] = id diff --git a/deployment/keystone/changeset/internal/types.go b/deployment/keystone/changeset/internal/types.go index b4f5b55e547..801b89955dd 100644 --- a/deployment/keystone/changeset/internal/types.go +++ b/deployment/keystone/changeset/internal/types.go @@ -10,6 +10,7 @@ import ( "strings" "github.com/ethereum/go-ethereum/common" + capabilitiespb "github.com/smartcontractkit/chainlink-common/pkg/capabilities/pb" chainsel "github.com/smartcontractkit/chain-selectors" @@ -136,7 +137,7 @@ type DonCapabilities struct { type DONCapabilityWithConfig struct { Capability kcr.CapabilitiesRegistryCapability - Config []byte + Config capabilitiespb.CapabilityConfig } func (v DonCapabilities) Validate() error { diff --git a/deployment/keystone/changeset/internal/update_don_test.go b/deployment/keystone/changeset/internal/update_don_test.go index 819c1e36d53..6e857d65d7e 100644 --- a/deployment/keystone/changeset/internal/update_don_test.go +++ b/deployment/keystone/changeset/internal/update_don_test.go @@ -13,6 +13,7 @@ import ( chainsel "github.com/smartcontractkit/chain-selectors" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "google.golang.org/protobuf/proto" "github.com/smartcontractkit/chainlink-common/pkg/logger" @@ -96,9 +97,11 @@ func TestUpdateDon(t *testing.T) { } ) - initialCapCfg, err := internal.GetDefaultCapConfig(initialCap) + initialCapCfg := internal.GetDefaultCapConfig(initialCap) + initialCapCfgB, err := proto.Marshal(initialCapCfg) require.NoError(t, err) - capToAddCfg, err := internal.GetDefaultCapConfig(capToAdd) + capToAddCfg := internal.GetDefaultCapConfig(capToAdd) + capToAddCfgB, err := proto.Marshal(capToAddCfg) require.NoError(t, err) lggr := logger.Test(t) @@ -109,7 +112,7 @@ func TestUpdateDon(t *testing.T) { { Name: "don 1", Nodes: []deployment.Node{node_1, node_2, node_3, node_4}, - Capabilities: []internal.DONCapabilityWithConfig{{Capability: initialCap, Config: initialCapCfg}}, + Capabilities: []internal.DONCapabilityWithConfig{{Capability: initialCap, Config: *initialCapCfg}}, }, }, nops: []internal.NOP{ @@ -139,7 +142,7 @@ func TestUpdateDon(t *testing.T) { Chain: testCfg.Chain, P2PIDs: []p2pkey.PeerID{p2p_1.PeerID(), p2p_2.PeerID(), p2p_3.PeerID(), p2p_4.PeerID()}, CapabilityConfigs: []internal.CapabilityConfig{ - {Capability: initialCap, Config: initialCapCfg}, {Capability: capToAdd, Config: capToAddCfg}, + {Capability: initialCap, Config: initialCapCfgB}, {Capability: capToAdd, Config: capToAddCfgB}, }, } want := &internal.UpdateDonResponse{ @@ -148,8 +151,8 @@ func TestUpdateDon(t *testing.T) { ConfigCount: 1, NodeP2PIds: internal.PeerIDsToBytes([]p2pkey.PeerID{p2p_1.PeerID(), p2p_2.PeerID(), p2p_3.PeerID(), p2p_4.PeerID()}), CapabilityConfigurations: []kcr.CapabilitiesRegistryCapabilityConfiguration{ - {CapabilityId: kstest.MustCapabilityId(t, testCfg.Registry, initialCap), Config: initialCapCfg}, - {CapabilityId: kstest.MustCapabilityId(t, testCfg.Registry, capToAdd), Config: capToAddCfg}, + {CapabilityId: kstest.MustCapabilityId(t, testCfg.Registry, initialCap), Config: initialCapCfgB}, + {CapabilityId: kstest.MustCapabilityId(t, testCfg.Registry, capToAdd), Config: capToAddCfgB}, }, }, } @@ -318,9 +321,12 @@ func testDon(t *testing.T, don internal.DonInfo) kstest.Don { } var capabilityConfigs []internal.CapabilityConfig - for _, cap := range don.Capabilities { + for i := range don.Capabilities { + cap := &don.Capabilities[i] + cfg, err := proto.Marshal(&cap.Config) + require.NoError(t, err) capabilityConfigs = append(capabilityConfigs, internal.CapabilityConfig{ - Capability: cap.Capability, Config: cap.Config, + Capability: cap.Capability, Config: cfg, }) } return kstest.Don{ diff --git a/deployment/keystone/changeset/internal/update_nodes_test.go b/deployment/keystone/changeset/internal/update_nodes_test.go index 68c14499b75..c564e87c2de 100644 --- a/deployment/keystone/changeset/internal/update_nodes_test.go +++ b/deployment/keystone/changeset/internal/update_nodes_test.go @@ -13,7 +13,6 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/known/durationpb" capabilitiespb "github.com/smartcontractkit/chainlink-common/pkg/capabilities/pb" @@ -463,8 +462,6 @@ func TestUpdateNodes(t *testing.T) { }, }, } - phonyCapCfgBytes, err := proto.Marshal(phonyCapCfg) - require.NoError(t, err) initMap := make(map[p2pkey.PeerID][]kcr.CapabilitiesRegistryCapability) for p2pID := range tt.args.req.P2pToUpdates { initMap[p2pID] = []kcr.CapabilitiesRegistryCapability{phonyCap} @@ -489,7 +486,7 @@ func TestUpdateNodes(t *testing.T) { expectedUpdatedCaps[p2p] = expectedCaps } else { expectedUpdatedCaps[p2p] = []internal.RegisteredCapability{ - {CapabilitiesRegistryCapability: phonyCap, ID: id, Config: phonyCapCfgBytes}, + {CapabilitiesRegistryCapability: phonyCap, ID: id, Config: phonyCapCfg}, } } } diff --git a/deployment/keystone/changeset/test/helpers.go b/deployment/keystone/changeset/test/helpers.go index 212cf90ccaf..ef994d87acb 100644 --- a/deployment/keystone/changeset/test/helpers.go +++ b/deployment/keystone/changeset/test/helpers.go @@ -150,12 +150,9 @@ func SetupTestEnv(t *testing.T, c TestConfig) TestEnv { assetNodes := memory.NewNodes(t, zapcore.InfoLevel, assetChains, c.AssetDonConfig.N, 0, crConfig) require.Len(t, assetNodes, c.AssetDonConfig.N) - ocr3CapCfg, err := internal.GetDefaultCapConfig(internal.OCR3Cap) - require.NoError(t, err) - writerChainCapCfg, err := internal.GetDefaultCapConfig(internal.WriteChainCap) - require.NoError(t, err) - streamTriggerChainCapCfg, err := internal.GetDefaultCapConfig(internal.StreamTriggerCap) - require.NoError(t, err) + ocr3CapCfg := internal.GetDefaultCapConfig(internal.OCR3Cap) + writerChainCapCfg := internal.GetDefaultCapConfig(internal.WriteChainCap) + streamTriggerChainCapCfg := internal.GetDefaultCapConfig(internal.StreamTriggerCap) // TODO: partition nodes into multiple nops @@ -168,7 +165,7 @@ func SetupTestEnv(t *testing.T, c TestConfig) TestEnv { }, }, Capabilities: []internal.DONCapabilityWithConfig{ - {Capability: internal.OCR3Cap, Config: ocr3CapCfg}, + {Capability: internal.OCR3Cap, Config: *ocr3CapCfg}, }, } cwDon := internal.DonCapabilities{ @@ -180,7 +177,7 @@ func SetupTestEnv(t *testing.T, c TestConfig) TestEnv { }, }, Capabilities: []internal.DONCapabilityWithConfig{ - {Capability: internal.WriteChainCap, Config: writerChainCapCfg}, + {Capability: internal.WriteChainCap, Config: *writerChainCapCfg}, }, } assetDon := internal.DonCapabilities{ @@ -192,7 +189,7 @@ func SetupTestEnv(t *testing.T, c TestConfig) TestEnv { }, }, Capabilities: []internal.DONCapabilityWithConfig{ - {Capability: internal.StreamTriggerCap, Config: streamTriggerChainCapCfg}, + {Capability: internal.StreamTriggerCap, Config: *streamTriggerChainCapCfg}, }, } diff --git a/deployment/keystone/changeset/update_don_test.go b/deployment/keystone/changeset/update_don_test.go index 0c985420619..5581d8ff587 100644 --- a/deployment/keystone/changeset/update_don_test.go +++ b/deployment/keystone/changeset/update_don_test.go @@ -5,6 +5,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "google.golang.org/protobuf/proto" commonchangeset "github.com/smartcontractkit/chainlink/deployment/common/changeset" "github.com/smartcontractkit/chainlink/deployment/common/proposalutils" @@ -29,9 +30,11 @@ func TestUpdateDon(t *testing.T) { } caps = []kcr.CapabilitiesRegistryCapability{capA, capB} ) - capACfg, err := internal.GetDefaultCapConfig(capA) + capACfg := internal.GetDefaultCapConfig(capA) + capACfgB, err := proto.Marshal(capACfg) require.NoError(t, err) - capBCfg, err := internal.GetDefaultCapConfig(capB) + capBCfg := internal.GetDefaultCapConfig(capB) + capBCfgB, err := proto.Marshal(capBCfg) require.NoError(t, err) t.Run("no mcms", func(t *testing.T) { @@ -59,10 +62,10 @@ func TestUpdateDon(t *testing.T) { P2PIDs: p2pIDs, CapabilityConfigs: []changeset.CapabilityConfig{ { - Capability: capA, Config: capACfg, + Capability: capA, Config: capACfgB, }, { - Capability: capB, Config: capBCfg, + Capability: capB, Config: capBCfgB, }, }, } @@ -99,11 +102,11 @@ func TestUpdateDon(t *testing.T) { CapabilityConfigs: []changeset.CapabilityConfig{ { Capability: capA, - Config: capACfg, + Config: capACfgB, }, { Capability: capB, - Config: capBCfg, + Config: capBCfgB, }, }, MCMSConfig: &changeset.MCMSConfig{MinDuration: 0}, From faf902cc23dd12a03e078eb889ea97f22fd2b39c Mon Sep 17 00:00:00 2001 From: vyzaldysanchez Date: Mon, 20 Jan 2025 14:27:01 -0400 Subject: [PATCH 21/23] Fixes lint --- deployment/keystone/changeset/internal/deploy.go | 14 +++++++------- deployment/keystone/changeset/internal/types.go | 2 +- .../keystone/changeset/internal/update_don_test.go | 8 ++++---- deployment/keystone/changeset/test/helpers.go | 6 +++--- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/deployment/keystone/changeset/internal/deploy.go b/deployment/keystone/changeset/internal/deploy.go index 6453523a2da..fcfd21e44dd 100644 --- a/deployment/keystone/changeset/internal/deploy.go +++ b/deployment/keystone/changeset/internal/deploy.go @@ -469,20 +469,20 @@ func RegisterCapabilities(lggr logger.Logger, req RegisterCapabilitiesRequest) ( for don, caps := range req.DonToCapabilities { var registerCaps []RegisteredCapability for i := range caps { - cap := &caps[i] - id, ok := uniqueCaps[cap.Capability] + regCap := &caps[i] + id, ok := uniqueCaps[regCap.Capability] if !ok { var err error - id, err = registry.GetHashedCapabilityId(&bind.CallOpts{}, cap.Capability.LabelledName, cap.Capability.Version) + id, err = registry.GetHashedCapabilityId(&bind.CallOpts{}, regCap.Capability.LabelledName, regCap.Capability.Version) if err != nil { - return nil, fmt.Errorf("failed to call GetHashedCapabilityId for capability %v: %w", cap, err) + return nil, fmt.Errorf("failed to call GetHashedCapabilityId for capability %v: %w", regCap, err) } - uniqueCaps[cap.Capability] = id + uniqueCaps[regCap.Capability] = id } registerCap := RegisteredCapability{ ID: id, - Config: &cap.Config, - CapabilitiesRegistryCapability: cap.Capability, + Config: regCap.Config, + CapabilitiesRegistryCapability: regCap.Capability, } lggr.Debugw("hashed capability id", "capability", cap, "id", id) registerCaps = append(registerCaps, registerCap) diff --git a/deployment/keystone/changeset/internal/types.go b/deployment/keystone/changeset/internal/types.go index 801b89955dd..c4e9deccdf9 100644 --- a/deployment/keystone/changeset/internal/types.go +++ b/deployment/keystone/changeset/internal/types.go @@ -137,7 +137,7 @@ type DonCapabilities struct { type DONCapabilityWithConfig struct { Capability kcr.CapabilitiesRegistryCapability - Config capabilitiespb.CapabilityConfig + Config *capabilitiespb.CapabilityConfig } func (v DonCapabilities) Validate() error { diff --git a/deployment/keystone/changeset/internal/update_don_test.go b/deployment/keystone/changeset/internal/update_don_test.go index 6e857d65d7e..f942268db55 100644 --- a/deployment/keystone/changeset/internal/update_don_test.go +++ b/deployment/keystone/changeset/internal/update_don_test.go @@ -112,7 +112,7 @@ func TestUpdateDon(t *testing.T) { { Name: "don 1", Nodes: []deployment.Node{node_1, node_2, node_3, node_4}, - Capabilities: []internal.DONCapabilityWithConfig{{Capability: initialCap, Config: *initialCapCfg}}, + Capabilities: []internal.DONCapabilityWithConfig{{Capability: initialCap, Config: initialCapCfg}}, }, }, nops: []internal.NOP{ @@ -322,11 +322,11 @@ func testDon(t *testing.T, don internal.DonInfo) kstest.Don { var capabilityConfigs []internal.CapabilityConfig for i := range don.Capabilities { - cap := &don.Capabilities[i] - cfg, err := proto.Marshal(&cap.Config) + donCap := &don.Capabilities[i] + cfg, err := proto.Marshal(donCap.Config) require.NoError(t, err) capabilityConfigs = append(capabilityConfigs, internal.CapabilityConfig{ - Capability: cap.Capability, Config: cfg, + Capability: donCap.Capability, Config: cfg, }) } return kstest.Don{ diff --git a/deployment/keystone/changeset/test/helpers.go b/deployment/keystone/changeset/test/helpers.go index ef994d87acb..2f51a3c9f7a 100644 --- a/deployment/keystone/changeset/test/helpers.go +++ b/deployment/keystone/changeset/test/helpers.go @@ -165,7 +165,7 @@ func SetupTestEnv(t *testing.T, c TestConfig) TestEnv { }, }, Capabilities: []internal.DONCapabilityWithConfig{ - {Capability: internal.OCR3Cap, Config: *ocr3CapCfg}, + {Capability: internal.OCR3Cap, Config: ocr3CapCfg}, }, } cwDon := internal.DonCapabilities{ @@ -177,7 +177,7 @@ func SetupTestEnv(t *testing.T, c TestConfig) TestEnv { }, }, Capabilities: []internal.DONCapabilityWithConfig{ - {Capability: internal.WriteChainCap, Config: *writerChainCapCfg}, + {Capability: internal.WriteChainCap, Config: writerChainCapCfg}, }, } assetDon := internal.DonCapabilities{ @@ -189,7 +189,7 @@ func SetupTestEnv(t *testing.T, c TestConfig) TestEnv { }, }, Capabilities: []internal.DONCapabilityWithConfig{ - {Capability: internal.StreamTriggerCap, Config: *streamTriggerChainCapCfg}, + {Capability: internal.StreamTriggerCap, Config: streamTriggerChainCapCfg}, }, } From 7107f0a4b50f5195ebe874eff38ca6b06bc78da9 Mon Sep 17 00:00:00 2001 From: vyzaldysanchez Date: Mon, 20 Jan 2025 14:31:26 -0400 Subject: [PATCH 22/23] Fixes lint --- deployment/keystone/changeset/internal/deploy.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/deployment/keystone/changeset/internal/deploy.go b/deployment/keystone/changeset/internal/deploy.go index fcfd21e44dd..c5cc187fb4d 100644 --- a/deployment/keystone/changeset/internal/deploy.go +++ b/deployment/keystone/changeset/internal/deploy.go @@ -484,15 +484,15 @@ func RegisterCapabilities(lggr logger.Logger, req RegisterCapabilitiesRequest) ( Config: regCap.Config, CapabilitiesRegistryCapability: regCap.Capability, } - lggr.Debugw("hashed capability id", "capability", cap, "id", id) + lggr.Debugw("hashed capability id", "capability", regCap, "id", id) registerCaps = append(registerCaps, registerCap) } resp.DonToCapabilities[don] = registerCaps } var capabilities []capabilities_registry.CapabilitiesRegistryCapability - for cap := range uniqueCaps { - capabilities = append(capabilities, cap) + for uniqueCap := range uniqueCaps { + capabilities = append(capabilities, uniqueCap) } if len(capabilities) == 0 { lggr.Warn("no new capabilities to register") From faed4abbf94e92b4bdb87baccb5bdc96aab2c2d5 Mon Sep 17 00:00:00 2001 From: vyzaldysanchez Date: Mon, 20 Jan 2025 22:52:25 -0400 Subject: [PATCH 23/23] Refactors test util --- .../keystone/changeset/internal/deploy.go | 32 ++----------------- .../changeset/internal/deploy_test.go | 5 +-- .../keystone/changeset/internal/test/utils.go | 32 +++++++++++++++++-- .../changeset/internal/update_don_test.go | 4 +-- deployment/keystone/changeset/test/helpers.go | 7 ++-- .../keystone/changeset/update_don_test.go | 5 +-- 6 files changed, 44 insertions(+), 41 deletions(-) diff --git a/deployment/keystone/changeset/internal/deploy.go b/deployment/keystone/changeset/internal/deploy.go index c5cc187fb4d..8b67013aa15 100644 --- a/deployment/keystone/changeset/internal/deploy.go +++ b/deployment/keystone/changeset/internal/deploy.go @@ -15,16 +15,13 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" - "golang.org/x/exp/maps" - "google.golang.org/protobuf/proto" - "google.golang.org/protobuf/types/known/durationpb" - "github.com/smartcontractkit/ccip-owner-contracts/pkg/proposal/mcms" "github.com/smartcontractkit/ccip-owner-contracts/pkg/proposal/timelock" chainsel "github.com/smartcontractkit/chain-selectors" capabilitiespb "github.com/smartcontractkit/chainlink-common/pkg/capabilities/pb" "github.com/smartcontractkit/chainlink-common/pkg/logger" - "github.com/smartcontractkit/chainlink-common/pkg/values" + "golang.org/x/exp/maps" + "google.golang.org/protobuf/proto" "github.com/smartcontractkit/chainlink/deployment" capabilities_registry "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/keystone/generated/capabilities_registry_1_1_0" @@ -1046,28 +1043,3 @@ func configureForwarder(lggr logger.Logger, chain deployment.Chain, contractSet } return opMap, nil } - -func GetDefaultCapConfig(capability capabilities_registry.CapabilitiesRegistryCapability) *capabilitiespb.CapabilityConfig { - defaultCfg := &capabilitiespb.CapabilityConfig{ - DefaultConfig: values.Proto(values.EmptyMap()).GetMapValue(), - } - switch capability.CapabilityType { - case uint8(0): // trigger - defaultCfg.RemoteConfig = &capabilitiespb.CapabilityConfig_RemoteTriggerConfig{ - RemoteTriggerConfig: &capabilitiespb.RemoteTriggerConfig{ - RegistrationRefresh: durationpb.New(20 * time.Second), - RegistrationExpiry: durationpb.New(60 * time.Second), - MinResponsesToAggregate: uint32(10), - }, - } - case uint8(3): // target - defaultCfg.RemoteConfig = &capabilitiespb.CapabilityConfig_RemoteTargetConfig{ - RemoteTargetConfig: &capabilitiespb.RemoteTargetConfig{ - RequestHashExcludedAttributes: []string{"signed_report.Signatures"}, - }, - } - case uint8(2): // consensus - default: - } - return defaultCfg -} diff --git a/deployment/keystone/changeset/internal/deploy_test.go b/deployment/keystone/changeset/internal/deploy_test.go index b8a98207ea0..c059cd5a981 100644 --- a/deployment/keystone/changeset/internal/deploy_test.go +++ b/deployment/keystone/changeset/internal/deploy_test.go @@ -4,13 +4,14 @@ import ( "context" "testing" + "github.com/stretchr/testify/require" + "github.com/smartcontractkit/chainlink-common/pkg/logger" + "github.com/smartcontractkit/chainlink/deployment" "github.com/smartcontractkit/chainlink/deployment/keystone/changeset/internal" kstest "github.com/smartcontractkit/chainlink/deployment/keystone/changeset/internal/test" kcr "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/keystone/generated/capabilities_registry_1_1_0" - - "github.com/stretchr/testify/require" ) func Test_RegisterNOPS(t *testing.T) { diff --git a/deployment/keystone/changeset/internal/test/utils.go b/deployment/keystone/changeset/internal/test/utils.go index 451f0d2fa55..290d0ee2196 100644 --- a/deployment/keystone/changeset/internal/test/utils.go +++ b/deployment/keystone/changeset/internal/test/utils.go @@ -5,10 +5,12 @@ import ( "fmt" "sort" "testing" + "time" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/stretchr/testify/require" "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/types/known/durationpb" capabilitiespb "github.com/smartcontractkit/chainlink-common/pkg/capabilities/pb" "github.com/smartcontractkit/chainlink-common/pkg/logger" @@ -222,7 +224,7 @@ func (cc *CapabilityCache) AddCapabilities(_ logger.Logger, chain deployment.Cha out = append(out, internal.RegisteredCapability{ CapabilitiesRegistryCapability: c, ID: id, - Config: internal.GetDefaultCapConfig(c), + Config: GetDefaultCapConfig(t, c), }) continue } @@ -251,7 +253,7 @@ func (cc *CapabilityCache) AddCapabilities(_ logger.Logger, chain deployment.Cha out = append(out, internal.RegisteredCapability{ CapabilitiesRegistryCapability: capb, ID: id, - Config: internal.GetDefaultCapConfig(capb), + Config: GetDefaultCapConfig(t, capb), }) // cache the id cc.nameToId[internal.CapabilityID(capb)] = id @@ -295,3 +297,29 @@ func MustCapabilityId(t *testing.T, registry *capabilities_registry.Capabilities require.NoError(t, err) return id } + +func GetDefaultCapConfig(t *testing.T, capability capabilities_registry.CapabilitiesRegistryCapability) *capabilitiespb.CapabilityConfig { + t.Helper() + defaultCfg := &capabilitiespb.CapabilityConfig{ + DefaultConfig: values.Proto(values.EmptyMap()).GetMapValue(), + } + switch capability.CapabilityType { + case uint8(0): // trigger + defaultCfg.RemoteConfig = &capabilitiespb.CapabilityConfig_RemoteTriggerConfig{ + RemoteTriggerConfig: &capabilitiespb.RemoteTriggerConfig{ + RegistrationRefresh: durationpb.New(20 * time.Second), + RegistrationExpiry: durationpb.New(60 * time.Second), + MinResponsesToAggregate: uint32(10), + }, + } + case uint8(3): // target + defaultCfg.RemoteConfig = &capabilitiespb.CapabilityConfig_RemoteTargetConfig{ + RemoteTargetConfig: &capabilitiespb.RemoteTargetConfig{ + RequestHashExcludedAttributes: []string{"signed_report.Signatures"}, + }, + } + case uint8(2): // consensus + default: + } + return defaultCfg +} diff --git a/deployment/keystone/changeset/internal/update_don_test.go b/deployment/keystone/changeset/internal/update_don_test.go index f942268db55..42b032d9433 100644 --- a/deployment/keystone/changeset/internal/update_don_test.go +++ b/deployment/keystone/changeset/internal/update_don_test.go @@ -97,10 +97,10 @@ func TestUpdateDon(t *testing.T) { } ) - initialCapCfg := internal.GetDefaultCapConfig(initialCap) + initialCapCfg := kstest.GetDefaultCapConfig(t, initialCap) initialCapCfgB, err := proto.Marshal(initialCapCfg) require.NoError(t, err) - capToAddCfg := internal.GetDefaultCapConfig(capToAdd) + capToAddCfg := kstest.GetDefaultCapConfig(t, capToAdd) capToAddCfgB, err := proto.Marshal(capToAddCfg) require.NoError(t, err) diff --git a/deployment/keystone/changeset/test/helpers.go b/deployment/keystone/changeset/test/helpers.go index 2f51a3c9f7a..c0b7d9a0d67 100644 --- a/deployment/keystone/changeset/test/helpers.go +++ b/deployment/keystone/changeset/test/helpers.go @@ -24,6 +24,7 @@ import ( "github.com/smartcontractkit/chainlink/deployment/environment/memory" kschangeset "github.com/smartcontractkit/chainlink/deployment/keystone/changeset" "github.com/smartcontractkit/chainlink/deployment/keystone/changeset/internal" + kstest "github.com/smartcontractkit/chainlink/deployment/keystone/changeset/internal/test" "github.com/smartcontractkit/chainlink/deployment/keystone/changeset/workflowregistry" kcr "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/keystone/generated/capabilities_registry_1_1_0" "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/p2pkey" @@ -150,9 +151,9 @@ func SetupTestEnv(t *testing.T, c TestConfig) TestEnv { assetNodes := memory.NewNodes(t, zapcore.InfoLevel, assetChains, c.AssetDonConfig.N, 0, crConfig) require.Len(t, assetNodes, c.AssetDonConfig.N) - ocr3CapCfg := internal.GetDefaultCapConfig(internal.OCR3Cap) - writerChainCapCfg := internal.GetDefaultCapConfig(internal.WriteChainCap) - streamTriggerChainCapCfg := internal.GetDefaultCapConfig(internal.StreamTriggerCap) + ocr3CapCfg := kstest.GetDefaultCapConfig(t, internal.OCR3Cap) + writerChainCapCfg := kstest.GetDefaultCapConfig(t, internal.WriteChainCap) + streamTriggerChainCapCfg := kstest.GetDefaultCapConfig(t, internal.StreamTriggerCap) // TODO: partition nodes into multiple nops diff --git a/deployment/keystone/changeset/update_don_test.go b/deployment/keystone/changeset/update_don_test.go index 5581d8ff587..3fadb7822e2 100644 --- a/deployment/keystone/changeset/update_don_test.go +++ b/deployment/keystone/changeset/update_don_test.go @@ -11,6 +11,7 @@ import ( "github.com/smartcontractkit/chainlink/deployment/common/proposalutils" "github.com/smartcontractkit/chainlink/deployment/keystone/changeset" "github.com/smartcontractkit/chainlink/deployment/keystone/changeset/internal" + internaltest "github.com/smartcontractkit/chainlink/deployment/keystone/changeset/internal/test" "github.com/smartcontractkit/chainlink/deployment/keystone/changeset/test" kcr "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/keystone/generated/capabilities_registry_1_1_0" "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/p2pkey" @@ -30,10 +31,10 @@ func TestUpdateDon(t *testing.T) { } caps = []kcr.CapabilitiesRegistryCapability{capA, capB} ) - capACfg := internal.GetDefaultCapConfig(capA) + capACfg := internaltest.GetDefaultCapConfig(t, capA) capACfgB, err := proto.Marshal(capACfg) require.NoError(t, err) - capBCfg := internal.GetDefaultCapConfig(capB) + capBCfg := internaltest.GetDefaultCapConfig(t, capB) capBCfgB, err := proto.Marshal(capBCfg) require.NoError(t, err)