design icon indicating copy to clipboard operation
design copied to clipboard

Eth 2.0 Phase 2 with "precompiles" proposal

Open axic opened this issue 6 years ago • 1 comments

The execution engine part is mostly found here: https://notes.ethereum.org/s/HylpjAWsE#Shard-processing

Official discussion thread: https://ethresear.ch/t/a-layer-1-minimizing-phase-2-state-execution-proposal/5397

We should investigate the feasibility of this proposal in ewasm and provide feedback on the ethresearch forum.

axic avatar May 02 '19 14:05 axic

A translation of the proposal into (non-comprehensive) Ewasm design follows:

  1. Entry point is main(), receives no arguments
  2. The following EEI methods are defined:
  • getDataLength() -> i32
  • copyData(offset: i32ptr, length: i32, memoryOffset: i32ptr), where memoryOffset is the memory area of the current execution to copy data to
  • setStorage(key: i32ptr, valuePtr: i32ptr, valueLength: i32)
  • getStorageSize(key: i32ptr) -> i32
  • getStorage(key: i32ptr, offset: i32, length: i32, memoryOffset: i32ptr)
  • saveReceipt(target: i32ptr, dataPtr: i32ptr, dataLength: i32)
  • call(id: u64, dataPtr: i32ptr, dataLength: i32) -> i32 where it returns execution status
  • getResponseSize() -> i32 size of the data returned by previous call
  • getResponse(offset: i32, length: i32, memoryOffset: i32ptr)
  • currentShard() -> u64
  • getRecentBeaconStateRoot(slot: i32, memoryOffset: i32ptr)
  • getRecentShardStateRoot(slot: i32, memoryOffset: i32ptr)
  • abort() to signal failure
  • finish() to signal success
  • executeCode(codePtr: i32ptr, codeLength: i32, dataPtr: i32ptr, dataLength: i32)

Differences to @vbuterin's version:

  • adapted it to the fact that wasm cannot handle 256-bit data natively
  • execution input (data) must be retrieved via copyData
  • call returns a result code and data must be retrieved separately

axic avatar May 02 '19 15:05 axic