abci,txapp,kwild: new chain meta store #610
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This change move's the ABCI application's meta datastore from a badger DB file to postgres.
The ABCI metadata store must contain the following for the current block processed by the application:
These data are required primarily to satisfy the
Info
method of the ABCI application, which is used by cometbft as both an integrity check and to signal if and where to start reapplying blocks to catch the application up to the node's internal block store. The new(*TxApp).ChainInfo
method provides this information to the application and back to cometbft on startup.These data are also required for
InitChain
to ensure that when cometbft is starting at genesis (empty block store), the application state does not include existing unexpected data, which can happen when resetting cometbft's data (rm -r ~/.kwild
) but forgetting to drop kwild's postgresql database.To make this change while supporting an upgrade from v0.7.0 nodes, it is necessary to attempt to load the data from an existing badger DB is the meta tables do not already exist in postgres. This is unfortunate, but necessary, and can be removed at some point when we are convinced everyone is migrated. Also note that it was not possible to use the existing
kwil_voting.height
table for this upgrade since it lacked app hash.Although this change now allows the latest committed block height to be included with the main consensus DB transaction, it is still necessary to update the app hash following
Precommit
(and thus in a subsequent DB transactions). This is an improvement since it makes a surprise apphash mismatch with a peer node impossible on account of the non-atomic storage in the old badger DB, but there still exists a recognizable manual recovery scenario if the subsequent transaction fails to store the app hash. I believe this previous failure mode was the cause for the app hash mismatch I was diagnosing last week following a poorly time suspend of my laptop.There are several less notable changes below
common/sql.TxCloser
interface since it is unused on it's own, although it was once relevant whenExecute
was not used as a method of a transaction and instead via the top level DB. We can factor away thepg.DB.tx
field soon