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

Pay EVM gas fees with tokens via HydraDX pallet #206

Closed
wants to merge 17 commits into from

Conversation

4meta5
Copy link
Contributor

@4meta5 4meta5 commented May 26, 2024

Some changes must be made to safely config HydraDX-node/pallet-transaction-multi-payment for evm-template

HydraDX/tx-multi usage blockers

evm-template EVM config violates key assumptions built into the current version of HydraDX-node/pallet-transaction-multi-payment. The configurations that violate these assumptions include:

  1. setting the native currency as the EVM currency
  2. setting Ethereum Accounts as the main AccountId type
  3. setting ECDSA as the main Signature scheme

These settings were chosen intentionally to maximize Ethereum compatibility for developers building and using the EVM. They are not subject to change.

Unfortunately, HydraDX-node/pallet-transaction-multi-payment does not expect this config and, moreover, has hardcoded assumptions to the contrary that lead to unexpected behavior:

  1. reset_payment_currency extrinsic incorrectly routes native balance operations to the foreign asset handler because it assumes the EvmAssetId != NativeAssetId.
  2. Config::MultiCurrency has bounds not satisfied by pallet-assets (tried here to wrap it without luck). The only out of the box config for Config::MultiCurrency is orml-tokens or orml-currencies, the latter of the two still to use these pallets as is because pallet-assets is not supported.

orml-currencies usage blockers

orml-currencies is a pallet that allows ORML users to route native asset execution to a separate path than foreign asset execution. It supports pallet-balances + orml-tokens but does not support out of the box pallet-balances + pallet-assets.

Making orml-currencies work with pallet-assets is the same work required to resolve the problem outlined in HydraDX/tx-multi. By enabling pallet-assets to replace orml-tokens in the orml-currencies config, it would enable pallet-assets to be used in HydraDX/tx-multi as originally intended.

Code Changes

  • Split out DeFi configs into evm-template/runtime/src/defi.rs
  • Chose ecosystem pallet to enable paying EVM gas fees with any registered/governance-approved token: HydraDX-node/transaction-multi-payment. Additional approaches were compared and contrasted in an internal doc titled "Choosing an Implementation to Pay Gas Fees with Any Token".
  • Fork HydraDX-node && open-runtime-module-library to use HydraDX-Node/pallet-transaction-multi-payment
  • Match HydraDX-node, open-runtime-module-library fork dependencies to polkadot-sdk and frontier version used locally (polkadot-v1.7.0 when last updated). Import HydraDX-Node/transacton_multi_payment into deps.
  • Configured orml-tokens, orml-currencies to satisfy transaction-multi-payment::Config::MultiCurrency trait bounds. Justification: https://substrate.stackexchange.com/questions/8410/orml-tokens-vs-pallet-assets
  • Summarized blockers encountered configuring HydraDX/transaction-multi-payment for the evm-template runtime at the top of the PR description.

Next Steps

Following steps are sequential and should not be pursued in parallel:

  • implement pallet to enable using pallet-assets + pallet-balances by tx-multi-payment instead of orml-tokens nor orml-currencies
  • make issue & upstream changes required to tx-multi-payment to support EvmCurrency = NativeCurrencyId (so that reset_payment does not incorrectly route execution away from pallet-balances, could be solved by the write pallet impl in the top TODO)
  • write local precompile that uses ECDSA for tx-multi-payment precompile
  • make issue & upstream for tx-multi-payment precompile generic over signature scheme HydraDX-node

Copy link

netlify bot commented May 26, 2024

Deploy Preview for docs-oz-polkadot canceled.

Name Link
🔨 Latest commit 1f57931
🔍 Latest deploy log https://app.netlify.com/sites/docs-oz-polkadot/deploys/66575d4435b85f0008f03d54

@4meta5 4meta5 self-assigned this May 26, 2024
@4meta5 4meta5 added this to the Deliverable 2 - EVM template milestone May 26, 2024
@4meta5 4meta5 changed the title 189 Pay EVM gas fees with tokens #189 Pay EVM gas fees with tokens May 26, 2024
…ait bounds using balances and assets configs
@4meta5 4meta5 added the priority: 3 We will resolve this first before everything else. label May 26, 2024
@4meta5
Copy link
Contributor Author

4meta5 commented May 26, 2024

Chose to use orml_tokens instead of adding pallet-multi-asset (which required implementing all the necessary MultiCurrency traits using pallet-assets). That work was saved on a separate branch before proceeding with orml_tokens configuration.

@4meta5 4meta5 changed the title #189 Pay EVM gas fees with tokens Pay EVM gas fees with tokens via HydraDX pallet May 29, 2024
@4meta5 4meta5 added on hold Pending other work or discussion and removed priority: 3 We will resolve this first before everything else. labels May 29, 2024
@ggonzalez94 ggonzalez94 removed this from the Deliverable 2 - EVM template milestone Jun 27, 2024
@ggonzalez94
Copy link
Collaborator

@4meta5 I removed this from EVM milestone since we are not shipping this. We can include as part of a later milestone if we decide to ship this

@4meta5
Copy link
Contributor Author

4meta5 commented Jul 30, 2024

Closed because extremely stale at this point, blockers are documented clearly in the PR description for anyone wishing to take up this work in the future.

@4meta5 4meta5 closed this Jul 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
on hold Pending other work or discussion
Projects
Status: ⚠ Blocked
Development

Successfully merging this pull request may close these issues.

2 participants