Implement additional Ethereum operations in pwasm
JakeOShannessy opened this issue · 1 comments
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:
(import "env" "storage_write" (func $env.storage_write (type $t0)))
In order for the validation code to work we would need to implement EXTCODECOPY
ourselves, so that we can do something like:
(import "env" "extcodecopy" (func $env.extcodecopy (type $t1)))
I have already implemented EXTCODESIZE
, which shows it is possible, although EXTCODECOPY
is likely much more complex.
This is now addressed in master of https://github.com/Daohub-io/parity-ethereum, and relied upon in #151. Both EXTCODESIZE
and EXTCODECOPY
are implemented.