Skip to content

Commit

Permalink
Merge branch 'feat/actix-migration' into HEAD
Browse files Browse the repository at this point in the history
  • Loading branch information
elenaf9 committed Aug 11, 2021
2 parents d93c9f6 + 2108ac6 commit 5fe45cd
Show file tree
Hide file tree
Showing 89 changed files with 14,534 additions and 2,891 deletions.
9 changes: 9 additions & 0 deletions .changes/actix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"iota-stronghold": minor
---

- replace actor system riker with actix
- introduced registry actor for clients as service
- introduced snapshot actor as service
- merge `Internal` and `Client`-Actors into `SecureClient`
- api change in interface for test reading secrets out of a vault. minimal impact.
66 changes: 66 additions & 0 deletions .github/workflows/deploy-docs-to-gh-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: deploy

on:
pull_request:
branches: [dev, main]
push:
branches: [dev, main]

jobs:
checks:
if: github.event_name != 'push'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: '12.x'
- name: Test Build
run: |
cd documentation
if [ -e yarn.lock ]; then
yarn install --frozen-lockfile
elif [ -e package-lock.json ]; then
npm ci
else
npm i
fi
npm run build
gh-release:
if: github.event_name != 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: '12.x'
- name: Build
run: |
cd documentation
if [ -e yarn.lock ]; then
yarn install --frozen-lockfile
elif [ -e package-lock.json ]; then
npm ci
else
npm i
fi
npm run build
- name: Install rust-docs with nightly toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
components: rust-docs
- name: Deploy Rust Docs
run: |
sudo apt-get update
sudo apt-get install libudev-dev libusb-1.0-0-dev
DOCFLAGS="--cfg docsrs" cargo +stable doc --all-features --document-private-items --no-deps --release
cp -r target/doc documentation/build/rust
- name: Release to GitHub Pages
uses: iotaledger/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./documentation/build
cname: stronghold.docs.iota.org
28 changes: 0 additions & 28 deletions .github/workflows/deploy_docs_to_gh-pages.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ There are four main components of Stronghold:
3. **P2P**: Enables Strongholds in different processes or on different devices to communicate with each other securely.

## 3rd Party Independent Security Audit
In April of 2021, F-Secure performed a security assessment of the core crates of IOTA Stronghold and found nothing of concern. This is not an explicit declaration of fitness or freedom of error, but it is an indicator of the high quality of the code. You may review [the audit here](https://github.com/iotaledger/stronghold.rs/blob/dev/docs/meta/Audit.pdf).
In April of 2021, F-Secure performed a security assessment of the core crates of IOTA Stronghold and found nothing of concern. This is not an explicit declaration of fitness or freedom of error, but it is an indicator of the high quality of the code. You may review [the audit here](https://github.com/iotaledger/stronghold.rs/blob/dev/documentation/docs/meta/Audit.pdf).

## Roadmap
Here are some of the features and tasks that we are working on.
Expand Down
10 changes: 7 additions & 3 deletions client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ zeroize = "1.1"
zeroize_derive = "1.0"
anyhow = "1.0"
thiserror = "1.0"
futures = "0.3"
riker = "0.4"
# futures = "0.3"
actix = "0.12"

# remove dependency
# riker = "0.4"

[dependencies.stronghold_engine]
path = "../engine"
Expand All @@ -48,9 +51,10 @@ version = "0.3"

[dev-dependencies]
hex = "0.4.2"
criterion = "0.3.3"
criterion = { version = "0.3.3", features = ["async_tokio"] }
clap = { version = "3.0.0-beta.1", features = [ "yaml" ] }
rand = "0.8.3"
tokio = {version = "1.9", features = ["rt-multi-thread"] }

[[bench]]
name = "benchmark"
Expand Down
7 changes: 5 additions & 2 deletions client/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Stronghold Client

This is the official client layer of Stronghold. It uses the Riker actor model and provides an easy interface which acts as a functional passthrough to Stronghold's internal actor system.
This is the official client layer of Stronghold. It provides an [Actix](https://actix.rs) actor model system for easy Interface as well as functional passthrough to Stronghold's internal actor system for integrators not using Riker.

**Stronghold Interface**:
- `init_stronghold_system`: Initializes a new instance of the Stronghold system. Sets up the first client actor. Accepts a `ActorSystem`, the first `client_path`: `Vec<u8>` and any `StrongholdFlags` which pertain to the first actor.
Expand Down Expand Up @@ -41,4 +41,7 @@ Also requires keydata to unlock the snapshot and the keydata must implement and
- `BIP39Generate`: Returns a `StatusMessage` indicating the result of the request.
- `BIP39MnemonicSentence`: Returns the mnemonic sentence for the corresponding seed.
- `Ed25519PublicKey`: Returns an Ed25519 public key inside of a `ResultMessage`.
- `Ed25519Sign`: Returns an Ed25519 signature inside of a `ResultMessage`.
- `Ed25519Sign`: Returns an Ed25519 signature inside of a `ResultMessage`.



59 changes: 34 additions & 25 deletions client/benches/benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,19 @@
// SPDX-License-Identifier: Apache-2.0

use criterion::{criterion_group, criterion_main, Criterion};

use iota_stronghold::{Location, RecordHint, Stronghold};

use riker::actors::*;

use futures::executor::block_on;

fn init_stronghold() -> Stronghold {
let system = ActorSystem::new().unwrap();

Stronghold::init_stronghold_system(system, b"path".to_vec(), vec![])
async fn init_stronghold() -> Stronghold {
Stronghold::init_stronghold_system(b"path".to_vec(), vec![])
.await
.unwrap()
}

fn init_read_vault(stronghold: Stronghold) -> Stronghold {
let system = actix::System::new();

for i in 0..30 {
block_on(stronghold.write_to_vault(
system.block_on(stronghold.write_to_vault(
Location::generic("test", format!("some_record {}", i)),
format!("test data {}", i).as_bytes().to_vec(),
RecordHint::new(b"test").unwrap(),
Expand All @@ -29,19 +26,22 @@ fn init_read_vault(stronghold: Stronghold) -> Stronghold {
}

fn init_read_snap(stronghold: Stronghold, key_data: &[u8]) -> Stronghold {
let system = actix::System::new();
let mut stronghold = init_read_vault(stronghold);

block_on(stronghold.write_all_to_snapshot(&key_data.to_vec(), Some("bench_read".into()), None));
system.block_on(stronghold.write_all_to_snapshot(&key_data.to_vec(), Some("bench_read".into()), None));

stronghold
}

fn bench_stronghold_write_create(c: &mut Criterion) {
let stronghold = init_stronghold();
let system = actix::System::new();

let stronghold = system.block_on(init_stronghold());

c.bench_function("write to stronghold while creating vaults", |b| {
b.iter(|| {
block_on(stronghold.write_to_vault(
system.block_on(stronghold.write_to_vault(
Location::generic("test", "some_record"),
b"test data".to_vec(),
RecordHint::new(b"test").unwrap(),
Expand All @@ -52,44 +52,53 @@ fn bench_stronghold_write_create(c: &mut Criterion) {
}

fn bench_write_snapshot(c: &mut Criterion) {
let stronghold = init_stronghold();
let system = actix::System::new();
let stronghold = system.block_on(init_stronghold());
let mut stronghold = init_read_vault(stronghold);

let key_data = b"abcdefghijklmnopqrstuvwxyz012345".to_vec();

c.bench_function("Write to snapshot", |b| {
b.iter(|| {
block_on(stronghold.write_all_to_snapshot(&key_data, Some("bench".into()), None));
});
b.iter(|| system.block_on(stronghold.write_all_to_snapshot(&key_data, Some("bench".into()), None)));
});
}

fn bench_read_from_snapshot(c: &mut Criterion) {
let stronghold = init_stronghold();
let system = actix::System::new();
let stronghold = system.block_on(init_stronghold());
let key_data = b"abcdefghijklmnopqrstuvwxyz012345".to_vec();
let mut stronghold = init_read_snap(stronghold, &key_data);

c.bench_function("Read from snapshot", |b| {
b.iter(|| {
block_on(stronghold.read_snapshot(b"path".to_vec(), None, &key_data, Some("bench_read".into()), None));
system.block_on(stronghold.read_snapshot(
b"path".to_vec(),
None,
&key_data,
Some("bench_read".into()),
None,
))
});
});
}

fn bench_write_store(c: &mut Criterion) {
let stronghold = init_stronghold();
let system = actix::System::new();
let stronghold = system.block_on(init_stronghold());

c.bench_function("Bench write to store", |b| {
b.iter(|| block_on(stronghold.write_to_store(Location::generic("test", "some_key"), b"test".to_vec(), None)));
b.iter(|| {
system.block_on(stronghold.write_to_store(Location::generic("test", "some_key"), b"test".to_vec(), None))
});
});
}

fn bench_read_store(c: &mut Criterion) {
let stronghold = init_stronghold();
block_on(stronghold.write_to_store(Location::generic("test", "some_key"), b"test".to_vec(), None));
let system = actix::System::new();
let stronghold = system.block_on(init_stronghold());
system.block_on(stronghold.write_to_store(Location::generic("test", "some_key"), b"test".to_vec(), None));

c.bench_function("Bench read from store", |b| {
b.iter(|| block_on(stronghold.read_from_store(Location::generic("test", "some_key"))));
b.iter(|| system.block_on(stronghold.read_from_store(Location::generic("test", "some_key"))));
});
}

Expand Down
Loading

0 comments on commit 5fe45cd

Please sign in to comment.