11use std:: { rc:: Rc , sync:: Arc } ;
22
3+ use anyhow:: Context ;
34use ark_ff:: fields:: arithmetic:: InvalidBigInt ;
45use consensus:: ConsensusState ;
56use mina_curves:: pasta:: Fq ;
@@ -51,7 +52,7 @@ use super::{
5152 } ,
5253 step:: { step, InductiveRule , OptFlag , PreviousProofStatement , StepParams , StepProof } ,
5354 to_field_elements:: ToFieldElements ,
54- transaction:: { transaction_snark:: checked_hash, Check , ProofError , Prover } ,
55+ transaction:: { transaction_snark:: checked_hash, Check , Prover } ,
5556 witness:: Witness ,
5657 wrap:: WrapProof ,
5758} ;
@@ -195,7 +196,7 @@ impl Check<Fp> for ProtocolState {
195196fn ledger_proof_opt (
196197 proof : Option < & v2:: LedgerProofProdStableV2 > ,
197198 next_state : & v2:: MinaStateProtocolStateValueStableV2 ,
198- ) -> Result < ( Statement < SokDigest > , Arc < v2:: TransactionSnarkProofStableV2 > ) , InvalidBigInt > {
199+ ) -> anyhow :: Result < ( Statement < SokDigest > , Arc < v2:: TransactionSnarkProofStableV2 > ) > {
199200 match proof {
200201 Some ( proof) => {
201202 let statement: Statement < SokDigest > = ( & proof. 0 . statement ) . try_into ( ) ?;
@@ -216,7 +217,7 @@ fn ledger_proof_opt(
216217fn checked_hash_protocol_state (
217218 state : & ProtocolState ,
218219 w : & mut Witness < Fp > ,
219- ) -> Result < ( Fp , Fp ) , InvalidBigInt > {
220+ ) -> anyhow :: Result < ( Fp , Fp ) > {
220221 let ProtocolState {
221222 previous_state_hash,
222223 body,
@@ -499,7 +500,7 @@ mod floating_point {
499500 res
500501 }
501502
502- pub fn constant ( value : & BigInteger256 , precision : usize ) -> Result < Self , InvalidBigInt > {
503+ pub fn constant ( value : & BigInteger256 , precision : usize ) -> anyhow :: Result < Self > {
503504 Ok ( Self {
504505 value : ( * value) . try_into ( ) ?,
505506 precision,
@@ -714,7 +715,7 @@ mod vrf {
714715 message : Message ,
715716 prover_state : & v2:: ConsensusStakeProofStableV2 ,
716717 w : & mut Witness < Fp > ,
717- ) -> Result < ( Fp , Box < crate :: Account > ) , InvalidBigInt > {
718+ ) -> anyhow :: Result < ( Fp , Box < crate :: Account > ) > {
718719 let private_key = prover_state. producer_private_key . to_field :: < Fq > ( ) ?;
719720 let private_key = w. exists ( field_to_bits :: < Fq , 255 > ( private_key) ) ;
720721
@@ -779,15 +780,12 @@ mod vrf {
779780 seed : Fp ,
780781 prover_state : & v2:: ConsensusStakeProofStableV2 ,
781782 w : & mut Witness < Fp > ,
782- ) -> Result <
783- (
784- Boolean ,
785- Fp ,
786- Box < [ bool ; VRF_OUTPUT_NBITS ] > ,
787- Box < crate :: Account > ,
788- ) ,
789- InvalidBigInt ,
790- > {
783+ ) -> anyhow:: Result < (
784+ Boolean ,
785+ Fp ,
786+ Box < [ bool ; VRF_OUTPUT_NBITS ] > ,
787+ Box < crate :: Account > ,
788+ ) > {
791789 let ( winner_addr, winner_addr_bits) = {
792790 const LEDGER_DEPTH : usize = 35 ;
793791 assert_eq ! ( constraint_constants( ) . ledger_depth, LEDGER_DEPTH as u64 ) ;
@@ -1283,7 +1281,7 @@ pub mod consensus {
12831281 supply_increase : CheckedSigned < Fp , CheckedAmount < Fp > > ,
12841282 prover_state : & v2:: ConsensusStakeProofStableV2 ,
12851283 w : & mut Witness < Fp > ,
1286- ) -> Result < ( Boolean , CheckedConsensusState ) , InvalidBigInt > {
1284+ ) -> anyhow :: Result < ( Boolean , CheckedConsensusState ) > {
12871285 let previous_blockchain_state_ledger_hash = prev_state
12881286 . body
12891287 . blockchain_state
@@ -1535,7 +1533,7 @@ fn genesis_state_hash_checked(
15351533 state_hash : Fp ,
15361534 state : & ProtocolState ,
15371535 w : & mut Witness < Fp > ,
1538- ) -> Result < Fp , InvalidBigInt > {
1536+ ) -> anyhow :: Result < Fp > {
15391537 let is_genesis = is_genesis_state_var ( & state. body . consensus_state , w) ;
15401538
15411539 Ok ( w. exists_no_check ( match is_genesis {
@@ -1608,7 +1606,7 @@ fn protocol_create_var(
16081606fn block_main < ' a > (
16091607 params : BlockMainParams < ' a > ,
16101608 w : & mut Witness < Fp > ,
1611- ) -> Result < ( Fp , [ PreviousProofStatement < ' a > ; 2 ] ) , InvalidBigInt > {
1609+ ) -> anyhow :: Result < ( Fp , [ PreviousProofStatement < ' a > ; 2 ] ) > {
16121610 let BlockMainParams {
16131611 transition,
16141612 prev_state,
@@ -1835,7 +1833,7 @@ const BLOCK_N_PREVIOUS_PROOFS: usize = 2;
18351833pub ( super ) fn generate_block_proof (
18361834 params : BlockParams ,
18371835 w : & mut Witness < Fp > ,
1838- ) -> Result < WrapProof , ProofError > {
1836+ ) -> anyhow :: Result < WrapProof > {
18391837 let BlockParams {
18401838 input :
18411839 v2:: ProverExtendBlockchainInputStableV2 {
@@ -1855,7 +1853,7 @@ pub(super) fn generate_block_proof(
18551853 } = params;
18561854
18571855 let ( txn_snark_statement, txn_snark_proof) =
1858- ledger_proof_opt ( ledger_proof. as_deref ( ) , next_state) ?;
1856+ ledger_proof_opt ( ledger_proof. as_deref ( ) , next_state) . context ( "ledger_proof_opt" ) ?;
18591857 let prev_state_proof = & chain. proof ;
18601858
18611859 let ( new_state_hash, previous_proof_statements) = block_main (
@@ -1870,10 +1868,12 @@ pub(super) fn generate_block_proof(
18701868 pending_coinbase,
18711869 } ,
18721870 w,
1873- ) ?;
1871+ )
1872+ . context ( "block_main" ) ?;
18741873
18751874 let prev_challenge_polynomial_commitments =
1876- extract_recursion_challenges ( & [ prev_state_proof, & txn_snark_proof] ) ?;
1875+ extract_recursion_challenges ( & [ prev_state_proof, & txn_snark_proof] )
1876+ . context ( "extract_recursion_challenges" ) ?;
18771877
18781878 let rule = InductiveRule {
18791879 previous_proof_statements,
@@ -1918,7 +1918,8 @@ pub(super) fn generate_block_proof(
19181918 only_verify_constraints,
19191919 } ,
19201920 w,
1921- ) ?;
1921+ )
1922+ . context ( "step" ) ?;
19221923
19231924 if let Some ( expected) = expected_step_proof {
19241925 let proof_json = serde_json:: to_vec ( & proof. proof ) . unwrap ( ) ;
@@ -1943,4 +1944,5 @@ pub(super) fn generate_block_proof(
19431944 } ,
19441945 & mut w,
19451946 )
1947+ . context ( "wrap" )
19461948}
0 commit comments