-
Notifications
You must be signed in to change notification settings - Fork 16
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
Add support for getLogs() on FilterAPI #199
Comments
Test code const { providers } = require("ethers");
const BlocksToScan = 6001; // Relayers re-register to the hub every 6000 blocks
const hubContractAddress = "0x511bed1c29bc163c96b7d4dde28c7e0590aa44f5";
(async () => {
const jsonRpcProvider = new providers.JsonRpcProvider(
"https://node.sirius.lightstreams.io"
);
const latestBlock = await jsonRpcProvider.getBlockNumber();
console.log("latestBlock", latestBlock);
const fromBlock = latestBlock - BlocksToScan;
const relayAddedEvents = await jsonRpcProvider.getLogs({
fromBlock,
address: hubContractAddress
});
// never get a response
console.log("relayAddedEvents", relayAddedEvents);
})(); |
UPDATE: Seems like we have the filtering API in place without me writing any extra Lightchain code. I also wrote the tests for the |
Hanging call:
|
HA. A working call:
The question is... what's the difference. ID seems to be irrelevant from Go code perspective. |
Additional reproducable hanging sandbox from Portis: https://codesandbox.io/s/lightstreams-get-logs-dquuh |
Testing differences between Geth versions 1.8.27 and 1.9.2.Using Geth 1.9.2 with improved test suite logging and assertions as in commit below.Truffle connected to Local SiriuscURL connected to Local Sirius
cURL connected to Remote Sirius
Works all like charm 👍 Using Geth 1.8.27 with improved test suite logging and assertions as in commit below.... to be tested in few seconds |
Using Geth 1.8.27lightchain $lightchain version Truffle connected to Local SiriuscURL connected to Local Sirius
cURL connected to Remote Sirius
Works all like charm as well 👍 hmmm |
Summary
Some web3 libraries such as https://www.npmjs.com/package/ethers and other projects have the necessity to filter Lightchain logs.
The web3 method is called
getLogs()
and translates to Geth API aseth_getLogs
.ethers/providers/json-rpc-provider.ts
Steps to resolve
func (api *PublicFilterAPI) GetLogs(ctx context.Context, crit FilterCriteria) ([]*types.Log, error) {
From:
go-ethereum/eth/filters/api.go
Something like this should work as fix:
lightchain/database/database.go
The text was updated successfully, but these errors were encountered: