Skip to content

Commit

Permalink
Problem (Fix crypto-com#1881): wallet sync logic adapt to new tenderm…
Browse files Browse the repository at this point in the history
…int-rs light client design

Solution:
- running light client superivsor, and sync wallet to recent
  trusted block
- rpc call_batch ignore the first failed request and return the
  successed ones.
- run ra-sp-server before prepare env, and gen fresh keypackage when prepare test env
- fix tendermint-rs deserialization issues
  • Loading branch information
yihuang committed Jul 20, 2020
1 parent 2ac81fa commit 8ec7329
Show file tree
Hide file tree
Showing 33 changed files with 768 additions and 409 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ id_ecdsa

# integration tests temparary artifacts
/integration-tests/*.so
/integration-tests/bot/.venv
/integration-tests/.venv

**/chain-abci/Enclave_u.*

Expand Down
136 changes: 128 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,15 @@ default-members = [
ring = { git = "https://github.com/crypto-com/ring.git", rev = "bdbcc7041095f028d49d9fecd7edcf26d6083274" }
# FIXME: use upstream when merged
sha2 = { git = "https://github.com/crypto-com/hashes.git", rev = "289d5b76f2163a3808010341ed1df3cb156d97e1" }

[patch.crates-io.tendermint]
git = "https://github.com/informalsystems/tendermint-rs.git"
branch = "master"

[patch.crates-io.tendermint-rpc]
git = "https://github.com/informalsystems/tendermint-rs.git"
branch = "master"

[patch.crates-io.tendermint-light-client]
git = "https://github.com/informalsystems/tendermint-rs.git"
branch = "master"
6 changes: 1 addition & 5 deletions chain-tx-enclave-next/enclave-ra/ra-enclave/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ cmac = "0.3"
crypto-mac = { version = "0.8", features = ["std"] }
log = "0.4"
rcgen = "0.8"
ring = "0.16"
ring = "0.16.15"
rustls = "0.18"
serde_json = "1.0"
sgx-isa = { version = "0.3", features = ["sgxstd"] }
Expand All @@ -23,7 +23,3 @@ thiserror = "1.0"

ra-common = { path = "../ra-common" }
ra-sp-client = { path = "../ra-sp-client" }

# Add these lines in workpace Cargo.toml
# [patch.crates-io]
# ring = { git = "https://github.com/crypto-com/ring.git", rev = "4e1862fb0df9efaf2d2c1ec8cacb1e53104f3daa" }
2 changes: 1 addition & 1 deletion chain-tx-enclave-next/mls/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ readme = "../../README.md"
edition = "2018"

[dependencies]
ring = "0.16"
ring = "0.16.15"
thiserror = "1.0"
rustls = "0.18"
x509-parser = "0.8.0-beta4"
Expand Down
3 changes: 0 additions & 3 deletions chain-tx-enclave-next/tx-query-next/enclave-app/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,3 @@ chain-core = { path = "../../../chain-core", default-features = false, features
enclave-protocol = { path = "../../../enclave-protocol", features = ["edp"] }
enclave-utils = { path = "../../../chain-tx-enclave-next/enclave-utils", features = ["sgxstd"] }
ra-enclave = { path = "../../../chain-tx-enclave-next/enclave-ra/ra-enclave" }

# [patch.crates-io]
# ring = { git = "https://github.com/crypto-com/ring.git", rev = "4e1862fb0df9efaf2d2c1ec8cacb1e53104f3daa" }
22 changes: 17 additions & 5 deletions client-cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ use client_core::signer::WalletSignerManager;
use client_core::transaction_builder::DefaultWalletTransactionBuilder;
use client_core::types::BalanceChange;
use client_core::wallet::syncer::{
ObfuscationSyncerConfig, ProgressReport, SyncerOptions, WalletSyncer,
spawn_light_client_supervisor, Handle, ObfuscationSyncerConfig, ProgressReport, SyncerOptions,
WalletSyncer,
};
use client_core::wallet::{DefaultWalletClient, WalletClient};
use client_network::network_ops::{DefaultNetworkOpsClient, NetworkOpsClient};
Expand Down Expand Up @@ -385,10 +386,17 @@ impl Command {
block_height_ensure,
} => {
let enckey = ask_seckey(None)?;
let tendermint_client = WebsocketRpcClient::new(&tendermint_url())?;
let rpc_url = tendermint_url();
let tendermint_client = WebsocketRpcClient::new(&rpc_url)?;
let tx_obfuscation = get_tx_query(tendermint_client.clone())?;

let storage = SledStorage::new(storage_path())?;
let db_path = storage_path();
let storage = SledStorage::new(&db_path)?;
let handle = spawn_light_client_supervisor(
db_path.as_ref(),
&rpc_url,
tendermint_client.genesis()?.trusting_period(),
)?;
let config = ObfuscationSyncerConfig::new(
storage.clone(),
tendermint_client,
Expand All @@ -399,8 +407,12 @@ impl Command {
batch_size: *batch_size,
block_height_ensure: *block_height_ensure,
},
handle.clone(),
);
Self::resync(config, name.clone(), enckey, *force, storage)?;
handle
.terminate()
.expect("terminate light client supervisor in client-cli");
Ok(())
}
Command::MultiSig { multisig_command } => {
Expand Down Expand Up @@ -637,8 +649,8 @@ impl Command {
Ok(())
}

fn resync<S: Storage, C: Client, O: TransactionObfuscation>(
config: ObfuscationSyncerConfig<S, C, O>,
fn resync<S: Storage, C: Client, O: TransactionObfuscation, L: Handle + Send + Sync + Clone>(
config: ObfuscationSyncerConfig<S, C, O, L>,
name: String,
enckey: SecKey,
force: bool,
Expand Down
5 changes: 3 additions & 2 deletions client-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ secstr = { version = "0.4.0", features = ["serde"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
sled = { version = "0.33.0", optional = true }
tendermint = { git = "https://github.com/crypto-com/tendermint-rs.git", default-features = false, rev = "ceca4219d6ae4e4ce906a6579e865af15458fdd6" }
tendermint = "0.14"
tendermint-rpc = "0.14"
tokio = { version = "0.2", features = ["rt-threaded", "sync", "time", "tcp"], optional = true }
tokio-tungstenite = { version = "0.10", features = ["tls"], optional = true }
uuid = { version = "0.8.1", features = ["v4"] }
Expand All @@ -51,4 +52,4 @@ quickcheck = "0.9"
default = ["sled", "websocket-rpc"]
websocket-rpc = ["futures-util", "tokio", "tokio-tungstenite"]
mock-enclave = []
experimental = []
experimental = []
Loading

0 comments on commit 8ec7329

Please sign in to comment.