Skip to content

Commit

Permalink
chore: remove handle of impossible scenarios
Browse files Browse the repository at this point in the history
  • Loading branch information
ArniStarkware committed Aug 8, 2024
1 parent c132b7f commit fc926d3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
3 changes: 0 additions & 3 deletions crates/blockifier/src/transaction/errors.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use cairo_vm::types::errors::program_errors::ProgramError;
use num_bigint::BigUint;
use starknet_api::core::{ClassHash, ContractAddress, EntryPointSelector, Nonce};
use starknet_api::transaction::{Fee, TransactionVersion};
Expand Down Expand Up @@ -110,8 +109,6 @@ pub enum TransactionExecutionError {
not."
)]
InvalidSegmentStructure(usize, usize),
#[error(transparent)]
ProgramError(#[from] ProgramError),
}

#[derive(Debug, Error)]
Expand Down
17 changes: 10 additions & 7 deletions crates/blockifier/src/transaction/transactions.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::sync::Arc;

use cairo_vm::types::errors::program_errors::ProgramError;
use cairo_vm::vm::runners::cairo_runner::ExecutionResources;
use starknet_api::core::{ClassHash, CompiledClassHash, ContractAddress, Nonce};
use starknet_api::deprecated_contract_class::EntryPointType;
Expand Down Expand Up @@ -136,12 +137,12 @@ pub struct DeclareTransaction {
}

impl TryFrom<starknet_api::executable_transaction::DeclareTransaction> for DeclareTransaction {
type Error = TransactionExecutionError;
type Error = ProgramError;

fn try_from(
value: starknet_api::executable_transaction::DeclareTransaction,
) -> Result<Self, Self::Error> {
Self::new_from_executable_tx(value, false)
Self::create_from_executable_tx(value, false)
}
}

Expand Down Expand Up @@ -173,17 +174,19 @@ impl DeclareTransaction {
Self::create(declare_tx, tx_hash, class_info, true)
}

pub fn new_from_executable_tx(
pub fn create_from_executable_tx(
declare_tx: starknet_api::executable_transaction::DeclareTransaction,
only_query: bool,
) -> Result<Self, TransactionExecutionError> {
) -> Result<Self, ProgramError> {
let starknet_api::executable_transaction::DeclareTransaction { tx, tx_hash, class_info } =
declare_tx;
let class_info: ClassInfo = class_info.try_into()?;

// TODO(Arni): We don't need to verify the contract class version here, any executable
// declare transaction will always have matching versions.
Self::create(tx, tx_hash, class_info, only_query)
// Assert that the ContractClass matches the TransactionVersion, and return the result.
Ok(Self::create(tx, tx_hash, class_info, only_query).expect(
"In this flow we expect the ContractClass version to always be 1 and the \
TransactionVersion to be 3.",
))
}

implement_inner_tx_getter_calls!((class_hash, ClassHash), (signature, TransactionSignature));
Expand Down

0 comments on commit fc926d3

Please sign in to comment.