Skip to content

Commit

Permalink
update feature and fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
zjb0807 committed Jul 23, 2024
1 parent 0b69378 commit 6a1ff54
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 31 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ jobs:
- name: Install toolchain
uses: dtolnay/rust-toolchain@nightly
with:
toolchain: nightly-2024-07-22
components: rustfmt
- name: Setup cmake
uses: jwlawson/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion ecosystem-modules/stable-asset
2 changes: 1 addition & 1 deletion evm-tests
3 changes: 2 additions & 1 deletion modules/transaction-payment/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -961,7 +961,8 @@ where
// pre check before set OverrideChargeFeeMethod
ensure!(
fee_swap_path.len() <= T::TradingPathLimit::get() as usize
&& fee_swap_path.len() > 1 && fee_swap_path.first() != Some(&T::NativeCurrencyId::get())
&& fee_swap_path.len() > 1
&& fee_swap_path.first() != Some(&T::NativeCurrencyId::get())
&& fee_swap_path.last() == Some(&T::NativeCurrencyId::get()),
Error::<T>::InvalidSwapPath
);
Expand Down
12 changes: 6 additions & 6 deletions node/service/src/chain_spec/mandala.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,11 +400,11 @@ fn testnet_genesis(
collaterals_params: vec![
(
DOT,
Some(FixedU128::zero()), // interest rate per sec for this collateral
Some(FixedU128::zero()), // interest rate per sec for this collateral
Some(FixedU128::saturating_from_rational(150, 100)), // liquidation ratio
Some(FixedU128::saturating_from_rational(10, 100)), // liquidation penalty rate
Some(FixedU128::saturating_from_rational(10, 100)), // liquidation penalty rate
Some(FixedU128::saturating_from_rational(150, 100)), // required liquidation ratio
10_000_000 * dollar(AUSD), // maximum debit value in aUSD (cap)
10_000_000 * dollar(AUSD), // maximum debit value in aUSD (cap)
),
(
LDOT,
Expand Down Expand Up @@ -576,11 +576,11 @@ fn mandala_genesis(
collaterals_params: vec![
(
DOT,
Some(FixedU128::zero()), // interest rate per sec for this collateral
Some(FixedU128::zero()), // interest rate per sec for this collateral
Some(FixedU128::saturating_from_rational(105, 100)), // liquidation ratio
Some(FixedU128::saturating_from_rational(3, 100)), // liquidation penalty rate
Some(FixedU128::saturating_from_rational(3, 100)), // liquidation penalty rate
Some(FixedU128::saturating_from_rational(110, 100)), // required liquidation ratio
10_000_000 * dollar(AUSD), // maximum debit value in aUSD (cap)
10_000_000 * dollar(AUSD), // maximum debit value in aUSD (cap)
),
(
LDOT,
Expand Down
14 changes: 10 additions & 4 deletions runtime/acala/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2534,9 +2534,12 @@ impl Convert<(RuntimeCall, SignedExtra), Result<(EthereumTransactionMessage, Sig
access_list,
valid_until,
}) => {
#[cfg(not(feature = "tracing"))]
if System::block_number() > valid_until {
return Err(InvalidTransaction::Stale);
if cfg!(feature = "tracing") {
// skip check when enable tracing feature
} else {
return Err(InvalidTransaction::Stale);
}
}

let (_, _, _, _, mortality, check_nonce, _, _, charge) = extra.clone();
Expand Down Expand Up @@ -2580,9 +2583,12 @@ impl Convert<(RuntimeCall, SignedExtra), Result<(EthereumTransactionMessage, Sig
let (tip, valid_until) =
decode_gas_price(gas_price, gas_limit, TxFeePerGasV2::get()).ok_or(InvalidTransaction::Stale)?;

#[cfg(not(feature = "tracing"))]
if System::block_number() > valid_until {
return Err(InvalidTransaction::Stale);
if cfg!(feature = "tracing") {
// skip check when enable tracing feature
} else {
return Err(InvalidTransaction::Stale);
}
}

let (_, _, _, _, mortality, check_nonce, _, _, charge) = extra.clone();
Expand Down
26 changes: 16 additions & 10 deletions runtime/common/src/check_nonce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,17 @@ where
.map(|x| x.nonce)
.unwrap_or_default();

#[cfg(not(feature = "tracing"))]
if self.nonce != evm_nonce {
return Err(if self.nonce < evm_nonce {
InvalidTransaction::Stale
} else {
InvalidTransaction::Future
if cfg!(feature = "tracing") {
// skip check when enable tracing feature
} else {
if self.nonce != evm_nonce {
return Err(if self.nonce < evm_nonce {
InvalidTransaction::Stale
} else {
InvalidTransaction::Future
}
.into());
}
.into());
}
} else if self.nonce != account.nonce {
return Err(if self.nonce < account.nonce {
Expand Down Expand Up @@ -158,9 +161,12 @@ where
.map(|x| x.nonce)
.unwrap_or_default();

#[cfg(not(feature = "tracing"))]
if self.nonce < evm_nonce {
return InvalidTransaction::Stale.into();
if cfg!(feature = "tracing") {
// skip check when enable tracing feature
} else {
if self.nonce < evm_nonce {
return InvalidTransaction::Stale.into();
}
}

let provides = vec![Encode::encode(&(address, self.nonce))];
Expand Down
3 changes: 2 additions & 1 deletion runtime/integration-tests/src/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,8 @@ fn transaction_payment_module_works_with_evm_contract() {
let dollar = dollar(NATIVE_CURRENCY);
let alice_evm_account = MockAddressMapping::get_account_id(&alice_evm_addr());
let ed = NativeTokenExistentialDeposit::get(); // 100_000_000_000
// new account

// new account
let empty_account = AccountId::new([1u8; 32]);
let empty_address = H160::from_slice(&[1u8; 20]);
let empty_address_account = MockAddressMapping::get_account_id(&empty_address);
Expand Down
13 changes: 10 additions & 3 deletions runtime/karura/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2560,9 +2560,12 @@ impl Convert<(RuntimeCall, SignedExtra), Result<(EthereumTransactionMessage, Sig
access_list,
valid_until,
}) => {
#[cfg(not(feature = "tracing"))]
if System::block_number() > valid_until {
return Err(InvalidTransaction::Stale);
if cfg!(feature = "tracing") {
// skip check when enable tracing feature
} else {
return Err(InvalidTransaction::Stale);
}
}

let (_, _, _, _, mortality, check_nonce, _, _, charge) = extra.clone();
Expand Down Expand Up @@ -2606,8 +2609,12 @@ impl Convert<(RuntimeCall, SignedExtra), Result<(EthereumTransactionMessage, Sig
let (tip, valid_until) =
decode_gas_price(gas_price, gas_limit, TxFeePerGasV2::get()).ok_or(InvalidTransaction::Stale)?;

#[cfg(not(feature = "tracing"))]
if System::block_number() > valid_until {
if cfg!(feature = "tracing") {
// skip check when enable tracing feature
} else {
return Err(InvalidTransaction::Stale);
}
return Err(InvalidTransaction::Stale);
}

Expand Down
14 changes: 10 additions & 4 deletions runtime/mandala/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1919,9 +1919,12 @@ impl Convert<(RuntimeCall, SignedExtra), Result<(EthereumTransactionMessage, Sig
access_list,
valid_until,
}) => {
#[cfg(not(feature = "tracing"))]
if System::block_number() > valid_until {
return Err(InvalidTransaction::Stale);
if cfg!(feature = "tracing") {
// skip check when enable tracing feature
} else {
return Err(InvalidTransaction::Stale);
}
}

let (_, _, _, _, mortality, check_nonce, _, _, charge) = extra.clone();
Expand Down Expand Up @@ -1965,9 +1968,12 @@ impl Convert<(RuntimeCall, SignedExtra), Result<(EthereumTransactionMessage, Sig
let (tip, valid_until) =
decode_gas_price(gas_price, gas_limit, TxFeePerGasV2::get()).ok_or(InvalidTransaction::Stale)?;

#[cfg(not(feature = "tracing"))]
if System::block_number() > valid_until {
return Err(InvalidTransaction::Stale);
if cfg!(feature = "tracing") {
// skip check when enable tracing feature
} else {
return Err(InvalidTransaction::Stale);
}
}

let (_, _, _, _, mortality, check_nonce, _, _, charge) = extra.clone();
Expand Down

0 comments on commit 6a1ff54

Please sign in to comment.