23#ifdef ENABLE_HISTORICAL_VERBOSE_LOGGING
24# define HISTORICAL_LOG(...) LOG_INFO_FMT(__VA_ARGS__)
27# define HISTORICAL_LOG(...)
45 template <
typename ParseContext>
46 constexpr auto parse(ParseContext& ctx)
51 template <
typename FormatContext>
67 static constexpr auto slow_fetch_threshold = std::chrono::milliseconds(1000);
69 static std::optional<ccf::PrimarySignature> get_signature(
72 auto tx = sig_store->create_read_only_tx();
74 return signatures->get();
77 static std::optional<ccf::CoseSignature> get_cose_signature(
80 auto tx = sig_store->create_read_only_tx();
82 return signatures->get();
85 static std::optional<std::vector<uint8_t>> get_tree(
88 auto tx = sig_store->create_read_only_tx();
124 "Source ledger secrets are empty");
133 "Historical ledger secrets are not older than main ledger secrets");
156 if (
store ==
nullptr)
158 throw std::logic_error(
"Store pointer not set");
160 auto e =
store->get_encryptor();
161 return e->get_commit_evidence(
215 return it->second.lock();
233 bool should_include_receipts,
234 SeqNo earliest_ledger_secret_seqno)
236 std::vector<SeqNo> removed{};
237 std::vector<SeqNo> added{};
246 bool any_too_early =
false;
250 auto new_it = new_seqnos.
begin();
251 while (new_it != new_seqnos.
end())
253 if (prev_it !=
my_stores.end() && *new_it == prev_it->first)
260 else if (prev_it !=
my_stores.end() && *new_it > prev_it->first)
267 removed.push_back(prev_it->first);
281 if (*new_it < earliest_ledger_secret_seqno || any_too_early)
285 added.push_back(*new_it);
286 prev_it =
my_stores.insert_or_assign(prev_it, *new_it,
nullptr);
287 any_too_early =
true;
293 all_it ==
all_stores.end() ? nullptr : all_it->second.lock();
294 if (details ==
nullptr)
297 details = std::make_shared<StoreDetails>();
298 all_stores.insert_or_assign(all_it, *new_it, details);
300 added.push_back(*new_it);
301 prev_it =
my_stores.insert_or_assign(prev_it, *new_it, details);
317 removed.push_back(it->first);
329 "Added seqnos: {}, removed seqnos: {}, supporting signatures: {}",
330 fmt::join(added,
","),
331 fmt::join(removed,
","),
334 const bool any_diff = !removed.empty() || !added.empty();
339 return {removed, added};
347 if (should_include_receipts)
354 for (
auto seqno : new_seqnos)
357 std::sort(added.begin(), added.end());
358 std::sort(more_to_add.begin(), more_to_add.end());
360 std::vector<SeqNo> together;
366 std::back_inserter(together));
368 if (more_to_add.size() + added.size() != together.size())
371 "Invariant violation in adjust_ranges: more_to_add({}) + "
372 "added({}) != together({})",
379 std::swap(added, together);
382 return {removed, added};
388 "Looking at {}, and populating receipts from it", new_seqno);
390 if (new_details !=
nullptr && new_details->store !=
nullptr)
392 if (new_details->is_signature)
396 fill_receipts_from_signature(new_details);
413 if (new_details->receipt !=
nullptr)
416 "Already have a receipt for {}, so no need to populate more",
421 std::vector<SeqNo> added;
423 auto next_seqno = new_seqno + 1;
428 all_it ==
all_stores.end() ? nullptr : all_it->second.lock();
429 if (details ==
nullptr)
432 "Looking for new supporting signature at {}", next_seqno);
433 details = std::make_shared<StoreDetails>();
438 "Tracking potential supporting signature for new seqno {} "
442 added.push_back(next_seqno);
443 my_stores.insert_or_assign(my_it, next_seqno, details);
446 all_stores.insert_or_assign(all_it, next_seqno, details);
449 if (details->store ==
nullptr)
455 "Assigning {} as potential signature for {}",
462 if (details->is_signature)
464 const auto filled_this =
465 fill_receipts_from_signature(details, new_seqno);
470 throw std::logic_error(fmt::format(
471 "Unexpected: Found a signature at {}, and contiguous range "
472 "of transactions from {}, yet signature does not cover "
493 bool fill_receipts_from_signature(
494 const std::shared_ptr<StoreDetails>& sig_details,
495 std::optional<ccf::SeqNo> should_fill = std::nullopt)
499 const auto sig = get_signature(sig_details->store);
500 const auto cose_sig = get_cose_signature(sig_details->store);
501 if (!sig.has_value() && !cose_sig.has_value())
505 const auto serialised_tree = get_tree(sig_details->store);
506 if (!serialised_tree.has_value())
514 auto sig_lower_bound_it =
515 my_stores.lower_bound(sig_details->transaction_id.seqno);
517 if (sig_lower_bound_it !=
my_stores.begin())
520 auto search_rit = std::reverse_iterator(sig_lower_bound_it);
523 auto seqno = search_rit->first;
524 if (tree.in_range(seqno))
526 auto details = search_rit->second;
527 if (details !=
nullptr && details->store !=
nullptr)
529 auto proof = tree.get_proof(seqno);
533 details->transaction_id = {sig->view, seqno};
534 details->receipt = std::make_shared<TxReceiptImpl>(
541 details->entry_digest,
542 details->get_commit_evidence(),
543 details->claims_digest);
548 ccf::cose::decode_ccf_receipt(cose_sig.value(),
false);
551 if (!parsed_txid.has_value())
553 throw std::logic_error(fmt::format(
554 "Cannot parse CCF TxID: {}", cose_receipt.phdr.ccf.txid));
557 details->transaction_id = {parsed_txid->view, seqno};
558 details->receipt = std::make_shared<TxReceiptImpl>(
565 details->entry_digest,
566 details->get_commit_evidence(),
567 details->claims_digest);
571 "Assigned a receipt for {} after given signature at {}",
573 sig_details->transaction_id.to_str());
575 if (should_fill.has_value() && seqno == *should_fill)
592 return !should_fill.has_value();
612 std::map<CompoundHandle, std::list<CompoundHandle>::iterator>
lru_lookup;
637 it->second.insert(handle);
643 for (
const auto& [seq, _] :
requests.at(handle).my_stores)
654 it->second.erase(handle);
655 if (it->second.empty())
669 for (
const auto& [seq, _] :
requests.at(handle).my_stores)
697 "LRU shrink to {} requested but cache is already empty", threshold);
703 "Cache size shrinking (reached {} / {}). Dropping {}",
730 assert(!stored_size || stored_size == new_size);
734 stored_size = new_size;
747 ::consensus::ledger_get_range,
757 auto [earliest_ledger_secret_seqno, earliest_ledger_secret] =
760 earliest_ledger_secret !=
nullptr,
761 "Can't fetch without knowing earliest");
763 const auto too_early = seqno < earliest_ledger_secret_seqno;
765 auto previous_secret_stored_version =
766 earliest_ledger_secret->previous_secret_stored_version;
767 const auto is_next_secret =
768 previous_secret_stored_version.value_or(0) == seqno;
770 if (too_early || is_next_secret)
773 if (!previous_secret_stored_version.has_value())
775 throw std::logic_error(fmt::format(
776 "Earliest known ledger secret at {} has no earlier secret stored "
778 earliest_ledger_secret_seqno,
782 const auto seqno_to_fetch = previous_secret_stored_version.value();
784 "Requesting historical entry at {} but first known ledger "
785 "secret is applicable from {}",
787 earliest_ledger_secret_seqno);
790 auto details = it ==
all_stores.end() ? nullptr : it->second.lock();
791 if (details ==
nullptr)
793 LOG_TRACE_FMT(
"Requesting older secret at {} now", seqno_to_fetch);
794 details = std::make_shared<StoreDetails>();
795 all_stores.insert_or_assign(it, seqno_to_fetch, details);
803 return seqno_to_fetch;
817 bool has_commit_evidence)
822 details->has_commit_evidence = has_commit_evidence;
824 details->entry_digest = entry_digest;
825 if (!claims_digest.empty())
827 details->claims_digest = std::move(claims_digest);
831 details->store ==
nullptr,
832 "Cache already has store for seqno {}",
834 details->store = store;
836 details->is_signature = is_signature;
844 const auto sig = get_signature(details->store);
845 const auto cose_sig = get_cose_signature(details->store);
848 details->transaction_id = {sig->view, sig->seqno};
849 details->receipt = std::make_shared<TxReceiptImpl>(
850 sig->sig, cose_sig, sig->root.h,
nullptr, sig->node, sig->cert);
852 else if (cose_sig.has_value())
855 ccf::cose::decode_ccf_receipt(cose_sig.value(),
false);
856 const auto& txid = as_receipt.phdr.ccf.txid;
859 if (!parsed_txid.has_value())
861 throw std::logic_error(
862 fmt::format(
"Cannot parse CCF TxID: {}", txid));
864 details->transaction_id = parsed_txid.value();
865 details->receipt = std::make_shared<TxReceiptImpl>(
875 throw std::logic_error(
876 fmt::format(
"Seqno {} is a signature of an unknown type", seqno));
881 while (request_it !=
requests.end())
883 auto& [handle, request] = *request_it;
888 request.awaiting_ledger_secrets.has_value() &&
889 request.awaiting_ledger_secrets.value() == seqno)
892 "{} is a ledger secret seqno this request was waiting for", seqno);
894 request.awaiting_ledger_secrets =
896 if (!request.awaiting_ledger_secrets.has_value())
901 auto my_stores_it = request.my_stores.begin();
902 while (my_stores_it != request.my_stores.end())
904 auto [store_seqno, _] = *my_stores_it;
907 it ==
all_stores.end() ? nullptr : it->second.lock();
909 if (store_details ==
nullptr)
911 store_details = std::make_shared<StoreDetails>();
912 all_stores.insert_or_assign(it, store_seqno, store_details);
915 my_stores_it->second = store_details;
925 if (request.include_receipts)
927 const bool seqno_in_this_request =
928 (request.my_stores.find(seqno) != request.my_stores.end() ||
929 request.supporting_signatures.find(seqno) !=
930 request.supporting_signatures.end());
931 if (seqno_in_this_request)
933 auto added = request.populate_receipts(seqno);
934 for (
auto seq : added)
949 auto tx = store->create_read_only_tx();
950 auto* encrypted_past_ledger_secret_handle =
952 ccf::Tables::ENCRYPTED_PAST_LEDGER_SECRET);
953 if (encrypted_past_ledger_secret_handle ==
nullptr)
958 auto encrypted_past_ledger_secret =
959 encrypted_past_ledger_secret_handle->get();
960 if (!encrypted_past_ledger_secret.has_value())
966 auto previous_ledger_secret =
967 encrypted_past_ledger_secret->previous_ledger_secret;
968 if (!previous_ledger_secret.has_value())
973 encrypted_past_ledger_secret->next_version.has_value() &&
974 encrypted_past_ledger_secret->next_version.value() == 1,
975 "Write to ledger secrets table at {} should contain a next_version "
977 store->current_version());
984 "Skipping redundant ledger secret with version of {} when the "
985 "earliest known secret is from {}",
986 previous_ledger_secret->version,
991 auto recovered_ledger_secret = std::make_shared<LedgerSecret>(
993 encrypting_secret, previous_ledger_secret->encrypted_data),
994 previous_ledger_secret->previous_secret_stored_version);
998 previous_ledger_secret->version, std::move(recovered_ledger_secret));
1011 if (end_seqno < start_seqno)
1013 throw std::logic_error(fmt::format(
1014 "Invalid range for historical query: end {} is before start {}",
1027 bool include_receipts)
1031 throw std::logic_error(
1032 "Invalid range for historical query: Cannot request empty range");
1037 const auto ms_until_expiry =
1038 std::chrono::duration_cast<std::chrono::milliseconds>(
1039 seconds_until_expiry);
1051 Request& request = it->second;
1057 "Adjusting handle {} to cover {} seqnos starting at {} "
1058 "(include_receipts={})",
1066 for (
auto seq : removed)
1070 for (
auto seq : added)
1084 std::vector<StatePtr> trusted_states;
1086 for (
auto seqno : seqnos)
1090 target_details !=
nullptr &&
1096 StatePtr state = std::make_shared<State>(
1097 target_details->store,
1098 target_details->receipt,
1099 target_details->transaction_id);
1100 trusted_states.push_back(state);
1110 return trusted_states;
1117 auto request_it =
requests.begin();
1118 while (request_it !=
requests.end())
1120 if (request_it->second.get_store_details(seqno) !=
nullptr)
1123 request_it =
requests.erase(request_it);
1133 const std::vector<StatePtr>& states)
1135 std::vector<ccf::kv::ReadOnlyStorePtr> stores;
1136 stores.reserve(states.size());
1137 for (
const auto& state : states)
1139 stores.push_back(state->store);
1147 const std::shared_ptr<ccf::LedgerSecrets>& secrets,
1162 auto range =
get_store_range(handle, seqno, seqno, seconds_until_expiry);
1182 auto range =
get_state_range(handle, seqno, seqno, seconds_until_expiry);
1205 seconds_until_expiry,
1227 seconds_until_expiry,
1262 throw std::runtime_error(
"Cannot request empty range");
1292 const auto erased_count =
requests.erase(handle);
1293 return erased_count > 0;
1305 auto details = it ==
all_stores.end() ? nullptr : it->second.lock();
1315 bool has_commit_evidence =
false;
1322 has_commit_evidence);
1332 const auto tx_id = store->current_txid();
1333 if (tx_id.seqno != seqno)
1336 "Corrupt ledger entry received - claims to be {} but is actually "
1351 const auto actual_view =
consensus->get_view(seqno);
1352 if (actual_view != tx_id.view)
1355 "Ledger entry comes from fork - contains {}.{} but this service "
1365 const auto is_signature =
1372 if (secret !=
nullptr)
1374 const auto& prev_version = secret->previous_secret_stored_version;
1375 if (prev_version.has_value() && *prev_version == seqno)
1378 "Handling past ledger secret. Current earliest is valid from {}, "
1380 "processing secret stored at {}",
1389 "Processing historical store at {} ({})",
1391 (
size_t)deserialise_result);
1399 std::move(claims_digest),
1400 has_commit_evidence);
1410 from_seqno, to_seqno, data.data(), data.size());
1416 const uint8_t* data,
1419 LOG_TRACE_FMT(
"handle_ledger_entries({}, {})", from_seqno, to_seqno);
1421 auto seqno = from_seqno;
1422 bool all_accepted =
true;
1426 serialized::peek<ccf::kv::SerialisedEntryHeader>(data, size);
1427 const auto whole_size =
1428 header.size + ccf::kv::serialised_entry_header_size;
1435 if (seqno != to_seqno + 1)
1438 "Claimed ledger entries: [{}, {}), actual [{}, {}]",
1445 return all_accepted;
1457 LOG_TRACE_FMT(
"handle_no_entry_range({}, {})", from_seqno, to_seqno);
1459 for (
auto seqno = from_seqno; seqno <= to_seqno; ++seqno)
1465 const auto fetches_it =
all_stores.find(seqno);
1477 const uint8_t* data,
1481 bool& has_commit_evidence)
1490 if (seqno < source_ledger_secrets->get_first().first)
1505 bool public_only =
false;
1506 for (
const auto& [_, request] :
requests)
1508 const auto& als = request.awaiting_ledger_secrets;
1509 if (als.has_value() && als.value() == seqno)
1516 auto exec = store->deserialize({data, data + size}, public_only);
1517 if (exec ==
nullptr)
1524 claims_digest = std::move(exec->consume_claims_digest());
1526 auto commit_evidence_digest =
1527 std::move(exec->consume_commit_evidence_digest());
1528 has_commit_evidence = commit_evidence_digest.has_value();
1530 catch (
const std::exception& e)
1533 "Exception while attempting to deserialise entry {}: {}",
1548 void tick(
const std::chrono::milliseconds& elapsed_ms)
1556 auto& request = it->second;
1557 if (elapsed_ms >= request.time_to_expiry)
1560 "Dropping expired historical query with handle {}", it->first);
1566 request.time_to_expiry -= elapsed_ms;
1576 std::optional<std::pair<ccf::SeqNo, ccf::SeqNo>> range_to_request =
1580 auto details = it->second.lock();
1581 if (details ==
nullptr)
1589 details->time_until_fetch -= elapsed_ms;
1590 if (details->time_until_fetch.count() <= 0)
1592 details->time_until_fetch = slow_fetch_threshold;
1594 const auto seqno = it->first;
1595 if (
auto range_val = range_to_request; range_val.has_value())
1597 auto range = range_val.value();
1598 if (range.second + 1 == seqno)
1600 range.second = seqno;
1601 range_to_request = range;
1608 range_to_request = std::make_pair(seqno, seqno);
1614 range_to_request = std::make_pair(seqno, seqno);
1623 if (
auto range_val = range_to_request; range_val.has_value())
1626 auto range = range_val.value();
1642 template <
typename... Ts>
1685 seconds_until_expiry);
1707 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:19
ConstIterator end() const
Definition contiguous_set.h:517
bool empty() const
Definition contiguous_set.h:344
ConstIterator begin() const
Definition contiguous_set.h:512
size_t size() const
Definition contiguous_set.h:336
Definition historical_queries_interface.h:67
Definition historical_queries.h:95
std::map< CompoundHandle, std::list< CompoundHandle >::iterator > lru_lookup
Definition historical_queries.h:612
void update_store_raw_size(SeqNo seq, size_t new_size)
Definition historical_queries.h:727
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:810
std::vector< StatePtr > get_states_for(const CompoundHandle &handle, const SeqNoCollection &seqnos)
Definition historical_queries.h:1267
std::map< CompoundHandle, Request > requests
Definition historical_queries.h:600
std::list< CompoundHandle > lru_requests
Definition historical_queries.h:611
std::vector< ccf::kv::ReadOnlyStorePtr > states_to_stores(const std::vector< StatePtr > &states)
Definition historical_queries.h:1132
ExpiryDuration default_expiry_duration
Definition historical_queries.h:607
bool track_deletes_on_missing_keys_v
Definition historical_queries.h:105
ccf::kv::Store & source_store
Definition historical_queries.h:97
std::map< ccf::SeqNo, WeakStoreDetailsPtr > AllRequestedStores
Definition historical_queries.h:172
ringbuffer::WriterPtr to_host
Definition historical_queries.h:99
void add_request_refs(CompoundHandle handle)
Definition historical_queries.h:641
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:1218
std::unordered_map< SeqNo, std::set< CompoundHandle > > store_to_requests
Definition historical_queries.h:616
std::vector< StatePtr > get_state_range(const CompoundHandle &handle, ccf::SeqNo start_seqno, ccf::SeqNo end_seqno)
Definition historical_queries.h:1231
StoreStage
Definition historical_queries.h:108
AllRequestedStores all_stores
Definition historical_queries.h:605
void set_soft_cache_limit(CacheSize cache_limit)
Definition historical_queries.h:1278
void remove_request_ref(SeqNo seq, CompoundHandle handle)
Definition historical_queries.h:649
CacheSize estimated_store_cache_size
Definition historical_queries.h:620
StatePtr get_state_at(const CompoundHandle &handle, ccf::SeqNo seqno, ExpiryDuration seconds_until_expiry)
Definition historical_queries.h:1177
StateCacheImpl(ccf::kv::Store &store, const std::shared_ptr< ccf::LedgerSecrets > &secrets, ringbuffer::WriterPtr host_writer)
Definition historical_queries.h:1145
bool drop_cached_states(const CompoundHandle &handle)
Definition historical_queries.h:1288
void handle_no_entry(ccf::SeqNo seqno)
Definition historical_queries.h:1448
void remove_request_refs(CompoundHandle handle)
Definition historical_queries.h:667
void track_deletes_on_missing_keys(bool track)
Definition historical_queries.h:1283
std::vector< StatePtr > get_states_for(const CompoundHandle &handle, const SeqNoCollection &seqnos, ExpiryDuration seconds_until_expiry)
Definition historical_queries.h:1255
std::vector< ccf::kv::ReadOnlyStorePtr > get_stores_for(const CompoundHandle &handle, const SeqNoCollection &seqnos, ExpiryDuration seconds_until_expiry)
Definition historical_queries.h:1240
std::map< ccf::SeqNo, StoreDetailsPtr > RequestedStores
Definition historical_queries.h:169
void handle_no_entry_range(ccf::SeqNo from_seqno, ccf::SeqNo to_seqno)
Definition historical_queries.h:1453
bool handle_encrypted_past_ledger_secret(const ccf::kv::StorePtr &store, LedgerSecretPtr encrypting_secret)
Definition historical_queries.h:945
ccf::kv::ReadOnlyStorePtr get_store_at(const CompoundHandle &handle, ccf::SeqNo seqno)
Definition historical_queries.h:1171
StatePtr get_state_at(const CompoundHandle &handle, ccf::SeqNo seqno)
Definition historical_queries.h:1191
std::shared_ptr< ccf::NodeEncryptor > historical_encryptor
Definition historical_queries.h:102
CacheSize soft_store_cache_limit
Definition historical_queries.h:619
void add_request_ref(SeqNo seq, CompoundHandle handle)
Definition historical_queries.h:622
void fetch_entries_range(ccf::SeqNo from, ccf::SeqNo to)
Definition historical_queries.h:742
std::vector< uint8_t > LedgerEntry
Definition historical_queries.h:113
bool handle_ledger_entry(ccf::SeqNo seqno, const uint8_t *data, size_t size)
Definition historical_queries.h:1301
void fetch_entry_at(ccf::SeqNo seqno)
Definition historical_queries.h:737
ccf::kv::ReadOnlyStorePtr get_store_at(const CompoundHandle &handle, ccf::SeqNo seqno, ExpiryDuration seconds_until_expiry)
Definition historical_queries.h:1157
StoreDetailsPtr next_secret_fetch_handle
Definition historical_queries.h:189
void update_earliest_known_ledger_secret()
Definition historical_queries.h:115
ccf::pal::Mutex requests_lock
Definition historical_queries.h:597
std::shared_ptr< StoreDetails > StoreDetailsPtr
Definition historical_queries.h:168
bool handle_ledger_entry(ccf::SeqNo seqno, const std::vector< uint8_t > &data)
Definition historical_queries.h:1296
void tick(const std::chrono::milliseconds &elapsed_ms)
Definition historical_queries.h:1548
VersionedSecret earliest_secret_
Definition historical_queries.h:188
std::optional< ccf::SeqNo > fetch_supporting_secret_if_needed(ccf::SeqNo seqno)
Definition historical_queries.h:754
std::unordered_map< ccf::SeqNo, size_t > raw_store_sizes
Definition historical_queries.h:617
std::shared_ptr< ccf::LedgerSecrets > source_ledger_secrets
Definition historical_queries.h:98
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:1475
std::shared_ptr< ccf::LedgerSecrets > historical_ledger_secrets
Definition historical_queries.h:101
std::vector< ccf::kv::ReadOnlyStorePtr > get_stores_for(const CompoundHandle &handle, const SeqNoCollection &seqnos)
Definition historical_queries.h:1249
std::vector< StatePtr > get_states_internal(const CompoundHandle &handle, const SeqNoCollection &seqnos, ExpiryDuration seconds_until_expiry, bool include_receipts)
Definition historical_queries.h:1023
void delete_all_interested_requests(ccf::SeqNo seqno)
Definition historical_queries.h:1115
void lru_shrink_to_fit(size_t threshold)
Definition historical_queries.h:690
bool handle_ledger_entries(ccf::SeqNo from_seqno, ccf::SeqNo to_seqno, const uint8_t *data, size_t size)
Definition historical_queries.h:1413
size_t get_estimated_store_cache_size()
Definition historical_queries.h:1542
void set_default_expiry_duration(ExpiryDuration duration)
Definition historical_queries.h:1273
bool handle_ledger_entries(ccf::SeqNo from_seqno, ccf::SeqNo to_seqno, const LedgerEntry &data)
Definition historical_queries.h:1406
std::vector< ccf::kv::ReadOnlyStorePtr > get_store_range(const CompoundHandle &handle, ccf::SeqNo start_seqno, ccf::SeqNo end_seqno)
Definition historical_queries.h:1209
std::weak_ptr< StoreDetails > WeakStoreDetailsPtr
Definition historical_queries.h:171
SeqNoCollection collection_from_single_range(ccf::SeqNo start_seqno, ccf::SeqNo end_seqno)
Definition historical_queries.h:1008
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:1196
void lru_promote(CompoundHandle handle)
Definition historical_queries.h:675
void lru_evict(CompoundHandle handle)
Definition historical_queries.h:716
Definition historical_queries.h:1634
StatePtr get_state_at(RequestHandle handle, ccf::SeqNo seqno, ExpiryDuration seconds_until_expiry) override
Definition historical_queries.h:1661
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:1697
std::vector< StatePtr > get_states_for(RequestHandle handle, const SeqNoCollection &seqnos, ExpiryDuration seconds_until_expiry) override
Definition historical_queries.h:1735
CompoundHandle make_compound_handle(RequestHandle rh)
Definition historical_queries.h:1636
std::vector< ccf::kv::ReadOnlyStorePtr > get_store_range(RequestHandle handle, ccf::SeqNo start_seqno, ccf::SeqNo end_seqno) override
Definition historical_queries.h:1688
ccf::kv::ReadOnlyStorePtr get_store_at(RequestHandle handle, ccf::SeqNo seqno) override
Definition historical_queries.h:1655
std::vector< ccf::kv::ReadOnlyStorePtr > get_stores_for(RequestHandle handle, const SeqNoCollection &seqnos) override
Definition historical_queries.h:1728
std::vector< ccf::kv::ReadOnlyStorePtr > get_stores_for(RequestHandle handle, const SeqNoCollection &seqnos, ExpiryDuration seconds_until_expiry) override
Definition historical_queries.h:1719
StatePtr get_state_at(RequestHandle handle, ccf::SeqNo seqno) override
Definition historical_queries.h:1670
void set_soft_cache_limit(CacheSize cache_limit) override
Definition historical_queries.h:1756
std::vector< StatePtr > get_state_range(RequestHandle handle, ccf::SeqNo start_seqno, ccf::SeqNo end_seqno) override
Definition historical_queries.h:1710
size_t get_estimated_store_cache_size() override
Definition historical_queries.h:1771
ccf::kv::ReadOnlyStorePtr get_store_at(RequestHandle handle, ccf::SeqNo seqno, ExpiryDuration seconds_until_expiry) override
Definition historical_queries.h:1646
void set_default_expiry_duration(ExpiryDuration duration) override
Definition historical_queries.h:1751
bool drop_cached_states(RequestHandle handle) override
Definition historical_queries.h:1766
std::vector< StatePtr > get_states_for(RequestHandle handle, const SeqNoCollection &seqnos) override
Definition historical_queries.h:1744
void track_deletes_on_missing_keys(bool track) override
Definition historical_queries.h:1761
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:1675
StateCache(Ts &&... ts)
Definition historical_queries.h:1643
ReadOnlyTx create_read_only_tx() override
Definition store.h:1296
EncryptorPtr get_encryptor() override
Definition store.h:221
std::shared_ptr< Consensus > get_consensus() override
Definition store.h:183
Definition encryptor.h:15
#define HISTORICAL_LOG(...)
Definition historical_queries.h:27
#define LOG_INFO_FMT
Definition internal_logger.h:15
#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
Definition historical_queries_adapter.h:17
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:33
std::pair< RequestNamespace, RequestHandle > CompoundHandle
Definition historical_queries.h:38
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:1363
ApplyResult
Definition kv_types.h:305
@ PASS_SIGNATURE
Definition kv_types.h:307
@ FAIL
Definition kv_types.h:314
std::mutex Mutex
Definition locking.h:12
Definition app_interface.h:13
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:84
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:92
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
static std::optional< TxID > from_str(const std::string_view &sv)
Definition tx_id.h:53
Definition historical_queries.h:192
bool include_receipts
Definition historical_queries.h:198
std::vector< ccf::SeqNo > populate_receipts(ccf::SeqNo new_seqno)
Definition historical_queries.h:385
StoreDetailsPtr get_store_details(ccf::SeqNo seqno) const
Definition historical_queries.h:210
Request(AllRequestedStores &all_stores_)
Definition historical_queries.h:208
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:231
std::optional< ccf::SeqNo > awaiting_ledger_secrets
Definition historical_queries.h:206
AllRequestedStores & all_stores
Definition historical_queries.h:193
std::chrono::milliseconds time_to_expiry
Definition historical_queries.h:196
RequestedStores supporting_signatures
Definition historical_queries.h:203
ccf::SeqNo first_requested_seqno() const
Definition historical_queries.h:221
RequestedStores my_stores
Definition historical_queries.h:195
Definition historical_queries.h:141
std::chrono::milliseconds time_until_fetch
Definition historical_queries.h:142
std::optional< std::string > get_commit_evidence()
Definition historical_queries.h:152
bool has_commit_evidence
Definition historical_queries.h:150
ccf::kv::StorePtr store
Definition historical_queries.h:146
ccf::ClaimsDigest claims_digest
Definition historical_queries.h:145
ccf::crypto::Sha256Hash entry_digest
Definition historical_queries.h:144
ccf::TxID transaction_id
Definition historical_queries.h:149
TxReceiptImplPtr receipt
Definition historical_queries.h:148
StoreStage current_stage
Definition historical_queries.h:143
bool is_signature
Definition historical_queries.h:147
Definition historical_queries.h:175
ccf::LedgerSecretPtr secret
Definition historical_queries.h:177
ccf::SeqNo valid_from
Definition historical_queries.h:176
VersionedSecret(const ccf::VersionedLedgerSecret &vls)
Definition historical_queries.h:182
VersionedSecret()=default