Skip to content

Commit

Permalink
new forge fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
RensR committed Nov 28, 2024
1 parent e37f379 commit 5e7b209
Show file tree
Hide file tree
Showing 119 changed files with 1,104 additions and 368 deletions.
8 changes: 6 additions & 2 deletions contracts/src/v0.8/ccip/ARMProxy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,17 @@ contract ARMProxy is OwnerIsCreator, ITypeAndVersion {
// DYNAMIC CONFIG
address private s_arm;

constructor(address arm) {
constructor(
address arm
) {
setARM(arm);
}

/// @notice SetARM sets the ARM implementation contract address.
/// @param arm The address of the arm implementation contract.
function setARM(address arm) public onlyOwner {
function setARM(
address arm
) public onlyOwner {
if (arm == address(0)) revert ZeroAddressNotAllowed();
s_arm = arm;
emit ARMSet(arm);
Expand Down
16 changes: 12 additions & 4 deletions contracts/src/v0.8/ccip/AggregateRateLimiter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ contract AggregateRateLimiter is OwnerIsCreator {
RateLimiter.TokenBucket private s_rateLimiter;

/// @param config The RateLimiter.Config
constructor(RateLimiter.Config memory config) {
constructor(
RateLimiter.Config memory config
) {
s_rateLimiter = RateLimiter.TokenBucket({
rate: config.rate,
capacity: config.capacity,
Expand All @@ -37,7 +39,9 @@ contract AggregateRateLimiter is OwnerIsCreator {
}

/// @notice Consumes value from the rate limiter bucket based on the token value given.
function _rateLimitValue(uint256 value) internal {
function _rateLimitValue(
uint256 value
) internal {
s_rateLimiter._consume(value, address(0));
}

Expand All @@ -61,7 +65,9 @@ contract AggregateRateLimiter is OwnerIsCreator {
/// @notice Sets the rate limited config.
/// @param config The new rate limiter config.
/// @dev should only be callable by the owner or token limit admin.
function setRateLimiterConfig(RateLimiter.Config memory config) external onlyAdminOrOwner {
function setRateLimiterConfig(
RateLimiter.Config memory config
) external onlyAdminOrOwner {
s_rateLimiter._setTokenBucketConfig(config);
}

Expand All @@ -78,7 +84,9 @@ contract AggregateRateLimiter is OwnerIsCreator {
/// @notice Sets the token limit admin address.
/// @param newAdmin the address of the new admin.
/// @dev setting this to address(0) indicates there is no active admin.
function setAdmin(address newAdmin) external onlyAdminOrOwner {
function setAdmin(
address newAdmin
) external onlyAdminOrOwner {
s_admin = newAdmin;
emit AdminSet(newAdmin);
}
Expand Down
28 changes: 21 additions & 7 deletions contracts/src/v0.8/ccip/CommitStore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ contract CommitStore is ICommitStore, ITypeAndVersion, OCR2Base {
/// only if one must strictly ensure that for a given round there is only one valid report ever generated by
/// the DON. In our case additional valid reports (i.e. approved by >= f+1 oracles) are not a problem, as they will
/// will either be ignored (reverted as an invalid interval) or will be accepted as an additional valid price update.
constructor(StaticConfig memory staticConfig) OCR2Base(false) {
constructor(
StaticConfig memory staticConfig
) OCR2Base(false) {
if (
staticConfig.onRamp == address(0) || staticConfig.chainSelector == 0 || staticConfig.sourceChainSelector == 0
|| staticConfig.rmnProxy == address(0)
Expand All @@ -113,7 +115,9 @@ contract CommitStore is ICommitStore, ITypeAndVersion, OCR2Base {

/// @notice Sets the minimum sequence number.
/// @param minSeqNr The new minimum sequence number.
function setMinSeqNr(uint64 minSeqNr) external onlyOwner {
function setMinSeqNr(
uint64 minSeqNr
) external onlyOwner {
uint64 oldSeqNum = s_minSeqNr;

s_minSeqNr = minSeqNr;
Expand All @@ -129,7 +133,9 @@ contract CommitStore is ICommitStore, ITypeAndVersion, OCR2Base {

/// @notice Sets the latest epoch and round for price update.
/// @param latestPriceEpochAndRound The new epoch and round for prices.
function setLatestPriceEpochAndRound(uint40 latestPriceEpochAndRound) external onlyOwner {
function setLatestPriceEpochAndRound(
uint40 latestPriceEpochAndRound
) external onlyOwner {
uint40 oldEpochAndRound = s_latestPriceEpochAndRound;

s_latestPriceEpochAndRound = latestPriceEpochAndRound;
Expand All @@ -142,22 +148,28 @@ contract CommitStore is ICommitStore, ITypeAndVersion, OCR2Base {
/// @param root The merkle root to check the commit status for.
/// @return the timestamp of the committed root or zero in the case that it was never
/// committed.
function getMerkleRoot(bytes32 root) external view returns (uint256) {
function getMerkleRoot(
bytes32 root
) external view returns (uint256) {
return s_roots[root];
}

/// @notice Returns if a root is blessed or not.
/// @param root The merkle root to check the blessing status for.
/// @return whether the root is blessed or not.
function isBlessed(bytes32 root) public view returns (bool) {
function isBlessed(
bytes32 root
) public view returns (bool) {
return IRMN(i_rmnProxy).isBlessed(IRMN.TaggedRoot({commitStore: address(this), root: root}));
}

/// @notice Used by the owner in case an invalid sequence of roots has been
/// posted and needs to be removed. The interval in the report is trusted.
/// @param rootToReset The roots that will be reset. This function will only
/// reset roots that are not blessed.
function resetUnblessedRoots(bytes32[] calldata rootToReset) external onlyOwner {
function resetUnblessedRoots(
bytes32[] calldata rootToReset
) external onlyOwner {
for (uint256 i = 0; i < rootToReset.length; ++i) {
bytes32 root = rootToReset[i];
if (!isBlessed(root)) {
Expand Down Expand Up @@ -255,7 +267,9 @@ contract CommitStore is ICommitStore, ITypeAndVersion, OCR2Base {
}

/// @notice Sets the dynamic config. This function is called during `setOCR2Config` flow
function _beforeSetConfig(bytes memory onchainConfig) internal override {
function _beforeSetConfig(
bytes memory onchainConfig
) internal override {
DynamicConfig memory dynamicConfig = abi.decode(onchainConfig, (DynamicConfig));

if (dynamicConfig.priceRegistry == address(0)) revert InvalidCommitStoreConfig();
Expand Down
48 changes: 36 additions & 12 deletions contracts/src/v0.8/ccip/FeeQuoter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,9 @@ contract FeeQuoter is AuthorizedCallers, IFeeQuoter, ITypeAndVersion, IReceiver,
// ================================================================

/// @inheritdoc IPriceRegistry
function getTokenPrice(address token) public view override returns (Internal.TimestampedPackedUint224 memory) {
function getTokenPrice(
address token
) public view override returns (Internal.TimestampedPackedUint224 memory) {
Internal.TimestampedPackedUint224 memory tokenPrice = s_usdPerToken[token];

// If the token price is not stale, return it
Expand All @@ -261,14 +263,18 @@ contract FeeQuoter is AuthorizedCallers, IFeeQuoter, ITypeAndVersion, IReceiver,
/// @notice Get the `tokenPrice` for a given token, checks if the price is valid.
/// @param token The token to get the price for.
/// @return tokenPrice The tokenPrice for the given token if it exists and is valid.
function getValidatedTokenPrice(address token) external view returns (uint224) {
function getValidatedTokenPrice(
address token
) external view returns (uint224) {
return _getValidatedTokenPrice(token);
}

/// @notice Get the `tokenPrice` for an array of tokens.
/// @param tokens The tokens to get prices for.
/// @return tokenPrices The tokenPrices for the given tokens.
function getTokenPrices(address[] calldata tokens) external view returns (Internal.TimestampedPackedUint224[] memory) {
function getTokenPrices(
address[] calldata tokens
) external view returns (Internal.TimestampedPackedUint224[] memory) {
uint256 length = tokens.length;
Internal.TimestampedPackedUint224[] memory tokenPrices = new Internal.TimestampedPackedUint224[](length);
for (uint256 i = 0; i < length; ++i) {
Expand All @@ -280,7 +286,9 @@ contract FeeQuoter is AuthorizedCallers, IFeeQuoter, ITypeAndVersion, IReceiver,
/// @notice Returns the token price data feed configuration
/// @param token The token to retrieve the feed config for
/// @return tokenPriceFeedConfig The token price data feed config (if feed address is 0, the feed config is disabled)
function getTokenPriceFeedConfig(address token) external view returns (TokenPriceFeedConfig memory) {
function getTokenPriceFeedConfig(
address token
) external view returns (TokenPriceFeedConfig memory) {
return s_usdPriceFeedsPerToken[token];
}

Expand Down Expand Up @@ -338,7 +346,9 @@ contract FeeQuoter is AuthorizedCallers, IFeeQuoter, ITypeAndVersion, IReceiver,
/// @notice Gets the token price for a given token and reverts if the token is not supported
/// @param token The address of the token to get the price for
/// @return tokenPriceValue The token price
function _getValidatedTokenPrice(address token) internal view returns (uint224) {
function _getValidatedTokenPrice(
address token
) internal view returns (uint224) {
Internal.TimestampedPackedUint224 memory tokenPrice = getTokenPrice(token);
// Token price must be set at least once
if (tokenPrice.timestamp == 0 || tokenPrice.value == 0) revert TokenNotSupported(token);
Expand Down Expand Up @@ -436,7 +446,9 @@ contract FeeQuoter is AuthorizedCallers, IFeeQuoter, ITypeAndVersion, IReceiver,
// ================================================================

/// @inheritdoc IPriceRegistry
function updatePrices(Internal.PriceUpdates calldata priceUpdates) external override {
function updatePrices(
Internal.PriceUpdates calldata priceUpdates
) external override {
// The caller must be the fee updater
_validateCaller();

Expand All @@ -461,13 +473,17 @@ contract FeeQuoter is AuthorizedCallers, IFeeQuoter, ITypeAndVersion, IReceiver,

/// @notice Updates the USD token price feeds for given tokens
/// @param tokenPriceFeedUpdates Token price feed updates to apply
function updateTokenPriceFeeds(TokenPriceFeedUpdate[] memory tokenPriceFeedUpdates) external onlyOwner {
function updateTokenPriceFeeds(
TokenPriceFeedUpdate[] memory tokenPriceFeedUpdates
) external onlyOwner {
_updateTokenPriceFeeds(tokenPriceFeedUpdates);
}

/// @notice Updates the USD token price feeds for given tokens
/// @param tokenPriceFeedUpdates Token price feed updates to apply
function _updateTokenPriceFeeds(TokenPriceFeedUpdate[] memory tokenPriceFeedUpdates) private {
function _updateTokenPriceFeeds(
TokenPriceFeedUpdate[] memory tokenPriceFeedUpdates
) private {
for (uint256 i; i < tokenPriceFeedUpdates.length; ++i) {
TokenPriceFeedUpdate memory update = tokenPriceFeedUpdates[i];
address sourceToken = update.sourceToken;
Expand Down Expand Up @@ -607,7 +623,9 @@ contract FeeQuoter is AuthorizedCallers, IFeeQuoter, ITypeAndVersion, IReceiver,
/// @notice Gets the fee configuration for a token.
/// @param token The token to get the fee configuration for.
/// @return premiumMultiplierWeiPerEth The multiplier for destination chain specific premiums.
function getPremiumMultiplierWeiPerEth(address token) external view returns (uint64 premiumMultiplierWeiPerEth) {
function getPremiumMultiplierWeiPerEth(
address token
) external view returns (uint64 premiumMultiplierWeiPerEth) {
return s_premiumMultiplierWeiPerEth[token];
}

Expand Down Expand Up @@ -967,18 +985,24 @@ contract FeeQuoter is AuthorizedCallers, IFeeQuoter, ITypeAndVersion, IReceiver,
/// @notice Returns the configured config for the dest chain selector.
/// @param destChainSelector Destination chain selector to fetch config for.
/// @return destChainConfig Config for the destination chain.
function getDestChainConfig(uint64 destChainSelector) external view returns (DestChainConfig memory) {
function getDestChainConfig(
uint64 destChainSelector
) external view returns (DestChainConfig memory) {
return s_destChainConfigs[destChainSelector];
}

/// @notice Updates the destination chain specific config.
/// @param destChainConfigArgs Array of source chain specific configs.
function applyDestChainConfigUpdates(DestChainConfigArgs[] memory destChainConfigArgs) external onlyOwner {
function applyDestChainConfigUpdates(
DestChainConfigArgs[] memory destChainConfigArgs
) external onlyOwner {
_applyDestChainConfigUpdates(destChainConfigArgs);
}

/// @notice Internal version of applyDestChainConfigUpdates.
function _applyDestChainConfigUpdates(DestChainConfigArgs[] memory destChainConfigArgs) internal {
function _applyDestChainConfigUpdates(
DestChainConfigArgs[] memory destChainConfigArgs
) internal {
for (uint256 i = 0; i < destChainConfigArgs.length; ++i) {
DestChainConfigArgs memory destChainConfigArg = destChainConfigArgs[i];
uint64 destChainSelector = destChainConfigArgs[i].destChainSelector;
Expand Down
20 changes: 15 additions & 5 deletions contracts/src/v0.8/ccip/MultiAggregateRateLimiter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ contract MultiAggregateRateLimiter is IMessageInterceptor, AuthorizedCallers, IT
}

/// @inheritdoc IMessageInterceptor
function onInboundMessage(Client.Any2EVMMessage memory message) external onlyAuthorizedCallers {
function onInboundMessage(
Client.Any2EVMMessage memory message
) external onlyAuthorizedCallers {
_applyRateLimit(message.sourceChainSelector, message.destTokenAmounts, false);
}

Expand Down Expand Up @@ -130,7 +132,9 @@ contract MultiAggregateRateLimiter is IMessageInterceptor, AuthorizedCallers, IT
/// @notice Retrieves the token value for a token using the FeeQuoter.
/// @param tokenAmount The token and amount to get the value for.
/// @return tokenValue USD value in 18 decimals.
function _getTokenValue(Client.EVMTokenAmount memory tokenAmount) internal view returns (uint256) {
function _getTokenValue(
Client.EVMTokenAmount memory tokenAmount
) internal view returns (uint256) {
// not fetching validated price, as price staleness is not important for value-based rate limiting
// we only need to verify the price is not 0
uint224 pricePerToken = IFeeQuoter(s_feeQuoter).getTokenPrice(tokenAmount.token).value;
Expand All @@ -154,7 +158,9 @@ contract MultiAggregateRateLimiter is IMessageInterceptor, AuthorizedCallers, IT
/// @notice Applies the provided rate limiter config updates.
/// @param rateLimiterUpdates Rate limiter updates.
/// @dev Only callable by the owner.
function applyRateLimiterConfigUpdates(RateLimiterConfigArgs[] memory rateLimiterUpdates) external onlyOwner {
function applyRateLimiterConfigUpdates(
RateLimiterConfigArgs[] memory rateLimiterUpdates
) external onlyOwner {
for (uint256 i = 0; i < rateLimiterUpdates.length; ++i) {
RateLimiterConfigArgs memory updateArgs = rateLimiterUpdates[i];
RateLimiter.Config memory configUpdate = updateArgs.rateLimiterConfig;
Expand Down Expand Up @@ -253,14 +259,18 @@ contract MultiAggregateRateLimiter is IMessageInterceptor, AuthorizedCallers, IT
/// @notice Sets the FeeQuoter address.
/// @param newFeeQuoter the address of the new FeeQuoter.
/// @dev precondition The address must be a non-zero address.
function setFeeQuoter(address newFeeQuoter) external onlyOwner {
function setFeeQuoter(
address newFeeQuoter
) external onlyOwner {
_setFeeQuoter(newFeeQuoter);
}

/// @notice Sets the FeeQuoter address.
/// @param newFeeQuoter the address of the new FeeQuoter.
/// @dev precondition The address must be a non-zero address.
function _setFeeQuoter(address newFeeQuoter) internal {
function _setFeeQuoter(
address newFeeQuoter
) internal {
if (newFeeQuoter == address(0)) {
revert ZeroAddressNotAllowed();
}
Expand Down
12 changes: 9 additions & 3 deletions contracts/src/v0.8/ccip/NonceManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ contract NonceManager is INonceManager, AuthorizedCallers, ITypeAndVersion {
/// executed in the same order they are sent (assuming they are DON)
mapping(uint64 sourceChainSelector => mapping(bytes sender => uint64 inboundNonce)) private s_inboundNonces;

constructor(address[] memory authorizedCallers) AuthorizedCallers(authorizedCallers) {}
constructor(
address[] memory authorizedCallers
) AuthorizedCallers(authorizedCallers) {}

/// @inheritdoc INonceManager
function getIncrementedOutboundNonce(
Expand Down Expand Up @@ -123,7 +125,9 @@ contract NonceManager is INonceManager, AuthorizedCallers, ITypeAndVersion {

/// @notice Updates the previous ramps addresses.
/// @param previousRampsArgs The previous on/off ramps addresses.
function applyPreviousRampsUpdates(PreviousRampsArgs[] calldata previousRampsArgs) external onlyOwner {
function applyPreviousRampsUpdates(
PreviousRampsArgs[] calldata previousRampsArgs
) external onlyOwner {
for (uint256 i = 0; i < previousRampsArgs.length; ++i) {
PreviousRampsArgs calldata previousRampsArg = previousRampsArgs[i];

Expand All @@ -146,7 +150,9 @@ contract NonceManager is INonceManager, AuthorizedCallers, ITypeAndVersion {
/// @notice Gets the previous onRamp address for the given chain selector
/// @param chainSelector The chain selector
/// @return previousRamps The previous on/offRamp addresses
function getPreviousRamps(uint64 chainSelector) external view returns (PreviousRamps memory) {
function getPreviousRamps(
uint64 chainSelector
) external view returns (PreviousRamps memory) {
return s_previousRamps[chainSelector];
}
}
Loading

0 comments on commit 5e7b209

Please sign in to comment.