Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 3 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,9 @@ jobs:
with:
node-version: 18.x
- name: Install deps
run: cargo +1.88.0 install staging-chain-spec-builder --force # base64ct 1.8.0 requires the Cargo feature called `edition2024`
run: cargo install staging-chain-spec-builder --force
- name: Run ts tests
run: |
npm install -g yarn
make test-ts
# TODO: update bodhi & enable this
# make test-ts
2 changes: 1 addition & 1 deletion evm-tests
Submodule evm-tests updated 1 files
+1 −1 ethjson/src/uint.rs
8 changes: 4 additions & 4 deletions modules/asset-registry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ where
if let Some(asset_metadata) = Pallet::<T>::asset_metadatas(AssetIds::ForeignAssetId(foreign_asset_id)) {
let minimum_balance = asset_metadata.minimal_balance.into();
let rate = FixedU128::saturating_from_rational(minimum_balance, T::Currency::minimum_balance().into());
log::debug!(target: "asset-registry::weight", "ForeignAsset: {}, MinimumBalance: {}, rate:{:?}", foreign_asset_id, minimum_balance, rate);
log::debug!(target: "asset-registry::weight", "ForeignAsset: {foreign_asset_id}, MinimumBalance: {minimum_balance}, rate: {rate:?}");
return Some(rate);
}
}
Expand All @@ -596,7 +596,7 @@ where
let minimum_balance = asset_metadata.minimal_balance.into();
let rate =
FixedU128::saturating_from_rational(minimum_balance, T::Currency::minimum_balance().into());
log::debug!(target: "asset-registry::weight", "LiquidCrowdloan: {}, MinimumBalance: {}, rate:{:?}", lease, minimum_balance, rate);
log::debug!(target: "asset-registry::weight", "LiquidCrowdloan: {lease}, MinimumBalance: {minimum_balance}, rate: {rate:?}");
Some(rate)
} else {
None
Expand All @@ -621,7 +621,7 @@ where
let minimum_balance = asset_metadata.minimal_balance.into();
let rate =
FixedU128::saturating_from_rational(minimum_balance, T::Currency::minimum_balance().into());
log::debug!(target: "asset-registry::weight", "StableAsset: {}, MinimumBalance: {}, rate:{:?}", pool_id, minimum_balance, rate);
log::debug!(target: "asset-registry::weight", "StableAsset: {pool_id}, MinimumBalance: {minimum_balance}, rate: {rate:?}");
Some(rate)
} else {
None
Expand All @@ -646,7 +646,7 @@ where
let minimum_balance = asset_metadata.minimal_balance.into();
let rate =
FixedU128::saturating_from_rational(minimum_balance, T::Currency::minimum_balance().into());
log::debug!(target: "asset-registry::weight", "Erc20: {}, MinimumBalance: {}, rate:{:?}", address, minimum_balance, rate);
log::debug!(target: "asset-registry::weight", "Erc20: {address}, MinimumBalance: {minimum_balance}, rate: {rate:?}");
Some(rate)
} else {
None
Expand Down
19 changes: 7 additions & 12 deletions modules/auction-manager/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,14 +268,12 @@ pub mod module {
if let Err(e) = Self::_offchain_worker() {
log::info!(
target: "auction-manager",
"offchain worker: cannot run offchain worker at {:?}: {:?}",
now, e,
"offchain worker: cannot run offchain worker at {now:?}: {e:?}",
);
} else {
log::debug!(
target: "auction-manager",
"offchain worker: offchain worker start at block: {:?} already done!",
now,
"offchain worker: offchain worker start at block: {now:?} already done!",
);
}
}
Expand Down Expand Up @@ -342,8 +340,7 @@ impl<T: Config> Pallet<T> {
if let Err(err) = SubmitTransaction::<T, Call<T>>::submit_transaction(xt) {
log::info!(
target: "auction-manager",
"offchain worker: submit unsigned auction cancel tx for AuctionId {:?} failed: {:?}",
auction_id, err,
"offchain worker: submit unsigned auction cancel tx for AuctionId {auction_id:?} failed: {err:?}",
);
}
}
Expand All @@ -368,8 +365,7 @@ impl<T: Config> Pallet<T> {

log::debug!(
target: "auction-manager",
"offchain worker: max iterations is {:?}",
max_iterations
"offchain worker: max iterations is {max_iterations:?}",
);

// start iterations to cancel collateral auctions
Expand Down Expand Up @@ -696,9 +692,9 @@ impl<T: Config> Pallet<T> {
if let Err(e) = res {
log::warn!(
target: "auction-manager",
"issue_debit: failed to issue stable {:?} to {:?}: {:?}. \
"issue_debit: failed to issue stable {:?} to {bidder:?}: {e:?}. \
This is unexpected but should be safe",
collateral_auction.payment_amount(bid_price), bidder, e
collateral_auction.payment_amount(bid_price)
);
debug_assert!(false);
}
Expand All @@ -714,9 +710,8 @@ impl<T: Config> Pallet<T> {
if let Err(e) = res {
log::warn!(
target: "auction-manager",
"withdraw_collateral: failed to withdraw {:?} {:?} from CDP treasury to {:?}: {:?}. \
"withdraw_collateral: failed to withdraw {refund_collateral:?} {collateral_type:?} from CDP treasury to {refund_recipient:?}: {e:?}. \
This is unexpected but should be safe",
refund_collateral, collateral_type, refund_recipient, e
);
debug_assert!(false);
}
Expand Down
35 changes: 10 additions & 25 deletions modules/cdp-engine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![allow(clippy::unused_unit)]
#![allow(clippy::upper_case_acronyms)]
#![allow(clippy::useless_conversion)]

use frame_support::{
pallet_prelude::*, traits::ExistenceRequirement, traits::UnixTime, transactional, BoundedVec, PalletId,
Expand Down Expand Up @@ -420,15 +421,12 @@ pub mod module {
if let Err(e) = Self::_offchain_worker() {
log::info!(
target: "cdp-engine offchain worker",
"cannot run offchain worker at {:?}: {:?}",
now,
e,
"cannot run offchain worker at {now:?}: {e:?}",
);
} else {
log::debug!(
target: "cdp-engine offchain worker",
"offchain worker start at block: {:?} already done!",
now,
"offchain worker start at block: {now:?} already done!",
);
}
}
Expand Down Expand Up @@ -651,9 +649,8 @@ impl<T: Config> Pallet<T> {
Err(e) => {
log::warn!(
target: "cdp-engine",
"on_system_surplus: failed to on system surplus {:?}: {:?}. \
"on_system_surplus: failed to on system surplus {issued_stable_coin_balance:?}: {e:?}. \
This is unexpected but should be safe",
issued_stable_coin_balance, e
);
}
}
Expand All @@ -678,8 +675,7 @@ impl<T: Config> Pallet<T> {
if SubmitTransaction::<T, Call<T>>::submit_transaction(xt).is_err() {
log::info!(
target: "cdp-engine offchain worker",
"submit unsigned liquidation tx for \nCDP - AccountId {:?} CurrencyId {:?} \nfailed!",
who, currency_id,
"submit unsigned liquidation tx for \nCDP - AccountId {who:?} CurrencyId {currency_id:?} \nfailed!",
);
}
}
Expand All @@ -694,8 +690,7 @@ impl<T: Config> Pallet<T> {
if SubmitTransaction::<T, Call<T>>::submit_transaction(xt).is_err() {
log::info!(
target: "cdp-engine offchain worker",
"submit unsigned settlement tx for \nCDP - AccountId {:?} CurrencyId {:?} \nfailed!",
who, currency_id,
"submit unsigned settlement tx for \nCDP - AccountId {who:?} CurrencyId {currency_id:?} \nfailed!",
);
}
}
Expand Down Expand Up @@ -739,9 +734,7 @@ impl<T: Config> Pallet<T> {
None => {
log::debug!(
target: "cdp-engine offchain worker",
"collateral_currency was removed, need to reset the offchain worker: collateral_position is {:?}, collateral_currency_ids: {:?}",
collateral_position,
collateral_currency_ids
"collateral_currency was removed, need to reset the offchain worker: collateral_position is {collateral_position:?}, collateral_currency_ids: {collateral_currency_ids:?}",
);
to_be_continue.set(&(0, Option::<Vec<u8>>::None));
return Ok(());
Expand Down Expand Up @@ -786,13 +779,7 @@ impl<T: Config> Pallet<T> {
let iteration_end_time = sp_io::offchain::timestamp();
log::debug!(
target: "cdp-engine offchain worker",
"iteration info:\n max iterations is {:?}\n currency id: {:?}, start key: {:?}, iterate count: {:?}\n iteration start at: {:?}, end at: {:?}, execution time: {:?}\n",
max_iterations,
currency_id,
start_key,
iteration_count,
iteration_start_time,
iteration_end_time,
"iteration info:\n max iterations is {max_iterations:?}\n currency id: {currency_id:?}, start key: {start_key:?}, iterate count: {iteration_count:?}\n iteration start at: {iteration_start_time:?}, end at: {iteration_end_time:?}, execution time: {:?}\n",
iteration_end_time.diff(&iteration_start_time)
);

Expand Down Expand Up @@ -1467,9 +1454,8 @@ impl<T: Config> LiquidateCollateral<T::AccountId> for LiquidateViaContracts<T> {
log::error!(
target: "cdp-engine",
"LiquidateViaContracts: transfer collateral to contract failed. \
Collateral: {:?}, amount: {:?} contract: {:?}, error: {:?}. \
Collateral: {currency_id:?}, amount: {collateral_supply:?} contract: {contract:?}, error: {e:?}. \
This is unexpected, need extra action.",
currency_id, collateral_supply, contract, e,
);
} else {
// notify liquidation success
Expand All @@ -1494,9 +1480,8 @@ impl<T: Config> LiquidateCollateral<T::AccountId> for LiquidateViaContracts<T> {
log::error!(
target: "cdp-engine",
"LiquidateViaContracts: refund rest collateral to CDP owner failed. \
Collateral: {:?}, amount: {:?} error: {:?}. \
Collateral: {currency_id:?}, amount: {refund_collateral_amount:?} error: {e:?}. \
This is unexpected, need extra action.",
currency_id, refund_collateral_amount, e,
);
}
}
Expand Down
4 changes: 2 additions & 2 deletions modules/cdp-treasury/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![allow(clippy::unused_unit)]
#![allow(clippy::needless_range_loop)]
#![allow(clippy::useless_conversion)]

use frame_support::{pallet_prelude::*, traits::ExistenceRequirement, transactional, PalletId};
use frame_system::pallet_prelude::*;
Expand Down Expand Up @@ -338,8 +339,7 @@ impl<T: Config> Pallet<T> {
Err(e) => {
log::warn!(
target: "cdp-treasury",
"get_swap_supply_amount: Attempt to burn surplus {:?} failed: {:?}, this is unexpected but should be safe",
offset_amount, e
"get_swap_supply_amount: Attempt to burn surplus {offset_amount:?} failed: {e:?}, this is unexpected but should be safe",
);
}
}
Expand Down
5 changes: 3 additions & 2 deletions modules/collator-selection/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
#![allow(clippy::into_iter_on_ref)]
#![allow(clippy::try_err)]
#![allow(clippy::let_and_return)]
#![allow(clippy::useless_conversion)]

pub use pallet::*;

Expand Down Expand Up @@ -551,8 +552,8 @@ pub mod pallet {
if let Err(why) = outcome {
log::warn!(
target: "collator-selection",
"Failed to remove candidate {:?}", why);
debug_assert!(false, "failed to remove candidate {:?}", why);
"Failed to remove candidate {why:?}");
debug_assert!(false, "failed to remove candidate {why:?}");
} else {
<NonCandidates<T>>::insert(
who,
Expand Down
4 changes: 2 additions & 2 deletions modules/evm-utility/macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ pub fn generate_function_selector(_: TokenStream, input: TokenStream) -> TokenSt
attrs: Default::default(),
}));
} else {
panic!("Not method string: `{:?}`", lit);
panic!("Not method string: `{lit:?}`");
}
} else {
panic!("Not enum: `{:?}`", variant);
panic!("Not enum: `{variant:?}`");
}
}

Expand Down
34 changes: 13 additions & 21 deletions modules/evm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#![allow(clippy::or_fun_call)]
#![allow(clippy::unused_unit)]
#![allow(clippy::upper_case_acronyms)]
#![allow(clippy::useless_conversion)]

pub use crate::runner::{
stack::SubstrateStackState,
Expand Down Expand Up @@ -445,8 +446,7 @@ pub mod module {

assert!(
reason.is_succeed(),
"Genesis contract failed to execute, error: {:?}",
reason
"Genesis contract failed to execute, error: {reason:?}",
);

let out = runtime.machine().return_value();
Expand Down Expand Up @@ -1323,8 +1323,8 @@ pub mod module {
} else {
log::debug!(
target: "evm",
"batch_call failed: [from: {:?}, contract: {:?}, exit_reason: {:?}, output: {:?}, logs: {:?}, used_gas: {:?}]",
source, target, info.exit_reason, info.value, info.logs, used_gas
"batch_call failed: [from: {source:?}, contract: {target:?}, exit_reason: {:?}, output: {:?}, logs: {:?}, used_gas: {used_gas:?}]",
info.exit_reason, info.value, info.logs
);
Err(DispatchErrorWithPostInfo {
post_info: PostDispatchInfo {
Expand Down Expand Up @@ -1370,9 +1370,8 @@ impl<T: Config> Pallet<T> {
return false;
}

Self::accounts(address).map_or(true, |account_info| {
account_info.contract_info.is_none() && account_info.nonce.is_zero()
})
Self::accounts(address)
.is_none_or(|account_info| account_info.contract_info.is_none() && account_info.nonce.is_zero())
}

/// Remove an account if its empty.
Expand Down Expand Up @@ -1460,8 +1459,7 @@ impl<T: Config> Pallet<T> {
// so this should never happen
log::warn!(
target: "evm",
"remove_account: removed account {:?} while is still linked to contract info",
address
"remove_account: removed account {address:?} while is still linked to contract info",
);
debug_assert!(false, "removed account while is still linked to contract info");
}
Expand Down Expand Up @@ -1812,8 +1810,7 @@ impl<T: Config> Pallet<T> {

log::debug!(
target: "evm",
"reserve_storage: [from: {:?}, account: {:?}, limit: {:?}, amount: {:?}]",
caller, user, limit, amount
"reserve_storage: [from: {caller:?}, account: {user:?}, limit: {limit:?}, amount: {amount:?}]",
);

T::ChargeTransactionPayment::reserve_fee(&user, amount, Some(RESERVE_ID_STORAGE_DEPOSIT))?;
Expand All @@ -1832,8 +1829,7 @@ impl<T: Config> Pallet<T> {

log::debug!(
target: "evm",
"unreserve_storage: [from: {:?}, account: {:?}, used: {:?}, refunded: {:?}, unused: {:?}, amount: {:?}]",
caller, user, used, refunded, unused, amount
"unreserve_storage: [from: {caller:?}, account: {user:?}, used: {used:?}, refunded: {refunded:?}, unused: {unused:?}, amount: {amount:?}]",
);

// should always be able to unreserve the amount
Expand All @@ -1854,8 +1850,7 @@ impl<T: Config> Pallet<T> {

log::debug!(
target: "evm",
"charge_storage: [from: {:?}, account: {:?}, contract: {:?}, contract_acc: {:?}, storage: {:?}, amount: {:?}]",
caller, user, contract, contract_acc, storage, amount
"charge_storage: [from: {caller:?}, account: {user:?}, contract: {contract:?}, contract_acc: {contract_acc:?}, storage: {storage:?}, amount: {amount:?}]",
);

if storage.is_positive() {
Expand Down Expand Up @@ -1893,8 +1888,7 @@ impl<T: Config> Pallet<T> {

log::debug!(
target: "evm",
"refund_storage: [from: {:?}, account: {:?}, contract: {:?}, contract_acc: {:?}, maintainer: {:?}, maintainer_acc: {:?}, amount: {:?}]",
caller, user, contract, contract_acc, maintainer, maintainer_acc, amount
"refund_storage: [from: {caller:?}, account: {user:?}, contract: {contract:?}, contract_acc: {contract_acc:?}, maintainer: {maintainer:?}, maintainer_acc: {maintainer_acc:?}, amount: {amount:?}]",
);

// user can't be a dead account
Expand Down Expand Up @@ -2272,8 +2266,7 @@ impl<T: Config> DispatchableTask for EvmTask<T> {
);
log::debug!(
target: "evm",
"EvmTask remove: [from: {:?}, contract: {:?}, maintainer: {:?}, count: {:?}]",
caller, contract, maintainer, count
"EvmTask remove: [from: {caller:?}, contract: {contract:?}, maintainer: {maintainer:?}, count: {count:?}]",
);
if r.maybe_cursor.is_none() {
// AllRemoved
Expand All @@ -2282,8 +2275,7 @@ impl<T: Config> DispatchableTask for EvmTask<T> {
debug_assert!(result.is_ok());
log::debug!(
target: "evm",
"EvmTask refund_storage: [from: {:?}, contract: {:?}, maintainer: {:?}, result: {:?}]",
caller, contract, maintainer, result
"EvmTask refund_storage: [from: {caller:?}, contract: {contract:?}, maintainer: {maintainer:?}, result: {result:?}]",
);

// Remove account after all of the storages are cleared.
Expand Down
2 changes: 1 addition & 1 deletion modules/evm/src/precompiles/modexp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ pub trait ModexpImpl {
// output of length and value 1.
if bytes.len() as u64 <= mod_len {
let mut ret = Vec::with_capacity(mod_len as usize);
ret.extend(core::iter::repeat(0).take(mod_len as usize - bytes.len()));
ret.extend(core::iter::repeat_n(0, mod_len as usize - bytes.len()));
ret.extend_from_slice(&bytes[..]);
ret.to_vec()
} else {
Expand Down
Loading