Skip to content

cre-4958: manual shard assignments - #23348

Draft
mchain0 wants to merge 9 commits into
developfrom
cre-4958
Draft

cre-4958: manual shard assignments#23348
mchain0 wants to merge 9 commits into
developfrom
cre-4958

Conversation

@mchain0

@mchain0 mchain0 commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Enables manual shard assignments owner->shard.

Scope:

  • Config layer — ShardAssignmentMode field added to [Sharding] TOML config with 3 mode constants (ringocr-only, manual-only, ringocr-with-overrides). Validation updated to skip ShardOrchestratorAddress requirement for manual-only.
  • CRESettings job spec — config_type key inside the existing settings TOML column branches between regular settings and shard assignment. No DB migration needed. validate.go parses and validates accordingly. delegate.go routes to a dedicated AtomicSettings instance for shard assignment, reusing the existing Store() pattern.
  • ShardResolver (shardownership/resolver.go) — New interface with 3 implementations:
    • ringOCRShardResolver — wraps ShardOrchestrator client (existing behavior)
    • manualShardResolver — loads shard assignment TOML from AtomicSettings, parses it, O(1) owner→shard map lookup, no external deps
    • overrideShardResolver — manual wins for static owners, delegates to RingOCR for hashed owners
  • Wiring — cre.go creates the resolver based on mode. workflow_registry.go's filterWorkflowsByShard uses the resolver with owner hex from WorkflowMetadataView.Owner. Engine execution guard uses the resolver with EngineConfig.WorkflowOwner. application.go skips ShardOrchestrator infrastructure in manual-only mode.
  • Deployment — ShardAssignmentJob type prepends config_type = "shard_assignment" to the settings TOML, reuses the existing cre-settings.tmpl template. ProposeShardAssignmentJob operation added.

Tests:

  • Unit tests for config parsing, owner normalization, all 3 resolvers
  • E2E test files for manual-only and ringocr-with-overrides modes
  • Test config TOMLs for both new modes

cre-4958

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

✅ No conflicts with other open PRs targeting develop

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

I see you updated files related to core. Please run make gocs in the root directory to add a changeset as well as in the text include at least one of the following tags:

  • #added For any new functionality added.
  • #breaking_change For any functionality that requires manual action for the node to boot.
  • #bugfix For bug fixes.
  • #changed For any change to the existing functionality.
  • #db_update For any feature that introduces updates to database schema.
  • #deprecation_notice For any upcoming deprecation functionality.
  • #internal For changesets that need to be excluded from the final changelog.
  • #nops For any feature that is NOP facing and needs to be in the official Release Notes for the release.
  • #removed For any functionality/config that is removed.
  • #updated For any functionality that is updated.
  • #wip For any change that is not ready yet and external communication about it should be held off till it is feature complete.

@trunk-io

trunk-io Bot commented Aug 6, 2026

Copy link
Copy Markdown

Static BadgeStatic BadgeStatic Badge

Failed Test Failure Summary Logs
TestScripts/node/validate The test named 'TestScripts/node/validate' failed during execution. Logs ↗︎
TestScripts/node/validate/fallback-override Logs ↗︎
TestScripts/node/validate/default Logs ↗︎
TestScripts/node/validate/invalid-ocr-p2p Logs ↗︎

... and 24 more

View Full Report ↗︎Docs

@mchain0
mchain0 requested a review from bolekk August 6, 2026 16:16

@bolekk bolekk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM overall!

Comment thread core/services/workflows/syncer/v2/file_workflow_source_test.go Outdated
Comment thread core/services/chainlink/application.go Outdated
Comment thread core/services/cresettings/delegate.go
Comment thread core/services/cresettings/delegate.go Outdated
Comment thread core/services/cresettings/delegate.go Outdated
}); err != nil {
return nil, fmt.Errorf("failed to update settings: %w", err)
spec := j.CRESettingsSpec
configType := spec.ConfigType

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

cc @jmank88 are you OK with this extension? Soon we can also add the third type for offchain Capabilities Registry (FYI @vyzaldysanchez )

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've refactored this a bit after @pavel-raykov 's suggestion. pls have a look

Comment thread core/services/cresettings/delegate.go Outdated
type ShardAssignmentConfig struct {
StaticDefaultAssignment []uint32
DisabledShards []uint32
PerOwnerAssignment map[string][]uint32

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's add perOrg too. I'm about to send a caching extension to OrgResolver and we will soon stop failing open on missing orgs. Orgs are much easier to manage in the config compared to owners.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

how about we do this PR with owners initially and make a separate with an extension for orgs? that might be just easier to comprehend and review from the risks perspectives

)

type ShardResolver interface {
ResolveShard(ctx context.Context, workflowID string, ownerHex string) (shardID uint32, found bool, err error)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

include org? optional?

Comment thread core/store/migrate/migrations/0302_add_shard_assignment_to_cre_settings.sql Outdated
Comment thread core/services/workflows/v2/engine.go
Comment thread core/services/cresettings/delegate.go Outdated
@cl-sonarqube-production

Copy link
Copy Markdown

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.

3 participants