Skip to content

Commit

Permalink
feat: remove struct input for rate limit
Browse files Browse the repository at this point in the history
  • Loading branch information
CheyenneAtapour committed Jul 23, 2024
1 parent 242aa04 commit 01acca6
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 26 deletions.
20 changes: 16 additions & 4 deletions src/contracts/misc/ArbGhoSteward.sol
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,25 @@ contract ArbGhoSteward is Ownable, IArbGhoSteward {
/// @inheritdoc IArbGhoSteward
function updateRateLimit(
uint64 remoteChainSelector,
RateLimiter.Config calldata outboundConfig,
RateLimiter.Config calldata inboundConfig
bool outboundEnabled,
uint128 outboundCapacity,
uint128 outboundRate,
bool inboundEnabled,
uint128 inboundCapacity,
uint128 inboundRate
) external onlyRiskCouncil {
UpgradeableBurnMintTokenPool(GHO_TOKEN_POOL).setChainRateLimiterConfig(
remoteChainSelector,
outboundConfig,
inboundConfig
RateLimiter.Config({
isEnabled: outboundEnabled,
capacity: outboundCapacity,
rate: outboundRate
}),
RateLimiter.Config({
isEnabled: inboundEnabled,
capacity: inboundCapacity,
rate: inboundRate
})
);
}

Expand Down
20 changes: 16 additions & 4 deletions src/contracts/misc/GhoStewardV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -243,13 +243,25 @@ contract GhoStewardV2 is Ownable, IGhoStewardV2 {
/// @inheritdoc IGhoStewardV2
function updateRateLimit(
uint64 remoteChainSelector,
RateLimiter.Config calldata outboundConfig,
RateLimiter.Config calldata inboundConfig
bool outboundEnabled,
uint128 outboundCapacity,
uint128 outboundRate,
bool inboundEnabled,
uint128 inboundCapacity,
uint128 inboundRate
) external onlyRiskCouncil {
UpgradeableLockReleaseTokenPool(GHO_TOKEN_POOL).setChainRateLimiterConfig(
remoteChainSelector,
outboundConfig,
inboundConfig
RateLimiter.Config({
isEnabled: outboundEnabled,
capacity: outboundCapacity,
rate: outboundRate
}),
RateLimiter.Config({
isEnabled: inboundEnabled,
capacity: inboundCapacity,
rate: inboundRate
})
);
}

Expand Down
16 changes: 12 additions & 4 deletions src/contracts/misc/interfaces/IArbGhoSteward.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,21 @@ interface IArbGhoSteward {
* @notice Updates the CCIP rate limit config
* @dev Only callable by Risk Council
* @param remoteChainSelector The remote chain selector for which the rate limits apply.
* @param outboundConfig The new outbound rate limiter config.
* @param inboundConfig The new inbound rate limiter config.
* @param outboundEnabled True if the outbound rate limiter is enabled.
* @param outboundCapacity The outbound rate limiter capacity.
* @param outboundRate The outbound rate limiter rate.
* @param inboundEnabled True if the inbound rate limiter is enabled.
* @param inboundCapacity The inbound rate limiter capacity.
* @param inboundRate The inbound rate limiter rate.
*/
function updateRateLimit(
uint64 remoteChainSelector,
RateLimiter.Config calldata outboundConfig,
RateLimiter.Config calldata inboundConfig
bool outboundEnabled,
uint128 outboundCapacity,
uint128 outboundRate,
bool inboundEnabled,
uint128 inboundCapacity,
uint128 inboundRate
) external;

/**
Expand Down
16 changes: 12 additions & 4 deletions src/contracts/misc/interfaces/IGhoStewardV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,21 @@ interface IGhoStewardV2 {
* @notice Updates the CCIP rate limit config
* @dev Only callable by Risk Council
* @param remoteChainSelector The remote chain selector for which the rate limits apply.
* @param outboundConfig The new outbound rate limiter config.
* @param inboundConfig The new inbound rate limiter config.
* @param outboundEnabled True if the outbound rate limiter is enabled.
* @param outboundCapacity The outbound rate limiter capacity.
* @param outboundRate The outbound rate limiter rate.
* @param inboundEnabled True if the inbound rate limiter is enabled.
* @param inboundCapacity The inbound rate limiter capacity.
* @param inboundRate The inbound rate limiter rate.
*/
function updateRateLimit(
uint64 remoteChainSelector,
RateLimiter.Config calldata outboundConfig,
RateLimiter.Config calldata inboundConfig
bool outboundEnabled,
uint128 outboundCapacity,
uint128 outboundRate,
bool inboundEnabled,
uint128 inboundCapacity,
uint128 inboundRate
) external;

/**
Expand Down
18 changes: 14 additions & 4 deletions src/test/TestArbGhoSteward.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import {RateLimiter} from 'src/contracts/misc/deps/Dependencies.sol';
contract TestArbGhoSteward is TestGhoBase {
using ReserveConfiguration for DataTypes.ReserveConfigurationMap;

RateLimiter.Config rateLimitConfig = RateLimiter.Config({isEnabled: true, capacity: type(uint128).max, rate: 1e15});

event ChainConfigured(
uint64 remoteChainSelector,
RateLimiter.Config outboundRateLimiterConfig,
Expand Down Expand Up @@ -125,8 +127,12 @@ contract TestArbGhoSteward is TestGhoBase {
vm.prank(RISK_COUNCIL);
ARB_GHO_STEWARD.updateRateLimit(
2,
RateLimiter.Config({isEnabled: true, capacity: type(uint128).max, rate: 1e15}),
RateLimiter.Config({isEnabled: true, capacity: type(uint128).max, rate: 1e15})
rateLimitConfig.isEnabled,
rateLimitConfig.capacity,
rateLimitConfig.rate,
rateLimitConfig.isEnabled,
rateLimitConfig.capacity,
rateLimitConfig.rate
);
}

Expand All @@ -135,8 +141,12 @@ contract TestArbGhoSteward is TestGhoBase {
vm.expectRevert('INVALID_CALLER');
ARB_GHO_STEWARD.updateRateLimit(
2,
RateLimiter.Config({isEnabled: true, capacity: type(uint128).max, rate: 1e15}),
RateLimiter.Config({isEnabled: true, capacity: type(uint128).max, rate: 1e15})
rateLimitConfig.isEnabled,
rateLimitConfig.capacity,
rateLimitConfig.rate,
rateLimitConfig.isEnabled,
rateLimitConfig.capacity,
rateLimitConfig.rate
);
}

Expand Down
22 changes: 16 additions & 6 deletions src/test/TestGhoStewardV2.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import {RateLimiter} from '../contracts/misc/deps/Dependencies.sol';
contract TestGhoStewardV2 is TestGhoBase {
using ReserveConfiguration for DataTypes.ReserveConfigurationMap;

RateLimiter.Config rateLimitConfig = RateLimiter.Config({isEnabled: true, capacity: type(uint128).max, rate: 1e15});

event ChainConfigured(
uint64 remoteChainSelector,
RateLimiter.Config outboundRateLimiterConfig,
Expand Down Expand Up @@ -863,14 +865,18 @@ contract TestGhoStewardV2 is TestGhoBase {
vm.expectEmit(false, false, false, true);
emit ChainConfigured(
2,
RateLimiter.Config({isEnabled: true, capacity: type(uint128).max, rate: 1e15}),
RateLimiter.Config({isEnabled: true, capacity: type(uint128).max, rate: 1e15})
rateLimitConfig,
rateLimitConfig
);
vm.prank(RISK_COUNCIL);
GHO_STEWARD_V2.updateRateLimit(
2,
RateLimiter.Config({isEnabled: true, capacity: type(uint128).max, rate: 1e15}),
RateLimiter.Config({isEnabled: true, capacity: type(uint128).max, rate: 1e15})
rateLimitConfig.isEnabled,
rateLimitConfig.capacity,
rateLimitConfig.rate,
rateLimitConfig.isEnabled,
rateLimitConfig.capacity,
rateLimitConfig.rate
);
}

Expand All @@ -879,8 +885,12 @@ contract TestGhoStewardV2 is TestGhoBase {
vm.expectRevert('INVALID_CALLER');
GHO_STEWARD_V2.updateRateLimit(
2,
RateLimiter.Config({isEnabled: true, capacity: type(uint128).max, rate: 1e15}),
RateLimiter.Config({isEnabled: true, capacity: type(uint128).max, rate: 1e15})
rateLimitConfig.isEnabled,
rateLimitConfig.capacity,
rateLimitConfig.rate,
rateLimitConfig.isEnabled,
rateLimitConfig.capacity,
rateLimitConfig.rate
);
}

Expand Down

0 comments on commit 01acca6

Please sign in to comment.