Skip to content

fix(agent): reconcile Random Sampling sharding membership - #2511

Merged
branarakic merged 20 commits into
testnet-canaryfrom
fix/issue-1642-random-sampling-membership
Sep 13, 2026
Merged

branarakic merged 20 commits into
testnet-canaryfrom
fix/issue-1642-random-sampling-membership

Conversation

@branarakic

@branarakic branarakic commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Core nodes recheck Random Sampling identity and sharding-table membership every 30 seconds. A node admitted after startup can start proving without a daemon restart. Confirmed removal retires the prover; readmission starts a fresh handle. Transient lookup failures retain the active prover.

A feature runtime owns waiting, disabled, binding, running, retiring and stopped states, including timer ownership and retry transitions. The chain adapter refreshes invalidated RandomSampling bindings and returns typed membership, missing-deployment or indeterminate facts. Previously observed deployments remain retryable across rotation. Initially absent or unsupported deployments remain disabled. Only missing RandomSampling, RandomSamplingStorage or ShardingTableStorage bindings are classified as a missing sampling deployment; unrelated mandatory Hub-contract initialization errors remain indeterminate with their original typed error. ChainAdapter owns each capability declaration once; required resolver and legacy-probe types derive from it, and the compatibility reader preserves older optional probes and their receiver.

The public createRandomSamplingHandle() method continues returning a directly usable RandomSamplingHandle, including disabled no-op handles. The lifecycle uses a separate protected binding-result path to decide resource ownership and retries. Shutdown fences new work immediately, then joins construction and physical close before store/network teardown. A timeout retains physical ownership until cleanup settles; a settled close rejection is logged and permits teardown or later readmission.

Status preserves the existing disabled-reason values. Pending cleanup reports enabled: false, disabledReason: not_started and optional retiring: true; the CLI explains this diagnostic, and it clears after physical retirement. Existing exhaustive reason maps and status literals remain compatible.

Validation:

  • 130 tests pass: 71 membership, package-root consumer, proof-repair, shutdown and recurring-task tests; 59 chain availability, parity, Hub-resolution and rotation-poller tests.
  • Three regressions run the real adapter initialization and Hub-resolution code with deterministic RPC reads. Missing Identity, Profile and ParametersStorage contracts remain indeterminate while the same Hub fixture resolves the sampling deployment. All three fail on the preceding head. Positive controls cover missing RandomSampling, RandomSamplingStorage and ShardingTableStorage.
  • Package-root consumer tests retain usable active/disabled handles; type contracts preserve public return types and legacy probe shapes and keep the binding resolver off the public agent surface.
  • The runtime build started from empty chain and agent output; public type/package checks, strict checking of four relevant test files (zero diagnostics), lint, the 1,842-file inventory and diff checks pass.

Closes #1642.

Comment thread packages/agent/src/dkg-agent.ts Outdated
Comment thread packages/agent/test/random-sampling-membership.test.ts
Comment thread packages/agent/src/dkg-agent-lifecycle.ts Outdated
Comment thread packages/agent/src/dkg-agent-lifecycle.ts Outdated
Comment thread packages/agent/src/dkg-agent-lifecycle.ts Outdated
Comment thread packages/agent/src/random-sampling-runtime.ts Outdated
Comment thread packages/agent/src/random-sampling-runtime.ts Outdated
Comment thread packages/agent/src/random-sampling-runtime.ts Outdated
Comment thread packages/agent/src/random-sampling-runtime.ts Outdated
Comment thread packages/agent/src/random-sampling-runtime.ts
Comment thread packages/agent/test/random-sampling-status-compat.typecheck.ts Outdated
Comment thread packages/agent/src/random-sampling-eligibility.ts Outdated
Comment thread packages/agent/src/random-sampling-eligibility.ts Outdated
Comment thread packages/agent/src/dkg-agent-lifecycle.ts Outdated
@branarakic
branarakic requested a review from Jurij89 as a code owner September 7, 2026 23:53
@branarakic

Copy link
Copy Markdown
Contributor Author

Fixed both PR-specific CI failures in 751a2ac: the offline adapter now implements typed availability without a parity exemption, and the five lifecycle admission cases observe the owned runtime instead of spying on the removed factory. Unexpected readiness/capability exceptions become indeterminate outcomes, with a recovery assertion.

Validation: 29 chain availability/parity + 48 runtime/proof-repair/outbox + five Hardhat-backed admission cases pass (82 total); agent/CLI builds, registered declaration and fixture checks, lint, inventory and SPARQL pass. The previous agent shard 6 failure has the empty identity response followed by a 60-second negative-admission cache signature tracked in #2507; its independent repair is #2508. Fresh CI is running.

Comment thread packages/agent/src/random-sampling-runtime.ts
Comment thread packages/chain/src/random-sampling-availability.ts Outdated
Comment thread packages/chain/test/random-sampling-availability.unit.test.ts Outdated
Comment thread packages/agent/src/random-sampling-runtime.ts Outdated
Comment thread packages/agent/src/random-sampling-eligibility.ts Outdated
Comment thread packages/chain/src/evm-adapter-base.ts
Comment thread packages/chain/src/mock-adapter.ts Outdated
Comment thread packages/agent/tsconfig.type-tests.json Outdated
Comment thread packages/agent/src/random-sampling-bind.ts
Comment thread packages/agent/src/random-sampling-bind.ts Outdated
Comment thread packages/agent/src/random-sampling-bind.ts
Comment thread packages/agent/src/random-sampling-runtime.ts Outdated
Comment thread packages/chain/src/mock-adapter.ts Outdated
Comment thread packages/agent/test/random-sampling-membership.test.ts
Comment thread packages/agent/src/random-sampling-eligibility.ts Outdated
Comment thread packages/chain/src/random-sampling-availability.ts Outdated
Comment thread packages/agent/src/random-sampling-runtime.ts Outdated
Comment thread packages/agent/src/random-sampling-runtime.ts Outdated
Comment thread packages/agent/src/random-sampling-bind.ts Outdated
Comment thread packages/agent/src/dkg-agent-lifecycle.ts
Comment thread packages/chain/src/chain-adapter.ts Outdated
Comment thread packages/chain/src/evm-adapter-random-sampling.ts
@branarakic
branarakic merged commit 41a6c40 into testnet-canary Sep 13, 2026
63 checks passed
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