Skip to content

Commit 9d29db1

Browse files
* Introduce RPC and new protocol crate
* Fork ledger traits * Genesis config for opa * Opa administration logic / pallet * Subxt based client - connectivity * Development runtime - working, global logger use needs to consider rust::tracing * Signature and address types, substrate crypto used directly for account signatures * Seed mechanism changed in ChronicleSigning to allow us to supply a specific seed * Remove transaction costs and balance checks Signed-off-by: Ryan <ryan.roberts@btp.works>
1 parent f0c4df1 commit 9d29db1

File tree

101 files changed

+10843
-6146
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+10843
-6146
lines changed

Cargo.lock

Lines changed: 3221 additions & 2459 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,21 @@ members = [
88
"crates/chronicle-domain",
99
"crates/chronicle-domain-lint",
1010
"crates/chronicle-domain-test",
11-
"crates/chronicle-protocol",
1211
"crates/chronicle-synth",
1312
"crates/chronicle-signing",
1413
"crates/chronicle-telemetry",
1514
"crates/gq-subscribe",
1615
"crates/id-provider",
17-
"crates/opa-tp",
18-
"crates/opa-tp-protocol",
19-
"crates/opactl",
20-
"crates/sawtooth-tp",
2116
"crates/pallet-chronicle",
17+
"crates/pallet-opa",
2218
"node/runtime-chronicle",
2319
"node/node-chronicle",
20+
"crates/embedded-substrate",
21+
"crates/runtime-api-chronicle",
22+
"crates/protocol-abstract",
23+
"crates/protocol-substrate",
24+
"crates/protocol-substrate-chronicle",
25+
"crates/protocol-substrate-opa",
2426
]
2527

2628
[workspace.dependencies]
@@ -29,16 +31,12 @@ anyhow = "1.0.6"
2931
assert_fs = "1.0"
3032
async-graphql = "5.0.9"
3133
async-graphql-poem = "5.0.9"
32-
async-stl-client = { git = "https://github.com/btpworks/async-stl-sdk" }
3334
async-stream = "0.3.3"
3435
async-trait = "0.1.61"
3536
backoff = { version = "0.4.0", features = ["futures", "tokio"] }
3637
base64 = "0.21"
3738
bytes = "1.3.0"
3839
cached = "0.42"
39-
frame-support = "24.0.0"
40-
frame-system = "24.0.0"
41-
frame-benchmarking = "24.0.0"
4240
cfg-if = "1.0.0"
4341
chronicle-signing = { path = "crates/chronicle-signing" }
4442
chrono = "0.4.26"
@@ -53,14 +51,13 @@ criterion = { version = "0.5.1", features = ["async_futures", "async_tokio"] }
5351
crossbeam = "0.8.1"
5452
custom_error = "1.9.2"
5553
derivative = "2.2.0"
56-
diesel = { version = "2.0.0-rc.0", features = [
57-
"postgres",
58-
"uuid",
59-
"chrono",
60-
"r2d2",
61-
] }
62-
diesel_migrations = { version = "2.0.0-rc.0", features = ["postgres"] }
54+
diesel = { version = "2.1", features = ["postgres", "uuid", "chrono", "r2d2"] }
55+
diesel-async = { version = "0.4" }
56+
diesel_migrations = { version = "2.1", features = ["postgres"] }
6357
dotenvy = "0.15"
58+
frame-benchmarking = "24.0.0"
59+
frame-support = "24.0.0"
60+
frame-system = "24.0.0"
6461
futures = "0.3.21"
6562
genco = "0.16.1"
6663
glob = "0.3.0"
@@ -80,22 +77,24 @@ k256 = { version = "0.11.3", features = [
8077
"ecdsa",
8178
"pkcs8",
8279
"sha256",
80+
"keccak256",
8381
"std",
8482
"pem",
8583
"serde",
8684
] }
8785
lazy_static = "1.4.0"
8886
locspan = "0.7"
8987
lru = "0.11"
88+
macro-attr-2018 = "3.0.0"
9089
maplit = "1.0.2"
9190
metrics = "0.21.0"
9291
metrics-exporter-prometheus = "0.12.1"
9392
mime = "0.3"
93+
mobc = "0.8"
9494
mockito = "1.1"
95+
newtype-derive-2018 = "0.2.1"
9596
oauth2 = "4.4"
9697
opa = { git = "https://github.com/tamasfe/opa-rs", rev = "3cf7fea" }
97-
openssl = { version = "0.10" }
98-
openssl-sys = { version = "0.10", features = ["vendored"] }
9998
opentelemetry = { version = "0.19.0", features = ["rt-tokio"] }
10099
opentelemetry-jaeger = { version = "0.18.0", features = [
101100
"rt-tokio",
@@ -127,18 +126,16 @@ rust-embed = { version = "6.6.0", features = [
127126
"debug-embed",
128127
"include-exclude",
129128
] }
130-
sawtooth-sdk = { git = "https://github.com/hyperledger/sawtooth-sdk-rust", rev = "5a300de" }
131129
secret-vault = { version = "1.8", features = [] }
132130
secret-vault-value = "0.3"
133-
serde = "1.0.152"
134-
serde_derive = "1.0.152"
135-
serde_json = "1.0.93"
131+
serde = "1.0"
132+
serde_derive = "1.0"
133+
serde_json = "1.0"
136134
serde_yaml = "0.9.14"
137135
shellexpand = "3.0.0"
138-
macro-attr-2018 = "3.0.0"
139-
newtype-derive-2018 = "0.2.1"
140136
temp-dir = "0.1.11"
141137
tempfile = "3.4.0"
138+
testcontainers = "0.14"
142139
thiserror = "1.0"
143140
tmq = "0.3"
144141
tokio = { version = "1.27", features = [
@@ -165,5 +162,3 @@ user-error = "1.2.8"
165162
uuid = "1.2.2"
166163
valico = "3.6.0"
167164
vaultrs = "*"
168-
zmq = { version = "0.9", features = ["vendored"] }
169-
testcontainers = "0.14"

crates/api/Cargo.toml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ version = "0.7.5"
66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
77

88
[dependencies]
9+
anyhow = { workspace = true }
910
async-graphql = { workspace = true, features = [
1011
"opentelemetry",
1112
"chrono",
@@ -14,20 +15,24 @@ async-graphql = { workspace = true, features = [
1415
"uuid",
1516
] }
1617
async-graphql-poem = { workspace = true }
17-
async-stl-client = { workspace = true }
1818
async-stream = { workspace = true }
1919
async-trait = { workspace = true }
2020
base64 = { workspace = true }
2121
cached = { workspace = true }
2222
cfg-if = { workspace = true }
23-
chronicle-protocol = { path = "../chronicle-protocol" }
2423
chronicle-signing = { workspace = true }
2524
chronicle-telemetry = { path = "../chronicle-telemetry" }
2625
chrono = { workspace = true }
27-
common = { path = "../common" }
26+
common = { path = "../common", features = [
27+
"json-ld",
28+
"diesel-bindings",
29+
"graphql-bindings",
30+
"std",
31+
] }
2832
custom_error = { workspace = true }
2933
derivative = { workspace = true }
3034
diesel = { workspace = true }
35+
diesel-async = { workspace = true }
3136
diesel_migrations = { workspace = true }
3237
futures = { workspace = true }
3338
glob = { workspace = true }
@@ -45,12 +50,14 @@ poem = { workspace = true }
4550
portpicker = { workspace = true }
4651
prost = { workspace = true }
4752
protobuf = { workspace = true }
53+
protocol-substrate = { path = "../protocol-substrate" }
54+
protocol-substrate-chronicle = { path = "../protocol-substrate-chronicle" }
55+
protocol-substrate-opa = { path = "../protocol-substrate-opa" }
4856
r2d2 = { workspace = true }
4957
rand = { workspace = true }
5058
rand_core = { workspace = true }
5159
reqwest = { workspace = true }
52-
sawtooth-sdk = { workspace = true }
53-
sawtooth_tp = { path = "../sawtooth-tp" }
60+
rust-embed = { workspace = true }
5461
serde = { workspace = true }
5562
serde_derive = { workspace = true }
5663
serde_json = { workspace = true }
@@ -65,9 +72,8 @@ uuid = { workspace = true }
6572

6673
[dev-dependencies]
6774
assert_fs = { workspace = true }
68-
chronicle-protocol = { path = "../chronicle-protocol" }
75+
embedded-substrate = { path = "../embedded-substrate" }
6976
insta = { workspace = true, features = ["json", "yaml"] }
70-
opa-tp-protocol = { path = "../opa-tp-protocol" }
7177
tempfile = { workspace = true }
7278

7379
[build-dependencies]

crates/api/src/chronicle_graphql/mod.rs

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ use chrono::NaiveDateTime;
1212
use common::{
1313
identity::{AuthId, IdentityError, JwtClaims, OpaData, SignedIdentity},
1414
ledger::{SubmissionError, SubmissionStage},
15-
opa::{ExecutorContext, OpaExecutorError},
15+
opa::std::{ExecutorContext, OpaExecutorError},
1616
prov::{
17-
to_json_ld::ToJson, ChronicleIri, ChronicleTransactionId, ExternalId, ExternalIdPart,
17+
json_ld::ToJson, ChronicleIri, ChronicleTransactionId, ExternalId, ExternalIdPart,
1818
ProvModel,
1919
},
2020
};
@@ -292,10 +292,7 @@ impl From<SignedIdentity> for CommitIdentity {
292292
CommitIdentity {
293293
identity: identity.identity,
294294
signature: identity.signature.map(|x| hex::encode(&*x)).unwrap_or_default(),
295-
verifying_key: identity
296-
.verifying_key
297-
.map(|x| hex::encode(x.to_bytes()))
298-
.unwrap_or_default(),
295+
verifying_key: identity.verifying_key.map(hex::encode).unwrap_or_default(),
299296
}
300297
}
301298
}
@@ -810,8 +807,8 @@ impl IriEndpoint {
810807
.body("failed to compact JSON response"))
811808
},
812809
},
813-
Err(StoreError::Db(diesel::result::Error::NotFound))
814-
| Err(StoreError::RecordNotFound) => {
810+
Err(StoreError::Db(diesel::result::Error::NotFound)) |
811+
Err(StoreError::RecordNotFound) => {
815812
tracing::debug!("not found: {prov_type} {} in {ns}", id.external_id_part());
816813
Ok(poem::Response::builder()
817814
.status(StatusCode::NOT_FOUND)
@@ -875,9 +872,8 @@ impl IriEndpoint {
875872

876873
match ChronicleIri::from_str(&ns_iri.iri) {
877874
Ok(iri) => Ok(Ok((ns_iri.ns.into(), iri))),
878-
Err(error) => {
879-
Ok(Err(Response::builder().status(StatusCode::NOT_FOUND).body(error.to_string())))
880-
},
875+
Err(error) =>
876+
Ok(Err(Response::builder().status(StatusCode::NOT_FOUND).body(error.to_string()))),
881877
}
882878
}
883879

@@ -888,24 +884,21 @@ impl IriEndpoint {
888884
claims: Option<&JwtClaims>,
889885
) -> poem::Result<poem::Response> {
890886
match self.parse_ns_iri_from_uri_path(req).await? {
891-
Ok((ns, ChronicleIri::Activity(id))) => {
887+
Ok((ns, ChronicleIri::Activity(id))) =>
892888
self.response_for_query(claims, "activity", &id, &ns, |mut conn, id, ns| {
893889
self.store.prov_model_for_activity_id(&mut conn, id, ns)
894890
})
895-
.await
896-
},
897-
Ok((ns, ChronicleIri::Agent(id))) => {
891+
.await,
892+
Ok((ns, ChronicleIri::Agent(id))) =>
898893
self.response_for_query(claims, "agent", &id, &ns, |mut conn, id, ns| {
899894
self.store.prov_model_for_agent_id(&mut conn, id, ns)
900895
})
901-
.await
902-
},
903-
Ok((ns, ChronicleIri::Entity(id))) => {
896+
.await,
897+
Ok((ns, ChronicleIri::Entity(id))) =>
904898
self.response_for_query(claims, "entity", &id, &ns, |mut conn, id, ns| {
905899
self.store.prov_model_for_entity_id(&mut conn, id, ns)
906900
})
907-
.await
908-
},
901+
.await,
909902
Ok(_) => Ok(poem::Response::builder()
910903
.status(StatusCode::NOT_FOUND)
911904
.body("may query only: activity, agent, entity")),

crates/api/src/chronicle_graphql/mutation.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
//! Primitive mutation operations that are not in terms of particular domain types
2-
2+
use crate::commands::{ActivityCommand, AgentCommand, ApiCommand, ApiResponse, EntityCommand};
33
use async_graphql::Context;
44
use chrono::{DateTime, Utc};
55
use common::{
66
attributes::Attributes,
7-
commands::{ActivityCommand, AgentCommand, ApiCommand, ApiResponse, EntityCommand},
87
identity::AuthId,
98
prov::{operations::DerivationType, ActivityId, AgentId, EntityId, Role},
109
};

crates/api/src/commands.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use core::pin::Pin;
2+
use std::{path::PathBuf, sync::Arc};
23
#[cfg(feature = "std")]
34
use std::{path::PathBuf, sync::Arc};
45

@@ -7,7 +8,7 @@ use futures::AsyncRead;
78

89
use serde::{Deserialize, Serialize};
910

10-
use crate::{
11+
use common::{
1112
attributes::Attributes,
1213
prov::{
1314
operations::{ChronicleOperation, DerivationType},
@@ -16,13 +17,6 @@ use crate::{
1617
},
1718
};
1819

19-
#[cfg(not(feature = "std"))]
20-
use parity_scale_codec::{
21-
alloc::boxed::Box, alloc::string::String, alloc::sync::Arc, alloc::vec::Vec,
22-
};
23-
#[cfg(not(feature = "std"))]
24-
use scale_info::prelude::*;
25-
2620
#[derive(Debug, Clone, Serialize, Deserialize)]
2721
pub enum NamespaceCommand {
2822
Create { external_id: ExternalId },
@@ -47,7 +41,6 @@ pub enum AgentCommand {
4741
role: Option<Role>,
4842
},
4943
}
50-
5144
#[derive(Debug, Clone, Serialize, Deserialize)]
5245
pub enum ActivityCommand {
5346
Create {
@@ -156,8 +149,7 @@ impl ActivityCommand {
156149
#[derive(Clone)]
157150
pub enum PathOrFile {
158151
Path(PathBuf),
159-
File(Arc<Pin<Box<dyn AsyncRead + Sync + Send>>>), /* Non serialisable variant, used in
160-
* process */
152+
File(Arc<Pin<Box<dyn AsyncRead + Sync + Send>>>),
161153
}
162154

163155
impl core::fmt::Debug for PathOrFile {

0 commit comments

Comments
 (0)