Skip to content
Permalink
Browse files

Generalize Account Ids (#220)

* 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 26d893d5c06f023cddcd503eb0b37b787f2fdf38
Showing with 1,477 additions and 977 deletions.
  1. +10 −5 .circleci/config.yml
  2. +1 −0 crates/interledger-ccp/Cargo.toml
  3. +3 −1 crates/interledger-ccp/src/lib.rs
  4. +1 −1 crates/interledger-settlement-engines/Cargo.toml
  5. +4 −4 crates/interledger-settlement-engines/src/api.rs
  6. +107 −143 crates/interledger-settlement-engines/src/engines/ethereum_ledger/eth_engine.rs
  7. +2 −2 crates/interledger-settlement-engines/src/engines/ethereum_ledger/fixtures.rs
  8. +22 −51 crates/interledger-settlement-engines/src/engines/ethereum_ledger/test_helpers.rs
  9. +21 −5 crates/interledger-settlement-engines/src/engines/ethereum_ledger/types.rs
  10. +0 −15 crates/interledger-settlement-engines/src/main.rs
  11. +23 −0 crates/interledger-settlement-engines/src/stores/mod.rs
  12. +39 −21 crates/interledger-settlement-engines/src/stores/redis_ethereum_ledger/store.rs
  13. +126 −2 crates/interledger-settlement-engines/src/stores/redis_store_common.rs
  14. +79 −54 crates/interledger-settlement-engines/tests/eth_ledger_settlement.rs
  15. +107 −61 crates/interledger-settlement-engines/tests/eth_xrp_interoperable.rs
  16. +49 −8 crates/interledger-settlement-engines/tests/test_helpers.rs
  17. +87 −62 crates/interledger-settlement-engines/tests/xrp_ledger_settlement.rs
  18. +3 −1 crates/interledger-store-redis/Cargo.toml
  19. +57 −34 crates/interledger-store-redis/src/account.rs
  20. +1 −1 crates/interledger-store-redis/src/lib.rs
  21. +155 −146 crates/interledger-store-redis/src/store.rs
  22. +61 −49 crates/interledger-store-redis/tests/accounts_test.rs
  23. +70 −56 crates/interledger-store-redis/tests/balances_test.rs
  24. +11 −6 crates/interledger-store-redis/tests/btp_test.rs
  25. +12 −4 crates/interledger-store-redis/tests/common/store_helpers.rs
  26. +11 −6 crates/interledger-store-redis/tests/http_test.rs
  27. +7 −6 crates/interledger-store-redis/tests/rate_limiting_test.rs
  28. +1 −1 crates/interledger-store-redis/tests/rates_test.rs
  29. +137 −105 crates/interledger-store-redis/tests/routing_test.rs
  30. +27 −21 crates/interledger-store-redis/tests/settlement_test.rs
  31. +5 −1 crates/interledger/src/main.rs
  32. +9 −4 crates/interledger/src/node.rs
  33. +124 −0 crates/interledger/tests/test_helpers.rs
  34. +105 −101 crates/interledger/tests/three_nodes.rs
@@ -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
@@ -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: >-
@@ -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"] }
@@ -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,
@@ -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"
@@ -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" }
@@ -1,3 +1,4 @@
use crate::stores::{IdempotentEngineData, IdempotentEngineStore};
use crate::{ApiResponse, CreateAccount, SettlementEngine};
use bytes::Bytes;
use futures::{
@@ -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;
@@ -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
@@ -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)))
@@ -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:

0 comments on commit 26d893d

Please sign in to comment.
You can’t perform that action at this time.