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"
23#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 inline 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 inline 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 const ACMECertificates acme_certificates = {Tables::ACME_CERTIFICATES};
90 const SnpHostDataMap host_data = {Tables::HOST_DATA};
91 const SnpMeasurements snp_measurements = {Tables::NODE_SNP_MEASUREMENTS};
93 Tables::NODE_SNP_UVM_ENDORSEMENTS};
94
95 inline auto get_all_node_tables() const
96 {
97 return std::make_tuple(
99 nodes,
102 host_data,
105 }
106
107 //
108 // History of governance, proposals, and ballots tables
109 //
110 const GovernanceHistory governance_history = {Tables::GOV_HISTORY};
112 Tables::COSE_GOV_HISTORY};
114 Tables::COSE_RECENT_PROPOSALS};
115
116 const jsgov::ProposalMap proposals = {jsgov::Tables::PROPOSALS};
118 jsgov::Tables::PROPOSALS_INFO};
119
121 {
122 return std::make_tuple(
125 proposals,
128 }
129
130 //
131 // JS Generic tables
132 //
133 const Modules modules = {Tables::MODULES};
135 Tables::MODULES_QUICKJS_BYTECODE};
137 Tables::MODULES_QUICKJS_VERSION};
138 const InterpreterFlush interpreter_flush = {Tables::INTERPRETER_FLUSH};
139 const JSEngine js_engine = {Tables::JSENGINE};
140 const endpoints::EndpointsMap js_endpoints = {endpoints::Tables::ENDPOINTS};
141
142 inline auto get_all_js_generic_tables() const
143 {
144 return std::make_tuple(
145 modules,
149 js_engine,
151 }
152
153 //
154 // JWT tables
155 //
156 const CACertBundlePEMs ca_cert_bundles = {Tables::CA_CERT_BUNDLE_PEMS};
157 const JwtIssuers jwt_issuers = {Tables::JWT_ISSUERS};
159 Tables::JWT_PUBLIC_SIGNING_KEYS_METADATA};
161 {Tables::Legacy::JWT_PUBLIC_SIGNING_KEYS};
164 Tables::Legacy::JWT_PUBLIC_SIGNING_KEY_ISSUER};
165
175
176 //
177 // Service tables
178 //
179 const Service service = {Tables::SERVICE};
181 Tables::PREVIOUS_SERVICE_IDENTITY};
182 const Configuration config = {Tables::CONFIGURATION};
183 const Constitution constitution = {Tables::CONSTITUTION};
184
185 inline auto get_all_service_tables() const
186 {
187 return std::make_tuple(
189 }
190
191 // All builtin governance tables should be included here, so that wrapper
192 // endpoints can be automatically generated for them
204
205 //
206 // Internal tables (public:ccf.internal.* and ccf.internal.*)
207 //
208 const Secrets secrets = {Tables::ENCRYPTED_LEDGER_SECRETS};
209 const SnapshotEvidence snapshot_evidence = {Tables::SNAPSHOT_EVIDENCE};
210 const RecoveryShares shares = {Tables::SHARES};
212 Tables::ENCRYPTED_PAST_LEDGER_SECRET};
214 Tables::ENCRYPTED_SUBMITTED_SHARES};
215
216 // The signatures and serialised_tree tables should always be written to at
217 // the same time so that the root of the tree in the signatures table
218 // matches the serialised Merkle tree.
219 const Signatures signatures = {Tables::SIGNATURES};
221 Tables::SERIALISED_MERKLE_TREE};
222
223 inline auto get_all_signature_tables() const
224 {
225 return std::make_tuple(signatures, serialise_tree);
226 }
227
228 inline auto get_all_internal_tables() const
229 {
230 return std::tuple_cat(
231 std::make_tuple(
232 secrets,
234 shares,
238 }
239
241 };
242}
ccf::kv::RawCopySerialisedMap< JwtKeyId, JwtIssuer > JwtPublicSigningKeyIssuer
Definition jwt.h:92
ccf::kv::RawCopySerialisedMap< JwtKeyId, Cert > JwtPublicSigningKeys
Definition jwt.h:90
ccf::ServiceMap< EndpointKey, EndpointProperties > EndpointsMap
Definition endpoint.h:236
ccf::kv::RawCopySerialisedMap< ccf::ProposalId, std::vector< uint8_t > > ProposalMap
Definition gov.h:83
ServiceMap< ccf::ProposalId, ProposalInfo > ProposalInfoMap
Definition gov.h:84
Definition app_interface.h:15
ccf::kv::RawCopySerialisedMap< NodeId, ccf::crypto::Pem > NodeEndorsedCertificates
Definition nodes.h:21
ServiceMap< NodeId, NodeInfo > Nodes
Definition nodes.h:19
ccf::kv::RawCopySerialisedValue< std::string > ModulesQuickJsVersion
Definition modules.h:18
ServiceMap< UserId, UserDetails > UserInfo
Definition users.h:32
ServiceMap< std::string, ProposalId > COSERecentProposals
Definition governance_history.h:22
ccf::kv::RawCopySerialisedMap< MemberId, ccf::crypto::Pem > MemberCerts
Definition members.h:79
ServiceValue< SnapshotHash > SnapshotEvidence
Definition snapshot_evidence.h:22
ServiceMap< MemberId, MemberDetails > MemberInfo
Definition members.h:77
std::shared_ptr< ccf::kv::Store > make_store()
Definition network_tables.h:39
ccf::kv::RawCopySerialisedMap< UserId, ccf::crypto::Pem > UserCerts
Definition users.h:31
ServiceValue< std::string > Constitution
Definition constitution.h:9
ServiceMap< DID, FeedToEndorsementsDataMap > SNPUVMEndorsements
Definition uvm_endorsements.h:24
ccf::kv::RawCopySerialisedMap< std::string, std::vector< uint8_t > > ModulesQuickJsBytecode
Definition modules.h:17
ServiceValue< ServiceInfo > Service
Definition service.h:55
ServiceValue< PrimarySignature > Signatures
Definition signatures.h:58
ServiceMap< MemberId, SignedReq > GovernanceHistory
Definition governance_history.h:12
ServiceMap< MemberId, EncryptedSubmittedShare > EncryptedSubmittedShares
Definition submitted_shares.h:19
ServiceMap< MemberId, MemberAck > MemberAcks
Definition members.h:140
ServiceMap< pal::SgxAttestationMeasurement, CodeStatus > CodeIDs
Definition code_id.h:11
ServiceMap< pal::SnpAttestationMeasurement, CodeStatus > SnpMeasurements
Definition snp_measurements.h:12
ServiceMap< JwtIssuer, JwtIssuerMetadata > JwtIssuers
Definition jwt.h:71
ServiceMap< std::string, ccf::crypto::Pem > ACMECertificates
Definition acme_certificates.h:12
ccf::kv::RawCopySerialisedValue< std::vector< uint8_t > > SerialisedMerkleTree
Definition signatures.h:62
ServiceMap< HostData, HostDataMetadata > SnpHostDataMap
Definition host_data.h:14
ccf::kv::RawCopySerialisedMap< std::string, Module > Modules
Definition modules.h:15
ServiceValue< bool > InterpreterFlush
Definition modules.h:19
ServiceValue< LedgerSecretsForNodes > Secrets
Definition secrets.h:36
ccf::kv::RawCopySerialisedMap< MemberId, ccf::crypto::Pem > MemberPublicEncryptionKeys
Definition members.h:81
ServiceValue< EncryptedLedgerSecretInfo > EncryptedLedgerSecretsInfo
Definition shares.h:118
ServiceValue< ccf::crypto::Pem > PreviousServiceIdentity
Definition previous_service_identity.h:13
ServiceMap< MemberId, std::vector< uint8_t > > COSEGovernanceHistory
Definition governance_history.h:17
ServiceValue< JSRuntimeOptions > JSEngine
Definition jsengine.h:106
ServiceMap< JwtKeyId, std::vector< OpenIDJWKMetadata > > JwtPublicSigningKeys
Definition jwt.h:73
ServiceMap< std::string, std::string > CACertBundlePEMs
Definition cert_bundles.h:9
Definition network_tables.h:45
const jsgov::ProposalInfoMap proposal_info
Definition network_tables.h:117
auto get_all_signature_tables() const
Definition network_tables.h:223
auto get_all_internal_tables() const
Definition network_tables.h:228
const endpoints::EndpointsMap js_endpoints
Definition network_tables.h:140
auto get_all_node_tables() const
Definition network_tables.h:95
const UserInfo user_info
Definition network_tables.h:75
std::shared_ptr< ccf::kv::Store > tables
Definition network_tables.h:46
const JwtIssuers jwt_issuers
Definition network_tables.h:157
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
const Tables::Legacy::JwtPublicSigningKeys legacy_jwt_public_signing_keys
Definition network_tables.h:160
auto get_all_member_tables() const
Definition network_tables.h:65
auto get_all_service_tables() const
Definition network_tables.h:185
const EncryptedSubmittedShares encrypted_submitted_shares
Definition network_tables.h:213
const Service service
Definition network_tables.h:179
auto get_all_jwt_tables() const
Definition network_tables.h:166
const SnpHostDataMap host_data
Definition network_tables.h:90
const Configuration config
Definition network_tables.h:182
const CACertBundlePEMs ca_cert_bundles
Definition network_tables.h:156
const JSEngine js_engine
Definition network_tables.h:139
const RecoveryShares shares
Definition network_tables.h:210
const ACMECertificates acme_certificates
Definition network_tables.h:89
auto get_all_user_tables() const
Definition network_tables.h:77
const InterpreterFlush interpreter_flush
Definition network_tables.h:138
const ModulesQuickJsBytecode modules_quickjs_bytecode
Definition network_tables.h:134
const SnpMeasurements snp_measurements
Definition network_tables.h:91
const COSEGovernanceHistory cose_governance_history
Definition network_tables.h:111
const EncryptedLedgerSecretsInfo encrypted_ledger_secrets
Definition network_tables.h:211
const COSERecentProposals cose_recent_proposals
Definition network_tables.h:113
const jsgov::ProposalMap proposals
Definition network_tables.h:116
const SerialisedMerkleTree serialise_tree
Definition network_tables.h:220
NetworkTables()
Definition network_tables.h:240
const PreviousServiceIdentity previous_service_identity
Definition network_tables.h:180
const Secrets secrets
Definition network_tables.h:208
const SNPUVMEndorsements snp_uvm_endorsements
Definition network_tables.h:92
const CodeIDs node_code_ids
Definition network_tables.h:85
const SnapshotEvidence snapshot_evidence
Definition network_tables.h:209
const MemberCerts member_certs
Definition network_tables.h:59
const Signatures signatures
Definition network_tables.h:219
const GovernanceHistory governance_history
Definition network_tables.h:110
const ModulesQuickJsVersion modules_quickjs_version
Definition network_tables.h:136
const Tables::Legacy::JwtPublicSigningKeyIssuer legacy_jwt_public_signing_key_issuer
Definition network_tables.h:163
auto get_all_builtin_governance_tables() const
Definition network_tables.h:193
auto get_all_governance_history_tables() const
Definition network_tables.h:120
const Modules modules
Definition network_tables.h:133
const JwtPublicSigningKeys jwt_public_signing_keys_metadata
Definition network_tables.h:158
const Nodes nodes
Definition network_tables.h:86
auto get_all_js_generic_tables() const
Definition network_tables.h:142
const Constitution constitution
Definition network_tables.h:183
Definition kv_types.h:82