1
1
use std:: { rc:: Rc , sync:: Arc } ;
2
2
3
+ use anyhow:: Context ;
3
4
use ark_ff:: fields:: arithmetic:: InvalidBigInt ;
4
5
use consensus:: ConsensusState ;
5
6
use mina_curves:: pasta:: Fq ;
@@ -51,7 +52,7 @@ use super::{
51
52
} ,
52
53
step:: { step, InductiveRule , OptFlag , PreviousProofStatement , StepParams , StepProof } ,
53
54
to_field_elements:: ToFieldElements ,
54
- transaction:: { transaction_snark:: checked_hash, Check , ProofError , Prover } ,
55
+ transaction:: { transaction_snark:: checked_hash, Check , Prover } ,
55
56
witness:: Witness ,
56
57
wrap:: WrapProof ,
57
58
} ;
@@ -195,7 +196,7 @@ impl Check<Fp> for ProtocolState {
195
196
fn ledger_proof_opt (
196
197
proof : Option < & v2:: LedgerProofProdStableV2 > ,
197
198
next_state : & v2:: MinaStateProtocolStateValueStableV2 ,
198
- ) -> Result < ( Statement < SokDigest > , Arc < v2:: TransactionSnarkProofStableV2 > ) , InvalidBigInt > {
199
+ ) -> anyhow :: Result < ( Statement < SokDigest > , Arc < v2:: TransactionSnarkProofStableV2 > ) > {
199
200
match proof {
200
201
Some ( proof) => {
201
202
let statement: Statement < SokDigest > = ( & proof. 0 . statement ) . try_into ( ) ?;
@@ -216,7 +217,7 @@ fn ledger_proof_opt(
216
217
fn checked_hash_protocol_state (
217
218
state : & ProtocolState ,
218
219
w : & mut Witness < Fp > ,
219
- ) -> Result < ( Fp , Fp ) , InvalidBigInt > {
220
+ ) -> anyhow :: Result < ( Fp , Fp ) > {
220
221
let ProtocolState {
221
222
previous_state_hash,
222
223
body,
@@ -499,7 +500,7 @@ mod floating_point {
499
500
res
500
501
}
501
502
502
- pub fn constant ( value : & BigInteger256 , precision : usize ) -> Result < Self , InvalidBigInt > {
503
+ pub fn constant ( value : & BigInteger256 , precision : usize ) -> anyhow :: Result < Self > {
503
504
Ok ( Self {
504
505
value : ( * value) . try_into ( ) ?,
505
506
precision,
@@ -714,7 +715,7 @@ mod vrf {
714
715
message : Message ,
715
716
prover_state : & v2:: ConsensusStakeProofStableV2 ,
716
717
w : & mut Witness < Fp > ,
717
- ) -> Result < ( Fp , Box < crate :: Account > ) , InvalidBigInt > {
718
+ ) -> anyhow :: Result < ( Fp , Box < crate :: Account > ) > {
718
719
let private_key = prover_state. producer_private_key . to_field :: < Fq > ( ) ?;
719
720
let private_key = w. exists ( field_to_bits :: < Fq , 255 > ( private_key) ) ;
720
721
@@ -779,15 +780,12 @@ mod vrf {
779
780
seed : Fp ,
780
781
prover_state : & v2:: ConsensusStakeProofStableV2 ,
781
782
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
+ ) > {
791
789
let ( winner_addr, winner_addr_bits) = {
792
790
const LEDGER_DEPTH : usize = 35 ;
793
791
assert_eq ! ( constraint_constants( ) . ledger_depth, LEDGER_DEPTH as u64 ) ;
@@ -1283,7 +1281,7 @@ pub mod consensus {
1283
1281
supply_increase : CheckedSigned < Fp , CheckedAmount < Fp > > ,
1284
1282
prover_state : & v2:: ConsensusStakeProofStableV2 ,
1285
1283
w : & mut Witness < Fp > ,
1286
- ) -> Result < ( Boolean , CheckedConsensusState ) , InvalidBigInt > {
1284
+ ) -> anyhow :: Result < ( Boolean , CheckedConsensusState ) > {
1287
1285
let previous_blockchain_state_ledger_hash = prev_state
1288
1286
. body
1289
1287
. blockchain_state
@@ -1535,7 +1533,7 @@ fn genesis_state_hash_checked(
1535
1533
state_hash : Fp ,
1536
1534
state : & ProtocolState ,
1537
1535
w : & mut Witness < Fp > ,
1538
- ) -> Result < Fp , InvalidBigInt > {
1536
+ ) -> anyhow :: Result < Fp > {
1539
1537
let is_genesis = is_genesis_state_var ( & state. body . consensus_state , w) ;
1540
1538
1541
1539
Ok ( w. exists_no_check ( match is_genesis {
@@ -1608,7 +1606,7 @@ fn protocol_create_var(
1608
1606
fn block_main < ' a > (
1609
1607
params : BlockMainParams < ' a > ,
1610
1608
w : & mut Witness < Fp > ,
1611
- ) -> Result < ( Fp , [ PreviousProofStatement < ' a > ; 2 ] ) , InvalidBigInt > {
1609
+ ) -> anyhow :: Result < ( Fp , [ PreviousProofStatement < ' a > ; 2 ] ) > {
1612
1610
let BlockMainParams {
1613
1611
transition,
1614
1612
prev_state,
@@ -1835,7 +1833,7 @@ const BLOCK_N_PREVIOUS_PROOFS: usize = 2;
1835
1833
pub ( super ) fn generate_block_proof (
1836
1834
params : BlockParams ,
1837
1835
w : & mut Witness < Fp > ,
1838
- ) -> Result < WrapProof , ProofError > {
1836
+ ) -> anyhow :: Result < WrapProof > {
1839
1837
let BlockParams {
1840
1838
input :
1841
1839
v2:: ProverExtendBlockchainInputStableV2 {
@@ -1855,7 +1853,7 @@ pub(super) fn generate_block_proof(
1855
1853
} = params;
1856
1854
1857
1855
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" ) ?;
1859
1857
let prev_state_proof = & chain. proof ;
1860
1858
1861
1859
let ( new_state_hash, previous_proof_statements) = block_main (
@@ -1870,10 +1868,12 @@ pub(super) fn generate_block_proof(
1870
1868
pending_coinbase,
1871
1869
} ,
1872
1870
w,
1873
- ) ?;
1871
+ )
1872
+ . context ( "block_main" ) ?;
1874
1873
1875
1874
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" ) ?;
1877
1877
1878
1878
let rule = InductiveRule {
1879
1879
previous_proof_statements,
@@ -1918,7 +1918,8 @@ pub(super) fn generate_block_proof(
1918
1918
only_verify_constraints,
1919
1919
} ,
1920
1920
w,
1921
- ) ?;
1921
+ )
1922
+ . context ( "step" ) ?;
1922
1923
1923
1924
if let Some ( expected) = expected_step_proof {
1924
1925
let proof_json = serde_json:: to_vec ( & proof. proof ) . unwrap ( ) ;
@@ -1943,4 +1944,5 @@ pub(super) fn generate_block_proof(
1943
1944
} ,
1944
1945
& mut w,
1945
1946
)
1947
+ . context ( "wrap" )
1946
1948
}
0 commit comments