Skip to content

Commit b8cefa9

Browse files
authored
Merge branch 'main' into respond_at_commit
2 parents 7968e0e + c17a103 commit b8cefa9

File tree

4 files changed

+35
-17
lines changed

4 files changed

+35
-17
lines changed

.github/copilot-instructions.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
**Key directories**:
77

8-
- `src/` - Core CCF implementation in C++ (consensus, crypto, kv store, HTTP, TLS, JavaScript runtime), including unit tests in subdirs
8+
- `src/` - Core CCF implementation in C++ (consensus, crypto, KV store, HTTP, TLS, JavaScript runtime), including unit tests in subdirs
99
- `include/ccf/` - Public C++ API headers
1010
- `tests/` - Python-based end-to-end test suite
1111
- `python/` - CCF Python SDK and client libraries
@@ -16,8 +16,8 @@
1616

1717
- Coding style is enforced by the `ci-checks.sh` script, which runs clang-format for C++ and black for Python.
1818
- Linters and static analysis tools are also run as part of CI, clang-tidy for C++ and ruff for Python.
19-
- Run `ci-checks.sh -f` to automatically run these tools.
20-
- This tool must run successfully before creating a PR.
19+
- Run `ci-checks.sh -f` to automatically apply fixes (formatting and supported lint fixes).
20+
- `ci-checks.sh` must run successfully before any commit is pushed.
2121
- Match the existing coding style for naming and casing conventions. This is not automatically enforced, so pay attention to surrounding code for guidance.
2222
- All tests in `ci.yml` must pass before a PR can be merged. Consider which are likely to be affected by your changes and run those locally before pushing.
2323
- Take particular care with any changes that may affect compatibility with older releases, and ensure these are tested, via the `lts_compatibility` test with `LONG_TESTS=1` enabled.

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1111

1212
### Added
1313

14+
- Added `ccf::IdentityHistoryNotFetched` exception type to distinguish identity-history-fetching errors from other logic errors in the network identity subsystem (#7708).
1415
- Added `ccf::describe_cose_receipt_v1(receipt)` to obtain COSE receipts with Merkle proof in unprotected header for non-signature TXs, and empty unprotected header for signature TXs (#7700).
1516
- `NetworkIdentitySubsystemInterface` now exposes `get_trusted_keys()`, returning all trusted network identity keys as a `TrustedKeys` map (#7690).
1617

include/ccf/network_identity_interface.h

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "ccf/crypto/ec_public_key.h"
66
#include "ccf/node_subsystem_interface.h"
77

8+
#include <exception>
89
#include <map>
910
#include <optional>
1011
#include <string>
@@ -31,6 +32,20 @@ namespace ccf
3132
/// network identity keys over the history of the service.
3233
using TrustedKeys = std::map<ccf::SeqNo, ccf::crypto::ECPublicKeyPtr>;
3334

35+
/// Exception thrown when identity data is requested before the
36+
/// asynchronous identity-history-fetching process has completed.
37+
struct IdentityHistoryNotFetched : public std::exception
38+
{
39+
std::string msg;
40+
41+
IdentityHistoryNotFetched(std::string msg) : msg(std::move(msg)) {}
42+
43+
[[nodiscard]] const char* what() const noexcept override
44+
{
45+
return msg.c_str();
46+
}
47+
};
48+
3449
/// Interface for accessing the network identity subsystem, which manages
3550
/// the service's cryptographic identity and its historical trusted keys.
3651
class NetworkIdentitySubsystemInterface : public ccf::AbstractNodeSubSystem
@@ -53,25 +68,27 @@ namespace ccf
5368
/// or std::nullopt if the chain is not available for the given sequence
5469
/// number.
5570
///
56-
/// @throws std::logic_error if endorsement fetching has not completed.
71+
/// @throws IdentityHistoryNotFetched if identity history fetching has not
72+
/// completed.
5773
[[nodiscard]] virtual std::optional<CoseEndorsementsChain>
5874
get_cose_endorsements_chain(ccf::SeqNo seqno) const = 0;
5975

6076
/// Returns the trusted EC public key that was active at the given
6177
/// sequence number, or nullptr if the sequence number precedes the
6278
/// earliest known trusted key.
6379
///
64-
/// @throws std::logic_error if endorsement fetching has not completed
65-
/// (i.e. endorsements_fetching_status() != FetchStatus::Done), or if
66-
/// no trusted keys have been fetched.
80+
/// @throws IdentityHistoryNotFetched if identity history fetching has not
81+
/// completed.
82+
/// @throws std::logic_error if no trusted keys have been fetched, or if
83+
/// internal key resolution is inconsistent.
6784
[[nodiscard]] virtual ccf::crypto::ECPublicKeyPtr get_trusted_identity_for(
6885
ccf::SeqNo seqno) const = 0;
6986

7087
/// Returns all trusted network identity keys as a map from sequence
7188
/// number to EC public key.
7289
///
73-
/// @throws std::logic_error if endorsement fetching has not completed
74-
/// (i.e. endorsements_fetching_status() != FetchStatus::Done).
90+
/// @throws IdentityHistoryNotFetched if identity history fetching has not
91+
/// completed.
7592
[[nodiscard]] virtual TrustedKeys get_trusted_keys() const = 0;
7693
};
7794
}

src/node/rpc/network_identity_subsystem.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,9 @@ namespace ccf
144144
{
145145
if (fetch_status.load() != FetchStatus::Done)
146146
{
147-
throw std::logic_error(fmt::format(
148-
"COSE endorsements chain requested for seqno {} but endorsement "
149-
"fetching has not been completed yet",
147+
throw IdentityHistoryNotFetched(fmt::format(
148+
"COSE endorsements chain requested for seqno {} but identity "
149+
"history fetching has not been completed yet",
150150
seqno));
151151
}
152152

@@ -186,9 +186,9 @@ namespace ccf
186186
{
187187
if (fetch_status.load() != FetchStatus::Done)
188188
{
189-
throw std::logic_error(fmt::format(
190-
"Trusted key requested for seqno {} but the fetching has "
191-
"not been completed yet",
189+
throw IdentityHistoryNotFetched(fmt::format(
190+
"Trusted key requested for seqno {} but identity history "
191+
"fetching has not been completed yet",
192192
seqno));
193193
}
194194
if (trusted_keys.empty())
@@ -217,8 +217,8 @@ namespace ccf
217217
{
218218
if (fetch_status.load() != FetchStatus::Done)
219219
{
220-
throw std::logic_error(
221-
"Trusted keys requested but endorsements/key fetching has not "
220+
throw IdentityHistoryNotFetched(
221+
"Trusted keys requested but identity history fetching has not "
222222
"completed yet");
223223
}
224224
return trusted_keys;

0 commit comments

Comments
 (0)