-
Notifications
You must be signed in to change notification settings - Fork 5k
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
Redundant newHeads Subscriptions when waiting on multiple outstanding requests. #3632
Comments
I can work around this by using the usual provider-wrapping tricks, but I think it'd be better if this was fixed in web3 directly. I may be wrong, but it looks like there's a single |
Do you mind providing a script for this? Happy to also take a look at it with hyperledger for better understanding :) |
@GregTheGreek - sorry, but your question was a bit ambiguous - a script for what, exactly? I'm preparing a workaround PR for HL Caliper that I hope to submit a bit later today (debugging it now). Otherwise the reproduction is really just to run an Ethereum benchmark with Caliper and observe that the number of I would've done this in web3.js directly, but I need it to be working quickly and I think it likely requires substantial structural changes. I'll post another comment shortly with links to the offending web3.js code, however, so that the Edit: Another easy way to reproduce would be to write a quick script that depends on web3.js to submit |
To address the The control flow of all transactions winds up routing through When using a provider that supports subscriptions, the logic of |
If someone does improve on this logic, it appears that Not only is this a performance issue, but I think it's somewhat of a race condition for networks with faster block times, though admittedly it's unlikely that we'd see this in the wild on any networks that exist today. That is, it's possible that we can request the receipt, not find it, the block containing the transaction is mined, and then we set up the I've verified this in the logs from one of my recent Besu benchmarking runs. A snipped of these logs is shown below. Note that if you want Besu to produce these logs you'll need to run it at
|
I'm prepping a PR that should fix this. In this PR I'll be refactoring I'll be re-implementing the transaction management logic as a basic state machine. So far I've created a type called I'm now in the process of writing a
Most of that logic will hang off of events fired by the There's a chance that some of this might spill over into how the PromiEvent is managed, or what events it fires. So far I'm hopeful that if there are any chances there, they'll be purely additive. If there are any modifications necessary I'll be sure to reach out to the maintainers before proceeding. Finally, I'm also doing my best to write this in a way that it can be easily ported over to TypeScript when the time comes. |
I'm also not quite sure yet what I'll do about |
Can you link to the branch? I would like to follow the progress |
Expected behavior
When I'm using a websocket or other subscription-capable provider, I'd assume that a single
newHeads
subscription would be all that's necessary for web3 to be notified when my transaction is confirmed.Actual behavior
When I'm using a websocket or other subscription-capable provider, web3.js sets up one
newHeads
subscription for every outstanding transaction.Steps to reproduce the behavior
newHeads
subscriptions active on the client (it'll have increased by two).Environment
I'm running into this primarily in a NodeJS environment while performance testing Hyperledger Besu.
Admittedly this likely isn't a major issue for public Ethereum, but it becomes quite substantial when submitting a high volume of transactions to a private network. For example, on a network with a 2s block time (typical for IBFT 2 networks), if the user is sending 100 transactions per second, there will be up to 200
newHeads
subscriptions active on the client, all from a single user.The text was updated successfully, but these errors were encountered: