Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nissan with tadeas #9

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions .github/workflows/certora.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
with: { java-version: '11', java-package: jre }

- name: Install certora cli
run: pip install certora-cli==3.6.8.post3
run: pip install certora-cli

- name: Install solc
run: |
Expand All @@ -46,7 +46,7 @@ jobs:
make munged
cd ..
echo "key length" ${#CERTORAKEY}
sh certora/scripts/${{ matrix.rule }}
certoraRun certora/conf/${{ matrix.rule }} --wait_for_results
env:
CERTORAKEY: ${{ secrets.CERTORAKEY }}

Expand All @@ -55,9 +55,19 @@ jobs:
max-parallel: 16
matrix:
rule:
- verifyAToken.sh
- verifyPool.sh getReserveNormalizedVariableDebtCheck
- verifyReserveConfiguration.sh
- verifyStableTokenCLI.sh
- verifyUserConfigCLI.sh
- verifyVariableTokenCLI.sh
- AToken.conf
- Pool.conf
- ReserveConfiguration.conf
- StableTokenCLI.conf
- UserConfigCLI.conf
- VariableTokenCLI.conf
- NEW-pool-simple-properties.conf --rule cannotDepositInInactiveReserve --msg "cannotDepositInInactiveReserve"
- NEW-pool-simple-properties.conf --rule cannotDepositInFrozenReserve --msg "cannotDepositInFrozenReserve"
- NEW-pool-simple-properties.conf --rule cannotDepositZeroAmount --msg "cannotDepositZeroAmount"
- NEW-pool-simple-properties.conf --rule cannotWithdrawZeroAmount --msg "cannotWithdrawZeroAmount"
- NEW-pool-simple-properties.conf --rule cannotWithdrawFromInactiveReserve --msg "cannotWithdrawFromInactiveReserve"
- NEW-pool-simple-properties.conf --rule cannotBorrowZeroAmount --msg "cannotBorrowZeroAmount"
- NEW-pool-simple-properties.conf --rule cannotBorrowOnInactiveReserve --msg "cannotBorrowOnInactiveReserve"
- NEW-pool-simple-properties.conf --rule cannotBorrowOnReserveDisabledForBorrowing --msg "cannotBorrowOnReserveDisabledForBorrowing"
- NEW-pool-simple-properties.conf --rule cannotBorrowOnFrozenReserve --msg "cannotBorrowOnFrozenReserve"
- NEW-pool-no-summarizations.conf
42 changes: 26 additions & 16 deletions certora/applyHarness.patch
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
diff -ruN .gitignore .gitignore
--- .gitignore 1970-01-01 02:00:00
+++ .gitignore 2023-01-25 13:43:43
--- .gitignore 1970-01-01 02:00:00.000000000 +0200
+++ .gitignore 2024-03-26 12:06:06.824739877 +0200
@@ -0,0 +1,2 @@
+*
+!.gitignore
diff -ruN protocol/tokenization/AToken.sol protocol/tokenization/AToken.sol
--- protocol/tokenization/AToken.sol 2023-01-29 12:42:35
+++ protocol/tokenization/AToken.sol 2023-01-29 12:49:56
@@ -71,16 +71,16 @@
--- protocol/tokenization/AToken.sol 2024-03-25 19:09:57.942951737 +0200
+++ protocol/tokenization/AToken.sol 2024-03-26 16:40:05.810557503 +0200
@@ -37,6 +37,9 @@
function getRevision() internal pure virtual override returns (uint256) {
return ATOKEN_REVISION;
}
+ //function MOMO_KOKO() internal pure virtual returns (uint256) {
+ // return ATOKEN_REVISION;
+ //}

/**
* @dev Constructor.
@@ -70,16 +73,16 @@

_domainSeparator = _calculateDomainSeparator();

Expand All @@ -34,15 +44,15 @@ diff -ruN protocol/tokenization/AToken.sol protocol/tokenization/AToken.sol
}

/// @inheritdoc IAToken
diff -ruN protocol/tokenization/StableDebtToken.sol protocol/tokenization/StableDebtToken.sol
--- protocol/tokenization/StableDebtToken.sol 2023-01-11 13:38:21
+++ protocol/tokenization/StableDebtToken.sol 2023-01-29 12:50:20
@@ -336,7 +336,7 @@
* @param avgRate The average rate at which the total supply increases
* @return The debt balance of the user since the last burn/mint action
*/
- function _calcTotalSupply(uint256 avgRate) internal view returns (uint256) {
+ function _calcTotalSupply(uint256 avgRate) internal virtual view returns (uint256) {
uint256 principalSupply = super.totalSupply();
diff -ruN protocol/tokenization/base/ScaledBalanceTokenBase.sol protocol/tokenization/base/ScaledBalanceTokenBase.sol
--- protocol/tokenization/base/ScaledBalanceTokenBase.sol 2024-03-25 19:09:57.942951737 +0200
+++ protocol/tokenization/base/ScaledBalanceTokenBase.sol 2024-03-26 16:43:02.451462373 +0200
@@ -34,7 +34,7 @@
}

/// @inheritdoc IScaledBalanceToken
- function scaledBalanceOf(address user) external view override returns (uint256) {
+ function scaledBalanceOf(address user) public view override returns (uint256) {
return super.balanceOf(user);
}

if (principalSupply == 0) {
14 changes: 14 additions & 0 deletions certora/conf/AToken.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"files": [
"certora/harness/ATokenHarness.sol",
"certora/harness/SimpleERC20.sol"
],
"link": [
"ATokenHarness:_underlyingAsset=SimpleERC20"
],
"optimistic_loop": true,
"process": "emv",
"solc": "solc8.10",
"verify": "ATokenHarness:certora/specs/AToken.spec",
"msg": "aToken spec"
}
41 changes: 41 additions & 0 deletions certora/conf/NEW-pool-no-summarizations.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"files": [
"certora/harness/ATokenHarness.sol",
"certora/harness/PoolHarness.sol",
"certora/harness/StableDebtTokenHarness.sol",
"certora/harness/SimpleERC20.sol",
"certora/munged/protocol/tokenization/VariableDebtToken.sol",
"certora/munged/misc/AaveProtocolDataProvider.sol",
"certora/munged/protocol/pool/DefaultReserveInterestRateStrategy.sol",
"certora/munged/protocol/configuration/ACLManager.sol",
"certora/munged/protocol/libraries/aave-upgradeability/InitializableImmutableAdminUpgradeabilityProxy.sol",
"certora/munged/protocol/configuration/PriceOracleSentinel.sol",
"certora/munged/protocol/configuration/PoolAddressesProvider.sol",
],
"link": [
"ATokenHarness:POOL=PoolHarness",
"ATokenHarness:_underlyingAsset=SimpleERC20",
"PoolHarness:ADDRESSES_PROVIDER=PoolAddressesProvider",
"AaveProtocolDataProvider:ADDRESSES_PROVIDER=PoolAddressesProvider",
],
"struct_link": [
"PoolHarness:aTokenAddress=ATokenHarness",
"PoolHarness:stableDebtTokenAddress=StableDebtTokenHarness",
"PoolHarness:variableDebtTokenAddress=VariableDebtToken",
"PoolHarness:interestRateStrategyAddress=DefaultReserveInterestRateStrategy",
],
// "rule_sanity": "basic", // from time to time, use advanced instead of basic, it gives more insight on requires, vacuity rules etc.
"optimistic_loop": true,
"process": "emv",
"global_timeout": "7198",
"prover_args": ["-depth 11"], // If reachability passes and the time is ok, this number is ok, dont touch it.
"solc": "solc8.10",
"verify": "PoolHarness:certora/specs/NEW-pool-no-summarizations.spec",
"rule": ["liquidityIndexNonDecresingFor_cumulateToLiquidityIndex",
"depositUpdatesUserATokenSuperBalance",
"depositCannotChangeOthersATokenSuperBalance"
],
"parametric_contracts": ["PoolHarness"],
// method repayWithPermit address,uint256,uint256,address,uint256,uint8,bytes32,bytes32
"msg": "pool-no-summarizations::partial rules",
}
42 changes: 42 additions & 0 deletions certora/conf/NEW-pool-simple-properties.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"files": [
"certora/harness/ATokenHarness.sol",
"certora/harness/PoolHarness.sol",
"certora/harness/StableDebtTokenHarness.sol",
"certora/harness/SimpleERC20.sol",
"contracts/protocol/tokenization/VariableDebtToken.sol",
"contracts/misc/AaveProtocolDataProvider.sol",
"contracts/protocol/pool/DefaultReserveInterestRateStrategy.sol",
"contracts/protocol/libraries/types/DataTypes.sol",
"contracts/protocol/configuration/PoolAddressesProvider.sol",
],
"link": [
"ATokenHarness:POOL=PoolHarness",
"ATokenHarness:_underlyingAsset=SimpleERC20",
"PoolHarness:ADDRESSES_PROVIDER=PoolAddressesProvider",
],
"struct_link": [
"PoolHarness:aTokenAddress=ATokenHarness",
"PoolHarness:stableDebtTokenAddress=StableDebtTokenHarness",
"PoolHarness:variableDebtTokenAddress=VariableDebtToken",
"PoolHarness:interestRateStrategyAddress=DefaultReserveInterestRateStrategy",
],
"rule_sanity": "basic", // from time to time, use advanced instead of basic, it gives more insight on requires, vacuity rules etc.
"optimistic_loop": true,
"process": "emv",
"prover_args": ["-depth 12"], // If reachability passes and the time is ok, this number is ok, dont touch it.
"solc": "solc8.10",
"verify": "PoolHarness:certora/specs/NEW-pool-simple-properties.spec",
"rule": ["cannotDepositInInactiveReserve",
"cannotDepositInFrozenReserve",
"cannotDepositZeroAmount",
"cannotWithdrawZeroAmount",
"cannotWithdrawFromInactiveReserve",
"cannotBorrowZeroAmount",
"cannotBorrowOnInactiveReserve",
"cannotBorrowOnReserveDisabledForBorrowing",
"cannotBorrowOnFrozenReserve"
],
"parametric_contracts": ["PoolHarness"],
"msg": "pool-simple-properties::ALL",
}
22 changes: 22 additions & 0 deletions certora/conf/Pool.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"files": [
"certora/harness/ATokenHarness.sol",
"certora/harness/PoolHarness.sol",
"certora/harness/StableDebtTokenHarness.sol",
"certora/munged/protocol/tokenization/VariableDebtToken.sol"
],
"link": [
"ATokenHarness:POOL=PoolHarness"
],
"rule": [
"getReserveNormalizedVariableDebtCheck"
],
"optimistic_loop": true,
"process": "emv",
"prover_args": ["-depth 40","-mediumTimeout 700"],
"smt_timeout": "600",
"solc": "solc8.10",
"verify": "PoolHarness:certora/specs/pool.spec",
"msg": "Pool"
}

13 changes: 13 additions & 0 deletions certora/conf/ReserveConfiguration.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"files": [
"certora/harness/ReserveConfigurationHarness.sol"
],
"msg": "ReserveConfiguration",
"optimistic_loop": true,
"process": "emv",
"prover_args": [
"-useBitVectorTheory"
],
"solc": "solc8.10",
"verify": "ReserveConfigurationHarness:certora/specs/ReserveConfiguration.spec"
}
12 changes: 12 additions & 0 deletions certora/conf/StableTokenCLI.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"cache": "StableToken",
"files": [
"certora/harness/StableDebtTokenHarness.sol:StableDebtTokenHarness"
],
"loop_iter": "4",
"msg": "stableTokenCLI",
"optimistic_loop": true,
"process": "emv",
"solc": "solc8.10",
"verify": "StableDebtTokenHarness:certora/specs/StableDebtToken.spec"
}
13 changes: 13 additions & 0 deletions certora/conf/UserConfigCLI.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"files": [
"certora/harness/UserConfigurationHarness.sol"
],
"msg": "UserConfiguration All spec",
"optimistic_loop": true,
"process": "emv",
"prover_args": [
"-useBitVectorTheory"
],
"solc": "solc8.10",
"verify": "UserConfigurationHarness:certora/specs/UserConfiguration.spec"
}
10 changes: 10 additions & 0 deletions certora/conf/VariableTokenCLI.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"files": [
"certora/harness/VariableDebtTokenHarness.sol"
],
"msg": "variable debt token",
"optimistic_loop": true,
"process": "emv",
"solc": "solc8.10",
"verify": "VariableDebtTokenHarness:certora/specs/VariableDebtToken.spec"
}
11 changes: 10 additions & 1 deletion certora/harness/ATokenHarness.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pragma solidity 0.8.10;
import {Pool} from '../munged/protocol/pool/Pool.sol';
import {AToken} from '../munged/protocol/tokenization/AToken.sol';
import {WadRayMath} from '../munged/protocol/libraries/math/WadRayMath.sol';
import {ScaledBalanceTokenBase} from '../munged/protocol/tokenization/base/ScaledBalanceTokenBase.sol';

/**
* @title Certora harness for Aave ERC20 AToken
Expand All @@ -28,4 +29,12 @@ using WadRayMath for uint256;
function scaledBalanceOfToBalanceOf(uint256 bal) public view returns (uint256) {
return bal.rayMul(POOL.getReserveNormalizedIncome(_underlyingAsset));
}
}

function ATokenBalanceOf(address user) public view returns (uint256) {
return super.balanceOf(user);
}

function superBalance(address user) public view returns (uint256) {
return scaledBalanceOf(user);
}
}
59 changes: 59 additions & 0 deletions certora/harness/PoolHarness.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ import {DataTypes} from '../munged/protocol/libraries/types/DataTypes.sol';
import {ReserveLogic} from '../munged/protocol/libraries/logic/ReserveLogic.sol';
import {IPoolAddressesProvider} from '../munged/interfaces/IPoolAddressesProvider.sol';

import {IERC20} from '../../contracts/dependencies/openzeppelin/contracts/IERC20.sol';
import {ReserveConfiguration} from '../munged/protocol/libraries/configuration/ReserveConfiguration.sol';



contract PoolHarness is Pool {

using ReserveLogic for DataTypes.ReserveData;
Expand All @@ -18,4 +23,58 @@ contract PoolHarness is Pool {
DataTypes.ReserveCache memory reserveCache = reserve.cache();
return reserveCache.currScaledVariableDebt;
}

function getTotalDebt(address asset) public view returns (uint256) {
uint256 totalVariable = IERC20(_reserves[asset].variableDebtTokenAddress).totalSupply();
uint256 totalStable = IERC20(_reserves[asset].stableDebtTokenAddress).totalSupply();
return totalVariable + totalStable;
}

function getTotalATokenSupply(address asset) public view returns (uint256) {
return IERC20(_reserves[asset].aTokenAddress).totalSupply();
}

function getReserveLiquidityIndex(address asset) public view returns (uint256) {
return _reserves[asset].liquidityIndex;
}

function getReserveStableBorrowRate(address asset) public view returns (uint256) {
return _reserves[asset].currentStableBorrowRate;
}

function getReserveVariableBorrowIndex(address asset) public view returns (uint256) {
return _reserves[asset].variableBorrowIndex;
}

function getReserveVariableBorrowRate(address asset) public view returns (uint256) {
return _reserves[asset].currentVariableBorrowRate;
}

function updateReserveIndexes(address asset) public returns (bool) {
ReserveLogic._updateIndexes(_reserves[asset], _reserves[asset].cache());
return true;
}

function updateReserveIndexesWithCache(address asset, DataTypes.ReserveCache memory cache) public returns (bool) {
ReserveLogic._updateIndexes(_reserves[asset], cache);
return true;
}

function cumulateToLiquidityIndex(address asset, uint256 totalLiquidity, uint256 amount) public returns (uint256) {
return ReserveLogic.cumulateToLiquidityIndex(_reserves[asset], totalLiquidity, amount);
}

function getActive(DataTypes.ReserveConfigurationMap memory self) external pure returns (bool) {
return ReserveConfiguration.getActive(self);
}

function getFrozen(DataTypes.ReserveConfigurationMap memory self) external pure returns (bool) {
return ReserveConfiguration.getFrozen(self);
}

function getBorrowingEnabled(DataTypes.ReserveConfigurationMap memory self) external pure returns (bool) {
return ReserveConfiguration.getBorrowingEnabled(self);
}


}
Loading
Loading