Calling eth_getLogs ends with an unhandled EIP155-related error
See original GitHub issueExpected Behavior
When using ganache-core
to programmatically fork the mainnet Ethereum chain and querying it for logs, any past/existing events should be retrieved as if the request to the Ethereum client the fork was created from.
Current Behavior
The process ends up crashing with and unhandled promise rejection error:
(node:47221) UnhandledPromiseRejectionWarning: Error: Incompatible EIP155-based V 0 and chain id 1. See the second parameter of the Transaction constructor to set the chain id.
Steps to Reproduce (for bugs)
Run the following code:
const ganache = require("ganache-core"); // @2.13.2
const Web3 = require("web3"); // @1.3.6
const httpProvider = new Web3.providers.HttpProvider(process.env.NODE_URL);
const forkProvider = ganache.provider({ fork: httpProvider });
const web3 = new Web3(forkProvider);
web3.eth.getPastLogs(
{
fromBlock: 12563800,
toBlock: 12563810,
topics: [
// ERC-20 Approve event signature
"0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925",
// A random owner address
"0x000000000000000000000000f403c135812408bfbe8713b5a23a04b3d48aae31",
],
},
console.log
);
It will throw the following:
(node:47221) UnhandledPromiseRejectionWarning: Error: Incompatible EIP155-based V 0 and chain id 1. See the second parameter of the Transaction constructor to set the chain id.
at Transaction._validateV (./node_modules/ganache-core/node_modules/ethereumjs-tx/src/transaction.ts:370:13)
at Transaction.set [as v] (./node_modules/ganache-core/node_modules/ethereumjs-tx/src/transaction.ts:387:16)
at ./node_modules/ganache-core/lib/utils/transaction.js:116:23
at Array.forEach (<anonymous>)
at initData (./node_modules/ganache-core/lib/utils/transaction.js:110:18)
at new Transaction (./node_modules/ganache-core/lib/utils/transaction.js:168:5)
at Function.fromJSON (./node_modules/ganache-core/lib/utils/transaction.js:228:16)
at ./node_modules/ganache-core/lib/forking/forked_blockchain.js:388:21
at Array.forEach (<anonymous>)
at Object.callback (./node_modules/ganache-core/lib/forking/forked_blockchain.js:386:31)
at sendTxCallback (./node_modules/ganache-core/node_modules/web3-core-method/src/index.js:664:29)
at onJsonrpcResult (./node_modules/ganache-core/node_modules/web3-core-requestmanager/src/index.js:179:9)
at ./node_modules/ganache-core/lib/forking/forked_blockchain.js:136:11
at processTicksAndRejections (internal/process/task_queues.js:93:5)
Note:
Digging a bit into the code, it looks like it is trying to replay the transactions in those blocks and when processing 0xe3bfbc0d881037378ede46078de1539066c0dbff4641ae379740aebd715721f0
at block 12563806, it fails validating the EIP-155 v
value of 0
inside ethereumjs-tx
.
So what may be happening is that this transaction was created with an non-EIP155 code/lib/wallet and ethereumjs-tx
does not properly handle it.
Context
This problem was seen while testing an app that relies on events to be logged, then processed. So alternatives have to be considered like testing the app in a live testnet or using other tools to fork the chain.
Your Environment
- Version used: 2.13.2
- NodeJS Version: 12.x, 14.x
- Operating System and version: macOS 11.4
- Link to your project or repro gist: https://gist.github.com/gabmontes/440c533a03aa5f6749a308081b969311
- I intend to submit a pull request to fix this issue: [ ]
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:15 (8 by maintainers)
Top GitHub Comments
Honestly, I saw the commit you made in your 7.0 branch with the breaking changes.
I’m super new with all the ganache tools so I don’t exactly know what I’m doing, but when I do, I’ll be sure to give some feedback. I’m actually surprised ganache was not working like real nodes. That just proves I really don’t know what I’m doing.
Thanks for the help
@gabmontes Looks like ganache is validating data from that it receives from the
fork
when it really shouldn’t be, or at least it should be using different hardfork rules, depending on the context on the transaction it is validating. This will likely be fixed in the upcoming Ganache v7 release. You can try an internal preview of this release by first uninstalling ganache-cli/ganache-core and installing ganache@internal instead (npm install ganache@internal
for library use ornpm install --global ganache@internal
for global use).