This eliminates the BIP30 checks for blocks before the BIP34 activation.
Those checks consist of one LevelDB Get call for each transaction in the block (34,846,734 in total).
This eliminates the BIP30 checks for blocks before the BIP34 activation.
Those checks consist of one LevelDB Get call for each transaction in the block (34,846,734 in total).
We need this flag to handle masking the BIP34/BIP30 logic.
This eliminates the related disk access.
Haven’t reviewed closely, but it would be nice how much of a speed up this gives before deciding whether to review.
Also, you’d want to update the comment it is applied to all blocks except the
// two in the chain
, as the check is applied to no block (in the assumevalid chain) after your changes.
1818@@ -1819,6 +1819,8 @@ bool CChainState::ConnectBlock(const CBlock& block, CValidationState& state, CBl
1819 CBlockIndex *pindexBIP34height = pindex->pprev->GetAncestor(chainparams.GetConsensus().BIP34Height);
1820 //Only continue to enforce if we're below BIP34 activation height or the block hash at that height doesn't correspond.
1821 fEnforceBIP30 = fEnforceBIP30 && (!pindexBIP34height || !(pindexBIP34height->GetBlockHash() == chainparams.GetConsensus().BIP34Hash));
1822+ // And we're not assuming the block is valid.
1823+ fEnforceBIP30 = fEnforceBIP30 && !fAssumeValid;
Yes, but in the exact same way that an assumevalid chain with invalid scripts would cause that today.
I don’t see a incentives issue, as violating bip30 really only allows you to destroy coins.
Am I missing something?
From IRC:
[08:29] Anyway this would be a simple fix to your PR — just ensure that you only skip the bip30 checks if assume valid is set and the assume valid block hash builds on the known bip34 activation block hash; that would ensure that we only skip the bip30 checks on blocks we know to be safe from this issue
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
Reviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
time src/bitcoind -stopatheight=227931
for master (33894612c0de953b75b41dbfcc643986e4ac177e) and this PR. Starting with an empty data dir on each run, except for a bitcoin.conf
which contained par=8
and dbcache=2048
. Master took 16m27s
and this PR took 16m43s
.
time ./src/bitcoind -reindex-chainstate -stopatheight=227931 -dbcache=1024
this pr: 3m25.503s master: 3m47.508s
ie 10% faster
Running time ./src/bitcoind -reindex-chainstate -stopatheight=227931 -dbcache=1024
I do see the speedup:
master e653eeff7651d823407e2e31a89176cc0b240c62: 6m8s
this PR: 5m48s
-0 on this since it doesn’t speed up the non-trivial parts of IBD and introduces more varied behavior to consensus-critical code. Benching the first 200k blocks is deceptive since that’s such a small part of total IBD time. Benching a more meaningful part of the chain (almost by definition) shows no improvement:
I think I’m in agreement with @sdaftuar and @jamesob, even though this may bring a slight speedup to a small portion of IBD. @laanwj Can you weigh in here? @sdaftuar
(even though I think this change could be made to be correct, this is complex enough that we should have a higher bar for making this kind of change).
I’d be interested in hearing more of your thoughts on this. i.e what do you think that bar looks like? If this change was a 30% speedup would that be acceptable? 50%? Or would you only consider optimizations that would affect all of IBD etc.