From 3a7abeb0cd4a6e3b99dce36aafe3951add501b7a Mon Sep 17 00:00:00 2001 From: wojciechos Date: Tue, 10 Dec 2024 21:52:49 +0100 Subject: [PATCH] Skip error logs for FGW responses with NOT_RECEIVED status (#2303) * Add NotReceived case handling in adaptTransactionStatus --------- Co-authored-by: Rian Hughes --- rpc/transaction.go | 9 +++++++-- starknet/compiler/rust/src/lib.rs | 15 +++++++++++---- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/rpc/transaction.go b/rpc/transaction.go index 8e3c3956f..8157b4caa 100644 --- a/rpc/transaction.go +++ b/rpc/transaction.go @@ -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 { @@ -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 @@ -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) } diff --git a/starknet/compiler/rust/src/lib.rs b/starknet/compiler/rust/src/lib.rs index a1027a3e3..fa45765cb 100644 --- a/starknet/compiler/rust/src/lib.rs +++ b/starknet/compiler/rust/src/lib.rs @@ -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)] @@ -25,9 +27,14 @@ pub extern "C" fn compileSierraToCasm(sierra_json: *const c_char, result: *mut * } }; - let mut casm_class_result: Option> = None; + let mut casm_class_result: Option> = + 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 {