Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip check nonce and valid when enable the tracing feature #2778

Merged
merged 5 commits into from
Jul 23, 2024
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
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
2 changes: 1 addition & 1 deletion runtime/acala/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -415,4 +415,4 @@ no-metadata-docs = ["frame-support/no-metadata-docs"]
# more types in the metadata.
full-metadata-docs = ["frame-support/full-metadata-docs"]

tracing = ["module-evm/tracing", "module-evm-rpc-runtime-api/tracing"]
tracing = ["module-evm/tracing", "module-evm-rpc-runtime-api/tracing", "runtime-common/tracing"]
12 changes: 10 additions & 2 deletions runtime/acala/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2535,7 +2535,11 @@ impl Convert<(RuntimeCall, SignedExtra), Result<(EthereumTransactionMessage, Sig
valid_until,
}) => {
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,7 +2584,11 @@ impl Convert<(RuntimeCall, SignedExtra), Result<(EthereumTransactionMessage, Sig
decode_gas_price(gas_price, gas_limit, TxFeePerGasV2::get()).ok_or(InvalidTransaction::Stale)?;

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
1 change: 1 addition & 0 deletions runtime/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,4 @@ wasm-bench = [
runtime-benchmarks = [
"orml-oracle/runtime-benchmarks"
]
tracing = []
10 changes: 8 additions & 2 deletions runtime/common/src/check_nonce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,10 @@ where
let evm_nonce = module_evm::Accounts::<T>::get(address)
.map(|x| x.nonce)
.unwrap_or_default();
if self.nonce != evm_nonce {

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 {
Expand Down Expand Up @@ -155,7 +158,10 @@ where
let evm_nonce = module_evm::Accounts::<T>::get(address)
.map(|x| x.nonce)
.unwrap_or_default();
if self.nonce < evm_nonce {

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

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
2 changes: 1 addition & 1 deletion runtime/karura/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -423,4 +423,4 @@ no-metadata-docs = ["frame-support/no-metadata-docs"]
# more types in the metadata.
full-metadata-docs = ["frame-support/full-metadata-docs"]

tracing = ["module-evm/tracing", "module-evm-rpc-runtime-api/tracing"]
tracing = ["module-evm/tracing", "module-evm-rpc-runtime-api/tracing", "runtime-common/tracing"]
12 changes: 10 additions & 2 deletions runtime/karura/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2561,7 +2561,11 @@ impl Convert<(RuntimeCall, SignedExtra), Result<(EthereumTransactionMessage, Sig
valid_until,
}) => {
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,7 +2610,11 @@ impl Convert<(RuntimeCall, SignedExtra), Result<(EthereumTransactionMessage, Sig
decode_gas_price(gas_price, gas_limit, TxFeePerGasV2::get()).ok_or(InvalidTransaction::Stale)?;

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
2 changes: 1 addition & 1 deletion runtime/mandala/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -447,4 +447,4 @@ no-metadata-docs = ["frame-support/no-metadata-docs"]
# more types in the metadata.
full-metadata-docs = ["frame-support/full-metadata-docs"]

tracing = ["module-evm/tracing", "module-evm-rpc-runtime-api/tracing"]
tracing = ["module-evm/tracing", "module-evm-rpc-runtime-api/tracing", "runtime-common/tracing"]
12 changes: 10 additions & 2 deletions runtime/mandala/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1920,7 +1920,11 @@ impl Convert<(RuntimeCall, SignedExtra), Result<(EthereumTransactionMessage, Sig
valid_until,
}) => {
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,7 +1969,11 @@ impl Convert<(RuntimeCall, SignedExtra), Result<(EthereumTransactionMessage, Sig
decode_gas_price(gas_price, gas_limit, TxFeePerGasV2::get()).ok_or(InvalidTransaction::Stale)?;

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
Loading