Skip to content

Commit

Permalink
refactor: safe require in MintBurn
Browse files Browse the repository at this point in the history
  • Loading branch information
QGarchery committed Jan 14, 2025
1 parent 6ab5bad commit 2279357
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
7 changes: 6 additions & 1 deletion certora/specs/MintBurnEthereum.spec
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,17 @@ rule burn(env e) {
uint256 otherBalanceBefore = balanceOf(other);
uint256 totalSupplyBefore = totalSupply();

// Safe require as zeroVirtualVotingPower represents the virtual sum of votes delegated to zero.
require delegatee(from) == 0 => fromBalanceBefore <= currentContract._zeroVirtualVotingPower;
// Safe require as it is verified in delegatedLTEqDelegateeVP.
require delegatee(from) != 0 => fromBalanceBefore <= fromVotingPowerBefore;

// run transaction
burn@withrevert(e, amount);

// check outcome
if (lastReverted) {
assert e.msg.sender == 0x0 || fromBalanceBefore < amount || fromVotingPowerBefore < amount ;
assert e.msg.sender == 0x0 || fromBalanceBefore < amount;
} else {
// updates balance and totalSupply
assert to_mathint(balanceOf(from)) == fromBalanceBefore - amount;
Expand Down
8 changes: 6 additions & 2 deletions certora/specs/MintBurnOptimism.spec
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,17 @@ rule burn(env e) {
uint256 otherBalanceBefore = balanceOf(other);
uint256 totalSupplyBefore = totalSupply();

// Safe require as zeroVirtualVotingPower represents the virtual sum of votes delegated to zero.
require delegatee(from) == 0 => fromBalanceBefore <= currentContract._zeroVirtualVotingPower;
// Safe require as it is verified in delegatedLTEqDelegateeVP.
require delegatee(from) != 0 => fromBalanceBefore <= fromVotingPowerBefore;

// run transaction
burn@withrevert(e, from, amount);

// check outcome
if (lastReverted) {
assert e.msg.sender == 0x0 || fromBalanceBefore < amount || fromVotingPowerBefore < amount
|| e.msg.sender != currentContract.bridge;
assert e.msg.sender == 0x0 || fromBalanceBefore < amount || e.msg.sender != currentContract.bridge;
} else {
// updates balance and totalSupply
assert to_mathint(balanceOf(from)) == fromBalanceBefore - amount;
Expand Down

0 comments on commit 2279357

Please sign in to comment.