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

Commit

Permalink
Fix Incompatible EIP155-based V RPC error
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasjpaterno authored and davidmurdoch committed Jan 15, 2020
1 parent 56b832c commit 81d4226
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion lib/statemanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ var sigUtil = require("eth-sig-util");
var _ = require("lodash");
const { BlockOutOfRangeError } = require("./utils/errorhelper");
const BN = utils.BN;
const rlp = require("rlp");
const Common = require("ethereumjs-common").default;

const ZERO_BUFFER = Buffer.from([0]);

Expand Down Expand Up @@ -287,7 +289,39 @@ StateManager.prototype.getCode = function(address, number, callback) {
};

StateManager.prototype.queueRawTransaction = function(data, callback) {
const tx = new Transaction(data, Transaction.types.signed, this.blockchain.vm.opts.common);
let chainId;
if (Buffer.isBuffer(data)) {
let decodedData = rlp.decode(data);
let v = decodedData[6];
if (v !== undefined) {
v = utils.bufferToInt(v);
let _chainId = Math.floor((v - 35) / 2);
switch (_chainId) {
case this.net_version:
chainId = this.net_version;
break;
case 1337:
chainId = _chainId;
break;
default:
break;
}
}
}
let common = !chainId
? this.blockchain.vm.opts.common
: Common.forCustomChain(
"mainnet", // TODO needs to match chain id
{
name: "ganache",
networkId: this.options.network_id || this.forkVersion,
chainId,
comment: "Local test network",
bootstrapNodes: []
},
this.options.hardfork
);
let tx = new Transaction(data, Transaction.types.signed, common);
// use toLowerCase() to properly handle from addresses meant to be validated.
const from = to.hex(tx.from).toLowerCase();
this._queueTransaction("eth_sendRawTransaction", tx, from, null, callback);
Expand Down

0 comments on commit 81d4226

Please sign in to comment.