From fe818aa58585d3525c827f04751b527310e2439a Mon Sep 17 00:00:00 2001 From: Nikita <32309387+TepNik@users.noreply.github.com> Date: Fri, 10 Jan 2025 20:21:34 +0800 Subject: [PATCH 1/4] test: removed testFail Foundry tests and minor fixes in tests (#365) * Minor fixes in tests + prettier * Fixed GovV3Test. Removed testFail foundry tests + fixed expectRevert for calls into the internal library * Fixed warnings * fix: update forge std --------- Co-authored-by: Lukas --- diffs/default_before_default_after.md | 2 - lib/forge-std | 2 +- src/asset-manager/AaveWstethWithdrawer.sol | 4 +- .../arbitrum/AaveArbEthERC20Bridge.sol | 4 +- src/bridges/optimism/AaveOpEthERC20Bridge.sol | 4 +- src/bridges/polygon/AavePolEthERC20Bridge.sol | 4 +- .../polygon/AavePolEthPlasmaBridge.sol | 4 +- src/swaps/AaveSwapper.sol | 2 +- tests/GovV3Test.t.sol | 31 ++++++-- .../AaveWstethWithdrawerTest.t.sol | 78 +++++-------------- .../arbitrum/AaveArbEthERC20BridgeTest.t.sol | 6 +- .../optimism/AaveOpEthERC20BridgeTest.t.sol | 3 +- .../polygon/AavePolEthERC20BridgeTest.t.sol | 8 +- .../polygon/AavePolEthPlasmaBridge.t.sol | 9 +-- tests/swaps/AaveSwapperTest.t.sol | 3 +- 15 files changed, 70 insertions(+), 94 deletions(-) diff --git a/diffs/default_before_default_after.md b/diffs/default_before_default_after.md index dbd03dce4..c15d3e2bc 100644 --- a/diffs/default_before_default_after.md +++ b/diffs/default_before_default_after.md @@ -1,5 +1,3 @@ -## Emodes changes - ## Raw diff ```json diff --git a/lib/forge-std b/lib/forge-std index d3db4ef90..726a6ee5f 160000 --- a/lib/forge-std +++ b/lib/forge-std @@ -1 +1 @@ -Subproject commit d3db4ef90a72b7d24aa5a2e5c649593eaef7801d +Subproject commit 726a6ee5fc8427a0013d6f624e486c9130c0e336 diff --git a/src/asset-manager/AaveWstethWithdrawer.sol b/src/asset-manager/AaveWstethWithdrawer.sol index 86ae9f610..50cfdfd57 100644 --- a/src/asset-manager/AaveWstethWithdrawer.sol +++ b/src/asset-manager/AaveWstethWithdrawer.sol @@ -103,8 +103,8 @@ contract AaveWstethWithdrawer is /// @inheritdoc IRescuableBase function maxRescue( - address erc20Token - ) public view override(RescuableBase, IRescuableBase) returns (uint256) { + address + ) public pure override(RescuableBase, IRescuableBase) returns (uint256) { return type(uint256).max; } diff --git a/src/bridges/arbitrum/AaveArbEthERC20Bridge.sol b/src/bridges/arbitrum/AaveArbEthERC20Bridge.sol index 3e73c4cb8..f93cfdab8 100644 --- a/src/bridges/arbitrum/AaveArbEthERC20Bridge.sol +++ b/src/bridges/arbitrum/AaveArbEthERC20Bridge.sol @@ -117,8 +117,8 @@ contract AaveArbEthERC20Bridge is Ownable, Rescuable, IAaveArbEthERC20Bridge { /// @inheritdoc IRescuableBase function maxRescue( - address erc20Token - ) public view override(RescuableBase, IRescuableBase) returns (uint256) { + address + ) public pure override(RescuableBase, IRescuableBase) returns (uint256) { return type(uint256).max; } } diff --git a/src/bridges/optimism/AaveOpEthERC20Bridge.sol b/src/bridges/optimism/AaveOpEthERC20Bridge.sol index 1a3c8940f..04fafe174 100644 --- a/src/bridges/optimism/AaveOpEthERC20Bridge.sol +++ b/src/bridges/optimism/AaveOpEthERC20Bridge.sol @@ -58,8 +58,8 @@ contract AaveOpEthERC20Bridge is Ownable, Rescuable, IAaveOpEthERC20Bridge { /// @inheritdoc IRescuableBase function maxRescue( - address erc20Token - ) public view override(RescuableBase, IRescuableBase) returns (uint256) { + address + ) public pure override(RescuableBase, IRescuableBase) returns (uint256) { return type(uint256).max; } } diff --git a/src/bridges/polygon/AavePolEthERC20Bridge.sol b/src/bridges/polygon/AavePolEthERC20Bridge.sol index 9e18d3237..bf9a465f5 100644 --- a/src/bridges/polygon/AavePolEthERC20Bridge.sol +++ b/src/bridges/polygon/AavePolEthERC20Bridge.sol @@ -100,8 +100,8 @@ contract AavePolEthERC20Bridge is Ownable, Rescuable, IAavePolEthERC20Bridge { /// @inheritdoc IRescuableBase function maxRescue( - address erc20Token - ) public view override(RescuableBase, IRescuableBase) returns (uint256) { + address + ) public pure override(RescuableBase, IRescuableBase) returns (uint256) { return type(uint256).max; } diff --git a/src/bridges/polygon/AavePolEthPlasmaBridge.sol b/src/bridges/polygon/AavePolEthPlasmaBridge.sol index 465f02b16..c09d42e5b 100644 --- a/src/bridges/polygon/AavePolEthPlasmaBridge.sol +++ b/src/bridges/polygon/AavePolEthPlasmaBridge.sol @@ -105,8 +105,8 @@ contract AavePolEthPlasmaBridge is Ownable, Rescuable, IAavePolEthPlasmaBridge { /// @inheritdoc IRescuableBase function maxRescue( - address erc20Token - ) public view override(RescuableBase, IRescuableBase) returns (uint256) { + address + ) public pure override(RescuableBase, IRescuableBase) returns (uint256) { return type(uint256).max; } diff --git a/src/swaps/AaveSwapper.sol b/src/swaps/AaveSwapper.sol index 432523e91..eae26aca7 100644 --- a/src/swaps/AaveSwapper.sol +++ b/src/swaps/AaveSwapper.sol @@ -135,7 +135,7 @@ contract AaveSwapper is IAaveSwapper, Initializable, OwnableWithGuardian, Rescua /// @inheritdoc IRescuableBase function maxRescue( - address erc20Token + address ) public pure override(RescuableBase, IRescuableBase) returns (uint256) { return type(uint256).max; } diff --git a/tests/GovV3Test.t.sol b/tests/GovV3Test.t.sol index 07fe4dbd6..b520076cd 100644 --- a/tests/GovV3Test.t.sol +++ b/tests/GovV3Test.t.sol @@ -2,6 +2,7 @@ pragma solidity ^0.8.0; import 'forge-std/Test.sol'; +import {Vm} from 'forge-std/Vm.sol'; import {IVotingMachineWithProofs, GovV3Helpers, PayloadsControllerUtils, IPayloadsControllerCore, GovV3StorageHelpers, IGovernanceCore} from '../src/GovV3Helpers.sol'; import {ProtocolV3TestBase} from '../src/ProtocolV3TestBase.sol'; import {MiscEthereum} from 'aave-address-book/MiscEthereum.sol'; @@ -17,7 +18,6 @@ interface Mock { contract GovernanceV3Test is ProtocolV3TestBase { event TestEvent(); - error CannotFindPayload(); PayloadWithEmit payload; @@ -92,7 +92,7 @@ contract GovernanceV3Test is ProtocolV3TestBase { GovV3StorageHelpers.readyPayloadId(vm, payloadsController, payloadId); IPayloadsControllerCore.Payload memory pl = payloadsController.getPayloadById(payloadId); assertEq(uint256(pl.state), uint256(IPayloadsControllerCore.PayloadState.Queued)); - assertEq(pl.queuedAt, block.timestamp - pl.delay -1); + assertEq(pl.queuedAt, block.timestamp - pl.delay - 1); assertEq(uint256(pl.maximumAccessLevelRequired), 1); assertEq(pl.createdAt, block.timestamp); assertEq(pl.creator, address(this)); @@ -124,7 +124,7 @@ contract GovernanceV3Test is ProtocolV3TestBase { function test_expectRevertOnNonExistingPayload() public { vm.expectRevert(); - GovV3Helpers.executePayload(vm, address(1)); + this.selfExternalCallToExecutePayload(vm, address(1)); } /** @@ -151,7 +151,7 @@ contract GovernanceV3Test is ProtocolV3TestBase { vm.stopPrank(); } - function xtest_payloadCreationWhenPayloadAlreadyCreated() public { + function test_payloadCreationWhenPayloadAlreadyCreated() public { // 1. deploy payloads PayloadWithEmit pl1 = new PayloadWithEmit(); PayloadWithEmit pl2 = new PayloadWithEmit(); @@ -165,20 +165,37 @@ contract GovernanceV3Test is ProtocolV3TestBase { // 3. create same payload vm.expectRevert(GovV3Helpers.PayloadAlreadyCreated.selector); - GovV3Helpers.createPayload(actions); + this.selfExternalCallToCreatePayload(actions); } function test_helpers() public { defaultTest('default', AaveV3Ethereum.POOL, address(payload)); } - function testFail_findPayload() public { + function test_findPayload() public { IPayloadsControllerCore.ExecutionAction[] memory actions = new IPayloadsControllerCore.ExecutionAction[](1); actions[0] = GovV3Helpers.buildAction(address(42)); // should revert as payload 0x42 does not exist - vm.expectRevert(CannotFindPayload.selector); + vm.expectRevert(GovV3Helpers.CannotFindPayload.selector); + this.selfExternalCallToBuildMainnetPayload(vm, actions); + } + + function selfExternalCallToBuildMainnetPayload( + Vm vm, + IPayloadsControllerCore.ExecutionAction[] memory actions + ) external { GovV3Helpers.buildMainnetPayload(vm, actions); } + + function selfExternalCallToCreatePayload( + IPayloadsControllerCore.ExecutionAction[] memory actions + ) external { + GovV3Helpers.createPayload(actions); + } + + function selfExternalCallToExecutePayload(Vm vm, address payloadAddress) external { + GovV3Helpers.executePayload(vm, payloadAddress); + } } diff --git a/tests/asset-manager/AaveWstethWithdrawerTest.t.sol b/tests/asset-manager/AaveWstethWithdrawerTest.t.sol index f7dcf4743..9e150e23a 100644 --- a/tests/asset-manager/AaveWstethWithdrawerTest.t.sol +++ b/tests/asset-manager/AaveWstethWithdrawerTest.t.sol @@ -10,11 +10,11 @@ import {AaveWstethWithdrawer} from '../../src/asset-manager/AaveWstethWithdrawer contract AaveWstethWithdrawerTest is Test { using stdStorage for StdStorage; - + event StartedWithdrawal(uint256[] amounts, uint256 indexed index); event FinalizedWithdrawal(uint256 amount, uint256 indexed index); - + uint256 public constant EXISTING_UNSTETH_TOKENID = 46283; uint256 public constant WITHDRAWAL_AMOUNT = 999999999900; uint256 public constant FINALIZED_WITHDRAWAL_AMOUNT = 1173102309960; @@ -30,7 +30,6 @@ contract AaveWstethWithdrawerTest is Test { AaveWstethWithdrawer public withdrawer; - /// At current block oldWithdrawer (UNSTETH_OWNER) has an Lido withdrawal NFT /// this NFT represents an WITHDRAWAL_AMOUNT of STETH that /// yields FINALIZED_WITHDRAWAL_AMOUNT of ETH when completed. @@ -45,19 +44,15 @@ contract AaveWstethWithdrawerTest is Test { address(withdrawer), 46283 ); - + /// start an withdrawal to create the storage slot - AaveV3Ethereum.COLLECTOR.transfer( - address(WSTETH), - address(withdrawer), - WITHDRAWAL_AMOUNT - ); + AaveV3Ethereum.COLLECTOR.transfer(address(WSTETH), address(withdrawer), WITHDRAWAL_AMOUNT); uint256[] memory amounts = new uint256[](1); amounts[0] = WITHDRAWAL_AMOUNT; withdrawer.startWithdraw(amounts); vm.stopPrank(); - - /// override the storage slot to the requestId respective to the unSTETH NFT + + /// override the storage slot to the requestId respective to the unSTETH NFT /// and the minCheckpointIndex AaveWstethWithdrawer oldWithdrawer = AaveWstethWithdrawer(payable(UNSTETH_OWNER)); uint256 key = 0; @@ -70,10 +65,7 @@ contract AaveWstethWithdrawerTest is Test { .with_key(key) .checked_write(reqId); - stdstore - .target(address(withdrawer)) - .sig('minCheckpointIndex()') - .checked_write(minIndex); + stdstore.target(address(withdrawer)).sig('minCheckpointIndex()').checked_write(minIndex); _; } @@ -119,11 +111,7 @@ contract UpdateGuardian is AaveWstethWithdrawerTest { contract StartWithdrawal is AaveWstethWithdrawerTest { function test_revertsIf_invalidCaller() public { vm.prank(OWNER); - AaveV3Ethereum.COLLECTOR.transfer( - address(WSTETH), - address(withdrawer), - WITHDRAWAL_AMOUNT - ); + AaveV3Ethereum.COLLECTOR.transfer(address(WSTETH), address(withdrawer), WITHDRAWAL_AMOUNT); uint256[] memory amounts = new uint256[](1); amounts[0] = WITHDRAWAL_AMOUNT; vm.expectRevert('ONLY_BY_OWNER_OR_GUARDIAN'); @@ -136,11 +124,7 @@ contract StartWithdrawal is AaveWstethWithdrawerTest { uint256 nextIndex = withdrawer.nextIndex(); vm.startPrank(OWNER); - AaveV3Ethereum.COLLECTOR.transfer( - address(WSTETH), - address(withdrawer), - WITHDRAWAL_AMOUNT - ); + AaveV3Ethereum.COLLECTOR.transfer(address(WSTETH), address(withdrawer), WITHDRAWAL_AMOUNT); uint256[] memory amounts = new uint256[](1); amounts[0] = WITHDRAWAL_AMOUNT; vm.expectEmit(address(withdrawer)); @@ -161,11 +145,7 @@ contract StartWithdrawal is AaveWstethWithdrawerTest { uint256 nextIndex = withdrawer.nextIndex(); vm.prank(OWNER); - AaveV3Ethereum.COLLECTOR.transfer( - address(WSTETH), - address(withdrawer), - WITHDRAWAL_AMOUNT - ); + AaveV3Ethereum.COLLECTOR.transfer(address(WSTETH), address(withdrawer), WITHDRAWAL_AMOUNT); uint256[] memory amounts = new uint256[](1); amounts[0] = WITHDRAWAL_AMOUNT; vm.expectEmit(address(withdrawer)); @@ -207,7 +187,7 @@ contract FinalizeWithdrawal is AaveWstethWithdrawerTest { assertEq(collectorBalanceAfter, collectorBalanceBefore + FINALIZED_WITHDRAWAL_AMOUNT); } - + function test_finalizeWithdrawalWithExtraFunds() public withUnsteth { uint256 collectorBalanceBefore = WETH.balanceOf(COLLECTOR); @@ -230,28 +210,17 @@ contract EmergencyTokenTransfer is AaveWstethWithdrawerTest { function test_revertsIf_invalidCaller() public { deal(address(WSTETH), address(withdrawer), WITHDRAWAL_AMOUNT); vm.expectRevert('ONLY_RESCUE_GUARDIAN'); - withdrawer.emergencyTokenTransfer( - address(WSTETH), - COLLECTOR, - WITHDRAWAL_AMOUNT - ); + withdrawer.emergencyTokenTransfer(address(WSTETH), COLLECTOR, WITHDRAWAL_AMOUNT); } function test_successful_governanceCaller() public { uint256 initialCollectorBalance = WSTETH.balanceOf(COLLECTOR); deal(address(WSTETH), address(withdrawer), WITHDRAWAL_AMOUNT); vm.startPrank(OWNER); - withdrawer.emergencyTokenTransfer( - address(WSTETH), - COLLECTOR, - WITHDRAWAL_AMOUNT - ); + withdrawer.emergencyTokenTransfer(address(WSTETH), COLLECTOR, WITHDRAWAL_AMOUNT); vm.stopPrank(); - assertEq( - WSTETH.balanceOf(COLLECTOR), - initialCollectorBalance + WITHDRAWAL_AMOUNT - ); + assertEq(WSTETH.balanceOf(COLLECTOR), initialCollectorBalance + WITHDRAWAL_AMOUNT); assertEq(WSTETH.balanceOf(address(withdrawer)), 0); } } @@ -259,29 +228,18 @@ contract EmergencyTokenTransfer is AaveWstethWithdrawerTest { contract Emergency721TokenTransfer is AaveWstethWithdrawerTest { function test_revertsIf_invalidCaller() public withUnsteth { vm.expectRevert('ONLY_RESCUE_GUARDIAN'); - withdrawer.emergency721TokenTransfer( - address(UNSTETH), - COLLECTOR, - EXISTING_UNSTETH_TOKENID - ); + withdrawer.emergency721TokenTransfer(address(UNSTETH), COLLECTOR, EXISTING_UNSTETH_TOKENID); } function test_successful_governanceCaller() public withUnsteth { uint256 lidoNftBalanceBefore = UNSTETH.balanceOf(address(withdrawer)); vm.startPrank(OWNER); - withdrawer.emergency721TokenTransfer( - address(UNSTETH), - COLLECTOR, - EXISTING_UNSTETH_TOKENID - ); + withdrawer.emergency721TokenTransfer(address(UNSTETH), COLLECTOR, EXISTING_UNSTETH_TOKENID); vm.stopPrank(); uint256 lidoNftBalanceAfter = UNSTETH.balanceOf(address(withdrawer)); - assertEq( - UNSTETH.balanceOf(COLLECTOR), - 1 - ); + assertEq(UNSTETH.balanceOf(COLLECTOR), 1); assertEq(lidoNftBalanceAfter, lidoNftBalanceBefore - 1); } -} \ No newline at end of file +} diff --git a/tests/bridges/arbitrum/AaveArbEthERC20BridgeTest.t.sol b/tests/bridges/arbitrum/AaveArbEthERC20BridgeTest.t.sol index bb220e079..cfe8652ea 100644 --- a/tests/bridges/arbitrum/AaveArbEthERC20BridgeTest.t.sol +++ b/tests/bridges/arbitrum/AaveArbEthERC20BridgeTest.t.sol @@ -7,6 +7,7 @@ import {AaveV3Ethereum, AaveV3EthereumAssets} from 'aave-address-book/AaveV3Ethe import {AaveV3Arbitrum, AaveV3ArbitrumAssets} from 'aave-address-book/AaveV3Arbitrum.sol'; import {GovernanceV3Ethereum} from 'aave-address-book/GovernanceV3Ethereum.sol'; import {GovernanceV3Arbitrum} from 'aave-address-book/GovernanceV3Arbitrum.sol'; +import {IRescuable} from 'solidity-utils/contracts/utils/Rescuable.sol'; import {AaveArbEthERC20Bridge} from '../../../src/bridges/arbitrum/AaveArbEthERC20Bridge.sol'; import {IAaveArbEthERC20Bridge} from '../../../src/bridges/arbitrum/IAaveArbEthERC20Bridge.sol'; @@ -93,10 +94,9 @@ contract BridgeTest is AaveArbEthERC20BridgeTest { bridgeArbitrum.transferOwnership(GovernanceV3Arbitrum.EXECUTOR_LVL_1); vm.startPrank(GovernanceV3Arbitrum.EXECUTOR_LVL_1); - ArbSysMock arbsys = new ArbSysMock(); - vm.etch(address(0x0000000000000000000000000000000000000064), address(arbsys).code); + vm.etch(address(0x0000000000000000000000000000000000000064), address(arbsys).code); vm.expectEmit(); emit Bridge(AaveV3ArbitrumAssets.USDC_UNDERLYING, amount); @@ -113,7 +113,7 @@ contract BridgeTest is AaveArbEthERC20BridgeTest { contract EmergencyTokenTransfer is AaveArbEthERC20BridgeTest { function test_revertsIf_invalidCaller() public { - vm.expectRevert('ONLY_RESCUE_GUARDIAN'); + vm.expectRevert(IRescuable.OnlyRescueGuardian.selector); vm.startPrank(makeAddr('random-caller')); bridgeArbitrum.emergencyTokenTransfer( AaveV3ArbitrumAssets.LINK_UNDERLYING, diff --git a/tests/bridges/optimism/AaveOpEthERC20BridgeTest.t.sol b/tests/bridges/optimism/AaveOpEthERC20BridgeTest.t.sol index 042517b86..ee716316f 100644 --- a/tests/bridges/optimism/AaveOpEthERC20BridgeTest.t.sol +++ b/tests/bridges/optimism/AaveOpEthERC20BridgeTest.t.sol @@ -7,6 +7,7 @@ import {IERC20} from 'solidity-utils/contracts/oz-common/interfaces/IERC20.sol'; import {AaveV3Ethereum, AaveV3EthereumAssets} from 'aave-address-book/AaveV3Ethereum.sol'; import {AaveV3Optimism, AaveV3OptimismAssets} from 'aave-address-book/AaveV3Optimism.sol'; import {GovernanceV3Optimism} from 'aave-address-book/GovernanceV3Optimism.sol'; +import {IRescuable} from 'solidity-utils/contracts/utils/Rescuable.sol'; import {AaveOpEthERC20Bridge} from 'src/bridges/optimism/AaveOpEthERC20Bridge.sol'; import {IAaveOpEthERC20Bridge} from 'src/bridges/optimism/IAaveOpEthERC20Bridge.sol'; @@ -104,7 +105,7 @@ contract TransferOwnership is AaveOpEthERC20BridgeTest { contract EmergencyTokenTransfer is AaveOpEthERC20BridgeTest { function test_revertsIf_invalidCaller() public { - vm.expectRevert('ONLY_RESCUE_GUARDIAN'); + vm.expectRevert(IRescuable.OnlyRescueGuardian.selector); vm.startPrank(makeAddr('random-caller')); bridge.emergencyTokenTransfer( AaveV3OptimismAssets.USDC_UNDERLYING, diff --git a/tests/bridges/polygon/AavePolEthERC20BridgeTest.t.sol b/tests/bridges/polygon/AavePolEthERC20BridgeTest.t.sol index 87c333d53..063ae1b3f 100644 --- a/tests/bridges/polygon/AavePolEthERC20BridgeTest.t.sol +++ b/tests/bridges/polygon/AavePolEthERC20BridgeTest.t.sol @@ -9,6 +9,7 @@ import {AaveV3Polygon, AaveV3PolygonAssets} from 'aave-address-book/AaveV3Polygo import {MiscEthereum} from 'aave-address-book/MiscEthereum.sol'; import {GovernanceV3Ethereum} from 'aave-address-book/GovernanceV3Ethereum.sol'; import {GovernanceV3Polygon} from 'aave-address-book/GovernanceV3Polygon.sol'; +import {IRescuable} from 'solidity-utils/contracts/utils/Rescuable.sol'; import {AavePolEthERC20Bridge} from 'src/bridges/polygon/AavePolEthERC20Bridge.sol'; import {IAavePolEthERC20Bridge} from 'src/bridges/polygon/IAavePolEthERC20Bridge.sol'; @@ -84,7 +85,7 @@ contract BridgeTest is AavePolEthERC20BridgeTest { contract EmergencyTokenTransfer is AavePolEthERC20BridgeTest { function test_revertsIf_invalidCaller() public { - vm.expectRevert('ONLY_RESCUE_GUARDIAN'); + vm.expectRevert(IRescuable.OnlyRescueGuardian.selector); vm.startPrank(makeAddr('random-caller')); bridgePolygon.emergencyTokenTransfer( AaveV2PolygonAssets.BAL_UNDERLYING, @@ -289,11 +290,12 @@ contract ForkedBridgeTests is Test { MiscEthereum.AAVE_POL_ETH_BRIDGE ); - IAavePolEthERC20Bridge(0xc928002904Ec475663A83063D492EA2aE09EbDA1).exit(burnProof); // Old bridge address for this TX assertGt( - IERC20(AaveV3EthereumAssets.DAI_UNDERLYING).balanceOf(0xc928002904Ec475663A83063D492EA2aE09EbDA1), + IERC20(AaveV3EthereumAssets.DAI_UNDERLYING).balanceOf( + 0xc928002904Ec475663A83063D492EA2aE09EbDA1 + ), balanceDaiBefore ); } diff --git a/tests/bridges/polygon/AavePolEthPlasmaBridge.t.sol b/tests/bridges/polygon/AavePolEthPlasmaBridge.t.sol index a7fc419d1..77a774895 100644 --- a/tests/bridges/polygon/AavePolEthPlasmaBridge.t.sol +++ b/tests/bridges/polygon/AavePolEthPlasmaBridge.t.sol @@ -10,6 +10,7 @@ import {AaveV3Polygon, AaveV3PolygonAssets} from 'aave-address-book/AaveV3Polygo import {MiscEthereum} from 'aave-address-book/MiscEthereum.sol'; import {GovernanceV3Ethereum} from 'aave-address-book/GovernanceV3Ethereum.sol'; import {GovernanceV3Polygon} from 'aave-address-book/GovernanceV3Polygon.sol'; +import {IRescuable} from 'solidity-utils/contracts/utils/Rescuable.sol'; import {AavePolEthPlasmaBridge} from 'src/bridges/polygon/AavePolEthPlasmaBridge.sol'; import {IAavePolEthPlasmaBridge} from 'src/bridges/polygon/IAavePolEthPlasmaBridge.sol'; @@ -118,9 +119,7 @@ contract WithdrawToCollectorTest is AavePolEthPlasmaBridgeTest { uint256 balanceCollectorBefore = IERC20(MATIC_MAINNET).balanceOf( address(AaveV3Ethereum.COLLECTOR) ); - uint256 balanceBridgeBefore = IERC20(MATIC_MAINNET).balanceOf( - address(bridgeMainnet) - ); + uint256 balanceBridgeBefore = IERC20(MATIC_MAINNET).balanceOf(address(bridgeMainnet)); assertEq(balanceBridgeBefore, amount); @@ -136,7 +135,7 @@ contract WithdrawToCollectorTest is AavePolEthPlasmaBridgeTest { contract EmergencyTokenTransfer is AavePolEthPlasmaBridgeTest { function test_revertsIf_invalidCaller() public { - vm.expectRevert('ONLY_RESCUE_GUARDIAN'); + vm.expectRevert(IRescuable.OnlyRescueGuardian.selector); vm.startPrank(makeAddr('random-caller')); bridgePolygon.emergencyTokenTransfer( AaveV2PolygonAssets.BAL_UNDERLYING, @@ -207,7 +206,7 @@ contract ExitTest is AavePolEthPlasmaBridgeTest { /// The TX can be found here: https://etherscan.io/tx/0x75849d87d15d6a5837c29e2d97a10a442fa71bee50c8cb8ddc01058a474e581e contract ForkedBridgeTests is Test { event ConfirmExit(bytes proof); - + function test_successful() public { vm.createSelectFork(vm.rpcUrl('mainnet'), 19419577); // One block before an actual exit diff --git a/tests/swaps/AaveSwapperTest.t.sol b/tests/swaps/AaveSwapperTest.t.sol index d7f1b9293..8eb760dc2 100644 --- a/tests/swaps/AaveSwapperTest.t.sol +++ b/tests/swaps/AaveSwapperTest.t.sol @@ -7,6 +7,7 @@ import {GovernanceV3Ethereum} from 'aave-address-book/GovernanceV3Ethereum.sol'; import {AaveV2Ethereum, AaveV2EthereumAssets} from 'aave-address-book/AaveV2Ethereum.sol'; import {AaveV3Ethereum, AaveV3EthereumAssets} from 'aave-address-book/AaveV3Ethereum.sol'; import {IERC20} from 'solidity-utils/contracts/oz-common/interfaces/IERC20.sol'; +import {IRescuable} from 'solidity-utils/contracts/utils/Rescuable.sol'; import {AaveSwapper} from 'src/swaps/AaveSwapper.sol'; import {IAaveSwapper} from 'src/swaps/interfaces/IAaveSwapper.sol'; @@ -314,7 +315,7 @@ contract CancelSwap is AaveSwapperTest { contract EmergencyTokenTransfer is AaveSwapperTest { function test_revertsIf_invalidCaller() public { - vm.expectRevert('ONLY_RESCUE_GUARDIAN'); + vm.expectRevert(IRescuable.OnlyRescueGuardian.selector); swaps.emergencyTokenTransfer( AaveV2EthereumAssets.BAL_UNDERLYING, address(AaveV2Ethereum.COLLECTOR), From 92f631c72e763d47b4e4e736af345f37483dbfb1 Mon Sep 17 00:00:00 2001 From: Harsh Pandey Date: Fri, 17 Jan 2025 18:25:01 +0530 Subject: [PATCH 2/4] chore: update address book (#366) --- lib/aave-address-book | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/aave-address-book b/lib/aave-address-book index c34ae690a..d22bc7838 160000 --- a/lib/aave-address-book +++ b/lib/aave-address-book @@ -1 +1 @@ -Subproject commit c34ae690a16a506101bd4b8b45b88935f666be69 +Subproject commit d22bc78386303517252c8ec28761274259ce33c1 From 551cc56b3af72c7da7e7b8dc0f02c196f026f2a2 Mon Sep 17 00:00:00 2001 From: Harsh Pandey Date: Mon, 20 Jan 2025 17:13:02 +0530 Subject: [PATCH 3/4] chore: update address book (#367) --- lib/aave-address-book | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/aave-address-book b/lib/aave-address-book index d22bc7838..9489562fb 160000 --- a/lib/aave-address-book +++ b/lib/aave-address-book @@ -1 +1 @@ -Subproject commit d22bc78386303517252c8ec28761274259ce33c1 +Subproject commit 9489562fbb3344d18a946d08a00247696a69878c From 066f216c4d178b87d9212f78343bf8a10f08d0c2 Mon Sep 17 00:00:00 2001 From: Harsh Pandey Date: Tue, 21 Jan 2025 19:07:54 +0530 Subject: [PATCH 4/4] chore: linea config engine and govHelper payloads (#368) * feat: add helpers for linea * chore: update lib --- lib/aave-address-book | 2 +- src/GovV3Helpers.sol | 27 +++++++++++++++++++++ src/v3-config-engine/AaveV3PayloadLinea.sol | 15 ++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 src/v3-config-engine/AaveV3PayloadLinea.sol diff --git a/lib/aave-address-book b/lib/aave-address-book index 9489562fb..837214a8b 160000 --- a/lib/aave-address-book +++ b/lib/aave-address-book @@ -1 +1 @@ -Subproject commit 9489562fbb3344d18a946d08a00247696a69878c +Subproject commit 837214a8bfff3c937a6d8fd803d0c88eeaa948a0 diff --git a/src/GovV3Helpers.sol b/src/GovV3Helpers.sol index 44588046a..1a94a7c27 100644 --- a/src/GovV3Helpers.sol +++ b/src/GovV3Helpers.sol @@ -21,6 +21,7 @@ import {GovernanceV3Gnosis} from 'aave-address-book/GovernanceV3Gnosis.sol'; import {GovernanceV3Scroll} from 'aave-address-book/GovernanceV3Scroll.sol'; import {GovernanceV3PolygonZkEvm} from 'aave-address-book/GovernanceV3PolygonZkEvm.sol'; import {GovernanceV3ZkSync} from 'aave-address-book/GovernanceV3ZkSync.sol'; +import {GovernanceV3Linea} from 'aave-address-book/GovernanceV3Linea.sol'; import {MiscEthereum} from 'aave-address-book/MiscEthereum.sol'; import {Address} from 'solidity-utils/contracts/oz-common/Address.sol'; import {Create2Utils} from 'solidity-utils/contracts/utils/ScriptUtils.sol'; @@ -696,6 +697,30 @@ library GovV3Helpers { return _buildPayload(vm, ChainIds.ZKSYNC, action); } + /** + * Builds a payload to be executed via governance + * @param vm Vm + * @param actions actions array + */ + function buildLineaPayload( + Vm vm, + IPayloadsControllerCore.ExecutionAction[] memory actions + ) internal returns (PayloadsControllerUtils.Payload memory) { + return _buildPayload(vm, ChainIds.LINEA, actions); + } + + /** + * Builds a payload to be executed via governance + * @param vm Vm + * @param action single action struct + */ + function buildLineaPayload( + Vm vm, + IPayloadsControllerCore.ExecutionAction memory action + ) internal returns (PayloadsControllerUtils.Payload memory) { + return _buildPayload(vm, ChainIds.LINEA, action); + } + /** * @dev creates a proposal with multiple payloads * @param vm Vm @@ -777,6 +802,8 @@ library GovV3Helpers { return GovernanceV3PolygonZkEvm.PAYLOADS_CONTROLLER; } else if (chainId == ChainIds.ZKSYNC) { return GovernanceV3ZkSync.PAYLOADS_CONTROLLER; + } else if (chainId == ChainIds.LINEA) { + return GovernanceV3Linea.PAYLOADS_CONTROLLER; } revert CannotFindPayloadsController(); diff --git a/src/v3-config-engine/AaveV3PayloadLinea.sol b/src/v3-config-engine/AaveV3PayloadLinea.sol new file mode 100644 index 000000000..9c165ad03 --- /dev/null +++ b/src/v3-config-engine/AaveV3PayloadLinea.sol @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import {AaveV3Linea} from 'aave-address-book/AaveV3Linea.sol'; +import 'aave-v3-origin/contracts/extensions/v3-config-engine/AaveV3Payload.sol'; + +/** + * @dev Base smart contract for an Aave v3.2.0 listing on v3 Linea. + * @author BGD Labs + */ +abstract contract AaveV3PayloadLinea is AaveV3Payload(IEngine(AaveV3Linea.CONFIG_ENGINE)) { + function getPoolContext() public pure override returns (IEngine.PoolContext memory) { + return IEngine.PoolContext({networkName: 'Linea', networkAbbreviation: 'Lin'}); + } +}