Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into fix-eip2930
Browse files Browse the repository at this point in the history
  • Loading branch information
zjb0807 committed Feb 14, 2025
2 parents b8363bb + 41a10b7 commit 58e9fd0
Show file tree
Hide file tree
Showing 35 changed files with 212 additions and 161 deletions.
18 changes: 0 additions & 18 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion modules/auction-manager/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ impl<T: Config> Pallet<T> {
let mut to_be_continue = StorageValueRef::persistent(OFFCHAIN_WORKER_DATA);

// get to_be_continue record,
// if it exsits, iterator map storage start with previous key
// if it exists, iterator map storage start with previous key
let start_key = to_be_continue.get::<Vec<u8>>().unwrap_or_default();

// get the max iterationns config
Expand Down
2 changes: 1 addition & 1 deletion modules/collator-selection/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ pub mod pallet {
#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config> {
/// Invulnurable was updated.
/// Invulnerable was updated.
NewInvulnerables { new_invulnerables: Vec<T::AccountId> },
/// Desired candidates was updated.
NewDesiredCandidates { new_desired_candidates: u32 },
Expand Down
2 changes: 1 addition & 1 deletion modules/currencies/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2946,7 +2946,7 @@ fn sweep_dust_native_currency_works() {
},
));

// TODO: seems the insert directly does not work now, it's probably because of the new machanism of
// TODO: seems the insert directly does not work now, it's probably because of the new mechanism of
// provider and consumer: https://github.com/paritytech/substrate/blob/569aae5341ea0c1d10426fa1ec13a36c0b64393b/frame/system/src/lib.rs#L1692
// consider deposit_creating alive account, then decrease the ED to fix this test!
assert_eq!(
Expand Down
2 changes: 1 addition & 1 deletion modules/dex/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ pub mod module {
UnacceptableShareIncrement,
/// The liquidity withdrawn is unacceptable
UnacceptableLiquidityWithdrawn,
/// The swap dosen't meet the invariant check
/// The swap doesn't meet the invariant check
InvariantCheckFailed,
/// The Provision is unqualified to be converted to `Enabled`
UnqualifiedProvision,
Expand Down
12 changes: 6 additions & 6 deletions modules/evm-accounts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,13 +240,13 @@ impl<T: Config> Pallet<T> {

fn evm_account_domain_separator() -> [u8; 32] {
let domain_hash = keccak256!("EIP712Domain(string name,string version,uint256 chainId,bytes32 salt)");
let mut domain_seperator_msg = domain_hash.to_vec();
domain_seperator_msg.extend_from_slice(keccak256!("Acala EVM claim")); // name
domain_seperator_msg.extend_from_slice(keccak256!("1")); // version
domain_seperator_msg.extend_from_slice(&to_bytes(T::ChainId::get())); // chain id
domain_seperator_msg
let mut domain_separator_msg = domain_hash.to_vec();
domain_separator_msg.extend_from_slice(keccak256!("Acala EVM claim")); // name
domain_separator_msg.extend_from_slice(keccak256!("1")); // version
domain_separator_msg.extend_from_slice(&to_bytes(T::ChainId::get())); // chain id
domain_separator_msg
.extend_from_slice(frame_system::Pallet::<T>::block_hash(BlockNumberFor::<T>::zero()).as_ref()); // genesis block hash
keccak_256(domain_seperator_msg.as_slice())
keccak_256(domain_separator_msg.as_slice())
}

fn do_claim_default_evm_address(who: T::AccountId) -> Result<EvmAddress, DispatchError> {
Expand Down
2 changes: 1 addition & 1 deletion modules/evm-utility/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

//! # Evm utiltity Module
//! # Evm utility Module
//!
//! A pallet provides some utility methods.
Expand Down
6 changes: 3 additions & 3 deletions modules/evm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -719,14 +719,14 @@ pub mod module {
ensure_root(origin)?;

let _from_account = T::AddressMapping::get_account_id(&from);
let _payed: NegativeImbalanceOf<T>;
let _paid: NegativeImbalanceOf<T>;
#[cfg(not(feature = "with-ethereum-compatibility"))]
{
// unreserve the transaction fee for gas_limit
let weight = T::GasToWeight::convert(gas_limit);
let (_, imbalance) = T::ChargeTransactionPayment::unreserve_and_charge_fee(&_from_account, weight)
.map_err(|_| Error::<T>::ChargeFeeFailed)?;
_payed = imbalance;
_paid = imbalance;
}

match T::Runner::call(
Expand Down Expand Up @@ -786,7 +786,7 @@ pub mod module {
let res = T::ChargeTransactionPayment::refund_fee(
&_from_account,
T::GasToWeight::convert(refund_gas),
_payed,
_paid,
);
debug_assert!(res.is_ok());
}
Expand Down
10 changes: 5 additions & 5 deletions modules/evm/src/runner/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1625,7 +1625,7 @@ impl<'inner, 'config, 'precompiles, S: StackState<'config>, P: PrecompileSet> Pr
self.executor.state.refund_external_cost(ref_time, proof_size);
}

/// Retreive the remaining gas.
/// Retrieve the remaining gas.
fn remaining_gas(&self) -> u64 {
self.executor.state.metadata().gasometer.gas()
}
Expand All @@ -1635,17 +1635,17 @@ impl<'inner, 'config, 'precompiles, S: StackState<'config>, P: PrecompileSet> Pr
Handler::log(self.executor, address, topics, data)
}

/// Retreive the code address (what is the address of the precompile being called).
/// Retrieve the code address (what is the address of the precompile being called).
fn code_address(&self) -> H160 {
self.code_address
}

/// Retreive the input data the precompile is called with.
/// Retrieve the input data the precompile is called with.
fn input(&self) -> &[u8] {
self.input
}

/// Retreive the context in which the precompile is executed.
/// Retrieve the context in which the precompile is executed.
fn context(&self) -> &Context {
self.context
}
Expand All @@ -1655,7 +1655,7 @@ impl<'inner, 'config, 'precompiles, S: StackState<'config>, P: PrecompileSet> Pr
self.is_static
}

/// Retreive the gas limit of this call.
/// Retrieve the gas limit of this call.
fn gas_limit(&self) -> Option<u64> {
self.gas_limit
}
Expand Down
2 changes: 1 addition & 1 deletion modules/idle-scheduler/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ fn can_process_tasks_up_to_weight_limit() {
Weight::from_parts(100_002_000_000, 0) + <()>::on_idle_base() + (<()>::clear_tasks() * 2),
);

// Due to hashing, excution is not guaranteed to be in order.
// Due to hashing, execution is not guaranteed to be in order.
assert_eq!(
Tasks::<Runtime>::get(0),
Some(ScheduledTasks::BalancesTask(BalancesTask::OnIdle))
Expand Down
2 changes: 1 addition & 1 deletion modules/incentives/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1168,7 +1168,7 @@ fn transfer_reward_and_update_rewards_storage_atomically_when_accumulate_incenti
vec![(PoolId::Loans(LDOT), vec![(ACA, 30), (AUSD, 90)]),],
));

// accumulate ACA and AUSD failed, because pool dosen't exist
// accumulate ACA and AUSD failed, because pool doesn't exist
IncentivesModule::accumulate_incentives(PoolId::Loans(LDOT));
assert_eq!(
orml_rewards::PoolInfos::<Runtime>::contains_key(PoolId::Dex(LDOT)),
Expand Down
2 changes: 1 addition & 1 deletion modules/prices/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
//! The data from Oracle cannot be used in business, prices module will do some
//! process and feed prices for Acala. Process include:
//! - specify a fixed price for stable currency
//! - feed price in USD or related price bewteen two currencies
//! - feed price in USD or related price between two currencies
//! - lock/unlock the price data get from oracle
#![cfg_attr(not(feature = "std"), no_std)]
Expand Down
2 changes: 1 addition & 1 deletion modules/support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ pub trait TransactionPayment<AccountId, Balance, NegativeImbalance> {
who: &AccountId,
weight: Weight,
) -> Result<(Balance, NegativeImbalance), TransactionValidityError>;
fn refund_fee(who: &AccountId, weight: Weight, payed: NegativeImbalance) -> Result<(), TransactionValidityError>;
fn refund_fee(who: &AccountId, weight: Weight, paid: NegativeImbalance) -> Result<(), TransactionValidityError>;
fn charge_fee(
who: &AccountId,
len: u32,
Expand Down
12 changes: 2 additions & 10 deletions modules/support/src/mocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,7 @@ impl<AccountId, Balance: Default + Copy, NegativeImbalance: Imbalance<Balance>>
Ok((Default::default(), Imbalance::zero()))
}

fn refund_fee(
_who: &AccountId,
_weight: Weight,
_payed: NegativeImbalance,
) -> Result<(), TransactionValidityError> {
fn refund_fee(_who: &AccountId, _weight: Weight, _paid: NegativeImbalance) -> Result<(), TransactionValidityError> {
Ok(())
}

Expand Down Expand Up @@ -185,11 +181,7 @@ impl<
Ok((Default::default(), Imbalance::zero()))
}

fn refund_fee(
_who: &AccountId,
_weight: Weight,
_payed: NegativeImbalance,
) -> Result<(), TransactionValidityError> {
fn refund_fee(_who: &AccountId, _weight: Weight, _paid: NegativeImbalance) -> Result<(), TransactionValidityError> {
Ok(())
}

Expand Down
30 changes: 15 additions & 15 deletions modules/transaction-payment/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,10 @@ pub mod module {
/// transaction fee paid, the second is the tip paid, if any.
type OnTransactionPayment: OnUnbalanced<NegativeImbalanceOf<Self>>;

/// A fee mulitplier for `Operational` extrinsics to compute "virtual tip" to boost their
/// A fee multiplier for `Operational` extrinsics to compute "virtual tip" to boost their
/// `priority`
///
/// This value is multipled by the `final_fee` to obtain a "virtual tip" that is later
/// This value is multiplied by the `final_fee` to obtain a "virtual tip" that is later
/// added to a tip component in regular `priority` calculations.
/// It means that a `Normal` transaction can front-run a similarly-sized `Operational`
/// extrinsic (with no tip), by including a tip value greater than the virtual tip.
Expand Down Expand Up @@ -373,19 +373,19 @@ pub mod module {
/// Weight information for the extrinsics in this module.
type WeightInfo: WeightInfo;

/// PalletId used to derivate sub account.
/// PalletId used to derivative sub account.
#[pallet::constant]
type PalletId: Get<PalletId>;

/// Treasury account used to transfer balance to sub account of `PalletId`.
#[pallet::constant]
type TreasuryAccount: Get<Self::AccountId>;

/// Custom fee surplus if not payed with native asset.
/// Custom fee surplus if not paid with native asset.
#[pallet::constant]
type CustomFeeSurplus: Get<Percent>;

/// Alternative fee surplus if not payed with native asset.
/// Alternative fee surplus if not paid with native asset.
#[pallet::constant]
type AlternativeFeeSurplus: Get<Percent>;

Expand Down Expand Up @@ -1155,7 +1155,7 @@ where
Ok(())
}

/// The sub account derivated by `PalletId`.
/// The sub account derivatived by `PalletId`.
fn sub_account_id(id: CurrencyId) -> T::AccountId {
T::PalletId::get().into_sub_account_truncating(id)
}
Expand Down Expand Up @@ -1516,7 +1516,7 @@ where
len: usize,
_result: &DispatchResult,
) -> Result<(), TransactionValidityError> {
if let Some((tip, who, Some(payed), fee, surplus)) = pre {
if let Some((tip, who, Some(paid), fee, surplus)) = pre {
let actual_fee = Pallet::<T>::compute_actual_fee(len as u32, info, post_info, tip);
let refund_fee = fee.saturating_sub(actual_fee);
let mut refund = refund_fee;
Expand All @@ -1543,17 +1543,17 @@ where

let actual_payment = match <T as Config>::Currency::deposit_into_existing(&who, refund) {
Ok(refund_imbalance) => {
// The refund cannot be larger than the up front payed max weight.
// The refund cannot be larger than the up front paid max weight.
// `PostDispatchInfo::calc_unspent` guards against such a case.
match payed.offset(refund_imbalance) {
match paid.offset(refund_imbalance) {
SameOrOther::Same(actual_payment) => actual_payment,
SameOrOther::None => Default::default(),
_ => return Err(InvalidTransaction::Payment.into()),
}
}
// We do not recreate the account using the refund. The up front payment
// is gone in that case.
Err(_) => payed,
Err(_) => paid,
};
let (tip, fee) = actual_payment.split(actual_tip);

Expand Down Expand Up @@ -1624,23 +1624,23 @@ where
fn refund_fee(
who: &T::AccountId,
refund_weight: Weight,
payed: NegativeImbalanceOf<T>,
paid: NegativeImbalanceOf<T>,
) -> Result<(), TransactionValidityError> {
log::debug!(target: LOG_TARGET, "refund_fee: who: {:?}, refund_weight: {:?}, payed: {:?}", who, refund_weight, payed.peek());
log::debug!(target: LOG_TARGET, "refund_fee: who: {:?}, refund_weight: {:?}, paid: {:?}", who, refund_weight, paid.peek());

let refund = Pallet::<T>::weight_to_fee(refund_weight);
let actual_payment = match <T as Config>::Currency::deposit_into_existing(who, refund) {
Ok(refund_imbalance) => {
// The refund cannot be larger than the up front payed max weight.
match payed.offset(refund_imbalance) {
// The refund cannot be larger than the up front paid max weight.
match paid.offset(refund_imbalance) {
SameOrOther::Same(actual_payment) => actual_payment,
SameOrOther::None => Default::default(),
_ => return Err(InvalidTransaction::Payment.into()),
}
}
// We do not recreate the account using the refund. The up front payment
// is gone in that case.
Err(_) => payed,
Err(_) => paid,
};

// distribute fee
Expand Down
4 changes: 2 additions & 2 deletions modules/xcm-interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ pub mod module {
fn withdraw_unbonded_from_sub_account(sub_account_index: u16, amount: Balance) -> DispatchResult {
let (xcm_dest_weight, xcm_fee) = Self::xcm_dest_weight_and_fee(XcmInterfaceOperation::HomaWithdrawUnbonded);

// TODO: config xcm_dest_weight and fee for withdraw_unbonded and transfer seperately.
// Temperarily use double fee.
// TODO: config xcm_dest_weight and fee for withdraw_unbonded and transfer separately.
// Temporarily use double fee.
let xcm_message = T::RelayChainCallBuilder::finalize_multiple_calls_into_xcm_message(
vec![
(
Expand Down
18 changes: 9 additions & 9 deletions primitives/src/unchecked_extrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ where
target: "evm", "tx msg: {:?}", msg
);

let msg_hash = msg.hash(); // TODO: consider rewirte this to use `keccak_256` for hashing because it could be faster
let msg_hash = msg.hash(); // TODO: consider rewrite this to use `keccak_256` for hashing because it could be faster

let signer = recover_signer(&sig, msg_hash.as_fixed_bytes()).ok_or(InvalidTransaction::BadProof)?;

Expand Down Expand Up @@ -189,7 +189,7 @@ where
target: "evm", "tx msg: {:?}", msg
);

let msg_hash = msg.hash(); // TODO: consider rewirte this to use `keccak_256` for hashing because it could be faster
let msg_hash = msg.hash(); // TODO: consider rewrite this to use `keccak_256` for hashing because it could be faster

let signer = recover_signer(&sig, msg_hash.as_fixed_bytes()).ok_or(InvalidTransaction::BadProof)?;

Expand Down Expand Up @@ -237,7 +237,7 @@ where
target: "evm", "tx msg: {:?}", msg
);

let msg_hash = msg.hash(); // TODO: consider rewirte this to use `keccak_256` for hashing because it could be faster
let msg_hash = msg.hash(); // TODO: consider rewrite this to use `keccak_256` for hashing because it could be faster

let signer = recover_signer(&sig, msg_hash.as_fixed_bytes()).ok_or(InvalidTransaction::BadProof)?;

Expand Down Expand Up @@ -331,12 +331,12 @@ fn verify_eip712_signature(eth_msg: EthereumTransactionMessage, sig: [u8; 65]) -
let access_list_type_hash = keccak256!("AccessList(address address,uint256[] storageKeys)");
let tx_type_hash = keccak256!("Transaction(string action,address to,uint256 nonce,uint256 tip,bytes data,uint256 value,uint256 gasLimit,uint256 storageLimit,AccessList[] accessList,uint256 validUntil)AccessList(address address,uint256[] storageKeys)");

let mut domain_seperator_msg = domain_hash.to_vec();
domain_seperator_msg.extend_from_slice(keccak256!("Acala EVM")); // name
domain_seperator_msg.extend_from_slice(keccak256!("1")); // version
domain_seperator_msg.extend_from_slice(&to_bytes(eth_msg.chain_id)); // chain id
domain_seperator_msg.extend_from_slice(eth_msg.genesis.as_bytes()); // salt
let domain_separator = keccak_256(domain_seperator_msg.as_slice());
let mut domain_separator_msg = domain_hash.to_vec();
domain_separator_msg.extend_from_slice(keccak256!("Acala EVM")); // name
domain_separator_msg.extend_from_slice(keccak256!("1")); // version
domain_separator_msg.extend_from_slice(&to_bytes(eth_msg.chain_id)); // chain id
domain_separator_msg.extend_from_slice(eth_msg.genesis.as_bytes()); // salt
let domain_separator = keccak_256(domain_separator_msg.as_slice());

let mut tx_msg = tx_type_hash.to_vec();
match eth_msg.action {
Expand Down
Loading

0 comments on commit 58e9fd0

Please sign in to comment.