From a1f2d3be633838f31a3d3585ae6bb4aefb655584 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Sat, 4 Aug 2018 01:41:05 +0100 Subject: [PATCH 1/4] Remove dead code --- wasm/generateInterface.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/wasm/generateInterface.js b/wasm/generateInterface.js index 59d3ed44..2245f88c 100644 --- a/wasm/generateInterface.js +++ b/wasm/generateInterface.js @@ -286,7 +286,6 @@ function generateManifest (interfaceManifest, opts) { // generate the call to the interface let spOffset = 0 let numOfLocals = 0 - let lastOffset let call = `(call $${op.name}` op.input.forEach((input) => { if (input === 'i128' || input == 'address') { @@ -331,7 +330,6 @@ function generateManifest (interfaceManifest, opts) { } else if (input === 'i64') { call += checkOverflowStackItem64(spOffset) } else if (input === 'writeOffset' || input === 'readOffset') { - lastOffset = input locals += `(local $offset${numOfLocals} i32)` body += `(set_local $offset${numOfLocals} ${checkOverflowStackItem256(spOffset)})` call += `(get_local $offset${numOfLocals})` From 8355b436c99445dcae2f61d9f013bdb7c54b1a28 Mon Sep 17 00:00:00 2001 From: Lane Rettig Date: Sat, 2 Jun 2018 20:31:36 -0300 Subject: [PATCH 2/4] Clean up logic to make code more readable --- wasm/generateInterface.js | 49 +++++++++++++-------------------------- 1 file changed, 16 insertions(+), 33 deletions(-) diff --git a/wasm/generateInterface.js b/wasm/generateInterface.js index 2245f88c..177b3dd3 100644 --- a/wasm/generateInterface.js +++ b/wasm/generateInterface.js @@ -333,11 +333,7 @@ function generateManifest (interfaceManifest, opts) { locals += `(local $offset${numOfLocals} i32)` body += `(set_local $offset${numOfLocals} ${checkOverflowStackItem256(spOffset)})` call += `(get_local $offset${numOfLocals})` - } else if (input === 'length' && (opcode === 'CALL' || opcode === 'CALLCODE' || opcode === 'DELEGATECALL' || opcode === 'STATICCALL')) { - // CALLs in EVM have 7 arguments - // but in ewasm CALLs only have 5 arguments - // so delete the bottom two stack elements, after processing the 5th argument - + } else if (input === 'length') { locals += `(local $length${numOfLocals} i32)` body += `(set_local $length${numOfLocals} ${checkOverflowStackItem256(spOffset)})` @@ -348,21 +344,13 @@ function generateManifest (interfaceManifest, opts) { call += `(get_local $length${numOfLocals})` numOfLocals++ - // delete 6th stack element - spOffset-- - - // delete 7th stack element - spOffset-- - } else if (input === 'length' && (opcode !== 'CALL' && opcode !== 'CALLCODE' && opcode !== 'DELEGATECALL' && opcode !== 'STATICCALL')) { - locals += `(local $length${numOfLocals} i32)` - body += `(set_local $length${numOfLocals} ${checkOverflowStackItem256(spOffset)})` - - body += ` - (call $memusegas (get_local $offset${numOfLocals}) (get_local $length${numOfLocals})) - (set_local $offset${numOfLocals} (i32.add (get_global $memstart) (get_local $offset${numOfLocals})))` - - call += `(get_local $length${numOfLocals})` - numOfLocals++ + // CALLs in EVM have 7 arguments + // but in ewasm CALLs only have 5 arguments + // so delete the bottom two stack elements, after processing the 5th argument + if (opcode === 'CALL' || opcode === 'CALLCODE') { + spOffset-- + spOffset-- + } } spOffset-- }) @@ -408,21 +396,16 @@ function generateManifest (interfaceManifest, opts) { call += '(get_local $callback)' } - if (opcode === 'CALL' || opcode === 'CALLCODE' || opcode === 'DELEGATECALL' || opcode === 'STATICCALL') { - call = - `(i64.store - (i32.add (get_global $sp) (i32.const ${spOffset * 32})) - (i64.extend_u/i32 - (i32.eqz ${call}) ;; flip CALL result from EEI to EVM convention (0 -> 1, 1,2,.. -> 1) - )))` - + let wrapper + if (opcode === 'CALL' || opcode === 'CALLCODE' || opcode === 'DELEGATECALL') { + // flip CALL result from EEI to EVM convention (0 -> 1, 1,2,.. -> 0) + wrapper = `(i32.eqz ${call})` } else { - call = - `(i64.store - (i32.add (get_global $sp) (i32.const ${spOffset * 32})) - (i64.extend_u/i32 - ${call})))` + wrapper = call } + call = `(i64.store + (i32.add (get_global $sp) (i32.const ${spOffset * 32})) + (i64.extend_u/i32 ${wrapper})))` call += cleanupStackItem64(spOffset) } else if (output === 'i64') { From aa8ca04385be92a0a7ef481bd792651ea3ea6b9e Mon Sep 17 00:00:00 2001 From: Lane Rettig Date: Sat, 2 Jun 2018 20:37:06 -0300 Subject: [PATCH 3/4] Fix CREATE Update input and output. This opcode requires special treatment hence an additional case in the conditional. We only overwrite the value stored in the opointer (with zero) if the call does not succeed. --- include/wast-async.h | 20 ++++++++++---------- include/wast.h | 20 ++++++++++---------- wasm/generateInterface.js | 13 +++++++++++-- wasm/wast-async.json | 20 ++++++++++---------- wasm/wast.json | 20 ++++++++++---------- 5 files changed, 51 insertions(+), 42 deletions(-) diff --git a/include/wast-async.h b/include/wast-async.h index 8049bd6f..18eb282b 100644 --- a/include/wast-async.h +++ b/include/wast-async.h @@ -50,7 +50,7 @@ namespace evm2wasm } },{ opcodeEnum::CALLDATASIZE, { - .wast = ";; generated by ./wasm/generateInterface.js\n(func $CALLDATASIZE (i64.store\n (i32.add (get_global $sp) (i32.const 32))\n (i64.extend_u/i32\n (call $getCallDataSize)))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const 56)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 48)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 40)) (i64.const 0)))", + .wast = ";; generated by ./wasm/generateInterface.js\n(func $CALLDATASIZE (i64.store\n (i32.add (get_global $sp) (i32.const 32))\n (i64.extend_u/i32 (call $getCallDataSize)))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const 56)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 48)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 40)) (i64.const 0)))", .imports = "(import \"ethereum\" \"getCallDataSize\" (func $getCallDataSize (result i32)))" } },{ @@ -60,7 +60,7 @@ namespace evm2wasm } },{ opcodeEnum::CODESIZE, { - .wast = ";; generated by ./wasm/generateInterface.js\n(func $CODESIZE (param $callback i32) (i64.store\n (i32.add (get_global $sp) (i32.const 32))\n (i64.extend_u/i32\n (call $getCodeSize(get_local $callback))))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const 56)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 48)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 40)) (i64.const 0)))", + .wast = ";; generated by ./wasm/generateInterface.js\n(func $CODESIZE (param $callback i32) (i64.store\n (i32.add (get_global $sp) (i32.const 32))\n (i64.extend_u/i32 (call $getCodeSize(get_local $callback))))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const 56)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 48)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 40)) (i64.const 0)))", .imports = "(import \"ethereum\" \"getCodeSize\" (func $getCodeSize (param i32) (result i32)))" } },{ @@ -70,7 +70,7 @@ namespace evm2wasm } },{ opcodeEnum::EXTCODESIZE, { - .wast = ";; generated by ./wasm/generateInterface.js\n(func $EXTCODESIZE (param $callback i32) (i64.store\n (i32.add (get_global $sp) (i32.const 0))\n (i64.extend_u/i32\n (call $getExternalCodeSize(get_global $sp)(get_local $callback))))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const 24)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 16)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 8)) (i64.const 0)))", + .wast = ";; generated by ./wasm/generateInterface.js\n(func $EXTCODESIZE (param $callback i32) (i64.store\n (i32.add (get_global $sp) (i32.const 0))\n (i64.extend_u/i32 (call $getExternalCodeSize(get_global $sp)(get_local $callback))))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const 24)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 16)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 8)) (i64.const 0)))", .imports = "(import \"ethereum\" \"getExternalCodeSize\" (func $getExternalCodeSize (param i32 i32) (result i32)))" } },{ @@ -115,27 +115,27 @@ namespace evm2wasm } },{ opcodeEnum::CREATE, { - .wast = ";; generated by ./wasm/generateInterface.js\n(func $CREATE (param $callback i32)(local $offset0 i32)(local $length0 i32) (set_local $offset0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -32)))\n (i64.load (i32.add (get_global $sp) (i32.const -24)))\n (i64.load (i32.add (get_global $sp) (i32.const -16)))\n (i64.load (i32.add (get_global $sp) (i32.const -8)))))(set_local $length0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -64)))\n (i64.load (i32.add (get_global $sp) (i32.const -56)))\n (i64.load (i32.add (get_global $sp) (i32.const -48)))\n (i64.load (i32.add (get_global $sp) (i32.const -40)))))\n (call $memusegas (get_local $offset0) (get_local $length0))\n (set_local $offset0 (i32.add (get_global $memstart) (get_local $offset0))) (call $create(get_global $sp)(get_local $offset0)(get_local $length0) (i32.add (get_global $sp) (i32.const -64))(get_local $callback))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const -40)) (i64.const 0))\n (i32.store (i32.add (get_global $sp) (i32.const -44)) (i32.const 0)))", - .imports = "(import \"ethereum\" \"create\" (func $create (param i32 i32 i32 i32 i32) ))" + .wast = ";; generated by ./wasm/generateInterface.js\n(func $CREATE (param $callback i32)(local $offset0 i32)(local $length0 i32) (set_local $offset0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -32)))\n (i64.load (i32.add (get_global $sp) (i32.const -24)))\n (i64.load (i32.add (get_global $sp) (i32.const -16)))\n (i64.load (i32.add (get_global $sp) (i32.const -8)))))(set_local $length0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -64)))\n (i64.load (i32.add (get_global $sp) (i32.const -56)))\n (i64.load (i32.add (get_global $sp) (i32.const -48)))\n (i64.load (i32.add (get_global $sp) (i32.const -40)))))\n (call $memusegas (get_local $offset0) (get_local $length0))\n (set_local $offset0 (i32.add (get_global $memstart) (get_local $offset0))) (if (i32.ne (call $create(get_global $sp)(get_local $offset0)(get_local $length0)(i32.add (get_global $sp) (i32.const -64))) (i32.const 0))\n (then (i64.store\n (i32.add (get_global $sp) (i32.const -64))\n (i64.const 0)))))", + .imports = "(import \"ethereum\" \"create\" (func $create (param i32 i32 i32 i32 i32) (result i32)))" } },{ opcodeEnum::CALL, { - .wast = ";; generated by ./wasm/generateInterface.js\n(func $CALL (param $callback i32)(local $offset0 i32)(local $length0 i32) (set_local $offset0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -96)))\n (i64.load (i32.add (get_global $sp) (i32.const -88)))\n (i64.load (i32.add (get_global $sp) (i32.const -80)))\n (i64.load (i32.add (get_global $sp) (i32.const -72)))))(set_local $length0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -128)))\n (i64.load (i32.add (get_global $sp) (i32.const -120)))\n (i64.load (i32.add (get_global $sp) (i32.const -112)))\n (i64.load (i32.add (get_global $sp) (i32.const -104)))))\n (call $memusegas (get_local $offset0) (get_local $length0))\n (set_local $offset0 (i32.add (get_global $memstart) (get_local $offset0))) (i64.store\n (i32.add (get_global $sp) (i32.const -192))\n (i64.extend_u/i32\n (i32.eqz (call $call(call $check_overflow_i64\n (i64.load (i32.add (get_global $sp) (i32.const 0)))\n (i64.load (i32.add (get_global $sp) (i32.const 8)))\n (i64.load (i32.add (get_global $sp) (i32.const 16)))\n (i64.load (i32.add (get_global $sp) (i32.const 24))))(i32.add (get_global $sp) (i32.const -32))(i32.add (get_global $sp) (i32.const -64))(get_local $offset0)(get_local $length0)(get_local $callback)) ;; flip CALL result from EEI to EVM convention (0 -> 1, 1,2,.. -> 1)\n )))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const -168)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -176)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -184)) (i64.const 0)))", + .wast = ";; generated by ./wasm/generateInterface.js\n(func $CALL (param $callback i32)(local $offset0 i32)(local $length0 i32) (set_local $offset0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -96)))\n (i64.load (i32.add (get_global $sp) (i32.const -88)))\n (i64.load (i32.add (get_global $sp) (i32.const -80)))\n (i64.load (i32.add (get_global $sp) (i32.const -72)))))(set_local $length0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -128)))\n (i64.load (i32.add (get_global $sp) (i32.const -120)))\n (i64.load (i32.add (get_global $sp) (i32.const -112)))\n (i64.load (i32.add (get_global $sp) (i32.const -104)))))\n (call $memusegas (get_local $offset0) (get_local $length0))\n (set_local $offset0 (i32.add (get_global $memstart) (get_local $offset0))) (i64.store\n (i32.add (get_global $sp) (i32.const -192))\n (i64.extend_u/i32 (i32.eqz (call $call(call $check_overflow_i64\n (i64.load (i32.add (get_global $sp) (i32.const 0)))\n (i64.load (i32.add (get_global $sp) (i32.const 8)))\n (i64.load (i32.add (get_global $sp) (i32.const 16)))\n (i64.load (i32.add (get_global $sp) (i32.const 24))))(i32.add (get_global $sp) (i32.const -32))(i32.add (get_global $sp) (i32.const -64))(get_local $offset0)(get_local $length0)(get_local $callback)))))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const -168)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -176)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -184)) (i64.const 0)))", .imports = "(import \"ethereum\" \"call\" (func $call (param i64 i32 i32 i32 i32 i32) (result i32)))" } },{ opcodeEnum::CALLCODE, { - .wast = ";; generated by ./wasm/generateInterface.js\n(func $CALLCODE (param $callback i32)(local $offset0 i32)(local $length0 i32) (set_local $offset0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -96)))\n (i64.load (i32.add (get_global $sp) (i32.const -88)))\n (i64.load (i32.add (get_global $sp) (i32.const -80)))\n (i64.load (i32.add (get_global $sp) (i32.const -72)))))(set_local $length0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -128)))\n (i64.load (i32.add (get_global $sp) (i32.const -120)))\n (i64.load (i32.add (get_global $sp) (i32.const -112)))\n (i64.load (i32.add (get_global $sp) (i32.const -104)))))\n (call $memusegas (get_local $offset0) (get_local $length0))\n (set_local $offset0 (i32.add (get_global $memstart) (get_local $offset0))) (i64.store\n (i32.add (get_global $sp) (i32.const -192))\n (i64.extend_u/i32\n (i32.eqz (call $callCode(call $check_overflow_i64\n (i64.load (i32.add (get_global $sp) (i32.const 0)))\n (i64.load (i32.add (get_global $sp) (i32.const 8)))\n (i64.load (i32.add (get_global $sp) (i32.const 16)))\n (i64.load (i32.add (get_global $sp) (i32.const 24))))(i32.add (get_global $sp) (i32.const -32))(i32.add (get_global $sp) (i32.const -64))(get_local $offset0)(get_local $length0)(get_local $callback)) ;; flip CALL result from EEI to EVM convention (0 -> 1, 1,2,.. -> 1)\n )))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const -168)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -176)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -184)) (i64.const 0)))", + .wast = ";; generated by ./wasm/generateInterface.js\n(func $CALLCODE (param $callback i32)(local $offset0 i32)(local $length0 i32) (set_local $offset0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -96)))\n (i64.load (i32.add (get_global $sp) (i32.const -88)))\n (i64.load (i32.add (get_global $sp) (i32.const -80)))\n (i64.load (i32.add (get_global $sp) (i32.const -72)))))(set_local $length0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -128)))\n (i64.load (i32.add (get_global $sp) (i32.const -120)))\n (i64.load (i32.add (get_global $sp) (i32.const -112)))\n (i64.load (i32.add (get_global $sp) (i32.const -104)))))\n (call $memusegas (get_local $offset0) (get_local $length0))\n (set_local $offset0 (i32.add (get_global $memstart) (get_local $offset0))) (i64.store\n (i32.add (get_global $sp) (i32.const -192))\n (i64.extend_u/i32 (i32.eqz (call $callCode(call $check_overflow_i64\n (i64.load (i32.add (get_global $sp) (i32.const 0)))\n (i64.load (i32.add (get_global $sp) (i32.const 8)))\n (i64.load (i32.add (get_global $sp) (i32.const 16)))\n (i64.load (i32.add (get_global $sp) (i32.const 24))))(i32.add (get_global $sp) (i32.const -32))(i32.add (get_global $sp) (i32.const -64))(get_local $offset0)(get_local $length0)(get_local $callback)))))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const -168)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -176)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -184)) (i64.const 0)))", .imports = "(import \"ethereum\" \"callCode\" (func $callCode (param i64 i32 i32 i32 i32 i32) (result i32)))" } },{ opcodeEnum::DELEGATECALL, { - .wast = ";; generated by ./wasm/generateInterface.js\n(func $DELEGATECALL (param $callback i32)(local $offset0 i32)(local $length0 i32) (set_local $offset0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -96)))\n (i64.load (i32.add (get_global $sp) (i32.const -88)))\n (i64.load (i32.add (get_global $sp) (i32.const -80)))\n (i64.load (i32.add (get_global $sp) (i32.const -72)))))(set_local $length0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -128)))\n (i64.load (i32.add (get_global $sp) (i32.const -120)))\n (i64.load (i32.add (get_global $sp) (i32.const -112)))\n (i64.load (i32.add (get_global $sp) (i32.const -104)))))\n (call $memusegas (get_local $offset0) (get_local $length0))\n (set_local $offset0 (i32.add (get_global $memstart) (get_local $offset0))) (i64.store\n (i32.add (get_global $sp) (i32.const -192))\n (i64.extend_u/i32\n (i32.eqz (call $callDelegate(call $check_overflow_i64\n (i64.load (i32.add (get_global $sp) (i32.const 0)))\n (i64.load (i32.add (get_global $sp) (i32.const 8)))\n (i64.load (i32.add (get_global $sp) (i32.const 16)))\n (i64.load (i32.add (get_global $sp) (i32.const 24))))(i32.add (get_global $sp) (i32.const -32))(i32.add (get_global $sp) (i32.const -64))(get_local $offset0)(get_local $length0)(get_local $callback)) ;; flip CALL result from EEI to EVM convention (0 -> 1, 1,2,.. -> 1)\n )))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const -168)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -176)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -184)) (i64.const 0)))", + .wast = ";; generated by ./wasm/generateInterface.js\n(func $DELEGATECALL (param $callback i32)(local $offset0 i32)(local $length0 i32) (set_local $offset0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -96)))\n (i64.load (i32.add (get_global $sp) (i32.const -88)))\n (i64.load (i32.add (get_global $sp) (i32.const -80)))\n (i64.load (i32.add (get_global $sp) (i32.const -72)))))(set_local $length0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -128)))\n (i64.load (i32.add (get_global $sp) (i32.const -120)))\n (i64.load (i32.add (get_global $sp) (i32.const -112)))\n (i64.load (i32.add (get_global $sp) (i32.const -104)))))\n (call $memusegas (get_local $offset0) (get_local $length0))\n (set_local $offset0 (i32.add (get_global $memstart) (get_local $offset0))) (i64.store\n (i32.add (get_global $sp) (i32.const -128))\n (i64.extend_u/i32 (i32.eqz (call $callDelegate(call $check_overflow_i64\n (i64.load (i32.add (get_global $sp) (i32.const 0)))\n (i64.load (i32.add (get_global $sp) (i32.const 8)))\n (i64.load (i32.add (get_global $sp) (i32.const 16)))\n (i64.load (i32.add (get_global $sp) (i32.const 24))))(i32.add (get_global $sp) (i32.const -32))(i32.add (get_global $sp) (i32.const -64))(get_local $offset0)(get_local $length0)(get_local $callback)))))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const -104)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -112)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -120)) (i64.const 0)))", .imports = "(import \"ethereum\" \"callDelegate\" (func $callDelegate (param i64 i32 i32 i32 i32 i32) (result i32)))" } },{ opcodeEnum::STATICCALL, { - .wast = ";; generated by ./wasm/generateInterface.js\n(func $STATICCALL (param $callback i32)(local $offset0 i32)(local $length0 i32) (set_local $offset0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -64)))\n (i64.load (i32.add (get_global $sp) (i32.const -56)))\n (i64.load (i32.add (get_global $sp) (i32.const -48)))\n (i64.load (i32.add (get_global $sp) (i32.const -40)))))(set_local $length0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -96)))\n (i64.load (i32.add (get_global $sp) (i32.const -88)))\n (i64.load (i32.add (get_global $sp) (i32.const -80)))\n (i64.load (i32.add (get_global $sp) (i32.const -72)))))\n (call $memusegas (get_local $offset0) (get_local $length0))\n (set_local $offset0 (i32.add (get_global $memstart) (get_local $offset0))) (i64.store\n (i32.add (get_global $sp) (i32.const -160))\n (i64.extend_u/i32\n (i32.eqz (call $callStatic(call $check_overflow_i64\n (i64.load (i32.add (get_global $sp) (i32.const 0)))\n (i64.load (i32.add (get_global $sp) (i32.const 8)))\n (i64.load (i32.add (get_global $sp) (i32.const 16)))\n (i64.load (i32.add (get_global $sp) (i32.const 24))))(i32.add (get_global $sp) (i32.const -32))(get_local $offset0)(get_local $length0)(get_local $callback)) ;; flip CALL result from EEI to EVM convention (0 -> 1, 1,2,.. -> 1)\n )))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const -136)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -144)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -152)) (i64.const 0)))", + .wast = ";; generated by ./wasm/generateInterface.js\n(func $STATICCALL (param $callback i32)(local $offset0 i32)(local $length0 i32) (set_local $offset0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -64)))\n (i64.load (i32.add (get_global $sp) (i32.const -56)))\n (i64.load (i32.add (get_global $sp) (i32.const -48)))\n (i64.load (i32.add (get_global $sp) (i32.const -40)))))(set_local $length0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -96)))\n (i64.load (i32.add (get_global $sp) (i32.const -88)))\n (i64.load (i32.add (get_global $sp) (i32.const -80)))\n (i64.load (i32.add (get_global $sp) (i32.const -72)))))\n (call $memusegas (get_local $offset0) (get_local $length0))\n (set_local $offset0 (i32.add (get_global $memstart) (get_local $offset0))) (i64.store\n (i32.add (get_global $sp) (i32.const -96))\n (i64.extend_u/i32 (call $callStatic(call $check_overflow_i64\n (i64.load (i32.add (get_global $sp) (i32.const 0)))\n (i64.load (i32.add (get_global $sp) (i32.const 8)))\n (i64.load (i32.add (get_global $sp) (i32.const 16)))\n (i64.load (i32.add (get_global $sp) (i32.const 24))))(i32.add (get_global $sp) (i32.const -32))(get_local $offset0)(get_local $length0)(get_local $callback))))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const -72)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -80)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -88)) (i64.const 0)))", .imports = "(import \"ethereum\" \"callStatic\" (func $callStatic (param i64 i32 i32 i32 i32) (result i32)))" } },{ @@ -145,7 +145,7 @@ namespace evm2wasm } },{ opcodeEnum::RETURNDATASIZE, { - .wast = ";; generated by ./wasm/generateInterface.js\n(func $RETURNDATASIZE (i64.store\n (i32.add (get_global $sp) (i32.const 32))\n (i64.extend_u/i32\n (call $getReturnDataSize)))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const 56)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 48)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 40)) (i64.const 0)))", + .wast = ";; generated by ./wasm/generateInterface.js\n(func $RETURNDATASIZE (i64.store\n (i32.add (get_global $sp) (i32.const 32))\n (i64.extend_u/i32 (call $getReturnDataSize)))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const 56)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 48)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 40)) (i64.const 0)))", .imports = "(import \"ethereum\" \"getReturnDataSize\" (func $getReturnDataSize (result i32)))" } },{ diff --git a/include/wast.h b/include/wast.h index e1f892a6..46589625 100644 --- a/include/wast.h +++ b/include/wast.h @@ -50,7 +50,7 @@ namespace evm2wasm } },{ opcodeEnum::CALLDATASIZE, { - .wast = ";; generated by ./wasm/generateInterface.js\n(func $CALLDATASIZE (i64.store\n (i32.add (get_global $sp) (i32.const 32))\n (i64.extend_u/i32\n (call $getCallDataSize)))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const 56)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 48)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 40)) (i64.const 0)))", + .wast = ";; generated by ./wasm/generateInterface.js\n(func $CALLDATASIZE (i64.store\n (i32.add (get_global $sp) (i32.const 32))\n (i64.extend_u/i32 (call $getCallDataSize)))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const 56)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 48)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 40)) (i64.const 0)))", .imports = "(import \"ethereum\" \"getCallDataSize\" (func $getCallDataSize (result i32)))" } },{ @@ -60,7 +60,7 @@ namespace evm2wasm } },{ opcodeEnum::CODESIZE, { - .wast = ";; generated by ./wasm/generateInterface.js\n(func $CODESIZE (i64.store\n (i32.add (get_global $sp) (i32.const 32))\n (i64.extend_u/i32\n (call $getCodeSize)))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const 56)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 48)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 40)) (i64.const 0)))", + .wast = ";; generated by ./wasm/generateInterface.js\n(func $CODESIZE (i64.store\n (i32.add (get_global $sp) (i32.const 32))\n (i64.extend_u/i32 (call $getCodeSize)))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const 56)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 48)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 40)) (i64.const 0)))", .imports = "(import \"ethereum\" \"getCodeSize\" (func $getCodeSize (result i32)))" } },{ @@ -70,7 +70,7 @@ namespace evm2wasm } },{ opcodeEnum::EXTCODESIZE, { - .wast = ";; generated by ./wasm/generateInterface.js\n(func $EXTCODESIZE (i64.store\n (i32.add (get_global $sp) (i32.const 0))\n (i64.extend_u/i32\n (call $getExternalCodeSize(get_global $sp))))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const 24)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 16)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 8)) (i64.const 0)))", + .wast = ";; generated by ./wasm/generateInterface.js\n(func $EXTCODESIZE (i64.store\n (i32.add (get_global $sp) (i32.const 0))\n (i64.extend_u/i32 (call $getExternalCodeSize(get_global $sp))))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const 24)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 16)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 8)) (i64.const 0)))", .imports = "(import \"ethereum\" \"getExternalCodeSize\" (func $getExternalCodeSize (param i32) (result i32)))" } },{ @@ -115,27 +115,27 @@ namespace evm2wasm } },{ opcodeEnum::CREATE, { - .wast = ";; generated by ./wasm/generateInterface.js\n(func $CREATE (local $offset0 i32)(local $length0 i32) (set_local $offset0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -32)))\n (i64.load (i32.add (get_global $sp) (i32.const -24)))\n (i64.load (i32.add (get_global $sp) (i32.const -16)))\n (i64.load (i32.add (get_global $sp) (i32.const -8)))))(set_local $length0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -64)))\n (i64.load (i32.add (get_global $sp) (i32.const -56)))\n (i64.load (i32.add (get_global $sp) (i32.const -48)))\n (i64.load (i32.add (get_global $sp) (i32.const -40)))))\n (call $memusegas (get_local $offset0) (get_local $length0))\n (set_local $offset0 (i32.add (get_global $memstart) (get_local $offset0))) (call $create(get_global $sp)(get_local $offset0)(get_local $length0) (i32.add (get_global $sp) (i32.const -64)))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const -40)) (i64.const 0))\n (i32.store (i32.add (get_global $sp) (i32.const -44)) (i32.const 0)))", - .imports = "(import \"ethereum\" \"create\" (func $create (param i32 i32 i32 i32) ))" + .wast = ";; generated by ./wasm/generateInterface.js\n(func $CREATE (local $offset0 i32)(local $length0 i32) (set_local $offset0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -32)))\n (i64.load (i32.add (get_global $sp) (i32.const -24)))\n (i64.load (i32.add (get_global $sp) (i32.const -16)))\n (i64.load (i32.add (get_global $sp) (i32.const -8)))))(set_local $length0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -64)))\n (i64.load (i32.add (get_global $sp) (i32.const -56)))\n (i64.load (i32.add (get_global $sp) (i32.const -48)))\n (i64.load (i32.add (get_global $sp) (i32.const -40)))))\n (call $memusegas (get_local $offset0) (get_local $length0))\n (set_local $offset0 (i32.add (get_global $memstart) (get_local $offset0))) (if (i32.ne (call $create(get_global $sp)(get_local $offset0)(get_local $length0)(i32.add (get_global $sp) (i32.const -64))) (i32.const 0))\n (then (i64.store\n (i32.add (get_global $sp) (i32.const -64))\n (i64.const 0)))))", + .imports = "(import \"ethereum\" \"create\" (func $create (param i32 i32 i32 i32) (result i32)))" } },{ opcodeEnum::CALL, { - .wast = ";; generated by ./wasm/generateInterface.js\n(func $CALL (local $offset0 i32)(local $length0 i32) (set_local $offset0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -96)))\n (i64.load (i32.add (get_global $sp) (i32.const -88)))\n (i64.load (i32.add (get_global $sp) (i32.const -80)))\n (i64.load (i32.add (get_global $sp) (i32.const -72)))))(set_local $length0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -128)))\n (i64.load (i32.add (get_global $sp) (i32.const -120)))\n (i64.load (i32.add (get_global $sp) (i32.const -112)))\n (i64.load (i32.add (get_global $sp) (i32.const -104)))))\n (call $memusegas (get_local $offset0) (get_local $length0))\n (set_local $offset0 (i32.add (get_global $memstart) (get_local $offset0))) (i64.store\n (i32.add (get_global $sp) (i32.const -192))\n (i64.extend_u/i32\n (i32.eqz (call $call(call $check_overflow_i64\n (i64.load (i32.add (get_global $sp) (i32.const 0)))\n (i64.load (i32.add (get_global $sp) (i32.const 8)))\n (i64.load (i32.add (get_global $sp) (i32.const 16)))\n (i64.load (i32.add (get_global $sp) (i32.const 24))))(i32.add (get_global $sp) (i32.const -32))(i32.add (get_global $sp) (i32.const -64))(get_local $offset0)(get_local $length0)) ;; flip CALL result from EEI to EVM convention (0 -> 1, 1,2,.. -> 1)\n )))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const -168)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -176)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -184)) (i64.const 0)))", + .wast = ";; generated by ./wasm/generateInterface.js\n(func $CALL (local $offset0 i32)(local $length0 i32) (set_local $offset0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -96)))\n (i64.load (i32.add (get_global $sp) (i32.const -88)))\n (i64.load (i32.add (get_global $sp) (i32.const -80)))\n (i64.load (i32.add (get_global $sp) (i32.const -72)))))(set_local $length0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -128)))\n (i64.load (i32.add (get_global $sp) (i32.const -120)))\n (i64.load (i32.add (get_global $sp) (i32.const -112)))\n (i64.load (i32.add (get_global $sp) (i32.const -104)))))\n (call $memusegas (get_local $offset0) (get_local $length0))\n (set_local $offset0 (i32.add (get_global $memstart) (get_local $offset0))) (i64.store\n (i32.add (get_global $sp) (i32.const -192))\n (i64.extend_u/i32 (i32.eqz (call $call(call $check_overflow_i64\n (i64.load (i32.add (get_global $sp) (i32.const 0)))\n (i64.load (i32.add (get_global $sp) (i32.const 8)))\n (i64.load (i32.add (get_global $sp) (i32.const 16)))\n (i64.load (i32.add (get_global $sp) (i32.const 24))))(i32.add (get_global $sp) (i32.const -32))(i32.add (get_global $sp) (i32.const -64))(get_local $offset0)(get_local $length0)))))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const -168)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -176)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -184)) (i64.const 0)))", .imports = "(import \"ethereum\" \"call\" (func $call (param i64 i32 i32 i32 i32) (result i32)))" } },{ opcodeEnum::CALLCODE, { - .wast = ";; generated by ./wasm/generateInterface.js\n(func $CALLCODE (local $offset0 i32)(local $length0 i32) (set_local $offset0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -96)))\n (i64.load (i32.add (get_global $sp) (i32.const -88)))\n (i64.load (i32.add (get_global $sp) (i32.const -80)))\n (i64.load (i32.add (get_global $sp) (i32.const -72)))))(set_local $length0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -128)))\n (i64.load (i32.add (get_global $sp) (i32.const -120)))\n (i64.load (i32.add (get_global $sp) (i32.const -112)))\n (i64.load (i32.add (get_global $sp) (i32.const -104)))))\n (call $memusegas (get_local $offset0) (get_local $length0))\n (set_local $offset0 (i32.add (get_global $memstart) (get_local $offset0))) (i64.store\n (i32.add (get_global $sp) (i32.const -192))\n (i64.extend_u/i32\n (i32.eqz (call $callCode(call $check_overflow_i64\n (i64.load (i32.add (get_global $sp) (i32.const 0)))\n (i64.load (i32.add (get_global $sp) (i32.const 8)))\n (i64.load (i32.add (get_global $sp) (i32.const 16)))\n (i64.load (i32.add (get_global $sp) (i32.const 24))))(i32.add (get_global $sp) (i32.const -32))(i32.add (get_global $sp) (i32.const -64))(get_local $offset0)(get_local $length0)) ;; flip CALL result from EEI to EVM convention (0 -> 1, 1,2,.. -> 1)\n )))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const -168)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -176)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -184)) (i64.const 0)))", + .wast = ";; generated by ./wasm/generateInterface.js\n(func $CALLCODE (local $offset0 i32)(local $length0 i32) (set_local $offset0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -96)))\n (i64.load (i32.add (get_global $sp) (i32.const -88)))\n (i64.load (i32.add (get_global $sp) (i32.const -80)))\n (i64.load (i32.add (get_global $sp) (i32.const -72)))))(set_local $length0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -128)))\n (i64.load (i32.add (get_global $sp) (i32.const -120)))\n (i64.load (i32.add (get_global $sp) (i32.const -112)))\n (i64.load (i32.add (get_global $sp) (i32.const -104)))))\n (call $memusegas (get_local $offset0) (get_local $length0))\n (set_local $offset0 (i32.add (get_global $memstart) (get_local $offset0))) (i64.store\n (i32.add (get_global $sp) (i32.const -192))\n (i64.extend_u/i32 (i32.eqz (call $callCode(call $check_overflow_i64\n (i64.load (i32.add (get_global $sp) (i32.const 0)))\n (i64.load (i32.add (get_global $sp) (i32.const 8)))\n (i64.load (i32.add (get_global $sp) (i32.const 16)))\n (i64.load (i32.add (get_global $sp) (i32.const 24))))(i32.add (get_global $sp) (i32.const -32))(i32.add (get_global $sp) (i32.const -64))(get_local $offset0)(get_local $length0)))))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const -168)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -176)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -184)) (i64.const 0)))", .imports = "(import \"ethereum\" \"callCode\" (func $callCode (param i64 i32 i32 i32 i32) (result i32)))" } },{ opcodeEnum::DELEGATECALL, { - .wast = ";; generated by ./wasm/generateInterface.js\n(func $DELEGATECALL (local $offset0 i32)(local $length0 i32) (set_local $offset0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -96)))\n (i64.load (i32.add (get_global $sp) (i32.const -88)))\n (i64.load (i32.add (get_global $sp) (i32.const -80)))\n (i64.load (i32.add (get_global $sp) (i32.const -72)))))(set_local $length0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -128)))\n (i64.load (i32.add (get_global $sp) (i32.const -120)))\n (i64.load (i32.add (get_global $sp) (i32.const -112)))\n (i64.load (i32.add (get_global $sp) (i32.const -104)))))\n (call $memusegas (get_local $offset0) (get_local $length0))\n (set_local $offset0 (i32.add (get_global $memstart) (get_local $offset0))) (i64.store\n (i32.add (get_global $sp) (i32.const -192))\n (i64.extend_u/i32\n (i32.eqz (call $callDelegate(call $check_overflow_i64\n (i64.load (i32.add (get_global $sp) (i32.const 0)))\n (i64.load (i32.add (get_global $sp) (i32.const 8)))\n (i64.load (i32.add (get_global $sp) (i32.const 16)))\n (i64.load (i32.add (get_global $sp) (i32.const 24))))(i32.add (get_global $sp) (i32.const -32))(i32.add (get_global $sp) (i32.const -64))(get_local $offset0)(get_local $length0)) ;; flip CALL result from EEI to EVM convention (0 -> 1, 1,2,.. -> 1)\n )))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const -168)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -176)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -184)) (i64.const 0)))", + .wast = ";; generated by ./wasm/generateInterface.js\n(func $DELEGATECALL (local $offset0 i32)(local $length0 i32) (set_local $offset0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -96)))\n (i64.load (i32.add (get_global $sp) (i32.const -88)))\n (i64.load (i32.add (get_global $sp) (i32.const -80)))\n (i64.load (i32.add (get_global $sp) (i32.const -72)))))(set_local $length0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -128)))\n (i64.load (i32.add (get_global $sp) (i32.const -120)))\n (i64.load (i32.add (get_global $sp) (i32.const -112)))\n (i64.load (i32.add (get_global $sp) (i32.const -104)))))\n (call $memusegas (get_local $offset0) (get_local $length0))\n (set_local $offset0 (i32.add (get_global $memstart) (get_local $offset0))) (i64.store\n (i32.add (get_global $sp) (i32.const -128))\n (i64.extend_u/i32 (i32.eqz (call $callDelegate(call $check_overflow_i64\n (i64.load (i32.add (get_global $sp) (i32.const 0)))\n (i64.load (i32.add (get_global $sp) (i32.const 8)))\n (i64.load (i32.add (get_global $sp) (i32.const 16)))\n (i64.load (i32.add (get_global $sp) (i32.const 24))))(i32.add (get_global $sp) (i32.const -32))(i32.add (get_global $sp) (i32.const -64))(get_local $offset0)(get_local $length0)))))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const -104)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -112)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -120)) (i64.const 0)))", .imports = "(import \"ethereum\" \"callDelegate\" (func $callDelegate (param i64 i32 i32 i32 i32) (result i32)))" } },{ opcodeEnum::STATICCALL, { - .wast = ";; generated by ./wasm/generateInterface.js\n(func $STATICCALL (local $offset0 i32)(local $length0 i32) (set_local $offset0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -64)))\n (i64.load (i32.add (get_global $sp) (i32.const -56)))\n (i64.load (i32.add (get_global $sp) (i32.const -48)))\n (i64.load (i32.add (get_global $sp) (i32.const -40)))))(set_local $length0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -96)))\n (i64.load (i32.add (get_global $sp) (i32.const -88)))\n (i64.load (i32.add (get_global $sp) (i32.const -80)))\n (i64.load (i32.add (get_global $sp) (i32.const -72)))))\n (call $memusegas (get_local $offset0) (get_local $length0))\n (set_local $offset0 (i32.add (get_global $memstart) (get_local $offset0))) (i64.store\n (i32.add (get_global $sp) (i32.const -160))\n (i64.extend_u/i32\n (i32.eqz (call $callStatic(call $check_overflow_i64\n (i64.load (i32.add (get_global $sp) (i32.const 0)))\n (i64.load (i32.add (get_global $sp) (i32.const 8)))\n (i64.load (i32.add (get_global $sp) (i32.const 16)))\n (i64.load (i32.add (get_global $sp) (i32.const 24))))(i32.add (get_global $sp) (i32.const -32))(get_local $offset0)(get_local $length0)) ;; flip CALL result from EEI to EVM convention (0 -> 1, 1,2,.. -> 1)\n )))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const -136)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -144)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -152)) (i64.const 0)))", + .wast = ";; generated by ./wasm/generateInterface.js\n(func $STATICCALL (local $offset0 i32)(local $length0 i32) (set_local $offset0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -64)))\n (i64.load (i32.add (get_global $sp) (i32.const -56)))\n (i64.load (i32.add (get_global $sp) (i32.const -48)))\n (i64.load (i32.add (get_global $sp) (i32.const -40)))))(set_local $length0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -96)))\n (i64.load (i32.add (get_global $sp) (i32.const -88)))\n (i64.load (i32.add (get_global $sp) (i32.const -80)))\n (i64.load (i32.add (get_global $sp) (i32.const -72)))))\n (call $memusegas (get_local $offset0) (get_local $length0))\n (set_local $offset0 (i32.add (get_global $memstart) (get_local $offset0))) (i64.store\n (i32.add (get_global $sp) (i32.const -96))\n (i64.extend_u/i32 (call $callStatic(call $check_overflow_i64\n (i64.load (i32.add (get_global $sp) (i32.const 0)))\n (i64.load (i32.add (get_global $sp) (i32.const 8)))\n (i64.load (i32.add (get_global $sp) (i32.const 16)))\n (i64.load (i32.add (get_global $sp) (i32.const 24))))(i32.add (get_global $sp) (i32.const -32))(get_local $offset0)(get_local $length0))))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const -72)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -80)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -88)) (i64.const 0)))", .imports = "(import \"ethereum\" \"callStatic\" (func $callStatic (param i64 i32 i32 i32) (result i32)))" } },{ @@ -145,7 +145,7 @@ namespace evm2wasm } },{ opcodeEnum::RETURNDATASIZE, { - .wast = ";; generated by ./wasm/generateInterface.js\n(func $RETURNDATASIZE (i64.store\n (i32.add (get_global $sp) (i32.const 32))\n (i64.extend_u/i32\n (call $getReturnDataSize)))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const 56)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 48)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 40)) (i64.const 0)))", + .wast = ";; generated by ./wasm/generateInterface.js\n(func $RETURNDATASIZE (i64.store\n (i32.add (get_global $sp) (i32.const 32))\n (i64.extend_u/i32 (call $getReturnDataSize)))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const 56)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 48)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 40)) (i64.const 0)))", .imports = "(import \"ethereum\" \"getReturnDataSize\" (func $getReturnDataSize (result i32)))" } },{ diff --git a/wasm/generateInterface.js b/wasm/generateInterface.js index 177b3dd3..473a2717 100644 --- a/wasm/generateInterface.js +++ b/wasm/generateInterface.js @@ -134,8 +134,8 @@ const interfaceManifest = { CREATE: { name: 'create', async: true, - input: ['i128', 'readOffset', 'length'], - output: ['address'] + input: ['i128', 'readOffset', 'length', 'opointer'], + output: ['i32'] }, CALL: { name: 'call', @@ -391,6 +391,15 @@ function generateManifest (interfaceManifest, opts) { call += `) (drop (call $bswap_m256 (i32.add (i32.const 32) (get_global $sp)))) ` + } else if (opcode === 'CREATE') { + // Check the return value from the EEI method. + // 0 = success, 1 = failure, 2 = revert + // iff return === 0, there is nothing to do as the address has already been loaded. + // otherwise, we must return 0 instead, overwriting whatever was read from memory. + call = `(if (i32.ne ${call}) (i32.const 0)) + (then (i64.store + (i32.add (get_global $sp) (i32.const ${spOffset * 32})) + (i64.const 0))))` } else if (output === 'i32') { if (useAsyncAPI && op.async) { call += '(get_local $callback)' diff --git a/wasm/wast-async.json b/wasm/wast-async.json index 1f7579cb..128fea46 100644 --- a/wasm/wast-async.json +++ b/wasm/wast-async.json @@ -32,7 +32,7 @@ "imports": "(import \"ethereum\" \"getCallValue\" (func $getCallValue (param i32) ))" }, "CALLDATASIZE": { - "wast": ";; generated by ./wasm/generateInterface.js\n(func $CALLDATASIZE (i64.store\n (i32.add (get_global $sp) (i32.const 32))\n (i64.extend_u/i32\n (call $getCallDataSize)))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const 56)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 48)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 40)) (i64.const 0)))", + "wast": ";; generated by ./wasm/generateInterface.js\n(func $CALLDATASIZE (i64.store\n (i32.add (get_global $sp) (i32.const 32))\n (i64.extend_u/i32 (call $getCallDataSize)))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const 56)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 48)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 40)) (i64.const 0)))", "imports": "(import \"ethereum\" \"getCallDataSize\" (func $getCallDataSize (result i32)))" }, "CALLDATACOPY": { @@ -40,7 +40,7 @@ "imports": "(import \"ethereum\" \"callDataCopy\" (func $callDataCopy (param i32 i32 i32) ))" }, "CODESIZE": { - "wast": ";; generated by ./wasm/generateInterface.js\n(func $CODESIZE (param $callback i32) (i64.store\n (i32.add (get_global $sp) (i32.const 32))\n (i64.extend_u/i32\n (call $getCodeSize(get_local $callback))))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const 56)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 48)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 40)) (i64.const 0)))", + "wast": ";; generated by ./wasm/generateInterface.js\n(func $CODESIZE (param $callback i32) (i64.store\n (i32.add (get_global $sp) (i32.const 32))\n (i64.extend_u/i32 (call $getCodeSize(get_local $callback))))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const 56)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 48)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 40)) (i64.const 0)))", "imports": "(import \"ethereum\" \"getCodeSize\" (func $getCodeSize (param i32) (result i32)))" }, "CODECOPY": { @@ -48,7 +48,7 @@ "imports": "(import \"ethereum\" \"codeCopy\" (func $codeCopy (param i32 i32 i32 i32) ))" }, "EXTCODESIZE": { - "wast": ";; generated by ./wasm/generateInterface.js\n(func $EXTCODESIZE (param $callback i32) (i64.store\n (i32.add (get_global $sp) (i32.const 0))\n (i64.extend_u/i32\n (call $getExternalCodeSize(get_global $sp)(get_local $callback))))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const 24)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 16)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 8)) (i64.const 0)))", + "wast": ";; generated by ./wasm/generateInterface.js\n(func $EXTCODESIZE (param $callback i32) (i64.store\n (i32.add (get_global $sp) (i32.const 0))\n (i64.extend_u/i32 (call $getExternalCodeSize(get_global $sp)(get_local $callback))))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const 24)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 16)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 8)) (i64.const 0)))", "imports": "(import \"ethereum\" \"getExternalCodeSize\" (func $getExternalCodeSize (param i32 i32) (result i32)))" }, "EXTCODECOPY": { @@ -84,23 +84,23 @@ "imports": "(import \"ethereum\" \"getBlockGasLimit\" (func $getBlockGasLimit (result i64)))" }, "CREATE": { - "wast": ";; generated by ./wasm/generateInterface.js\n(func $CREATE (param $callback i32)(local $offset0 i32)(local $length0 i32) (set_local $offset0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -32)))\n (i64.load (i32.add (get_global $sp) (i32.const -24)))\n (i64.load (i32.add (get_global $sp) (i32.const -16)))\n (i64.load (i32.add (get_global $sp) (i32.const -8)))))(set_local $length0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -64)))\n (i64.load (i32.add (get_global $sp) (i32.const -56)))\n (i64.load (i32.add (get_global $sp) (i32.const -48)))\n (i64.load (i32.add (get_global $sp) (i32.const -40)))))\n (call $memusegas (get_local $offset0) (get_local $length0))\n (set_local $offset0 (i32.add (get_global $memstart) (get_local $offset0))) (call $create(get_global $sp)(get_local $offset0)(get_local $length0) (i32.add (get_global $sp) (i32.const -64))(get_local $callback))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const -40)) (i64.const 0))\n (i32.store (i32.add (get_global $sp) (i32.const -44)) (i32.const 0)))", - "imports": "(import \"ethereum\" \"create\" (func $create (param i32 i32 i32 i32 i32) ))" + "wast": ";; generated by ./wasm/generateInterface.js\n(func $CREATE (param $callback i32)(local $offset0 i32)(local $length0 i32) (set_local $offset0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -32)))\n (i64.load (i32.add (get_global $sp) (i32.const -24)))\n (i64.load (i32.add (get_global $sp) (i32.const -16)))\n (i64.load (i32.add (get_global $sp) (i32.const -8)))))(set_local $length0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -64)))\n (i64.load (i32.add (get_global $sp) (i32.const -56)))\n (i64.load (i32.add (get_global $sp) (i32.const -48)))\n (i64.load (i32.add (get_global $sp) (i32.const -40)))))\n (call $memusegas (get_local $offset0) (get_local $length0))\n (set_local $offset0 (i32.add (get_global $memstart) (get_local $offset0))) (if (i32.ne (call $create(get_global $sp)(get_local $offset0)(get_local $length0)(i32.add (get_global $sp) (i32.const -64))) (i32.const 0))\n (then (i64.store\n (i32.add (get_global $sp) (i32.const -64))\n (i64.const 0)))))", + "imports": "(import \"ethereum\" \"create\" (func $create (param i32 i32 i32 i32 i32) (result i32)))" }, "CALL": { - "wast": ";; generated by ./wasm/generateInterface.js\n(func $CALL (param $callback i32)(local $offset0 i32)(local $length0 i32) (set_local $offset0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -96)))\n (i64.load (i32.add (get_global $sp) (i32.const -88)))\n (i64.load (i32.add (get_global $sp) (i32.const -80)))\n (i64.load (i32.add (get_global $sp) (i32.const -72)))))(set_local $length0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -128)))\n (i64.load (i32.add (get_global $sp) (i32.const -120)))\n (i64.load (i32.add (get_global $sp) (i32.const -112)))\n (i64.load (i32.add (get_global $sp) (i32.const -104)))))\n (call $memusegas (get_local $offset0) (get_local $length0))\n (set_local $offset0 (i32.add (get_global $memstart) (get_local $offset0))) (i64.store\n (i32.add (get_global $sp) (i32.const -192))\n (i64.extend_u/i32\n (i32.eqz (call $call(call $check_overflow_i64\n (i64.load (i32.add (get_global $sp) (i32.const 0)))\n (i64.load (i32.add (get_global $sp) (i32.const 8)))\n (i64.load (i32.add (get_global $sp) (i32.const 16)))\n (i64.load (i32.add (get_global $sp) (i32.const 24))))(i32.add (get_global $sp) (i32.const -32))(i32.add (get_global $sp) (i32.const -64))(get_local $offset0)(get_local $length0)(get_local $callback)) ;; flip CALL result from EEI to EVM convention (0 -> 1, 1,2,.. -> 1)\n )))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const -168)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -176)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -184)) (i64.const 0)))", + "wast": ";; generated by ./wasm/generateInterface.js\n(func $CALL (param $callback i32)(local $offset0 i32)(local $length0 i32) (set_local $offset0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -96)))\n (i64.load (i32.add (get_global $sp) (i32.const -88)))\n (i64.load (i32.add (get_global $sp) (i32.const -80)))\n (i64.load (i32.add (get_global $sp) (i32.const -72)))))(set_local $length0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -128)))\n (i64.load (i32.add (get_global $sp) (i32.const -120)))\n (i64.load (i32.add (get_global $sp) (i32.const -112)))\n (i64.load (i32.add (get_global $sp) (i32.const -104)))))\n (call $memusegas (get_local $offset0) (get_local $length0))\n (set_local $offset0 (i32.add (get_global $memstart) (get_local $offset0))) (i64.store\n (i32.add (get_global $sp) (i32.const -192))\n (i64.extend_u/i32 (i32.eqz (call $call(call $check_overflow_i64\n (i64.load (i32.add (get_global $sp) (i32.const 0)))\n (i64.load (i32.add (get_global $sp) (i32.const 8)))\n (i64.load (i32.add (get_global $sp) (i32.const 16)))\n (i64.load (i32.add (get_global $sp) (i32.const 24))))(i32.add (get_global $sp) (i32.const -32))(i32.add (get_global $sp) (i32.const -64))(get_local $offset0)(get_local $length0)(get_local $callback)))))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const -168)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -176)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -184)) (i64.const 0)))", "imports": "(import \"ethereum\" \"call\" (func $call (param i64 i32 i32 i32 i32 i32) (result i32)))" }, "CALLCODE": { - "wast": ";; generated by ./wasm/generateInterface.js\n(func $CALLCODE (param $callback i32)(local $offset0 i32)(local $length0 i32) (set_local $offset0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -96)))\n (i64.load (i32.add (get_global $sp) (i32.const -88)))\n (i64.load (i32.add (get_global $sp) (i32.const -80)))\n (i64.load (i32.add (get_global $sp) (i32.const -72)))))(set_local $length0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -128)))\n (i64.load (i32.add (get_global $sp) (i32.const -120)))\n (i64.load (i32.add (get_global $sp) (i32.const -112)))\n (i64.load (i32.add (get_global $sp) (i32.const -104)))))\n (call $memusegas (get_local $offset0) (get_local $length0))\n (set_local $offset0 (i32.add (get_global $memstart) (get_local $offset0))) (i64.store\n (i32.add (get_global $sp) (i32.const -192))\n (i64.extend_u/i32\n (i32.eqz (call $callCode(call $check_overflow_i64\n (i64.load (i32.add (get_global $sp) (i32.const 0)))\n (i64.load (i32.add (get_global $sp) (i32.const 8)))\n (i64.load (i32.add (get_global $sp) (i32.const 16)))\n (i64.load (i32.add (get_global $sp) (i32.const 24))))(i32.add (get_global $sp) (i32.const -32))(i32.add (get_global $sp) (i32.const -64))(get_local $offset0)(get_local $length0)(get_local $callback)) ;; flip CALL result from EEI to EVM convention (0 -> 1, 1,2,.. -> 1)\n )))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const -168)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -176)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -184)) (i64.const 0)))", + "wast": ";; generated by ./wasm/generateInterface.js\n(func $CALLCODE (param $callback i32)(local $offset0 i32)(local $length0 i32) (set_local $offset0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -96)))\n (i64.load (i32.add (get_global $sp) (i32.const -88)))\n (i64.load (i32.add (get_global $sp) (i32.const -80)))\n (i64.load (i32.add (get_global $sp) (i32.const -72)))))(set_local $length0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -128)))\n (i64.load (i32.add (get_global $sp) (i32.const -120)))\n (i64.load (i32.add (get_global $sp) (i32.const -112)))\n (i64.load (i32.add (get_global $sp) (i32.const -104)))))\n (call $memusegas (get_local $offset0) (get_local $length0))\n (set_local $offset0 (i32.add (get_global $memstart) (get_local $offset0))) (i64.store\n (i32.add (get_global $sp) (i32.const -192))\n (i64.extend_u/i32 (i32.eqz (call $callCode(call $check_overflow_i64\n (i64.load (i32.add (get_global $sp) (i32.const 0)))\n (i64.load (i32.add (get_global $sp) (i32.const 8)))\n (i64.load (i32.add (get_global $sp) (i32.const 16)))\n (i64.load (i32.add (get_global $sp) (i32.const 24))))(i32.add (get_global $sp) (i32.const -32))(i32.add (get_global $sp) (i32.const -64))(get_local $offset0)(get_local $length0)(get_local $callback)))))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const -168)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -176)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -184)) (i64.const 0)))", "imports": "(import \"ethereum\" \"callCode\" (func $callCode (param i64 i32 i32 i32 i32 i32) (result i32)))" }, "DELEGATECALL": { - "wast": ";; generated by ./wasm/generateInterface.js\n(func $DELEGATECALL (param $callback i32)(local $offset0 i32)(local $length0 i32) (set_local $offset0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -96)))\n (i64.load (i32.add (get_global $sp) (i32.const -88)))\n (i64.load (i32.add (get_global $sp) (i32.const -80)))\n (i64.load (i32.add (get_global $sp) (i32.const -72)))))(set_local $length0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -128)))\n (i64.load (i32.add (get_global $sp) (i32.const -120)))\n (i64.load (i32.add (get_global $sp) (i32.const -112)))\n (i64.load (i32.add (get_global $sp) (i32.const -104)))))\n (call $memusegas (get_local $offset0) (get_local $length0))\n (set_local $offset0 (i32.add (get_global $memstart) (get_local $offset0))) (i64.store\n (i32.add (get_global $sp) (i32.const -192))\n (i64.extend_u/i32\n (i32.eqz (call $callDelegate(call $check_overflow_i64\n (i64.load (i32.add (get_global $sp) (i32.const 0)))\n (i64.load (i32.add (get_global $sp) (i32.const 8)))\n (i64.load (i32.add (get_global $sp) (i32.const 16)))\n (i64.load (i32.add (get_global $sp) (i32.const 24))))(i32.add (get_global $sp) (i32.const -32))(i32.add (get_global $sp) (i32.const -64))(get_local $offset0)(get_local $length0)(get_local $callback)) ;; flip CALL result from EEI to EVM convention (0 -> 1, 1,2,.. -> 1)\n )))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const -168)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -176)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -184)) (i64.const 0)))", + "wast": ";; generated by ./wasm/generateInterface.js\n(func $DELEGATECALL (param $callback i32)(local $offset0 i32)(local $length0 i32) (set_local $offset0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -96)))\n (i64.load (i32.add (get_global $sp) (i32.const -88)))\n (i64.load (i32.add (get_global $sp) (i32.const -80)))\n (i64.load (i32.add (get_global $sp) (i32.const -72)))))(set_local $length0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -128)))\n (i64.load (i32.add (get_global $sp) (i32.const -120)))\n (i64.load (i32.add (get_global $sp) (i32.const -112)))\n (i64.load (i32.add (get_global $sp) (i32.const -104)))))\n (call $memusegas (get_local $offset0) (get_local $length0))\n (set_local $offset0 (i32.add (get_global $memstart) (get_local $offset0))) (i64.store\n (i32.add (get_global $sp) (i32.const -128))\n (i64.extend_u/i32 (i32.eqz (call $callDelegate(call $check_overflow_i64\n (i64.load (i32.add (get_global $sp) (i32.const 0)))\n (i64.load (i32.add (get_global $sp) (i32.const 8)))\n (i64.load (i32.add (get_global $sp) (i32.const 16)))\n (i64.load (i32.add (get_global $sp) (i32.const 24))))(i32.add (get_global $sp) (i32.const -32))(i32.add (get_global $sp) (i32.const -64))(get_local $offset0)(get_local $length0)(get_local $callback)))))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const -104)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -112)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -120)) (i64.const 0)))", "imports": "(import \"ethereum\" \"callDelegate\" (func $callDelegate (param i64 i32 i32 i32 i32 i32) (result i32)))" }, "STATICCALL": { - "wast": ";; generated by ./wasm/generateInterface.js\n(func $STATICCALL (param $callback i32)(local $offset0 i32)(local $length0 i32) (set_local $offset0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -64)))\n (i64.load (i32.add (get_global $sp) (i32.const -56)))\n (i64.load (i32.add (get_global $sp) (i32.const -48)))\n (i64.load (i32.add (get_global $sp) (i32.const -40)))))(set_local $length0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -96)))\n (i64.load (i32.add (get_global $sp) (i32.const -88)))\n (i64.load (i32.add (get_global $sp) (i32.const -80)))\n (i64.load (i32.add (get_global $sp) (i32.const -72)))))\n (call $memusegas (get_local $offset0) (get_local $length0))\n (set_local $offset0 (i32.add (get_global $memstart) (get_local $offset0))) (i64.store\n (i32.add (get_global $sp) (i32.const -160))\n (i64.extend_u/i32\n (i32.eqz (call $callStatic(call $check_overflow_i64\n (i64.load (i32.add (get_global $sp) (i32.const 0)))\n (i64.load (i32.add (get_global $sp) (i32.const 8)))\n (i64.load (i32.add (get_global $sp) (i32.const 16)))\n (i64.load (i32.add (get_global $sp) (i32.const 24))))(i32.add (get_global $sp) (i32.const -32))(get_local $offset0)(get_local $length0)(get_local $callback)) ;; flip CALL result from EEI to EVM convention (0 -> 1, 1,2,.. -> 1)\n )))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const -136)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -144)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -152)) (i64.const 0)))", + "wast": ";; generated by ./wasm/generateInterface.js\n(func $STATICCALL (param $callback i32)(local $offset0 i32)(local $length0 i32) (set_local $offset0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -64)))\n (i64.load (i32.add (get_global $sp) (i32.const -56)))\n (i64.load (i32.add (get_global $sp) (i32.const -48)))\n (i64.load (i32.add (get_global $sp) (i32.const -40)))))(set_local $length0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -96)))\n (i64.load (i32.add (get_global $sp) (i32.const -88)))\n (i64.load (i32.add (get_global $sp) (i32.const -80)))\n (i64.load (i32.add (get_global $sp) (i32.const -72)))))\n (call $memusegas (get_local $offset0) (get_local $length0))\n (set_local $offset0 (i32.add (get_global $memstart) (get_local $offset0))) (i64.store\n (i32.add (get_global $sp) (i32.const -96))\n (i64.extend_u/i32 (call $callStatic(call $check_overflow_i64\n (i64.load (i32.add (get_global $sp) (i32.const 0)))\n (i64.load (i32.add (get_global $sp) (i32.const 8)))\n (i64.load (i32.add (get_global $sp) (i32.const 16)))\n (i64.load (i32.add (get_global $sp) (i32.const 24))))(i32.add (get_global $sp) (i32.const -32))(get_local $offset0)(get_local $length0)(get_local $callback))))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const -72)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -80)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -88)) (i64.const 0)))", "imports": "(import \"ethereum\" \"callStatic\" (func $callStatic (param i64 i32 i32 i32 i32) (result i32)))" }, "RETURNDATACOPY": { @@ -108,7 +108,7 @@ "imports": "(import \"ethereum\" \"returnDataCopy\" (func $returnDataCopy (param i32 i32 i32) ))" }, "RETURNDATASIZE": { - "wast": ";; generated by ./wasm/generateInterface.js\n(func $RETURNDATASIZE (i64.store\n (i32.add (get_global $sp) (i32.const 32))\n (i64.extend_u/i32\n (call $getReturnDataSize)))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const 56)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 48)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 40)) (i64.const 0)))", + "wast": ";; generated by ./wasm/generateInterface.js\n(func $RETURNDATASIZE (i64.store\n (i32.add (get_global $sp) (i32.const 32))\n (i64.extend_u/i32 (call $getReturnDataSize)))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const 56)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 48)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 40)) (i64.const 0)))", "imports": "(import \"ethereum\" \"getReturnDataSize\" (func $getReturnDataSize (result i32)))" }, "SSTORE": { diff --git a/wasm/wast.json b/wasm/wast.json index b5c0bc92..d5719d71 100644 --- a/wasm/wast.json +++ b/wasm/wast.json @@ -32,7 +32,7 @@ "imports": "(import \"ethereum\" \"getCallValue\" (func $getCallValue (param i32) ))" }, "CALLDATASIZE": { - "wast": ";; generated by ./wasm/generateInterface.js\n(func $CALLDATASIZE (i64.store\n (i32.add (get_global $sp) (i32.const 32))\n (i64.extend_u/i32\n (call $getCallDataSize)))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const 56)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 48)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 40)) (i64.const 0)))", + "wast": ";; generated by ./wasm/generateInterface.js\n(func $CALLDATASIZE (i64.store\n (i32.add (get_global $sp) (i32.const 32))\n (i64.extend_u/i32 (call $getCallDataSize)))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const 56)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 48)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 40)) (i64.const 0)))", "imports": "(import \"ethereum\" \"getCallDataSize\" (func $getCallDataSize (result i32)))" }, "CALLDATACOPY": { @@ -40,7 +40,7 @@ "imports": "(import \"ethereum\" \"callDataCopy\" (func $callDataCopy (param i32 i32 i32) ))" }, "CODESIZE": { - "wast": ";; generated by ./wasm/generateInterface.js\n(func $CODESIZE (i64.store\n (i32.add (get_global $sp) (i32.const 32))\n (i64.extend_u/i32\n (call $getCodeSize)))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const 56)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 48)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 40)) (i64.const 0)))", + "wast": ";; generated by ./wasm/generateInterface.js\n(func $CODESIZE (i64.store\n (i32.add (get_global $sp) (i32.const 32))\n (i64.extend_u/i32 (call $getCodeSize)))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const 56)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 48)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 40)) (i64.const 0)))", "imports": "(import \"ethereum\" \"getCodeSize\" (func $getCodeSize (result i32)))" }, "CODECOPY": { @@ -48,7 +48,7 @@ "imports": "(import \"ethereum\" \"codeCopy\" (func $codeCopy (param i32 i32 i32) ))" }, "EXTCODESIZE": { - "wast": ";; generated by ./wasm/generateInterface.js\n(func $EXTCODESIZE (i64.store\n (i32.add (get_global $sp) (i32.const 0))\n (i64.extend_u/i32\n (call $getExternalCodeSize(get_global $sp))))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const 24)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 16)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 8)) (i64.const 0)))", + "wast": ";; generated by ./wasm/generateInterface.js\n(func $EXTCODESIZE (i64.store\n (i32.add (get_global $sp) (i32.const 0))\n (i64.extend_u/i32 (call $getExternalCodeSize(get_global $sp))))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const 24)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 16)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 8)) (i64.const 0)))", "imports": "(import \"ethereum\" \"getExternalCodeSize\" (func $getExternalCodeSize (param i32) (result i32)))" }, "EXTCODECOPY": { @@ -84,23 +84,23 @@ "imports": "(import \"ethereum\" \"getBlockGasLimit\" (func $getBlockGasLimit (result i64)))" }, "CREATE": { - "wast": ";; generated by ./wasm/generateInterface.js\n(func $CREATE (local $offset0 i32)(local $length0 i32) (set_local $offset0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -32)))\n (i64.load (i32.add (get_global $sp) (i32.const -24)))\n (i64.load (i32.add (get_global $sp) (i32.const -16)))\n (i64.load (i32.add (get_global $sp) (i32.const -8)))))(set_local $length0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -64)))\n (i64.load (i32.add (get_global $sp) (i32.const -56)))\n (i64.load (i32.add (get_global $sp) (i32.const -48)))\n (i64.load (i32.add (get_global $sp) (i32.const -40)))))\n (call $memusegas (get_local $offset0) (get_local $length0))\n (set_local $offset0 (i32.add (get_global $memstart) (get_local $offset0))) (call $create(get_global $sp)(get_local $offset0)(get_local $length0) (i32.add (get_global $sp) (i32.const -64)))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const -40)) (i64.const 0))\n (i32.store (i32.add (get_global $sp) (i32.const -44)) (i32.const 0)))", - "imports": "(import \"ethereum\" \"create\" (func $create (param i32 i32 i32 i32) ))" + "wast": ";; generated by ./wasm/generateInterface.js\n(func $CREATE (local $offset0 i32)(local $length0 i32) (set_local $offset0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -32)))\n (i64.load (i32.add (get_global $sp) (i32.const -24)))\n (i64.load (i32.add (get_global $sp) (i32.const -16)))\n (i64.load (i32.add (get_global $sp) (i32.const -8)))))(set_local $length0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -64)))\n (i64.load (i32.add (get_global $sp) (i32.const -56)))\n (i64.load (i32.add (get_global $sp) (i32.const -48)))\n (i64.load (i32.add (get_global $sp) (i32.const -40)))))\n (call $memusegas (get_local $offset0) (get_local $length0))\n (set_local $offset0 (i32.add (get_global $memstart) (get_local $offset0))) (if (i32.ne (call $create(get_global $sp)(get_local $offset0)(get_local $length0)(i32.add (get_global $sp) (i32.const -64))) (i32.const 0))\n (then (i64.store\n (i32.add (get_global $sp) (i32.const -64))\n (i64.const 0)))))", + "imports": "(import \"ethereum\" \"create\" (func $create (param i32 i32 i32 i32) (result i32)))" }, "CALL": { - "wast": ";; generated by ./wasm/generateInterface.js\n(func $CALL (local $offset0 i32)(local $length0 i32) (set_local $offset0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -96)))\n (i64.load (i32.add (get_global $sp) (i32.const -88)))\n (i64.load (i32.add (get_global $sp) (i32.const -80)))\n (i64.load (i32.add (get_global $sp) (i32.const -72)))))(set_local $length0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -128)))\n (i64.load (i32.add (get_global $sp) (i32.const -120)))\n (i64.load (i32.add (get_global $sp) (i32.const -112)))\n (i64.load (i32.add (get_global $sp) (i32.const -104)))))\n (call $memusegas (get_local $offset0) (get_local $length0))\n (set_local $offset0 (i32.add (get_global $memstart) (get_local $offset0))) (i64.store\n (i32.add (get_global $sp) (i32.const -192))\n (i64.extend_u/i32\n (i32.eqz (call $call(call $check_overflow_i64\n (i64.load (i32.add (get_global $sp) (i32.const 0)))\n (i64.load (i32.add (get_global $sp) (i32.const 8)))\n (i64.load (i32.add (get_global $sp) (i32.const 16)))\n (i64.load (i32.add (get_global $sp) (i32.const 24))))(i32.add (get_global $sp) (i32.const -32))(i32.add (get_global $sp) (i32.const -64))(get_local $offset0)(get_local $length0)) ;; flip CALL result from EEI to EVM convention (0 -> 1, 1,2,.. -> 1)\n )))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const -168)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -176)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -184)) (i64.const 0)))", + "wast": ";; generated by ./wasm/generateInterface.js\n(func $CALL (local $offset0 i32)(local $length0 i32) (set_local $offset0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -96)))\n (i64.load (i32.add (get_global $sp) (i32.const -88)))\n (i64.load (i32.add (get_global $sp) (i32.const -80)))\n (i64.load (i32.add (get_global $sp) (i32.const -72)))))(set_local $length0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -128)))\n (i64.load (i32.add (get_global $sp) (i32.const -120)))\n (i64.load (i32.add (get_global $sp) (i32.const -112)))\n (i64.load (i32.add (get_global $sp) (i32.const -104)))))\n (call $memusegas (get_local $offset0) (get_local $length0))\n (set_local $offset0 (i32.add (get_global $memstart) (get_local $offset0))) (i64.store\n (i32.add (get_global $sp) (i32.const -192))\n (i64.extend_u/i32 (i32.eqz (call $call(call $check_overflow_i64\n (i64.load (i32.add (get_global $sp) (i32.const 0)))\n (i64.load (i32.add (get_global $sp) (i32.const 8)))\n (i64.load (i32.add (get_global $sp) (i32.const 16)))\n (i64.load (i32.add (get_global $sp) (i32.const 24))))(i32.add (get_global $sp) (i32.const -32))(i32.add (get_global $sp) (i32.const -64))(get_local $offset0)(get_local $length0)))))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const -168)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -176)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -184)) (i64.const 0)))", "imports": "(import \"ethereum\" \"call\" (func $call (param i64 i32 i32 i32 i32) (result i32)))" }, "CALLCODE": { - "wast": ";; generated by ./wasm/generateInterface.js\n(func $CALLCODE (local $offset0 i32)(local $length0 i32) (set_local $offset0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -96)))\n (i64.load (i32.add (get_global $sp) (i32.const -88)))\n (i64.load (i32.add (get_global $sp) (i32.const -80)))\n (i64.load (i32.add (get_global $sp) (i32.const -72)))))(set_local $length0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -128)))\n (i64.load (i32.add (get_global $sp) (i32.const -120)))\n (i64.load (i32.add (get_global $sp) (i32.const -112)))\n (i64.load (i32.add (get_global $sp) (i32.const -104)))))\n (call $memusegas (get_local $offset0) (get_local $length0))\n (set_local $offset0 (i32.add (get_global $memstart) (get_local $offset0))) (i64.store\n (i32.add (get_global $sp) (i32.const -192))\n (i64.extend_u/i32\n (i32.eqz (call $callCode(call $check_overflow_i64\n (i64.load (i32.add (get_global $sp) (i32.const 0)))\n (i64.load (i32.add (get_global $sp) (i32.const 8)))\n (i64.load (i32.add (get_global $sp) (i32.const 16)))\n (i64.load (i32.add (get_global $sp) (i32.const 24))))(i32.add (get_global $sp) (i32.const -32))(i32.add (get_global $sp) (i32.const -64))(get_local $offset0)(get_local $length0)) ;; flip CALL result from EEI to EVM convention (0 -> 1, 1,2,.. -> 1)\n )))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const -168)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -176)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -184)) (i64.const 0)))", + "wast": ";; generated by ./wasm/generateInterface.js\n(func $CALLCODE (local $offset0 i32)(local $length0 i32) (set_local $offset0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -96)))\n (i64.load (i32.add (get_global $sp) (i32.const -88)))\n (i64.load (i32.add (get_global $sp) (i32.const -80)))\n (i64.load (i32.add (get_global $sp) (i32.const -72)))))(set_local $length0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -128)))\n (i64.load (i32.add (get_global $sp) (i32.const -120)))\n (i64.load (i32.add (get_global $sp) (i32.const -112)))\n (i64.load (i32.add (get_global $sp) (i32.const -104)))))\n (call $memusegas (get_local $offset0) (get_local $length0))\n (set_local $offset0 (i32.add (get_global $memstart) (get_local $offset0))) (i64.store\n (i32.add (get_global $sp) (i32.const -192))\n (i64.extend_u/i32 (i32.eqz (call $callCode(call $check_overflow_i64\n (i64.load (i32.add (get_global $sp) (i32.const 0)))\n (i64.load (i32.add (get_global $sp) (i32.const 8)))\n (i64.load (i32.add (get_global $sp) (i32.const 16)))\n (i64.load (i32.add (get_global $sp) (i32.const 24))))(i32.add (get_global $sp) (i32.const -32))(i32.add (get_global $sp) (i32.const -64))(get_local $offset0)(get_local $length0)))))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const -168)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -176)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -184)) (i64.const 0)))", "imports": "(import \"ethereum\" \"callCode\" (func $callCode (param i64 i32 i32 i32 i32) (result i32)))" }, "DELEGATECALL": { - "wast": ";; generated by ./wasm/generateInterface.js\n(func $DELEGATECALL (local $offset0 i32)(local $length0 i32) (set_local $offset0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -96)))\n (i64.load (i32.add (get_global $sp) (i32.const -88)))\n (i64.load (i32.add (get_global $sp) (i32.const -80)))\n (i64.load (i32.add (get_global $sp) (i32.const -72)))))(set_local $length0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -128)))\n (i64.load (i32.add (get_global $sp) (i32.const -120)))\n (i64.load (i32.add (get_global $sp) (i32.const -112)))\n (i64.load (i32.add (get_global $sp) (i32.const -104)))))\n (call $memusegas (get_local $offset0) (get_local $length0))\n (set_local $offset0 (i32.add (get_global $memstart) (get_local $offset0))) (i64.store\n (i32.add (get_global $sp) (i32.const -192))\n (i64.extend_u/i32\n (i32.eqz (call $callDelegate(call $check_overflow_i64\n (i64.load (i32.add (get_global $sp) (i32.const 0)))\n (i64.load (i32.add (get_global $sp) (i32.const 8)))\n (i64.load (i32.add (get_global $sp) (i32.const 16)))\n (i64.load (i32.add (get_global $sp) (i32.const 24))))(i32.add (get_global $sp) (i32.const -32))(i32.add (get_global $sp) (i32.const -64))(get_local $offset0)(get_local $length0)) ;; flip CALL result from EEI to EVM convention (0 -> 1, 1,2,.. -> 1)\n )))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const -168)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -176)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -184)) (i64.const 0)))", + "wast": ";; generated by ./wasm/generateInterface.js\n(func $DELEGATECALL (local $offset0 i32)(local $length0 i32) (set_local $offset0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -96)))\n (i64.load (i32.add (get_global $sp) (i32.const -88)))\n (i64.load (i32.add (get_global $sp) (i32.const -80)))\n (i64.load (i32.add (get_global $sp) (i32.const -72)))))(set_local $length0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -128)))\n (i64.load (i32.add (get_global $sp) (i32.const -120)))\n (i64.load (i32.add (get_global $sp) (i32.const -112)))\n (i64.load (i32.add (get_global $sp) (i32.const -104)))))\n (call $memusegas (get_local $offset0) (get_local $length0))\n (set_local $offset0 (i32.add (get_global $memstart) (get_local $offset0))) (i64.store\n (i32.add (get_global $sp) (i32.const -128))\n (i64.extend_u/i32 (i32.eqz (call $callDelegate(call $check_overflow_i64\n (i64.load (i32.add (get_global $sp) (i32.const 0)))\n (i64.load (i32.add (get_global $sp) (i32.const 8)))\n (i64.load (i32.add (get_global $sp) (i32.const 16)))\n (i64.load (i32.add (get_global $sp) (i32.const 24))))(i32.add (get_global $sp) (i32.const -32))(i32.add (get_global $sp) (i32.const -64))(get_local $offset0)(get_local $length0)))))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const -104)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -112)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -120)) (i64.const 0)))", "imports": "(import \"ethereum\" \"callDelegate\" (func $callDelegate (param i64 i32 i32 i32 i32) (result i32)))" }, "STATICCALL": { - "wast": ";; generated by ./wasm/generateInterface.js\n(func $STATICCALL (local $offset0 i32)(local $length0 i32) (set_local $offset0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -64)))\n (i64.load (i32.add (get_global $sp) (i32.const -56)))\n (i64.load (i32.add (get_global $sp) (i32.const -48)))\n (i64.load (i32.add (get_global $sp) (i32.const -40)))))(set_local $length0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -96)))\n (i64.load (i32.add (get_global $sp) (i32.const -88)))\n (i64.load (i32.add (get_global $sp) (i32.const -80)))\n (i64.load (i32.add (get_global $sp) (i32.const -72)))))\n (call $memusegas (get_local $offset0) (get_local $length0))\n (set_local $offset0 (i32.add (get_global $memstart) (get_local $offset0))) (i64.store\n (i32.add (get_global $sp) (i32.const -160))\n (i64.extend_u/i32\n (i32.eqz (call $callStatic(call $check_overflow_i64\n (i64.load (i32.add (get_global $sp) (i32.const 0)))\n (i64.load (i32.add (get_global $sp) (i32.const 8)))\n (i64.load (i32.add (get_global $sp) (i32.const 16)))\n (i64.load (i32.add (get_global $sp) (i32.const 24))))(i32.add (get_global $sp) (i32.const -32))(get_local $offset0)(get_local $length0)) ;; flip CALL result from EEI to EVM convention (0 -> 1, 1,2,.. -> 1)\n )))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const -136)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -144)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -152)) (i64.const 0)))", + "wast": ";; generated by ./wasm/generateInterface.js\n(func $STATICCALL (local $offset0 i32)(local $length0 i32) (set_local $offset0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -64)))\n (i64.load (i32.add (get_global $sp) (i32.const -56)))\n (i64.load (i32.add (get_global $sp) (i32.const -48)))\n (i64.load (i32.add (get_global $sp) (i32.const -40)))))(set_local $length0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -96)))\n (i64.load (i32.add (get_global $sp) (i32.const -88)))\n (i64.load (i32.add (get_global $sp) (i32.const -80)))\n (i64.load (i32.add (get_global $sp) (i32.const -72)))))\n (call $memusegas (get_local $offset0) (get_local $length0))\n (set_local $offset0 (i32.add (get_global $memstart) (get_local $offset0))) (i64.store\n (i32.add (get_global $sp) (i32.const -96))\n (i64.extend_u/i32 (call $callStatic(call $check_overflow_i64\n (i64.load (i32.add (get_global $sp) (i32.const 0)))\n (i64.load (i32.add (get_global $sp) (i32.const 8)))\n (i64.load (i32.add (get_global $sp) (i32.const 16)))\n (i64.load (i32.add (get_global $sp) (i32.const 24))))(i32.add (get_global $sp) (i32.const -32))(get_local $offset0)(get_local $length0))))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const -72)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -80)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -88)) (i64.const 0)))", "imports": "(import \"ethereum\" \"callStatic\" (func $callStatic (param i64 i32 i32 i32) (result i32)))" }, "RETURNDATACOPY": { @@ -108,7 +108,7 @@ "imports": "(import \"ethereum\" \"returnDataCopy\" (func $returnDataCopy (param i32 i32 i32) ))" }, "RETURNDATASIZE": { - "wast": ";; generated by ./wasm/generateInterface.js\n(func $RETURNDATASIZE (i64.store\n (i32.add (get_global $sp) (i32.const 32))\n (i64.extend_u/i32\n (call $getReturnDataSize)))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const 56)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 48)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 40)) (i64.const 0)))", + "wast": ";; generated by ./wasm/generateInterface.js\n(func $RETURNDATASIZE (i64.store\n (i32.add (get_global $sp) (i32.const 32))\n (i64.extend_u/i32 (call $getReturnDataSize)))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const 56)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 48)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 40)) (i64.const 0)))", "imports": "(import \"ethereum\" \"getReturnDataSize\" (func $getReturnDataSize (result i32)))" }, "SSTORE": { From 3971ba4d5a371f3289907bc688690a486a4a4deb Mon Sep 17 00:00:00 2001 From: Lane Rettig Date: Sat, 2 Jun 2018 20:42:56 -0300 Subject: [PATCH 4/4] Add callcodeDynamicCode which is now working --- circle.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/circle.yml b/circle.yml index 999128b2..199ef023 100644 --- a/circle.yml +++ b/circle.yml @@ -89,6 +89,7 @@ defaults: testeth -t GeneralStateTests/stCallCodes -- --testpath ~/tests --singlenet "Byzantium" --singletest "callcall_00" --vm ~/libhera.so --evmc evm2wasm.js=true testeth -t GeneralStateTests/stCallCodes -- --testpath ~/tests --singlenet "Byzantium" --singletest "callcallcode_01" --vm ~/libhera.so --evmc evm2wasm.js=true testeth -t GeneralStateTests/stMemoryTest -- --testpath ~/tests --singlenet "Byzantium" --singletest "memReturn" --vm ~/libhera.so --evmc evm2wasm.js=true + testeth -t GeneralStateTests/stCallCodes -- --testpath ~/tests --singlenet "Byzantium" --singletest "callcodeDynamicCode" --vm ~/libhera.so --evmc evm2wasm.js=true echo "ran the state tests." state-tests: &state-tests-cpp @@ -105,6 +106,7 @@ defaults: testeth -t GeneralStateTests/stCallCodes -- --testpath ~/tests --singlenet "Byzantium" --singletest "callcall_00" --vm ~/libhera.so --evmc evm2wasm.cpp=true testeth -t GeneralStateTests/stCallCodes -- --testpath ~/tests --singlenet "Byzantium" --singletest "callcallcode_01" --vm ~/libhera.so --evmc evm2wasm.cpp=true testeth -t GeneralStateTests/stMemoryTest -- --testpath ~/tests --singlenet "Byzantium" --singletest "memReturn" --vm ~/libhera.so --evmc evm2wasm.cpp=true + testeth -t GeneralStateTests/stCallCodes -- --testpath ~/tests --singlenet "Byzantium" --singletest "callcodeDynamicCode" --vm ~/libhera.so --evmc evm2wasm.cpp=true echo "ran the state tests." cli-tests: &cli-tests