-
Notifications
You must be signed in to change notification settings - Fork 247
Add support for block-until-commit responses #7562
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request adds support for endpoints that defer their HTTP responses until the transaction is globally committed (or invalidated) by the consensus protocol. The implementation introduces a commit callback subsystem, modifies the task system to use shared ownership for resumable tasks, and integrates these changes throughout the RPC stack.
- Introduces
CommitCallbackSubsystemto manage callbacks triggered when transactions reach terminal consensus states - Changes
Resumablefromunique_ptrtoshared_ptrto support capturing in lambda callbacks - Adds
set_consensus_committed_functionto endpoint configuration API allowing endpoints to defer responses
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/e2e_logging.py | Adds test comparing response timing between blocking and non-blocking endpoints |
| src/tasks/task_system.cpp | Updates function signature to accept Resumable by value instead of rvalue reference |
| src/tasks/resumable.h | Changes Resumable from unique_ptr to shared_ptr to enable shared ownership |
| src/node/rpc_context_impl.h | Adds optional respond_on_commit field to track deferred responses |
| src/node/commit_callback_subsystem.h | New subsystem managing callbacks for committed/invalidated transactions |
| src/node/commit_callback_interface.h | Interface definition for commit callback subsystem |
| src/http/http_session.h | Implements response deferral by pausing tasks and registering commit callbacks |
| src/endpoints/endpoint_registry.cpp | Adds default handler for commit responses that reports invalidated transactions |
| src/endpoints/endpoint.cpp | Implements setter for consensus_committed_func |
| src/node/node_state.h | Integrates commit_callbacks subsystem into node state |
| src/enclave/rpc_sessions.h | Passes commit callbacks subsystem to HTTP sessions |
| src/enclave/enclave.h | Creates and installs commit callback subsystem during initialization |
| src/consensus/aft/raft.h | Integrates callback execution when transactions commit |
| src/node/rpc/frontend.h | Sets respond_on_commit when endpoint has consensus_committed_func |
| samples/apps/logging/logging.cpp | Demonstrates blocking endpoints with example /log/blocking/private endpoints |
| include/ccf/tx_status.h | Adds FinalTxStatus enum containing only terminal transaction states |
| include/ccf/endpoint_registry.h | Declares default_respond_on_commit_func in public API |
| include/ccf/endpoint_context.h | Defines ConsensusCommittedEndpointFunction type |
| include/ccf/endpoint.h | Adds consensus_committed_func field and setter to Endpoint |
| CHANGELOG.md | Documents the new feature and adds formatting changes to older sections |
Comments suppressed due to low confidence (5)
CHANGELOG.md:2160
- This adds an extra blank line that appears unintentional. This section already had proper formatting and this change doesn't improve readability.
- The new `command.start.service_configuration.maximum_node_certificate_validity_days` (defaults to 365 days) configuration entry sets the maximum validity period allowed for node certificates.
CHANGELOG.md:1874
- This adds an extra blank line that appears unintentional. This section already had proper formatting and this change doesn't improve readability.
- The new `node_certificate.initial_validity_days` (defaults to 1 day) configuration entry lets operators set the initial validity period for the node certificate (valid from the current system time).
CHANGELOG.md:2908
- This adds an extra blank line that appears unintentional. The surrounding sections don't use blank lines to separate items in this way.
CHANGELOG.md:2913 - This adds an extra blank line that appears unintentional. The surrounding sections don't use blank lines to separate items in this way.
- Governance
CHANGELOG.md:2918
- This adds an extra blank line that appears unintentional. The surrounding sections don't use blank lines to separate items in this way.
…into respond_at_commit
… back into consensus
This has taken a few different forms as I tried to work out what the right API was. I think this is a neat approach, and roughly minimal for apps to implement - a new modifier when installing an endpoint that defers the response until commit, and a default callback that inserts an error response if the TxID is invalidated.
A handful of outstanding items, probably for future PRs but up-for-discussion:
CommittedorInvalid) is not reached for a long time, the caller may still want to know the assignedTxID, rather than simply getting a client HTTP timeout.