This repository was archived by the owner on Jan 7, 2026. It is now read-only.
feat: get blockNumber from Ethers.js event data#312
Merged
Conversation
Move the function from inside `startRoundTracker` to the top level. Signed-off-by: Miroslav Bajtoš <[email protected]>
I found a way how to access the ContractEventPayload from the contract event listener function. By getting the block number from the event data, we don't have to make another RPC call to find the block number via potentially expensive & slow `eth_getLogs`. Signed-off-by: Miroslav Bajtoš <[email protected]>
Member
Author
|
This pull request is based on #310 and it's blocked until we land that refactor. |
Signed-off-by: Miroslav Bajtoš <[email protected]>
Signed-off-by: Miroslav Bajtoš <[email protected]>
juliangruber
approved these changes
May 17, 2024
bajtos
commented
May 21, 2024
Comment on lines
+35
to
+42
| const event = args.pop() | ||
| const blockNumber = event?.log?.blockNumber | ||
| if (blockNumber === undefined) { | ||
| console.warn( | ||
| 'Ethers.js event data did not include ContractEventPayload with the block number. ' + | ||
| 'Will call `eth_getLogs` to find the round start epoch.' | ||
| ) | ||
| } |
Member
Author
There was a problem hiding this comment.
This seems to work very well. 👍🏻 We are advancing rounds, and the warning is not printed.
2024-05-21T08:56:31Z app[5683210c621628] cdg [info]Mapped 0x8460766Edc62B525fc1FA4D628FC79229dC73031 IE round index 7310n to SPARK round number 12733n (start epoch: 3932512)
2024-05-21T08:56:33Z app[5683210c621628] cdg [info]SPARK round started: 12733n (epoch: 3932512)
2024-05-21T08:56:33Z app[9185e760f41658] cdg [info]Mapped 0x8460766Edc62B525fc1FA4D628FC79229dC73031 IE round index 7310n to SPARK round number 12733n (start epoch: 3932512)
2024-05-21T08:56:33Z app[9185e760f41658] cdg [info]SPARK round started: 12733n (epoch: 3932512)
2024-05-21T08:56:33Z app[3d8dd965ae2998] cdg [info]Mapped 0x8460766Edc62B525fc1FA4D628FC79229dC73031 IE round index 7310n to SPARK round number 12733n (start epoch: 3932512)
2024-05-21T08:56:33Z app[3d8dd965ae2998] cdg [info]SPARK round started: 12733n (epoch: 3932512)
2024-05-21T08:56:34Z app[48ed67dc0e0308] cdg [info]Mapped 0x8460766Edc62B525fc1FA4D628FC79229dC73031 IE round index 7310n to SPARK round number 12733n (start epoch: 3932512)
2024-05-21T08:56:34Z app[48ed67dc0e0308] cdg [info]SPARK round started: 12733n (epoch: 3932512)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I found a way how to access the ContractEventPayload from the contract event listener function. By getting the block number from the event data, we don't have to make another RPC call to find the block number via potentially expensive & slow
eth_getLogs.Very loosely related to: