From 29afd1726112aeff871fc8d30f7a39a954aa3777 Mon Sep 17 00:00:00 2001 From: Lovish Arora <46993225+lavish0000@users.noreply.github.com> Date: Thu, 22 May 2025 14:22:35 +0200 Subject: [PATCH 1/2] Refactor asset handling and dispatch calls to use SYSTEM_ACCOUNT_SIZE for improved consistency --- precompiles/assets-factory/src/lib.rs | 1 + precompiles/xtokens/src/lib.rs | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/precompiles/assets-factory/src/lib.rs b/precompiles/assets-factory/src/lib.rs index d695b3ff7..37ded8456 100644 --- a/precompiles/assets-factory/src/lib.rs +++ b/precompiles/assets-factory/src/lib.rs @@ -75,6 +75,7 @@ where _handle: &mut impl PrecompileHandle, id: u64, ) -> EvmResult
{ + _handle.record_db_read::(36)?; let asset_id = id .try_into() .map_err(|_| RevertReason::value_is_too_large("asset id type").in_field("id"))?; diff --git a/precompiles/xtokens/src/lib.rs b/precompiles/xtokens/src/lib.rs index 1e76a194b..6300c939e 100644 --- a/precompiles/xtokens/src/lib.rs +++ b/precompiles/xtokens/src/lib.rs @@ -113,7 +113,7 @@ where dest_weight_limit, }; - RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call, 0)?; + RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call, SYSTEM_ACCOUNT_SIZE)?; Ok(()) } @@ -160,7 +160,7 @@ where dest_weight_limit, }; - RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call, 0)?; + RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call, SYSTEM_ACCOUNT_SIZE)?; Ok(()) } @@ -194,7 +194,7 @@ where dest_weight_limit, }; - RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call, 0)?; + RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call, SYSTEM_ACCOUNT_SIZE)?; Ok(()) } @@ -240,7 +240,7 @@ where dest_weight_limit, }; - RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call, 0)?; + RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call, SYSTEM_ACCOUNT_SIZE)?; Ok(()) } @@ -299,7 +299,7 @@ where dest_weight_limit, }; - RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call, 0)?; + RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call, SYSTEM_ACCOUNT_SIZE)?; Ok(()) } @@ -353,7 +353,7 @@ where dest_weight_limit, }; - RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call, 0)?; + RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call, SYSTEM_ACCOUNT_SIZE)?; Ok(()) } From 226e25802ad2093a25b22fff27e738fb5eb3ce4e Mon Sep 17 00:00:00 2001 From: Lovish Arora <46993225+lavish0000@users.noreply.github.com> Date: Thu, 22 May 2025 15:06:34 +0200 Subject: [PATCH 2/2] Refactor dispatch calls in xtokens to improve readability by formatting parameters across multiple lines --- precompiles/xtokens/src/lib.rs | 42 +++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/precompiles/xtokens/src/lib.rs b/precompiles/xtokens/src/lib.rs index 6300c939e..500af4d50 100644 --- a/precompiles/xtokens/src/lib.rs +++ b/precompiles/xtokens/src/lib.rs @@ -113,7 +113,12 @@ where dest_weight_limit, }; - RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call, SYSTEM_ACCOUNT_SIZE)?; + RuntimeHelper::::try_dispatch( + handle, + Some(origin).into(), + call, + SYSTEM_ACCOUNT_SIZE, + )?; Ok(()) } @@ -160,7 +165,12 @@ where dest_weight_limit, }; - RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call, SYSTEM_ACCOUNT_SIZE)?; + RuntimeHelper::::try_dispatch( + handle, + Some(origin).into(), + call, + SYSTEM_ACCOUNT_SIZE, + )?; Ok(()) } @@ -194,7 +204,12 @@ where dest_weight_limit, }; - RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call, SYSTEM_ACCOUNT_SIZE)?; + RuntimeHelper::::try_dispatch( + handle, + Some(origin).into(), + call, + SYSTEM_ACCOUNT_SIZE, + )?; Ok(()) } @@ -240,7 +255,12 @@ where dest_weight_limit, }; - RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call, SYSTEM_ACCOUNT_SIZE)?; + RuntimeHelper::::try_dispatch( + handle, + Some(origin).into(), + call, + SYSTEM_ACCOUNT_SIZE, + )?; Ok(()) } @@ -299,7 +319,12 @@ where dest_weight_limit, }; - RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call, SYSTEM_ACCOUNT_SIZE)?; + RuntimeHelper::::try_dispatch( + handle, + Some(origin).into(), + call, + SYSTEM_ACCOUNT_SIZE, + )?; Ok(()) } @@ -353,7 +378,12 @@ where dest_weight_limit, }; - RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call, SYSTEM_ACCOUNT_SIZE)?; + RuntimeHelper::::try_dispatch( + handle, + Some(origin).into(), + call, + SYSTEM_ACCOUNT_SIZE, + )?; Ok(()) }