design icon indicating copy to clipboard operation
design copied to clipboard

Propose an ewasm subset for precompiles on the main chain

Open axic opened this issue 7 years ago • 4 comments

The only features ewasm would need to expose are:

  • useGas
  • calldata access (calldatacopy/calldatasize)
  • return / revert

This could be a way to get wasm VMs implemented and experimented with in a more controlled environment on the main chain.

It is not clear whether the precompiles would have "magic gas calculation rules" or just use "a metering process" on them.

axic avatar Jun 28 '18 17:06 axic

BTW, can you pass reference to calldata buffer directly to the contract main function?

chfast avatar Jun 28 '18 18:06 chfast

Sample precompile in Rust: https://github.com/ewasm/ewasm-precompile-sha256/blob/master/src/lib.rs

axic avatar Jun 29 '18 08:06 axic

Great idea. More generally, we can discuss how to constrain Wasm and EEI to get nice properties, such as allowing "magic gas calculation".

poemm avatar Jun 29 '18 17:06 poemm

Proposal to expose these functions from the EEI:

  • useGas
  • getCallDataSize
  • callDataCopy
  • getCaller (good for contracts like blockhash - or should be getTxOrigin?!)
  • getCallValue (not necessary, but could be useful to reject calls with value)
  • return
  • revert

axic avatar Jul 30 '18 21:07 axic