The code that records block data in the archive node database had a bug that swapped balances between fee transfer receivers, in the case when two fee transfers are combined into one fee transfer. That bug was fixed in PR #8509, and included in Mina release v1.1.5.
The erroneous data affects only the balances corresponding to those fee transfer transactions in blocks. No other balances in the archive database are affected, and the error affects only the database, and has no affect on the integrity of the Mina blockchain.
Once release v1.1.5 (or a later release) is installed, there will be no new swapped balances created. This document provides instruction on how to repair existing bad balances.
curl -so fix-all-balances.sh https://raw.githubusercontent.com/MinaProtocol/mina/develop/scripts/archive/fix-all-balances.sh
The script ./fix-all-balances.sh
should fix all balances from the canonical chain in your
archive database. You may need to modify the ARCHIVE_URL
variable
in the script, or provide it as an environment variable, depending on how you
run Postgresql for your archive node. Similarly, to use this tool for patching a devnet
database, simply run NETWORK=devnet ./fix-all-balances.sh
.
When you run the script, it prompts for a state hash, which should correspond to a recent block on the canonical chain which occurs in your archive database. You may wish to look at Mina Explorer to find a suitable state hash. If a block with the provided state hash does not occur in your database, the script will fail, and you should try again with an earlier state hash. Running the script will take at least 30 minutes, potentially one hour or more, to replay and verify all of the transactions since genesis.
After making the needed repairs, the tool reports the number of swapped balances. For example, you might see:
Found 16 swapped balances
To verify that the balances have been fixed, simply run the script again with the same arguments. When finished, the script should report:
Found 0 swapped balances
The script only examines transactions on the canonical chain through the block with the state hash provided. If the chain recorded in your database is longer, there may be additional swapped balances in the database. You can run the script again with a new state hash to repair those balances.