CCF
Loading...
Searching...
No Matches
network_tables.h
Go to the documentation of this file.
1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the Apache 2.0 License.
3#pragma once
4
5#include "ccf/endpoint.h"
24#include "kv/store.h"
25#include "tables/config.h"
28#include "tables/secrets.h"
29#include "tables/shares.h"
30#include "tables/signatures.h"
33
34#include <memory>
35#include <tuple>
36
37namespace ccf
38{
39 inline std::shared_ptr<ccf::kv::Store> make_store()
40 {
41 return std::make_shared<ccf::kv::Store>();
42 }
43
45 {
46 std::shared_ptr<ccf::kv::Store> tables;
47
48 //
49 // Governance tables (public:ccf.gov.*)
50 // Note that this only covers the builtin tables, with entries common to
51 // many CCF services and modified by C++ code. Constitutions may extend this
52 // with their own tables, and some services will not use all of these
53 // tables.
54 //
55
56 //
57 // Member tables
58 //
59 const MemberCerts member_certs = {Tables::MEMBER_CERTS};
61 Tables::MEMBER_ENCRYPTION_PUBLIC_KEYS};
62 const MemberInfo member_info = {Tables::MEMBER_INFO};
63 const MemberAcks member_acks = {Tables::MEMBER_ACKS};
64
65 [[nodiscard]] auto get_all_member_tables() const
66 {
67 return std::make_tuple(
69 }
70
71 //
72 // User tables
73 //
74 const UserCerts user_certs = {Tables::USER_CERTS};
75 const UserInfo user_info = {Tables::USER_INFO};
76
77 [[nodiscard]] auto get_all_user_tables() const
78 {
79 return std::make_tuple(user_certs, user_info);
80 }
81
82 //
83 // Node tables
84 //
85 const CodeIDs node_code_ids = {Tables::NODE_CODE_IDS};
86 const Nodes nodes = {Tables::NODES};
88 Tables::NODE_ENDORSED_CERTIFICATES};
89
90 const VirtualHostDataMap virtual_host_data = {Tables::VIRTUAL_HOST_DATA};
92 Tables::NODE_VIRTUAL_MEASUREMENTS};
93
94 const SnpHostDataMap host_data = {Tables::HOST_DATA};
95 const SnpMeasurements snp_measurements = {Tables::NODE_SNP_MEASUREMENTS};
97 Tables::NODE_SNP_UVM_ENDORSEMENTS};
98 const SnpTcbVersionMap snp_tcb_versions = {Tables::SNP_TCB_VERSIONS};
99
100 [[nodiscard]] auto get_all_node_tables() const
101 {
102 return std::make_tuple(
104 nodes,
108 host_data,
112 }
113
114 //
115 // History of governance, proposals, and ballots tables
116 //
117 const GovernanceHistory governance_history = {Tables::GOV_HISTORY};
119 Tables::COSE_GOV_HISTORY};
121 Tables::COSE_RECENT_PROPOSALS};
122
123 const jsgov::ProposalMap proposals = {jsgov::Tables::PROPOSALS};
125 jsgov::Tables::PROPOSALS_INFO};
126
127 [[nodiscard]] auto get_all_governance_history_tables() const
128 {
129 return std::make_tuple(
132 proposals,
135 }
136
137 //
138 // JS Generic tables
139 //
140 const Modules modules = {Tables::MODULES};
142 Tables::MODULES_QUICKJS_BYTECODE};
144 Tables::MODULES_QUICKJS_VERSION};
145 const InterpreterFlush interpreter_flush = {Tables::INTERPRETER_FLUSH};
146 const JSEngine js_engine = {Tables::JSENGINE};
147 const endpoints::EndpointsMap js_endpoints = {endpoints::Tables::ENDPOINTS};
148
149 [[nodiscard]] auto get_all_js_generic_tables() const
150 {
151 return std::make_tuple(
152 modules,
156 js_engine,
158 }
159
160 //
161 // JWT tables
162 //
163 const CACertBundlePEMs ca_cert_bundles = {Tables::CA_CERT_BUNDLE_PEMS};
164 const JwtIssuers jwt_issuers = {Tables::JWT_ISSUERS};
166 Tables::JWT_PUBLIC_SIGNING_KEYS_METADATA};
167
168 [[nodiscard]] auto get_all_jwt_tables() const
169 {
170 return std::make_tuple(
172 }
173
174 //
175 // Service tables
176 //
177 const Service service = {Tables::SERVICE};
179 Tables::PREVIOUS_SERVICE_IDENTITY};
181 Tables::PREVIOUS_SERVICE_LAST_SIGNED_ROOT};
184 Tables::PREVIOUS_SERVICE_IDENTITY_ENDORSEMENT};
185 const Configuration config = {Tables::CONFIGURATION};
186 const Constitution constitution = {Tables::CONSTITUTION};
187
188 [[nodiscard]] auto get_all_service_tables() const
189 {
190 return std::make_tuple(
192 }
193
194 // All builtin governance tables should be included here, so that wrapper
195 // endpoints can be automatically generated for them
207
208 //
209 // Internal tables (public:ccf.internal.* and ccf.internal.*)
210 //
211 const Secrets secrets = {Tables::ENCRYPTED_LEDGER_SECRETS};
212 const SnapshotEvidence snapshot_evidence = {Tables::SNAPSHOT_EVIDENCE};
213 const RecoveryShares shares = {Tables::SHARES};
215 Tables::ENCRYPTED_PAST_LEDGER_SECRET};
217 Tables::ENCRYPTED_SUBMITTED_SHARES};
218
219 // The signatures and serialised_tree tables should always be written to at
220 // the same time so that the root of the tree in the signatures table
221 // matches the serialised Merkle tree.
222 const Signatures signatures = {Tables::SIGNATURES};
223 const CoseSignatures cose_signatures = {Tables::COSE_SIGNATURES};
225 Tables::SERIALISED_MERKLE_TREE};
226
227 [[nodiscard]] auto get_all_signature_tables() const
228 {
229 return std::make_tuple(signatures, serialise_tree);
230 }
231
232 [[nodiscard]] auto get_all_internal_tables() const
233 {
234 return std::tuple_cat(
235 std::make_tuple(
236 secrets,
238 shares,
242 }
243
245 };
246}
Definition map.h:30
Definition set.h:33
Definition value.h:32
Definition app_interface.h:14
std::shared_ptr< ccf::kv::Store > make_store()
Definition network_tables.h:39
Definition network_tables.h:45
const jsgov::ProposalInfoMap proposal_info
Definition network_tables.h:124
auto get_all_signature_tables() const
Definition network_tables.h:227
const SnpTcbVersionMap snp_tcb_versions
Definition network_tables.h:98
auto get_all_internal_tables() const
Definition network_tables.h:232
const endpoints::EndpointsMap js_endpoints
Definition network_tables.h:147
auto get_all_node_tables() const
Definition network_tables.h:100
const UserInfo user_info
Definition network_tables.h:75
const PreviousServiceIdentityEndorsement previous_service_identity_endorsement
Definition network_tables.h:183
std::shared_ptr< ccf::kv::Store > tables
Definition network_tables.h:46
const JwtIssuers jwt_issuers
Definition network_tables.h:164
const NodeEndorsedCertificates node_endorsed_certificates
Definition network_tables.h:87
const MemberPublicEncryptionKeys member_encryption_public_keys
Definition network_tables.h:60
const MemberInfo member_info
Definition network_tables.h:62
const UserCerts user_certs
Definition network_tables.h:74
const MemberAcks member_acks
Definition network_tables.h:63
auto get_all_member_tables() const
Definition network_tables.h:65
auto get_all_service_tables() const
Definition network_tables.h:188
const EncryptedSubmittedShares encrypted_submitted_shares
Definition network_tables.h:216
const Service service
Definition network_tables.h:177
auto get_all_jwt_tables() const
Definition network_tables.h:168
const SnpHostDataMap host_data
Definition network_tables.h:94
const VirtualHostDataMap virtual_host_data
Definition network_tables.h:90
const Configuration config
Definition network_tables.h:185
const CoseSignatures cose_signatures
Definition network_tables.h:223
const CACertBundlePEMs ca_cert_bundles
Definition network_tables.h:163
const JSEngine js_engine
Definition network_tables.h:146
const RecoveryShares shares
Definition network_tables.h:213
auto get_all_user_tables() const
Definition network_tables.h:77
const InterpreterFlush interpreter_flush
Definition network_tables.h:145
const ModulesQuickJsBytecode modules_quickjs_bytecode
Definition network_tables.h:141
const SnpMeasurements snp_measurements
Definition network_tables.h:95
const COSEGovernanceHistory cose_governance_history
Definition network_tables.h:118
const EncryptedLedgerSecretsInfo encrypted_ledger_secrets
Definition network_tables.h:214
const VirtualMeasurements virtual_measurements
Definition network_tables.h:91
const PreviousServiceLastSignedRoot previous_service_last_signed_root
Definition network_tables.h:180
const COSERecentProposals cose_recent_proposals
Definition network_tables.h:120
const jsgov::ProposalMap proposals
Definition network_tables.h:123
const JwtPublicSigningKeysMetadata jwt_public_signing_keys_metadata
Definition network_tables.h:165
const SerialisedMerkleTree serialise_tree
Definition network_tables.h:224
NetworkTables()
Definition network_tables.h:244
const PreviousServiceIdentity previous_service_identity
Definition network_tables.h:178
const Secrets secrets
Definition network_tables.h:211
const SNPUVMEndorsements snp_uvm_endorsements
Definition network_tables.h:96
const CodeIDs node_code_ids
Definition network_tables.h:85
const SnapshotEvidence snapshot_evidence
Definition network_tables.h:212
const MemberCerts member_certs
Definition network_tables.h:59
const Signatures signatures
Definition network_tables.h:222
const GovernanceHistory governance_history
Definition network_tables.h:117
const ModulesQuickJsVersion modules_quickjs_version
Definition network_tables.h:143
auto get_all_builtin_governance_tables() const
Definition network_tables.h:196
auto get_all_governance_history_tables() const
Definition network_tables.h:127
const Modules modules
Definition network_tables.h:140
const Nodes nodes
Definition network_tables.h:86
auto get_all_js_generic_tables() const
Definition network_tables.h:149
const Constitution constitution
Definition network_tables.h:186