Skip to content

Commit

Permalink
Merge branch 'fix/legacy-on-ramp' into tmp/testnet-maintenance
Browse files Browse the repository at this point in the history
  • Loading branch information
DhairyaSethi committed Oct 22, 2024
2 parents ebce713 + 7b49a40 commit 720a45f
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ contract UpgradeableBurnMintTokenPool is Initializable, UpgradeableBurnMintToken
address token,
address armProxy,
bool allowlistEnabled
) UpgradeableTokenPool(IBurnMintERC20(token), armProxy, allowlistEnabled) {
_disableInitializers();
}
) UpgradeableTokenPool(IBurnMintERC20(token), armProxy, allowlistEnabled) {}

/// @dev Initializer
/// @dev The address passed as `owner` must accept ownership after initialization.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ contract UpgradeableLockReleaseTokenPool is Initializable, UpgradeableTokenPool,
bool acceptLiquidity
) UpgradeableTokenPool(IERC20(token), armProxy, allowlistEnabled) {
i_acceptLiquidity = acceptLiquidity;
_disableInitializers();
}

/// @dev Initializer
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/v0.8/ccip/pools/GHO/UpgradeableTokenPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ abstract contract UpgradeableTokenPool is IPool, OwnerIsCreator, IERC165 {
}

/// @notice Getter for proxy pool address.
/// @return proxyPool The proxy pool address for the given remoteChainSelector
/// @return proxyPool The proxy pool address.
function getProxyPool() public view returns (address proxyPool) {
assembly ("memory-safe") {
proxyPool := shr(96, shl(96, sload(PROXY_POOL_SLOT)))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
```diff
diff --git a/src/v0.8/ccip/pools/BurnMintTokenPool.sol b/src/v0.8/ccip/pools/GHO/UpgradeableBurnMintTokenPool.sol
index 9af0f22f4c..57a3226ef4 100644
index 9af0f22f4c..99f8a7b42f 100644
--- a/src/v0.8/ccip/pools/BurnMintTokenPool.sol
+++ b/src/v0.8/ccip/pools/GHO/UpgradeableBurnMintTokenPool.sol
@@ -1,28 +1,92 @@
@@ -1,28 +1,90 @@
// SPDX-License-Identifier: BUSL-1.1
-pragma solidity 0.8.19;
+pragma solidity ^0.8.0;
Expand Down Expand Up @@ -57,9 +57,7 @@ index 9af0f22f4c..57a3226ef4 100644
- address router
- ) TokenPool(token, allowlist, armProxy, router) {}
+ bool allowlistEnabled
+ ) UpgradeableTokenPool(IBurnMintERC20(token), armProxy, allowlistEnabled) {
+ _disableInitializers();
+ }
+ ) UpgradeableTokenPool(IBurnMintERC20(token), armProxy, allowlistEnabled) {}
+
+ /// @dev Initializer
+ /// @dev The address passed as `owner` must accept ownership after initialization.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
```diff
diff --git a/src/v0.8/ccip/pools/LockReleaseTokenPool.sol b/src/v0.8/ccip/pools/GHO/UpgradeableLockReleaseTokenPool.sol
index 1a17fa0398..7de31fa91e 100644
index 1a17fa0398..a055c8b8cd 100644
--- a/src/v0.8/ccip/pools/LockReleaseTokenPool.sol
+++ b/src/v0.8/ccip/pools/GHO/UpgradeableLockReleaseTokenPool.sol
@@ -1,26 +1,39 @@
Expand Down Expand Up @@ -55,7 +55,7 @@ index 1a17fa0398..7de31fa91e 100644
string public constant override typeAndVersion = "LockReleaseTokenPool 1.4.0";

/// @dev The unique lock release pool flag to signal through EIP 165.
@@ -37,14 +50,53 @@ contract LockReleaseTokenPool is TokenPool, ILiquidityContainer, ITypeAndVersion
@@ -37,16 +50,54 @@ contract LockReleaseTokenPool is TokenPool, ILiquidityContainer, ITypeAndVersion
/// @dev Can be address(0) if none is configured.
address internal s_rateLimitAdmin;

Expand Down Expand Up @@ -85,9 +85,8 @@ index 1a17fa0398..7de31fa91e 100644
+ bool acceptLiquidity
+ ) UpgradeableTokenPool(IERC20(token), armProxy, allowlistEnabled) {
i_acceptLiquidity = acceptLiquidity;
+ _disableInitializers();
+ }
+
}

+ /// @dev Initializer
+ /// @dev The address passed as `owner` must accept ownership after initialization.
+ /// @dev The `allowlist` is only effective if pool is set to access-controlled mode
Expand All @@ -111,10 +110,12 @@ index 1a17fa0398..7de31fa91e 100644
+ _applyAllowListUpdates(new address[](0), allowlist);
+ }
+ s_bridgeLimit = bridgeLimit;
}

+ }
+
/// @notice Locks the token in the pool
@@ -66,6 +118,9 @@ contract LockReleaseTokenPool is TokenPool, ILiquidityContainer, ITypeAndVersion
/// @param amount Amount to lock
/// @dev The whenHealthy check is important to ensure that even if a ramp is compromised
@@ -66,6 +117,9 @@ contract LockReleaseTokenPool is TokenPool, ILiquidityContainer, ITypeAndVersion
whenHealthy
returns (bytes memory)
{
Expand All @@ -124,7 +125,7 @@ index 1a17fa0398..7de31fa91e 100644
_consumeOutboundRateLimit(remoteChainSelector, amount);
emit Locked(msg.sender, amount);
return "";
@@ -83,6 +138,11 @@ contract LockReleaseTokenPool is TokenPool, ILiquidityContainer, ITypeAndVersion
@@ -83,6 +137,11 @@ contract LockReleaseTokenPool is TokenPool, ILiquidityContainer, ITypeAndVersion
uint64 remoteChainSelector,
bytes memory
) external virtual override onlyOffRamp(remoteChainSelector) whenHealthy {
Expand All @@ -136,7 +137,7 @@ index 1a17fa0398..7de31fa91e 100644
_consumeInboundRateLimit(remoteChainSelector, amount);
getToken().safeTransfer(receiver, amount);
emit Released(msg.sender, receiver, amount);
@@ -120,11 +180,48 @@ contract LockReleaseTokenPool is TokenPool, ILiquidityContainer, ITypeAndVersion
@@ -120,11 +179,48 @@ contract LockReleaseTokenPool is TokenPool, ILiquidityContainer, ITypeAndVersion
s_rateLimitAdmin = rateLimitAdmin;
}

Expand Down Expand Up @@ -185,7 +186,7 @@ index 1a17fa0398..7de31fa91e 100644
/// @notice Checks if the pool can accept liquidity.
/// @return true if the pool can accept liquidity, false otherwise.
function canAcceptLiquidity() external view returns (bool) {
@@ -151,7 +248,7 @@ contract LockReleaseTokenPool is TokenPool, ILiquidityContainer, ITypeAndVersion
@@ -151,7 +247,7 @@ contract LockReleaseTokenPool is TokenPool, ILiquidityContainer, ITypeAndVersion
emit LiquidityRemoved(msg.sender, amount);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
```diff
diff --git a/src/v0.8/ccip/pools/TokenPool.sol b/src/v0.8/ccip/pools/GHO/UpgradeableTokenPool.sol
index b3571bb449..4808aa3998 100644
index b3571bb449..aa86725ef6 100644
--- a/src/v0.8/ccip/pools/TokenPool.sol
+++ b/src/v0.8/ccip/pools/GHO/UpgradeableTokenPool.sol
@@ -1,21 +1,24 @@
Expand Down Expand Up @@ -104,7 +104,7 @@ index b3571bb449..4808aa3998 100644
}
+
+ /// @notice Getter for proxy pool address.
+ /// @return proxyPool The proxy pool address for the given remoteChainSelector
+ /// @return proxyPool The proxy pool address.
+ function getProxyPool() public view returns (address proxyPool) {
+ assembly ("memory-safe") {
+ proxyPool := shr(96, shl(96, sload(PROXY_POOL_SLOT)))
Expand Down
12 changes: 6 additions & 6 deletions contracts/src/v0.8/ccip/test/pools/GHO/GhoBaseTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,18 @@ abstract contract GhoBaseTest is BaseTest {
emptyArray,
router
);
TransparentUpgradeableProxy tokenProxyPool = new TransparentUpgradeableProxy(
TransparentUpgradeableProxy tokenPoolProxy = new TransparentUpgradeableProxy(
address(tokenPoolImpl),
proxyAdmin,
tokenPoolInitParams
);
// Manage ownership
vm.stopPrank();
vm.prank(owner);
UpgradeableBurnMintTokenPool(address(tokenProxyPool)).acceptOwnership();
UpgradeableBurnMintTokenPool(address(tokenPoolProxy)).acceptOwnership();
vm.startPrank(OWNER);

return address(tokenProxyPool);
return address(tokenPoolProxy);
}

function _deployUpgradeableLockReleaseTokenPool(
Expand All @@ -83,7 +83,7 @@ abstract contract GhoBaseTest is BaseTest {
router,
bridgeLimit
);
TransparentUpgradeableProxy tokenProxyPool = new TransparentUpgradeableProxy(
TransparentUpgradeableProxy tokenPoolProxy = new TransparentUpgradeableProxy(
address(tokenPoolImpl),
proxyAdmin,
tokenPoolInitParams
Expand All @@ -92,10 +92,10 @@ abstract contract GhoBaseTest is BaseTest {
// Manage ownership
vm.stopPrank();
vm.prank(owner);
UpgradeableLockReleaseTokenPool(address(tokenProxyPool)).acceptOwnership();
UpgradeableLockReleaseTokenPool(address(tokenPoolProxy)).acceptOwnership();
vm.startPrank(OWNER);

return address(tokenProxyPool);
return address(tokenPoolProxy);
}

function _inflateFacilitatorLevel(address tokenPool, address ghoToken, uint256 amount) internal {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,11 @@ contract ForkPoolAfterMigration is ForkBase {
}

contract ForkPoolBeforeMigration is ForkBase {
event Locked(address indexed sender, uint256 amount);
event Burned(address indexed sender, uint256 amount);
event Released(address indexed sender, address indexed recipient, uint256 amount);
event Minted(address indexed sender, address indexed recipient, uint256 amount);

uint256 internal constant BLOCK_BEFORE_MIGRATION_L1 = 6673089;
uint256 internal constant BLOCK_BEFORE_MIGRATION_L2 = 79570677;

Expand Down Expand Up @@ -321,24 +326,25 @@ contract ForkPoolBeforeMigration is ForkBase {

function testSendViaRouter() public {
uint256 amount = 10e18;

Client.EVM2AnyMessage memory message = _generateMessage(alice, 1);
message.tokenAmounts[0] = Client.EVMTokenAmount({token: address(l1.token), amount: amount});

{
vm.selectFork(l1.forkId);

uint256 feeTokenAmount = l1.router.getFee(l2.chainSelector, message);

vm.expectEmit();
emit Locked(address(l1.EVM2EVMOnRamp1_2), amount);
vm.prank(alice);
l1.router.ccipSend{value: feeTokenAmount}(l2.chainSelector, message);
}
{
vm.selectFork(l2.forkId);

message.tokenAmounts[0].token = address(l2.token);
uint256 feeTokenAmount = l2.router.getFee(l1.chainSelector, message);

vm.expectEmit();
emit Burned(address(l2.EVM2EVMOnRamp1_2), amount);
vm.prank(alice);
l2.router.ccipSend{value: feeTokenAmount}(l1.chainSelector, message);
}
Expand All @@ -349,15 +355,18 @@ contract ForkPoolBeforeMigration is ForkBase {
{
vm.selectFork(l1.forkId);

vm.expectEmit();
emit Locked(address(l1.EVM2EVMOnRamp1_2), amount);
vm.prank(address(l1.EVM2EVMOnRamp1_2));
l1.tokenPool.lockOrBurn(alice, abi.encode(alice), amount, l2.chainSelector, "");
}
{
vm.selectFork(l2.forkId);

// router is responsible for transferring liquidity, so we mock router.token.transferFrom(user, tokenPool)
deal(address(l2.token), address(l2.tokenPool), amount);

vm.expectEmit();
emit Burned(address(l2.EVM2EVMOnRamp1_2), amount);
vm.prank(address(l2.EVM2EVMOnRamp1_2));
l2.tokenPool.lockOrBurn(alice, abi.encode(alice), amount, l1.chainSelector, "");
}
Expand All @@ -367,19 +376,21 @@ contract ForkPoolBeforeMigration is ForkBase {
uint256 amount = 10e18;
{
vm.selectFork(l1.forkId);

uint256 balanceBefore = l1.token.balanceOf(alice);

vm.expectEmit();
emit Released(address(l1.EVM2EVMOffRamp1_2), alice, amount);
vm.prank(address(l1.EVM2EVMOffRamp1_2));
l1.tokenPool.releaseOrMint(abi.encode(alice), alice, amount, l2.chainSelector, "");

assertEq(l1.token.balanceOf(alice), balanceBefore + amount);
}
{
vm.selectFork(l2.forkId);

uint256 balanceBefore = l2.token.balanceOf(alice);

vm.expectEmit();
emit Minted(address(l2.EVM2EVMOffRamp1_2), alice, amount);
vm.prank(address(l2.EVM2EVMOffRamp1_2));
l2.tokenPool.releaseOrMint(abi.encode(alice), alice, amount, l1.chainSelector, "");

Expand Down

0 comments on commit 720a45f

Please sign in to comment.