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

Commit

Permalink
Revert "feat: add ability to use blockHash with eth_getLogs (#635)"
Browse files Browse the repository at this point in the history
This reverts commit fb16896.
  • Loading branch information
davidmurdoch committed Sep 29, 2020
1 parent fb16896 commit 4f8bc49
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 62 deletions.
9 changes: 1 addition & 8 deletions lib/statemanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -779,8 +779,7 @@ StateManager.prototype.getLogs = function(filter, callback) {
{
fromBlock: this.blockchain.getEffectiveBlockNumber.bind(this.blockchain, filter.fromBlock || "latest"),
toBlock: this.blockchain.getEffectiveBlockNumber.bind(this.blockchain, filter.toBlock || "latest"),
latestBlock: this.blockchain.getEffectiveBlockNumber.bind(this.blockchain, "latest"),
block: this.blockchain.getBlock.bind(this.blockchain, filter.blockHash || 0)
latestBlock: this.blockchain.getEffectiveBlockNumber.bind(this.blockchain, "latest")
},
function(err, results) {
if (err) {
Expand All @@ -789,17 +788,11 @@ StateManager.prototype.getLogs = function(filter, callback) {
var fromBlock = results.fromBlock;
var toBlock = results.toBlock;
var latestBlock = results.latestBlock;
var block = results.block;

if (toBlock > latestBlock) {
toBlock = latestBlock;
}

if (filter.blockHash) {
fromBlock = to.number(block.header.number);
toBlock = to.number(block.header.number);
}

var logs = [];
var current = fromBlock;

Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "@eth-optimism/ganache-core",
"description": "ganache fork for ethereum development",
"name": "ganache-core",
"version": "2.12.1",
"main": "./index.js",
"types": "./typings/index.d.ts",
Expand Down
52 changes: 0 additions & 52 deletions test/local/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,58 +179,6 @@ var tests = function(web3, EventTest) {
);
});

// NOTE! This test relies on the events triggered in the tests above.
it("should return logs using blockHash", function(done) {
var provider = web3.currentProvider;

provider.send(
{
jsonrpc: "2.0",
method: "eth_getBlockByNumber",
params: [
"latest",
false
],
id: new Date().getTime()
},
function(err, result) {
if (err) {
return done(err);
}

const hash = result.result.hash;

provider.send(
{
jsonrpc: "2.0",
method: "eth_getLogs",
params: [
{
blockHash: hash,
topics: [
"0xc54307031d9aa93e0568c363be84a9400dce343fef6a2851d55662a6af1a29da",
"0x0000000000000000000000000000000000000000000000000000000000000001",
"0x0000000000000000000000000000000000000000000000000000000000000006"
]
}
],
id: new Date().getTime()
},
function(err, result) {
if (err) {
return done(err);
}
const logIndex = result.result[0].logIndex;
const transactionIndex = result.result[0].transactionIndex;
assert.strictEqual(logIndex, "0x0");
assert.strictEqual(transactionIndex, "0x0");
done();
}
);
}
);
});

it("always returns a change for every new block subscription when instamining", function(done) {
var provider = web3.currentProvider;

Expand Down

0 comments on commit 4f8bc49

Please sign in to comment.