From e979d42a603c53c890bf6877a1ce77152922d1fc Mon Sep 17 00:00:00 2001 From: Liam Aharon Date: Thu, 22 May 2025 00:32:34 +0300 Subject: [PATCH 1/2] max depth limit 100 --- runtime/src/lib.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 56b1d1926..2079ce0ba 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -1596,6 +1596,14 @@ impl_runtime_apis! { tx: ::Extrinsic, block_hash: ::Hash, ) -> TransactionValidity { + use codec::DecodeLimit; + use frame_support::pallet_prelude::ValidateUnsigned; + use frame_support::traits::ExtrinsicCall; + let encoded = tx.call().encode(); + if let Err(e) = ::Call::decode_all_with_depth_limit(100, &mut encoded.as_slice()) { + log::warn!("Failed to decode call: {:?}", e); + todo!("handle err"); + } Executive::validate_transaction(source, tx, block_hash) } } From 6a25f28a033f903ba71bb67facc2aa2e7b304695 Mon Sep 17 00:00:00 2001 From: Liam Aharon Date: Thu, 22 May 2025 00:37:06 +0300 Subject: [PATCH 2/2] clean invalid tx handling --- runtime/src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 2079ce0ba..c4a71e947 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -12,6 +12,7 @@ pub mod check_nonce; mod migrations; use codec::{Compact, Decode, Encode}; +use frame_support::pallet_prelude::InvalidTransaction; use frame_support::traits::{Imbalance, InsideBoth}; use frame_support::{ dispatch::DispatchResultWithPostInfo, @@ -1602,7 +1603,7 @@ impl_runtime_apis! { let encoded = tx.call().encode(); if let Err(e) = ::Call::decode_all_with_depth_limit(100, &mut encoded.as_slice()) { log::warn!("Failed to decode call: {:?}", e); - todo!("handle err"); + return Err(TransactionValidityError::Invalid(InvalidTransaction::Call)); } Executive::validate_transaction(source, tx, block_hash) }