Skip to content

Commit 73f875c

Browse files
robinbryceRobin Bryce
and
Robin Bryce
authored
fixes to deal with the limitations of mongodb, grpc-gatway and bson (#12)
fix: oneof doesn't play well with grpc gateway (apparently) Instead of the (much cleaner) oneof, we will have a single message in the event per proof mech. only one of them will be present in any event fix: mongo cant store unsigned integers of any size So we use a different message for storing the proof details for mongo. It encodes the idtimestamp as a fixed lenght hex string. this preserves the sortable and comparible properties. For now we keep the other unsigned types as they wont use the full range of bits until a single tenant log has 2^63 events in it. fix: the field ordinals for merkle log messages were benignly 'wrong'. All message fields for merkle log messages start at ordinal 1 now AB#8859 Co-authored-by: Robin Bryce <[email protected]>
1 parent 965ae2a commit 73f875c

File tree

2 files changed

+37
-12
lines changed

2 files changed

+37
-12
lines changed

Diff for: datatrails-common-api/assets/v2/assets/eventresponse.proto

+10-7
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,14 @@ message EventResponse {
173173
// record. We anticipate at least two proof mechs: merkle_log and
174174
// verkle_log. We use oneof to avoid repeating the scattering of randomly
175175
// re-purposed fields we currently have for simple hash vs khipu.
176-
oneof proof_details {
177-
MerkleLogEntry merklelog_entry = 19 [ (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
178-
description:
179-
"verifiable merkle mmr log entry details"
180-
max_length: 1024
181-
}];
182-
};
176+
177+
178+
// proof details for proof_mechanism MERKLE_LOG
179+
MerkleLogEntry merklelog_entry = 19 [ (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
180+
description:
181+
"verifiable merkle mmr log entry details",
182+
// see https://github.com/grpc-ecosystem/grpc-gateway/blob/master/protoc-gen-openapiv2/options/openapiv2.proto
183+
// for specific types.
184+
type: OBJECT
185+
}];
183186
}

Diff for: datatrails-common-api/assets/v2/assets/merklelogentry.proto

+27-5
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,32 @@ import "google/protobuf/timestamp.proto";
88
// MerkeLogCommit provides the log entry details for a single mmr leaf.
99
message MerkleLogCommit {
1010
/* The mmr index */
11-
uint64 index = 3;
11+
uint64 index = 1;
1212
/* The mmr *leaf* index */
13-
uint64 leaf_index = 4; // TBD: this may be redundant.
13+
uint64 leaf_index = 2; // TBD: this may be redundant.
1414
/* time ordered and strictly unique per tenant. system wide
1515
* unique with very reasonable operational assumptions. */
16-
fixed64 idtimestamp = 5;
16+
fixed64 idtimestamp = 3;
17+
}
18+
19+
message MerkleLogCommitMongoDB {
20+
21+
// Note that should we ever have more than 2^63 events in a tenant log, the
22+
// index and leaf_index fields will not persist to mongo.
23+
24+
/* The mmr index */
25+
uint64 index = 1;
26+
/* The mmr *leaf* index */
27+
uint64 leaf_index = 2; // TBD: this may be redundant.
28+
29+
/* time ordered and strictly unique per tenant. system wide
30+
* unique with very reasonable operational assumptions.
31+
*
32+
* EXPRESSED AS A 16 character padded hex string because mongo db does not
33+
* support unsigned integers and we need all 64 bits to get a sensible epoch
34+
* duration.
35+
*/
36+
string idtimestamp = 3;
1737
}
1838

1939
// The message sent from forestrie to avid notifying that the corresponding
@@ -42,8 +62,10 @@ message MerkleLogEntry {
4262
uint32 log_version = 1;
4363
uint32 log_epoch = 2;
4464

45-
// Event trust level commited fields
46-
MerkleLogCommit commit = 3;
65+
// Event trust level commited fields. Note that we have to use a special
66+
// message because mongo db does not support unsigned integers. If/when we
67+
// move away from that, we can move this ordinal safely into a oneof
68+
MerkleLogCommitMongoDB commit = 3;
4769

4870
// TODO: Event trust level confirmed fields
4971

0 commit comments

Comments
 (0)