Commit 3c7fe6b5acfd0a626b54b4a24a1d167e67c8f8e4
this forces all endian manpulation to happen ONLY in the memory setter
and getterswanderer authored on 8/23/2016, 10:01:32 PM
Alex Beregszaszi committed on 8/24/2016, 1:59:30 AM
Parent: aa7f348ee71a97e479efcc2d058b302bcf683a0d
Files changed
debugInterface.js | changed |
environment.js | changed |
index.js | changed |
interface.js | changed |
tests/interface/address.wast | changed |
tests/interface/balance.wast | changed |
tests/interface/callDataCopy.wast | changed |
tests/interface/caller.wast | changed |
tests/interface/origin.wast | changed |
debugInterface.js | ||
---|---|---|
@@ -34,15 +34,15 @@ | ||
34 | 34 | } |
35 | 35 | console.error(`op: ${opcode.name} gas: ${this.environment.gasLeft}`) |
36 | 36 | console.log('-------------stack--------------') |
37 | 37 | for (let i = sp; i >= 0; i -= 32) { |
38 | - console.log(`${(sp - i) / 32} ${this.getMemoryBuffer(i).toString('hex')}`) | |
38 | + console.log(`${(sp - i) / 32} ${this.getMemoryBuffer(i).reverse().toString('hex')}`) | |
39 | 39 | } |
40 | 40 | return sp |
41 | 41 | }.bind(this) |
42 | 42 | } |
43 | 43 | } |
44 | 44 | |
45 | 45 | getMemoryBuffer (offset) { |
46 | - return new Buffer(this.module.exports.memory.slice(offset, offset + 32)).reverse() | |
46 | + return new Buffer(this.module.exports.memory.slice(offset, offset + 32)) | |
47 | 47 | } |
48 | 48 | } |
environment.js | ||
---|---|---|
@@ -37,9 +37,8 @@ | ||
37 | 37 | account.set('nonce', trie.nonce || new U256(0)) |
38 | 38 | account.set('balance', trie.balance || new U256(0)) |
39 | 39 | account.set('code', trie.code || new Uint8Array()) |
40 | 40 | account.set('storage', trie.storage || new Map()) |
41 | - | |
42 | 41 | this.state.set(address.toString(), account) |
43 | 42 | } |
44 | 43 | |
45 | 44 | getBalance (address) { |
index.js | ||
---|---|---|
@@ -17,11 +17,9 @@ | ||
17 | 17 | |
18 | 18 | // The Kernel Stores all of its state in the Environment. The Interface is used |
19 | 19 | // to by the VM to retrive infromation from the Environment. |
20 | 20 | const Environment = require('./environment.js') |
21 | - | |
22 | 21 | const DebugInterface = require('./debugInterface.js') |
23 | - | |
24 | 22 | const Address = require('./address.js') |
25 | 23 | const U256 = require('./u256.js') |
26 | 24 | const Utils = require('./utils.js') |
27 | 25 | const Transaction = require('./transaction.js') |
interface.js | ||
---|---|---|
@@ -168,9 +168,8 @@ | ||
168 | 168 | * Copys the input data in current environment to memory. This pertains to |
169 | 169 | * the input data passed with the message call instruction or transaction. |
170 | 170 | * @param {integer} offset the offset in memory to load into |
171 | 171 | * @param {integer} dataOffset the offset in the input data |
172 | - * @param {integer} length the length of data to copy | |
173 | 172 | */ |
174 | 173 | callDataCopy256 (offset, dataOffset) { |
175 | 174 | this.takeGas(3) |
176 | 175 | const callData = this.environment.callData.slice(dataOffset, dataOffset + 32) |
tests/interface/address.wast | ||
---|---|---|
@@ -8,9 +8,9 @@ | ||
8 | 8 | (func |
9 | 9 | (block |
10 | 10 | ;; loads the address into memory |
11 | 11 | (call_import $address (i32.const 0)) |
12 | - (if (i64.eq (i64.load (i32.const 0)) (i64.const 0x72a1048901c1485d)) ;; big enden | |
12 | + (if (i64.eq (i64.load (i32.const 0)) (i64.const 0xbd9c6f4a2d06c47b)) | |
13 | 13 | (return) |
14 | 14 | ) |
15 | 15 | (unreachable) |
16 | 16 | ) |
tests/interface/balance.wast | ||
---|---|---|
@@ -1,7 +1,7 @@ | ||
1 | 1 | ;; address of 5d48c1018904a172886829bbbd9c6f4a2d06c47b has a balance of 0x056bc75e2d63100000 (100 ETH) |
2 | 2 | (module |
3 | - (memory 1 (segment 0 "\5d\48\c1\01\89\04\a1\72\88\68\29\bb\bd\9c\6f\4a\2d\06\c4\7b")) | |
3 | + (memory 1 (segment 0 "\7b\c4\06\2d\4a\6f\9c\bd\bb\29\68\88\72\a1\04\89\01\c1\48\5d")) | |
4 | 4 | (import $balance "ethereum" "getBalance" (param i32 i32)) |
5 | 5 | (export "a" memory) |
6 | 6 | (export "test" 0) |
7 | 7 | (func |
tests/interface/callDataCopy.wast | ||
---|---|---|
@@ -8,9 +8,9 @@ | ||
8 | 8 | (func |
9 | 9 | (block |
10 | 10 | (call_import $callDataCopy (i32.const 0) (i32.const 0) (i32.const 8)) |
11 | 11 | |
12 | - (if (i64.eq (i64.load (i32.const 0)) (i64.const 0x2065726120756f59)) | |
12 | + (if (i64.eq (i64.load (i32.const 0)) (i64.const 0x596f752061726520)) | |
13 | 13 | (return) |
14 | 14 | ) |
15 | 15 | (unreachable) |
16 | 16 | ) |
tests/interface/caller.wast | ||
---|---|---|
@@ -8,9 +8,9 @@ | ||
8 | 8 | (func |
9 | 9 | (block |
10 | 10 | ;; loads the caller into memory |
11 | 11 | (call_import $caller (i32.const 0)) |
12 | - (if (i64.eq (i64.load (i32.const 0)) (i64.const 0x72a1048901c1485d)) | |
12 | + (if (i64.eq (i64.load (i32.const 0)) (i64.const 0xbd9c6f4a2d06c47b)) | |
13 | 13 | (return) |
14 | 14 | ) |
15 | 15 | (unreachable) |
16 | 16 | ) |
tests/interface/origin.wast | ||
---|---|---|
@@ -8,9 +8,9 @@ | ||
8 | 8 | (func |
9 | 9 | (block |
10 | 10 | ;; loads the address into memory |
11 | 11 | (call_import $origin (i32.const 0)) |
12 | - (if (i64.eq (i64.load (i32.const 0)) (i64.const 0x72a1048901c1485d)) | |
12 | + (if (i64.eq (i64.load (i32.const 0)) (i64.const 0xbd9c6f4a2d06c47b)) | |
13 | 13 | (return) |
14 | 14 | ) |
15 | 15 | (unreachable) |
16 | 16 | ) |
Built with git-ssb-web