From 4ae46a6eedff7d684f533724b4909da94963d3a8 Mon Sep 17 00:00:00 2001 From: moana Date: Wed, 14 Aug 2024 17:48:39 +0200 Subject: [PATCH] stake-contract: Adapt to changed `Prove` trait --- contracts/stake/tests/common/prove.rs | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/contracts/stake/tests/common/prove.rs b/contracts/stake/tests/common/prove.rs index 266bb683fd..c9f830359f 100644 --- a/contracts/stake/tests/common/prove.rs +++ b/contracts/stake/tests/common/prove.rs @@ -6,7 +6,7 @@ use dusk_bytes::Serializable; use execution_core::{ - plonk::Prover as PlonkProver, + plonk::{Error as PlonkError, Prover as PlonkProver}, transfer::phoenix::{Prove, TxCircuit, TxCircuitVec, NOTES_TREE_DEPTH}, }; use once_cell::sync::Lazy; @@ -41,29 +41,24 @@ fn fetch_prover(circuit_name: &str) -> PlonkProver { pub struct CachedProver(); impl Prove for CachedProver { - fn prove(circuit: TxCircuitVec) -> Vec { + type Error = PlonkError; + + fn prove(circuit: TxCircuitVec) -> Result, Self::Error> { let rng = &mut StdRng::seed_from_u64(0xbeef); // fetch the prover from the cache and crate the circuit let (proof, _pi) = match circuit.input_notes_info.len() { - 1 => PHOENIX_TX_1_2_PROVER - .prove(rng, &tx_circuit_1_2(circuit)) - .expect("the circuit should be correct"), - 2 => PHOENIX_TX_2_2_PROVER - .prove(rng, &tx_circuit_2_2(circuit)) - .expect("the circuit should be correct"), - 3 => PHOENIX_TX_3_2_PROVER - .prove(rng, &tx_circuit_3_2(circuit)) - .expect("the circuit should be correct"), - 4 => PHOENIX_TX_4_2_PROVER - .prove(rng, &tx_circuit_4_2(circuit)) - .expect("the circuit should be correct"), + 1 => PHOENIX_TX_1_2_PROVER.prove(rng, &tx_circuit_1_2(circuit))?, + 2 => PHOENIX_TX_2_2_PROVER.prove(rng, &tx_circuit_2_2(circuit))?, + 3 => PHOENIX_TX_3_2_PROVER.prove(rng, &tx_circuit_3_2(circuit))?, + 4 => PHOENIX_TX_4_2_PROVER.prove(rng, &tx_circuit_4_2(circuit))?, _ => panic!( "The `TxCircuit` is only implemented for 1, 2, 3 or 4 input-notes." ), }; - proof.to_bytes().to_vec() + + Ok(proof.to_bytes().to_vec()) } }