Skip to content

Aptos p2p map to cap reg (generalising)#21672

Draft
yashnevatia wants to merge 1 commit intoaptos-p2p-map-to-capRegfrom
aptos-p2p-map-to-capReg-2
Draft

Aptos p2p map to cap reg (generalising)#21672
yashnevatia wants to merge 1 commit intoaptos-p2p-map-to-capRegfrom
aptos-p2p-map-to-capReg-2

Conversation

@yashnevatia
Copy link
Contributor

Requires

Supports

@yashnevatia yashnevatia requested review from a team as code owners March 24, 2026 16:47
Copilot AI review requested due to automatic review settings March 24, 2026 16:47
@yashnevatia yashnevatia changed the title Aptos p2p map to cap reg 2 Aptos p2p map to cap reg (generalising) Mar 24, 2026
@yashnevatia yashnevatia marked this pull request as draft March 24, 2026 16:47
@github-actions
Copy link
Contributor

👋 yashnevatia, thanks for creating this pull request!

To help reviewers, please consider creating future PRs as drafts first. This allows you to self-review and make any final changes before notifying the team.

Once you're ready, you can mark it as "Ready for review" to request feedback. Thanks!

@github-actions
Copy link
Contributor

✅ No conflicts with other open PRs targeting develop

@yashnevatia yashnevatia changed the base branch from develop to aptos-p2p-map-to-capReg March 24, 2026 16:49
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Risk Rating: MEDIUM — introduces new per-DON config enrichment logic (Aptos-specific) that depends on Job Distributor metadata and mutates capability configs prior to on-chain DON updates.

This PR adds an enrichment layer to the capabilities-registry v2 “add capabilities” flow so Aptos capabilities can automatically inject a p2pToTransmitterMap into specConfig based on JD node metadata.

Changes:

  • Add a per-DON capability-config enrichment step in the AddCapabilities sequence (used before UpdateDON).
  • Introduce a new enricher package with an Aptos enricher that builds and injects specConfig.p2pToTransmitterMap.
  • Add an integration-style test ensuring the Aptos specConfig injection lands on-chain and can be decoded.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
deployment/cre/capabilities_registry/v2/changeset/sequences/add_capabilities.go Clones per-DON capability configs and runs enrichers before updating the DON.
deployment/cre/capabilities_registry/v2/changeset/enricher/enricher.go New enrichment framework + Aptos implementation that pulls transmit accounts from JD and injects specConfig.
deployment/cre/capabilities_registry/v2/changeset/add_capabilities_test.go Adds Aptos apply test asserting specConfig.p2pToTransmitterMap presence after Apply.

Scrupulous human review recommended for:

  • buildAptosP2PToTransmitterMap / mergeAptosP2PToTransmitterIntoConfig correctness and completeness guarantees (especially around missing nodes / partial JD responses).
  • The sequencing in AddCapabilities to avoid partially-applied state in the non-MCMS (immediate execution) strategy.

Suggested reviewers (per .github/CODEOWNERS for /deployment/cre):

  • @smartcontractkit/keystone
  • @smartcontractkit/operations-platform
Comments suppressed due to low confidence (5)

deployment/cre/capabilities_registry/v2/changeset/enricher/enricher.go:19

  • The import block isn’t gofmt-compliant (standard library imports are split and not sorted, with extra blank lines). This will typically fail gofmt/lint checks—please run gofmt so imports are grouped/sorted correctly.
    deployment/cre/capabilities_registry/v2/changeset/enricher/enricher.go:24
  • The doc comment for CapabilityConfigEnrichContext starts with a different type name ("DonCapabilityEnrichContext"), so it won’t be associated correctly by Go doc tooling. Please update the comment to start with CapabilityConfigEnrichContext (and keep the wording consistent with the type name).
    deployment/cre/capabilities_registry/v2/changeset/enricher/enricher.go:84
  • The doc comment for parseAptosChainSelectorFromCapabilityID begins with ParseAptos..., but the function is unexported and named parseAptos.... This mismatch makes the comment misleading and can trigger doc/lint issues; please align the comment prefix with the actual function name (or export the function if you intend it to be public).
    deployment/cre/capabilities_registry/v2/changeset/enricher/enricher.go:141
  • deployment.NodeInfo is documented as “optimistic” and may return only the subset of nodes that exist in JD. This function currently builds the p2p→transmitter map from whatever is returned, which can silently omit entries for DON peer IDs that weren’t returned. That would produce an incomplete p2pToTransmitterMap and likely misconfigure the DON. Please add an explicit validation that all requested donPeerIDs are present in the NodeInfo result (and return a clear error listing missing peer IDs).
    deployment/cre/capabilities_registry/v2/changeset/enricher/enricher.go:57
  • The error message here hard-codes the caller name ("AddCapabilities") even though the check lives in the enricher layer, and it doesn’t include the DON name/capability ID. Consider rewording to be caller-agnostic and include relevant context (e.g., DON + capability) so failures are easier to diagnose.

Comment on lines +176 to +188
donCapabilityConfigs := cloneCapabilityConfigsShallowCopyConfigMaps(input.CapabilityConfigs)
enrichCtx := enricher.CapabilityConfigEnrichContext{
Env: deps.Env,
DonName: donName,
P2PIDs: p2pIDs,
Configs: donCapabilityConfigs,
}
for _, e := range enricher.DefaultCapabilityConfigEnrichers() {
if err := e.Enrich(enrichCtx); err != nil {
return AddCapabilitiesOutput{}, fmt.Errorf("enrich capability configs for DON %s: %w", donName, err)
}
}

Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new enrichment step can fail after UpdateNodes has already executed (in the non-MCMS/simple strategy path), which would leave the registry in a partially-updated state (nodes updated, DON config not). To reduce this risk, consider performing capability-config enrichment before executing contracts.UpdateNodes, since enrichment only depends on Env, donName, and the DON’s p2pIDs (already available here).

Copilot uses AI. Check for mistakes.
@cl-sonarqube-production
Copy link

@trunk-io
Copy link

trunk-io bot commented Mar 24, 2026

Static BadgeStatic BadgeStatic BadgeStatic Badge

View Full Report ↗︎Docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants