Repository navigation
refactor(nns-delegation): publish the NNS delegation builder behind an Arc - #12096
Closed
pierugo-dfinity wants to merge 4 commits into
Closed
pierugo-dfinity wants to merge 4 commits into
pierugo-dfinity wants to merge 4 commits into
Conversation
…n Arc The delegation manager now publishes `Option<Arc<NNSDelegationBuilder>>` on the watch channel, and `NNSDelegationReader::builder()` returns a cheap, immutable snapshot of the latest builder. This lets a consumer verify the delegation against a certified state and build exactly the verified delegation without holding on to the channel, e.g. the query handler can be handed a snapshot instead of a receiver. It also means that: - the reader's `get_delegation*` methods no longer hold the channel's read lock while verifying and building the delegation; - the manager no longer deep-clones the builder every time it publishes one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The shared-snapshot delegation refactor has no active review issues.
No open issues 🎉
What changed in this PR
This refactor publishes NNS delegation builders through shared Arc snapshots, preparing query handlers to verify and build delegations from the same immutable snapshot without retaining a watch receiver.
Changes:
- Add
NNSDelegationReader::builder()and release the watch read lock before verification and construction. - Share builders between the manager and watch channel, avoiding deep clones during publication.
- Update PocketIC and HTTP endpoint test harnesses for the new channel type.
| File | Description |
|---|---|
rs/pocket_ic_server/src/pocket_ic.rs |
Wrap delegation builders in Arc for PocketIC request handlers. |
rs/http_endpoints/public/tests/test.rs |
Adapt delegation-drift tests to publish shared builders. |
rs/http_endpoints/public/tests/common/mod.rs |
Update test channel types and builder initialization. |
rs/http_endpoints/nns_delegation_reader/src/reader.rs |
Expose snapshots and use them outside the watch read lock. |
rs/http_endpoints/nns_delegation_manager/src/nns_delegation_manager.rs |
Store and publish shared builders; remove the large-enum lint exemption. |
Review effort: Balanced
Base automatically changed from
pierugo/delegations/remove-unused-logger
to
master
November 13, 2026 10:51
Contributor
Author
|
Superseded: this commit was folded into #12064. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #12065.
What
The NNS delegation manager now publishes
Option<Arc<NNSDelegationBuilder>>on its watch channel instead ofOption<NNSDelegationBuilder>. A new method,NNSDelegationReader::builder(), returns an immutable snapshot of the latest builder.Why
This is a preparatory step for verifying the NNS delegation embedded in query responses against the certified state the data certificate is built from. With a snapshot, the query handler can take an
Option<Arc<NNSDelegationBuilder>>and does not need anNNSDelegationReader(i.e. awatch::Receiver) in its input. The snapshot is immutable, so the delegation that is verified is exactly the one that is built.The change has two side benefits:
NNSDelegationReader::get_delegationandget_delegation_with_metadatanow take the snapshot first, then verify and build the delegation. They no longer hold the watch channel's read lock during that work, so the manager'ssend_replacedoes not have to wait on readers.PublishedDelegation::Presentnow stores anArc, so#[allow(clippy::large_enum_variant)]could be dropped as well.There is no behavior change.
Testing
Existing tests cover this change; the test harnesses were only updated to wrap builders in
Arc. The following pass:nns_delegation_manager,nns_delegation_reader, thepublicintegration tests,pocket-ic-server-lib);🤖 Generated with Claude Code