Compare commits

...

11 Commits

Author SHA1 Message Date
d567848cba chore: release master (#92) 2023-05-03 16:58:12 +04:00
9b942eacca feat(keypair): Make KeyFormat more convenient (#91)
* feat(keypair): Make `KeyFormat` more convenient

1. Make `KeyFormat` implement `Debug`, `Clone` and `Eq`.
2. Add `KeyPair::key_format(&self) -> KeyFormat` method.
2023-05-03 02:48:42 +07:00
c85fb16de3 chore: Fix build script (#90)
Fix build script
2023-04-18 16:42:51 +03:00
97ce5bbac7 chore(release-please): Fix publishing (#89)
Fix typo
2023-04-18 11:24:24 +03:00
864b7f5c13 chore: release master (#83) 2023-04-13 16:11:54 +03:00
da38a41ba7 fix(deps): Add trust-graph to workspace and bump sqlite-wasm version (#87)
* Add trust-graph to workspace

* Bump sqlite lite version

* Fix link
2023-04-13 15:03:08 +03:00
7493eed216 chore: skip cargo-workspace merge in release-please (#86)
Fix
2023-04-13 13:59:44 +03:00
e9399b7d0c chore: Move trust-graph to subdir (#85)
* Fix?

* Move trust-grap to subdir

* fix quickcheck update

* fix fmt

* fix service tests

* use marine 0.9.1

---------

Co-authored-by: Maria Kuklina <maria@fluence.one>
Co-authored-by: Valery Antopol <valery.antopol@gmail.com>
2023-04-13 13:55:35 +03:00
81eb924476 chore: Try workaround for release-please merge issue (#84) 2023-04-12 17:06:28 +03:00
fe902acc50 update aqua-lib (#81) 2023-04-12 15:22:47 +02:00
f5994b33d1 chore: Use setup-marine action (#78) 2023-03-20 12:19:48 +04:00
32 changed files with 3138 additions and 3570 deletions

View File

@ -19,7 +19,7 @@
} }
], ],
"packages": { "packages": {
".": { "trust-graph": {
"component": "trust-graph" "component": "trust-graph"
}, },
"aqua": { "aqua": {

View File

@ -1,6 +1,6 @@
{ {
".": "0.4.0", "trust-graph": "0.4.2",
"aqua": "0.4.0", "aqua": "0.4.1",
"service": "0.4.0", "service": "0.4.2",
"keypair": "0.10.0" "keypair": "0.10.1"
} }

View File

@ -14,9 +14,9 @@ jobs:
outputs: outputs:
releases-created: ${{ steps.release.outputs['releases_created'] }} releases-created: ${{ steps.release.outputs['releases_created'] }}
trust-graph-api-release-created: ${{ steps.release.outputs['aqua--release-created'] }} trust-graph-api-release-created: ${{ steps.release.outputs['aqua--release_created'] }}
trust-graph-release-created: ${{ steps.release.outputs['release-created'] }} trust-graph-release-created: ${{ steps.release.outputs['trust-graph--release_created'] }}
trust-graph-tag-name: ${{ steps.release.outputs['tag_name'] }} trust-graph-tag-name: ${{ steps.release.outputs['trust-graph--tag_name'] }}
steps: steps:
- name: Run release-please - name: Run release-please
@ -65,10 +65,8 @@ jobs:
- name: Setup Rust toolchain - name: Setup Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1 uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Install Marine - name: Setup marine
uses: baptiste0928/cargo-install@v1.3.0 uses: fluencelabs/setup-marine@v1
with:
crate: marine
- name: Build - name: Build
run: ./build.sh run: ./build.sh

View File

@ -19,10 +19,8 @@ jobs:
- name: Setup Rust toolchain - name: Setup Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1 uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Install marine - name: Setup marine
uses: baptiste0928/cargo-install@v1.3.0 uses: fluencelabs/setup-marine@v1
with:
crate: marine
- name: Build - name: Build
working-directory: ./service working-directory: ./service

1732
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1,28 +1,6 @@
[package]
name = "trust-graph"
version = "0.4.0"
authors = ["Fluence Labs"]
edition = "2021"
description = "trust graph"
license = "Apache-2.0"
repository = "https://github.com/fluencelabs/trust-graph"
[dependencies]
serde = { version = "1.0.118", features = ["derive"] }
fluence-keypair = { path = "./keypair", version = "0.10.0" }
bs58 = "0.4.0"
failure = "0.1.6"
log = "0.4.11"
ref-cast = "1.0.2"
derivative = "2.1.1"
thiserror = "1.0.23"
sha2 = "0.10.6"
rand = "0.8.5"
nonempty = "0.8.1"
[workspace] [workspace]
members = [ members = [
"trust-graph",
"keypair", "keypair",
"service" "service"
] ]

View File

@ -1,5 +1,13 @@
# Changelog # Changelog
## [0.4.1](https://github.com/fluencelabs/trust-graph/compare/trust-graph-api-v0.4.0...trust-graph-api-v0.4.1) (2023-04-13)
### Bug Fixes
* **deps:** update aqua to 0.10.3 ([fe902ac](https://github.com/fluencelabs/trust-graph/commit/fe902acc50a6b4c6bf97c487f3e47ae0f5ef8a95))
* **deps:** update aqua-lib to 0.7.0 ([fe902ac](https://github.com/fluencelabs/trust-graph/commit/fe902acc50a6b4c6bf97c487f3e47ae0f5ef8a95))
## [0.4.0](https://github.com/fluencelabs/trust-graph/compare/trust-graph-api-v0.3.2...trust-graph-api-v0.4.0) (2023-03-15) ## [0.4.0](https://github.com/fluencelabs/trust-graph/compare/trust-graph-api-v0.3.2...trust-graph-api-v0.4.0) (2023-03-15)

4780
aqua/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,12 +1,12 @@
{ {
"name": "@fluencelabs/trust-graph", "name": "@fluencelabs/trust-graph",
"version": "0.4.0", "version": "0.4.1",
"description": "Aqua Trust Graph API library", "description": "Aqua Trust Graph API library",
"files": [ "files": [
"*.aqua" "*.aqua"
], ],
"dependencies": { "dependencies": {
"@fluencelabs/aqua-lib": "^0.5.2" "@fluencelabs/aqua-lib": "^0.7.0"
}, },
"scripts": { "scripts": {
"generate-aqua": "../service/build.sh", "generate-aqua": "../service/build.sh",
@ -31,6 +31,6 @@
}, },
"homepage": "https://github.com/fluencelabs/trust-graph#readme", "homepage": "https://github.com/fluencelabs/trust-graph#readme",
"devDependencies": { "devDependencies": {
"@fluencelabs/aqua": "^0.7.4-322" "@fluencelabs/aqua": "^0.10.3"
} }
} }

View File

@ -14,9 +14,7 @@ SCRIPT_DIR="$(pwd)"
( (
echo "*** create builtin distribution package ***" echo "*** create builtin distribution package ***"
cd .. cd ..
mv builtin-package trust-graph tar --exclude="package.sh" -f trust-graph.tar.gz -zcv --transform 's|builtin-package|trust-graph|' builtin-package
tar --exclude="package.sh" -f trust-graph.tar.gz -zcv ./trust-graph
mv trust-graph builtin-package
) )
echo "*** done ***" echo "*** done ***"

View File

@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [0.10.1](https://github.com/fluencelabs/trust-graph/compare/keypair-v0.10.0...keypair-v0.10.1) (2023-05-02)
### Features
* **keypair:** Make `KeyFormat` more convenient ([#91](https://github.com/fluencelabs/trust-graph/issues/91)) ([9b942ea](https://github.com/fluencelabs/trust-graph/commit/9b942eacca49d0468b4d7512667102363a6c9aa3))
## [0.10.0](https://github.com/fluencelabs/trust-graph/compare/keypair-v0.9.0...keypair-v0.10.0) (2023-03-15) ## [0.10.0](https://github.com/fluencelabs/trust-graph/compare/keypair-v0.9.0...keypair-v0.10.0) (2023-03-15)

View File

@ -1,6 +1,6 @@
[package] [package]
name = "fluence-keypair" name = "fluence-keypair"
version = "0.10.0" version = "0.10.1"
authors = ["Fluence Labs"] authors = ["Fluence Labs"]
edition = "2021" edition = "2021"
description = "identity" description = "identity"

View File

@ -48,6 +48,7 @@ use std::str::FromStr;
/// ``` /// ```
/// ///
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum KeyFormat { pub enum KeyFormat {
Ed25519, Ed25519,
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
@ -168,6 +169,18 @@ impl KeyPair {
} }
} }
/// Get the key format of this keypair.
pub fn key_format(&self) -> KeyFormat {
use KeyPair::*;
match self {
Ed25519(_) => KeyFormat::Ed25519,
#[cfg(not(target_arch = "wasm32"))]
Rsa(_) => KeyFormat::Rsa,
Secp256k1(_) => KeyFormat::Secp256k1,
}
}
/// Get the public key of this keypair. /// Get the public key of this keypair.
pub fn public(&self) -> PublicKey { pub fn public(&self) -> PublicKey {
use KeyPair::*; use KeyPair::*;

View File

@ -234,7 +234,6 @@ pub struct Signature(pub Vec<u8>);
mod tests { mod tests {
use super::*; use super::*;
use quickcheck::*; use quickcheck::*;
use rand::seq::SliceRandom;
use std::fmt; use std::fmt;
const KEY1: &'static [u8] = include_bytes!("test/rsa-2048.pk8"); const KEY1: &'static [u8] = include_bytes!("test/rsa-2048.pk8");
@ -251,8 +250,8 @@ mod tests {
} }
impl Arbitrary for SomeKeypair { impl Arbitrary for SomeKeypair {
fn arbitrary<G: Gen>(g: &mut G) -> SomeKeypair { fn arbitrary(g: &mut Gen) -> SomeKeypair {
let mut key = [KEY1, KEY2, KEY3].choose(g).unwrap().to_vec(); let mut key = g.choose(&[KEY1, KEY2, KEY3]).unwrap().to_vec();
SomeKeypair(Keypair::from_pkcs8(&mut key).unwrap()) SomeKeypair(Keypair::from_pkcs8(&mut key).unwrap())
} }
} }

View File

@ -4,6 +4,25 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
* The following workspace dependencies were updated
* dependencies
* trust-graph bumped from 0.4.1 to 0.4.2
* fluence-keypair bumped from 0.10.0 to 0.10.1
## [0.4.1](https://github.com/fluencelabs/trust-graph/compare/trust-graph-wasm-v0.4.0...trust-graph-wasm-v0.4.1) (2023-04-13)
### Bug Fixes
* **deps:** Add trust-graph to workspace and bump sqlite-wasm version ([#87](https://github.com/fluencelabs/trust-graph/issues/87)) ([da38a41](https://github.com/fluencelabs/trust-graph/commit/da38a41ba727a14774a71bba6612b1bf1f498db9))
### Dependencies
* The following workspace dependencies were updated
* dependencies
* trust-graph bumped from 0.4.0 to 0.4.1
## [0.4.0](https://github.com/fluencelabs/trust-graph/compare/trust-graph-wasm-v0.3.2...trust-graph-wasm-v0.4.0) (2023-03-15) ## [0.4.0](https://github.com/fluencelabs/trust-graph/compare/trust-graph-wasm-v0.3.2...trust-graph-wasm-v0.4.0) (2023-03-15)

View File

@ -1,6 +1,6 @@
[package] [package]
name = "trust-graph-wasm" name = "trust-graph-wasm"
version = "0.4.0" version = "0.4.2"
authors = ["Fluence Labs"] authors = ["Fluence Labs"]
edition = "2021" edition = "2021"
description = "trust graph wasm" description = "trust graph wasm"
@ -12,8 +12,8 @@ name = "trust-graph"
path = "src/main.rs" path = "src/main.rs"
[dependencies] [dependencies]
trust-graph = { version = "0.4.0", path = "../." } trust-graph = { version = "0.4.2", path = "../trust-graph" }
fluence-keypair = { version = "0.10.0", path = "../keypair" } fluence-keypair = { version = "0.10.1", path = "../keypair" }
marine-rs-sdk = { version = "0.7.1", features = ["logger"] } marine-rs-sdk = { version = "0.7.1", features = ["logger"] }
marine-sqlite-connector = "0.8.0" marine-sqlite-connector = "0.8.0"
@ -29,8 +29,8 @@ bincode = "1.3.1"
thiserror = "1.0.23" thiserror = "1.0.23"
[dev-dependencies] [dev-dependencies]
marine-rs-sdk-test = "0.8.1" marine-rs-sdk-test = "0.9.1"
rusqlite = "0.28.0" rusqlite = "0.28.0"
[build-dependencies] [build-dependencies]
marine-rs-sdk-test = "0.8.1" marine-rs-sdk-test = "0.9.1"

View File

@ -5,12 +5,10 @@ modules_dir = "artifacts/"
logger_enabled = true logger_enabled = true
[module.wasi] [module.wasi]
preopened_files = ["/tmp"] mapped_dirs = { "/tmp" = "data" }
mapped_dirs = { "tmp" = "/tmp" }
[[module]] [[module]]
name = "trust-graph" name = "trust-graph"
logger_enabled = true logger_enabled = true
[module.wasi] [module.wasi]
preopened_files = ["/tmp"] mapped_dirs = { "/tmp" = "data" }
mapped_dirs = { "tmp" = "/tmp" }

View File

@ -13,7 +13,7 @@ mkdir -p artifacts
cp ../target/wasm32-wasi/release/trust-graph.wasm artifacts/ cp ../target/wasm32-wasi/release/trust-graph.wasm artifacts/
# download SQLite 3 to use in tests # download SQLite 3 to use in tests
curl -sS -L https://github.com/fluencelabs/sqlite/releases/download/v0.15.0_w/sqlite3.wasm -o artifacts/sqlite3.wasm curl -sS -L https://github.com/fluencelabs/sqlite/releases/download/sqlite-wasm-v0.18.1/sqlite3.wasm -o artifacts/sqlite3.wasm
# generate Aqua bindings # generate Aqua bindings
marine aqua artifacts/trust-graph.wasm -s TrustGraph -i trust-graph > ../aqua/trust-graph.aqua marine aqua artifacts/trust-graph.wasm -s TrustGraph -i trust-graph > ../aqua/trust-graph.aqua

View File

@ -18,18 +18,18 @@
mod service_tests { mod service_tests {
marine_rs_sdk_test::include_test_env!("/marine_test_env.rs"); marine_rs_sdk_test::include_test_env!("/marine_test_env.rs");
use crate::error::ServiceError; use crate::error::ServiceError;
use crate::storage_impl::DB_PATH;
use crate::TRUSTED_TIMESTAMP; use crate::TRUSTED_TIMESTAMP;
use fluence_keypair::KeyPair; use fluence_keypair::KeyPair;
use libp2p_identity::PeerId; use libp2p_identity::PeerId;
use marine_rs_sdk::{CallParameters, SecurityTetraplet}; use marine_rs_sdk::{CallParameters, SecurityTetraplet};
use marine_test_env::trust_graph::{Certificate, Revocation, ServiceInterface, Trust}; use marine_test_env::trust_graph::{Certificate, Revocation, ServiceInterface, Trust};
use rusqlite::Connection;
use std::collections::HashMap; use std::collections::HashMap;
use std::time::{SystemTime, UNIX_EPOCH}; use std::time::{SystemTime, UNIX_EPOCH};
static HOST_ID: &str = "some_host_id"; static HOST_ID: &str = "some_host_id";
static TEST_DB_PATH: &str = "data/trust-graph.sqlite";
struct Auth { struct Auth {
issuer: PeerId, issuer: PeerId,
trust: Trust, trust: Trust,
@ -55,12 +55,7 @@ mod service_tests {
} }
fn clear_env() { fn clear_env() {
let connection = Connection::open(DB_PATH).unwrap(); std::fs::remove_file(TEST_DB_PATH).unwrap_or_default();
connection
.execute("DELETE FROM trust_relations", [])
.unwrap();
connection.execute("DELETE FROM roots", []).unwrap();
} }
fn get_correct_timestamp_cp(arg_number: usize) -> CallParameters { fn get_correct_timestamp_cp(arg_number: usize) -> CallParameters {
@ -445,32 +440,32 @@ mod service_tests {
let mut trust_graph = marine_test_env::trust_graph::ServiceInterface::new(); let mut trust_graph = marine_test_env::trust_graph::ServiceInterface::new();
clear_env(); clear_env();
let peerA_kp = KeyPair::generate_ed25519(); let peer_a_kp = KeyPair::generate_ed25519();
let mut cur_time = 100u64; let mut cur_time = 100u64;
add_root_with_trust(&mut trust_graph, &peerA_kp, cur_time, cur_time + 9999, 10); add_root_with_trust(&mut trust_graph, &peer_a_kp, cur_time, cur_time + 9999, 10);
let peerB_kp = KeyPair::generate_ed25519(); let peer_b_kp = KeyPair::generate_ed25519();
add_trust( add_trust(
&mut trust_graph, &mut trust_graph,
&peerA_kp, &peer_a_kp,
&peerB_kp.get_peer_id(), &peer_b_kp.get_peer_id(),
cur_time, cur_time,
cur_time + 99999, cur_time + 99999,
); );
let weight = get_weight(&mut trust_graph, peerB_kp.get_peer_id(), cur_time); let weight = get_weight(&mut trust_graph, peer_b_kp.get_peer_id(), cur_time);
assert_ne!(weight, 0u32); assert_ne!(weight, 0u32);
cur_time += 1; cur_time += 1;
// A revokes B and cancels trust // A revokes B and cancels trust
revoke( revoke(
&mut trust_graph, &mut trust_graph,
&peerA_kp, &peer_a_kp,
&peerB_kp.get_peer_id(), &peer_b_kp.get_peer_id(),
cur_time, cur_time,
); );
let weight = get_weight(&mut trust_graph, peerB_kp.get_peer_id(), cur_time); let weight = get_weight(&mut trust_graph, peer_b_kp.get_peer_id(), cur_time);
assert_eq!(weight, 0u32); assert_eq!(weight, 0u32);
} }

View File

@ -1,5 +1,16 @@
# Changelog # Changelog
* The following workspace dependencies were updated
* dependencies
* fluence-keypair bumped from 0.10.0 to 0.10.1
## [0.4.1](https://github.com/fluencelabs/trust-graph/compare/trust-graph-v0.4.0...trust-graph-v0.4.1) (2023-04-13)
### Miscellaneous Chores
* **trust-graph:** Synchronize trust-graph, wasm and api versions
## [0.4.0](https://github.com/fluencelabs/trust-graph/compare/trust-graph-v0.3.2...trust-graph-v0.4.0) (2023-03-15) ## [0.4.0](https://github.com/fluencelabs/trust-graph/compare/trust-graph-v0.3.2...trust-graph-v0.4.0) (2023-03-15)

22
trust-graph/Cargo.toml Normal file
View File

@ -0,0 +1,22 @@
[package]
name = "trust-graph"
version = "0.4.2"
authors = ["Fluence Labs"]
edition = "2021"
description = "trust graph"
license = "Apache-2.0"
repository = "https://github.com/fluencelabs/trust-graph"
[dependencies]
serde = { version = "1.0.118", features = ["derive"] }
fluence-keypair = { path = "../keypair", version = "0.10.1" }
bs58 = "0.4.0"
failure = "0.1.6"
log = "0.4.11"
ref-cast = "1.0.2"
derivative = "2.1.1"
thiserror = "1.0.23"
sha2 = "0.10.6"
rand = "0.8.5"
nonempty = "0.8.1"