git ssb

0+

wanderer🌟 / js-primea-hypervisor



Commit e471d345208468943e92014ec771d505815361d6

Interface: use U256_SIZE_BYTES

Alex Beregszaszi committed on 8/25/2016, 2:39:12 AM
Parent: 8ef09c67f032b90950cba23e30ffcc14c0b47078

Files changed

constants.jschanged
interface.jschanged
constants.jsView
@@ -1,4 +1,5 @@
11 module.exports = {
22 BALANCE_SIZE_BYTES: 16, // Max balance size in bytes
3- ADDRESS_SIZE_BYTES: 20 // Address size in bytes
3+ ADDRESS_SIZE_BYTES: 20, // Address size in bytes
4+ U256_SIZE_BYTES: 32
45 }
interface.jsView
@@ -172,9 +172,9 @@
172172 */
173173 callDataCopy256 (offset, dataOffset) {
174174 this.takeGas(3)
175175 const callData = this.environment.callData.slice(dataOffset, dataOffset + 32)
176- this.setMemory(offset, 32, callData)
176+ this.setMemory(offset, constants.U256_SIZE_BYTES, callData)
177177 }
178178
179179 /**
180180 * Gets the size of code running in current environment.
@@ -253,9 +253,9 @@
253253 hash = new U256(0)
254254 } else {
255255 hash = new U256(this.environment.getBlockHash(number))
256256 }
257- this.setMemory(offset, 32, hash.toMemory())
257+ this.setMemory(offset, constants.U256_SIZE_BYTES, hash.toMemory())
258258 }
259259
260260 /**
261261 * Gets the block’s beneficiary address and loads into memory.
@@ -293,9 +293,9 @@
293293 */
294294 getBlockDifficulty (offset) {
295295 this.takeGas(2)
296296
297- this.setMemory(offset, 32, this.environment.block.difficulty.toMemory())
297+ this.setMemory(offset, constants.U256_SIZE_BYTES, this.environment.block.difficulty.toMemory())
298298 }
299299
300300 /**
301301 * Get the block’s gas limit.
@@ -418,11 +418,11 @@
418418 * @param {interger} pathOffest the memory offset to load the the path from
419419 * @param {interger} valueOffset the memory offset to load the value from
420420 */
421421 storageStore (pathOffset, valueOffset) {
422- const path = new Buffer(this.getMemory(pathOffset, 32)).toString('hex')
422+ const path = new Buffer(this.getMemory(pathOffset, constants.U256_SIZE_BYTES)).toString('hex')
423423 // copy the value
424- const value = this.getMemory(valueOffset, 32).slice(0)
424+ const value = this.getMemory(valueOffset, constants.U256_SIZE_BYTES).slice(0)
425425 const oldValue = this.environment.state.get(path)
426426 const valIsZero = value.every((i) => i === 0)
427427
428428 this.takeGas(5000)
@@ -448,11 +448,11 @@
448448 */
449449 storageLoad (pathOffset, resultOffset) {
450450 this.takeGas(50)
451451
452- const path = new Buffer(this.getMemory(pathOffset, 32)).toString('hex')
452+ const path = new Buffer(this.getMemory(pathOffset, constants.U256_SIZE_BYTES)).toString('hex')
453453 const result = this.environment.state.get(path)
454- this.setMemory(resultOffset, 32, result)
454+ this.setMemory(resultOffset, constants.U256_SIZE_BYTES, result)
455455 }
456456
457457 /**
458458 * Halt execution returning output data.

Built with git-ssb-web