Skip to content

Commit db8ea99

Browse files
author
Robin Bryce
committed
feat: forestrie event message additions
* Add the confirmation states representing the forestrie trust levels as described here: https://github.com/datatrails/\ epic-8120-scalable-proof-mechanisms/blob/main/event-trust-levels.md * Add the provisional extra details we need in the event for the MERKLE_LOG proof mechanism * Use a single oneof per proof mech details fix: the include paths for openapiv2 build: simplify the include path discovery build: export the proto dependencies under proto-include This means consumers do not need to replicate the tricky go list based include path discovery ci: add a job to check the dockerall task works But note this is disabled due to acr permissions issues For people who can't or wont install protoc and go AB#8859 remove fields that are not settled yet use oneof for proof_details
1 parent c7be1e4 commit db8ea99

File tree

12 files changed

+206
-69
lines changed

12 files changed

+206
-69
lines changed

.github/workflows/ci.yml

+1-4
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,7 @@ jobs:
3030
- name: Generate, Test and Export
3131
run: |
3232
# Note: it is by design that we don't use the builder
33-
task apis:bootstrap
34-
task apis:generate
35-
task apis:test
36-
task apis:export
33+
task all
3734
3835
- name: Show exports
3936
working-directory: exported/

.github/workflows/workflow.yml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Developer Workflow Tests
2+
3+
on:
4+
# we ony run these on pull request as they significantly hinder developer feed
5+
# back if they are triggered on push
6+
pull_request:
7+
branches:
8+
- main
9+
jobs:
10+
docker-all:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- name: Setup go-task
15+
uses: arduino/setup-task@v1
16+
with:
17+
version: 3.x
18+
repo-token: ${{ secrets.GITHUB_TOKEN }}
19+
- name: docker all
20+
run: |
21+
22+
echo "TODO: permissions on accessing our acr prevent this from working"
23+
exit 0
24+
# task dockerall

README.md

+23-8
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,26 @@
22

33
Common public api definitions for the DataTrails platform
44

5+
## Finding and including proto files for depdendecnies
6+
7+
tools/go.mod is the source of truth for all proto providing dependencies. That file alone specifies both the upstream version we are using *and* is used, via go install, to make the .proto files available locally
8+
9+
This corresponds to the practice recommended by grpc-gateway and elsewhere
10+
11+
1. *** ALWAYS *** Use tools/go.mod to specify the dependency version.
12+
2. Add the package to the `go install` command in the apis:preflight task
13+
3. If necessary, add a var for the new path in any-api **and** then add a reference to that var in the PROTO_INC var.
14+
15+
Following this practice removes the need for dual maintenance of dependency versions in the builder image. It also produces a build cycle that is significantly faster.
16+
17+
Cross repository builds in docker while using go.work to refer to locally modified sources don't work. And this setup is essential for an efficient workflow.
18+
19+
## bootstrap proto files
20+
21+
The proto's for protoc itself, the googleapis, and the grpc_health proxy are needed by almost everything and are also don't apear to be compatible with the tools/go.mod approach
22+
23+
For this reason we curl the proto's and make them available in our aggregate proto-includes archive
24+
525
## Workflow for updating common apis
626

727
### Ensure the go tool chain is setup on your host
@@ -46,12 +66,11 @@ If you want to iterate on *just* the helper go code and there tests, do one roun
4666

4767
`apis:bootstrap` -> `apis:clean:generated`
4868

49-
Then just iterate using `apis:build`
50-
69+
Then just iterate using `task apis:generate` and `task apis:test`
5170

5271
#### For avid
5372

54-
* task avid:xxx
73+
See the README.md in avid/src/api/README.md
5574

5675
##### Build one api against locally cloned go-datatrails-common-api
5776

@@ -60,8 +79,4 @@ The protos can be included exactly as they are found from a clone of go-datatrai
6079
task apis:assetsv2-api \
6180
DATATRAILS_COMMON_API="../../go-datatrails-common-api"
6281

63-
It is necessary however to run `task apis:bootsrap` after cloning go-datatrails-common
64-
65-
#### For forestrie
66-
67-
* task:xxx
82+
It is necessary however to run `task apis:bootsrap` after cloning go-datatrails-common

Taskfile.yml

+31-11
Original file line numberDiff line numberDiff line change
@@ -67,22 +67,42 @@ tasks:
6767
### -------------------------
6868
# Primary workflow tasks
6969
### -------------------------
70-
all:
71-
desc: "do everything necessary after clone (or rebase)"
70+
dockerall:
71+
desc: "do everything necessary after clone (or rebase) in the builder"
7272
cmds:
7373
- task: builder-start
7474
- defer: {task: builder-cleanup}
75-
# These steps should exactly mirror the steps in .github/workflows/ci.yml
76-
- docker exec -t {{.BUILD_CONTAINER}} task apis:bootstrap
77-
- docker exec -t {{.BUILD_CONTAINER}} task apis:generate
78-
- docker exec -t {{.BUILD_CONTAINER}} task apis:test
79-
- docker exec -t {{.BUILD_CONTAINER}} task apis:export
75+
- task: all
76+
77+
all:
78+
desc: |
79+
do everything necessary after clone (or rebase)
80+
81+
Note: This requires go and protoc installed on your host. If you are not
82+
comfortable doing this then use dockerall.
83+
84+
** The CI (ci.yml) uses this task and provides a clear illustration of the
85+
pre-requisites. It does not use docker **
86+
87+
cmds:
88+
- task: clean
89+
- task: bootstrap
90+
- task: generate
91+
- task: apis:test
92+
- task: apis:export
93+
94+
# 0. clean out generated and imported files
95+
clean:
96+
- rm -rf proto-include
97+
- rm -rf exported
98+
- task: apis:clean:generated
99+
100+
# 1. bootstrap (only needed post clone or rebase)
101+
bootstrap:
102+
- task: apis:bootstrap
80103

81104
# 2. generate
82105
generate:
83106
desc: generates all the artifacts we need pre-build
84107
cmds:
85-
- task: builder-start
86-
- defer: {task: builder-cleanup}
87-
# DO NOT add bootstrap here, use all instead
88-
- docker exec -t {{.BUILD_CONTAINER}} task apis:generate
108+
- task: apis:generate

datatrails-common-api/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
go.work

datatrails-common-api/assets/v2/assets/enums.proto

+7
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ enum ConfirmationStatus {
77
PENDING = 1; // not yet committed
88
CONFIRMED = 2; // committed
99
FAILED = 3; // permanent failure
10+
11+
// Regarding the new statuses for forestrie, See
12+
// https://github.com/datatrails/epic-8120-scalable-proof-mechanisms/blob/main/event-trust-levels.md
13+
STORED = 4; // forestrie, "its in the db"
14+
COMMITTED = 5; // forestrie, "you can know if its changed"
15+
// CONFIRMED = 6; // forestrie, "You can easily prove it changed"
16+
UNEQUIVOCAL = 7; // forestrie, "You easily prove it was publicly available to all"
1017
}
1118

1219
enum TrackedStatus {

datatrails-common-api/assets/v2/assets/eventresponse.proto

+18-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import "protoc-gen-openapiv2/options/annotations.proto";
77
import "google/protobuf/timestamp.proto";
88
import "datatrails-common-api/assets/v2/assets/enums.proto";
99
import "datatrails-common-api/assets/v2/assets/principal.proto";
10+
import "datatrails-common-api/assets/v2/assets/merklelogentry.proto";
1011
import "datatrails-common-api/attribute/v2/attribute/attribute.proto";
1112

1213
message EventResponse {
@@ -102,9 +103,9 @@ message EventResponse {
102103
read_only: true
103104
}];
104105

105-
// timestamp operation has been committed on the blockchain
106+
// timestamp for when the event was committed to a verifiable log
106107
google.protobuf.Timestamp timestamp_committed = 7 [ (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
107-
description: "time of event as recorded on blockchain"
108+
description: "time of event as recorded in verifiable storage"
108109
read_only: true
109110
}];
110111

@@ -135,6 +136,8 @@ message EventResponse {
135136
type: STRING
136137
}];
137138

139+
// NOTICE: We expect to retire simple hash and then remove all the top level dlt fields.
140+
138141
// hash of transaction committing this operation on blockchain
139142
string transaction_id = 11 [ (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
140143
description: "hash of the transaction as a hex string `0x11bf5b37e0b842e08dcfdc8c4aefc000`"
@@ -164,4 +167,17 @@ message EventResponse {
164167
"Identity of the tenant the that created this event"
165168
max_length: 1024
166169
}];
170+
171+
// An event has exactly one proof mechanism. This field caputures the proof
172+
// mechanism specific details supporting the trustworthyness of the event
173+
// record. We anticipate at least two proof mechs: merkle_log and
174+
// verkle_log. We use oneof to avoid repeating the scattering of randomly
175+
// re-purposed fields we currently have for simple hash vs khipu.
176+
oneof proof_details {
177+
MerklLogEntry 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+
};
167183
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// Maintainers, please refer to the style guide here:
2+
// https://developers.google.com/protocol-buffers/docs/style
3+
syntax = "proto3";
4+
package archivist.v2;
5+
option go_package="github.com/datatrails/go-datatrails-common-api-gen/assets/v2/assets;assets";
6+
import "google/protobuf/timestamp.proto";
7+
8+
// MerkeLogCommit provides the log entry details for a single mmr leaf.
9+
message MerkleLogCommit {
10+
/* The mmr index */
11+
uint64 index = 3;
12+
/* The mmr *leaf* index */
13+
uint64 leaf_index = 4; // TBD: this may be redundant.
14+
/* time ordered and strictly unique per tenant. system wide
15+
* unique with very reasonable operational assumptions. */
16+
fixed64 idtimestamp = 5;
17+
}
18+
19+
// The message sent from forestrie to avid notifying that the corresponding
20+
// event is commited to the tenants log.
21+
message MerkleLogCommitMessage {
22+
23+
// The tenant identity and the event identity for the committed event.
24+
string tenant_identity = 1;
25+
string event_identity = 2;
26+
/* The time portion of idtimestamp that contributed to the hash of the event
27+
* (the idtimestamp is _also_ included.
28+
* This must be copied into event.timestamp_committed when the saas db is updated */
29+
google.protobuf.Timestamp timestamp = 6;
30+
31+
uint32 log_version = 3;
32+
uint32 log_epoch = 4;
33+
MerkleLogCommit committed = 5;
34+
}
35+
36+
37+
38+
// The details stored in the SaaS db for a proof mech MERKLE_LOG commitment
39+
message MerklLogEntry {
40+
41+
// The tenant log version and epoch when the log entry was created.
42+
uint32 log_version = 1;
43+
uint32 log_epoch = 2;
44+
45+
// Event trust level commited fields
46+
MerkleLogCommit committed = 3;
47+
48+
// TODO: Event trust level confirmed fields
49+
50+
// signature over tenant mmr root
51+
52+
// TODO: Event trust level uniquivocal fields
53+
}

datatrails-common-api/assets/v2/assets/service.proto

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ package archivist.v2;
55
option go_package="github.com/datatrails/go-datatrails-common-api-gen/assets/v2/assets;assets";
66

77
import "google/api/annotations.proto";
8-
import "validate/validate.proto";
98
import "protoc-gen-openapiv2/options/annotations.proto";
109

1110
import "datatrails-common-api/assets/v2/assets/assetresponse.proto";

datatrails-common-api/go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ go 1.21
88
// This allows this module to operate as tho it were the generated module. This
99
// allows us to manage the proto tool dependencies via this go.mod. This go.mod
1010
// is also used as the go.mod for the generated package.
11-
replace github.com/datatrails/go-datatrails-common-api-gen => ./
11+
// replace github.com/datatrails/go-datatrails-common-api-gen => ./
1212

1313
require (
1414
github.com/datatrails/go-datatrails-common v0.10.2

getproto.sh

-3
This file was deleted.

0 commit comments

Comments
 (0)