Cap9 relies on several properties of a system in order to be implementable, one of those is the system needs to be able to reflect or introspect itself. In real terms it needs to be able to read the code that will be executed. On Ethereum we use EXTCODECOPY which reads the code of another contract. This is specified in eWASM (see the eWASM spec) but it is not implemented in pwasm (nor is there a spec to suggest that it should be.
These Ethereum primitives are provided via wasm imports from an env modules. For example, to be able to use SSTORE a wasm contract (in pwasm) can import storage_write via:
Cap9 relies on several properties of a system in order to be implementable, one of those is the system needs to be able to reflect or introspect itself. In real terms it needs to be able to read the code that will be executed. On Ethereum we use
EXTCODECOPY
which reads the code of another contract. This is specified in eWASM (see the eWASM spec) but it is not implemented in pwasm (nor is there a spec to suggest that it should be.These Ethereum primitives are provided via wasm imports from an
env
modules. For example, to be able to useSSTORE
a wasm contract (in pwasm) can importstorage_write
via:In order for the validation code to work we would need to implement
EXTCODECOPY
ourselves, so that we can do something like:I have already implemented
EXTCODESIZE
, which shows it is possible, althoughEXTCODECOPY
is likely much more complex.