Skip to content

Commit

Permalink
SingleProof: Assign error IDs to some asserts
Browse files Browse the repository at this point in the history
  • Loading branch information
Sword-Smith committed Nov 21, 2024
1 parent d2e556c commit 9b5dd0f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/assertion_error_ids.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) |
9 changes: 6 additions & 3 deletions src/models/blockchain/transaction/validity/single_proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
);

Expand Down Expand Up @@ -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
// _
Expand Down Expand Up @@ -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);
}
}

Expand Down
1 change: 1 addition & 0 deletions src/models/proof_abstractions/tasm/prover_job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 9b5dd0f

Please sign in to comment.