Skip to content
This repository was archived by the owner on Jan 5, 2019. It is now read-only.

Commit 859471d

Browse files
authored
Merge pull request #283 from kyteague/fix-calldataload
Fix CALLDATALOAD
2 parents 5d0e54c + 1603baa commit 859471d

File tree

5 files changed

+9
-8
lines changed

5 files changed

+9
-8
lines changed

circle.yml

+1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ defaults:
7373
testeth -t GeneralStateTests/stBadOpcode -- --testpath ~/tests --singlenet "Byzantium" --vm ~/libhera.so --evmc evm2wasm.js=true
7474
testeth -t GeneralStateTests/stCallCodes -- --testpath ~/tests --singlenet "Byzantium" --singletest "callcall_00" --vm ~/libhera.so --evmc evm2wasm.js=true
7575
testeth -t GeneralStateTests/stCallCodes -- --testpath ~/tests --singlenet "Byzantium" --singletest "callcallcode_01" --vm ~/libhera.so --evmc evm2wasm.js=true
76+
testeth -t GeneralStateTests/stMemoryTest -- --testpath ~/tests --singlenet "Byzantium" --singletest "memReturn" --vm ~/libhera.so --evmc evm2wasm.js=true
7677
echo "ran the state tests."
7778
7879
cli-tests: &cli-tests

wasm/CALLDATALOAD.wast

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
(get_local $writeOffset2)
2424
(get_local $writeOffset3)))
2525

26-
(call $callDataCopy256 (get_global $sp) (get_local $writeOffset))
26+
(call $callDataCopy (get_global $sp) (get_local $writeOffset) (i32.const 32))
2727
;; swap top stack item
2828
(drop (call $bswap_m256 (get_global $sp)))
2929
)

wasm/generateInterface.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ const interfaceManifest = {
88
output: []
99
},
1010
CALLDATALOAD: {
11-
name: 'callDataCopy256',
12-
input: ['pointer'],
13-
output: ['i256'] // TODO: this is wrong
11+
name: 'callDataCopy',
12+
input: ['writeOffset', 'i32', 'length'],
13+
output: []
1414
},
1515
GAS: {
1616
name: 'getGasLeft',

wasm/wast-async.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
"imports": "(import \"ethereum\" \"log\" (func $log (param i32 i32 i32 i32 i32 i32 i32) ))"
55
},
66
"CALLDATALOAD": {
7-
"wast": ";; stack:\n;; 0: dataOffset\n(func $CALLDATALOAD\n (local $writeOffset i32)\n (local $writeOffset0 i64)\n (local $writeOffset1 i64)\n (local $writeOffset2 i64)\n (local $writeOffset3 i64)\n\n (set_local $writeOffset0 (i64.load (i32.add (get_global $sp) (i32.const 0))))\n (set_local $writeOffset1 (i64.load (i32.add (get_global $sp) (i32.const 8))))\n (set_local $writeOffset2 (i64.load (i32.add (get_global $sp) (i32.const 16))))\n (set_local $writeOffset3 (i64.load (i32.add (get_global $sp) (i32.const 24))))\n\n (i64.store (i32.add (get_global $sp) (i32.const 0)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 8)) (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 24)) (i64.const 0))\n\n (set_local $writeOffset\n (call $check_overflow (get_local $writeOffset0)\n (get_local $writeOffset1)\n (get_local $writeOffset2)\n (get_local $writeOffset3)))\n\n (call $callDataCopy256 (get_global $sp) (get_local $writeOffset))\n ;; swap top stack item\n (drop (call $bswap_m256 (get_global $sp)))\n)\n",
8-
"imports": "(import \"ethereum\" \"callDataCopy256\" (func $callDataCopy256 (param i32 i32) ))"
7+
"wast": ";; stack:\n;; 0: dataOffset\n(func $CALLDATALOAD\n (local $writeOffset i32)\n (local $writeOffset0 i64)\n (local $writeOffset1 i64)\n (local $writeOffset2 i64)\n (local $writeOffset3 i64)\n\n (set_local $writeOffset0 (i64.load (i32.add (get_global $sp) (i32.const 0))))\n (set_local $writeOffset1 (i64.load (i32.add (get_global $sp) (i32.const 8))))\n (set_local $writeOffset2 (i64.load (i32.add (get_global $sp) (i32.const 16))))\n (set_local $writeOffset3 (i64.load (i32.add (get_global $sp) (i32.const 24))))\n\n (i64.store (i32.add (get_global $sp) (i32.const 0)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 8)) (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 24)) (i64.const 0))\n\n (set_local $writeOffset\n (call $check_overflow (get_local $writeOffset0)\n (get_local $writeOffset1)\n (get_local $writeOffset2)\n (get_local $writeOffset3)))\n\n (call $callDataCopy (get_global $sp) (get_local $writeOffset) (i32.const 32))\n ;; swap top stack item\n (drop (call $bswap_m256 (get_global $sp)))\n)\n",
8+
"imports": "(import \"ethereum\" \"callDataCopy\" (func $callDataCopy (param i32 i32 i32) ))"
99
},
1010
"GAS": {
1111
"wast": ";; generated by ./wasm/generateInterface.js\n(func $GAS (i64.store (i32.add (get_global $sp) (i32.const 32)) (call $getGasLeft))\n\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)))",

wasm/wast.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
"imports": "(import \"ethereum\" \"log\" (func $log (param i32 i32 i32 i32 i32 i32 i32) ))"
55
},
66
"CALLDATALOAD": {
7-
"wast": ";; stack:\n;; 0: dataOffset\n(func $CALLDATALOAD\n (local $writeOffset i32)\n (local $writeOffset0 i64)\n (local $writeOffset1 i64)\n (local $writeOffset2 i64)\n (local $writeOffset3 i64)\n\n (set_local $writeOffset0 (i64.load (i32.add (get_global $sp) (i32.const 0))))\n (set_local $writeOffset1 (i64.load (i32.add (get_global $sp) (i32.const 8))))\n (set_local $writeOffset2 (i64.load (i32.add (get_global $sp) (i32.const 16))))\n (set_local $writeOffset3 (i64.load (i32.add (get_global $sp) (i32.const 24))))\n\n (i64.store (i32.add (get_global $sp) (i32.const 0)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 8)) (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 24)) (i64.const 0))\n\n (set_local $writeOffset\n (call $check_overflow (get_local $writeOffset0)\n (get_local $writeOffset1)\n (get_local $writeOffset2)\n (get_local $writeOffset3)))\n\n (call $callDataCopy256 (get_global $sp) (get_local $writeOffset))\n ;; swap top stack item\n (drop (call $bswap_m256 (get_global $sp)))\n)\n",
8-
"imports": "(import \"ethereum\" \"callDataCopy256\" (func $callDataCopy256 (param i32 i32) ))"
7+
"wast": ";; stack:\n;; 0: dataOffset\n(func $CALLDATALOAD\n (local $writeOffset i32)\n (local $writeOffset0 i64)\n (local $writeOffset1 i64)\n (local $writeOffset2 i64)\n (local $writeOffset3 i64)\n\n (set_local $writeOffset0 (i64.load (i32.add (get_global $sp) (i32.const 0))))\n (set_local $writeOffset1 (i64.load (i32.add (get_global $sp) (i32.const 8))))\n (set_local $writeOffset2 (i64.load (i32.add (get_global $sp) (i32.const 16))))\n (set_local $writeOffset3 (i64.load (i32.add (get_global $sp) (i32.const 24))))\n\n (i64.store (i32.add (get_global $sp) (i32.const 0)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 8)) (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 24)) (i64.const 0))\n\n (set_local $writeOffset\n (call $check_overflow (get_local $writeOffset0)\n (get_local $writeOffset1)\n (get_local $writeOffset2)\n (get_local $writeOffset3)))\n\n (call $callDataCopy (get_global $sp) (get_local $writeOffset) (i32.const 32))\n ;; swap top stack item\n (drop (call $bswap_m256 (get_global $sp)))\n)\n",
8+
"imports": "(import \"ethereum\" \"callDataCopy\" (func $callDataCopy (param i32 i32 i32) ))"
99
},
1010
"GAS": {
1111
"wast": ";; generated by ./wasm/generateInterface.js\n(func $GAS (i64.store (i32.add (get_global $sp) (i32.const 32)) (call $getGasLeft))\n\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)))",

0 commit comments

Comments
 (0)