Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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/tall-mice-wink.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": minor
---

#added DKG integration with Vault plugin
2 changes: 1 addition & 1 deletion core/scripts/keystone/src/02_provision_ocr3_capability.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func generateOCR3Config(nodeKeys []NodeKeys, configFile string) ksdeploy.OCR3Onc
topLevelCfg := mustReadOCR3Config(configFile)
cfg := topLevelCfg.OracleConfig
secrets := focr.XXXGenerateTestOCRSecrets()
c, err := ksdeploy.GenerateOCR3Config(cfg, nodeKeysToKsDeployNodeKeys(nodeKeys[1:]), secrets) // skip the bootstrap node
c, err := ksdeploy.GenerateOCR3Config(cfg, nodeKeysToKsDeployNodeKeys(nodeKeys[1:]), secrets, nil) // skip the bootstrap node
helpers.PanicErr(err)
return c
}
Expand Down
2 changes: 1 addition & 1 deletion core/scripts/keystone/src/generate_local_ocr3_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func (g *generateLocalOCR3Config) Run(args []string) {
panic(err)
}

ocrConfig, err := changeset.GenerateOCR3Config(cfg, pubKeys, focr.XXXGenerateTestOCRSecrets())
ocrConfig, err := changeset.GenerateOCR3Config(cfg, pubKeys, focr.XXXGenerateTestOCRSecrets(), nil)
if err != nil {
panic(err)
}
Expand Down
2 changes: 1 addition & 1 deletion core/services/ocr2/delegate.go
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@ func (d *Delegate) newServicesVaultPlugin(
rpf, err := vaultocrplugin.NewReportingPluginFactory(
lggr,
requestStore,
nil, // PRIV-153: pass in `vault.NewVaultORM(d.ds) as db`
vaultocrplugin.NewVaultORM(d.ds),
&dkgRecipientKey,
pk,
secKeyShare,
Expand Down
3 changes: 3 additions & 0 deletions core/services/ocr2/plugins/vault/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ func (r *ReportingPluginFactory) NewReportingPlugin(ctx context.Context, config
if err != nil {
return nil, ocr3_1types.ReportingPluginInfo{}, fmt.Errorf("could not read result package from db: %w", err)
}
if pack == nil {
return nil, ocr3_1types.ReportingPluginInfo{}, fmt.Errorf("no result package found in db for instance ID %s", *configProto.DKGInstanceID)
}
rP := dkgocr.NewResultPackage()
err = rP.UnmarshalBinary(pack.ReportWithResultPackage)
if err != nil {
Expand Down
59 changes: 34 additions & 25 deletions deployment/cre/ocr3/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ func (c *OCR2OracleConfig) UnmarshalJSON(data []byte) error {
return nil
}

func GenerateOCR3Config(cfg OracleConfig, nca []NodeKeys, secrets focr.OCRSecrets) (OCR2OracleConfig, error) {
func GenerateOCR3Config(cfg OracleConfig, nca []NodeKeys, secrets focr.OCRSecrets, reportingPluginConfigOverride []byte) (OCR2OracleConfig, error) {
// the transmission schedule is very specific; arguably it should be not be a parameter
if len(cfg.TransmissionSchedule) != 1 || cfg.TransmissionSchedule[0] != len(nca) {
return OCR2OracleConfig{}, fmt.Errorf("transmission schedule must have exactly one entry, matching the len of the number of nodes want [%d], got %v. Total TransmissionSchedules = %d", len(nca), cfg.TransmissionSchedule, len(cfg.TransmissionSchedule))
Expand Down Expand Up @@ -292,22 +292,26 @@ func GenerateOCR3Config(cfg OracleConfig, nca []NodeKeys, secrets focr.OCRSecret

// let's keep reqTimeout as nil if it's 0, so we can use the default value within `chainlink-common`.
// See: https://github.com/smartcontractkit/chainlink-common/blob/main/pkg/capabilities/consensus/ocr3/factory.go#L73
var reqTimeout *durationpb.Duration
if cfg.RequestTimeout > 0 {
reqTimeout = durationpb.New(cfg.RequestTimeout)
}
cfgBytes, err := proto.Marshal(&capocr3types.ReportingPluginConfig{
MaxQueryLengthBytes: cfg.MaxQueryLengthBytes,
MaxObservationLengthBytes: cfg.MaxObservationLengthBytes,
MaxReportLengthBytes: cfg.MaxReportLengthBytes,
MaxOutcomeLengthBytes: cfg.MaxOutcomeLengthBytes,
MaxReportCount: cfg.MaxReportCount,
MaxBatchSize: cfg.MaxBatchSize,
OutcomePruningThreshold: cfg.OutcomePruningThreshold,
RequestTimeout: reqTimeout,
})
if err != nil {
return OCR2OracleConfig{}, fmt.Errorf("failed to marshal ReportingPluginConfig: %w", err)
cfgBytes := reportingPluginConfigOverride
if cfgBytes == nil {
var reqTimeout *durationpb.Duration
if cfg.RequestTimeout > 0 {
reqTimeout = durationpb.New(cfg.RequestTimeout)
}
var err2 error
cfgBytes, err2 = proto.Marshal(&capocr3types.ReportingPluginConfig{
MaxQueryLengthBytes: cfg.MaxQueryLengthBytes,
MaxObservationLengthBytes: cfg.MaxObservationLengthBytes,
MaxReportLengthBytes: cfg.MaxReportLengthBytes,
MaxOutcomeLengthBytes: cfg.MaxOutcomeLengthBytes,
MaxReportCount: cfg.MaxReportCount,
MaxBatchSize: cfg.MaxBatchSize,
OutcomePruningThreshold: cfg.OutcomePruningThreshold,
RequestTimeout: reqTimeout,
})
if err2 != nil {
return OCR2OracleConfig{}, fmt.Errorf("failed to marshal ReportingPluginConfig: %w", err2)
}
}

signers, transmitters, f, onchainConfig, offchainConfigVersion, offchainConfig, err := ocr3confighelper.ContractSetConfigArgsDeterministic(
Expand Down Expand Up @@ -366,6 +370,8 @@ type ConfigureOCR3Request struct {
DryRun bool
OcrSecrets focr.OCRSecrets

ReportingPluginConfigOverride []byte

UseMCMS bool
}

Expand All @@ -374,7 +380,7 @@ func (r ConfigureOCR3Request) generateOCR3Config() (OCR2OracleConfig, error) {
if r.Cfg == nil {
return OCR2OracleConfig{}, errors.New("OCR3 config is required")
}
return GenerateOCR3Config(*r.Cfg, nks, r.OcrSecrets)
return GenerateOCR3Config(*r.Cfg, nks, r.OcrSecrets, r.ReportingPluginConfigOverride)
}

type ConfigureOCR3Response struct {
Expand Down Expand Up @@ -441,6 +447,8 @@ type ConfigureOCR3Config struct {
OCR3Config *OracleConfig
DryRun bool

ReportingPluginConfigOverride []byte

UseMCMS bool
}

Expand All @@ -467,13 +475,14 @@ func ConfigureOCR3ContractFromJD(env *cldf.Environment, cfg ConfigureOCR3Config)
return nil, err
}
r, err := ConfigureOCR3contract(ConfigureOCR3Request{
Cfg: cfg.OCR3Config,
Chain: registryChain,
Contract: contract,
Nodes: nodes,
DryRun: cfg.DryRun,
UseMCMS: cfg.UseMCMS,
OcrSecrets: env.OCRSecrets,
Cfg: cfg.OCR3Config,
Chain: registryChain,
Contract: contract,
Nodes: nodes,
DryRun: cfg.DryRun,
UseMCMS: cfg.UseMCMS,
OcrSecrets: env.OCRSecrets,
ReportingPluginConfigOverride: cfg.ReportingPluginConfigOverride,
})
if err != nil {
return nil, err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ type ConfigureOCR3Input struct {
Config *ocr3.OracleConfig
DryRun bool

ReportingPluginConfigOverride []byte

MCMSConfig *ocr3.MCMSConfig
}

Expand Down Expand Up @@ -66,12 +68,13 @@ var ConfigureOCR3 = operations.NewOperation[ConfigureOCR3Input, ConfigureOCR3OpO
}

resp, err := ocr3.ConfigureOCR3ContractFromJD(deps.Env, ocr3.ConfigureOCR3Config{
ChainSel: input.ChainSelector,
NodeIDs: input.DON.NodeIDs,
OCR3Config: input.Config,
Contract: contract.Contract,
DryRun: input.DryRun,
UseMCMS: input.UseMCMS(),
ChainSel: input.ChainSelector,
NodeIDs: input.DON.NodeIDs,
OCR3Config: input.Config,
Contract: contract.Contract,
DryRun: input.DryRun,
UseMCMS: input.UseMCMS(),
ReportingPluginConfigOverride: input.ReportingPluginConfigOverride,
})
if err != nil {
return ConfigureOCR3OpOutput{}, fmt.Errorf("failed to configure OCR3Capability: %w", err)
Expand Down
56 changes: 38 additions & 18 deletions system-tests/lib/cre/contracts/contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ import (

"github.com/smartcontractkit/chainlink-evm/gethwrappers/data-feeds/generated/data_feeds_cache"
kcr "github.com/smartcontractkit/chainlink-evm/gethwrappers/keystone/generated/capabilities_registry_1_1_0"
ocr3_capability "github.com/smartcontractkit/chainlink-evm/gethwrappers/keystone/generated/ocr3_capability_1_0_0"

vaultprotos "github.com/smartcontractkit/chainlink-common/pkg/capabilities/actions/vault"
"github.com/smartcontractkit/chainlink-deployments-framework/datastore"
cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment"
commonchangeset "github.com/smartcontractkit/chainlink/deployment/common/changeset"
Expand Down Expand Up @@ -524,24 +526,6 @@ func ConfigureKeystone(input cre.ConfigureKeystoneInput) error {
return fmt.Errorf("failed to get vault DON: %w", err)
}

_, err = operations.ExecuteOperation(
input.CldEnv.OperationsBundle,
ks_contracts_op.ConfigureOCR3Op,
ks_contracts_op.ConfigureOCR3OpDeps{
Env: input.CldEnv,
},
ks_contracts_op.ConfigureOCR3OpInput{
ContractAddress: input.VaultOCR3Address,
ChainSelector: input.ChainSelector,
DON: vaultDON.keystoneDonConfig(),
Config: vaultDON.resolveOcr3Config(input.VaultOCR3Config),
DryRun: false,
},
)
if err != nil {
return errors.Wrap(err, "failed to configure Vault OCR3 contract")
}

_, err = operations.ExecuteOperation(
input.CldEnv.OperationsBundle,
ks_contracts_op.ConfigureDKGOp,
Expand All @@ -560,6 +544,42 @@ func ConfigureKeystone(input cre.ConfigureKeystoneInput) error {
if err != nil {
return errors.Wrap(err, "failed to configure DKG OCR3 contract")
}

client := input.CldEnv.BlockChains.EVMChains()[input.ChainSelector].Client
dkgContract, err := ocr3_capability.NewOCR3Capability(*input.DKGOCR3Address, client)
if err != nil {
return errors.Wrap(err, "failed to create OCR3 capability contract")
}
details, err := dkgContract.LatestConfigDetails(nil)
if err != nil {
return errors.Wrap(err, "failed to get latest config details from OCR3 capability contract")
}
instanceID := string(dkgocrtypes.MakeInstanceID(dkgContract.Address(), details.ConfigDigest))
cfg := vaultprotos.ReportingPluginConfig{
DKGInstanceID: &instanceID,
}
cfgb, err := proto.Marshal(&cfg)
if err != nil {
return errors.Wrap(err, "failed to marshal vault reporting plugin config")
}
_, err = operations.ExecuteOperation(
input.CldEnv.OperationsBundle,
ks_contracts_op.ConfigureOCR3Op,
ks_contracts_op.ConfigureOCR3OpDeps{
Env: input.CldEnv,
},
ks_contracts_op.ConfigureOCR3OpInput{
ContractAddress: input.VaultOCR3Address,
ChainSelector: input.ChainSelector,
DON: vaultDON.keystoneDonConfig(),
Config: vaultDON.resolveOcr3Config(input.VaultOCR3Config),
DryRun: false,
ReportingPluginConfigOverride: cfgb,
},
)
if err != nil {
return errors.Wrap(err, "failed to configure Vault OCR3 contract")
}
}

for chainSelector, evmOCR3Address := range input.EVMOCR3Addresses {
Expand Down
38 changes: 22 additions & 16 deletions system-tests/tests/smoke/cre/v2_vault_don_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,32 @@ func ExecuteVaultTest(t *testing.T, testEnv *TestEnvironment) {
var testLogger = framework.L

testLogger.Info().Msgf("Ensuring DKG result packages are present...")
var vaultFound bool
for _, nodeSet := range testEnv.Config.NodeSets {
for _, cap := range nodeSet.Capabilities {
if cap == cre.VaultCapability {
vaultFound = true
break
require.Eventually(t, func() bool {
for _, nodeSet := range testEnv.Config.NodeSets {
var vaultFound bool
for _, cap := range nodeSet.Capabilities {
if cap == cre.VaultCapability {
vaultFound = true
break
}
}
}
if vaultFound {
for i := range nodeSet.Nodes {
if i != nodeSet.BootstrapNodeIndex {
packageCount, err := vault.GetResultPackageCount(t.Context(), i, nodeSet.DbInput.Port)
require.NoError(t, err, "failed to get result package count")
require.Equal(t, int64(1), packageCount, "expected one result package in the database")
if vaultFound {
for i := range nodeSet.Nodes {
if i != nodeSet.BootstrapNodeIndex {
packageCount, err := vault.GetResultPackageCount(t.Context(), i, nodeSet.DbInput.Port)
if err != nil || packageCount != 1 {
return false
}
}
}
return true
}
break
}
}
require.True(t, vaultFound, "no node set with vault capability found in topology")
return false
}, time.Second*300, time.Second*5)

// Wait a bit to ensure the Vault plugin is ready.
time.Sleep(30 * time.Second)

testLogger.Info().Msg("Getting gateway configuration...")
require.NotEmpty(t, testEnv.FullCldEnvOutput.DonTopology.GatewayConnectorOutput.Configurations, "expected at least one gateway configuration")
Expand Down
Loading