Commit e214b19ee2bdfeef044a0c6277beab1b4d7472bb
passing all vm tests
wanderer committed on 11/14/2016, 10:37:59 PMParent: 3c2192ab4c4610302da22858ac40084fe5db349d
Files changed
EVMinterface.js | changed |
EVMinterface.js | ||
---|---|---|
@@ -434,12 +434,12 @@ | ||
434 | 434 | |
435 | 435 | let opPromise |
436 | 436 | |
437 | 437 | if (value.gt(this.kernel.environment.value)) { |
438 | - opPromise = Promise.resolve(new Address()) | |
438 | + opPromise = Promise.resolve(new Buffer(20).fill(0)) | |
439 | 439 | } else { |
440 | 440 | // todo actully run the code |
441 | - opPromise = Promise.resolve(ethUtil.generateAddress(this.kernel.environment.from, this.kernel.environment.nonce)) | |
441 | + opPromise = Promise.resolve(ethUtil.generateAddress(this.kernel.environment.address, this.kernel.environment.nonce)) | |
442 | 442 | } |
443 | 443 | |
444 | 444 | // wait for all the prevouse async ops to finish before running the callback |
445 | 445 | this.kernel.pushOpsQueue(opPromise, cbIndex, address => { |
@@ -457,35 +457,32 @@ | ||
457 | 457 | * @param {integer} resultLength |
458 | 458 | * @param {integer} gas |
459 | 459 | * @return {integer} Returns 1 or 0 depending on if the VM trapped on the message or not |
460 | 460 | */ |
461 | - _call (gasHigh, gasLow, addressOffset, valueOffset, dataOffset, dataLength, resultOffset, resultLength) { | |
461 | + _call (gasHigh, gasLow, addressOffset, valueOffset, dataOffset, dataLength, resultOffset, resultLength, cbIndex) { | |
462 | 462 | const gas = from64bit(gasHigh, gasLow) |
463 | 463 | // Load the params from mem |
464 | 464 | const address = [...this.getMemory(addressOffset, ADDRESS_SIZE_BYTES)] |
465 | - const value = U256.fromMemory(this.getMemory(valueOffset, U128_SIZE_BYTES)) | |
465 | + const value = new U256(this.getMemory(valueOffset, U128_SIZE_BYTES)) | |
466 | 466 | |
467 | 467 | this.takeGas(40) |
468 | 468 | |
469 | - // const data = this.getMemory(dataOffset, dataLength).slice(0) | |
470 | - | |
471 | - // // Special case for calling into empty account | |
472 | - // if (!this.environment.isAccountPresent(address)) { | |
473 | - // this.takeGas(25000) | |
474 | - // } | |
475 | - if (address.lt(new U256(4))) { | |
476 | - this.takeGas(25000) | |
477 | - } | |
478 | - // // Special case for non-zero value | |
469 | + // Special case for non-zero value; why does this exist? | |
479 | 470 | if (!value.isZero()) { |
480 | 471 | this.takeGas(9000 - 2300 + gas) |
481 | 472 | this.takeGas(-gas) |
482 | 473 | } |
483 | 474 | |
484 | - // const [errorCode, result] = this.environment.call(gas, address, value, data) | |
485 | - // this.setMemory(resultOffset, resultLength, result) | |
486 | - // return errorCode | |
487 | - return 1 | |
475 | + let opPromise = this.kernel.environment.state.root.get(address) | |
476 | + .catch(() => { | |
477 | + // why does this exist? | |
478 | + this.takeGas(25000) | |
479 | + }) | |
480 | + | |
481 | + // wait for all the prevouse async ops to finish before running the callback | |
482 | + this.kernel.pushOpsQueue(opPromise, cbIndex, () => { | |
483 | + return 1 | |
484 | + }) | |
488 | 485 | } |
489 | 486 | |
490 | 487 | /** |
491 | 488 | * Message-call into this account with an alternative account’s code. |
@@ -503,9 +500,9 @@ | ||
503 | 500 | // Load the params from mem |
504 | 501 | const path = [...this.getMemory(addressOffset, ADDRESS_SIZE_BYTES), 'code'] |
505 | 502 | const value = U256.fromMemory(this.getMemory(valueOffset, U128_SIZE_BYTES)) |
506 | 503 | |
507 | - // Special case for non-zero value | |
504 | + // Special case for non-zero value; why does this exist? | |
508 | 505 | if (!value.isZero()) { |
509 | 506 | this.takeGas(6700) |
510 | 507 | } |
511 | 508 | |
@@ -517,20 +514,9 @@ | ||
517 | 514 | return null |
518 | 515 | }) |
519 | 516 | |
520 | 517 | this.kernel.pushOpsQueue(opPromise, cbIndex, oldValue => { |
521 | - //TODO | |
522 | - // const data = this.getMemory(dataOffset, dataLength).slice(0) | |
523 | - | |
524 | - // // Special case for calling into empty account | |
525 | - // if (!this.environment.isAccountPresent(address)) { | |
526 | - // this.takeGas(25000) | |
527 | - // } | |
528 | - | |
529 | - // const [errorCode, result] = this.environment.call(gas, address, value, data) | |
530 | - // this.setMemory(resultOffset, resultLength, result) | |
531 | - // return errorCode | |
532 | - // | |
518 | + return 1 | |
533 | 519 | }) |
534 | 520 | } |
535 | 521 | |
536 | 522 | /** |
Built with git-ssb-web