Added rule sequentialBurnsEquivalentToSingleBurnOfSum (passing)

This commit is contained in:
Thomas Adams
2022-05-31 15:12:48 -07:00
parent 2a73da9f67
commit f74e316422

View File

@ -25,24 +25,54 @@ rule burnAmountProportionalToBalanceReduction {
env e;
address holder; uint256 token;
mathint startingBalance = balanceOf(holder, token); // 10
uint256 smallBurn; uint256 largeBurn; // 4, 7
mathint startingBalance = balanceOf(holder, token);
uint256 smallBurn; uint256 largeBurn;
require smallBurn < largeBurn;
// smaller burn amount
burn(e, holder, token, smallBurn) at beforeBurn;
mathint smallBurnBalanceChange = startingBalance - balanceOf(holder, token); // 4
mathint smallBurnBalanceChange = startingBalance - balanceOf(holder, token);
// larger burn amount
burn(e, holder, token, largeBurn) at beforeBurn;
mathint largeBurnBalanceChange = startingBalance - balanceOf(holder, token); // 7
mathint largeBurnBalanceChange = startingBalance - balanceOf(holder, token);
assert smallBurnBalanceChange < largeBurnBalanceChange,
"A larger burn must lead to a larger decrease in balance";
}
/// Unimplemented rule to verify monotonicity of burnBatch.
rule burnBatchAmountProportionalToBalanceReduction {
rule burnBatchAmountProportionalToBalanceReduction { // TODO implement rule or remove
assert true,
"just a placeholder that should never show up";
}
/// Two sequential burns must be equivalent to a single burn of the sum of their
/// amounts.
rule sequentialBurnsEquivalentToSingleBurnOfSum {
storage beforeBurns = lastStorage;
env e;
address holder; uint256 token;
mathint startingBalance = balanceOf(holder, token);
uint256 firstBurn; uint256 secondBurn; uint256 sumBurn;
require sumBurn == firstBurn + secondBurn;
// sequential burns
burn(e, holder, token, firstBurn) at beforeBurns;
burn(e, holder, token, secondBurn);
mathint sequentialBurnsBalanceChange = startingBalance - balanceOf(holder, token);
// burn of sum of sequential burns
burn(e, holder, token, sumBurn) at beforeBurns;
mathint sumBurnBalanceChange = startingBalance - balanceOf(holder, token);
assert sequentialBurnsBalanceChange == sumBurnBalanceChange,
"Sequential burns must be equivalent to a burn of their sum";
}
/// Unimplemented rule to verify additivty of burnBatch.
rule sequentialBatchBurnsEquivalentToSingleBurnBatchOfSum { // TODO implement rule or remove
assert true,
"just a placeholder that should never show up";
}