diff --git a/.golangci.yaml b/.golangci.yaml index 92a120933..b8da6867c 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -442,6 +442,10 @@ linters: - gocyclo - gosec - revive + - path: build/devenv + linters: + - staticcheck + text: "testcontainers.BindMount is deprecated" - path: 'pkg/handlers/validations\.go' linters: - gci diff --git a/aggregator/pkg/model/config.go b/aggregator/pkg/model/config.go index 732632d49..cb0c3c2c5 100644 --- a/aggregator/pkg/model/config.go +++ b/aggregator/pkg/model/config.go @@ -11,13 +11,14 @@ import ( "time" "github.com/smartcontractkit/chainlink-ccv/aggregator/pkg/auth" + "github.com/smartcontractkit/chainlink-ccv/pkg/monitoring" "github.com/smartcontractkit/chainlink-ccv/protocol" hmacutil "github.com/smartcontractkit/chainlink-ccv/protocol/common/hmac" ) // Signer represents a participant in the commit verification process. type Signer struct { - Address string `toml:"address"` + Address string `json:"address" toml:"address"` } // SignerIdentifier holds the chain-native signer identifier. @@ -44,9 +45,9 @@ type Committee struct { // The aggregator uses this to verify signatures from each chain's // commit verifier set. // Map structure: source selector -> QuorumConfig - QuorumConfigs map[SourceSelector]*QuorumConfig `toml:"quorumConfigs"` + QuorumConfigs map[SourceSelector]*QuorumConfig `json:"quorumConfigs" toml:"quorumConfigs"` // DestinationVerifiers maps destination chain selectors to their verifier contract addresses. - DestinationVerifiers map[DestinationSelector]string `toml:"destinationVerifiers"` + DestinationVerifiers map[DestinationSelector]string `json:"destinationVerifiers" toml:"destinationVerifiers"` // destinationVerifiersParsed holds the parsed addresses, populated during validation. destinationVerifiersParsed map[DestinationSelector]protocol.UnknownAddress } @@ -87,9 +88,9 @@ func (c *Committee) SetQuorumConfig(sourceSelector SourceSelector, quorumConfig // QuorumConfig represents the configuration for a quorum of signers. type QuorumConfig struct { - SourceVerifierAddress string `toml:"sourceVerifierAddress"` - Signers []Signer `toml:"signers"` - Threshold uint8 `toml:"threshold"` + SourceVerifierAddress string `json:"sourceVerifierAddress" toml:"sourceVerifierAddress"` + Signers []Signer `json:"signers" toml:"signers"` + Threshold uint8 `json:"threshold" toml:"threshold"` // sourceVerifierAddressParsed holds the parsed address, populated during validation. sourceVerifierAddressParsed protocol.UnknownAddress } @@ -361,35 +362,11 @@ func (c *RateLimitingConfig) getMostRestrictiveGroupLimit(client auth.ClientConf return mostRestrictive } -// MonitoringConfig provides monitoring configuration for aggregator. -type MonitoringConfig struct { - // Enabled enables the monitoring system. - Enabled bool `toml:"Enabled"` - // Type is the type of monitoring system to use (beholder, noop). - Type string `toml:"Type"` - // Beholder is the configuration for the beholder client (Not required if type is noop). - Beholder BeholderConfig `toml:"Beholder"` -} - -// BeholderConfig wraps OpenTelemetry configuration for the beholder client. -type BeholderConfig struct { - // InsecureConnection disables TLS for the beholder client. - InsecureConnection bool `toml:"InsecureConnection"` - // CACertFile is the path to the CA certificate file for the beholder client. - CACertFile string `toml:"CACertFile"` - // OtelExporterGRPCEndpoint is the endpoint for the beholder client to export to the collector. - OtelExporterGRPCEndpoint string `toml:"OtelExporterGRPCEndpoint"` - // OtelExporterHTTPEndpoint is the endpoint for the beholder client to export to the collector. - OtelExporterHTTPEndpoint string `toml:"OtelExporterHTTPEndpoint"` - // LogStreamingEnabled enables log streaming to the collector. - LogStreamingEnabled bool `toml:"LogStreamingEnabled"` - // MetricReaderInterval is the interval to scrape metrics (in seconds). - MetricReaderInterval int64 `toml:"MetricReaderInterval"` - // TraceSampleRatio is the ratio of traces to sample. - TraceSampleRatio float64 `toml:"TraceSampleRatio"` - // TraceBatchTimeout is the timeout for a batch of traces. - TraceBatchTimeout int64 `toml:"TraceBatchTimeout"` -} +// Type aliases — canonical definitions live in pkg/monitoring. +type ( + MonitoringConfig = monitoring.Config + BeholderConfig = monitoring.BeholderConfig +) // AggregatorConfig is the root configuration for the pb. type AggregatorConfig struct { diff --git a/build/devenv/cciptestinterfaces/interface.go b/build/devenv/cciptestinterfaces/interface.go index c2fcb162d..decc1ec26 100644 --- a/build/devenv/cciptestinterfaces/interface.go +++ b/build/devenv/cciptestinterfaces/interface.go @@ -15,8 +15,8 @@ import ( tokensapi "github.com/smartcontractkit/chainlink-ccip/deployment/tokens" "github.com/smartcontractkit/chainlink-ccip/deployment/v2_0_0/adapters" ccipChangesets "github.com/smartcontractkit/chainlink-ccip/deployment/v2_0_0/changesets" - "github.com/smartcontractkit/chainlink-ccip/deployment/v2_0_0/offchain" devenvcommon "github.com/smartcontractkit/chainlink-ccv/build/devenv/common" + ccvdeployment "github.com/smartcontractkit/chainlink-ccv/deployment" "github.com/smartcontractkit/chainlink-ccv/protocol" "github.com/smartcontractkit/chainlink-deployments-framework/datastore" "github.com/smartcontractkit/chainlink-deployments-framework/deployment" @@ -295,7 +295,7 @@ type TokenConfigProvider interface { env *deployment.Environment, selector uint64, remoteSelectors []uint64, - topology *offchain.EnvironmentTopology, + topology *ccvdeployment.EnvironmentTopology, ) ([]tokensapi.TokenTransferConfig, error) } @@ -312,15 +312,15 @@ type OnChainConfigurable interface { // DeployChainContracts call (e.g. deploying CREATE2 factory on EVM). // The returned DataStore is merged into env.DataStore before // GetDeployChainContractsCfg is called. - PreDeployContractsForSelector(ctx context.Context, env *deployment.Environment, selector uint64, topology *offchain.EnvironmentTopology) (datastore.DataStore, error) + PreDeployContractsForSelector(ctx context.Context, env *deployment.Environment, selector uint64, topology *ccvdeployment.EnvironmentTopology) (datastore.DataStore, error) // GetDeployChainContractsCfg returns the per-chain configuration for the // common DeployChainContracts changeset. Called after Pre, so env.DataStore // includes pre-deployed addresses (e.g. CREATE2 factory). - GetDeployChainContractsCfg(env *deployment.Environment, selector uint64, topology *offchain.EnvironmentTopology) (ccipChangesets.DeployChainContractsPerChainCfg, error) + GetDeployChainContractsCfg(env *deployment.Environment, selector uint64, topology *ccvdeployment.EnvironmentTopology) (ccipChangesets.DeployChainContractsPerChainCfg, error) // PostDeployContractsForSelector runs chain-specific setup after the common // DeployChainContracts call (e.g. deploying USDC/Lombard token pools on EVM). // The returned DataStore is merged into the final result. - PostDeployContractsForSelector(ctx context.Context, env *deployment.Environment, selector uint64, topology *offchain.EnvironmentTopology) (datastore.DataStore, error) + PostDeployContractsForSelector(ctx context.Context, env *deployment.Environment, selector uint64, topology *ccvdeployment.EnvironmentTopology) (datastore.DataStore, error) // GetConnectionProfile returns a ChainDefinition describing this chain as a // lane destination, plus the default committee verifier config to apply for // each remote chain. The environment uses profiles from all chains to diff --git a/build/devenv/common/common.go b/build/devenv/common/common.go index b38df125f..9dec7bf0f 100644 --- a/build/devenv/common/common.go +++ b/build/devenv/common/common.go @@ -8,8 +8,7 @@ import ( "github.com/smartcontractkit/chainlink-deployments-framework/datastore" - "github.com/smartcontractkit/chainlink-ccip/deployment/v2_0_0/offchain" - + ccvdeployment "github.com/smartcontractkit/chainlink-ccv/deployment" "github.com/smartcontractkit/chainlink-ccv/protocol" ) @@ -237,7 +236,7 @@ func All17TokenCombinations() []TokenCombination { // - LockRelease pairs with BurnMint (in both directions) func ComputeTokenCombinations( capabilities map[uint64][]PoolCapability, - topology *offchain.EnvironmentTopology, + topology *ccvdeployment.EnvironmentTopology, ) []TokenCombination { // Collect the set of distinct pool capabilities across all chains. type capKey struct { @@ -357,7 +356,7 @@ func newTokenCombination(localType, localVersion string, localCCVs []string, rem // ccvQualifierPermutations returns the set of CCV qualifier slices to exercise, // derived from the topology's available committees. It always includes the // empty-qualifier case (no explicit CCVs) for pools that support it. -func ccvQualifierPermutations(topology *offchain.EnvironmentTopology) [][]string { +func ccvQualifierPermutations(topology *ccvdeployment.EnvironmentTopology) [][]string { result := [][]string{ {}, // no explicit CCVs } @@ -384,7 +383,7 @@ func ccvQualifierPermutations(topology *offchain.EnvironmentTopology) [][]string } // qualifiersAvailable returns true if all qualifiers exist as committees in the topology. -func qualifiersAvailable(qualifiers []string, topology *offchain.EnvironmentTopology) bool { +func qualifiersAvailable(qualifiers []string, topology *ccvdeployment.EnvironmentTopology) bool { if topology == nil || topology.NOPTopology == nil { return len(qualifiers) == 0 } @@ -401,7 +400,7 @@ func qualifiersAvailable(qualifiers []string, topology *offchain.EnvironmentTopo // as the local chain and selectors[1:] as candidate remotes, and the filter keeps only // combinations whose declared local->remote orientation exists in the datastore. // Pass ds nil to skip the datastore check. -func FilterTokenCombinations(combos []TokenCombination, topology *offchain.EnvironmentTopology, ds datastore.DataStore, selectors []uint64) []TokenCombination { +func FilterTokenCombinations(combos []TokenCombination, topology *ccvdeployment.EnvironmentTopology, ds datastore.DataStore, selectors []uint64) []TokenCombination { filtered := make([]TokenCombination, 0, len(combos)) for _, combo := range combos { if !qualifiersAvailable(combo.LocalPoolCCVQualifiers(), topology) || diff --git a/build/devenv/environment.go b/build/devenv/environment.go index 932a36e09..0b1f5538b 100644 --- a/build/devenv/environment.go +++ b/build/devenv/environment.go @@ -26,7 +26,6 @@ import ( "github.com/smartcontractkit/chainlink-ccv/build/devenv/cciptestinterfaces" devenvcommon "github.com/smartcontractkit/chainlink-ccv/build/devenv/common" "github.com/smartcontractkit/chainlink-ccv/build/devenv/jobs" - "github.com/smartcontractkit/chainlink-ccv/build/devenv/offchainloader" "github.com/smartcontractkit/chainlink-ccv/build/devenv/services" "github.com/smartcontractkit/chainlink-ccv/build/devenv/services/chainconfig" "github.com/smartcontractkit/chainlink-ccv/build/devenv/services/committeeverifier" @@ -1109,7 +1108,7 @@ func NewEnvironment() (in *Cfg, err error) { capsBySelector[networkInfo.ChainSelector] = nil } } - combos := devenvcommon.ComputeTokenCombinations(capsBySelector, convertTopologyToCCIP(topology)) + combos := devenvcommon.ComputeTokenCombinations(capsBySelector, topology) ds := datastore.NewMemoryDataStore() for i, impl := range impls { @@ -1256,7 +1255,7 @@ func NewEnvironment() (in *Cfg, err error) { } // Get generated config from output datastore - aggCfg, err := offchainloader.GetAggregatorConfig(output.DataStore.Seal(), instanceName+"-aggregator") + aggCfg, err := ccvdeployment.GetAggregatorConfig(output.DataStore.Seal(), instanceName+"-aggregator") if err != nil { return nil, fmt.Errorf("failed to get aggregator config from output: %w", err) } @@ -1297,7 +1296,7 @@ func NewEnvironment() (in *Cfg, err error) { return nil, fmt.Errorf("failed to generate indexer config: %w", err) } - idxCfg, err := offchainloader.GetIndexerConfig(output.DataStore.Seal(), "indexer") + idxCfg, err := ccvdeployment.GetIndexerConfig(output.DataStore.Seal(), "indexer") if err != nil { return nil, fmt.Errorf("failed to get indexer config from output: %w", err) } @@ -1537,7 +1536,7 @@ func NewEnvironment() (in *Cfg, err error) { } // Get generated config from output datastore - tokenVerifierCfg, err := offchainloader.GetTokenVerifierConfig( + tokenVerifierCfg, err := ccvdeployment.GetTokenVerifierConfig( output.DataStore.Seal(), "TokenVerifier", ) if err != nil { diff --git a/build/devenv/evm/impl.go b/build/devenv/evm/impl.go index dbdc5b302..fdf631ad7 100644 --- a/build/devenv/evm/impl.go +++ b/build/devenv/evm/impl.go @@ -56,9 +56,9 @@ import ( "github.com/smartcontractkit/chainlink-ccip/chains/evm/deployment/v1_6_0/operations/rmn_remote" "github.com/smartcontractkit/chainlink-ccip/deployment/v2_0_0/adapters" ccipChangesets "github.com/smartcontractkit/chainlink-ccip/deployment/v2_0_0/changesets" - ccipOffchain "github.com/smartcontractkit/chainlink-ccip/deployment/v2_0_0/offchain" "github.com/smartcontractkit/chainlink-ccv/build/devenv/cciptestinterfaces" devenvcommon "github.com/smartcontractkit/chainlink-ccv/build/devenv/common" + ccvdeployment "github.com/smartcontractkit/chainlink-ccv/deployment" "github.com/smartcontractkit/chainlink-ccv/protocol" "github.com/smartcontractkit/chainlink-ccv/verifier/pkg/token/lombard" "github.com/smartcontractkit/chainlink-deployments-framework/chain/evm" @@ -951,7 +951,7 @@ func (m *CCIP17EVMConfig) ConfigureNodes(ctx context.Context, bc *blockchain.Inp // For each committee qualifier in the topology, a receiver requiring that committee's // verifier is created. Multi-committee receivers (requiring one committee with optional // verifiers from others) are only created when all referenced committees exist. -func buildMockReceivers(topology *ccipOffchain.EnvironmentTopology, selector uint64) []adapters.MockReceiverDeployParams { +func buildMockReceivers(topology *ccvdeployment.EnvironmentTopology, selector uint64) []adapters.MockReceiverDeployParams { has := func(q string) bool { _, ok := topology.NOPTopology.Committees[q] return ok @@ -1015,7 +1015,7 @@ func buildMockReceivers(topology *ccipOffchain.EnvironmentTopology, selector uin return receivers } -func (m *CCIP17EVMConfig) PreDeployContractsForSelector(_ context.Context, env *deployment.Environment, selector uint64, _ *ccipOffchain.EnvironmentTopology) (datastore.DataStore, error) { +func (m *CCIP17EVMConfig) PreDeployContractsForSelector(_ context.Context, env *deployment.Environment, selector uint64, _ *ccvdeployment.EnvironmentTopology) (datastore.DataStore, error) { m.logger.Info().Uint64("Selector", selector).Msg("EVM pre-deploy: deploying CREATE2 factory") create2FactoryRep, err := operations.ExecuteOperation(env.OperationsBundle, create2_factory.Deploy, env.BlockChains.EVMChains()[selector], @@ -1037,7 +1037,7 @@ func (m *CCIP17EVMConfig) PreDeployContractsForSelector(_ context.Context, env * return ds.Seal(), nil } -func (m *CCIP17EVMConfig) GetDeployChainContractsCfg(env *deployment.Environment, selector uint64, topology *ccipOffchain.EnvironmentTopology) (ccipChangesets.DeployChainContractsPerChainCfg, error) { +func (m *CCIP17EVMConfig) GetDeployChainContractsCfg(env *deployment.Environment, selector uint64, topology *ccvdeployment.EnvironmentTopology) (ccipChangesets.DeployChainContractsPerChainCfg, error) { create2Ref, err := env.DataStore.Addresses().Get( datastore.NewAddressRefKey(selector, datastore.ContractType(create2_factory.ContractType), create2_factory.Version, ""), ) @@ -1104,7 +1104,7 @@ func (m *CCIP17EVMConfig) GetDeployChainContractsCfg(env *deployment.Environment }, nil } -func (m *CCIP17EVMConfig) PostDeployContractsForSelector(_ context.Context, env *deployment.Environment, selector uint64, _ *ccipOffchain.EnvironmentTopology) (datastore.DataStore, error) { +func (m *CCIP17EVMConfig) PostDeployContractsForSelector(_ context.Context, env *deployment.Environment, selector uint64, _ *ccvdeployment.EnvironmentTopology) (datastore.DataStore, error) { m.logger.Info().Uint64("Selector", selector).Msg("EVM post-deploy: deploying USDC and Lombard token pools") create2Ref, err := env.DataStore.Addresses().Get( @@ -1255,7 +1255,7 @@ func (m *CCIP17EVMConfig) GetTokenTransferConfigs( env *deployment.Environment, selector uint64, remoteSelectors []uint64, - topology *ccipOffchain.EnvironmentTopology, + topology *ccvdeployment.EnvironmentTopology, ) ([]tokenscore.TokenTransferConfig, error) { applicableCombos := devenvcommon.FilterTokenCombinations( devenvcommon.AllTokenCombinations(), topology, env.DataStore, append([]uint64{selector}, remoteSelectors...), diff --git a/build/devenv/implcommon.go b/build/devenv/implcommon.go index 6c48cf48e..17df44b54 100644 --- a/build/devenv/implcommon.go +++ b/build/devenv/implcommon.go @@ -60,10 +60,8 @@ func DeployContractsForSelector( operations.NewMemoryReporter(), ) - ccipTopology := convertTopologyToCCIP(topology) - // 1. Pre-hook (e.g. EVM deploys CREATE2 factory here). - preDS, err := impl.PreDeployContractsForSelector(ctx, env, selector, ccipTopology) + preDS, err := impl.PreDeployContractsForSelector(ctx, env, selector, topology) if err != nil { return nil, fmt.Errorf("pre-deploy for selector %d: %w", selector, err) } @@ -79,12 +77,13 @@ func DeployContractsForSelector( } // 2. Get chain-specific config (reads pre-deployed addresses from env.DataStore). - cfg, err := impl.GetDeployChainContractsCfg(env, selector, ccipTopology) + cfg, err := impl.GetDeployChainContractsCfg(env, selector, topology) if err != nil { return nil, fmt.Errorf("get deploy config for selector %d: %w", selector, err) } // 3. Call the tooling API changeset. + ccipTopology := convertTopologyToCCIP(topology) registry := ccipAdapters.GetDeployChainContractsRegistry() out, err := ccipChangesets.DeployChainContracts(registry).Apply(*env, changesetscore.WithMCMS[ccipChangesets.DeployChainContractsCfg]{ Cfg: ccipChangesets.DeployChainContractsCfg{ @@ -107,7 +106,7 @@ func DeployContractsForSelector( env.DataStore = merged // 4. Post-hook (e.g. EVM deploys USDC/Lombard pools here). - postDS, err := impl.PostDeployContractsForSelector(ctx, env, selector, ccipTopology) + postDS, err := impl.PostDeployContractsForSelector(ctx, env, selector, topology) if err != nil { return nil, fmt.Errorf("post-deploy for selector %d: %w", selector, err) } @@ -557,7 +556,7 @@ func ConfigureAllTokenTransfers( } } - cfgs, err := tcp.GetTokenTransferConfigs(env, selectors[i], remoteSelectors, convertTopologyToCCIP(topology)) + cfgs, err := tcp.GetTokenTransferConfigs(env, selectors[i], remoteSelectors, topology) if err != nil { return fmt.Errorf("get token transfer configs for selector %d: %w", selectors[i], err) } diff --git a/build/devenv/offchainloader/loader.go b/build/devenv/offchainloader/loader.go deleted file mode 100644 index e97e79a84..000000000 --- a/build/devenv/offchainloader/loader.go +++ /dev/null @@ -1,174 +0,0 @@ -package offchainloader - -import ( - "github.com/smartcontractkit/chainlink-ccv/aggregator/pkg/model" - ccvdeployment "github.com/smartcontractkit/chainlink-ccv/deployment" - "github.com/smartcontractkit/chainlink-ccv/indexer/pkg/config" - "github.com/smartcontractkit/chainlink-ccv/pkg/chainaccess" - "github.com/smartcontractkit/chainlink-ccv/protocol" - verifier "github.com/smartcontractkit/chainlink-ccv/verifier/pkg" - "github.com/smartcontractkit/chainlink-ccv/verifier/pkg/token" - "github.com/smartcontractkit/chainlink-ccv/verifier/pkg/token/cctp" - "github.com/smartcontractkit/chainlink-ccv/verifier/pkg/token/lombard" - "github.com/smartcontractkit/chainlink-deployments-framework/datastore" -) - -func GetAggregatorConfig(ds datastore.DataStore, id string) (*model.Committee, error) { - ccvCfg, err := ccvdeployment.GetAggregatorConfig(ds, id) - if err != nil { - return nil, err - } - return convertCommittee(ccvCfg), nil -} - -func GetIndexerConfig(ds datastore.DataStore, id string) (*config.GeneratedConfig, error) { - ccvCfg, err := ccvdeployment.GetIndexerConfig(ds, id) - if err != nil { - return nil, err - } - return convertIndexerConfig(ccvCfg), nil -} - -func GetTokenVerifierConfig(ds datastore.DataStore, id string) (*token.Config, error) { - ccvCfg, err := ccvdeployment.GetTokenVerifierConfig(ds, id) - if err != nil { - return nil, err - } - return convertTokenVerifierConfig(ccvCfg), nil -} - -func convertCommittee(src *ccvdeployment.Committee) *model.Committee { - if src == nil { - return nil - } - dst := &model.Committee{ - DestinationVerifiers: src.DestinationVerifiers, - } - if src.QuorumConfigs != nil { - dst.QuorumConfigs = make(map[model.SourceSelector]*model.QuorumConfig, len(src.QuorumConfigs)) - for k, qc := range src.QuorumConfigs { - dst.QuorumConfigs[k] = convertQuorumConfig(qc) - } - } - return dst -} - -func convertQuorumConfig(src *ccvdeployment.QuorumConfig) *model.QuorumConfig { - if src == nil { - return nil - } - signers := make([]model.Signer, len(src.Signers)) - for i, s := range src.Signers { - signers[i] = model.Signer{Address: s.Address} - } - return &model.QuorumConfig{ - SourceVerifierAddress: src.SourceVerifierAddress, - Signers: signers, - Threshold: src.Threshold, - } -} - -func convertIndexerConfig(src *ccvdeployment.IndexerGeneratedConfig) *config.GeneratedConfig { - if src == nil { - return nil - } - verifiers := make([]config.GeneratedVerifierConfig, len(src.Verifiers)) - for i, v := range src.Verifiers { - verifiers[i] = config.GeneratedVerifierConfig{ - Name: v.Name, - IssuerAddresses: v.IssuerAddresses, - } - } - return &config.GeneratedConfig{Verifier: verifiers} -} - -func convertTokenVerifierConfig(src *ccvdeployment.TokenVerifierGeneratedConfig) *token.Config { - if src == nil { - return nil - } - dst := &token.Config{ - PyroscopeURL: src.PyroscopeURL, - CommitteeConfig: chainaccess.CommitteeConfig{ - OnRampAddresses: src.OnRampAddresses, - RMNRemoteAddresses: src.RMNRemoteAddresses, - }, - Monitoring: verifier.MonitoringConfig{ - Enabled: src.Monitoring.Enabled, - Type: src.Monitoring.Type, - Beholder: verifier.BeholderConfig{ - InsecureConnection: src.Monitoring.Beholder.InsecureConnection, - CACertFile: src.Monitoring.Beholder.CACertFile, - OtelExporterGRPCEndpoint: src.Monitoring.Beholder.OtelExporterGRPCEndpoint, - OtelExporterHTTPEndpoint: src.Monitoring.Beholder.OtelExporterHTTPEndpoint, - LogStreamingEnabled: src.Monitoring.Beholder.LogStreamingEnabled, - MetricReaderInterval: src.Monitoring.Beholder.MetricReaderInterval, - TraceSampleRatio: src.Monitoring.Beholder.TraceSampleRatio, - TraceBatchTimeout: src.Monitoring.Beholder.TraceBatchTimeout, - }, - }, - } - dst.TokenVerifiers = make([]token.VerifierConfig, len(src.TokenVerifiers)) - for i, tv := range src.TokenVerifiers { - vc := token.VerifierConfig{ - VerifierID: tv.VerifierID, - Type: tv.Type, - Version: tv.Version, - } - if tv.CCTP != nil { - vc.CCTPConfig = convertCCTPConfig(tv.CCTP) - } - if tv.Lombard != nil { - vc.LombardConfig = convertLombardConfig(tv.Lombard) - } - dst.TokenVerifiers[i] = vc - } - return dst -} - -func convertCCTPConfig(src *ccvdeployment.CCTPVerifierConfig) *cctp.CCTPConfig { - if src == nil { - return nil - } - dst := &cctp.CCTPConfig{ - AttestationAPI: src.AttestationAPI, - AttestationAPITimeout: src.AttestationAPITimeout, - AttestationAPIInterval: src.AttestationAPIInterval, - AttestationAPICooldown: src.AttestationAPICooldown, - VerifierVersion: protocol.ByteSlice(src.VerifierVersion), - } - if src.Verifiers != nil { - dst.Verifiers = toAnyMap(src.Verifiers) - } - if src.VerifierResolvers != nil { - dst.VerifierResolvers = toAnyMap(src.VerifierResolvers) - } - return dst -} - -func convertLombardConfig(src *ccvdeployment.LombardVerifierConfig) *lombard.LombardConfig { - if src == nil { - return nil - } - dst := &lombard.LombardConfig{ - AttestationAPI: src.AttestationAPI, - AttestationAPITimeout: src.AttestationAPITimeout, - AttestationAPIInterval: src.AttestationAPIInterval, - AttestationAPIBatchSize: src.AttestationAPIBatchSize, - VerifierVersion: protocol.ByteSlice(src.VerifierVersion), - } - if src.VerifierResolvers != nil { - dst.VerifierResolvers = toAnyMap(src.VerifierResolvers) - } - return dst -} - -func toAnyMap(src map[string]string) map[string]any { - if src == nil { - return nil - } - dst := make(map[string]any, len(src)) - for k, v := range src { - dst[k] = v - } - return dst -} diff --git a/build/devenv/services/committeeverifier/base.go b/build/devenv/services/committeeverifier/base.go index 808be22f8..4c5592523 100644 --- a/build/devenv/services/committeeverifier/base.go +++ b/build/devenv/services/committeeverifier/base.go @@ -405,7 +405,7 @@ func baseImageRequest(in *Input, envVars map[string]string, bootstrapConfigFileP } req.Mounts = testcontainers.Mounts() - req.Mounts = append(req.Mounts, testcontainers.BindMount( //nolint:staticcheck // we're still using it... + req.Mounts = append(req.Mounts, testcontainers.BindMount( bootstrapConfigFilePath, bootstrap.DefaultConfigPath, )) diff --git a/build/devenv/services/common.go b/build/devenv/services/common.go index 403764519..004c71bc4 100644 --- a/build/devenv/services/common.go +++ b/build/devenv/services/common.go @@ -46,7 +46,7 @@ func GoSourcePathMounts(rootPath, containerDirTarget string) testcontainers.Cont mounts := make([]testcontainers.ContainerMount, 0, 1) mounts = append(mounts, - testcontainers.BindMount( //nolint:staticcheck // we're still using it... + testcontainers.BindMount( absRootPath, testcontainers.ContainerMountTarget(containerDirTarget), ), @@ -79,11 +79,11 @@ func GoCacheMounts() testcontainers.ContainerMounts { goBuildCachePath = filepath.Join(homeDir, ".cache", "go-build") } mounts = append(mounts, - testcontainers.BindMount( //nolint:staticcheck // we're still using it... + testcontainers.BindMount( goModCachePath, "/go/pkg/mod", ), - testcontainers.BindMount( //nolint:staticcheck // we're still using it... + testcontainers.BindMount( goBuildCachePath, "/root/.cache/go-build", ), diff --git a/build/devenv/services/executor.go b/build/devenv/services/executor.go index 7c556e6db..bb4366d0e 100644 --- a/build/devenv/services/executor.go +++ b/build/devenv/services/executor.go @@ -184,7 +184,7 @@ func NewExecutor(in *ExecutorInput, blockchainOutputs []*ctfblockchain.Output) ( }, } - req.Mounts = append(req.Mounts, testcontainers.BindMount( //nolint:staticcheck // we're still using it... + req.Mounts = append(req.Mounts, testcontainers.BindMount( configFilePath, executor.DefaultConfigFile, )) diff --git a/build/devenv/services/executor/base.go b/build/devenv/services/executor/base.go index f750a9750..c39ed46f3 100644 --- a/build/devenv/services/executor/base.go +++ b/build/devenv/services/executor/base.go @@ -269,7 +269,7 @@ func NewStandalone(in *Input, blockchainOutputs []*ctfblockchain.Output) (*Outpu }, } - req.Mounts = append(req.Mounts, testcontainers.BindMount( //nolint:staticcheck + req.Mounts = append(req.Mounts, testcontainers.BindMount( configFilePath, executorpkg.DefaultConfigFile, )) @@ -495,7 +495,7 @@ func baseImageRequest(in *Input, envVars map[string]string, bootstrapConfigFileP } req.Mounts = testcontainers.Mounts() - req.Mounts = append(req.Mounts, testcontainers.BindMount( //nolint:staticcheck + req.Mounts = append(req.Mounts, testcontainers.BindMount( bootstrapConfigFilePath, bootstrap.DefaultConfigPath, )) diff --git a/build/devenv/services/tokenVerifier.go b/build/devenv/services/tokenVerifier.go index db5dde495..bb3884dcd 100644 --- a/build/devenv/services/tokenVerifier.go +++ b/build/devenv/services/tokenVerifier.go @@ -156,7 +156,7 @@ func NewTokenVerifier(in *TokenVerifierInput, blockchainOutputs []*blockchain.Ou } req.Mounts = testcontainers.Mounts() - req.Mounts = append(req.Mounts, testcontainers.BindMount( //nolint:staticcheck // we're still using it... + req.Mounts = append(req.Mounts, testcontainers.BindMount( configFilePath, aggregator.DefaultConfigFile, // TODO: switch to token verifier path, not aggregator path. )) diff --git a/deployment/aggregator.go b/deployment/aggregator.go deleted file mode 100644 index d6701d92f..000000000 --- a/deployment/aggregator.go +++ /dev/null @@ -1,20 +0,0 @@ -package deployment - -type SourceSelector = string - -type DestinationSelector = string - -type Signer struct { - Address string `json:"address"` -} - -type QuorumConfig struct { - SourceVerifierAddress string `json:"sourceVerifierAddress"` - Signers []Signer `json:"signers"` - Threshold uint8 `json:"threshold"` -} - -type Committee struct { - QuorumConfigs map[SourceSelector]*QuorumConfig `json:"quorumConfigs"` - DestinationVerifiers map[DestinationSelector]string `json:"destinationVerifiers"` -} diff --git a/deployment/changesets/apply_executor_config.go b/deployment/changesets/apply_executor_config.go index fff126381..d364f8bab 100644 --- a/deployment/changesets/apply_executor_config.go +++ b/deployment/changesets/apply_executor_config.go @@ -349,7 +349,7 @@ func buildExecutorJobSpecs( ReaderCacheExpiry: pool.ReaderCacheExpiry, MaxRetryDuration: pool.MaxRetryDuration, WorkerCount: pool.WorkerCount, - Monitoring: toExecutorMonitoring(monitoring), + Monitoring: monitoring, ChainConfiguration: chainCfgs, } @@ -376,23 +376,6 @@ executorConfig = ''' return jobSpecs, scope, nil } -func toExecutorMonitoring(m ccvdeployment.MonitoringConfig) executor.MonitoringConfig { - return executor.MonitoringConfig{ - Enabled: m.Enabled, - Type: m.Type, - Beholder: executor.BeholderConfig{ - InsecureConnection: m.Beholder.InsecureConnection, - CACertFile: m.Beholder.CACertFile, - OtelExporterGRPCEndpoint: m.Beholder.OtelExporterGRPCEndpoint, - OtelExporterHTTPEndpoint: m.Beholder.OtelExporterHTTPEndpoint, - LogStreamingEnabled: m.Beholder.LogStreamingEnabled, - MetricReaderInterval: m.Beholder.MetricReaderInterval, - TraceSampleRatio: m.Beholder.TraceSampleRatio, - TraceBatchTimeout: m.Beholder.TraceBatchTimeout, - }, - } -} - func buildNOPModes(nops []ccvdeployment.NOPConfig) map[shared.NOPAlias]shared.NOPMode { nopModes := make(map[shared.NOPAlias]shared.NOPMode) for _, nop := range nops { diff --git a/deployment/changesets/apply_verifier_config.go b/deployment/changesets/apply_verifier_config.go index d7886e060..c846496fa 100644 --- a/deployment/changesets/apply_verifier_config.go +++ b/deployment/changesets/apply_verifier_config.go @@ -13,7 +13,6 @@ import ( "github.com/smartcontractkit/chainlink-ccv/pkg/chainaccess" "github.com/smartcontractkit/chainlink-ccv/verifier/pkg/commit" - vtypes "github.com/smartcontractkit/chainlink-ccv/verifier/pkg/vtypes" ccvdeployment "github.com/smartcontractkit/chainlink-ccv/deployment" "github.com/smartcontractkit/chainlink-ccv/deployment/adapters" @@ -338,7 +337,7 @@ func buildVerifierJobSpecs( CommitteeVerifierAddresses: filterAddressesByChains(committeeVerifierAddrs, nopChains), DefaultExecutorOnRampAddresses: filterAddressesByChains(executorOnRampAddrs, nopChains), DisableFinalityCheckers: sortedFinalityCheckers, - Monitoring: toVerifierMonitoring(monitoring), + Monitoring: monitoring, CommitteeConfig: chainaccess.CommitteeConfig{ OnRampAddresses: filterAddressesByChains(onRampAddrs, nopChains), RMNRemoteAddresses: filterAddressesByChains(rmnRemoteAddrs, nopChains), @@ -369,23 +368,6 @@ committeeVerifierConfig = ''' return jobSpecs, scope, nil } -func toVerifierMonitoring(m ccvdeployment.MonitoringConfig) vtypes.MonitoringConfig { - return vtypes.MonitoringConfig{ - Enabled: m.Enabled, - Type: m.Type, - Beholder: vtypes.BeholderConfig{ - InsecureConnection: m.Beholder.InsecureConnection, - CACertFile: m.Beholder.CACertFile, - OtelExporterGRPCEndpoint: m.Beholder.OtelExporterGRPCEndpoint, - OtelExporterHTTPEndpoint: m.Beholder.OtelExporterHTTPEndpoint, - LogStreamingEnabled: m.Beholder.LogStreamingEnabled, - MetricReaderInterval: m.Beholder.MetricReaderInterval, - TraceSampleRatio: m.Beholder.TraceSampleRatio, - TraceBatchTimeout: m.Beholder.TraceBatchTimeout, - }, - } -} - // fetchSigningKeysForNOPs fetches signing keys from JD for NOPs that are missing a signer // address for the given signerFamily. func fetchSigningKeysForNOPs( diff --git a/deployment/changesets/generate_aggregator_config.go b/deployment/changesets/generate_aggregator_config.go index d26432e24..d3f7c02c7 100644 --- a/deployment/changesets/generate_aggregator_config.go +++ b/deployment/changesets/generate_aggregator_config.go @@ -9,6 +9,7 @@ import ( "github.com/smartcontractkit/chainlink-deployments-framework/datastore" "github.com/smartcontractkit/chainlink-deployments-framework/deployment" + "github.com/smartcontractkit/chainlink-ccv/aggregator/pkg/model" ccvdeployment "github.com/smartcontractkit/chainlink-ccv/deployment" "github.com/smartcontractkit/chainlink-ccv/deployment/adapters" ) @@ -94,7 +95,7 @@ func buildAggregatorCommittee( registry *adapters.Registry, committeeQualifier string, chainSelectors []uint64, -) (*ccvdeployment.Committee, error) { +) (*model.Committee, error) { ctx := context.Background() type chainQualifier struct { @@ -144,7 +145,7 @@ func buildAggregatorCommittee( return nil, fmt.Errorf("failed to build destination verifiers: %w", err) } - return &ccvdeployment.Committee{ + return &model.Committee{ QuorumConfigs: quorumConfigs, DestinationVerifiers: destVerifiers, }, nil @@ -156,13 +157,13 @@ func buildQuorumConfigs( committeeStates []*adapters.CommitteeState, committeeQualifier string, chainSelectors []uint64, -) (map[string]*ccvdeployment.QuorumConfig, error) { +) (map[string]*model.QuorumConfig, error) { supportedChains := make(map[uint64]bool, len(chainSelectors)) for _, sel := range chainSelectors { supportedChains[sel] = true } - quorumConfigs := make(map[string]*ccvdeployment.QuorumConfig) + quorumConfigs := make(map[string]*model.QuorumConfig) for _, state := range committeeStates { for _, sigConfig := range state.SignatureConfigs { @@ -191,12 +192,12 @@ func buildQuorumConfigs( return nil, fmt.Errorf("failed to resolve source verifier for chain %d: %w", sigConfig.SourceChainSelector, err) } - signers := make([]ccvdeployment.Signer, 0, len(sigConfig.Signers)) + signers := make([]model.Signer, 0, len(sigConfig.Signers)) for _, addr := range sigConfig.Signers { - signers = append(signers, ccvdeployment.Signer{Address: addr}) + signers = append(signers, model.Signer{Address: addr}) } - quorumConfigs[chainSelectorStr] = &ccvdeployment.QuorumConfig{ + quorumConfigs[chainSelectorStr] = &model.QuorumConfig{ SourceVerifierAddress: sourceVerifierAddr, Signers: signers, Threshold: sigConfig.Threshold, @@ -208,7 +209,7 @@ func buildQuorumConfigs( } func validateSignatureConfigConsistency( - existing *ccvdeployment.QuorumConfig, + existing *model.QuorumConfig, newSig adapters.SignatureConfig, chainSelectorStr string, committeeQualifier string, diff --git a/deployment/changesets/generate_indexer_config.go b/deployment/changesets/generate_indexer_config.go index 4a272bcfd..0907c0b93 100644 --- a/deployment/changesets/generate_indexer_config.go +++ b/deployment/changesets/generate_indexer_config.go @@ -10,6 +10,7 @@ import ( ccvdeployment "github.com/smartcontractkit/chainlink-ccv/deployment" "github.com/smartcontractkit/chainlink-ccv/deployment/adapters" + indexerconfig "github.com/smartcontractkit/chainlink-ccv/indexer/pkg/config" ) type GenerateIndexerConfigInput struct { @@ -136,8 +137,8 @@ func collectVerifierAddresses( return addresses, nil } -func toIndexerGeneratedConfig(verifierMap map[string][]string) *ccvdeployment.IndexerGeneratedConfig { - verifiers := make([]ccvdeployment.IndexerVerifierConfig, 0, len(verifierMap)) +func toIndexerGeneratedConfig(verifierMap map[string][]string) *indexerconfig.GeneratedConfig { + verifiers := make([]indexerconfig.GeneratedVerifierConfig, 0, len(verifierMap)) names := make([]string, 0, len(verifierMap)) for name := range verifierMap { @@ -155,13 +156,13 @@ func toIndexerGeneratedConfig(verifierMap map[string][]string) *ccvdeployment.In unique = append(unique, addr) } } - verifiers = append(verifiers, ccvdeployment.IndexerVerifierConfig{ + verifiers = append(verifiers, indexerconfig.GeneratedVerifierConfig{ Name: name, IssuerAddresses: unique, }) } - return &ccvdeployment.IndexerGeneratedConfig{ - Verifiers: verifiers, + return &indexerconfig.GeneratedConfig{ + Verifier: verifiers, } } diff --git a/deployment/changesets/generate_token_verifier_config.go b/deployment/changesets/generate_token_verifier_config.go index 971faa883..3b42a4856 100644 --- a/deployment/changesets/generate_token_verifier_config.go +++ b/deployment/changesets/generate_token_verifier_config.go @@ -10,6 +10,12 @@ import ( "github.com/smartcontractkit/chainlink-deployments-framework/datastore" "github.com/smartcontractkit/chainlink-deployments-framework/deployment" + "github.com/smartcontractkit/chainlink-ccv/pkg/chainaccess" + "github.com/smartcontractkit/chainlink-ccv/protocol" + "github.com/smartcontractkit/chainlink-ccv/verifier/pkg/token" + "github.com/smartcontractkit/chainlink-ccv/verifier/pkg/token/cctp" + "github.com/smartcontractkit/chainlink-ccv/verifier/pkg/token/lombard" + ccvdeployment "github.com/smartcontractkit/chainlink-ccv/deployment" "github.com/smartcontractkit/chainlink-ccv/deployment/adapters" "github.com/smartcontractkit/chainlink-ccv/deployment/shared" @@ -125,25 +131,14 @@ func GenerateTokenVerifierConfig(registry *adapters.Registry) deployment.ChangeS } } - config := &ccvdeployment.TokenVerifierGeneratedConfig{ - PyroscopeURL: cfg.PyroscopeURL, - OnRampAddresses: onRampAddresses, - RMNRemoteAddresses: rmnRemoteAddresses, - TokenVerifiers: []ccvdeployment.TokenVerifierEntry{}, - Monitoring: ccvdeployment.TokenVerifierMonitoringConfig{ - Enabled: cfg.Monitoring.Enabled, - Type: cfg.Monitoring.Type, - Beholder: ccvdeployment.TokenVerifierBeholderConfig{ - InsecureConnection: cfg.Monitoring.Beholder.InsecureConnection, - CACertFile: cfg.Monitoring.Beholder.CACertFile, - OtelExporterGRPCEndpoint: cfg.Monitoring.Beholder.OtelExporterGRPCEndpoint, - OtelExporterHTTPEndpoint: cfg.Monitoring.Beholder.OtelExporterHTTPEndpoint, - LogStreamingEnabled: cfg.Monitoring.Beholder.LogStreamingEnabled, - MetricReaderInterval: cfg.Monitoring.Beholder.MetricReaderInterval, - TraceSampleRatio: cfg.Monitoring.Beholder.TraceSampleRatio, - TraceBatchTimeout: cfg.Monitoring.Beholder.TraceBatchTimeout, - }, + tvConfig := &token.Config{ + PyroscopeURL: cfg.PyroscopeURL, + CommitteeConfig: chainaccess.CommitteeConfig{ + OnRampAddresses: onRampAddresses, + RMNRemoteAddresses: rmnRemoteAddresses, }, + TokenVerifiers: []token.VerifierConfig{}, + Monitoring: cfg.Monitoring, } if len(cctpVerifierAddresses) > 0 { @@ -151,18 +146,18 @@ func GenerateTokenVerifierConfig(registry *adapters.Registry) deployment.ChangeS if cctpVerifierID == "" { cctpVerifierID = fmt.Sprintf("cctp-%s", cctpCfg.Qualifier) } - config.TokenVerifiers = append(config.TokenVerifiers, ccvdeployment.TokenVerifierEntry{ + tvConfig.TokenVerifiers = append(tvConfig.TokenVerifiers, token.VerifierConfig{ VerifierID: cctpVerifierID, Type: "cctp", Version: "2.0", - CCTP: &ccvdeployment.CCTPVerifierConfig{ + CCTPConfig: &cctp.CCTPConfig{ AttestationAPI: cctpCfg.AttestationAPI, AttestationAPITimeout: cctpCfg.AttestationAPITimeout, AttestationAPIInterval: cctpCfg.AttestationAPIInterval, AttestationAPICooldown: cctpCfg.AttestationAPICooldown, - VerifierVersion: cctpCfg.VerifierVersion, - Verifiers: cctpVerifierAddresses, - VerifierResolvers: cctpVerifierResolverAddresses, + VerifierVersion: protocol.ByteSlice(cctpCfg.VerifierVersion), + Verifiers: stringsToAnyMap(cctpVerifierAddresses), + VerifierResolvers: stringsToAnyMap(cctpVerifierResolverAddresses), }, }) } @@ -172,17 +167,17 @@ func GenerateTokenVerifierConfig(registry *adapters.Registry) deployment.ChangeS if lombardVerifierID == "" { lombardVerifierID = fmt.Sprintf("lombard-%s", lombardCfg.Qualifier) } - config.TokenVerifiers = append(config.TokenVerifiers, ccvdeployment.TokenVerifierEntry{ + tvConfig.TokenVerifiers = append(tvConfig.TokenVerifiers, token.VerifierConfig{ VerifierID: lombardVerifierID, Type: "lombard", Version: "1.0", - Lombard: &ccvdeployment.LombardVerifierConfig{ + LombardConfig: &lombard.LombardConfig{ AttestationAPI: lombardCfg.AttestationAPI, AttestationAPITimeout: lombardCfg.AttestationAPITimeout, AttestationAPIInterval: lombardCfg.AttestationAPIInterval, AttestationAPIBatchSize: lombardCfg.AttestationAPIBatchSize, - VerifierVersion: lombardCfg.VerifierVersion, - VerifierResolvers: lombardVerifierResolverAddresses, + VerifierVersion: protocol.ByteSlice(lombardCfg.VerifierVersion), + VerifierResolvers: stringsToAnyMap(lombardVerifierResolverAddresses), }, }) } @@ -194,7 +189,7 @@ func GenerateTokenVerifierConfig(registry *adapters.Registry) deployment.ChangeS } } - if err := ccvdeployment.SaveTokenVerifierConfig(outputDS, cfg.ServiceIdentifier, config); err != nil { + if err := ccvdeployment.SaveTokenVerifierConfig(outputDS, cfg.ServiceIdentifier, tvConfig); err != nil { return deployment.ChangesetOutput{}, fmt.Errorf("failed to save token verifier config: %w", err) } @@ -206,6 +201,17 @@ func GenerateTokenVerifierConfig(registry *adapters.Registry) deployment.ChangeS return deployment.CreateChangeSet(apply, validate) } +func stringsToAnyMap(src map[string]string) map[string]any { + if src == nil { + return nil + } + dst := make(map[string]any, len(src)) + for k, v := range src { + dst[k] = v + } + return dst +} + func applyLombardDefaults(cfg LombardConfigInput, isProd bool) LombardConfigInput { if cfg.AttestationAPI == "" { if isProd { diff --git a/deployment/env_metadata_util.go b/deployment/env_metadata_util.go index 0fb425161..2c6601406 100644 --- a/deployment/env_metadata_util.go +++ b/deployment/env_metadata_util.go @@ -7,13 +7,16 @@ import ( "github.com/smartcontractkit/chainlink-deployments-framework/datastore" + "github.com/smartcontractkit/chainlink-ccv/aggregator/pkg/model" + indexerconfig "github.com/smartcontractkit/chainlink-ccv/indexer/pkg/config" "github.com/smartcontractkit/chainlink-ccv/deployment/shared" + "github.com/smartcontractkit/chainlink-ccv/verifier/pkg/token" ) type OffchainConfigs struct { - Aggregators map[string]*Committee `json:"aggregators,omitempty"` - Indexers map[string]*IndexerGeneratedConfig `json:"indexers,omitempty"` - TokenVerifiers map[string]*TokenVerifierGeneratedConfig `json:"tokenVerifiers,omitempty"` + Aggregators map[string]*model.Committee `json:"aggregators,omitempty"` + Indexers map[string]*indexerconfig.GeneratedConfig `json:"indexers,omitempty"` + TokenVerifiers map[string]*token.Config `json:"tokenVerifiers,omitempty"` NOPJobs shared.NOPJobs `json:"nopJobs,omitempty"` } @@ -21,7 +24,7 @@ type CCVEnvMetadata struct { OffchainConfigs *OffchainConfigs `json:"offchainConfigs,omitempty"` } -func SaveAggregatorConfig(ds datastore.MutableDataStore, serviceIdentifier string, cfg *Committee) error { +func SaveAggregatorConfig(ds datastore.MutableDataStore, serviceIdentifier string, cfg *model.Committee) error { ccvMeta, err := loadOrCreateCCVEnvMetadata(ds) if err != nil { return err @@ -31,7 +34,7 @@ func SaveAggregatorConfig(ds datastore.MutableDataStore, serviceIdentifier strin ccvMeta.OffchainConfigs = &OffchainConfigs{} } if ccvMeta.OffchainConfigs.Aggregators == nil { - ccvMeta.OffchainConfigs.Aggregators = make(map[string]*Committee) + ccvMeta.OffchainConfigs.Aggregators = make(map[string]*model.Committee) } ccvMeta.OffchainConfigs.Aggregators[serviceIdentifier] = cfg @@ -39,7 +42,7 @@ func SaveAggregatorConfig(ds datastore.MutableDataStore, serviceIdentifier strin return persistCCVEnvMetadata(ds, ccvMeta) } -func GetAggregatorConfig(ds datastore.DataStore, serviceIdentifier string) (*Committee, error) { +func GetAggregatorConfig(ds datastore.DataStore, serviceIdentifier string) (*model.Committee, error) { ccvMeta, err := loadCCVEnvMetadata(ds) if err != nil { return nil, err @@ -57,7 +60,7 @@ func GetAggregatorConfig(ds datastore.DataStore, serviceIdentifier string) (*Com return cfg, nil } -func SaveIndexerConfig(ds datastore.MutableDataStore, serviceIdentifier string, cfg *IndexerGeneratedConfig) error { +func SaveIndexerConfig(ds datastore.MutableDataStore, serviceIdentifier string, cfg *indexerconfig.GeneratedConfig) error { ccvMeta, err := loadOrCreateCCVEnvMetadata(ds) if err != nil { return err @@ -67,7 +70,7 @@ func SaveIndexerConfig(ds datastore.MutableDataStore, serviceIdentifier string, ccvMeta.OffchainConfigs = &OffchainConfigs{} } if ccvMeta.OffchainConfigs.Indexers == nil { - ccvMeta.OffchainConfigs.Indexers = make(map[string]*IndexerGeneratedConfig) + ccvMeta.OffchainConfigs.Indexers = make(map[string]*indexerconfig.GeneratedConfig) } ccvMeta.OffchainConfigs.Indexers[serviceIdentifier] = cfg @@ -75,7 +78,7 @@ func SaveIndexerConfig(ds datastore.MutableDataStore, serviceIdentifier string, return persistCCVEnvMetadata(ds, ccvMeta) } -func GetIndexerConfig(ds datastore.DataStore, serviceIdentifier string) (*IndexerGeneratedConfig, error) { +func GetIndexerConfig(ds datastore.DataStore, serviceIdentifier string) (*indexerconfig.GeneratedConfig, error) { ccvMeta, err := loadCCVEnvMetadata(ds) if err != nil { return nil, err @@ -93,7 +96,7 @@ func GetIndexerConfig(ds datastore.DataStore, serviceIdentifier string) (*Indexe return cfg, nil } -func SaveTokenVerifierConfig(ds datastore.MutableDataStore, serviceIdentifier string, cfg *TokenVerifierGeneratedConfig) error { +func SaveTokenVerifierConfig(ds datastore.MutableDataStore, serviceIdentifier string, cfg *token.Config) error { ccvMeta, err := loadOrCreateCCVEnvMetadata(ds) if err != nil { return err @@ -103,7 +106,7 @@ func SaveTokenVerifierConfig(ds datastore.MutableDataStore, serviceIdentifier st ccvMeta.OffchainConfigs = &OffchainConfigs{} } if ccvMeta.OffchainConfigs.TokenVerifiers == nil { - ccvMeta.OffchainConfigs.TokenVerifiers = make(map[string]*TokenVerifierGeneratedConfig) + ccvMeta.OffchainConfigs.TokenVerifiers = make(map[string]*token.Config) } ccvMeta.OffchainConfigs.TokenVerifiers[serviceIdentifier] = cfg @@ -111,7 +114,7 @@ func SaveTokenVerifierConfig(ds datastore.MutableDataStore, serviceIdentifier st return persistCCVEnvMetadata(ds, ccvMeta) } -func GetTokenVerifierConfig(ds datastore.DataStore, serviceIdentifier string) (*TokenVerifierGeneratedConfig, error) { +func GetTokenVerifierConfig(ds datastore.DataStore, serviceIdentifier string) (*token.Config, error) { ccvMeta, err := loadCCVEnvMetadata(ds) if err != nil { return nil, err diff --git a/deployment/go.mod b/deployment/go.mod index f267503b0..8047bfabc 100644 --- a/deployment/go.mod +++ b/deployment/go.mod @@ -143,6 +143,7 @@ require ( github.com/smartcontractkit/chainlink-ccip/chains/solana/gobindings v0.0.0-20250912190424-fd2e35d7deb5 // indirect github.com/smartcontractkit/chainlink-common/keystore v1.0.2 // indirect github.com/smartcontractkit/chainlink-common/pkg/chipingress v0.0.10 // indirect + github.com/smartcontractkit/chainlink-protos/chainlink-ccv/committee-verifier v0.0.0-20251211142334-5c3421fe2c8d // indirect github.com/smartcontractkit/chainlink-protos/chainlink-ccv/verifier v0.0.0-20251211142334-5c3421fe2c8d // indirect github.com/smartcontractkit/chainlink-protos/cre/go v0.0.0-20260326111235-8c09d1a4491f // indirect github.com/smartcontractkit/chainlink-protos/linking-service/go v0.0.0-20251002192024-d2ad9222409b // indirect diff --git a/deployment/indexer.go b/deployment/indexer.go deleted file mode 100644 index 462c442df..000000000 --- a/deployment/indexer.go +++ /dev/null @@ -1,10 +0,0 @@ -package deployment - -type IndexerVerifierConfig struct { - Name string `json:"name"` - IssuerAddresses []string `json:"issuerAddresses"` -} - -type IndexerGeneratedConfig struct { - Verifiers []IndexerVerifierConfig `json:"verifiers"` -} diff --git a/deployment/token_verifier.go b/deployment/token_verifier.go deleted file mode 100644 index 1eb6b201d..000000000 --- a/deployment/token_verifier.go +++ /dev/null @@ -1,55 +0,0 @@ -package deployment - -import "time" - -type TokenVerifierGeneratedConfig struct { - PyroscopeURL string `json:"pyroscope_url"` - OnRampAddresses map[string]string `json:"on_ramp_addresses"` - RMNRemoteAddresses map[string]string `json:"rmn_remote_addresses"` - TokenVerifiers []TokenVerifierEntry `json:"token_verifiers"` - Monitoring TokenVerifierMonitoringConfig `json:"monitoring"` -} - -type TokenVerifierEntry struct { - VerifierID string `json:"verifier_id"` - Type string `json:"type"` - Version string `json:"version"` - CCTP *CCTPVerifierConfig `json:"cctp,omitempty"` - Lombard *LombardVerifierConfig `json:"lombard,omitempty"` -} - -type CCTPVerifierConfig struct { - AttestationAPI string `json:"attestation_api"` - AttestationAPITimeout time.Duration `json:"attestation_api_timeout"` - AttestationAPIInterval time.Duration `json:"attestation_api_interval"` - AttestationAPICooldown time.Duration `json:"attestation_api_cooldown"` - VerifierVersion []byte `json:"verifier_version"` - Verifiers map[string]string `json:"verifiers"` - VerifierResolvers map[string]string `json:"verifier_resolvers"` -} - -type LombardVerifierConfig struct { - AttestationAPI string `json:"attestation_api"` - AttestationAPITimeout time.Duration `json:"attestation_api_timeout"` - AttestationAPIInterval time.Duration `json:"attestation_api_interval"` - AttestationAPIBatchSize int `json:"attestation_api_batch_size"` - VerifierVersion []byte `json:"verifier_version"` - VerifierResolvers map[string]string `json:"verifier_resolvers"` -} - -type TokenVerifierMonitoringConfig struct { - Enabled bool `json:"enabled"` - Type string `json:"type"` - Beholder TokenVerifierBeholderConfig `json:"beholder"` -} - -type TokenVerifierBeholderConfig struct { - InsecureConnection bool `json:"insecure_connection"` - CACertFile string `json:"ca_cert_file"` - OtelExporterGRPCEndpoint string `json:"otel_exporter_grpc_endpoint"` - OtelExporterHTTPEndpoint string `json:"otel_exporter_http_endpoint"` - LogStreamingEnabled bool `json:"log_streaming_enabled"` - MetricReaderInterval int64 `json:"metric_reader_interval"` - TraceSampleRatio float64 `json:"trace_sample_ratio"` - TraceBatchTimeout int64 `json:"trace_batch_timeout"` -} diff --git a/deployment/topology.go b/deployment/topology.go index a7db0134c..741b1ac1d 100644 --- a/deployment/topology.go +++ b/deployment/topology.go @@ -12,6 +12,7 @@ import ( "github.com/Masterminds/semver/v3" "github.com/smartcontractkit/chainlink-ccv/deployment/shared" + "github.com/smartcontractkit/chainlink-ccv/pkg/monitoring" ) // EnvironmentTopology holds all environment-specific configuration that cannot be inferred @@ -135,22 +136,11 @@ type ChainExecutorPoolConfig struct { ExecutionInterval time.Duration `toml:"execution_interval"` } -type MonitoringConfig struct { - Enabled bool `toml:"Enabled"` - Type string `toml:"Type"` - Beholder BeholderConfig `toml:"Beholder"` -} - -type BeholderConfig struct { - InsecureConnection bool `toml:"InsecureConnection"` - CACertFile string `toml:"CACertFile"` - OtelExporterGRPCEndpoint string `toml:"OtelExporterGRPCEndpoint"` - OtelExporterHTTPEndpoint string `toml:"OtelExporterHTTPEndpoint"` - LogStreamingEnabled bool `toml:"LogStreamingEnabled"` - MetricReaderInterval int64 `toml:"MetricReaderInterval"` - TraceSampleRatio float64 `toml:"TraceSampleRatio"` - TraceBatchTimeout int64 `toml:"TraceBatchTimeout"` -} +// Type aliases — canonical definitions live in pkg/monitoring. +type ( + MonitoringConfig = monitoring.Config + BeholderConfig = monitoring.BeholderConfig +) func LoadEnvironmentTopology(path string) (*EnvironmentTopology, error) { data, err := os.ReadFile(path) //nolint:gosec // G304: path is provided by trusted caller diff --git a/executor/config.go b/executor/config.go index 0a8f95338..a1cf7632c 100644 --- a/executor/config.go +++ b/executor/config.go @@ -6,6 +6,7 @@ import ( "time" "github.com/smartcontractkit/chainlink-ccv/pkg/chainaccess" + "github.com/smartcontractkit/chainlink-ccv/pkg/monitoring" ) const ( @@ -192,64 +193,8 @@ func (c *Configuration) GetNormalizedConfig() (*Configuration, error) { return &normalized, nil } -// MonitoringConfig provides monitoring configuration for executor. -type MonitoringConfig struct { - // Enabled enables the monitoring system. - Enabled bool `toml:"Enabled"` - // Type is the type of monitoring system to use (beholder, noop). - Type string `toml:"Type"` - // Beholder is the configuration for the beholder client (Not required if type is noop). - Beholder BeholderConfig `toml:"Beholder"` -} - -// BeholderConfig wraps OpenTelemetry configuration for the beholder client. -type BeholderConfig struct { - // InsecureConnection disables TLS for the beholder client. - InsecureConnection bool `toml:"InsecureConnection"` - // CACertFile is the path to the CA certificate file for the beholder client. - CACertFile string `toml:"CACertFile"` - // OtelExporterGRPCEndpoint is the endpoint for the beholder client to export to the collector. - OtelExporterGRPCEndpoint string `toml:"OtelExporterGRPCEndpoint"` - // OtelExporterHTTPEndpoint is the endpoint for the beholder client to export to the collector. - OtelExporterHTTPEndpoint string `toml:"OtelExporterHTTPEndpoint"` - // LogStreamingEnabled enables log streaming to the collector. - LogStreamingEnabled bool `toml:"LogStreamingEnabled"` - // MetricReaderInterval is the interval to scrape metrics (in seconds). - MetricReaderInterval int64 `toml:"MetricReaderInterval"` - // TraceSampleRatio is the ratio of traces to sample. - TraceSampleRatio float64 `toml:"TraceSampleRatio"` - // TraceBatchTimeout is the timeout for a batch of traces. - TraceBatchTimeout int64 `toml:"TraceBatchTimeout"` -} - -// Validate performs validation on the monitoring configuration. -func (m *MonitoringConfig) Validate() error { - if m.Enabled && m.Type == "" { - return fmt.Errorf("monitoring type is required when monitoring is enabled") - } - - if m.Enabled && m.Type == "beholder" { - if err := m.Beholder.Validate(); err != nil { - return fmt.Errorf("beholder config validation failed: %w", err) - } - } - - return nil -} - -// Validate performs validation on the beholder configuration. -func (b *BeholderConfig) Validate() error { - if b.MetricReaderInterval <= 0 { - return fmt.Errorf("metric_reader_interval must be positive, got %d", b.MetricReaderInterval) - } - - if b.TraceSampleRatio < 0 || b.TraceSampleRatio > 1 { - return fmt.Errorf("trace_sample_ratio must be between 0 and 1, got %f", b.TraceSampleRatio) - } - - if b.TraceBatchTimeout <= 0 { - return fmt.Errorf("trace_batch_timeout must be positive, got %d", b.TraceBatchTimeout) - } - - return nil -} +// Type aliases — canonical definitions live in pkg/monitoring. +type ( + MonitoringConfig = monitoring.Config + BeholderConfig = monitoring.BeholderConfig +) diff --git a/indexer/pkg/config/config.go b/indexer/pkg/config/config.go index 6ce443bdb..f67ffd56f 100644 --- a/indexer/pkg/config/config.go +++ b/indexer/pkg/config/config.go @@ -12,14 +12,14 @@ import ( // GeneratedVerifierConfig contains auto-generated verifier configuration. type GeneratedVerifierConfig struct { - Name string `toml:"Name"` - IssuerAddresses []string `toml:"IssuerAddresses"` + Name string `json:"name" toml:"Name"` + IssuerAddresses []string `json:"issuerAddresses" toml:"IssuerAddresses"` } // GeneratedConfig contains auto-generated deployment configuration. // This is typically generated by tooling and loaded from a separate file. type GeneratedConfig struct { - Verifier []GeneratedVerifierConfig `toml:"Verifier"` + Verifier []GeneratedVerifierConfig `json:"verifiers" toml:"Verifier"` } // Config provides all configuration for the indexer. diff --git a/indexer/pkg/config/monitoring.go b/indexer/pkg/config/monitoring.go index d9cbca55f..4cf55a037 100644 --- a/indexer/pkg/config/monitoring.go +++ b/indexer/pkg/config/monitoring.go @@ -1,67 +1,9 @@ package config -import ( - "fmt" -) - -// Config provides monitoring configuration for CCV services (verifier, executor, indexer, aggregator). -type MonitoringConfig struct { - // Enabled enables the monitoring system. - Enabled bool `toml:"Enabled"` - // Type is the type of monitoring system to use (beholder, noop). - Type string `toml:"Type"` - // Beholder is the configuration for the beholder client (Not required if type is noop). - Beholder BeholderConfig `toml:"Beholder"` -} - -// BeholderConfig wraps OpenTelemetry configuration for the beholder client. -type BeholderConfig struct { - // InsecureConnection disables TLS for the beholder client. - InsecureConnection bool `toml:"InsecureConnection"` - // CACertFile is the path to the CA certificate file for the beholder client. - CACertFile string `toml:"CACertFile"` - // OtelExporterGRPCEndpoint is the endpoint for the beholder client to export to the collector. - OtelExporterGRPCEndpoint string `toml:"OtelExporterGRPCEndpoint"` - // OtelExporterHTTPEndpoint is the endpoint for the beholder client to export to the collector. - OtelExporterHTTPEndpoint string `toml:"OtelExporterHTTPEndpoint"` - // LogStreamingEnabled enables log streaming to the collector. - LogStreamingEnabled bool `toml:"LogStreamingEnabled"` - // MetricReaderInterval is the interval to scrape metrics (in seconds). - MetricReaderInterval int64 `toml:"MetricReaderInterval"` - // TraceSampleRatio is the ratio of traces to sample. - TraceSampleRatio float64 `toml:"TraceSampleRatio"` - // TraceBatchTimeout is the timeout for a batch of traces. - TraceBatchTimeout int64 `toml:"TraceBatchTimeout"` -} - -// Validate performs validation on the monitoring configuration. -func (m *MonitoringConfig) Validate() error { - if m.Enabled && m.Type == "" { - return fmt.Errorf("monitoring type is required when monitoring is enabled") - } - - if m.Enabled && m.Type == "beholder" { - if err := m.Beholder.Validate(); err != nil { - return fmt.Errorf("beholder config validation failed: %w", err) - } - } +import "github.com/smartcontractkit/chainlink-ccv/pkg/monitoring" - return nil -} - -// Validate performs validation on the beholder configuration. -func (b *BeholderConfig) Validate() error { - if b.MetricReaderInterval <= 0 { - return fmt.Errorf("metric_reader_interval must be positive, got %d", b.MetricReaderInterval) - } - - if b.TraceSampleRatio < 0 || b.TraceSampleRatio > 1 { - return fmt.Errorf("trace_sample_ratio must be between 0 and 1, got %f", b.TraceSampleRatio) - } - - if b.TraceBatchTimeout <= 0 { - return fmt.Errorf("trace_batch_timeout must be positive, got %d", b.TraceBatchTimeout) - } - - return nil -} +// Type aliases — canonical definitions live in pkg/monitoring. +type ( + MonitoringConfig = monitoring.Config + BeholderConfig = monitoring.BeholderConfig +) diff --git a/pkg/monitoring/config.go b/pkg/monitoring/config.go new file mode 100644 index 000000000..299797a25 --- /dev/null +++ b/pkg/monitoring/config.go @@ -0,0 +1,65 @@ +package monitoring + +import "fmt" + +// Config provides monitoring configuration for CCV services. +type Config struct { + // Enabled enables the monitoring system. + Enabled bool `json:"enabled" toml:"Enabled"` + // Type is the type of monitoring system to use (beholder, noop). + Type string `json:"type" toml:"Type"` + // Beholder is the configuration for the beholder client (Not required if type is noop). + Beholder BeholderConfig `json:"beholder" toml:"Beholder"` +} + +// BeholderConfig wraps OpenTelemetry configuration for the beholder client. +type BeholderConfig struct { + // InsecureConnection disables TLS for the beholder client. + InsecureConnection bool `json:"insecure_connection" toml:"InsecureConnection"` + // CACertFile is the path to the CA certificate file for the beholder client. + CACertFile string `json:"ca_cert_file" toml:"CACertFile"` + // OtelExporterGRPCEndpoint is the endpoint for the beholder client to export to the collector. + OtelExporterGRPCEndpoint string `json:"otel_exporter_grpc_endpoint" toml:"OtelExporterGRPCEndpoint"` + // OtelExporterHTTPEndpoint is the endpoint for the beholder client to export to the collector. + OtelExporterHTTPEndpoint string `json:"otel_exporter_http_endpoint" toml:"OtelExporterHTTPEndpoint"` + // LogStreamingEnabled enables log streaming to the collector. + LogStreamingEnabled bool `json:"log_streaming_enabled" toml:"LogStreamingEnabled"` + // MetricReaderInterval is the interval to scrape metrics (in seconds). + MetricReaderInterval int64 `json:"metric_reader_interval" toml:"MetricReaderInterval"` + // TraceSampleRatio is the ratio of traces to sample. + TraceSampleRatio float64 `json:"trace_sample_ratio" toml:"TraceSampleRatio"` + // TraceBatchTimeout is the timeout for a batch of traces. + TraceBatchTimeout int64 `json:"trace_batch_timeout" toml:"TraceBatchTimeout"` +} + +// Validate performs validation on the monitoring configuration. +func (m *Config) Validate() error { + if m.Enabled && m.Type == "" { + return fmt.Errorf("monitoring type is required when monitoring is enabled") + } + + if m.Enabled && m.Type == "beholder" { + if err := m.Beholder.Validate(); err != nil { + return fmt.Errorf("beholder config validation failed: %w", err) + } + } + + return nil +} + +// Validate performs validation on the beholder configuration. +func (b *BeholderConfig) Validate() error { + if b.MetricReaderInterval <= 0 { + return fmt.Errorf("metric_reader_interval must be positive, got %d", b.MetricReaderInterval) + } + + if b.TraceSampleRatio < 0 || b.TraceSampleRatio > 1 { + return fmt.Errorf("trace_sample_ratio must be between 0 and 1, got %f", b.TraceSampleRatio) + } + + if b.TraceBatchTimeout <= 0 { + return fmt.Errorf("trace_batch_timeout must be positive, got %d", b.TraceBatchTimeout) + } + + return nil +} diff --git a/verifier/pkg/vtypes/config.go b/verifier/pkg/vtypes/config.go index c8c880fb6..fd5603c5f 100644 --- a/verifier/pkg/vtypes/config.go +++ b/verifier/pkg/vtypes/config.go @@ -1,67 +1,9 @@ package vtypes -import ( - "fmt" -) - -// MonitoringConfig provides monitoring configuration for verifier. -type MonitoringConfig struct { - // Enabled enables the monitoring system. - Enabled bool `toml:"Enabled"` - // Type is the type of monitoring system to use (beholder, noop). - Type string `toml:"Type"` - // Beholder is the configuration for the beholder client (Not required if type is noop). - Beholder BeholderConfig `toml:"Beholder"` -} - -// BeholderConfig wraps OpenTelemetry configuration for the beholder client. -type BeholderConfig struct { - // InsecureConnection disables TLS for the beholder client. - InsecureConnection bool `toml:"InsecureConnection"` - // CACertFile is the path to the CA certificate file for the beholder client. - CACertFile string `toml:"CACertFile"` - // OtelExporterGRPCEndpoint is the endpoint for the beholder client to export to the collector. - OtelExporterGRPCEndpoint string `toml:"OtelExporterGRPCEndpoint"` - // OtelExporterHTTPEndpoint is the endpoint for the beholder client to export to the collector. - OtelExporterHTTPEndpoint string `toml:"OtelExporterHTTPEndpoint"` - // LogStreamingEnabled enables log streaming to the collector. - LogStreamingEnabled bool `toml:"LogStreamingEnabled"` - // MetricReaderInterval is the interval to scrape metrics (in seconds). - MetricReaderInterval int64 `toml:"MetricReaderInterval"` - // TraceSampleRatio is the ratio of traces to sample. - TraceSampleRatio float64 `toml:"TraceSampleRatio"` - // TraceBatchTimeout is the timeout for a batch of traces. - TraceBatchTimeout int64 `toml:"TraceBatchTimeout"` -} - -// Validate performs validation on the monitoring configuration. -func (m *MonitoringConfig) Validate() error { - if m.Enabled && m.Type == "" { - return fmt.Errorf("monitoring type is required when monitoring is enabled") - } - - if m.Enabled && m.Type == "beholder" { - if err := m.Beholder.Validate(); err != nil { - return fmt.Errorf("beholder config validation failed: %w", err) - } - } +import "github.com/smartcontractkit/chainlink-ccv/pkg/monitoring" - return nil -} - -// Validate performs validation on the beholder configuration. -func (b *BeholderConfig) Validate() error { - if b.MetricReaderInterval <= 0 { - return fmt.Errorf("metric_reader_interval must be positive, got %d", b.MetricReaderInterval) - } - - if b.TraceSampleRatio < 0 || b.TraceSampleRatio > 1 { - return fmt.Errorf("trace_sample_ratio must be between 0 and 1, got %f", b.TraceSampleRatio) - } - - if b.TraceBatchTimeout <= 0 { - return fmt.Errorf("trace_batch_timeout must be positive, got %d", b.TraceBatchTimeout) - } - - return nil -} +// Type aliases — canonical definitions live in pkg/monitoring. +type ( + MonitoringConfig = monitoring.Config + BeholderConfig = monitoring.BeholderConfig +)