Skip to content

Conversation

@diamondhands0
Copy link
Member

@diamondhands0 diamondhands0 commented Mar 25, 2024

  • 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.

@diamondhands0 diamondhands0 requested a review from a team as a code owner March 25, 2024 02:22
@diamondhands0 diamondhands0 force-pushed the diamondhands/INCREASE-LOGGING-ON-BLOCK-TIP-ERROR branch from 1fb8281 to 77c73ab Compare March 25, 2024 02:48
* 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.
@diamondhands0 diamondhands0 force-pushed the diamondhands/INCREASE-LOGGING-ON-BLOCK-TIP-ERROR branch from 77c73ab to 875d276 Compare March 25, 2024 02:53

for {
if atomic.LoadInt32(&desoBlockProducer.exit) >= 0 {
if atomic.LoadInt32(&desoBlockProducer.exit) > 0 {
Copy link
Member Author

@diamondhands0 diamondhands0 Mar 25, 2024

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,
Copy link
Member Author

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 {
Copy link
Member Author

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.
Copy link
Member

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.

@lazynina lazynina merged commit deaebbd into main Mar 29, 2024
@lazynina lazynina deleted the diamondhands/INCREASE-LOGGING-ON-BLOCK-TIP-ERROR branch March 29, 2024 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants