22#ifdef ENABLE_HISTORICAL_VERBOSE_LOGGING
23# define HISTORICAL_LOG(...) LOG_INFO_FMT(__VA_ARGS__)
25# define HISTORICAL_LOG(...)
43 template <
typename ParseContext>
44 constexpr auto parse(ParseContext& ctx)
49 template <
typename FormatContext>
65 static constexpr auto slow_fetch_threshold = std::chrono::milliseconds(1000);
66 static constexpr size_t soft_to_raw_ratio{5};
68 static std::optional<ccf::PrimarySignature> get_signature(
71 auto tx = sig_store->create_read_only_tx();
73 return signatures->get();
76 static std::optional<ccf::CoseSignature> get_cose_signature(
79 auto tx = sig_store->create_read_only_tx();
81 return signatures->get();
84 static std::optional<std::vector<uint8_t>> get_tree(
87 auto tx = sig_store->create_read_only_tx();
123 "Source ledger secrets are empty");
132 "Historical ledger secrets are not older than main ledger secrets");
153 if (
store !=
nullptr)
155 auto e =
store->get_encryptor();
156 return e->get_commit_nonce(
160 throw std::logic_error(
"Store pointer not set");
224 return it->second.lock();
242 bool should_include_receipts,
243 SeqNo earliest_ledger_secret_seqno)
245 std::vector<SeqNo> removed{};
246 std::vector<SeqNo> added{};
255 bool any_too_early =
false;
259 auto new_it = new_seqnos.
begin();
260 while (new_it != new_seqnos.
end())
262 if (prev_it !=
my_stores.end() && *new_it == prev_it->first)
269 else if (prev_it !=
my_stores.end() && *new_it > prev_it->first)
273 removed.push_back(prev_it->first);
282 if (*new_it < earliest_ledger_secret_seqno || any_too_early)
286 added.push_back(*new_it);
287 prev_it =
my_stores.insert_or_assign(prev_it, *new_it,
nullptr);
288 any_too_early =
true;
294 all_it ==
all_stores.end() ? nullptr : all_it->second.lock();
295 if (details ==
nullptr)
298 details = std::make_shared<StoreDetails>();
299 all_stores.insert_or_assign(all_it, *new_it, details);
301 added.push_back(*new_it);
302 prev_it =
my_stores.insert_or_assign(prev_it, *new_it, details);
311 for (
auto it = prev_it; it !=
my_stores.end(); ++it)
313 removed.push_back(it->first);
319 const bool any_diff = !removed.empty() || !added.empty();
324 return {removed, added};
332 if (should_include_receipts)
339 for (
auto seqno : new_seqnos)
344 return {removed, added};
350 "Looking at {}, and populating receipts from it", new_seqno);
352 if (new_details !=
nullptr && new_details->store !=
nullptr)
354 if (new_details->is_signature)
358 fill_receipts_from_signature(new_details);
375 auto next_seqno = new_seqno + 1;
380 all_it ==
all_stores.end() ? nullptr : all_it->second.lock();
381 if (details ==
nullptr)
384 "Looking for new supporting signature at {}", next_seqno);
385 details = std::make_shared<StoreDetails>();
386 all_stores.insert_or_assign(all_it, next_seqno, details);
389 if (details->store ==
nullptr)
395 "Assigning {} as potential signature for {}",
402 if (details->is_signature)
404 const auto filled_this =
405 fill_receipts_from_signature(details, new_seqno);
410 throw std::logic_error(fmt::format(
411 "Unexpected: Found a signature at {}, and contiguous range "
412 "of transactions from {}, yet signature does not cover "
430 bool fill_receipts_from_signature(
431 const std::shared_ptr<StoreDetails>& sig_details,
432 std::optional<ccf::SeqNo> should_fill = std::nullopt)
436 const auto sig = get_signature(sig_details->store);
437 if (!sig.has_value())
441 const auto cose_sig = get_cose_signature(sig_details->store);
442 const auto serialised_tree = get_tree(sig_details->store);
443 if (!serialised_tree.has_value())
451 auto sig_lower_bound_it =
452 my_stores.lower_bound(sig_details->transaction_id.seqno);
454 if (sig_lower_bound_it !=
my_stores.begin())
457 auto search_rit = std::reverse_iterator(sig_lower_bound_it);
460 auto seqno = search_rit->first;
461 if (tree.in_range(
seqno))
463 auto details = search_rit->second;
464 if (details !=
nullptr && details->store !=
nullptr)
466 auto proof = tree.get_proof(
seqno);
467 details->transaction_id = {sig->view,
seqno};
468 details->receipt = std::make_shared<TxReceiptImpl>(
475 details->entry_digest,
476 details->get_commit_evidence(),
477 details->claims_digest);
479 "Assigned a receipt for {} after given signature at {}",
481 sig_details->transaction_id.to_str());
483 if (should_fill.has_value() &&
seqno == *should_fill)
500 return !should_fill.has_value();
520 std::map<CompoundHandle, std::list<CompoundHandle>::iterator>
lru_lookup;
547 it->second.insert(handle);
553 for (
const auto& [seq, _] :
requests.at(handle).my_stores)
564 it->second.erase(handle);
565 if (it->second.empty())
579 for (
const auto& [seq, _] :
requests.at(handle).my_stores)
607 "LRU shrink to {} requested but cache is already empty", threshold);
613 "Cache size shrinking (reached {} / {}). Dropping {}",
640 assert(!stored_size || stored_size == new_size);
644 stored_size = new_size;
657 ::consensus::ledger_get_range,
667 auto [earliest_ledger_secret_seqno, earliest_ledger_secret] =
670 earliest_ledger_secret !=
nullptr,
671 "Can't fetch without knowing earliest");
673 const auto too_early =
seqno < earliest_ledger_secret_seqno;
675 auto previous_secret_stored_version =
676 earliest_ledger_secret->previous_secret_stored_version;
677 const auto is_next_secret =
678 previous_secret_stored_version.value_or(0) ==
seqno;
680 if (too_early || is_next_secret)
683 if (!previous_secret_stored_version.has_value())
685 throw std::logic_error(fmt::format(
686 "Earliest known ledger secret at {} has no earlier secret stored "
688 earliest_ledger_secret_seqno,
692 const auto seqno_to_fetch = previous_secret_stored_version.value();
694 "Requesting historical entry at {} but first known ledger "
695 "secret is applicable from {}",
697 earliest_ledger_secret_seqno);
700 auto details = it ==
all_stores.end() ? nullptr : it->second.lock();
701 if (details ==
nullptr)
703 LOG_TRACE_FMT(
"Requesting older secret at {} now", seqno_to_fetch);
704 details = std::make_shared<StoreDetails>();
705 all_stores.insert_or_assign(it, seqno_to_fetch, details);
713 return seqno_to_fetch;
727 bool has_commit_evidence)
732 details->has_commit_evidence = has_commit_evidence;
734 details->entry_digest = entry_digest;
735 if (!claims_digest.empty())
737 details->claims_digest = std::move(claims_digest);
741 details->store ==
nullptr,
742 "Cache already has store for seqno {}",
744 details->store = store;
746 details->is_signature = is_signature;
754 const auto sig = get_signature(details->store);
755 const auto cose_sig = get_cose_signature(details->store);
758 details->transaction_id = {sig->view, sig->seqno};
759 details->receipt = std::make_shared<TxReceiptImpl>(
760 sig->sig, cose_sig, sig->root.h,
nullptr, sig->node, sig->cert);
765 while (request_it !=
requests.end())
767 auto& [handle, request] = *request_it;
772 request.awaiting_ledger_secrets.has_value() &&
773 request.awaiting_ledger_secrets.value() ==
seqno)
776 "{} is a ledger secret seqno this request was waiting for",
seqno);
778 request.awaiting_ledger_secrets =
780 if (!request.awaiting_ledger_secrets.has_value())
785 auto my_stores_it = request.my_stores.begin();
786 while (my_stores_it != request.my_stores.end())
788 auto [store_seqno, _] = *my_stores_it;
791 it ==
all_stores.end() ? nullptr : it->second.lock();
793 if (store_details ==
nullptr)
795 store_details = std::make_shared<StoreDetails>();
796 all_stores.insert_or_assign(it, store_seqno, store_details);
799 my_stores_it->second = store_details;
809 if (request.include_receipts)
811 const bool seqno_in_this_request =
812 (request.my_stores.find(
seqno) != request.my_stores.end() ||
813 request.supporting_signatures.find(
seqno) !=
814 request.supporting_signatures.end());
815 if (seqno_in_this_request)
817 request.populate_receipts(
seqno);
829 auto tx = store->create_read_only_tx();
830 auto* encrypted_past_ledger_secret_handle =
832 ccf::Tables::ENCRYPTED_PAST_LEDGER_SECRET);
833 if (encrypted_past_ledger_secret_handle ==
nullptr)
838 auto encrypted_past_ledger_secret =
839 encrypted_past_ledger_secret_handle->get();
840 if (!encrypted_past_ledger_secret.has_value())
846 auto previous_ledger_secret =
847 encrypted_past_ledger_secret->previous_ledger_secret;
848 if (!previous_ledger_secret.has_value())
853 encrypted_past_ledger_secret->next_version.has_value() &&
854 encrypted_past_ledger_secret->next_version.value() == 1,
855 "Write to ledger secrets table at {} should contain a next_version "
857 store->current_version());
861 auto recovered_ledger_secret = std::make_shared<LedgerSecret>(
863 encrypting_secret, previous_ledger_secret->encrypted_data),
864 previous_ledger_secret->previous_secret_stored_version);
868 previous_ledger_secret->version, std::move(recovered_ledger_secret));
881 if (end_seqno < start_seqno)
883 throw std::logic_error(fmt::format(
884 "Invalid range for historical query: end {} is before start {}",
897 bool include_receipts)
901 throw std::logic_error(
902 "Invalid range for historical query: Cannot request empty range");
907 const auto ms_until_expiry =
908 std::chrono::duration_cast<std::chrono::milliseconds>(
909 seconds_until_expiry);
927 "Adjusting handle {} to cover {} seqnos starting at {} "
928 "(include_receipts={})",
936 for (
auto seq : removed)
940 for (
auto seq : added)
954 std::vector<StatePtr> trusted_states;
956 for (
auto seqno : seqnos)
960 target_details !=
nullptr &&
966 StatePtr state = std::make_shared<State>(
967 target_details->store,
968 target_details->receipt,
969 target_details->transaction_id);
970 trusted_states.push_back(state);
980 return trusted_states;
988 while (request_it !=
requests.end())
990 if (request_it->second.get_store_details(
seqno) !=
nullptr)
993 request_it =
requests.erase(request_it);
1003 const std::vector<StatePtr>& states)
1005 std::vector<ccf::kv::ReadOnlyStorePtr> stores;
1006 stores.reserve(states.size());
1007 for (
const auto& state : states)
1009 stores.push_back(state->store);
1017 const std::shared_ptr<ccf::LedgerSecrets>& secrets,
1075 seconds_until_expiry,
1097 seconds_until_expiry,
1132 throw std::runtime_error(
"Cannot request empty range");
1163 const auto erased_count =
requests.erase(handle);
1164 return erased_count > 0;
1176 auto details = it ==
all_stores.end() ? nullptr : it->second.lock();
1186 bool has_commit_evidence =
false;
1193 has_commit_evidence);
1203 const auto tx_id = store->current_txid();
1204 if (tx_id.seqno !=
seqno)
1207 "Corrupt ledger entry received - claims to be {} but is actually "
1223 if (actual_view != tx_id.view)
1226 "Ledger entry comes from fork - contains {}.{} but this service "
1236 const auto is_signature =
1243 if (secret !=
nullptr)
1245 const auto& prev_version = secret->previous_secret_stored_version;
1246 if (prev_version.has_value() && *prev_version ==
seqno)
1249 "Handling past ledger secret. Current earliest is valid from {}, "
1251 "processing secret stored at {}",
1260 "Processing historical store at {} ({})",
1262 (
size_t)deserialise_result);
1270 std::move(claims_digest),
1271 has_commit_evidence);
1281 from_seqno, to_seqno, data.data(), data.size());
1287 const uint8_t* data,
1290 LOG_TRACE_FMT(
"handle_ledger_entries({}, {})", from_seqno, to_seqno);
1292 auto seqno = from_seqno;
1293 bool all_accepted =
true;
1297 serialized::peek<ccf::kv::SerialisedEntryHeader>(data, size);
1298 const auto whole_size =
1299 header.size + ccf::kv::serialised_entry_header_size;
1306 if (
seqno != to_seqno + 1)
1309 "Claimed ledger entries: [{}, {}), actual [{}, {}]",
1316 return all_accepted;
1328 LOG_TRACE_FMT(
"handle_no_entry_range({}, {})", from_seqno, to_seqno);
1348 const uint8_t* data,
1352 bool& has_commit_evidence)
1361 if (seqno < source_ledger_secrets->get_first().first)
1376 bool public_only =
false;
1377 for (
const auto& [_, request] :
requests)
1379 const auto& als = request.awaiting_ledger_secrets;
1380 if (als.has_value() && als.value() ==
seqno)
1387 auto exec = store->deserialize({data, data + size}, public_only);
1388 if (exec ==
nullptr)
1395 claims_digest = std::move(exec->consume_claims_digest());
1397 auto commit_evidence_digest =
1398 std::move(exec->consume_commit_evidence_digest());
1399 has_commit_evidence = commit_evidence_digest.has_value();
1401 catch (
const std::exception& e)
1404 "Exception while attempting to deserialise entry {}: {}",
1419 void tick(
const std::chrono::milliseconds& elapsed_ms)
1427 auto& request = it->second;
1428 if (elapsed_ms >= request.time_to_expiry)
1431 "Dropping expired historical query with handle {}", it->first);
1437 request.time_to_expiry -= elapsed_ms;
1447 std::optional<std::pair<ccf::SeqNo, ccf::SeqNo>> range_to_request =
1451 auto details = it->second.lock();
1452 if (details ==
nullptr)
1460 details->time_until_fetch -= elapsed_ms;
1461 if (details->time_until_fetch.count() <= 0)
1463 details->time_until_fetch = slow_fetch_threshold;
1465 const auto seqno = it->first;
1466 if (
auto range_val = range_to_request; range_val.has_value())
1468 auto range = range_val.value();
1469 if (range.second + 1 ==
seqno)
1471 range.second =
seqno;
1472 range_to_request = range;
1479 range_to_request = std::make_pair(
seqno,
seqno);
1485 range_to_request = std::make_pair(
seqno,
seqno);
1494 if (
auto range_val = range_to_request; range_val.has_value())
1497 auto range = range_val.value();
1513 template <
typename... Ts>
1556 seconds_until_expiry);
1578 seconds_until_expiry);
#define CCF_ASSERT_FMT(expr,...)
Definition ccf_assert.h:10
#define CCF_ASSERT(expr, msg)
Definition ccf_assert.h:14
Definition claims_digest.h:10
Definition ledger_secrets.h:25
Definition sha256_hash.h:16
Definition contiguous_set.h:18
ConstIterator end() const
Definition contiguous_set.h:490
bool empty() const
Definition contiguous_set.h:317
ConstIterator begin() const
Definition contiguous_set.h:485
size_t size() const
Definition contiguous_set.h:309
Definition historical_queries_interface.h:67
Definition historical_queries.h:94
std::map< CompoundHandle, std::list< CompoundHandle >::iterator > lru_lookup
Definition historical_queries.h:520
void update_store_raw_size(SeqNo seq, size_t new_size)
Definition historical_queries.h:637
void process_deserialised_store(const StoreDetailsPtr &details, const ccf::kv::StorePtr &store, const ccf::crypto::Sha256Hash &entry_digest, ccf::SeqNo seqno, bool is_signature, ccf::ClaimsDigest &&claims_digest, bool has_commit_evidence)
Definition historical_queries.h:720
std::vector< StatePtr > get_states_for(const CompoundHandle &handle, const SeqNoCollection &seqnos)
Definition historical_queries.h:1137
std::map< CompoundHandle, Request > requests
Definition historical_queries.h:508
std::list< CompoundHandle > lru_requests
Definition historical_queries.h:519
std::vector< ccf::kv::ReadOnlyStorePtr > states_to_stores(const std::vector< StatePtr > &states)
Definition historical_queries.h:1002
ExpiryDuration default_expiry_duration
Definition historical_queries.h:515
bool track_deletes_on_missing_keys_v
Definition historical_queries.h:104
ccf::kv::Store & source_store
Definition historical_queries.h:96
std::map< ccf::SeqNo, WeakStoreDetailsPtr > AllRequestedStores
Definition historical_queries.h:181
ringbuffer::WriterPtr to_host
Definition historical_queries.h:98
void add_request_refs(CompoundHandle handle)
Definition historical_queries.h:551
std::vector< StatePtr > get_state_range(const CompoundHandle &handle, ccf::SeqNo start_seqno, ccf::SeqNo end_seqno, ExpiryDuration seconds_until_expiry)
Definition historical_queries.h:1088
std::unordered_map< SeqNo, std::set< CompoundHandle > > store_to_requests
Definition historical_queries.h:524
std::vector< StatePtr > get_state_range(const CompoundHandle &handle, ccf::SeqNo start_seqno, ccf::SeqNo end_seqno)
Definition historical_queries.h:1101
StoreStage
Definition historical_queries.h:107
AllRequestedStores all_stores
Definition historical_queries.h:513
void set_soft_cache_limit(CacheSize cache_limit)
Definition historical_queries.h:1148
void remove_request_ref(SeqNo seq, CompoundHandle handle)
Definition historical_queries.h:559
CacheSize estimated_store_cache_size
Definition historical_queries.h:530
StatePtr get_state_at(const CompoundHandle &handle, ccf::SeqNo seqno, ExpiryDuration seconds_until_expiry)
Definition historical_queries.h:1047
StateCacheImpl(ccf::kv::Store &store, const std::shared_ptr< ccf::LedgerSecrets > &secrets, ringbuffer::WriterPtr host_writer)
Definition historical_queries.h:1015
bool drop_cached_states(const CompoundHandle &handle)
Definition historical_queries.h:1159
void handle_no_entry(ccf::SeqNo seqno)
Definition historical_queries.h:1319
void remove_request_refs(CompoundHandle handle)
Definition historical_queries.h:577
void track_deletes_on_missing_keys(bool track)
Definition historical_queries.h:1154
std::vector< StatePtr > get_states_for(const CompoundHandle &handle, const SeqNoCollection &seqnos, ExpiryDuration seconds_until_expiry)
Definition historical_queries.h:1125
std::vector< ccf::kv::ReadOnlyStorePtr > get_stores_for(const CompoundHandle &handle, const SeqNoCollection &seqnos, ExpiryDuration seconds_until_expiry)
Definition historical_queries.h:1110
std::map< ccf::SeqNo, StoreDetailsPtr > RequestedStores
Definition historical_queries.h:178
void handle_no_entry_range(ccf::SeqNo from_seqno, ccf::SeqNo to_seqno)
Definition historical_queries.h:1324
bool handle_encrypted_past_ledger_secret(const ccf::kv::StorePtr &store, LedgerSecretPtr encrypting_secret)
Definition historical_queries.h:825
ccf::kv::ReadOnlyStorePtr get_store_at(const CompoundHandle &handle, ccf::SeqNo seqno)
Definition historical_queries.h:1041
StatePtr get_state_at(const CompoundHandle &handle, ccf::SeqNo seqno)
Definition historical_queries.h:1061
std::shared_ptr< ccf::NodeEncryptor > historical_encryptor
Definition historical_queries.h:101
CacheSize soft_store_cache_limit
Definition historical_queries.h:527
void add_request_ref(SeqNo seq, CompoundHandle handle)
Definition historical_queries.h:532
void fetch_entries_range(ccf::SeqNo from, ccf::SeqNo to)
Definition historical_queries.h:652
std::vector< uint8_t > LedgerEntry
Definition historical_queries.h:112
bool handle_ledger_entry(ccf::SeqNo seqno, const uint8_t *data, size_t size)
Definition historical_queries.h:1172
void fetch_entry_at(ccf::SeqNo seqno)
Definition historical_queries.h:647
ccf::kv::ReadOnlyStorePtr get_store_at(const CompoundHandle &handle, ccf::SeqNo seqno, ExpiryDuration seconds_until_expiry)
Definition historical_queries.h:1027
StoreDetailsPtr next_secret_fetch_handle
Definition historical_queries.h:198
void update_earliest_known_ledger_secret()
Definition historical_queries.h:114
ccf::pal::Mutex requests_lock
Definition historical_queries.h:505
std::shared_ptr< StoreDetails > StoreDetailsPtr
Definition historical_queries.h:177
bool handle_ledger_entry(ccf::SeqNo seqno, const std::vector< uint8_t > &data)
Definition historical_queries.h:1167
void tick(const std::chrono::milliseconds &elapsed_ms)
Definition historical_queries.h:1419
VersionedSecret earliest_secret_
Definition historical_queries.h:197
std::optional< ccf::SeqNo > fetch_supporting_secret_if_needed(ccf::SeqNo seqno)
Definition historical_queries.h:664
std::unordered_map< ccf::SeqNo, size_t > raw_store_sizes
Definition historical_queries.h:525
std::shared_ptr< ccf::LedgerSecrets > source_ledger_secrets
Definition historical_queries.h:97
ccf::kv::StorePtr deserialise_ledger_entry(ccf::SeqNo seqno, const uint8_t *data, size_t size, ccf::kv::ApplyResult &result, ccf::ClaimsDigest &claims_digest, bool &has_commit_evidence)
Definition historical_queries.h:1346
std::shared_ptr< ccf::LedgerSecrets > historical_ledger_secrets
Definition historical_queries.h:100
std::vector< ccf::kv::ReadOnlyStorePtr > get_stores_for(const CompoundHandle &handle, const SeqNoCollection &seqnos)
Definition historical_queries.h:1119
std::vector< StatePtr > get_states_internal(const CompoundHandle &handle, const SeqNoCollection &seqnos, ExpiryDuration seconds_until_expiry, bool include_receipts)
Definition historical_queries.h:893
void delete_all_interested_requests(ccf::SeqNo seqno)
Definition historical_queries.h:985
void lru_shrink_to_fit(size_t threshold)
Definition historical_queries.h:600
bool handle_ledger_entries(ccf::SeqNo from_seqno, ccf::SeqNo to_seqno, const uint8_t *data, size_t size)
Definition historical_queries.h:1284
size_t get_estimated_store_cache_size()
Definition historical_queries.h:1413
CacheSize soft_store_cache_limit_raw
Definition historical_queries.h:528
void set_default_expiry_duration(ExpiryDuration duration)
Definition historical_queries.h:1143
bool handle_ledger_entries(ccf::SeqNo from_seqno, ccf::SeqNo to_seqno, const LedgerEntry &data)
Definition historical_queries.h:1277
std::vector< ccf::kv::ReadOnlyStorePtr > get_store_range(const CompoundHandle &handle, ccf::SeqNo start_seqno, ccf::SeqNo end_seqno)
Definition historical_queries.h:1079
std::weak_ptr< StoreDetails > WeakStoreDetailsPtr
Definition historical_queries.h:180
SeqNoCollection collection_from_single_range(ccf::SeqNo start_seqno, ccf::SeqNo end_seqno)
Definition historical_queries.h:878
std::vector< ccf::kv::ReadOnlyStorePtr > get_store_range(const CompoundHandle &handle, ccf::SeqNo start_seqno, ccf::SeqNo end_seqno, ExpiryDuration seconds_until_expiry)
Definition historical_queries.h:1066
void lru_promote(CompoundHandle handle)
Definition historical_queries.h:585
void lru_evict(CompoundHandle handle)
Definition historical_queries.h:626
Definition historical_queries.h:1505
StatePtr get_state_at(RequestHandle handle, ccf::SeqNo seqno, ExpiryDuration seconds_until_expiry) override
Definition historical_queries.h:1532
std::vector< StatePtr > get_state_range(RequestHandle handle, ccf::SeqNo start_seqno, ccf::SeqNo end_seqno, ExpiryDuration seconds_until_expiry) override
Definition historical_queries.h:1568
std::vector< StatePtr > get_states_for(RequestHandle handle, const SeqNoCollection &seqnos, ExpiryDuration seconds_until_expiry) override
Definition historical_queries.h:1606
CompoundHandle make_compound_handle(RequestHandle rh)
Definition historical_queries.h:1507
std::vector< ccf::kv::ReadOnlyStorePtr > get_store_range(RequestHandle handle, ccf::SeqNo start_seqno, ccf::SeqNo end_seqno) override
Definition historical_queries.h:1559
ccf::kv::ReadOnlyStorePtr get_store_at(RequestHandle handle, ccf::SeqNo seqno) override
Definition historical_queries.h:1526
std::vector< ccf::kv::ReadOnlyStorePtr > get_stores_for(RequestHandle handle, const SeqNoCollection &seqnos) override
Definition historical_queries.h:1599
std::vector< ccf::kv::ReadOnlyStorePtr > get_stores_for(RequestHandle handle, const SeqNoCollection &seqnos, ExpiryDuration seconds_until_expiry) override
Definition historical_queries.h:1590
StatePtr get_state_at(RequestHandle handle, ccf::SeqNo seqno) override
Definition historical_queries.h:1541
void set_soft_cache_limit(CacheSize cache_limit) override
Definition historical_queries.h:1627
std::vector< StatePtr > get_state_range(RequestHandle handle, ccf::SeqNo start_seqno, ccf::SeqNo end_seqno) override
Definition historical_queries.h:1581
ccf::kv::ReadOnlyStorePtr get_store_at(RequestHandle handle, ccf::SeqNo seqno, ExpiryDuration seconds_until_expiry) override
Definition historical_queries.h:1517
void set_default_expiry_duration(ExpiryDuration duration) override
Definition historical_queries.h:1622
bool drop_cached_states(RequestHandle handle) override
Definition historical_queries.h:1637
std::vector< StatePtr > get_states_for(RequestHandle handle, const SeqNoCollection &seqnos) override
Definition historical_queries.h:1615
void track_deletes_on_missing_keys(bool track) override
Definition historical_queries.h:1632
std::vector< ccf::kv::ReadOnlyStorePtr > get_store_range(RequestHandle handle, ccf::SeqNo start_seqno, ccf::SeqNo end_seqno, ExpiryDuration seconds_until_expiry) override
Definition historical_queries.h:1546
StateCache(Ts &&... ts)
Definition historical_queries.h:1514
ReadOnlyTx create_read_only_tx() override
Definition store.h:1267
EncryptorPtr get_encryptor() override
Definition store.h:220
std::shared_ptr< Consensus > get_consensus() override
Definition store.h:182
Definition encryptor.h:15
#define HISTORICAL_LOG(...)
Definition historical_queries.h:25
#define LOG_TRACE_FMT
Definition internal_logger.h:13
#define LOG_DEBUG_FMT
Definition internal_logger.h:14
#define LOG_FAIL_FMT
Definition internal_logger.h:16
std::vector< uint8_t > HashBytes
Definition hash_bytes.h:10
Definition historical_queries_adapter.h:18
std::chrono::seconds ExpiryDuration
Definition historical_queries_interface.h:50
std::shared_ptr< State > StatePtr
Definition historical_queries_interface.h:41
RequestNamespace
Definition historical_queries.h:31
std::pair< RequestNamespace, RequestHandle > CompoundHandle
Definition historical_queries.h:36
size_t RequestHandle
Definition historical_queries_interface.h:48
size_t CacheSize
Definition historical_queries_interface.h:52
std::shared_ptr< ReadOnlyStore > ReadOnlyStorePtr
Definition read_only_store.h:23
std::shared_ptr< ccf::kv::Store > StorePtr
Definition store.h:1332
ApplyResult
Definition kv_types.h:302
@ PASS_SIGNATURE
Definition kv_types.h:304
@ FAIL
Definition kv_types.h:311
std::mutex Mutex
Definition locking.h:12
Definition app_interface.h:14
LedgerSecretsMap::value_type VersionedLedgerSecret
Definition ledger_secrets.h:22
std::shared_ptr< TxReceiptImpl > TxReceiptImplPtr
Definition receipt.h:133
std::shared_ptr< LedgerSecret > LedgerSecretPtr
Definition ledger_secret.h:79
seqno
Definition signatures.h:54
uint64_t SeqNo
Definition tx_id.h:36
std::vector< uint8_t > decrypt_previous_ledger_secret_raw(const LedgerSecretPtr &ledger_secret, const std::vector< uint8_t > &encrypted_previous_secret_raw)
Definition ledger_secret.h:87
Definition consensus_types.h:23
uint64_t Index
Definition ledger_enclave_types.h:11
@ HistoricalQuery
Definition ledger_enclave_types.h:16
std::shared_ptr< AbstractWriter > WriterPtr
Definition ring_buffer_types.h:154
#define RINGBUFFER_WRITE_MESSAGE(MSG,...)
Definition ring_buffer_types.h:259
SeqNo seqno
Definition tx_id.h:46
View view
Definition tx_id.h:45
Definition historical_queries.h:201
bool include_receipts
Definition historical_queries.h:207
StoreDetailsPtr get_store_details(ccf::SeqNo seqno) const
Definition historical_queries.h:219
Request(AllRequestedStores &all_stores_)
Definition historical_queries.h:217
void populate_receipts(ccf::SeqNo new_seqno)
Definition historical_queries.h:347
std::pair< std::vector< SeqNo >, std::vector< SeqNo > > adjust_ranges(const SeqNoCollection &new_seqnos, bool should_include_receipts, SeqNo earliest_ledger_secret_seqno)
Definition historical_queries.h:240
std::optional< ccf::SeqNo > awaiting_ledger_secrets
Definition historical_queries.h:215
AllRequestedStores & all_stores
Definition historical_queries.h:202
std::chrono::milliseconds time_to_expiry
Definition historical_queries.h:205
RequestedStores supporting_signatures
Definition historical_queries.h:212
ccf::SeqNo first_requested_seqno() const
Definition historical_queries.h:230
RequestedStores my_stores
Definition historical_queries.h:204
Definition historical_queries.h:140
std::chrono::milliseconds time_until_fetch
Definition historical_queries.h:141
std::optional< std::string > get_commit_evidence()
Definition historical_queries.h:163
bool has_commit_evidence
Definition historical_queries.h:149
ccf::kv::StorePtr store
Definition historical_queries.h:145
ccf::ClaimsDigest claims_digest
Definition historical_queries.h:144
ccf::crypto::Sha256Hash entry_digest
Definition historical_queries.h:143
ccf::TxID transaction_id
Definition historical_queries.h:148
ccf::crypto::HashBytes get_commit_nonce()
Definition historical_queries.h:151
TxReceiptImplPtr receipt
Definition historical_queries.h:147
StoreStage current_stage
Definition historical_queries.h:142
bool is_signature
Definition historical_queries.h:146
Definition historical_queries.h:184
ccf::LedgerSecretPtr secret
Definition historical_queries.h:186
ccf::SeqNo valid_from
Definition historical_queries.h:185
VersionedSecret(const ccf::VersionedLedgerSecret &vls)
Definition historical_queries.h:191
VersionedSecret()=default