Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Commit

Permalink
Cleanup transaction, remove old code
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasjpaterno committed Dec 10, 2019
1 parent 9d0b335 commit 8f3e5e3
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 67 deletions.
3 changes: 1 addition & 2 deletions lib/utils/gas/binSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ module.exports = async function binSearch(generateVM, runArgs, result, callback)
const vm = generateVM(); // Generate fresh VM
runArgs.tx.gasLimit = gas.toBuffer();
const result = await vm.runTx(runArgs).catch((vmerr) => ({ vmerr }));
const vmerr = result.vmerr;
return !vmerr && !result.execResult.exceptionError;
return !result.vmerr && !result.execResult.exceptionError;
};

if (!(await isEnoughGas(range.hi))) {
Expand Down
65 changes: 0 additions & 65 deletions lib/utils/transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,25 +56,6 @@ function fixProps(tx, data) {
const fieldNames = ["nonce", "gasPrice", "gasLimit", "value"];
fieldNames.forEach((fieldName) => configZeroableField(tx, fieldName, 32));

// Ethereumjs-tx doesn't set the _chainId value whenever the v value is set,
// which causes transaction signing to fail on transactions that include a
// chain id in the v value (like ethers.js does).
// Whenever the v value changes we need to make sure the chainId is also set.
// const vDescriptors = Object.getOwnPropertyDescriptor(tx, "v");
// // eslint-disable-next-line accessor-pairs
// Object.defineProperty(tx, "v", {
// set: (v) => {
// vDescriptors.set.call(tx, v);
// // calculate chainId from signature
// const sigV = ethUtil.bufferToInt(tx.v);
// let chainId = Math.floor((sigV - 35) / 2);
// if (chainId < 0) {
// chainId = 0;
// }
// tx._chainId = chainId || 0;
// }
// });

if (tx.isFake()) {
/**
* @prop {Buffer} from (read/write) Set from address to bypass transaction
Expand Down Expand Up @@ -330,50 +311,4 @@ module.exports = class Transaction extends EthereumJsTransaction {

return resultJSON;
}

/**
* Computes a sha3-256 hash of the serialized tx
*
* This method is nearly identical to ethereumjs-tx hash with the exception of
* the v,r,s value setting when _chainId > 0. Because the `_chainId` in our
* implementation is calculated whenever the v is updated we have to make sure
* we don't recalc the chainId when we set the v to soemthing else.
*
* Note: If the transaction is a fake transaction this hash method gets
* overridden in the constructor.
*
* @param {Boolean} [includeSignature=true] whether or not to inculde the signature
* @return {Buffer}
*/
// hash(includeSignature = true) {
// // EIP155 spec:
// // when computing the hash of a transaction for purposes of signing or recovering,
// // instead of hashing only the first six elements (ie. nonce, gasprice, startgas, to, value, data),
// // hash nine elements, with v replaced by CHAIN_ID, r = 0 and s = 0

// let items;
// if (includeSignature) {
// items = this.raw;
// } else {
// // cache the chainId here
// const chainId = this._chainId;
// if (chainId > 0) {
// const cacheRaw = this.raw.slice();
// // Setting `this.v` changes the value of `this._chainId`
// this.v = chainId;
// this.r = 0;
// this.s = 0;

// items = this.raw;
// this.raw = cacheRaw;
// // set the chainId back to its original value here.
// this._chainId = chainId;
// } else {
// items = this.raw.slice(0, 6);
// }
// }

// // create hash
// return ethUtil.rlphash(items);
// }
};

0 comments on commit 8f3e5e3

Please sign in to comment.