Skip to content

Commit db3c4af

Browse files
Move NativeSystemAccountProvider to pallet-evm
1 parent 7086528 commit db3c4af

9 files changed

Lines changed: 29 additions & 31 deletions

File tree

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frame/ethereum/src/mock.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ impl AddressMapping<AccountId32> for HashedAddressMapping {
152152
}
153153

154154
impl pallet_evm::Config for Test {
155-
type AccountProvider = fp_evm::NativeSystemAccountProvider<Self>;
155+
type AccountProvider = pallet_evm::NativeSystemAccountProvider<Self>;
156156
type FeeCalculator = FixedGasPrice;
157157
type GasWeightMapping = pallet_evm::FixedGasWeightMapping<Self>;
158158
type WeightPerGas = WeightPerGas;

frame/evm/precompile/dispatch/src/mock.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ parameter_types! {
139139
pub WeightPerGas: Weight = Weight::from_ref_time(20_000);
140140
}
141141
impl pallet_evm::Config for Test {
142-
type AccountProvider = fp_evm::NativeSystemAccountProvider<Self>;
142+
type AccountProvider = pallet_evm::NativeSystemAccountProvider<Self>;
143143
type FeeCalculator = FixedGasPrice;
144144
type GasWeightMapping = pallet_evm::FixedGasWeightMapping<Self>;
145145
type WeightPerGas = WeightPerGas;

frame/evm/src/lib.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -916,3 +916,27 @@ impl<T> OnCreate<T> for Tuple {
916916
)*)
917917
}
918918
}
919+
920+
/// Native system account provider that `frame_system` provides.
921+
pub struct NativeSystemAccountProvider<T>(sp_std::marker::PhantomData<T>);
922+
923+
impl<T: frame_system::Config> AccountProvider for NativeSystemAccountProvider<T> {
924+
type AccountId = T::AccountId;
925+
type Index = T::Index;
926+
927+
fn account_nonce(who: &Self::AccountId) -> Self::Index {
928+
frame_system::Pallet::<T>::account_nonce(&who)
929+
}
930+
931+
fn inc_account_nonce(who: &Self::AccountId) {
932+
frame_system::Pallet::<T>::inc_account_nonce(&who)
933+
}
934+
935+
fn create_account(who: &Self::AccountId) {
936+
let _ = frame_system::Pallet::<T>::inc_sufficients(&who);
937+
}
938+
fn remove_account(who: &Self::AccountId) {
939+
let _ = frame_system::Pallet::<T>::dec_sufficients(&who);
940+
}
941+
}
942+

frame/evm/src/mock.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ parameter_types! {
132132
pub MockPrecompiles: MockPrecompileSet = MockPrecompileSet;
133133
}
134134
impl crate::Config for Test {
135-
type AccountProvider = fp_evm::NativeSystemAccountProvider<Self>;
135+
type AccountProvider = crate::NativeSystemAccountProvider<Self>;
136136
type FeeCalculator = FixedGasPrice;
137137
type GasWeightMapping = crate::FixedGasWeightMapping<Self>;
138138
type WeightPerGas = WeightPerGas;

primitives/evm/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ scale-codec = { package = "parity-scale-codec", workspace = true }
1616
serde = { workspace = true, optional = true }
1717
# Substrate
1818
frame-support = { workspace = true }
19-
frame-system = { workspace = true }
2019
sp-core = { workspace = true }
2120
sp-runtime = { workspace = true }
2221
sp-std = { workspace = true }
@@ -30,7 +29,6 @@ std = [
3029
"scale-codec/std",
3130
# Substrate
3231
"frame-support/std",
33-
"frame-system/std",
3432
"sp-core/std",
3533
"sp-runtime/std",
3634
"sp-std/std",

primitives/evm/src/account_provider.rs

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -39,26 +39,3 @@ pub trait AccountProvider {
3939
/// Incremented with each new transaction submitted by the account.
4040
fn inc_account_nonce(who: &Self::AccountId);
4141
}
42-
43-
/// Native system account provider that `frame_system` provides.
44-
pub struct NativeSystemAccountProvider<T>(sp_std::marker::PhantomData<T>);
45-
46-
impl<T: frame_system::Config> AccountProvider for NativeSystemAccountProvider<T> {
47-
type AccountId = T::AccountId;
48-
type Index = T::Index;
49-
50-
fn account_nonce(who: &Self::AccountId) -> Self::Index {
51-
frame_system::Pallet::<T>::account_nonce(&who)
52-
}
53-
54-
fn inc_account_nonce(who: &Self::AccountId) {
55-
frame_system::Pallet::<T>::inc_account_nonce(&who)
56-
}
57-
58-
fn create_account(who: &Self::AccountId) {
59-
let _ = frame_system::Pallet::<T>::inc_sufficients(&who);
60-
}
61-
fn remove_account(who: &Self::AccountId) {
62-
let _ = frame_system::Pallet::<T>::dec_sufficients(&who);
63-
}
64-
}

primitives/evm/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub use evm::{
3535
};
3636

3737
pub use self::{
38-
account_provider::{AccountProvider, NativeSystemAccountProvider},
38+
account_provider::AccountProvider,
3939
precompile::{
4040
Context, ExitError, ExitRevert, ExitSucceed, LinearCostPrecompile, Precompile,
4141
PrecompileFailure, PrecompileHandle, PrecompileOutput, PrecompileResult, PrecompileSet,

template/runtime/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ parameter_types! {
326326
}
327327

328328
impl pallet_evm::Config for Runtime {
329-
type AccountProvider = fp_evm::NativeSystemAccountProvider<Self>;
329+
type AccountProvider = pallet_evm::NativeSystemAccountProvider<Self>;
330330
type FeeCalculator = BaseFee;
331331
type GasWeightMapping = pallet_evm::FixedGasWeightMapping<Self>;
332332
type WeightPerGas = WeightPerGas;

0 commit comments

Comments
 (0)