Skip to content

Commit

Permalink
Merge branch 'mateusz/shared-sdk-integration-wip' (#1238)
Browse files Browse the repository at this point in the history
* mateusz/shared-sdk-integration-wip:
  feat: point to the masp_proofs with correct multicore feature flag
  feat: disable multicore ff by default, make ShieldedUtils trait async
  • Loading branch information
cwgoes committed May 19, 2023
2 parents a9a3e32 + e72eb4c commit 6881260
Show file tree
Hide file tree
Showing 9 changed files with 108 additions and 96 deletions.
146 changes: 73 additions & 73 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions apps/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ abciplus = [
]

[dependencies]
namada = {path = "../shared", default-features = false, features = ["wasm-runtime", "ferveo-tpke", "masp-tx-gen"]}
namada = {path = "../shared", default-features = false, features = ["wasm-runtime", "ferveo-tpke", "masp-tx-gen", "multicore"]}
ark-serialize = "0.3.0"
ark-std = "0.3.0"
# branch = "bat/arse-merkle-tree"
Expand Down Expand Up @@ -148,8 +148,8 @@ tracing-subscriber = {version = "0.3.7", features = ["env-filter", "json"]}
websocket = "0.26.2"
winapi = "0.3.9"
#libmasp = { git = "https://github.com/anoma/masp", branch = "murisi/masp-incentive" }
masp_primitives = { git = "https://github.com/anoma/masp", rev = "bee40fc465f6afbd10558d12fe96eb1742eee45c", features = ["transparent-inputs"] }
masp_proofs = { git = "https://github.com/anoma/masp", rev = "bee40fc465f6afbd10558d12fe96eb1742eee45c", features = ["bundled-prover", "download-params"] }
masp_primitives = { git = "https://github.com/anoma/masp", rev = "4274fc0bf300bcdae4f186fba134bab8af83ae93", features = ["transparent-inputs"] }
masp_proofs = { git = "https://github.com/anoma/masp", rev = "4274fc0bf300bcdae4f186fba134bab8af83ae93", features = ["bundled-prover", "download-params"] }
bimap = {version = "0.6.2", features = ["serde"]}
rust_decimal = "=1.26.1"
rust_decimal_macros = "=1.26.1"
Expand Down
9 changes: 7 additions & 2 deletions apps/src/lib/client/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use std::path::PathBuf;

use async_std::io;
use async_std::io::prelude::WriteExt;
use async_trait::async_trait;
use borsh::{BorshDeserialize, BorshSerialize};
use data_encoding::HEXLOWER_PERMISSIVE;
use masp_proofs::prover::LocalTxProver;
Expand Down Expand Up @@ -336,6 +337,7 @@ impl Default for CLIShieldedUtils {
}
}

#[async_trait(?Send)]
impl masp::ShieldedUtils for CLIShieldedUtils {
type C = tendermint_rpc::HttpClient;

Expand All @@ -354,7 +356,7 @@ impl masp::ShieldedUtils for CLIShieldedUtils {

/// Try to load the last saved shielded context from the given context
/// directory. If this fails, then leave the current context unchanged.
fn load(self) -> std::io::Result<masp::ShieldedContext<Self>> {
async fn load(self) -> std::io::Result<masp::ShieldedContext<Self>> {
// Try to load shielded context from file
let mut ctx_file = File::open(self.context_dir.join(FILE_NAME))?;
let mut bytes = Vec::new();
Expand All @@ -367,7 +369,10 @@ impl masp::ShieldedUtils for CLIShieldedUtils {
}

/// Save this shielded context into its associated context directory
fn save(&self, ctx: &masp::ShieldedContext<Self>) -> std::io::Result<()> {
async fn save(
&self,
ctx: &masp::ShieldedContext<Self>,
) -> std::io::Result<()> {
// TODO: use mktemp crate?
let tmp_path = self.context_dir.join(TMP_FILE_NAME);
{
Expand Down
11 changes: 8 additions & 3 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ resolver = "2"
version = "0.16.0"

[features]
default = []
default = ["multicore"]
mainnet = []
ferveo-tpke = [
"ferveo",
Expand Down Expand Up @@ -42,11 +42,16 @@ ibc-mocks = [
"ibc/mocks",
"ibc/std",
]

ibc-mocks-abcipp = [
"ibc-abcipp/mocks",
"ibc-abcipp/std",
]

multicore = [
"bellman/multicore"
]

# for integration tests and test utilies
testing = [
"rand",
Expand All @@ -63,7 +68,7 @@ ark-serialize = {version = "0.3"}
# branch = "bat/arse-merkle-tree"
arse-merkle-tree = {package = "sparse-merkle-tree", git = "https://github.com/heliaxdev/sparse-merkle-tree", rev = "e086b235ed6e68929bf73f617dd61cd17b000a56", default-features = false, features = ["std", "borsh"]}
bech32 = "0.8.0"
bellman = "0.11.2"
bellman = { version = "0.11.2", default-features = false, features = ["groth16"] }
borsh = "0.9.0"
chrono = {version = "0.4.22", default-features = false, features = ["clock", "std"]}
data-encoding = "2.3.2"
Expand All @@ -81,7 +86,7 @@ ics23 = "0.9.0"
index-set = {git = "https://github.com/heliaxdev/index-set", tag = "v0.7.1", features = ["serialize-borsh", "serialize-serde"]}
itertools = "0.10.0"
libsecp256k1 = {git = "https://github.com/heliaxdev/libsecp256k1", rev = "bbb3bd44a49db361f21d9db80f9a087c194c0ae9", default-features = false, features = ["std", "static-context"]}
masp_primitives = { git = "https://github.com/anoma/masp", rev = "bee40fc465f6afbd10558d12fe96eb1742eee45c" }
masp_primitives = { git = "https://github.com/anoma/masp", rev = "4274fc0bf300bcdae4f186fba134bab8af83ae93" }
proptest = {git = "https://github.com/heliaxdev/proptest", rev = "8f1b4abe7ebd35c0781bf9a00a4ee59833ffa2a1", optional = true}
prost = "0.11.6"
prost-types = "0.11.6"
Expand Down
8 changes: 5 additions & 3 deletions shared/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,14 @@ namada-sdk = [
"masp_primitives/transparent-inputs",
]

multicore = ["bellman/multicore", "namada_core/multicore", "masp_proofs/multicore"]

[dependencies]
async-std = "1.11.0"
namada_core = {path = "../core", default-features = false, features = ["secp256k1-sign-verify"]}
namada_proof_of_stake = {path = "../proof_of_stake", default-features = false}
async-trait = {version = "0.1.51", optional = true}
bellman = "0.11.2"
bellman = { version = "0.11.2", default-features = false, features = ["groth16"] }
bls12_381 = "0.6.1"
borsh = "0.9.0"
circular-queue = "0.2.6"
Expand Down Expand Up @@ -141,8 +143,8 @@ wasmer-engine-universal = {version = "=2.2.0", optional = true}
wasmer-vm = {version = "2.2.0", optional = true}
wasmparser = "0.83.0"
#libmasp = { git = "https://github.com/anoma/masp", branch = "murisi/masp-incentive" }
masp_primitives = { git = "https://github.com/anoma/masp", rev = "bee40fc465f6afbd10558d12fe96eb1742eee45c" }
masp_proofs = { git = "https://github.com/anoma/masp", rev = "bee40fc465f6afbd10558d12fe96eb1742eee45c" }
masp_primitives = { git = "https://github.com/anoma/masp", rev = "4274fc0bf300bcdae4f186fba134bab8af83ae93" }
masp_proofs = { git = "https://github.com/anoma/masp", rev = "4274fc0bf300bcdae4f186fba134bab8af83ae93", default-features = false, features = ["local-prover"] }
rand = {version = "0.8", default-features = false, optional = true}
rand_core = {version = "0.6", default-features = false, optional = true}
zeroize = "1.5.5"
Expand Down
14 changes: 7 additions & 7 deletions shared/src/ledger/masp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ pub fn get_params_dir() -> PathBuf {

/// Abstracts platform specific details away from the logic of shielded pool
/// operations.
#[async_trait]
#[async_trait(?Send)]
pub trait ShieldedUtils:
Sized + BorshDeserialize + BorshSerialize + Default + Clone
{
Expand All @@ -263,10 +263,10 @@ pub trait ShieldedUtils:
fn local_tx_prover(&self) -> LocalTxProver;

/// Load up the currently saved ShieldedContext
fn load(self) -> std::io::Result<ShieldedContext<Self>>;
async fn load(self) -> std::io::Result<ShieldedContext<Self>>;

/// Sace the given ShieldedContext for future loads
fn save(&self, ctx: &ShieldedContext<Self>) -> std::io::Result<()>;
async fn save(&self, ctx: &ShieldedContext<Self>) -> std::io::Result<()>;
}

/// Make a ViewingKey that can view notes encrypted by given ExtendedSpendingKey
Expand Down Expand Up @@ -394,15 +394,15 @@ impl<U: ShieldedUtils + Default> Default for ShieldedContext<U> {
impl<U: ShieldedUtils> ShieldedContext<U> {
/// Try to load the last saved shielded context from the given context
/// directory. If this fails, then leave the current context unchanged.
pub fn load(&mut self) -> std::io::Result<()> {
let new_ctx = self.utils.clone().load()?;
pub async fn load(&mut self) -> std::io::Result<()> {
let new_ctx = self.utils.clone().load().await?;
*self = new_ctx;
Ok(())
}

/// Save this shielded context into its associated context directory
pub fn save(&self) -> std::io::Result<()> {
self.utils.save(self)
pub async fn save(&self) -> std::io::Result<()> {
self.utils.save(self).await
}

/// Merge data from the given shielded context into the current shielded
Expand Down
2 changes: 1 addition & 1 deletion tx_prelude/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ abciplus = [
]

[dependencies]
masp_primitives = { git = "https://github.com/anoma/masp", rev = "bee40fc465f6afbd10558d12fe96eb1742eee45c" }
masp_primitives = { git = "https://github.com/anoma/masp", rev = "4274fc0bf300bcdae4f186fba134bab8af83ae93" }
namada_core = {path = "../core", default-features = false}
namada_macros = {path = "../macros"}
namada_proof_of_stake = {path = "../proof_of_stake", default-features = false}
Expand Down
4 changes: 2 additions & 2 deletions vm_env/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ abciplus = [
namada_core = {path = "../core", default-features = false}
borsh = "0.9.0"
#libmasp = { git = "https://github.com/anoma/masp", branch = "murisi/masp-incentive" }
masp_primitives = { git = "https://github.com/anoma/masp", rev = "bee40fc465f6afbd10558d12fe96eb1742eee45c" }
masp_proofs = { git = "https://github.com/anoma/masp", rev = "bee40fc465f6afbd10558d12fe96eb1742eee45c" }
masp_primitives = { git = "https://github.com/anoma/masp", rev = "4274fc0bf300bcdae4f186fba134bab8af83ae93" }
masp_proofs = { git = "https://github.com/anoma/masp", rev = "4274fc0bf300bcdae4f186fba134bab8af83ae93" }
hex = "0.4.3"
4 changes: 2 additions & 2 deletions wasm/wasm_source/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ once_cell = {version = "1.8.0", optional = true}
rust_decimal = {version = "=1.26.1", optional = true}
wee_alloc = "0.4.5"
getrandom = { version = "0.2", features = ["custom"] }
masp_proofs = { git = "https://github.com/anoma/masp", rev = "bee40fc465f6afbd10558d12fe96eb1742eee45c", optional = true }
masp_primitives = { git = "https://github.com/anoma/masp", rev = "bee40fc465f6afbd10558d12fe96eb1742eee45c", optional = true }
masp_proofs = { git = "https://github.com/anoma/masp", rev = "4274fc0bf300bcdae4f186fba134bab8af83ae93", optional = true }
masp_primitives = { git = "https://github.com/anoma/masp", rev = "4274fc0bf300bcdae4f186fba134bab8af83ae93", optional = true }
ripemd = "0.1.3"

[dev-dependencies]
Expand Down

0 comments on commit 6881260

Please sign in to comment.