Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszjasiuk committed Mar 20, 2023
1 parent 9ca9277 commit 8c0bb97
Show file tree
Hide file tree
Showing 10 changed files with 190 additions and 73 deletions.
84 changes: 67 additions & 17 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions apps/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ tracing-subscriber = {version = "0.3.7", features = ["env-filter"]}
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_proofs = { path = "/home/mj/Projects/heliax/masp/masp_proofs", default-features = false, features = ["local-prover", "bundled-prover", "download-params"] }
masp_primitives = { path = "/home/mj/Projects/heliax/masp/masp_primitives" }
bimap = {version = "0.6.2", features = ["serde"]}
rust_decimal = "1.26.1"
rust_decimal_macros = "1.26.1"
Expand Down
15 changes: 12 additions & 3 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 masp_proofs::prover::LocalTxProver;
use namada::ledger::governance::storage as gov_storage;
Expand Down Expand Up @@ -321,6 +322,7 @@ impl Default for CLIShieldedUtils {
}
}

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

Expand All @@ -339,7 +341,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 @@ -352,7 +354,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 Expand Up @@ -684,7 +689,11 @@ pub async fn submit_vote_proposal<
"Proposal start epoch for proposal id {} is not definied.",
proposal_id
);
if !args.tx.force { safe_exit(1) } else { Ok(()) }
if !args.tx.force {
safe_exit(1)
} else {
Ok(())
}
}
}
}
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.12.0"

[features]
default = []
default = ["multicore"]
ferveo-tpke = [
"ferveo",
"tpke",
Expand Down Expand Up @@ -44,6 +44,10 @@ ibc-mocks-abcipp = [
"ibc-abcipp/mocks",
]

multicore = [
"bellman/multicore"
]

# for integration tests and test utilies
testing = [
"rand",
Expand All @@ -59,7 +63,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 = "04ad1eeb28901b57a7599bbe433b3822965dabe8", 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 @@ -77,7 +81,8 @@ ics23 = "0.7.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 = "bee40fc465f6afbd10558d12fe96eb1742eee45c" }
masp_primitives = { path = "/home/mj/Projects/heliax/masp/masp_primitives" }
proptest = {git = "https://github.com/heliaxdev/proptest", branch = "tomas/sm", optional = true}
prost = "0.9.0"
prost-types = "0.9.0"
Expand Down
11 changes: 7 additions & 4 deletions shared/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ version = "0.12.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[features]
default = ["abciplus", "namada-sdk"]
default = ["abciplus", "namada-sdk", "multicore"]
multicore = ["masp_proofs/multicore", "bellman/multicore", "namada_core/multicore"]
# NOTE "dev" features that shouldn't be used in live networks are enabled by default for now
dev = []
ferveo-tpke = [
Expand Down Expand Up @@ -93,7 +94,7 @@ 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 @@ -137,8 +138,10 @@ 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 = "bee40fc465f6afbd10558d12fe96eb1742eee45c"}
masp_primitives = { path = "/home/mj/Projects/heliax/masp/masp_primitives" }
# masp_proofs = { git = "https://github.com/anoma/masp", rev = "bee40fc465f6afbd10558d12fe96eb1742eee45c", default-features = false, features=["local-prover"]}
masp_proofs = { path = "/home/mj/Projects/heliax/masp/masp_proofs", 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 = { path = "/home/mj/Projects/heliax/masp/masp_primitives" }
namada_core = {path = "../core", default-features = false}
namada_macros = {path = "../macros"}
namada_proof_of_stake = {path = "../proof_of_stake", default-features = false}
Expand Down
Loading

0 comments on commit 8c0bb97

Please sign in to comment.