Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wallet-core: Add functionality to create transaction #2135

Merged
merged 15 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions contracts/stake/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ rusk-profile = { version = "0.6", path = "../../rusk-profile" }
once_cell = { version = "1.9" }
rusk-abi = { version = "0.13.0-rc", path = "../../rusk-abi", default-features = false, features = ["host"] }
execution-core = { version = "0.1.0", path = "../../execution-core", features = ["zk"] }
rusk-prover = { version = "0.3", path = "../../rusk-prover/" }
rkyv = { version = "0.7", default-features = false, features = ["size_32"] }
hex = "0.4"
rand = "0.8"
Expand Down
1 change: 0 additions & 1 deletion contracts/stake/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@

pub mod assert;
pub mod init;
pub mod prove;
pub mod utils;
127 changes: 0 additions & 127 deletions contracts/stake/tests/common/prove.rs

This file was deleted.

4 changes: 3 additions & 1 deletion contracts/stake/tests/common/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use execution_core::{
BlsScalar, ContractError,
};
use rusk_abi::{CallReceipt, PiecrustError, Session};
use rusk_prover::LocalProver;

const POINT_LIMIT: u64 = 0x100000000;

Expand Down Expand Up @@ -178,7 +179,7 @@ pub fn create_transaction<const I: usize>(
inputs.push((note.clone(), opening));
}

PhoenixTransaction::new::<StdRng, crate::common::prove::CachedProver>(
PhoenixTransaction::new::<StdRng, LocalProver>(
rng,
sender_sk,
change_pk,
Expand All @@ -192,5 +193,6 @@ pub fn create_transaction<const I: usize>(
gas_price,
exec.map(Into::into),
)
.expect("creating the creation shouldn't fail")
.into()
}
2 changes: 1 addition & 1 deletion contracts/transfer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ rusk-abi = { version = "0.13.0-rc", path = "../../rusk-abi" }
rusk-profile = { version = "0.6", path = "../../rusk-profile" }
once_cell = { version = "1.9" }
rusk-abi = { version = "0.13.0-rc", path = "../../rusk-abi", default-features = false, features = ["host"] }
execution-core = { version = "0.1.0", path = "../../execution-core", features = ["zk"] }
rusk-prover = { version = "0.3", path = "../../rusk-prover/" }
rkyv = { version = "0.7", default-features = false, features = ["size_32"] }
bytecheck = { version = "0.6", default-features = false }
hex = "0.4"
Expand Down
8 changes: 4 additions & 4 deletions contracts/transfer/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {

// Set the ID_[circuit_name] variables
let circuits = [
rusk_profile::Circuit::from_name("ExecuteCircuitOneTwo")?,
rusk_profile::Circuit::from_name("ExecuteCircuitTwoTwo")?,
rusk_profile::Circuit::from_name("ExecuteCircuitThreeTwo")?,
rusk_profile::Circuit::from_name("ExecuteCircuitFourTwo")?,
rusk_profile::Circuit::from_name("TxCircuitOneTwo")?,
rusk_profile::Circuit::from_name("TxCircuitTwoTwo")?,
rusk_profile::Circuit::from_name("TxCircuitThreeTwo")?,
rusk_profile::Circuit::from_name("TxCircuitFourTwo")?,
];
for circuit in circuits {
set_id_env_var(&circuit);
Expand Down
12 changes: 7 additions & 5 deletions contracts/transfer/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,19 @@
// Copyright (c) DUSK NETWORK. All rights reserved.

use core::fmt;
use execution_core::transfer::phoenix::Error as PhoenixError;
use execution_core::Error as ExecutionError;

#[derive(Debug, Clone)]
pub enum Error {
Phoenix(PhoenixError),
/// Wrapper of execution-core error type.
Execution(ExecutionError),
/// A contract balance is not sufficient for the requested withdrawal
NotEnoughBalance,
}

impl From<PhoenixError> for Error {
fn from(e: PhoenixError) -> Self {
Self::Phoenix(e)
impl From<ExecutionError> for Error {
fn from(e: ExecutionError) -> Self {
Self::Execution(e)
}
}

Expand Down
4 changes: 2 additions & 2 deletions contracts/transfer/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use crate::error::Error;
use crate::tree::Tree;
use crate::verifier_data::*;
use crate::verifier_data::tx_circuit_verifier;

use alloc::collections::btree_map::Entry;
use alloc::collections::{BTreeMap, BTreeSet};
Expand Down Expand Up @@ -681,7 +681,7 @@ impl TransferState {
fn verify_tx_proof(tx: &PhoenixTransaction) -> bool {
// fetch the verifier data
let num_inputs = tx.nullifiers().len();
let vd = verifier_data_execute(num_inputs)
let vd = tx_circuit_verifier(num_inputs)
.expect("No circuit available for given number of inputs!")
.to_vec();

Expand Down
26 changes: 13 additions & 13 deletions contracts/transfer/src/verifier_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,38 @@
// Copyright (c) DUSK NETWORK. All rights reserved.

// Note: all ID environment variables are set in the contracts build script
const VD_EXEC_1_2: &[u8] = include_bytes!(concat!(
const TX_CIRCUIT_1_2_VERIFIER: &[u8] = include_bytes!(concat!(
env!("RUSK_BUILT_KEYS_PATH"),
"/",
env!("ID_EXECUTECIRCUITONETWO"),
env!("ID_TXCIRCUITONETWO"),
".vd"
));
const VD_EXEC_2_2: &[u8] = include_bytes!(concat!(
const TX_CIRCUIT_2_2_VERIFIER: &[u8] = include_bytes!(concat!(
env!("RUSK_BUILT_KEYS_PATH"),
"/",
env!("ID_EXECUTECIRCUITTWOTWO"),
env!("ID_TXCIRCUITTWOTWO"),
".vd"
));
const VD_EXEC_3_2: &[u8] = include_bytes!(concat!(
const TX_CIRCUIT_3_2_VERIFIER: &[u8] = include_bytes!(concat!(
env!("RUSK_BUILT_KEYS_PATH"),
"/",
env!("ID_EXECUTECIRCUITTHREETWO"),
env!("ID_TXCIRCUITTHREETWO"),
".vd"
));
const VD_EXEC_4_2: &[u8] = include_bytes!(concat!(
const TX_CIRCUIT_4_2_VERIFIER: &[u8] = include_bytes!(concat!(
env!("RUSK_BUILT_KEYS_PATH"),
"/",
env!("ID_EXECUTECIRCUITFOURTWO"),
env!("ID_TXCIRCUITFOURTWO"),
".vd"
));

/// Verifier data for the phoenix-circuits.
pub const fn verifier_data_execute(inputs: usize) -> Option<&'static [u8]> {
pub const fn tx_circuit_verifier(inputs: usize) -> Option<&'static [u8]> {
let vd = match inputs {
1 => VD_EXEC_1_2,
2 => VD_EXEC_2_2,
3 => VD_EXEC_3_2,
4 => VD_EXEC_4_2,
1 => TX_CIRCUIT_1_2_VERIFIER,
2 => TX_CIRCUIT_2_2_VERIFIER,
3 => TX_CIRCUIT_3_2_VERIFIER,
4 => TX_CIRCUIT_4_2_VERIFIER,
_ => return None,
};

Expand Down
1 change: 0 additions & 1 deletion contracts/transfer/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@
//
// Copyright (c) DUSK NETWORK. All rights reserved.

pub mod prove;
pub mod utils;
Loading
Loading