Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rpc 0.8.0 errors #627

Merged
merged 28 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
59ddaca
Move and rename tx status struct; add failure_reason
FabijanC Oct 3, 2024
f7cd52e
Add test
FabijanC Oct 3, 2024
cc6c0fc
Rename InsufficientMaxFee to InsufficientResourcesForValidate
FabijanC Oct 3, 2024
2d2acee
Improve readability
FabijanC Oct 3, 2024
e492274
Improve readability in error conversion
FabijanC Oct 4, 2024
21be40e
Copy stack_trace.rs from blockifier
FabijanC Oct 10, 2024
ff2f8fa
Refactor ContractExecutionError to use ErrorStack; add todo [skip ci]
FabijanC Oct 10, 2024
b01e425
Implement serialize_error_stack with a couple of TODOs [skip ci]
FabijanC Oct 10, 2024
b9794a1
Improve comment in stack_trace.rs [skip ci]
FabijanC Oct 11, 2024
f8f7cfb
Address TODOs in unit tests [skip ci]
FabijanC Oct 11, 2024
6f05512
Remove TODO for BlockifierStateError [skip ci]
FabijanC Oct 11, 2024
0bb359a
Add ContractExecutionError handler to estimate_message_fee
FabijanC Oct 11, 2024
ee3792a
Fix failing unit test contract_error
FabijanC Oct 11, 2024
4408b50
Add TransactionExecutionError skeleton [TODO] [skip ci]
FabijanC Oct 11, 2024
df67ec8
Handle execution error in simulation/estimation
FabijanC Oct 14, 2024
df9ce7f
Update rpc error tests
FabijanC Oct 14, 2024
4bc7474
Adapt tests; edit TODOs; add util for extracting rpc error
FabijanC Oct 14, 2024
3117875
Add json rpc error asserter; fix failing tests
FabijanC Oct 15, 2024
9d924cf
Merge branch 'json-rpc-v0.8.0' into rpc-0.8.0-errors
FabijanC Oct 15, 2024
5f3d6d2
Add test: estimate_fee_of_multiple_txs
FabijanC Oct 15, 2024
8a2f6ac
Refactor creation of broadcasted invoke for estimation
FabijanC Oct 16, 2024
9f2e4bc
Improve panicking_contract: compile with 2.8.0, add method for distan…
FabijanC Oct 17, 2024
4727e65
Add test util for contract deployment
FabijanC Oct 17, 2024
6f44920
Remove vm handling from error stack serialization; add nested call test
FabijanC Oct 17, 2024
8fb7154
Apply improved json rpc error extraction and assertion in forking test
FabijanC Oct 17, 2024
e713a77
Make index variables more descriptive (i -> tx_i)
FabijanC Oct 17, 2024
7fb902b
Improve test clarity
FabijanC Oct 17, 2024
ed1609a
Add test of panicking simulation
FabijanC Oct 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
Compiled using cairo 2.2.0
Compiled using cairo 2.8.0
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
use core::starknet::ContractAddress;

#[starknet::interface]
trait IPanickingContract<TContractState> {
fn create_panic(self: @TContractState, panic_reason: felt252);
fn create_panic_in_another_contract(self: @TContractState, address: ContractAddress, panic_reason: felt252);
}

#[starknet::contract]
mod PanickingContract {
use core::starknet::{ContractAddress, call_contract_syscall};

#[storage]
struct Storage {}

#[external(v0)]
#[abi(embed_v0)]
impl PanickingContract of super::IPanickingContract<ContractState> {
fn create_panic(self: @ContractState, panic_reason: felt252) {
panic_with_felt252(panic_reason);
}

fn create_panic_in_another_contract(self: @ContractState, address: ContractAddress, panic_reason: felt252) {
call_contract_syscall(
address,
selector!("create_panic"),
array![panic_reason].span()
).unwrap();
}
}
}

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions crates/starknet-devnet-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ description = "Starknet core logic for devnet"
[dependencies]
blockifier = { workspace = true, features = ["testing"] }
cairo-lang-starknet-classes = { workspace = true }
cairo-vm = { workspace = true }
clap = { workspace = true }
ethers = { workspace = true }
starknet_api = { workspace = true, features = ["testing"] }
Expand Down
22 changes: 14 additions & 8 deletions crates/starknet-devnet-core/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ use starknet_types::contract_address::ContractAddress;
use starknet_types::contract_storage_key::ContractStorageKey;
use thiserror::Error;

use crate::stack_trace::{gen_tx_execution_error_trace, ErrorStack};

#[derive(Error, Debug)]
pub enum Error {
#[error(transparent)]
Expand All @@ -12,12 +14,10 @@ pub enum Error {
StateError(#[from] StateError),
#[error(transparent)]
BlockifierStateError(#[from] blockifier::state::errors::StateError),
#[error(transparent)]
BlockifierTransactionError(#[from] blockifier::transaction::errors::TransactionExecutionError),
#[error(transparent)]
BlockifierExecutionError(#[from] blockifier::execution::errors::EntryPointExecutionError),
#[error("{revert_error}")]
ExecutionError { revert_error: String },
#[error("{0:?}")]
ContractExecutionError(ErrorStack),
#[error("Execution error in simulating transaction no. {failure_index}: {error_stack:?}")]
ContractExecutionErrorInSimulation { failure_index: u64, error_stack: ErrorStack },
#[error("Types error: {0}")]
TypesError(#[from] starknet_types::error::Error),
#[error("I/O error: {0}")]
Expand Down Expand Up @@ -78,6 +78,12 @@ impl From<starknet_types_core::felt::FromStrError> for Error {
}
}

impl From<blockifier::transaction::errors::TransactionExecutionError> for Error {
fn from(e: blockifier::transaction::errors::TransactionExecutionError) -> Self {
Self::ContractExecutionError(gen_tx_execution_error_trace(&e))
}
}

#[derive(Debug, Error)]
pub enum StateError {
#[error("No class hash {0:x} found")]
Expand All @@ -94,8 +100,8 @@ pub enum StateError {

#[derive(Debug, Error)]
pub enum TransactionValidationError {
#[error("Provided max fee is not enough to cover the transaction cost.")]
InsufficientMaxFee,
#[error("The transaction's resources don't cover validation or the minimal transaction fee.")]
InsufficientResourcesForValidate,
#[error("Account transaction nonce is invalid.")]
InvalidTransactionNonce,
#[error("Account balance is not enough to cover the transaction cost.")]
Expand Down
1 change: 1 addition & 0 deletions crates/starknet-devnet-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pub mod error;
pub mod messaging;
mod predeployed_accounts;
pub mod raw_execution;
pub mod stack_trace;
pub mod starknet;
mod state;
mod system_contract;
Expand Down
Loading