-
Notifications
You must be signed in to change notification settings - Fork 167
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
Use L1 block number for Ticket Parameters and Round Initialization #2222
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few minor requests.
The L1 block numbers are not stored in DB and therefore need to be enriched with L1 Block Number using Arbitrum RPC API; an alternative approach would be to store L1 Block Numbers in DB:
I was slightly concerned about this because the # of RPC requests from the node is already going to be higher when connected to Arbitrum Rinkeby/mainnet due to the higher frequency of blocks. If the request count increases significantly that can affect the costs of using certain ETH JSON-RPC providers - for example, Infura's pricing tiers are based on the # of RPC requests sent per day. However, I see that extra RPC requests are only added by enriching the MiniHeaders with the L1 block number when:
- We batch request logs when backfilling and there would be an additional RPC request per log. However, since the # of logs will be determined by the # of relevant logs found with the topics that the node cares about (this is what FilterLogs does by setting specific topics as parameters), if there are very few logs that the node cares about there would be very few additional RPC requests. I suspect this will be common right now
- In
buildCanonicalChain()
. I don't completely grok the # of additional RPC requests that would be required there. Would be good to get a sense of this
Generally, I think your point that this may be okay for now is reasonable, but I do think we should get a sense of the additional RPC requests for that last point that result from this enrichment process.
Good points @yondonfu! I made one improvement in terms of the number of RPC calls here 1382f59 I realized that we actually don't need to add L1 Block Number to every block we process, it's enough to add it into the block with the highest number. It makes the code a little more tricky, but on the other hand, we minimize the number of RPC calls we make. Let me know your thoughts. With regards to your concerns.
Right, especially after this change 1382f59, I think this part is not an issue.
My understanding is that when the next block number is the child of the current block, then |
Because the block with the highest number is the latest block that we've received from polling and all other blocks we should've seen already? So, I think this should actually generally be true when using Arbitrum since re-orgs [1] shouldn't be a thing while Arbitrum is using a sequencer so we wouldn't expect [1] i.e. When certain blocks that have already occurred are discarded and new blocks take their place - transactions in the previous blocks generally end up eventually being included in the new blocks. This happens from time to time on L1 Ethereum.
See above point about re-orgs being a case to handle (which is why |
Ahh, I missed this information. So, I start to understand the idea behind
Because we're not interested in the L1 block number of all other blocks. Timewatcher is the only entity that actually reads the L1 block number and Timewatcher is only interested in the highest L1 block number as it checks:
It's the only place in the whole codebase where we read the L1 Block Number from the event. So, I think it's safe to enrich L1 only the event with the highest block number. Obviously assuming that The highest L2 Block number contains the highest L1 Block Number. But I understand it's the case, because of this sequencer thingy.
I think we don't need to set L1 Block Number on all events. It's already compatible with L1, since the block with the highest number is enriched with L1 Block Number (which is equal to Block Number in case of running on L1). |
Should be true.
Hm let me try to walk through a scenario that I think might happen when connected to a L1 provider:
I'm not sure if existing synchronization prevents the last case from happening - thoughts? |
Discussed offline. The check in https://github.com/leszko/go-livepeer/blob/1382f59ad78aa7f819ba84207d1d1ad4c90e5e6b/eth/watchers/timewatcher.go#L209 will ensure that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM after cleaning up commit history & resolving conflicts.
4a4bfc6
to
0c94301
Compare
0c94301
to
3f7bad4
Compare
What does this pull request do? Explain your changes. (required)
Use L1 block numbers during Round Initialization and in Ticket Params.
Important comments:
TimeWatcher
now has a functionLastSeenL1Block()
, but I found it does not need to haveLastSeenBlock()
anymoreblocks
andl1Blocks
in the code can be super-confusing, I tried to rename all the necessary parts of the code, so thatblock
always refers to L2 Block, however, there are still a places for which we may need an additional renaming in the future:Specific updates (required)
block
intol1Block
when it refers to L1 BlocksHow did you test each of these updates (required)
Tests on Arbitrum:
Does this pull request close any open issues?
fix #2220
Checklist:
make
runs successfully./test.sh
pass