git ssb

0+

wanderer🌟 / js-primea-hypervisor



Commit 3c7fe6b5acfd0a626b54b4a24a1d167e67c8f8e4

this forces all endian manpulation to happen ONLY in the memory setter

and getters
wanderer 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.jschanged
environment.jschanged
index.jschanged
interface.jschanged
tests/interface/address.wastchanged
tests/interface/balance.wastchanged
tests/interface/callDataCopy.wastchanged
tests/interface/caller.wastchanged
tests/interface/origin.wastchanged
debugInterface.jsView
@@ -34,15 +34,15 @@
3434 }
3535 console.error(`op: ${opcode.name} gas: ${this.environment.gasLeft}`)
3636 console.log('-------------stack--------------')
3737 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')}`)
3939 }
4040 return sp
4141 }.bind(this)
4242 }
4343 }
4444
4545 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))
4747 }
4848 }
environment.jsView
@@ -37,9 +37,8 @@
3737 account.set('nonce', trie.nonce || new U256(0))
3838 account.set('balance', trie.balance || new U256(0))
3939 account.set('code', trie.code || new Uint8Array())
4040 account.set('storage', trie.storage || new Map())
41-
4241 this.state.set(address.toString(), account)
4342 }
4443
4544 getBalance (address) {
index.jsView
@@ -17,11 +17,9 @@
1717
1818 // The Kernel Stores all of its state in the Environment. The Interface is used
1919 // to by the VM to retrive infromation from the Environment.
2020 const Environment = require('./environment.js')
21-
2221 const DebugInterface = require('./debugInterface.js')
23-
2422 const Address = require('./address.js')
2523 const U256 = require('./u256.js')
2624 const Utils = require('./utils.js')
2725 const Transaction = require('./transaction.js')
interface.jsView
@@ -168,9 +168,8 @@
168168 * Copys the input data in current environment to memory. This pertains to
169169 * the input data passed with the message call instruction or transaction.
170170 * @param {integer} offset the offset in memory to load into
171171 * @param {integer} dataOffset the offset in the input data
172- * @param {integer} length the length of data to copy
173172 */
174173 callDataCopy256 (offset, dataOffset) {
175174 this.takeGas(3)
176175 const callData = this.environment.callData.slice(dataOffset, dataOffset + 32)
tests/interface/address.wastView
@@ -8,9 +8,9 @@
88 (func
99 (block
1010 ;; loads the address into memory
1111 (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))
1313 (return)
1414 )
1515 (unreachable)
1616 )
tests/interface/balance.wastView
@@ -1,7 +1,7 @@
11 ;; address of 5d48c1018904a172886829bbbd9c6f4a2d06c47b has a balance of 0x056bc75e2d63100000 (100 ETH)
22 (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"))
44 (import $balance "ethereum" "getBalance" (param i32 i32))
55 (export "a" memory)
66 (export "test" 0)
77 (func
tests/interface/callDataCopy.wastView
@@ -8,9 +8,9 @@
88 (func
99 (block
1010 (call_import $callDataCopy (i32.const 0) (i32.const 0) (i32.const 8))
1111
12- (if (i64.eq (i64.load (i32.const 0)) (i64.const 0x2065726120756f59))
12+ (if (i64.eq (i64.load (i32.const 0)) (i64.const 0x596f752061726520))
1313 (return)
1414 )
1515 (unreachable)
1616 )
tests/interface/caller.wastView
@@ -8,9 +8,9 @@
88 (func
99 (block
1010 ;; loads the caller into memory
1111 (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))
1313 (return)
1414 )
1515 (unreachable)
1616 )
tests/interface/origin.wastView
@@ -8,9 +8,9 @@
88 (func
99 (block
1010 ;; loads the address into memory
1111 (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))
1313 (return)
1414 )
1515 (unreachable)
1616 )

Built with git-ssb-web