-
Notifications
You must be signed in to change notification settings - Fork 108
Fix minor issues to speed up block processing logic #1145
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
Fix minor issues to speed up block processing logic #1145
Conversation
1fb8281 to
77c73ab
Compare
* Fix a bug whereby block production would not start until the first call to SubmitBlock, which resulted in erratic miner behavior. Specifically, all calls to get-block-template would fail until the first call to submit-block. Normally in the steady-state this is not an issue, but during a reboot it can become a "chicken and egg" where miners need get-block-template to generate a valid block, but get-block-template won't return until they actually produce a block (which they can't do without a template). * Reduce the default block size used by miners to 500kb, down from 2mb. This ends up giving better performance during periods of high congestion because smaller blocks are processed more quickly. With very large blocks, we were encountering an issue whereby a block would take a minute or two to fuly validate, causing erratic behavior as the block propagated through the network. * Add a rest period during initial transaction download that allows for other processes to grab the ChainLock if needed. This was the least obviously-needed of the fixes, but it doesn't hurt to leave it in, and could prevent deadlock-related issues during periods of high congestion. * Add more useful logging in various places.
77c73ab to
875d276
Compare
|
|
||
| for { | ||
| if atomic.LoadInt32(&desoBlockProducer.exit) >= 0 { | ||
| if atomic.LoadInt32(&desoBlockProducer.exit) > 0 { |
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.
This was causing a lot of the erratic behavior when nodes would restart. See main PR description for details.
| // spam blocks in the event someone tries to abuse the initially low min | ||
| // fee rates. | ||
| MinerMaxBlockSizeBytes: 2000000, | ||
| MinerMaxBlockSizeBytes: 500000, |
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.
Note that this does not reduce the maximum block size permitted by the network, only the default block size used by miners when generating block templates.
| // five seconds is the right amount. We added it during a mission-critical sprint | ||
| // to find and fix slow block production issue as one of several patches. It clearly doesn't | ||
| // hurt so we decided to leave it in for now. | ||
| if (ii+1)%1000 == 0 { |
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.
Early on, I suspected that the reason get-block-template wasn't working was because of a ChainLock starvation caused by downloading a lot of transactions. Ultimately, it wasn't that, but giving a breather for other processes to acquire the ChainLock seemed like a fine thing to keep, and doesn't slow down sync too much.
| return | ||
| } | ||
|
|
||
| // Set the time to a nil value so we run on the first iteration of the loop. |
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.
Let's update this comment since time is no longer nil.
Fix a bug whereby block production would not start until the first call to SubmitBlock, which resulted in erratic miner behavior. Specifically, all calls to get-block-template would fail until the first call to submit-block. Normally in the steady-state this is not an issue, but during a reboot it can become a "chicken and egg" where miners need get-block-template to generate a valid block, but get-block-template won't return until they actually produce a block (which they can't do without a template).
Reduce the default block size used by miners to 500kb, down from 2mb. This ends up giving better performance during periods of high congestion because smaller blocks are processed more quickly. With very large blocks, we were encountering an issue whereby a block would take a minute or two to fuly validate, causing erratic behavior as the block propagated through the network.
Add a rest period during initial transaction download that allows for other processes to grab the ChainLock if needed. This was the least obviously-needed of the fixes, but it doesn't hurt to leave it in, and could prevent deadlock-related issues during periods of high congestion.
Add more useful logging in various places.