Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eth_getLogs - Event filter topics do not work #1207

Closed
Tracked by #936
jaeaster opened this issue Dec 6, 2022 · 4 comments
Closed
Tracked by #936

eth_getLogs - Event filter topics do not work #1207

jaeaster opened this issue Dec 6, 2022 · 4 comments

Comments

@jaeaster
Copy link

jaeaster commented Dec 6, 2022

When retrieving logs, specifying a topic to filter by a specific event does not work. This effects eth_getLogs, eth_newFilter, eth_subscribe and any other method where you can retrieve logs and filter by a topic.

const rpc = 'https://wallaby.node.glif.io/rpc/v1'; 
const provider = new _ethers.providers.JsonRpcProvider(rpc);

const factoryInterface = new _ethers.utils.Interface([
  "event NewDKGCreated(address dkg)"
]);

const factoryAddress = '0x66aa40539213e2a5710c46980041b0c743a4d767';
const fromBlock = 18203;
const toBlock = 18203;
const topics = [
  factoryInterface.getEventTopic("NewDKGCreated")
];

await provider.getLogs({
  address: factoryAddress,
  fromBlock,
  toBlock,
  topics
})

=> []

If I exclude the topics, I see the event duplicated 5 times

await provider.getLogs({
  address: factoryAddress,
  fromBlock,
  toBlock,
  topics: []
})

=> (5) [{}, {}, {}, {}, {}]

{blockNumber: 18203, blockHash: '0xb8864eef3b4fc8b03d7c7469ef95ace27967617d6564953cb8851f28640d3d79', transactionIndex: 0, removed: false, address: '0x66Aa40539213E2a5710c46980041B0c743A4D767',}

{blockNumber: 18203, blockHash: '0xb8864eef3b4fc8b03d7c7469ef95ace27967617d6564953cb8851f28640d3d79', transactionIndex: 0, removed: true, address: '0x66Aa40539213E2a5710c46980041B0c743A4D767',}

{blockNumber: 18203, blockHash: '0xb8864eef3b4fc8b03d7c7469ef95ace27967617d6564953cb8851f28640d3d79', transactionIndex: 0, removed: false, address: '0x66Aa40539213E2a5710c46980041B0c743A4D767',}

{blockNumber: 18203, blockHash: '0xb8864eef3b4fc8b03d7c7469ef95ace27967617d6564953cb8851f28640d3d79', transactionIndex: 0, removed: true, address: '0x66Aa40539213E2a5710c46980041B0c743A4D767',}

{blockNumber: 18203, blockHash: '0xb8864eef3b4fc8b03d7c7469ef95ace27967617d6564953cb8851f28640d3d79', transactionIndex: 0, removed: false, address: '0x66Aa40539213E2a5710c46980041B0c743A4D767',}

And if I expand any one of those 5 logs, I see the matching topic

topics: ['0x910c4ffd91af4d613aaac5d9ebe9951074b1d661ea51abb6ec9bdf419e2140ea']
@iand
Copy link

iand commented Dec 7, 2022

Not clear what the immediate cause of this is. It could be in the filtering logic or deeper in the FVM functions that produce the topic hashes. Estimate a day to investigate and fix

@jaeaster
Copy link
Author

jaeaster commented Dec 7, 2022

A couple more notes:

I mentioned that when I use getLogs without a topic filter, I can get the logs I want and I can see that the topic hash is what I expect. So the computation of the topic hash seems to be correct, but the matching/filtering is not.

The fact that there are 5 duplicated log entries is unexpected. And in fact, I made the same query a few hours after I originally made this issue and I saw 7 entries. This behavior should probably be a separate issue, what do you think?

@iand
Copy link

iand commented Dec 8, 2022

I mentioned that when I use getLogs without a topic filter, I can get the logs I want and I can see that the topic hash is what I expect. So the computation of the topic hash seems to be correct, but the matching/filtering is not.

Agree, something is not correct here. I'm investigating

The fact that there are 5 duplicated log entries is unexpected. And in fact, I made the same query a few hours after I originally made this issue and I saw 7 entries. This behavior should probably be a separate issue, what do you think?

I can't reproduce this, I get just one result

14:05 $ curl https://wallaby.node.glif.io/rpc/v1 -X POST -H "Content-Type: application/json"  --data '{"jsonrpc":"2.0","id":1,"method":"eth_getLogs","params":[{"address":["0x66aa40539213e2a5710c46980041b0c743a4d767"],"fromBlock":"0x471B","toBlock":"0x471B","topics":null}]}'

{"jsonrpc":"2.0","result":[{"address":"0x66aa40539213e2a5710c46980041b0c743a4d767","data":"0x0000000000000000000000002d1f7bc61dc80d43e2ab43c3cb3116d508a3ce0b","topics":["0x910c4ffd91af4d613aaac5d9ebe9951074b1d661ea51abb6ec9bdf419e2140ea"],"removed":false,"logIndex":"0x0","transactionIndex":"0x0","transactionHash":"0x6e10b6c39273d01f96f83c419c9ee236e273c14a555e5f8d3c7142b279c6a576","blockHash":"0xb8864eef3b4fc8b03d7c7469ef95ace27967617d6564953cb8851f28640d3d79","blockNumber":"0x471b"}],"id":1}

@jaeaster
Copy link
Author

jaeaster commented Dec 8, 2022

I can't reproduce this, I get just one result

I also get one result now ... time seems to be relevant. And we've observed the result count both grow and shrink. Will update if I figure anything else out related to varying responses.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants