From 9b5dd0f40eb44f39b31eb9d2b69b9d27ab7aef74 Mon Sep 17 00:00:00 2001 From: sword_smith Date: Thu, 21 Nov 2024 17:22:45 +0100 Subject: [PATCH] SingleProof: Assign error IDs to some asserts --- src/assertion_error_ids.md | 3 ++- .../blockchain/transaction/validity/single_proof.rs | 9 ++++++--- src/models/proof_abstractions/tasm/prover_job.rs | 1 + 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/assertion_error_ids.md b/src/assertion_error_ids.md index a04f26b56..2db829772 100644 --- a/src/assertion_error_ids.md +++ b/src/assertion_error_ids.md @@ -18,4 +18,5 @@ often. | 0..10 | [`RemovalRecordsIntegrity`](models/blockchain/transaction/validity/removal_records_integrity.rs) | | 10..20 | [`AuditVmEndState`](models/proof_abstractions/tasm/audit_vm_end_state.rs) | | 20..30 | [`merge::AuthenticateCoinbaseFields`](models/blockchain/transaction/validity/tasm/merge/authenticate_coinbase_fields.rs) | -| 30..40 | [`NativeCurrency`](src/models/blockchain/type_scripts/native_currency.rs) | +| 30..40 | [`NativeCurrency`](models/blockchain/type_scripts/native_currency.rs) | +| 40..100 | [`SingleProof`](models/blockchain/transaction/validity/single_proof.rs) | diff --git a/src/models/blockchain/transaction/validity/single_proof.rs b/src/models/blockchain/transaction/validity/single_proof.rs index 36caf36d1..f3c7850b3 100644 --- a/src/models/blockchain/transaction/validity/single_proof.rs +++ b/src/models/blockchain/transaction/validity/single_proof.rs @@ -35,6 +35,9 @@ use crate::models::blockchain::transaction::validity::merge::Merge; use crate::models::blockchain::transaction::validity::proof_collection::ProofCollection; use crate::models::blockchain::transaction::validity::update::Update; +const INVALID_WITNESS_DISCRIMINANT_ERROR: i128 = 1_000_040; +const NO_BRANCH_TAKEN_ERROR: i128 = 1_000_041; + #[derive(Debug, Clone, BFieldCodec, TasmObject)] pub(crate) struct WitnessOfUpdate { proof: Proof, @@ -775,7 +778,7 @@ impl ConsensusProgram for SingleProof { add // _ discr (discr == proof_coll || discr == update || discr == merge) - assert + assert error_id {INVALID_WITNESS_DISCRIMINANT_ERROR} // _ discr ); @@ -812,7 +815,7 @@ impl ConsensusProgram for SingleProof { // a discriminant of -1 indicates that some branch was executed push -1 eq - assert + assert error_id {NO_BRANCH_TAKEN_ERROR} pop 1 pop 5 pop 5 // _ @@ -879,7 +882,7 @@ mod test { let_assert!(Err(ConsensusError::TritonVMPanic(_, instruction_err)) = consensus_err); let_assert!(InstructionError::AssertionFailed(assertion_err) = instruction_err); let_assert!(Some(err_id) = assertion_err.id); - assert_eq!(42, err_id); + assert_eq!(INVALID_WITNESS_DISCRIMINANT_ERROR, err_id); } } diff --git a/src/models/proof_abstractions/tasm/prover_job.rs b/src/models/proof_abstractions/tasm/prover_job.rs index 9a796ba76..18d309c20 100644 --- a/src/models/proof_abstractions/tasm/prover_job.rs +++ b/src/models/proof_abstractions/tasm/prover_job.rs @@ -10,6 +10,7 @@ //! program can execute at a time. #[cfg(not(test))] use std::process::Stdio; + use tasm_lib::maybe_write_debuggable_vm_state_to_disk; #[cfg(not(test))] use tokio::io::AsyncWriteExt;