Skip to content

Commit

Permalink
chore: fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
brotherlymite committed Dec 14, 2024
1 parent 9969804 commit 2f3b857
Show file tree
Hide file tree
Showing 9 changed files with 111 additions and 25 deletions.
3 changes: 2 additions & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,5 @@ scroll = { key = "${ETHERSCAN_API_KEY_SCROLL}", chainId = 534352 }
zksync = { key = "${ETHERSCAN_API_KEY_ZKSYNC}", chain = 324 }

[fmt]
tab_width = 2
tab_width = 2
quote_style = 'single'
14 changes: 7 additions & 7 deletions script/Deploy.s.sol
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {MiscEthereum} from "aave-address-book/MiscEthereum.sol";
import {AaveV3Ethereum} from "aave-address-book/AaveV3Ethereum.sol";
import {MiscEthereum} from 'aave-address-book/MiscEthereum.sol';
import {AaveV3Ethereum} from 'aave-address-book/AaveV3Ethereum.sol';

import {MiscPolygon} from "aave-address-book/MiscPolygon.sol";
import {AaveV3Polygon} from "aave-address-book/AaveV3Polygon.sol";
import {MiscPolygon} from 'aave-address-book/MiscPolygon.sol';
import {AaveV3Polygon} from 'aave-address-book/AaveV3Polygon.sol';

import {GovV3Helpers} from "aave-helpers/src/GovV3Helpers.sol";
import {CollectorWithCustomImpl} from "../src/CollectorWithCustomImpl.sol";
import {UpgradePayload} from "../src/UpgradePayload.sol";
import {GovV3Helpers} from 'aave-helpers/src/GovV3Helpers.sol';
import {CollectorWithCustomImpl} from '../src/CollectorWithCustomImpl.sol';
import {UpgradePayload} from '../src/UpgradePayload.sol';

library DeploymentLibrary {
function _deploy(address aclManager, address collector, address proxyAdmin) private returns (address) {
Expand Down
2 changes: 1 addition & 1 deletion src/CollectorWithCustomImpl.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {Collector, ICollector} from "aave-v3-origin/contracts/treasury/Collector.sol";
import {Collector, ICollector} from 'aave-v3-origin/contracts/treasury/Collector.sol';

/**
* @title Collector
Expand Down
2 changes: 1 addition & 1 deletion src/CollectorWithCustomImplZkSync.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {Collector, ICollector} from "aave-v3-origin/contracts/treasury/Collector.sol";
import {Collector, ICollector} from 'aave-v3-origin/contracts/treasury/Collector.sol';

/**
* @title Collector
Expand Down
6 changes: 3 additions & 3 deletions src/UpgradePayload.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ pragma solidity ^0.8.0;
import {
ITransparentUpgradeableProxy,
ProxyAdmin
} from "solidity-utils/contracts/transparent-proxy/TransparentUpgradeableProxy.sol";
import {IAccessControl} from "aave-v3-origin/contracts/dependencies/openzeppelin/contracts/IAccessControl.sol";
import {ICollector} from "aave-v3-origin/contracts/treasury/ICollector.sol";
} from 'solidity-utils/contracts/transparent-proxy/TransparentUpgradeableProxy.sol';
import {IAccessControl} from 'aave-v3-origin/contracts/dependencies/openzeppelin/contracts/IAccessControl.sol';
import {ICollector} from 'aave-v3-origin/contracts/treasury/ICollector.sol';

contract UpgradePayload {
address public immutable PROXY_ADMIN;
Expand Down
8 changes: 4 additions & 4 deletions test/Mainnet.t.sol
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {AaveV3Ethereum, IPool} from "aave-address-book/AaveV3Ethereum.sol";
import {UpgradeTest} from "./UpgradeTest.sol";
import {DeploymentLibrary} from "../script/Deploy.s.sol";
import {AaveV3Ethereum, IPool} from 'aave-address-book/AaveV3Ethereum.sol';
import {UpgradeTest} from './UpgradeTest.sol';
import {DeploymentLibrary} from '../script/Deploy.s.sol';

contract MainnetTest is UpgradeTest {
constructor() UpgradeTest("mainnet", 21336615) {}
constructor() UpgradeTest('mainnet', 21336615) {}

function _getPayload() internal virtual override returns (address) {
return DeploymentLibrary.deployMainnet();
Expand Down
8 changes: 4 additions & 4 deletions test/Polygon.t.sol
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {AaveV3Polygon, IPool} from "aave-address-book/AaveV3Polygon.sol";
import {UpgradeTest} from "./UpgradeTest.sol";
import {DeploymentLibrary} from "../script/Deploy.s.sol";
import {AaveV3Polygon, IPool} from 'aave-address-book/AaveV3Polygon.sol';
import {UpgradeTest} from './UpgradeTest.sol';
import {DeploymentLibrary} from '../script/Deploy.s.sol';

contract PolygonTest is UpgradeTest {
constructor() UpgradeTest("polygon", 65118236) {}
constructor() UpgradeTest('polygon', 65118236) {}

function _getPayload() internal virtual override returns (address) {
return DeploymentLibrary.deployPolygon();
Expand Down
8 changes: 4 additions & 4 deletions test/UpgradeTest.sol
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {ProtocolV3TestBase, IPool, IPoolAddressesProvider} from "aave-helpers/src/ProtocolV3TestBase.sol";
import {Collector, ICollector, IERC20} from "aave-v3-origin/contracts/treasury/Collector.sol";
import {IAccessControl} from "aave-v3-origin/contracts/dependencies/openzeppelin/contracts/IAccessControl.sol";
import {UpgradePayload} from "../src/UpgradePayload.sol";
import {ProtocolV3TestBase, IPool, IPoolAddressesProvider} from 'aave-helpers/src/ProtocolV3TestBase.sol';
import {Collector, ICollector, IERC20} from 'aave-v3-origin/contracts/treasury/Collector.sol';
import {IAccessControl} from 'aave-v3-origin/contracts/dependencies/openzeppelin/contracts/IAccessControl.sol';
import {UpgradePayload} from '../src/UpgradePayload.sol';

/**
* @dev Test for AaveV3EthereumLido_GHOListingOnLidoPool_20241119
Expand Down
85 changes: 85 additions & 0 deletions zksync/test/ZkSync.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {ProtocolV3TestBase, IPool, IPoolAddressesProvider} from 'aave-helpers/src/ProtocolV3TestBase.sol';
import {Collector, ICollector, IERC20} from "aave-v3-origin/contracts/treasury/Collector.sol";
import {IAccessControl} from "aave-v3-origin/contracts/dependencies/openzeppelin/contracts/IAccessControl.sol";
import {UpgradePayload} from "../src/UpgradePayload.sol";

/**
* @dev Test for AaveV3EthereumLido_GHOListingOnLidoPool_20241119
* command: FOUNDRY_PROFILE=mainnet forge test --match-path=src/20241119_AaveV3EthereumLido_GHOListingOnLidoPool/AaveV3EthereumLido_GHOListingOnLidoPool_20241119.t.sol -vv
*/
abstract contract UpgradeTest is ProtocolV3TestBase {
string public NETWORK;
uint256 public immutable BLOCK_NUMBER;

address payload;

constructor(string memory network, uint256 blocknumber) {
NETWORK = network;
BLOCK_NUMBER = blocknumber;
}

function setUp() public {
vm.createSelectFork(vm.rpcUrl(NETWORK), BLOCK_NUMBER);
payload = _getPayload();
}

function test_defaultExecution() external {
defaultTest(NETWORK, _getPool(), payload);
}

// ensures stream id is in same position as before
function test_storageCorrectness() external {
Collector collector = Collector(UpgradePayload(payload).COLLECTOR());
uint256 nextStreamIdBefore = collector.getNextStreamId();

executePayload(vm, payload);

assertEq(nextStreamIdBefore, collector.getNextStreamId());
// revision should be 6
assertEq(uint256(vm.load(address(collector), bytes32(uint256(0)))), 6);
// initializing should be false
assertEq(vm.load(address(collector), bytes32(uint256(1))), 0x0);
// last slot of gap should be empty
assertEq(vm.load(address(collector), bytes32(uint256(51))), 0x0);
// reentrancy _status should be 1
assertEq(uint256(vm.load(address(collector), bytes32(uint256(52)))), 1);
}

function test_transfer_aclAdmin() external {
executePayload(vm, payload);

IPoolAddressesProvider provider = _getPool().ADDRESSES_PROVIDER();
address aclAdmin = provider.getACLAdmin();
Collector collector = Collector(UpgradePayload(payload).COLLECTOR());

vm.startPrank(aclAdmin);
deal(address(collector), 100 ether);
collector.transfer(IERC20(collector.ETH_MOCK_ADDRESS()), address(this), 100 ether);
}

// ensures reentracy is not borked
function test_transfer_newAdmin() external {
executePayload(vm, payload);

IPoolAddressesProvider provider = _getPool().ADDRESSES_PROVIDER();
address aclAdmin = provider.getACLAdmin();
address aclManager = provider.getACLManager();
Collector collector = Collector(UpgradePayload(payload).COLLECTOR());

vm.startPrank(aclAdmin);
IAccessControl(aclManager).grantRole(collector.FUNDS_ADMIN_ROLE(), address(this));
vm.stopPrank();

deal(address(collector), 100 ether);
collector.transfer(IERC20(collector.ETH_MOCK_ADDRESS()), address(this), 100 ether);
}

function _getPayload() internal virtual returns (address);

function _getPool() internal virtual returns (IPool);

receive() external payable {}
}

0 comments on commit 2f3b857

Please sign in to comment.