Skip to content

Commit

Permalink
Generalize Account Ids (#220)
Browse files Browse the repository at this point in the history
* feat(store-redis) use wrapper AccountId struct that internally uses UUID for indexing accounts

* test(engines): add helper to send to an SPSP account id

note that this does not support usernames, meaning the sender must know the internal store account's uuid which seems to introduce bad UX

* feat(eth-se): Remove dependency from Account trait and use EthereumAccount wherever possible

* feat(redis): Allow deserialization of Accounts

* test(engines): Use explicit account UIDs for SPSP and checking balances

Previously we assumed that they were increasing, which is not the case now since each id gets randomly generated

* test(interledger): adjust remaining tests to work with any account id

* implement IdempotentStore for the Ethereum store by forwarding to the wrapped store

Rust does not support trait delegation

* refactor(eth-engine): Use IdempotentEngineStore in the API

* tests(eth-engine): use IdempotentEngine in the store and remove redundant cli params

* Remove Redis dependency from Engines

We need it as a dev-dependency when interacting to parse Accounts.
Engines now use raw-unparsed String datatypes as account ids. We remove the Copy trait and add clone's where necessary, but this allows us to do less type conversions

* chore(engine): remove redundant string conversion

* Fix libcurl issue with cargo-audit
  • Loading branch information
gakonst committed Aug 19, 2019
1 parent 27d7c60 commit 26d893d
Show file tree
Hide file tree
Showing 34 changed files with 1,477 additions and 977 deletions.
15 changes: 10 additions & 5 deletions .circleci/config.yml
Expand Up @@ -16,16 +16,21 @@ jobs:
- run:
name: Install Cargo Extensions
command: |
# cargo-audit started requiring libcurl3
echo "deb http://security.ubuntu.com/ubuntu xenial-security main" | sudo tee -a /etc/apt/sources.list
sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 3B4FE6ACC0B21F32
sudo apt-get update
sudo apt-get install libcurl3 -y
# get libcurl to a place where it won't get overwritten
sudo cp /usr/lib/x86_64-linux-gnu/libcurl.so.3 /usr/lib
sudo apt-get install curl -y
cargo install --quiet cargo-audit || true # cargo-kcov
rustup component add rustfmt clippy || true
- run:
name: Install Redis
# Install from stretch-backports to get the latest version
# The normal repository has version 3.2, which doesn't support redis modules
command: |
echo "deb http://deb.debian.org/debian stretch-backports main" | sudo tee -a /etc/apt/sources.list
sudo apt-get update
sudo apt-get -t stretch-backports install redis-server
sudo apt-get install redis-server
redis-server --version
- run:
name: Install node and ganache
Expand Down Expand Up @@ -64,7 +69,7 @@ jobs:
cargo clippy --all-targets --all-features -- -D warnings
- run:
name: Audit Dependencies
command: cargo audit
command: LD_PRELOAD=/usr/lib/libcurl.so.3 cargo audit
# - run:
# name: Install kcov
# command: >-
Expand Down
1 change: 1 addition & 0 deletions crates/interledger-ccp/Cargo.toml
Expand Up @@ -21,3 +21,4 @@ parking_lot = "0.7.1"
ring = "0.14.6"
tokio-executor = "0.1.7"
tokio-timer = "0.2.10"
serde = { version = "1.0.98", features = ["derive"] }
4 changes: 3 additions & 1 deletion crates/interledger-ccp/src/lib.rs
Expand Up @@ -26,8 +26,10 @@ mod test_helpers;

pub use server::{CcpRouteManager, CcpRouteManagerBuilder};

use serde::{Deserialize, Serialize};

#[repr(u8)]
#[derive(Clone, Copy, Debug, PartialEq, PartialOrd)]
#[derive(Clone, Copy, Debug, PartialEq, PartialOrd, Serialize, Deserialize)]
pub enum RoutingRelation {
Parent = 1,
Peer = 2,
Expand Down
2 changes: 1 addition & 1 deletion crates/interledger-settlement-engines/Cargo.toml
Expand Up @@ -16,7 +16,6 @@ futures = "0.1.25"
interledger-service = { path = "../interledger-service", version = "0.2.1" }
interledger-settlement = { path = "../interledger-settlement", version = "0.1.0" }
interledger-service-util = { path = "../interledger-service-util", version = "0.2.1" }
interledger-store-redis = { path = "../interledger-store-redis", version = "0.2.1" }
interledger-ildcp = { path = "../interledger-ildcp", version = "0.2.1" }
ethabi = "8.0.1"
serde = "1.0.91"
Expand Down Expand Up @@ -48,3 +47,4 @@ os_type = "2.2.0"
rand = "0.7.0"
interledger = { path = "../interledger", version = "0.4.0" }
interledger-packet = { path = "../interledger-packet", version = "0.2.1" }
interledger-store-redis = { path = "../interledger-store-redis", version = "0.2.1" }
8 changes: 4 additions & 4 deletions crates/interledger-settlement-engines/src/api.rs
@@ -1,3 +1,4 @@
use crate::stores::{IdempotentEngineData, IdempotentEngineStore};
use crate::{ApiResponse, CreateAccount, SettlementEngine};
use bytes::Bytes;
use futures::{
Expand All @@ -6,7 +7,6 @@ use futures::{
};
use hyper::{Response, StatusCode};
use interledger_settlement::Quantity;
use interledger_settlement::{IdempotentData, IdempotentStore};
use log::error;
use ring::digest::{digest, SHA256};
use tokio::executor::spawn;
Expand All @@ -26,7 +26,7 @@ impl_web! {
impl<E, S> SettlementEngineApi<E, S>
where
E: SettlementEngine + Clone + Send + Sync + 'static,
S: IdempotentStore + Clone + Send + Sync + 'static,
S: IdempotentEngineStore + Clone + Send + Sync + 'static,
{
/// Create a new API service by providing it with a field that
/// implements the `SettlementEngine` trait
Expand Down Expand Up @@ -85,7 +85,7 @@ impl_web! {
error!("{}", error_msg);
error_msg
})
.and_then(move |ret: Option<IdempotentData>| {
.and_then(move |ret: Option<IdempotentEngineData>| {
if let Some(ret) = ret {
if ret.2 == input_hash {
Ok(Some((ret.0, ret.1)))
Expand Down Expand Up @@ -160,7 +160,7 @@ fn get_hash_of(preimage: &[u8]) -> [u8; 32] {
impl<E, S> SettlementEngineApi<E, S>
where
E: SettlementEngine + Clone + Send + Sync + 'static,
S: IdempotentStore + Clone + Send + Sync + 'static,
S: IdempotentEngineStore + Clone + Send + Sync + 'static,
{
/// Serves the API
/// Example:
Expand Down

0 comments on commit 26d893d

Please sign in to comment.