Repository navigation
feat(query-handler): return 503 on state-delegation mismatch in queries - #12064
Draft
pierugo-dfinity wants to merge 2 commits into
Draft
pierugo-dfinity wants to merge 2 commits into
pierugo-dfinity wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block approval of the query delegation-verification changes.
No open issues 🎉
What changed in this PR
This PR makes query execution verify NNS delegations against the certified state used to build each data certificate. Public query endpoints return HTTP 503 when verification fails, rather than serving an inconsistent certificate.
Changes:
- Move delegation verification into the query handler and propagate verification failures to HTTP responses, logs, and metrics.
- Adapt query interfaces, test runtimes, replay, and PocketIC to the delegation-reader API.
- Add coverage for delegation consistency, certificate metadata, and HTTP 503 responses.
| File | Description |
|---|---|
rs/state_machine_tests/src/lib.rs |
Adapt delegated queries to use a reader with relaxed range checks. |
rs/replica_tests/src/lib.rs |
Update query inputs and error handling. |
rs/replica_tests/Cargo.toml |
Add the logger dependency. |
rs/replica_tests/BUILD.bazel |
Add the Bazel logger dependency. |
rs/replay/src/player.rs |
Update replay query inputs and failure messages. |
rs/pocket_ic_server/src/pocket_ic.rs |
Pass delegations without separate metadata. |
rs/interfaces/src/execution_environment.rs |
Define reader-based query inputs and a verification error variant. |
rs/interfaces/Cargo.toml |
Add the delegation-reader dependency. |
rs/interfaces/BUILD.bazel |
Add the Bazel delegation-reader dependency. |
rs/http_endpoints/public/tests/test.rs |
Test HTTP 503 responses for delegation verification failures. |
rs/http_endpoints/public/src/query.rs |
Select range checks and map verification failures to HTTP 503. |
rs/http_endpoints/nns_delegation_reader/test_utils/BUILD.bazel |
Expose test utilities to execution-environment tests. |
rs/http_endpoints/nns_delegation_reader/src/reader.rs |
Verify delegations before returning them with metadata. |
rs/http_endpoints/nns_delegation_manager/src/lib.rs |
Re-export the delegation validation error type. |
rs/execution_environment/src/query_handler/tests.rs |
Test matching, mismatched, and absent delegations. |
rs/execution_environment/src/query_handler.rs |
Verify delegations against the certificate’s exact certified state. |
rs/execution_environment/Cargo.toml |
Add delegation test utilities. |
rs/execution_environment/BUILD.bazel |
Add delegation utilities and state-manager mocks for tests. |
Cargo.lock |
Record the added dependencies. |
Review effort: Balanced
pierugo-dfinity
force-pushed
the
pierugo/query-handler/serve-503
branch
from
November 13, 2026 15:39
87306c8 to
4a54480
Compare
pierugo-dfinity
changed the base branch from
master
to
pierugo/delegations/snapshot
November 13, 2026 15:40
The query handler verifies the NNS delegation against the exact certified state the data certificate is built from, and only embeds it if it is consistent. Otherwise the query fails with `QueryExecutionError::DelegationInconsistentWithState`, which the HTTP endpoint turns into a 503 so that clients retry once the replica has a fresh delegation. `QueryExecutionInput` carries the `NNSDelegationSnapshot` and the `CanisterRangesCheck` to apply, and `NNSDelegationSnapshot::get_delegation_with_metadata` (which did not verify the delegation) is replaced by `NNSDelegationSnapshot::build_verified_with_metadata`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pierugo-dfinity
force-pushed
the
pierugo/query-handler/serve-503
branch
from
November 16, 2026 15:12
4a54480 to
da6a28d
Compare
This branch has not been deployed
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.
No description provided.