Skip to content

Conversation

@dmitrylavrenov
Copy link
Contributor

@dmitrylavrenov dmitrylavrenov commented Mar 5, 2024

The goal of this PR is to expose account related logic that pallet_evm required to control accounts existence in the network and their transactions uniqueness. By default, the pallet operates native system accounts records that frame_system provides.

The interface allow any custom account provider logic to be used instead of just using frame_system account provider. The accounts records should store nonce value for each account at least.

Related to #1331

cc @MOZGIII

@dmitrylavrenov dmitrylavrenov marked this pull request as ready for review March 5, 2024 16:47
@dmitrylavrenov dmitrylavrenov requested a review from sorpaas as a code owner March 5, 2024 16:47
@MOZGIII
Copy link
Contributor

MOZGIII commented Mar 15, 2024

Some context: this implementation has been used by the Humanode network for a while now, and we got tired of maintaining these patches in our own fork. It is our hope to merge this in the upstream such that:

  1. Our contribution is shared with the broader community, we believe this would be useful as an option to apply the EVM integration.
  2. We can avoid doing double work of applying upgrades and changes that frontier applies.
  3. We could get feedback from the upstream on our implementation of the approach we chose.

@boundless-forest
Copy link
Collaborator

Some context: this implementation has been used by the Humanode network for a while now, and we got tired of maintaining these patches in our own fork

Totally understand. I think it would be possible to accept the changes that abstract the operations related to the account into a pallet config(trait), but it makes no sense to include the pallet-evm-system implementation in your another pr in the frontier repo, as it will increase the maintenance burden, most of the downstream frontier users don't have that need. Exposing the trait and keeping the implementation on your side is a preferable way in my opinion. what do you think?

@MOZGIII
Copy link
Contributor

MOZGIII commented Mar 15, 2024

This would work for us. The reason why we are adding pallet-evm-system is that it is a very basic implementation of the independent accounts system that is required for this trait to make sense. We are worried that it will be difficult to maintain this trait without a buddy crate that would use it, at least with the mock tests.

So, the main rationale for merging both is to actually ensure the code doesn't break.

There are a lot of other things we'd suggest upstreaming, like a custom balances implementation that can work with the pallet-evm-system setting - that one, in our opinion, is something that we'd probably be able to leave out in our fork still.

@dmitrylavrenov
Copy link
Contributor Author

dmitrylavrenov commented Aug 20, 2024

@boundless-forest @crystalin @koushiro any updates ?

Will be ready to rebase after getting your feedback as I would like to merge it.

@boundless-forest
Copy link
Collaborator

Will be ready to rebase after getting your feedback as I would like to merge it.

I reviewed your solution regarding the pallet-evm-system and pallet-evm-balances. In my understanding, the chain has two account systems (currently, there is only one substrate account system in essence). The questions are as follows:

  1. How can tokens be exchanged between these two account systems? For example, if I have an AccountId32 A in the native account and another H160 account in the EvmSystem or EvmBalance, I assume there would be an additional bridge to facilitate transfers or withdrawals between these two accounts, correct? If so, I see little difference compared to the current mapping method. The bridge mentioned above is equivalent to mapping and then transferring.
  2. For the existing running chains with AccountId32, the H160 account information is stored in the native modules, which may require migration to your designed system and balance pallets.
  3. This solution will disrupt the dispatch precompile, which is used in several projects I know of. Since there is no mapping from H160 to AccountId32, it requires a valid origin for the substrate call underneath.

As for the chains with H160 account systems as the default, since they do not require account mapping, your solution does not change the way they operate.

The Frontier repo lacks reviewers and maintainers. I'm also quite frustrated about this. We need more people involved in the issue and PR discussions.

@MOZGIII
Copy link
Contributor

MOZGIII commented Aug 21, 2024

  1. How can tokens be exchanged between these two account systems? For example, if I have an AccountId32 A in the native account and another H160 account in the EvmSystem or EvmBalance, I assume there would be an additional bridge to facilitate transfers or withdrawals between these two accounts, correct? If so, I see little difference compared to the current mapping method. The bridge mentioned above is equivalent to mapping and then transferring.

There is a huge difference in that with separate account systems there is no trying to retrofit AccountId20 into AccountId32, and also no possibility of the confusing interactions between other pallets and EVM - EVM accounts are completely isolated in their own system, with only explicitly implemented pathways to interact with the native system.

  1. For the existing running chains with AccountId32, the H160 account information is stored in the native modules, which may require migration to your designed system and balance pallets.

This is not intended to be deployed to either preexisting chains - neither for the ones using the mixed accounts in the system table with the EVM address mappings, not for the ones using the EVM-native AccountId20 as AccountId.

This is for the new chains, and for Humanode which is running this setup in mainnet for a couple years now.

  1. This solution will disrupt the dispatch precompile, which is used in several projects I know of. Since there is no mapping from H160 to AccountId32, it requires a valid origin for the substrate call underneath.

This solution does not replace the account mappings though - they can still be used; we wanted it explicitly because we dislike the mappings system and the implications of mixing those with respect to the RPCs and our (Huamnode) chain's sybil-attack mechanisms.

As for the chains with H160 account systems as the default, since they do not require account mapping, your solution does not change the way they operate.

Yep. For the mixed accounts too - this adds an entirely new way to set things up.


You can inspect how this works in practice at Humanode chain:

Upstreaming this is really important to us, as we plan to further expand our investment into Frontier codebase and having too many custom patches is starting to slow us down. For instance, we'd be interested in working on proper EVM tracing support - but currently we're stalled by this upstreaming.

The Frontier repo lacks reviewers and maintainers. I'm also quite frustrated about this. We need more people involved in the issue and PR discussions.

We could aid acting act in this capacity at some point in the future as our involvement in Frontier and resource capacity grows.

@boundless-forest
Copy link
Collaborator

boundless-forest commented Aug 23, 2024

This is for the new chains, and for Humanode which is running this setup in mainnet for a couple years now.

Considering that many chains have been setup based on the current path and have been running in production for several years. I suggest we merge these traits so your team doesn't need to maintain and pick during the frontier upgrade process. For the pallet-evm-system and pallet-evm-balances, you can place them into your node runtime repo to reduce your maintenance burden. Is this approach acceptable for your team?

I suggest submitting an issue to gather feedback from the community members regarding your team's solution the evm-system and evm-balances. If many believe this is a preferable, we can consider including it in this repo.

@dmitrylavrenov
Copy link
Contributor Author

dmitrylavrenov commented Sep 10, 2024

@boundless-forest @MOZGIII Just merged master including conflict resolution. Looks like we've agreed on merging account abstraction.

For the pallet-evm-system and pallet-evm-balances we can create an issue and discuss separately to avoid blocking this PR. What do you think?

@dmitrylavrenov dmitrylavrenov force-pushed the introduce-external-account-provider branch from 157661e to 6c97cbc Compare September 10, 2024 09:07
@boundless-forest boundless-forest merged commit d21ddc2 into polkadot-evm:master Sep 11, 2024
dnjscksdn98 added a commit to bifrost-platform/bifrost-frontier that referenced this pull request Sep 23, 2024
l0r1s pushed a commit to opentensor/frontier that referenced this pull request May 19, 2025
* Introduce account provider interface

* Use AccountProvider logic at pallet-evm

* Remove redundant ower type usage

* Fix fmt

* Fix clippy

* Fix clippy

* License at primitives/evm/src/account_provider.rs

* Rename NativeSystemAccountProvider to FrameSystemAccountProvider

* Formatting corrcetions at account_provider.rs

---------

Co-authored-by: MOZGIII <[email protected]>
dnjscksdn98 added a commit to bifrost-platform/bifrost-frontier that referenced this pull request Jul 25, 2025
dnjscksdn98 pushed a commit to bifrost-platform/bifrost-frontier that referenced this pull request Jul 25, 2025
* Introduce account provider interface

* Use AccountProvider logic at pallet-evm

* Remove redundant ower type usage

* Fix fmt

* Fix clippy

* Fix clippy

* License at primitives/evm/src/account_provider.rs

* Rename NativeSystemAccountProvider to FrameSystemAccountProvider

* Formatting corrcetions at account_provider.rs

---------

Co-authored-by: MOZGIII <[email protected]>
dnjscksdn98 added a commit to bifrost-platform/bifrost-frontier that referenced this pull request Jul 28, 2025
dnjscksdn98 pushed a commit to bifrost-platform/bifrost-frontier that referenced this pull request Jul 28, 2025
* Introduce account provider interface

* Use AccountProvider logic at pallet-evm

* Remove redundant ower type usage

* Fix fmt

* Fix clippy

* Fix clippy

* License at primitives/evm/src/account_provider.rs

* Rename NativeSystemAccountProvider to FrameSystemAccountProvider

* Formatting corrcetions at account_provider.rs

---------

Co-authored-by: MOZGIII <[email protected]>
dnjscksdn98 added a commit to bifrost-platform/bifrost-node that referenced this pull request Jul 29, 2025
alstjd0921 pushed a commit to bifrost-platform/bifrost-frontier that referenced this pull request Aug 14, 2025
alstjd0921 pushed a commit to bifrost-platform/bifrost-frontier that referenced this pull request Aug 14, 2025
* Introduce account provider interface

* Use AccountProvider logic at pallet-evm

* Remove redundant ower type usage

* Fix fmt

* Fix clippy

* Fix clippy

* License at primitives/evm/src/account_provider.rs

* Rename NativeSystemAccountProvider to FrameSystemAccountProvider

* Formatting corrcetions at account_provider.rs

---------

Co-authored-by: MOZGIII <[email protected]>
alstjd0921 pushed a commit to bifrost-platform/bifrost-node that referenced this pull request Sep 10, 2025
alstjd0921 added a commit to bifrost-platform/bifrost-node that referenced this pull request Sep 10, 2025
* NODE-161, deps: update to stable2503

* NODE-161, fix: node: Replace TxPool RPC with Frontier implementation #moonbeam-foundation/moonbeam#3218

* NODE-161, fix: runtime: Fix weight limits in evm tracing runtimes (moonbeam-foundation/moonbeam#3210)

* NODE-161, deps: update Cargo

* NODE-161, fix: Use DecodeWithMemTracking (paritytech/polkadot-sdk#7360)

* NODE-161, feat: runtime: upgrade to EIP-7702 new APIs

* NODE-161, Introduce a gas-based Storage limit per tx (polkadot-evm/frontier#1142), Support external account provider (polkadot-evm/frontier#1329)

* NODE-161, fix: remove sc_transaction_pool

* NODE-161, fix: add missing crates

* NODE-161, fix: resolve typo

* NODE-161, fix: remove Paramter

* NODE-161, feat: Allow whitleisting contract deployer (polkadot-evm/frontier#1629)

* NODE-161, feat: Update Treasury to Support Relay Chain Block Number Provider (paritytech/polkadot-sdk#3970)

* NODE-161, feat: [Identity] Decouple usernames from identities (paritytech/polkadot-sdk#5554)

* NODE-161, feat: Collective: dynamic deposit based on number of proposals (paritytech/polkadot-sdk#3151)

* NODE-161, fix: add missing DecodeWithMemTracking

* NODE-161, feat: Moves disabling logic into pallet-session (paritytech/polkadot-sdk#7581)

* NODE-161, feat: Update Scheduler to have a configurable block provider (paritytech/polkadot-sdk#7441)

* NODE-161, chore: add WeightInfo to pallet_transaction_payment

* NODE-161, fix: add missing authorization_list

* NODE-161, fix: replace to new_bare

* NODE-161, fix: add missing DecodeWithMemTracking derive

* NODE-161, fix: resolve type mismatch

* NODE-161, fix: use system_version (paritytech/polkadot-sdk#4257)

* NODE-161, fix: use Cow (paritytech/polkadot-sdk#5693)

* NODE-161, feat: Generic slashing side-effects (paritytech/polkadot-sdk#5623)

* NODE-161, feat: impl create_inherent (paritytech/polkadot-sdk#3685)

* NODE-161, fix: remove generic parameter from on_unbalanceds

* NODE-161, fix: update storage_at runtime api

* NODE-161, fix: node: Remove network starter that is no longer needed (paritytech/polkadot-sdk#6400)

* NODE-161, fix: node: update FullNetworkConfiguration params

* NODE-161, fix: node: update TransactionPool

* NODE-161, fix: node: substrate-offchain: upgrade hyper to v1 (paritytech/polkadot-sdk#5919)

* NODE-161, fix: node: update service, rpc

* NODE-161, chore: remove unused imports

* chore: add cargo feature "metadata-hash"

* NODE-161, fix: add cumulus primitives storage proof size HostFunctions

* NODE-161, chore: update dependencies branch

* NODE-161, chore: update to stable2506

* NODE-161, chore: remove `RuntimeEvent` from pallet::Config

* NODE-161, fix: update test code

* NODE-161, fix: make node-lts compatible

* NODE-161, chore: update `test_btc_registration_pool.ts`

* NODE-161, chore: update `test_btc_registration_pool.ts`

* NODE-161, chore: update `test_btc_registration_pool.ts`

* NODE-161, fix: use node.kill()

* NODE-161, fix: resolve test codes

* NODE-161, fix: remove console.log

* NODE-161, chore: update tools package.json

* feat: init blaze

* fix: remove unused crate

* import precompile-blaze

* NODE-161, chore: add mbm migrator into runtimes

* NODE-161, chore: add pallet_session migration

* NODE-161, fix: new_full_parts -> new_full_parts_record_import

* fix: resolve issues

* NODE-161, deps: update runtime version (489)

---------

Co-authored-by: dnjscksdn98 <[email protected]>
alstjd0921 added a commit to bifrost-platform/bifrost-node that referenced this pull request Sep 10, 2025
* Node 161 pectra update (#126)

* NODE-161, deps: update to stable2503

* NODE-161, fix: node: Replace TxPool RPC with Frontier implementation #moonbeam-foundation/moonbeam#3218

* NODE-161, fix: runtime: Fix weight limits in evm tracing runtimes (moonbeam-foundation/moonbeam#3210)

* NODE-161, deps: update Cargo

* NODE-161, fix: Use DecodeWithMemTracking (paritytech/polkadot-sdk#7360)

* NODE-161, feat: runtime: upgrade to EIP-7702 new APIs

* NODE-161, Introduce a gas-based Storage limit per tx (polkadot-evm/frontier#1142), Support external account provider (polkadot-evm/frontier#1329)

* NODE-161, fix: remove sc_transaction_pool

* NODE-161, fix: add missing crates

* NODE-161, fix: resolve typo

* NODE-161, fix: remove Paramter

* NODE-161, feat: Allow whitleisting contract deployer (polkadot-evm/frontier#1629)

* NODE-161, feat: Update Treasury to Support Relay Chain Block Number Provider (paritytech/polkadot-sdk#3970)

* NODE-161, feat: [Identity] Decouple usernames from identities (paritytech/polkadot-sdk#5554)

* NODE-161, feat: Collective: dynamic deposit based on number of proposals (paritytech/polkadot-sdk#3151)

* NODE-161, fix: add missing DecodeWithMemTracking

* NODE-161, feat: Moves disabling logic into pallet-session (paritytech/polkadot-sdk#7581)

* NODE-161, feat: Update Scheduler to have a configurable block provider (paritytech/polkadot-sdk#7441)

* NODE-161, chore: add WeightInfo to pallet_transaction_payment

* NODE-161, fix: add missing authorization_list

* NODE-161, fix: replace to new_bare

* NODE-161, fix: add missing DecodeWithMemTracking derive

* NODE-161, fix: resolve type mismatch

* NODE-161, fix: use system_version (paritytech/polkadot-sdk#4257)

* NODE-161, fix: use Cow (paritytech/polkadot-sdk#5693)

* NODE-161, feat: Generic slashing side-effects (paritytech/polkadot-sdk#5623)

* NODE-161, feat: impl create_inherent (paritytech/polkadot-sdk#3685)

* NODE-161, fix: remove generic parameter from on_unbalanceds

* NODE-161, fix: update storage_at runtime api

* NODE-161, fix: node: Remove network starter that is no longer needed (paritytech/polkadot-sdk#6400)

* NODE-161, fix: node: update FullNetworkConfiguration params

* NODE-161, fix: node: update TransactionPool

* NODE-161, fix: node: substrate-offchain: upgrade hyper to v1 (paritytech/polkadot-sdk#5919)

* NODE-161, fix: node: update service, rpc

* NODE-161, chore: remove unused imports

* chore: add cargo feature "metadata-hash"

* NODE-161, fix: add cumulus primitives storage proof size HostFunctions

* NODE-161, chore: update dependencies branch

* NODE-161, chore: update to stable2506

* NODE-161, chore: remove `RuntimeEvent` from pallet::Config

* NODE-161, fix: update test code

* NODE-161, fix: make node-lts compatible

* NODE-161, chore: update `test_btc_registration_pool.ts`

* NODE-161, chore: update `test_btc_registration_pool.ts`

* NODE-161, chore: update `test_btc_registration_pool.ts`

* NODE-161, fix: use node.kill()

* NODE-161, fix: resolve test codes

* NODE-161, fix: remove console.log

* NODE-161, chore: update tools package.json

* feat: init blaze

* fix: remove unused crate

* import precompile-blaze

* NODE-161, chore: add mbm migrator into runtimes

* NODE-161, chore: add pallet_session migration

* NODE-161, fix: new_full_parts -> new_full_parts_record_import

* fix: resolve issues

* NODE-161, deps: update runtime version (489)

---------

Co-authored-by: dnjscksdn98 <[email protected]>

* NODE-80 branch restructure (#127)

* NODE-179, feat: init pallet storages

* NODE-179, feat: init pallet extrinsics

* NODE-179, chore: add locktime

* NODE-179, feat: finalize fee rate

* NODE-179, feature: impl coin selections

* NODE-179, feat: check blaze activation state

* NODE-179, feature: impl `remove_outbound_messages` for legacy mode

* NODE-80: implement benchmarking (#121)

* NODE-80, feature: impl benchmarking.rs & mock.rs

* NODE-80, fix: benchmark

* NODE-80, fix: benchmark

* NODE-80, chore: update weights

* fix: zero out proof size in weights

* chore: resolve

---------

Co-authored-by: dnjscksdn98 <[email protected]>

* fix: correctly use mocha with tsx (#133)

---------

Co-authored-by: dnjscksdn98 <[email protected]>
alstjd0921 added a commit to bifrost-platform/bifrost-node that referenced this pull request Sep 11, 2025
* Node 161 pectra update (#126)

* NODE-161, deps: update to stable2503

* NODE-161, fix: node: Replace TxPool RPC with Frontier implementation #moonbeam-foundation/moonbeam#3218

* NODE-161, fix: runtime: Fix weight limits in evm tracing runtimes (moonbeam-foundation/moonbeam#3210)

* NODE-161, deps: update Cargo

* NODE-161, fix: Use DecodeWithMemTracking (paritytech/polkadot-sdk#7360)

* NODE-161, feat: runtime: upgrade to EIP-7702 new APIs

* NODE-161, Introduce a gas-based Storage limit per tx (polkadot-evm/frontier#1142), Support external account provider (polkadot-evm/frontier#1329)

* NODE-161, fix: remove sc_transaction_pool

* NODE-161, fix: add missing crates

* NODE-161, fix: resolve typo

* NODE-161, fix: remove Paramter

* NODE-161, feat: Allow whitleisting contract deployer (polkadot-evm/frontier#1629)

* NODE-161, feat: Update Treasury to Support Relay Chain Block Number Provider (paritytech/polkadot-sdk#3970)

* NODE-161, feat: [Identity] Decouple usernames from identities (paritytech/polkadot-sdk#5554)

* NODE-161, feat: Collective: dynamic deposit based on number of proposals (paritytech/polkadot-sdk#3151)

* NODE-161, fix: add missing DecodeWithMemTracking

* NODE-161, feat: Moves disabling logic into pallet-session (paritytech/polkadot-sdk#7581)

* NODE-161, feat: Update Scheduler to have a configurable block provider (paritytech/polkadot-sdk#7441)

* NODE-161, chore: add WeightInfo to pallet_transaction_payment

* NODE-161, fix: add missing authorization_list

* NODE-161, fix: replace to new_bare

* NODE-161, fix: add missing DecodeWithMemTracking derive

* NODE-161, fix: resolve type mismatch

* NODE-161, fix: use system_version (paritytech/polkadot-sdk#4257)

* NODE-161, fix: use Cow (paritytech/polkadot-sdk#5693)

* NODE-161, feat: Generic slashing side-effects (paritytech/polkadot-sdk#5623)

* NODE-161, feat: impl create_inherent (paritytech/polkadot-sdk#3685)

* NODE-161, fix: remove generic parameter from on_unbalanceds

* NODE-161, fix: update storage_at runtime api

* NODE-161, fix: node: Remove network starter that is no longer needed (paritytech/polkadot-sdk#6400)

* NODE-161, fix: node: update FullNetworkConfiguration params

* NODE-161, fix: node: update TransactionPool

* NODE-161, fix: node: substrate-offchain: upgrade hyper to v1 (paritytech/polkadot-sdk#5919)

* NODE-161, fix: node: update service, rpc

* NODE-161, chore: remove unused imports

* chore: add cargo feature "metadata-hash"

* NODE-161, fix: add cumulus primitives storage proof size HostFunctions

* NODE-161, chore: update dependencies branch

* NODE-161, chore: update to stable2506

* NODE-161, chore: remove `RuntimeEvent` from pallet::Config

* NODE-161, fix: update test code

* NODE-161, fix: make node-lts compatible

* NODE-161, chore: update `test_btc_registration_pool.ts`

* NODE-161, chore: update `test_btc_registration_pool.ts`

* NODE-161, chore: update `test_btc_registration_pool.ts`

* NODE-161, fix: use node.kill()

* NODE-161, fix: resolve test codes

* NODE-161, fix: remove console.log

* NODE-161, chore: update tools package.json

* feat: init blaze

* fix: remove unused crate

* import precompile-blaze

* NODE-161, chore: add mbm migrator into runtimes

* NODE-161, chore: add pallet_session migration

* NODE-161, fix: new_full_parts -> new_full_parts_record_import

* fix: resolve issues

* NODE-161, deps: update runtime version (489)

---------

Co-authored-by: dnjscksdn98 <[email protected]>

* NODE-80 branch restructure (#127)

* NODE-179, feat: init pallet storages

* NODE-179, feat: init pallet extrinsics

* NODE-179, chore: add locktime

* NODE-179, feat: finalize fee rate

* NODE-179, feature: impl coin selections

* NODE-179, feat: check blaze activation state

* NODE-179, feature: impl `remove_outbound_messages` for legacy mode

* NODE-80: implement benchmarking (#121)

* NODE-80, feature: impl benchmarking.rs & mock.rs

* NODE-80, fix: benchmark

* NODE-80, fix: benchmark

* NODE-80, chore: update weights

* fix: zero out proof size in weights

* chore: resolve

---------

Co-authored-by: dnjscksdn98 <[email protected]>

* fix: correctly use mocha with tsx (#133)

* chore: version (#134)

---------

Co-authored-by: dnjscksdn98 <[email protected]>
dnjscksdn98 added a commit to bifrost-platform/bifrost-frontier that referenced this pull request Sep 15, 2025
dnjscksdn98 pushed a commit to bifrost-platform/bifrost-frontier that referenced this pull request Sep 15, 2025
* Introduce account provider interface

* Use AccountProvider logic at pallet-evm

* Remove redundant ower type usage

* Fix fmt

* Fix clippy

* Fix clippy

* License at primitives/evm/src/account_provider.rs

* Rename NativeSystemAccountProvider to FrameSystemAccountProvider

* Formatting corrcetions at account_provider.rs

---------

Co-authored-by: MOZGIII <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants