-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Address Travis spurious failures #8680
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
Conversation
… for tests waitfornewblock waits until a new block is received, or the timeout expires, then returns the current block height/hash. waitforblock waits for a specific blockhash, or until the timeout expires, then returns the current block height/hash. If the target blockhash is the current tip, it will return immediately. waitforblockheight waits until the tip has reached a certain height or higher, then returns the current height and hash. waitforblockheight is used to avoid polling in the rpc tests.
|
These RPCs happen to also wait for wallet processing at this point, but that will change if wallet processing becomes asynchronous. ACK on this as a stopgap measure to prevent the synchronization issues. But I think there should be a warning in their help to not rely on this behavior "as the tests do". |
| { | ||
| if (fHelp || params.size() < 1 || params.size() > 2) | ||
| throw runtime_error( | ||
| "waitforblock\n" |
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.
nit: s/waitforblock/waitforblock <blockhash> <timeout>
I guess most commands help have it like this.
|
Concept ACK. |
|
Gah I'm just going to go ahead and merge this, I need the tests to pass, it's low-risk (largest risk is to break the tests even more, well...) and fixups can be done later. |
d6a5dc4 add waitfornewblock/waitforblock/waitforblockheight rpcs and use them for tests (Cory Fields)
| return True | ||
| time.sleep(wait) | ||
| if heights == [ heights[0] ]*len(heights): #heights are the same but hashes are not | ||
| raise AssertionError("Block sync failed") |
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.
Nit: mempool_packages.py relies on this not being thrown.
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.
There's a slightly bigger issue that @morcos just noticed, which is that the block notification signals doesn't quite work with invalidateblock right now.
I think we can work around it by having the invalidateblock rpc handler explicitly call the ui signals in this case (which is probably the right thing to do in general).
|
Just to be sure: The new rpc calls are not meant for general consumption but serve as a temporary fix for the tests? |
|
Does this need a backport? |
|
@luke-jr No, the commit that reworked the locks is only in master |
|
This will also break the tests, when an old binary is used for comp. checks. |
|
There were suggestions by @morcos and @TheBlueMatt to address the failures in a less breaking way during one of the last meetings, but I couldn't find any follow ups. |
| { | ||
| if (fHelp || params.size() < 1 || params.size() > 2) | ||
| throw runtime_error( | ||
| "waitforblock\n" |
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.
waitforblockheight
Also there is a spurious opening { some lines below.
This change is needed to prevent sync_blocks timeouts in the mempool_reorg test after the sync_blocks update in the upcoming commit "[qa] Change sync_blocks to pick smarter maxheight". This change was initially suggested by Suhas Daftuar <[email protected]> in #8680 (comment)
This change is needed to prevent sync_blocks timeouts in the mempool_reorg test after the sync_blocks update in the upcoming commit "[qa] Change sync_blocks to pick smarter maxheight". This change was initially suggested by Suhas Daftuar <[email protected]> in bitcoin#8680 (comment) Github-Pull: bitcoin#9196 Rebased-From: 67c6326
This change is needed to prevent sync_blocks timeouts in the mempool_reorg test after the sync_blocks update in the upcoming commit "[qa] Change sync_blocks to pick smarter maxheight". This change was initially suggested by Suhas Daftuar <[email protected]> in bitcoin#8680 (comment) Github-Pull: bitcoin#9196 Rebased-From: 67c6326
This change is needed to prevent sync_blocks timeouts in the mempool_reorg test after the sync_blocks update in the upcoming commit "[qa] Change sync_blocks to pick smarter maxheight". This change was initially suggested by Suhas Daftuar <[email protected]> in bitcoin#8680 (comment) Github-Pull: bitcoin#9196 Rebased-From: 67c6326
* Implement BIP 9 GBT changes - BIP9DeploymentInfo struct for static deployment info - VersionBitsDeploymentInfo: Avoid C++11ism by commenting parameter names - getblocktemplate: Make sure to set deployments in the version if it is LOCKED_IN - In this commit, all rules are considered required for clients to support * qa/rpc-tests: bip9-softforks: Add tests for getblocktemplate versionbits updates * getblocktemplate: Explicitly handle the distinction between GBT-affecting softforks vs not * getblocktemplate: Use version/force mutation to support pre-BIP9 clients * Don't use floating point Github-Pull: bitcoin#8317 Rebased-From: 477777f * Send tip change notification from invalidateblock This change is needed to prevent sync_blocks timeouts in the mempool_reorg test after the sync_blocks update in the upcoming commit "[qa] Change sync_blocks to pick smarter maxheight". This change was initially suggested by Suhas Daftuar <[email protected]> in bitcoin#8680 (comment) Github-Pull: bitcoin#9196 Rebased-From: 67c6326 * torcontrol: Explicitly request RSA1024 private key When generating a new service key, explicitly request a RSA1024 one. The bitcoin P2P protocol has no support for the longer hidden service names that will come with ed25519 keys, until it does, we depend on the old hidden service type so make this explicit. See bitcoin#9214. Github-Pull: bitcoin#9234 Rebased-From: 7d3b627 * Bugfix: FRT: don't terminate when keypool is empty Github-Pull: bitcoin#9295 Rebased-From: c24a4f5 * add fundrawtransaction test on a locked wallet with empty keypool Github-Pull: bitcoin#9295 Rebased-From: 1a6eacb
* Implement BIP 9 GBT changes - BIP9DeploymentInfo struct for static deployment info - VersionBitsDeploymentInfo: Avoid C++11ism by commenting parameter names - getblocktemplate: Make sure to set deployments in the version if it is LOCKED_IN - In this commit, all rules are considered required for clients to support * qa/rpc-tests: bip9-softforks: Add tests for getblocktemplate versionbits updates * getblocktemplate: Explicitly handle the distinction between GBT-affecting softforks vs not * getblocktemplate: Use version/force mutation to support pre-BIP9 clients * Don't use floating point Github-Pull: #8317 Rebased-From: 477777f2503e3a56a267556f0fc5091042d93340 * Send tip change notification from invalidateblock This change is needed to prevent sync_blocks timeouts in the mempool_reorg test after the sync_blocks update in the upcoming commit "[qa] Change sync_blocks to pick smarter maxheight". This change was initially suggested by Suhas Daftuar <[email protected]> in bitcoin/bitcoin#8680 (comment) Github-Pull: #9196 Rebased-From: 67c6326abd1788e6f411feb4f44b69774e76aae2 * torcontrol: Explicitly request RSA1024 private key When generating a new service key, explicitly request a RSA1024 one. The bitcoin P2P protocol has no support for the longer hidden service names that will come with ed25519 keys, until it does, we depend on the old hidden service type so make this explicit. See #9214. Github-Pull: #9234 Rebased-From: 7d3b627395582ae7c9d54ebdbc68096d7042162b * Bugfix: FRT: don't terminate when keypool is empty Github-Pull: #9295 Rebased-From: c24a4f5981d47d55aa9e4eb40294832a4d38fb80 * add fundrawtransaction test on a locked wallet with empty keypool Github-Pull: #9295 Rebased-From: 1a6eacbf3b7e3d5941fec1154079bbc4678ce861
d6a5dc4 add waitfornewblock/waitforblock/waitforblockheight rpcs and use them for tests (Cory Fields)
d6a5dc4 add waitfornewblock/waitforblock/waitforblockheight rpcs and use them for tests (Cory Fields)
This change is needed to prevent sync_blocks timeouts in the mempool_reorg test after the sync_blocks update in the upcoming commit "[qa] Change sync_blocks to pick smarter maxheight". This change was initially suggested by Suhas Daftuar <[email protected]> in bitcoin#8680 (comment)
This change is needed to prevent sync_blocks timeouts in the mempool_reorg test after the sync_blocks update in the upcoming commit "[qa] Change sync_blocks to pick smarter maxheight". This change was initially suggested by Suhas Daftuar <[email protected]> in bitcoin#8680 (comment) Github-Pull: bitcoin#9196 Rebased-From: 67c6326
d6a5dc4 add waitfornewblock/waitforblock/waitforblockheight rpcs and use them for tests (Cory Fields)
As discussed in last week's meeting. The failures are annoying.
I'm sure that this isn't the best approach, but these rpcs seem generally useful, and I believe this fixes the current race issue.
The problem is that the wallet is not yet finished dealing with transactions before getblockcount/getbestblockhash return new values, so assertions about balances are racy. The approach I've taken here is to wait for a signal that the processing is complete, then cache the new height/hash on the rpc side. That allows for blocking in the call rather than polling, and it ensures that we're synced up before it returns. It also means no cs_main locking.
To fix sync_blocks in particular, wait for height 0 from all nodes. That returns the current height/hash instantly, since it should never actually have to wait. Then, grab the current height from all nodes, take the max, and wait on that height for all nodes. Repeat until all heights match.
@sdaftuar Mentioned that it may be useful to a wait_for_wallet() call, which would presumably work similarly, though I'm afraid it may introduce new race issues. Suggestions on that approach are also welcome.