Skip to content

Commit

Permalink
Skip error logs for FGW responses with NOT_RECEIVED status (#2303)
Browse files Browse the repository at this point in the history
* Add NotReceived case handling in adaptTransactionStatus

---------

Co-authored-by: Rian Hughes <rian.hughes@physics.ox.ac.uk>
  • Loading branch information
wojciechos and rianhughes authored Dec 10, 2024
1 parent 926b485 commit 3a7abeb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
9 changes: 7 additions & 2 deletions rpc/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,8 @@ func (h *Handler) AddTransaction(ctx context.Context, tx BroadcastedTransaction)
}, nil
}

var errTransactionNotFound = fmt.Errorf("transaction not found")

func (h *Handler) TransactionStatus(ctx context.Context, hash felt.Felt) (*TransactionStatus, *jsonrpc.Error) {
receipt, txErr := h.TransactionReceiptByHash(hash)
switch txErr {
Expand All @@ -585,10 +587,11 @@ func (h *Handler) TransactionStatus(ctx context.Context, hash felt.Felt) (*Trans

status, err := adaptTransactionStatus(txStatus)
if err != nil {
h.log.Errorw("Failed to adapt transaction status", "err", err)
if !errors.Is(err, errTransactionNotFound) {
h.log.Errorw("Failed to adapt transaction status", "err", err)
}
return nil, ErrTxnHashNotFound
}

return status, nil
}
return nil, txErr
Expand Down Expand Up @@ -751,6 +754,8 @@ func adaptTransactionStatus(txStatus *starknet.TransactionStatus) (*TransactionS
status.Finality = TxnStatusAcceptedOnL2
case starknet.Received:
status.Finality = TxnStatusReceived
case starknet.NotReceived:
return nil, errTransactionNotFound
default:
return nil, fmt.Errorf("unknown finality status: %v", finalityStatus)
}
Expand Down
15 changes: 11 additions & 4 deletions starknet/compiler/rust/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use cairo_lang_starknet_classes::casm_contract_class::{CasmContractClass, StarknetSierraCompilationError};
use cairo_lang_starknet_classes::casm_contract_class::{
CasmContractClass, StarknetSierraCompilationError,
};
use std::ffi::{c_char, CStr, CString};
use std::panic::{self,AssertUnwindSafe};
use std::panic::{self, AssertUnwindSafe};

#[no_mangle]
#[allow(clippy::not_unsafe_ptr_arg_deref)]
Expand All @@ -25,9 +27,14 @@ pub extern "C" fn compileSierraToCasm(sierra_json: *const c_char, result: *mut *
}
};

let mut casm_class_result: Option<Result<CasmContractClass, StarknetSierraCompilationError>> = None;
let mut casm_class_result: Option<Result<CasmContractClass, StarknetSierraCompilationError>> =
None;
let compilation_result = panic::catch_unwind(AssertUnwindSafe(|| {
casm_class_result = Some(CasmContractClass::from_contract_class(sierra_class, true, usize::MAX));
casm_class_result = Some(CasmContractClass::from_contract_class(
sierra_class,
true,
usize::MAX,
));
}));
if let Err(_) = compilation_result {
unsafe {
Expand Down

0 comments on commit 3a7abeb

Please sign in to comment.