Skip to content

Commit

Permalink
feat: remove munging
Browse files Browse the repository at this point in the history
  • Loading branch information
QGarchery committed Sep 15, 2023
1 parent 9b3f24e commit 957758d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 20 deletions.
6 changes: 2 additions & 4 deletions certora/harness/MorphoHarness.sol
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,8 @@ contract MorphoHarness is Morpho {
return marketParams.id();
}

function optimizedId(MarketParams memory marketParams) external pure returns (Id marketParamsId) {
assembly ("memory-safe") {
marketParamsId := keccak256(marketParams, mul(5, 32))
}
function refId(MarketParams memory marketParams) external pure returns (Id marketParamsId) {
marketParamsId = Id.wrap(keccak256(abi.encode(marketParams)));
}

function libMulDivUp(uint256 x, uint256 y, uint256 d) public pure returns (uint256) {
Expand Down
14 changes: 0 additions & 14 deletions certora/munging.patch
Original file line number Diff line number Diff line change
@@ -1,14 +0,0 @@

diff -ruN libraries/MarketParamsLib.sol libraries/MarketParamsLib.sol
--- libraries/MarketParamsLib.sol 2023-08-29 09:59:37.937583556 +0200
+++ libraries/MarketParamsLib.sol 2023-08-29 10:16:10.519752188 +0200
@@ -10,8 +10,6 @@
library MarketParamsLib {
/// @notice Returns the id of the market `marketParams`.
function id(MarketParams memory marketParams) internal pure returns (Id marketParamsId) {
- assembly ("memory-safe") {
- marketParamsId := keccak256(marketParams, mul(5, 32))
- }
+ marketParamsId = Id.wrap(keccak256(abi.encode(marketParams)));
}
}
4 changes: 2 additions & 2 deletions certora/specs/LibSummary.spec
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ rule checkSummaryMulDivDown(uint256 x, uint256 y, uint256 d) {
assert result * d <= x * y;
}

// Check the munging of the MarketParams.id function.
// Check the optimization of the MarketParams.id function.
rule checkSummaryId(MorphoHarness.MarketParams marketParams) {
assert optimizedId(marketParams) == libId(marketParams);
assert libId(marketParams) == refId(marketParams);
}

0 comments on commit 957758d

Please sign in to comment.