Skip to content

Commit

Permalink
Merge pull request #16 from bgd-labs/feat/base-delegation-isolation
Browse files Browse the repository at this point in the history
Draft: BaseDelegation
  • Loading branch information
kyzia551 authored Jun 28, 2023
2 parents db18cec + e8d31fa commit e715907
Show file tree
Hide file tree
Showing 482 changed files with 891 additions and 78,776 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
ETH_RPC_URL=https://eth-mainnet.alchemyapi.io/v2/ALCHEMY_API_KEY
RPC_MAINNET=https://eth-mainnet.alchemyapi.io/v2/ALCHEMY_API_KEY
FORK_BLOCK=someBlockNumber
7 changes: 4 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
[submodule "lib/openzeppelin-contracts"]
path = lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
#TODO: should be removed
[submodule "lib/aave-token-v2"]
path = lib/aave-token-v2
url = https://github.com/aave/aave-token-v2
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "lib/openzeppelin-contracts"]
path = lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
16 changes: 13 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,17 @@ build :; forge build --sizes
.PHONY : test

# IMPORTANT It is highly probable that will be necessary to modify the --fork-block-number, depending on the test
test :; forge test -vvv --rpc-url=${ETH_RPC_URL} --fork-block-number ${FORK_BLOCK}
trace :; forge test -vvvv --rpc-url=${ETH_RPC_URL}
test :; forge test -vvv --rpc-url=${RPC_MAINNET} --fork-block-number ${FORK_BLOCK}
trace :; forge test -vvvv --rpc-url=${RPC_MAINNET}
clean :; forge clean
snapshot :; forge snapshot
snapshot :; forge snapshot

git-diff :
@mkdir -p diffs
@printf '%s\n%s\n%s\n' "\`\`\`diff" "$$(git diff --no-index --diff-algorithm=patience --ignore-space-at-eol ${before} ${after})" "\`\`\`" > diffs/${out}.md


storage-diff :
forge inspect lib/aave-token-v2/contracts/token/AaveTokenV2.sol:AaveTokenV2 storage-layout --pretty > reports/AaveTokenV2_layout.md
forge inspect src/AaveTokenV3.sol:AaveTokenV3 storage-layout --pretty > reports/AaveTokenV3_layout.md
make git-diff before=reports/AaveTokenV2_layout.md after=reports/AaveTokenV3_layout.md out=AaveToken_v2_v3_layout_diff
6 changes: 3 additions & 3 deletions certora/harness/AaveTokenV3Harness.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,16 @@ contract AaveTokenV3Harness is AaveTokenV3 {

// returns user's voting delegate
function getVotingDelegate(address user) public view returns (address) {
return _votingDelegateeV2[user];
return _votingDelegatee[user];
}

// returns user's proposition delegate
function getPropositionDelegate(address user) public view returns (address) {
return _propositionDelegateeV2[user];
return _propositionDelegatee[user];
}

// returns user's delegation state
function getDelegationState(address user) public view returns (DelegationState) {
function getDelegationState(address user) public view returns (DelegationMode) {
return _balances[user].delegationState;
}
}
6 changes: 3 additions & 3 deletions certora/harness/AaveTokenV3HarnessCommunity.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ contract AaveTokenV3Harness is AaveTokenV3 {
}

function getVotingDelegate(address user) public view returns (address) {
return _votingDelegateeV2[user];
return _votingDelegatee[user];
}

function getPropositionDelegate(address user) public view returns (address) {
return _propositionDelegateeV2[user];
return _propositionDelegatee[user];
}

function getDelegationState(address user) public view returns (DelegationState) {
function getDelegationState(address user) public view returns (DelegationMode) {
return _balances[user].delegationState;
}

Expand Down
4 changes: 2 additions & 2 deletions certora/harness/AaveTokenV3HarnessStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ contract AaveTokenV3Harness is AaveTokenV3 {
}

function getVotingDelegate(address user) public view returns (address) {
return _votingDelegateeV2[user];
return _votingDelegatee[user];
}

function getPropositionDelegate(address user) public view returns (address) {
return _propositionDelegateeV2[user];
return _propositionDelegatee[user];
}

function getDelegationState(address user) public view returns (uint8) {
Expand Down
42 changes: 42 additions & 0 deletions diffs/AaveToken_v2_v3_layout_diff.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
```diff
diff --git a/reports/AaveTokenV2_layout.md b/reports/AaveTokenV3_layout.md
index 0936f3f..964f7da 100644
--- a/reports/AaveTokenV2_layout.md
+++ b/reports/AaveTokenV3_layout.md
@@ -1,19 +1,16 @@
-| Name | Type | Slot | Offset | Bytes | Contract |
-|----------------------------------|----------------------------------------------------------------------------------------|------|--------|-------|---------------------------------------------------------------|
-| _balances | mapping(address => uint256) | 0 | 0 | 32 | lib/aave-token-v2/contracts/token/AaveTokenV2.sol:AaveTokenV2 |
-| _allowances | mapping(address => mapping(address => uint256)) | 1 | 0 | 32 | lib/aave-token-v2/contracts/token/AaveTokenV2.sol:AaveTokenV2 |
-| _totalSupply | uint256 | 2 | 0 | 32 | lib/aave-token-v2/contracts/token/AaveTokenV2.sol:AaveTokenV2 |
-| _name | string | 3 | 0 | 32 | lib/aave-token-v2/contracts/token/AaveTokenV2.sol:AaveTokenV2 |
-| _symbol | string | 4 | 0 | 32 | lib/aave-token-v2/contracts/token/AaveTokenV2.sol:AaveTokenV2 |
-| _decimals | uint8 | 5 | 0 | 1 | lib/aave-token-v2/contracts/token/AaveTokenV2.sol:AaveTokenV2 |
-| lastInitializedRevision | uint256 | 6 | 0 | 32 | lib/aave-token-v2/contracts/token/AaveTokenV2.sol:AaveTokenV2 |
-| ______gap | uint256[50] | 7 | 0 | 1600 | lib/aave-token-v2/contracts/token/AaveTokenV2.sol:AaveTokenV2 |
-| _nonces | mapping(address => uint256) | 57 | 0 | 32 | lib/aave-token-v2/contracts/token/AaveTokenV2.sol:AaveTokenV2 |
-| _votingSnapshots | mapping(address => mapping(uint256 => struct GovernancePowerDelegationERC20.Snapshot)) | 58 | 0 | 32 | lib/aave-token-v2/contracts/token/AaveTokenV2.sol:AaveTokenV2 |
-| _votingSnapshotsCounts | mapping(address => uint256) | 59 | 0 | 32 | lib/aave-token-v2/contracts/token/AaveTokenV2.sol:AaveTokenV2 |
-| _aaveGovernance | contract ITransferHook | 60 | 0 | 20 | lib/aave-token-v2/contracts/token/AaveTokenV2.sol:AaveTokenV2 |
-| DOMAIN_SEPARATOR | bytes32 | 61 | 0 | 32 | lib/aave-token-v2/contracts/token/AaveTokenV2.sol:AaveTokenV2 |
-| _votingDelegates | mapping(address => address) | 62 | 0 | 32 | lib/aave-token-v2/contracts/token/AaveTokenV2.sol:AaveTokenV2 |
-| _propositionPowerSnapshots | mapping(address => mapping(uint256 => struct GovernancePowerDelegationERC20.Snapshot)) | 63 | 0 | 32 | lib/aave-token-v2/contracts/token/AaveTokenV2.sol:AaveTokenV2 |
-| _propositionPowerSnapshotsCounts | mapping(address => uint256) | 64 | 0 | 32 | lib/aave-token-v2/contracts/token/AaveTokenV2.sol:AaveTokenV2 |
-| _propositionPowerDelegates | mapping(address => address) | 65 | 0 | 32 | lib/aave-token-v2/contracts/token/AaveTokenV2.sol:AaveTokenV2 |
+| Name | Type | Slot | Offset | Bytes | Contract |
+|-------------------------------------|-----------------------------------------------------------------|------|--------|-------|---------------------------------|
+| _balances | mapping(address => struct BaseAaveToken.DelegationAwareBalance) | 0 | 0 | 32 | src/AaveTokenV3.sol:AaveTokenV3 |
+| _allowances | mapping(address => mapping(address => uint256)) | 1 | 0 | 32 | src/AaveTokenV3.sol:AaveTokenV3 |
+| _totalSupply | uint256 | 2 | 0 | 32 | src/AaveTokenV3.sol:AaveTokenV3 |
+| _name | string | 3 | 0 | 32 | src/AaveTokenV3.sol:AaveTokenV3 |
+| _symbol | string | 4 | 0 | 32 | src/AaveTokenV3.sol:AaveTokenV3 |
+| ______DEPRECATED_OLD_ERC20_DECIMALS | uint8 | 5 | 0 | 1 | src/AaveTokenV3.sol:AaveTokenV3 |
+| lastInitializedRevision | uint256 | 6 | 0 | 32 | src/AaveTokenV3.sol:AaveTokenV3 |
+| ______gap | uint256[50] | 7 | 0 | 1600 | src/AaveTokenV3.sol:AaveTokenV3 |
+| _nonces | mapping(address => uint256) | 57 | 0 | 32 | src/AaveTokenV3.sol:AaveTokenV3 |
+| ______DEPRECATED_FROM_AAVE_V1 | uint256[3] | 58 | 0 | 96 | src/AaveTokenV3.sol:AaveTokenV3 |
+| __DEPRECATED_DOMAIN_SEPARATOR | bytes32 | 61 | 0 | 32 | src/AaveTokenV3.sol:AaveTokenV3 |
+| ______DEPRECATED_FROM_AAVE_V2 | uint256[4] | 62 | 0 | 128 | src/AaveTokenV3.sol:AaveTokenV3 |
+| _votingDelegatee | mapping(address => address) | 66 | 0 | 32 | src/AaveTokenV3.sol:AaveTokenV3 |
+| _propositionDelegatee | mapping(address => address) | 67 | 0 | 32 | src/AaveTokenV3.sol:AaveTokenV3 |
```
14 changes: 11 additions & 3 deletions foundry.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
[default]
[profile.default]
src = 'src'
out = 'out'
libs = ['lib']
remappings = [
'openzeppelin-contracts/=lib/openzeppelin-contracts/contracts'
'openzeppelin-contracts/=lib/openzeppelin-contracts/'
]

# See more config options https://github.com/gakonst/foundry/tree/master/config
fs_permissions = [{access = "write", path = "./reports"}]

[rpc_endpoints]
mainnet = "${RPC_MAINNET}"

[etherscan]
mainnet={key="${ETHERSCAN_API_KEY_MAINNET}",chainId=1}

# See more config options https://github.com/gakonst/foundry/tree/master/config
2 changes: 1 addition & 1 deletion lib/forge-std
Submodule forge-std updated 47 files
+92 −0 .github/workflows/ci.yml
+29 −0 .github/workflows/sync.yml
+0 −26 .github/workflows/tests.yml
+2 −0 .gitignore
+1 −1 LICENSE-APACHE
+1 −1 LICENSE-MIT
+9 −5 README.md
+21 −0 foundry.toml
+1 −1 lib/ds-test
+16 −0 package.json
+33 −0 src/Base.sol
+26 −0 src/Script.sol
+376 −0 src/StdAssertions.sol
+231 −0 src/StdChains.sol
+639 −0 src/StdCheats.sol
+15 −0 src/StdError.sol
+92 −0 src/StdInvariant.sol
+179 −0 src/StdJson.sol
+43 −0 src/StdMath.sol
+327 −0 src/StdStorage.sol
+333 −0 src/StdStyle.sol
+192 −0 src/StdUtils.sol
+31 −681 src/Test.sol
+469 −55 src/Vm.sol
+14 −6 src/console2.sol
+105 −0 src/interfaces/IERC1155.sol
+12 −0 src/interfaces/IERC165.sol
+43 −0 src/interfaces/IERC20.sol
+190 −0 src/interfaces/IERC4626.sol
+164 −0 src/interfaces/IERC721.sol
+73 −0 src/interfaces/IMulticall3.sol
+0 −379 src/test/StdAssertions.t.sol
+0 −193 src/test/StdCheats.t.sol
+0 −200 src/test/StdMath.t.sol
+999 −0 test/StdAssertions.t.sol
+160 −0 test/StdChains.t.sol
+418 −0 test/StdCheats.t.sol
+6 −12 test/StdError.t.sol
+197 −0 test/StdMath.t.sol
+63 −86 test/StdStorage.t.sol
+110 −0 test/StdStyle.t.sol
+297 −0 test/StdUtils.t.sol
+10 −0 test/compilation/CompilationScript.sol
+10 −0 test/compilation/CompilationScriptBase.sol
+10 −0 test/compilation/CompilationTest.sol
+10 −0 test/compilation/CompilationTestBase.sol
+187 −0 test/fixtures/broadcast.log.json
1 change: 1 addition & 0 deletions lib/openzeppelin-contracts
Submodule openzeppelin-contracts added at e50c24
11 changes: 0 additions & 11 deletions lib/openzeppelin-contracts/.codecov.yml

This file was deleted.

21 changes: 0 additions & 21 deletions lib/openzeppelin-contracts/.editorconfig

This file was deleted.

64 changes: 0 additions & 64 deletions lib/openzeppelin-contracts/.eslintrc

This file was deleted.

1 change: 0 additions & 1 deletion lib/openzeppelin-contracts/.gitattributes

This file was deleted.

21 changes: 0 additions & 21 deletions lib/openzeppelin-contracts/.github/ISSUE_TEMPLATE/bug_report.md

This file was deleted.

4 changes: 0 additions & 4 deletions lib/openzeppelin-contracts/.github/ISSUE_TEMPLATE/config.yml

This file was deleted.

This file was deleted.

20 changes: 0 additions & 20 deletions lib/openzeppelin-contracts/.github/PULL_REQUEST_TEMPLATE.md

This file was deleted.

25 changes: 0 additions & 25 deletions lib/openzeppelin-contracts/.github/workflows/docs.yml

This file was deleted.

Loading

0 comments on commit e715907

Please sign in to comment.