This repository has been archived by the owner on Nov 15, 2023. It is now read-only.
contracts: Make chain extensions composeable #11751
Labels
J0-enhancement
An additional feature request.
Z2-medium
Can be fixed by a coder with good Rust knowledge but little knowledge of the codebase.
Currently, you can only have one chain extension per
pallet-contracts
. The runtime author needs to provide a type implementingChainExtension
to theConfig
trait which is then called into whenever a contract uses a chain extension:The meaning of the
func_id
is defined by the chain extension itself. The chain extension would use it to select which sub functionality (function) it should provide. This means that a single chain extension controls the whole function space.This works fine if a chain wants to provide a single monolithic chain extension specific to its needs. However, we know that there are also general use chain extensions that are useful to many chains. Those would usually be candidates for inclusion to the
pallet-contracts
core API but it is desirable to have them exist as a chain extension for a while.Because of this we want chain authors to be able to pick and choose different chain extensions and compose them. The idea is to the following:
ChainExtension
for(ChainExtension, ChainExtension, ...)
.u32
function space intoextension: u16, func: u16
: The msb bits selects the chain extension and the lsb bits the function within.trait ChainExtension
will be changed to provide aconst u16
to announce its extension id and theChainExtension::call
will only get the lsb bits.seal_call_chain_extension
remains unchanged.The text was updated successfully, but these errors were encountered: