diff --git a/404.html b/404.html index 21bff5723..2559b8921 100644 --- a/404.html +++ b/404.html @@ -91,7 +91,7 @@ diff --git a/approved/0001-agile-coretime.html b/approved/0001-agile-coretime.html index e384121b2..53d0960dd 100644 --- a/approved/0001-agile-coretime.html +++ b/approved/0001-agile-coretime.html @@ -90,7 +90,7 @@ @@ -710,7 +710,7 @@

- @@ -724,7 +724,7 @@

- diff --git a/approved/0005-coretime-interface.html b/approved/0005-coretime-interface.html index ae6e9adb8..e7ff33acd 100644 --- a/approved/0005-coretime-interface.html +++ b/approved/0005-coretime-interface.html @@ -90,7 +90,7 @@ diff --git a/approved/0007-system-collator-selection.html b/approved/0007-system-collator-selection.html index 390a05133..76ead4e2b 100644 --- a/approved/0007-system-collator-selection.html +++ b/approved/0007-system-collator-selection.html @@ -90,7 +90,7 @@ diff --git a/approved/0008-parachain-bootnodes-dht.html b/approved/0008-parachain-bootnodes-dht.html index 113accb4c..ba3293523 100644 --- a/approved/0008-parachain-bootnodes-dht.html +++ b/approved/0008-parachain-bootnodes-dht.html @@ -90,7 +90,7 @@ diff --git a/approved/0012-process-for-adding-new-collectives.html b/approved/0012-process-for-adding-new-collectives.html index 60ece3342..7dd3043ea 100644 --- a/approved/0012-process-for-adding-new-collectives.html +++ b/approved/0012-process-for-adding-new-collectives.html @@ -90,7 +90,7 @@ diff --git a/approved/0014-improve-locking-mechanism-for-parachains.html b/approved/0014-improve-locking-mechanism-for-parachains.html index f25a743fb..87f44a8c8 100644 --- a/approved/0014-improve-locking-mechanism-for-parachains.html +++ b/approved/0014-improve-locking-mechanism-for-parachains.html @@ -90,7 +90,7 @@ diff --git a/approved/0022-adopt-encointer-runtime.html b/approved/0022-adopt-encointer-runtime.html index 7552a5ca6..66fed49d0 100644 --- a/approved/0022-adopt-encointer-runtime.html +++ b/approved/0022-adopt-encointer-runtime.html @@ -90,7 +90,7 @@ diff --git a/approved/0032-minimal-relay.html b/approved/0032-minimal-relay.html index a473dc2ba..57b45582d 100644 --- a/approved/0032-minimal-relay.html +++ b/approved/0032-minimal-relay.html @@ -90,7 +90,7 @@ diff --git a/approved/0050-fellowship-salaries.html b/approved/0050-fellowship-salaries.html index 050e507a5..b6ec1fea1 100644 --- a/approved/0050-fellowship-salaries.html +++ b/approved/0050-fellowship-salaries.html @@ -90,7 +90,7 @@ diff --git a/approved/0056-one-transaction-per-notification.html b/approved/0056-one-transaction-per-notification.html index d92b139c7..d44bbb6aa 100644 --- a/approved/0056-one-transaction-per-notification.html +++ b/approved/0056-one-transaction-per-notification.html @@ -90,7 +90,7 @@ diff --git a/index.html b/index.html index b1b0fd865..dd1acaa4a 100644 --- a/index.html +++ b/index.html @@ -90,7 +90,7 @@ @@ -185,7 +185,7 @@

Introduction - @@ -196,7 +196,7 @@

Introduction - diff --git a/introduction.html b/introduction.html index b1b0fd865..dd1acaa4a 100644 --- a/introduction.html +++ b/introduction.html @@ -90,7 +90,7 @@ @@ -185,7 +185,7 @@

Introduction - @@ -196,7 +196,7 @@

Introduction - diff --git a/print.html b/print.html index 980cad0f9..d26bb7759 100644 --- a/print.html +++ b/print.html @@ -91,7 +91,7 @@ @@ -180,204 +180,6 @@

IntroductionThis book contains the Polkadot Fellowship Requests for Comments (RFCs) detailing proposed changes to the technical implementation of the Polkadot network.

GitHub logo polkadot-fellows/RFCs

-

(source)

-

Table of Contents

- -

RFC-0066: Add EVM+ink! Contracts Pallets to Asset Hub for Polkadot

-
- - - -
Start Date14 January 2024
DescriptionA proposal to add EVM+ink! Contracts to Asset Hub for Polkadot to support Polkadot Rollups and larger numbers of EVM/Coreplay smart contract developers and their users on Polkadot Rollups and AssetHub for Polkadot.
AuthorsSourabh Niyogi
-
-

Summary

-

This RFC proposes to add the two dominant smart contract programming languages in the Polkadot ecosystem to AssetHub: -EVM + ink!/Coreplay. The objective is to increase DOT Revenue by making AssetHub accessible to -(1) Polkadot Rollups; -(2) EVM smart contract programmers; -(3) Coreplay programmers who will benefit from easier-to-use smart contract environments.
-These changes in AssetHub are enabled by key Polkadot 2.0 technologies: -PolkaVM supporting Coreplay, and -hyper data availability in Blobs Chain.

-

Motivation

-

EVM Contracts are pervasive in the Web3 blockchain ecosystem, -while Polkadot 2.0's Coreplay aims to surpass EVM Contracts in ease-of-use using PolkaVM's RISC architecture.

-

Asset Hub for Polkadot does not have smart contract capabilities, -even though dominant stablecoin assets such as USDC and USDT are originated there.
-In addition, in the RFC #32 - Minimal Relay Chain architecture, -DOT balances are planned to be shifted to Asset Hub, to support Polkadot 2.0's -CoreJam map-reduce architecture.
-In this 2.0 architecture, there is no room for synchronous contracts on the Polkadot relay chain -- -doing so would waste precious resources that should be dedicated to sync+async composability.
-However, while Polkadot fellows have concluded the Polkadot relay chain should not support -synchronous smart contracts, this is not applicable to AssetHub for Polkadot.

-

The following sections argue for the need for Smart Contracts on AssetHub.

-

Defi+NFT Applications need Smart Contracts on AssetHub

-

EVM Smart Contract chains within Polkadot and outside are dominated by defi + NFT applications. While the assetConversion pallet (implementing Uniswap v1) is a start to having some basic defi on AssetHub, -many programmers may be surprised to find that synchronous EVM smart contract capabilities (e.g. uniswap v2+v3) on other chains are not possible on AssetHub.

-

Indeed, this is true for many Polkadot parachains, with the exception of the top 2 Polkadot parachains (by marketcap circa early 2024: Moonbeam + Astar) who do include the EVM pallets.
-This leads to a cumbersome Polkadot EVM smart contract programming experience between AssetHub and these 2 Polkadot parachains, making the Polkadot ecosystem hard to work with for asset-related applications from defi to NFTs.

-

The ink! defi ecosystem remains nascent, having only Astar as a potential home, and empirically has almost no defi/NFT activity. Although e.g. uniswap translations have been written,

-

An AssetHub for Polkadot deployment of EVM and ink! contracts, it is hoped, would likely support new applications for top assets (USDC and USDT) and spur many smart contract developers to develop end user applications with familiar synchronous programming constructs.

-

Rollups need Smart Contracts on AssetHub

-

Polkadot Data Availability technology is extremely promising but underutilized.
-We envision a new class of customer, "Polkadot Rollups" that can utilize Polkadot DA far better than Ethereum and other technology platforms.
-Unlike Ethereum's DA which is capped at a fixed throughput now extending to EIP-4844, Polkadot data availability is linear in the number of cores.
-This means Polkadot can support a much larger number of rollups than Ethereum now, and even more as the number of cores in Polkadot grows. -This performance difference has not been widely appreciated in the blockchain community.

-

Recently, a "Blobs" chain has been developed to expose Polkadot DA to rollups by senior Polkadot Fellows:

- -

A rollup kit is mappable to widely used rollup platforms, such as OP Stack, Arbitrum Orbit or StarkNet Madara.
-A Blobs chain, currently deployed on Kusama (paraID 3338), enables rollups to utilize functionality outside the Polkadot 1.0 parachain architecture by having rollups submit transactions via a rollup kit abstraction. The Blobs chain write interface is simple blobs.submitBlob(namespaceId, blob) with a matching read interface.

-

However, simply sending blobs is not enough to power a rollup. End users need to interact with a "settlement layer", while rollups require proof systems for security.

-

Key functionality for optimistic rollups (e.g. OP Stack, Arbitrum Orbit) are:

- -

Analogous functionality exist for ZK-rollup platforms (e.g. Polygon zkEVM, StarkNet Madara), with high potential for using the same Blobs+AssetHub chains.

-

While it is possible to have the operations in EVM Contracts translated in FRAME pallets (e.g. an "opstack" pallet), we do not believe a pallet translation confers significant benefits.
-Instead, we believe the translation would require regular updates from the rollup platform, which have proven difficult to implement in practice.

-

ink! on AssetHub will lead to CorePlay Developers on AssetHub

-

While ink! WASM Smart Contracts have been promising technology, the adoption of ink! WASM Contracts amongst Polkadot parachains has been low, in practice just Astar to date, with nowhere near as many developers.
-This may be due to missing tooling, slow compile times, and/or simply because ink!/Rust is just harder to learn than Solidity, the dominant programming language of EVM Chains.

-

Fortunately, ink! can compile to PolkaVM, a new RISC based VM that has the special capability of suspending and resuming the registers, supporting long-running computations.
-This has the key new promise of making smart contract languages easier to use -- instead of smart contract developers worrying about what can be done within the gas limits of a specific block or a specific transaction, Coreplay smart contracts can be much easier to program on (see here).

-

We believe AssetHub should support ink! as a precursor to support CorePlay's capabilities as soon as possible.
-To the best of our knowledge, release times of this are unknown but having ink! inside AssetHub would be natural for Polkadot 2.0.

-

Stakeholders

- -

Explanation

-

Limit Smart Contract Weight allocation

-

AssetHub is a major component of the Polkadot 2.0 Minimal Relay Chain architecture. It is critical that smart contract developers not be able to clog AssetHub's blockspace for other mission critical applications, such as Staking and Governance.

-

As such, it is proposed that at most 50% of the available weight in AssetHub for Polkadot blocks be allocated to smart contracts pallets (EVM, ink! and/or Coreplay). While to date AssetHub has limited usage, it is believed (see here) that imposing this limit on smart contracts pallet would limit the effect on non-smart contract usage. A excessively small weight limit like 10% or 20% may limit the attractiveness of Polkadot as a platform for Polkadot rollups and EVM Contracts. A excessively large weight like 90% or 100% may threaten AssetHub usage.

-

In practice, this 50% weight limit would be used for 3 categories of smart contract usage:

- -

We expect the first category to dominate. If AssetHub smart contract usage increases so as to approach this 50% limit, the gas price will increase significantly. This likely motivates EVM contract developers to migrate to a EVM contract chain and/or rethink their application to work asynchronously within CoreJam, another major Polkadot 2.0 technology.

-

Model AssetHub Assets inside EVM Smart Contracts based on Astar

-

It is essential to make AssetHub assets interface well with EVM Smart Contracts. -Polkadot parachains Astar and Moonbeam have a mapping between assetIDs and "virtual" EVM Contracts.

- -

We propose that AssetHub support a systemic mapping following Astar: -(a) Native Relay DOT + KSM - should be mapped to 0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF on AssetHub for Polkadot and AssetHub for Kusama respectively -(b) Other Assethubs assets should map into an EVM address using a 0xffffffff prefix -https://docs.astar.network/docs/learn/interoperability/xcm/integration/tools#xc20-address

-

The usage of the above has been made code-complete by Astar:

- -

Polkadot parachains Astar and Moonbeam adopted two very different approaches of how end users interact with EVM Contracts.
-We propose that AssetHub for Polkadot adopt the Astar solution, mirroring it as closely as possible.

-

New DOT Revenue Sources

-

A substantial motivation in this proposal is to increase demand for DOT via two key chains:

- -

New Revenue from AssetHub EVM Contracts

-

Enabling EVM Contracts on AssetHub will support DOT revenue from:

- -

New Revenue for ink!/Coreplay Contracts

-

Enabling ink! contracts will pave the way to a new class of AssetHub Smart Contract Developers.
-Given PolkaVM's proven reduced compile time and RISC architecture enabling register snapshots, it is natural to utilize these new technical capabilities on a flagship system chain.
-To the extent these capabilities are attractive to smart contract developers, this has the potential for bringing in new DOT revenue from a system chain.

-

Drawbacks and Tradeoffs

-

Supporting EVM Contracts in AssetHub is seen by some as undercutting Polkadot's 1.0 parachain architecture, both special purpose appchains and smart contract developer platform parachains.
-We believe the lack of growth of parachains in the last 12-18 months, and the high potential of CorePlay motivates new options be pursued in system chains.

-

Maintaining EVM Contracts on AssetHub may be seen as difficult and may require Substrate engineers to maintain EVM Pallets and manage the xcContracts.
-We believe this cost will be relatively small based on the proven deployment of Astar and Moonbeam.
-The cost will be justified compared to the potential upside of new DOT revenue from defi/NFT applications on AssetHub and the potential for utilizing Polkadot DA for Polkadot rollups.

-

Testing, Security, and Privacy

-

Testing the mapping between assetIDs and EVM Contracts thoroughly will be critical.

-

Having a complete working OP Stack chain using AssetHub for Kusama (1000) and Blobs on Kusama (3338) would be highly desirable, but is unlikely to be required.

-

Performance, Ergonomics, and Compatibility

-

Performance

-

The weight limit of 50% is expected to be adequate to limit excess smart contract usage at this time.

-

Storage bloat is expected to kept to a minimum with the nominal 0.01 Existential Deposit.

-

Ergonomics

-

Note that the existential deposit is not 0 DOT but being lowered from 0.1 DOT to 0.01 DOT, which may pose problems for some developers.
-Many developers routinely deploy their EVM contracts on many different EVM Chains in parallel. This non-zero ED may pose problems for some developers

-

The 0.01 DOT (worth $0.075 USD) is unlikely to pose significant issue.

-

Compatibility

-

It is believed that EVM pallet (as deployed on Moonbeam + Astar) is sufficiently compatible with Ethereum, and that the ED of 0.01 DOT pose negligible issues.

-

The messaging architecture for rollups are not compatible with Polkadot XCM.
-It is not clear if leading rollup platforms (OP Stack, Arbitrum Orbit, Polygon zkEVM) could be made compatible with XCM.

-

Unresolved Questions

-

It is highly desirable to know the throughput of Polkadot DA with popular rollup architectures OP Stack and Arbitrum Orbit.
-This would enable CEXs and EVM L2 builders to choose Polkadot over Ethereum.

- -

If accepted, this RFC could pave the way for CorePlay on Asset Hub for Polkadot/Kusama, a major component of Polkadot 2.0's smart contract future.

-

The importance of precompiles should

(source)

Table of Contents

-

Stakeholders

+

Stakeholders

All chain teams are stakeholders, as implementing this feature would require timely effort on their side and would impact compatibility with older tools.

This feature is essential for all offline signer tools; many regular signing tools might make use of it. In general, this RFC greatly improves security of any network implementing it, as many governing keys are used with offline signers.

Implementing this RFC would remove requirement to maintain metadata portals manually, as task of metadata verification would be effectively moved to consensus mechanism of the chain.

-

Explanation

+

Explanation

Detailed description of metadata shortening and digest process is provided in metadata-shortener crate (see cargo doc --open and examples). Below are presented algorithms of the process.

Definitions

Metadata structure

@@ -2026,24 +1828,24 @@

Transition overhead

Some slightly out of spec systems might experience breaking changes as new content of signed extensions is added. It is important to note, that there is no real overhead in processing time nor complexity, as the metadata checking mechanism is voluntary. The only drawbacks are expected for tools that do not implement MetadataV14 self-descripting features.

-

Testing, Security, and Privacy

+

Testing, Security, and Privacy

The metadata shortening protocol should be extensively tested on all available examples of metadata before releasing changes to either metadata or shortener. Careful code review should be performed on shortener implementation code to ensure security. The main metadata tree would inevitably be constructed on runtime build which would also ensure correctness.

To be able to recall shortener protocol in case of vulnerability issues, a version byte is included.

-

Performance, Ergonomics, and Compatibility

-

Performance

+

Performance, Ergonomics, and Compatibility

+

Performance

This is negligibly short pessimization during build time on the chain side. Cold wallets performance would improve mostly as metadata validity mechanism that was taking most of effort in cold wallet support would become trivial.

-

Ergonomics

+

Ergonomics

The proposal was optimized for cold storage wallets usage with minimal impact on all other parts of the ecosystem

-

Compatibility

+

Compatibility

Proposal in this form is not compatible with older tools that do not implement proper MetadataV14 self-descriptive features; those would have to be upgraded to include a new signed extensions field.

Prior Art and References

This project was developed upon a Polkadot Treasury grant; relevant development links are located in metadata-offline-project repository.

-

Unresolved Questions

+

Unresolved Questions

  1. How would polkadot-js handle the transition?
  2. Where would non-rust tools like Ledger apps get shortened metadata content?
- +

Changes to code of all cold signers to implement this mechanism SHOULD be done when this is enabled; non-cold signers may perform extra metadata check for better security. Ultimately, signing anything without decoding it with verifiable metadata should become discouraged in all situations where a decision-making mechanism is involved (that is, outside of fully automated blind signers like trade bots or staking rewards payout tools).

(source)

Table of Contents

@@ -2086,11 +1888,11 @@

Summary

+

Summary

Propose a way of permuting the availability chunk indices assigned to validators, in the context of recovering available data from systematic chunks, with the purpose of fairly distributing network bandwidth usage.

-

Motivation

+

Motivation

Currently, the ValidatorIndex is always identical to the ChunkIndex. Since the validator array is only shuffled once per session, naively using the ValidatorIndex as the ChunkIndex would pose an unreasonable stress on the first N/3 validators during an entire session, when favouring availability recovery from systematic chunks.

@@ -2098,9 +1900,9 @@

Motivation

systematic availability chunks to different validators, based on the relay chain block and core. The main purpose is to ensure fair distribution of network bandwidth usage for availability recovery in general and in particular for systematic chunk holders.

-

Stakeholders

+

Stakeholders

Relay chain node core developers.

-

Explanation

+

Explanation

Systematic erasure codes

An erasure coding algorithm is considered systematic if it preserves the original unencoded data as part of the resulting code. @@ -2264,28 +2066,28 @@

Drawbacks

Related discussion about updating CandidateReceipt
  • It's a breaking change that requires all validators and collators to upgrade their node version at least once.
  • -

    Testing, Security, and Privacy

    +

    Testing, Security, and Privacy

    Extensive testing will be conducted - both automated and manual. This proposal doesn't affect security or privacy.

    -

    Performance, Ergonomics, and Compatibility

    -

    Performance

    +

    Performance, Ergonomics, and Compatibility

    +

    Performance

    This is a necessary data availability optimisation, as reed-solomon erasure coding has proven to be a top consumer of CPU time in polkadot as we scale up the parachain block size and number of availability cores.

    With this optimisation, preliminary performance results show that CPU time used for reed-solomon coding/decoding can be halved and total POV recovery time decrease by 80% for large POVs. See more here.

    -

    Ergonomics

    +

    Ergonomics

    Not applicable.

    -

    Compatibility

    +

    Compatibility

    This is a breaking change. See upgrade path section above. All validators and collators need to have upgraded their node versions before the feature will be enabled via a governance call.

    Prior Art and References

    See comments on the tracking issue and the in-progress PR

    -

    Unresolved Questions

    +

    Unresolved Questions

    Not applicable.

    - +

    This enables future optimisations for the performance of availability recovery, such as retrieving batched systematic chunks from backers/approval-checkers.

    Appendix A

    @@ -2365,19 +2167,19 @@

    Summary

    +

    Summary

    Currently, substrate runtime use an simple allocator defined by host side. Every runtime MUST import these allocator functions for normal execution. This situation make runtime code not versatile enough.

    So this RFC proposes to define a new spec for allocator part to make substrate runtime more generic.

    -

    Motivation

    +

    Motivation

    Since this RFC define a new way for allocator, we now regard the old one as legacy allocator. As we all know, since the allocator implementation details are defined by the substrate client, parachain/parathread cannot customize memory allocator algorithm, so the new specification allows the runtime to customize memory allocation, and then export the allocator function according to the specification for the client side to use. Another benefit is that some new host functions can be designed without allocating memory on the client, which may have potential performance improvements. Also it will help provide a unified and clean specification if substrate runtime support multi-targets(e.g. RISC-V). There is also a potential benefit. Many programming languages that support compilation to wasm may not be friendly to supporting external allocator. This is beneficial for other programming languages ​​to enter the substrate runtime ecosystem. The last and most important benefit is that for offchain context execution, the runtime can fully support pure wasm. What this means here is that all imported host functions could not actually be called (as stub functions), then the various verification logic of the runtime can be converted into pure wasm, which provides the possibility for the substrate runtime to run block verification in other environments (such as in browsers and other non-substrate environments).

    -

    Stakeholders

    +

    Stakeholders

    No attempt was made at convincing stakeholders.

    -

    Explanation

    +

    Explanation

    Runtime side spec

    This section contains a list of functions should be exported by substrate runtime.

    We define the spec as version 1, so the following dummy function v1 MUST be exported to hint @@ -2420,16 +2222,16 @@

    Drawbacks

    The allocator inside of the runtime will make code size bigger, but it's not obvious. The allocator inside of the runtime maybe slow down(or speed up) the runtime, still not obvious.

    We could ignore these drawbacks since they are not prominent. And the execution efficiency is highly decided by runtime developer. We could not prevent a poor efficiency if developer want to do it.

    -

    Testing, Security, and Privacy

    +

    Testing, Security, and Privacy

    Keep the legacy allocator runtime test cases, and add new feature to compile test cases for v1 allocator spec. And then update the test asserts.

    Update template runtime to enable v1 spec. Once the dev network runs well, it seems that the spec is implmented correctly.

    -

    Performance, Ergonomics, and Compatibility

    -

    Performance

    +

    Performance, Ergonomics, and Compatibility

    +

    Performance

    As the above says, not obvious impact about performance. And polkadot-sdk could offer the best practice allocator for all chains. Third party also could customized by theirself. So the performance could be improved over time.

    -

    Ergonomics

    +

    Ergonomics

    Only for runtime developer, Just need to import a new crate and enable a new feature. Maybe it's convienient for other wasm-target language to implment.

    -

    Compatibility

    +

    Compatibility

    It's 100% compatible. Only Some runtime configs and executor configs need to be depreacted.

    For support new runtime spec, we MUST upgrade the client binary to support new spec of client part firstly.

    We SHALL add an optional primtive crate to enable the version 1 spec and disable the legacy allocator by cargo feature. @@ -2439,11 +2241,209 @@

    Move the allocator inside of the runtime
  • Add new allocator design
  • -

    Unresolved Questions

    +

    Unresolved Questions

    None at this time.

    - +

    The content discussed with RFC-0004 is basically orthogonal, but it could still be considered together, and it is preferred that this rfc be implmentented first.

    This feature could make substrate runtime be easier supported by other languages and integreted into other ecosystem.

    +

    (source)

    +

    Table of Contents

    + +

    RFC-0066: Add EVM+ink! Contracts Pallets to Asset Hub for Polkadot

    +
    + + + +
    Start Date14 January 2024
    DescriptionA proposal to add EVM+ink! Contracts to Asset Hub for Polkadot to support Polkadot Rollups and larger numbers of EVM/Coreplay smart contract developers and their users on Polkadot Rollups and AssetHub for Polkadot.
    AuthorsSourabh Niyogi
    +
    +

    Summary

    +

    This RFC proposes to add the two dominant smart contract programming languages in the Polkadot ecosystem to AssetHub: +EVM + ink!/Coreplay. The objective is to increase DOT Revenue by making AssetHub accessible to +(1) Polkadot Rollups; +(2) EVM smart contract programmers; +(3) Coreplay programmers who will benefit from easier-to-use smart contract environments.
    +These changes in AssetHub are enabled by key Polkadot 2.0 technologies: +PolkaVM supporting Coreplay, and +hyper data availability in Blobs Chain.

    +

    Motivation

    +

    EVM Contracts are pervasive in the Web3 blockchain ecosystem, +while Polkadot 2.0's Coreplay aims to surpass EVM Contracts in ease-of-use using PolkaVM's RISC architecture.

    +

    Asset Hub for Polkadot does not have smart contract capabilities, +even though dominant stablecoin assets such as USDC and USDT are originated there.
    +In addition, in the RFC #32 - Minimal Relay Chain architecture, +DOT balances are planned to be shifted to Asset Hub, to support Polkadot 2.0's +CoreJam map-reduce architecture.
    +In this 2.0 architecture, there is no room for synchronous contracts on the Polkadot relay chain -- +doing so would waste precious resources that should be dedicated to sync+async composability.
    +However, while Polkadot fellows have concluded the Polkadot relay chain should not support +synchronous smart contracts, this is not applicable to AssetHub for Polkadot.

    +

    The following sections argue for the need for Smart Contracts on AssetHub.

    +

    Defi+NFT Applications need Smart Contracts on AssetHub

    +

    EVM Smart Contract chains within Polkadot and outside are dominated by defi + NFT applications. While the assetConversion pallet (implementing Uniswap v1) is a start to having some basic defi on AssetHub, +many programmers may be surprised to find that synchronous EVM smart contract capabilities (e.g. uniswap v2+v3) on other chains are not possible on AssetHub.

    +

    Indeed, this is true for many Polkadot parachains, with the exception of the top 2 Polkadot parachains (by marketcap circa early 2024: Moonbeam + Astar) who do include the EVM pallets.
    +This leads to a cumbersome Polkadot EVM smart contract programming experience between AssetHub and these 2 Polkadot parachains, making the Polkadot ecosystem hard to work with for asset-related applications from defi to NFTs.

    +

    The ink! defi ecosystem remains nascent, having only Astar as a potential home, and empirically has almost no defi/NFT activity. Although e.g. uniswap translations have been written,

    +

    An AssetHub for Polkadot deployment of EVM and ink! contracts, it is hoped, would likely support new applications for top assets (USDC and USDT) and spur many smart contract developers to develop end user applications with familiar synchronous programming constructs.

    +

    Rollups need Smart Contracts on AssetHub

    +

    Polkadot Data Availability technology is extremely promising but underutilized.
    +We envision a new class of customer, "Polkadot Rollups" that can utilize Polkadot DA far better than Ethereum and other technology platforms.
    +Unlike Ethereum's DA which is capped at a fixed throughput now extending to EIP-4844, Polkadot data availability is linear in the number of cores.
    +This means Polkadot can support a much larger number of rollups than Ethereum now, and even more as the number of cores in Polkadot grows. +This performance difference has not been widely appreciated in the blockchain community.

    +

    Recently, a "Blobs" chain has been developed to expose Polkadot DA to rollups by senior Polkadot Fellows:

    + +

    A rollup kit is mappable to widely used rollup platforms, such as OP Stack, Arbitrum Orbit or StarkNet Madara.
    +A Blobs chain, currently deployed on Kusama (paraID 3338), enables rollups to utilize functionality outside the Polkadot 1.0 parachain architecture by having rollups submit transactions via a rollup kit abstraction. The Blobs chain write interface is simple blobs.submitBlob(namespaceId, blob) with a matching read interface.

    +

    However, simply sending blobs is not enough to power a rollup. End users need to interact with a "settlement layer", while rollups require proof systems for security.

    +

    Key functionality for optimistic rollups (e.g. OP Stack, Arbitrum Orbit) are:

    + +

    Analogous functionality exist for ZK-rollup platforms (e.g. Polygon zkEVM, StarkNet Madara), with high potential for using the same Blobs+AssetHub chains.

    +

    While it is possible to have the operations in EVM Contracts translated in FRAME pallets (e.g. an "opstack" pallet), we do not believe a pallet translation confers significant benefits.
    +Instead, we believe the translation would require regular updates from the rollup platform, which have proven difficult to implement in practice.

    +

    ink! on AssetHub will lead to CorePlay Developers on AssetHub

    +

    While ink! WASM Smart Contracts have been promising technology, the adoption of ink! WASM Contracts amongst Polkadot parachains has been low, in practice just Astar to date, with nowhere near as many developers.
    +This may be due to missing tooling, slow compile times, and/or simply because ink!/Rust is just harder to learn than Solidity, the dominant programming language of EVM Chains.

    +

    Fortunately, ink! can compile to PolkaVM, a new RISC based VM that has the special capability of suspending and resuming the registers, supporting long-running computations.
    +This has the key new promise of making smart contract languages easier to use -- instead of smart contract developers worrying about what can be done within the gas limits of a specific block or a specific transaction, Coreplay smart contracts can be much easier to program on (see here).

    +

    We believe AssetHub should support ink! as a precursor to support CorePlay's capabilities as soon as possible.
    +To the best of our knowledge, release times of this are unknown but having ink! inside AssetHub would be natural for Polkadot 2.0.

    +

    Stakeholders

    + +

    Explanation

    +

    Limit Smart Contract Weight allocation

    +

    AssetHub is a major component of the Polkadot 2.0 Minimal Relay Chain architecture. It is critical that smart contract developers not be able to clog AssetHub's blockspace for other mission critical applications, such as Staking and Governance.

    +

    As such, it is proposed that at most 50% of the available weight in AssetHub for Polkadot blocks be allocated to smart contracts pallets (EVM, ink! and/or Coreplay). While to date AssetHub has limited usage, it is believed (see here) that imposing this limit on smart contracts pallet would limit the effect on non-smart contract usage. A excessively small weight limit like 10% or 20% may limit the attractiveness of Polkadot as a platform for Polkadot rollups and EVM Contracts. A excessively large weight like 90% or 100% may threaten AssetHub usage.

    +

    In practice, this 50% weight limit would be used for 3 categories of smart contract usage:

    + +

    We expect the first category to dominate. If AssetHub smart contract usage increases so as to approach this 50% limit, the gas price will increase significantly. This likely motivates EVM contract developers to migrate to a EVM contract chain and/or rethink their application to work asynchronously within CoreJam, another major Polkadot 2.0 technology.

    +

    Model AssetHub Assets inside EVM Smart Contracts based on Astar

    +

    It is essential to make AssetHub assets interface well with EVM Smart Contracts. +Polkadot parachains Astar and Moonbeam have a mapping between assetIDs and "virtual" EVM Contracts.

    + +

    We propose that AssetHub support a systemic mapping following Astar: +(a) Native Relay DOT + KSM - should be mapped to 0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF on AssetHub for Polkadot and AssetHub for Kusama respectively +(b) Other Assethubs assets should map into an EVM address using a 0xffffffff prefix +https://docs.astar.network/docs/learn/interoperability/xcm/integration/tools#xc20-address

    +

    The usage of the above has been made code-complete by Astar:

    + +

    Polkadot parachains Astar and Moonbeam adopted two very different approaches of how end users interact with EVM Contracts.
    +We propose that AssetHub for Polkadot adopt the Astar solution, mirroring it as closely as possible.

    +

    New DOT Revenue Sources

    +

    A substantial motivation in this proposal is to increase demand for DOT via two key chains:

    + +

    New Revenue from AssetHub EVM Contracts

    +

    Enabling EVM Contracts on AssetHub will support DOT revenue from:

    + +

    New Revenue for ink!/Coreplay Contracts

    +

    Enabling ink! contracts will pave the way to a new class of AssetHub Smart Contract Developers.
    +Given PolkaVM's proven reduced compile time and RISC architecture enabling register snapshots, it is natural to utilize these new technical capabilities on a flagship system chain.
    +To the extent these capabilities are attractive to smart contract developers, this has the potential for bringing in new DOT revenue from a system chain.

    +

    Drawbacks and Tradeoffs

    +

    Supporting EVM Contracts in AssetHub is seen by some as undercutting Polkadot's 1.0 parachain architecture, both special purpose appchains and smart contract developer platform parachains.
    +We believe the lack of growth of parachains in the last 12-18 months, and the high potential of CorePlay motivates new options be pursued in system chains.

    +

    Maintaining EVM Contracts on AssetHub may be seen as difficult and may require Substrate engineers to maintain EVM Pallets and manage the xcContracts.
    +We believe this cost will be relatively small based on the proven deployment of Astar and Moonbeam.
    +The cost will be justified compared to the potential upside of new DOT revenue from defi/NFT applications on AssetHub and the potential for utilizing Polkadot DA for Polkadot rollups.

    +

    Testing, Security, and Privacy

    +

    Testing the mapping between assetIDs and EVM Contracts thoroughly will be critical.

    +

    Having a complete working OP Stack chain using AssetHub for Kusama (1000) and Blobs on Kusama (3338) would be highly desirable, but is unlikely to be required.

    +

    Performance, Ergonomics, and Compatibility

    +

    Performance

    +

    The weight limit of 50% is expected to be adequate to limit excess smart contract usage at this time.

    +

    Storage bloat is expected to kept to a minimum with the nominal 0.01 Existential Deposit.

    +

    Ergonomics

    +

    Note that the existential deposit is not 0 DOT but being lowered from 0.1 DOT to 0.01 DOT, which may pose problems for some developers.
    +Many developers routinely deploy their EVM contracts on many different EVM Chains in parallel. This non-zero ED may pose problems for some developers

    +

    The 0.01 DOT (worth $0.075 USD) is unlikely to pose significant issue.

    +

    Compatibility

    +

    It is believed that EVM pallet (as deployed on Moonbeam + Astar) is sufficiently compatible with Ethereum, and that the ED of 0.01 DOT pose negligible issues.

    +

    The messaging architecture for rollups are not compatible with Polkadot XCM.
    +It is not clear if leading rollup platforms (OP Stack, Arbitrum Orbit, Polygon zkEVM) could be made compatible with XCM.

    +

    Unresolved Questions

    +

    It is highly desirable to know the throughput of Polkadot DA with popular rollup architectures OP Stack and Arbitrum Orbit.
    +This would enable CEXs and EVM L2 builders to choose Polkadot over Ethereum.

    + +

    If accepted, this RFC could pave the way for CorePlay on Asset Hub for Polkadot/Kusama, a major component of Polkadot 2.0's smart contract future.

    +

    The importance of precompiles should

    (source)

    Table of Contents