Verify sum of pool balances against chain total supply.
Co-authored-by: Jack Grigg <jack@z.cash>
This commit is contained in:
parent
486817498f
commit
aa78fc0878
20
src/main.cpp
20
src/main.cpp
|
@ -3597,6 +3597,26 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
||||||
block.vtx[0].GetValueOut(), blockReward),
|
block.vtx[0].GetValueOut(), blockReward),
|
||||||
REJECT_INVALID, "bad-cb-amount");
|
REJECT_INVALID, "bad-cb-amount");
|
||||||
|
|
||||||
|
// Ensure that the total chain supply is consistent with the value in each pool.
|
||||||
|
if (!fJustCheck &&
|
||||||
|
pindex->nChainTotalSupply &&
|
||||||
|
pindex->nChainTransparentValue &&
|
||||||
|
pindex->nChainSproutValue &&
|
||||||
|
pindex->nChainSaplingValue &&
|
||||||
|
pindex->nChainOrchardValue)
|
||||||
|
{
|
||||||
|
auto expectedChainSupply =
|
||||||
|
pindex->nChainTransparentValue.value() +
|
||||||
|
pindex->nChainSproutValue.value() +
|
||||||
|
pindex->nChainSaplingValue.value() +
|
||||||
|
pindex->nChainOrchardValue.value();
|
||||||
|
if (expectedChainSupply != pindex->nChainTotalSupply.value()) {
|
||||||
|
// This may be added as a rule to ZIP 209 and return a failure in a future soft-fork.
|
||||||
|
error("ConnectBlock(): chain total supply (%d) does not match sum of pool balances (%d) at height %d",
|
||||||
|
pindex->nChainTotalSupply.value(), expectedChainSupply, pindex->nHeight);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Ensure Sapling authorizations are valid (if we are checking them)
|
// Ensure Sapling authorizations are valid (if we are checking them)
|
||||||
if (saplingAuth.has_value() && !saplingAuth.value()->validate()) {
|
if (saplingAuth.has_value() && !saplingAuth.value()->validate()) {
|
||||||
return state.DoS(100,
|
return state.DoS(100,
|
||||||
|
|
Loading…
Reference in New Issue