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

CCIP-4329 modify setChainRateLimiterConfig file for setting multiple rate limits #15386

Merged
merged 39 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
6c54396
modify setChainRateLimiterConfig file for setting multiple rate limits
jhweintraub Nov 22, 2024
9e6e783
Merge 6c543967665cb76faafdd20155ba005c1d3beef9 into 6afc0d21508499edf…
jhweintraub Nov 22, 2024
c6b2c10
Update gethwrappers
app-token-issuer-infra-releng[bot] Nov 22, 2024
2c101e1
[Bot] Update changeset file with jira issues
app-token-issuer-infra-releng[bot] Nov 22, 2024
454552e
snapshot fix
jhweintraub Nov 22, 2024
d1e6d6e
Merge branch 'develop' into fix/updateRatLimitConfig
jhweintraub Nov 25, 2024
b65ddca
fix wrappers after merge
jhweintraub Nov 25, 2024
ace4de3
fix test that was broken in merge
jhweintraub Nov 25, 2024
9088cfa
fix liquidityManager snapshot which is affected by token pool changes
jhweintraub Nov 25, 2024
687746d
fix broken integration tests from removing critical setup function
jhweintraub Nov 25, 2024
d950f38
Merge branch 'develop' into fix/updateRatLimitConfig
jhweintraub Nov 26, 2024
d212e5c
add array length check for setChainRateLimitConfigs
jhweintraub Nov 26, 2024
418582a
formatting and snapshot fix
jhweintraub Nov 26, 2024
da4e332
Merge 418582a4fdbe27966aae0601475aba7ce3420af7 into d77db32432894c1e2…
jhweintraub Nov 26, 2024
9d0fe36
Update gethwrappers
app-token-issuer-infra-releng[bot] Nov 26, 2024
8b1553e
simplify test setups
jhweintraub Nov 26, 2024
699bce0
Merge branch 'develop' into fix/updateRatLimitConfig
jhweintraub Nov 26, 2024
8b7c336
Merge branch 'develop' into fix/updateRatLimitConfig
jhweintraub Dec 2, 2024
932214b
Merge 8b7c33626c7974ecc94a017161ab65c241271788 into 5a3a99b7982dbf0f8…
jhweintraub Dec 2, 2024
adf57d7
Update gethwrappers
app-token-issuer-infra-releng[bot] Dec 2, 2024
473ec1b
update wrappers and snapshots which were broken in merge
jhweintraub Dec 2, 2024
a00ea27
Merge branch 'develop' into fix/updateRatLimitConfig
jhweintraub Dec 2, 2024
79bd48c
Merge branch 'develop' into fix/updateRatLimitConfig
jhweintraub Dec 2, 2024
e49d1ba
Merge branch 'develop' into fix/updateRatLimitConfig
jhweintraub Dec 3, 2024
981419d
Merge branch 'develop' into fix/updateRatLimitConfig
jhweintraub Dec 4, 2024
c0bda25
Merge branch 'develop' into fix/updateRatLimitConfig
jhweintraub Dec 4, 2024
0b3933f
Merge c0bda258237b5c8278fcd3408989c0da73ad9c58 into 103dba23e8aa8b767…
jhweintraub Dec 4, 2024
a4ff6c4
Update gethwrappers
app-token-issuer-infra-releng[bot] Dec 4, 2024
b3c1f69
update wrappers and snapshot
jhweintraub Dec 4, 2024
0044a8c
changeset
jhweintraub Dec 4, 2024
82d28a2
Merge branch 'develop' into fix/updateRatLimitConfig
jhweintraub Dec 5, 2024
71f54b0
snapshot update
jhweintraub Dec 5, 2024
0c25f46
Delete contracts/.changeset/orange-buckets-live.md
jhweintraub Dec 5, 2024
b12d8b1
Merge branch 'develop' into fix/updateRatLimitConfig
jhweintraub Dec 6, 2024
56561e5
attempt fix changeset
jhweintraub Dec 6, 2024
ac800ac
attempt changeset fix with update pnpm package
jhweintraub Dec 6, 2024
1ef59ef
Merge branch 'develop' into fix/updateRatLimitConfig
jhweintraub Dec 9, 2024
5886d85
re-add function that was removed early in PR to prevent any required …
jhweintraub Dec 9, 2024
50ff55b
update liquidityManager snapshot because of changes to token pools
jhweintraub Dec 9, 2024
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
10 changes: 10 additions & 0 deletions contracts/.changeset/smooth-cycles-draw.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@chainlink/contracts': patch
---

Modify TokenPool.sol function setChainRateLimiterConfig to now accept an array of configs and set sequentially. Requested by front-end. #bugfix


PR issue: CCIP-4329

Solidity Review issue: CCIP-3966
142 changes: 71 additions & 71 deletions contracts/gas-snapshots/ccip.gas-snapshot

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions contracts/gas-snapshots/liquiditymanager.gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ LiquidityManager_addLiquidity:test_addLiquiditySuccess() (gas: 279198)
LiquidityManager_rebalanceLiquidity:test_InsufficientLiquidityReverts() (gas: 206764)
LiquidityManager_rebalanceLiquidity:test_InvalidRemoteChainReverts() (gas: 192374)
LiquidityManager_rebalanceLiquidity:test_rebalanceBetweenPoolsSuccess() (gas: 9141798)
LiquidityManager_rebalanceLiquidity:test_rebalanceBetweenPoolsSuccess_AlreadyFinalized() (gas: 9246772)
LiquidityManager_rebalanceLiquidity:test_rebalanceBetweenPools_MultiStageFinalization() (gas: 9241912)
LiquidityManager_rebalanceLiquidity:test_rebalanceBetweenPools_NativeRewrap() (gas: 9169653)
LiquidityManager_rebalanceLiquidity:test_rebalanceBetweenPoolsSuccess_AlreadyFinalized() (gas: 9312140)
LiquidityManager_rebalanceLiquidity:test_rebalanceBetweenPools_MultiStageFinalization() (gas: 9307280)
LiquidityManager_rebalanceLiquidity:test_rebalanceBetweenPools_NativeRewrap() (gas: 9235021)
LiquidityManager_rebalanceLiquidity:test_rebalanceLiquiditySuccess() (gas: 382928)
LiquidityManager_receive:test_receive_success() (gas: 21182)
LiquidityManager_removeLiquidity:test_InsufficientLiquidityReverts() (gas: 184959)
Expand All @@ -19,7 +19,7 @@ LiquidityManager_setFinanceRole:test_OnlyOwnerReverts() (gas: 10987)
LiquidityManager_setFinanceRole:test_setFinanceRoleSuccess() (gas: 21836)
LiquidityManager_setLocalLiquidityContainer:test_OnlyOwnerReverts() (gas: 11030)
LiquidityManager_setLocalLiquidityContainer:test_ReverstWhen_CalledWithTheZeroAddress() (gas: 10621)
LiquidityManager_setLocalLiquidityContainer:test_setLocalLiquidityContainerSuccess() (gas: 3784709)
LiquidityManager_setLocalLiquidityContainer:test_setLocalLiquidityContainerSuccess() (gas: 3850077)
LiquidityManager_setMinimumLiquidity:test_OnlyOwnerReverts() (gas: 10925)
LiquidityManager_setMinimumLiquidity:test_setMinimumLiquiditySuccess() (gas: 36389)
LiquidityManager_withdrawERC20:test_withdrawERC20Reverts() (gas: 180396)
Expand Down
20 changes: 11 additions & 9 deletions contracts/src/v0.8/ccip/pools/TokenPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -506,18 +506,20 @@ abstract contract TokenPool is IPoolV1, Ownable2StepMsgSender {
return s_remoteChainConfigs[remoteChainSelector].inboundRateLimiterConfig._currentTokenBucketState();
}

/// @notice Sets the chain rate limiter config.
/// @param remoteChainSelector The remote chain selector for which the rate limits apply.
/// @param outboundConfig The new outbound rate limiter config, meaning the onRamp rate limits for the given chain.
/// @param inboundConfig The new inbound rate limiter config, meaning the offRamp rate limits for the given chain.
function setChainRateLimiterConfig(
uint64 remoteChainSelector,
RateLimiter.Config memory outboundConfig,
RateLimiter.Config memory inboundConfig
/// @notice Sets multiple chain rate limiter configs.
/// @param remoteChainSelectors The remote chain selector for which the rate limits apply.
/// @param outboundConfigs The new outbound rate limiter config, meaning the onRamp rate limits for the given chain.
/// @param inboundConfigs The new inbound rate limiter config, meaning the offRamp rate limits for the given chain.
function setChainRateLimiterConfigs(
uint64[] calldata remoteChainSelectors,
RateLimiter.Config[] calldata outboundConfigs,
RateLimiter.Config[] calldata inboundConfigs
) external {
if (msg.sender != s_rateLimitAdmin && msg.sender != owner()) revert Unauthorized(msg.sender);

_setRateLimitConfig(remoteChainSelector, outboundConfig, inboundConfig);
for (uint256 x = 0; x < remoteChainSelectors.length; x++) {
jhweintraub marked this conversation as resolved.
Show resolved Hide resolved
_setRateLimitConfig(remoteChainSelectors[x], outboundConfigs[x], inboundConfigs[x]);
}
}

function _setRateLimitConfig(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,28 @@ import {RateLimiter} from "../../../libraries/RateLimiter.sol";
import {TokenPool} from "../../../pools/TokenPool.sol";
import {TokenPoolSetup} from "./TokenPoolSetup.t.sol";

contract TokenPool_setChainRateLimiterConfig is TokenPoolSetup {
function testFuzz_SetChainRateLimiterConfig_Success(uint128 capacity, uint128 rate, uint32 newTime) public {
contract TokenPool_setChainRateLimiterConfigs is TokenPoolSetup {
uint64 internal s_remoteChainSelector;

function setUp() public virtual override {
TokenPoolSetup.setUp();

bytes[] memory remotePoolAddresses = new bytes[](1);
remotePoolAddresses[0] = abi.encode(address(2));

TokenPool.ChainUpdate[] memory chainUpdates = new TokenPool.ChainUpdate[](1);
s_remoteChainSelector = 123124;
chainUpdates[0] = TokenPool.ChainUpdate({
remoteChainSelector: s_remoteChainSelector,
remotePoolAddresses: remotePoolAddresses,
remoteTokenAddress: abi.encode(address(3)),
outboundRateLimiterConfig: _getOutboundRateLimiterConfig(),
inboundRateLimiterConfig: _getInboundRateLimiterConfig()
});
s_tokenPool.applyChainUpdates(new uint64[](0), chainUpdates);
}

function testFuzz_SetChainRateLimiterConfigs_Success(uint128 capacity, uint128 rate, uint32 newTime) public {
// Cap the lower bound to 4 so 4/2 is still >= 2
vm.assume(capacity >= 4);
// Cap the lower bound to 2 so 2/2 is still >= 1
Expand All @@ -22,14 +42,23 @@ contract TokenPool_setChainRateLimiterConfig is TokenPoolSetup {
RateLimiter.Config memory newInboundConfig =
RateLimiter.Config({isEnabled: true, capacity: capacity / 2, rate: rate / 2});

uint64[] memory chainSelectors = new uint64[](1);
chainSelectors[0] = DEST_CHAIN_SELECTOR;

RateLimiter.Config[] memory newOutboundConfigs = new RateLimiter.Config[](1);
newOutboundConfigs[0] = newOutboundConfig;

RateLimiter.Config[] memory newInboundConfigs = new RateLimiter.Config[](1);
newInboundConfigs[0] = newInboundConfig;

vm.expectEmit();
emit RateLimiter.ConfigChanged(newOutboundConfig);
vm.expectEmit();
emit RateLimiter.ConfigChanged(newInboundConfig);
vm.expectEmit();
emit TokenPool.ChainConfigured(DEST_CHAIN_SELECTOR, newOutboundConfig, newInboundConfig);

s_tokenPool.setChainRateLimiterConfig(DEST_CHAIN_SELECTOR, newOutboundConfig, newInboundConfig);
s_tokenPool.setChainRateLimiterConfigs(chainSelectors, newOutboundConfigs, newInboundConfigs);

uint256 expectedTokens = RateLimiter._min(newOutboundConfig.capacity, oldOutboundTokens);

Expand All @@ -51,20 +80,34 @@ contract TokenPool_setChainRateLimiterConfig is TokenPoolSetup {
// Reverts

function test_OnlyOwnerOrRateLimitAdmin_Revert() public {
uint64[] memory chainSelectors = new uint64[](1);
chainSelectors[0] = DEST_CHAIN_SELECTOR;

RateLimiter.Config[] memory newOutboundConfigs = new RateLimiter.Config[](1);
jhweintraub marked this conversation as resolved.
Show resolved Hide resolved
newOutboundConfigs[0] = _getOutboundRateLimiterConfig();

RateLimiter.Config[] memory newInboundConfigs = new RateLimiter.Config[](1);
newInboundConfigs[0] = _getInboundRateLimiterConfig();

vm.startPrank(STRANGER);

vm.expectRevert(abi.encodeWithSelector(TokenPool.Unauthorized.selector, STRANGER));
s_tokenPool.setChainRateLimiterConfig(
DEST_CHAIN_SELECTOR, _getOutboundRateLimiterConfig(), _getInboundRateLimiterConfig()
);
s_tokenPool.setChainRateLimiterConfigs(chainSelectors, newOutboundConfigs, newInboundConfigs);
}

function test_NonExistentChain_Revert() public {
uint64 wrongChainSelector = 9084102894;

uint64[] memory chainSelectors = new uint64[](1);
chainSelectors[0] = wrongChainSelector;

RateLimiter.Config[] memory newOutboundConfigs = new RateLimiter.Config[](1);
jhweintraub marked this conversation as resolved.
Show resolved Hide resolved
newOutboundConfigs[0] = _getOutboundRateLimiterConfig();

RateLimiter.Config[] memory newInboundConfigs = new RateLimiter.Config[](1);
newInboundConfigs[0] = _getInboundRateLimiterConfig();

vm.expectRevert(abi.encodeWithSelector(TokenPool.NonExistentChain.selector, wrongChainSelector));
s_tokenPool.setChainRateLimiterConfig(
wrongChainSelector, _getOutboundRateLimiterConfig(), _getInboundRateLimiterConfig()
);
s_tokenPool.setChainRateLimiterConfigs(chainSelectors, newOutboundConfigs, newInboundConfigs);
}
}

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions core/gethwrappers/ccip/generated/token_pool/token_pool.go

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
GETH_VERSION: 1.14.11
burn_from_mint_token_pool: ../../../contracts/solc/v0.8.24/BurnFromMintTokenPool/BurnFromMintTokenPool.abi ../../../contracts/solc/v0.8.24/BurnFromMintTokenPool/BurnFromMintTokenPool.bin 3be84751a3c43b6a8522e67368b69e1ec1b4271768c4c0fd9542ade23ce33306
burn_mint_token_pool: ../../../contracts/solc/v0.8.24/BurnMintTokenPool/BurnMintTokenPool.abi ../../../contracts/solc/v0.8.24/BurnMintTokenPool/BurnMintTokenPool.bin f44a858fed054ede21ae4af7ca66006c0993d9980b641dae2c6d3dc08471c936
burn_with_from_mint_token_pool: ../../../contracts/solc/v0.8.24/BurnWithFromMintTokenPool/BurnWithFromMintTokenPool.abi ../../../contracts/solc/v0.8.24/BurnWithFromMintTokenPool/BurnWithFromMintTokenPool.bin 0b825a9ea058cf2c72b75996bfe0e69f92e0e36b9af674abfe8fd036f5fa1a2c
burn_from_mint_token_pool: ../../../contracts/solc/v0.8.24/BurnFromMintTokenPool/BurnFromMintTokenPool.abi ../../../contracts/solc/v0.8.24/BurnFromMintTokenPool/BurnFromMintTokenPool.bin c5640ed063d225eef245747d034a521ed71a5fc619c62efd2a3038eb477391a5
burn_mint_token_pool: ../../../contracts/solc/v0.8.24/BurnMintTokenPool/BurnMintTokenPool.abi ../../../contracts/solc/v0.8.24/BurnMintTokenPool/BurnMintTokenPool.bin 6536eb9d507197f00506b80c1bb4070e14836b4fb8ec9b2500c113ee75739349
burn_with_from_mint_token_pool: ../../../contracts/solc/v0.8.24/BurnWithFromMintTokenPool/BurnWithFromMintTokenPool.abi ../../../contracts/solc/v0.8.24/BurnWithFromMintTokenPool/BurnWithFromMintTokenPool.bin 178a8cf180296e830b282a3cf989748218990c421aa85fdb6b430efaf0abd32d
ccip_encoding_utils: ../../../contracts/solc/v0.8.24/ICCIPEncodingUtils/ICCIPEncodingUtils.abi ../../../contracts/solc/v0.8.24/ICCIPEncodingUtils/ICCIPEncodingUtils.bin 9971fc93c34442a0989570d3dab90a125de31e6e60754ad972807ce6ad4dfba0
ccip_home: ../../../contracts/solc/v0.8.24/CCIPHome/CCIPHome.abi ../../../contracts/solc/v0.8.24/CCIPHome/CCIPHome.bin 02cb75b4274a5be7f4006cf2b72cc09e77eb6dba4c1a9c720af86668ff8ea1df
ccip_reader_tester: ../../../contracts/solc/v0.8.24/CCIPReaderTester/CCIPReaderTester.abi ../../../contracts/solc/v0.8.24/CCIPReaderTester/CCIPReaderTester.bin 893c9930e874fe5235db24e28a22650c37f562da94fac93618566bcd84839fdc
ether_sender_receiver: ../../../contracts/solc/v0.8.24/EtherSenderReceiver/EtherSenderReceiver.abi ../../../contracts/solc/v0.8.24/EtherSenderReceiver/EtherSenderReceiver.bin 09510a3f773f108a3c231e8d202835c845ded862d071ec54c4f89c12d868b8de
fee_quoter: ../../../contracts/solc/v0.8.24/FeeQuoter/FeeQuoter.abi ../../../contracts/solc/v0.8.24/FeeQuoter/FeeQuoter.bin 8a0869d14bb5247fbc6d836fc20d123358373ed688e0d3b387d59e7d05496fea
lock_release_token_pool: ../../../contracts/solc/v0.8.24/LockReleaseTokenPool/LockReleaseTokenPool.abi ../../../contracts/solc/v0.8.24/LockReleaseTokenPool/LockReleaseTokenPool.bin 26dd99fa523446ff6857898d3aa14976660b4307a753de82541362a9ae33f292
lock_release_token_pool: ../../../contracts/solc/v0.8.24/LockReleaseTokenPool/LockReleaseTokenPool.abi ../../../contracts/solc/v0.8.24/LockReleaseTokenPool/LockReleaseTokenPool.bin 6257cc8f29e486b4c0129a6e287e5349c19e39009e692181f4e18d8e43bb7a1f
maybe_revert_message_receiver: ../../../contracts/solc/v0.8.24/MaybeRevertMessageReceiver/MaybeRevertMessageReceiver.abi ../../../contracts/solc/v0.8.24/MaybeRevertMessageReceiver/MaybeRevertMessageReceiver.bin d73956c26232ebcc4a5444429fa99cbefed960e323be9b5a24925885c2e477d5
message_hasher: ../../../contracts/solc/v0.8.24/MessageHasher/MessageHasher.abi ../../../contracts/solc/v0.8.24/MessageHasher/MessageHasher.bin ec2d3a92348d8e7b8f0d359b62a45157b9d2c750c01fbcf991826c4392f6e218
mock_usdc_token_messenger: ../../../contracts/solc/v0.8.24/MockE2EUSDCTokenMessenger/MockE2EUSDCTokenMessenger.abi ../../../contracts/solc/v0.8.24/MockE2EUSDCTokenMessenger/MockE2EUSDCTokenMessenger.bin d976651d36b33ac2196b32b9d2f4fa6690c6a18d41b621365659fce1c1d1e737
Expand All @@ -26,7 +26,7 @@ rmn_proxy_contract: ../../../contracts/solc/v0.8.24/ARMProxy/ARMProxy.abi ../../
rmn_remote: ../../../contracts/solc/v0.8.24/RMNRemote/RMNRemote.abi ../../../contracts/solc/v0.8.24/RMNRemote/RMNRemote.bin faee0b0cdbe67f2e28deccf12acd4df13dd90992f6cbc0ba17bab845b8f4eb1c
router: ../../../contracts/solc/v0.8.24/Router/Router.abi ../../../contracts/solc/v0.8.24/Router/Router.bin 2e4f0a7826c8abb49d882bb49fc5ff20a186dbd3137624b9097ffed903ae4888
token_admin_registry: ../../../contracts/solc/v0.8.24/TokenAdminRegistry/TokenAdminRegistry.abi ../../../contracts/solc/v0.8.24/TokenAdminRegistry/TokenAdminRegistry.bin 397bc7be08c2848c0f4715f90b16206d6367f78ffb7cd48e2b1dfc0ccc5aea26
token_pool: ../../../contracts/solc/v0.8.24/TokenPool/TokenPool.abi ../../../contracts/solc/v0.8.24/TokenPool/TokenPool.bin e2d55e56f5401e8cb52fbf4c7dbc477548b5ca2f1d6a28561ebd523f42113c55
token_pool: ../../../contracts/solc/v0.8.24/TokenPool/TokenPool.abi ../../../contracts/solc/v0.8.24/TokenPool/TokenPool.bin e38e84f2c22a6a93bd5e621ad33f050c8af0843a6ebf78b4dd64caa2245f995f
usdc_reader_tester: ../../../contracts/solc/v0.8.24/USDCReaderTester/USDCReaderTester.abi ../../../contracts/solc/v0.8.24/USDCReaderTester/USDCReaderTester.bin 672a07c9218fd6ad7c04dde583088b0f5ffc8d55a46f4be1714008dd3409438b
usdc_token_pool: ../../../contracts/solc/v0.8.24/USDCTokenPool/USDCTokenPool.abi ../../../contracts/solc/v0.8.24/USDCTokenPool/USDCTokenPool.bin 0e49d3f0a8420c81a2136dbba66ed988a8ec0e975799e7c8ba83d163bb45313a
usdc_token_pool: ../../../contracts/solc/v0.8.24/USDCTokenPool/USDCTokenPool.abi ../../../contracts/solc/v0.8.24/USDCTokenPool/USDCTokenPool.bin 9dd1b329e7207e4d19426cb4bf7564c099de1181277be4b55466b1d7c6548720
weth9: ../../../contracts/solc/v0.8.24/WETH9/WETH9.abi ../../../contracts/solc/v0.8.24/WETH9/WETH9.bin 2970d79a0ca6dd6279cde130de45e56c8790ed695eae477fb5ba4c1bb75b720d
Loading