Skip to content

Stake Database, Fast Pool Info, Reorg Handling

Compare
Choose a tag to compare
@chappjc chappjc released this 10 Jun 18:44
· 1401 commits to master since this release
v0.3.2

IMPORTANT: When upgrading to v0.3.2 it is necessary to delete your current dcrdata.sqlt.db. It shouldn't be necessary to delete the ffldb_stake folder, but it is recommended to delete it as well so it can also be fresh.

The main visible difference is faster startup once the databases are synchronized because: (1) as the stake database is kept up-to-date when running, and (2) no rewind by TicketMaturityHeight blocks is needed anymore. The only delay at startup is a pre-population of the live ticket cache, which takes 30-60 seconds.

Several calculations are fixed, reorganization is handled by the stake database now, and blockdata.Collect() is much faster as the ticketpoolinfo RPC is no longer used (in favor of the stake database and a live ticket cache).

Notable changes:

  • The stakedb package for maintaining the stake database while running.
  • Use StakeDatabase.PoolInfo() in sync instead of slow RPC. Also don't use BlockHeader.PoolSize as it is not the same as what stake/Node.LiveTickets() indicates.
  • Reorganization handling framework and a complete handler in the stakedb package that will disconnect orphaned blocks and switch to the new sidechain.
  • Updated dependencies (JSONRPCClientPort, testnet2, fixed OnNewTickets, wtxmgr->udb, required RPC API version, etc).
  • Mempool section of web UI is updated immediately rather than after the first regular collection.
  • Use the new GetBlockHeaderVerbose RPC.
  • Fix some data races.
  • Fix min/max fee computation in FeeInfoBlock. Add tests for FeeInfoBlock and FeeRateInfoBlock.
  • Docs and copyrights.
  • A few new functions for future development.

This is a step toward collecting block data without using RPCs that operate implicitly on the current best block, however BlockDataSaver.Store() needs refactoring.

stakedb has a PoolInfo() method for getting ticket pool value quickly using its live ticket cache, and it does it as the height of the database rather than using the node RPC to get ticket pool value at current best height. Also, FeeInfoBlock() in txhelpers computes ticket fee info for an input block, rather than the node RPC.

5cecd17...master