Skip to content

Commit

Permalink
Add missing type and version (#1243)
Browse files Browse the repository at this point in the history
## Motivation
`NonceManager` and `MultiAggregateRateLimiter` contracts were missing
`typeAndVersion`.

## Solution
Add `ITypeAndVersion` inheritance to both contracts.
  • Loading branch information
RayXpub authored Aug 1, 2024
1 parent 274e933 commit 59ac4e4
Show file tree
Hide file tree
Showing 8 changed files with 105 additions and 36 deletions.
57 changes: 29 additions & 28 deletions contracts/gas-snapshots/ccip.gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ EVM2EVMMultiOffRamp_ccipReceive:test_Reverts() (gas: 15662)
EVM2EVMMultiOffRamp_commit:test_InvalidIntervalMinLargerThanMax_Revert() (gas: 67195)
EVM2EVMMultiOffRamp_commit:test_InvalidInterval_Revert() (gas: 59698)
EVM2EVMMultiOffRamp_commit:test_InvalidRootRevert() (gas: 58778)
EVM2EVMMultiOffRamp_commit:test_NoConfigWithOtherConfigPresent_Revert() (gas: 6394741)
EVM2EVMMultiOffRamp_commit:test_NoConfig_Revert() (gas: 5977968)
EVM2EVMMultiOffRamp_commit:test_NoConfigWithOtherConfigPresent_Revert() (gas: 6394807)
EVM2EVMMultiOffRamp_commit:test_NoConfig_Revert() (gas: 5978034)
EVM2EVMMultiOffRamp_commit:test_OnlyGasPriceUpdates_Success() (gas: 106229)
EVM2EVMMultiOffRamp_commit:test_OnlyPriceUpdateStaleReport_Revert() (gas: 116228)
EVM2EVMMultiOffRamp_commit:test_OnlyTokenPriceUpdates_Success() (gas: 106272)
Expand All @@ -156,7 +156,7 @@ EVM2EVMMultiOffRamp_commit:test_StaleReportWithRoot_Success() (gas: 227807)
EVM2EVMMultiOffRamp_commit:test_UnauthorizedTransmitter_Revert() (gas: 117527)
EVM2EVMMultiOffRamp_commit:test_Unhealthy_Revert() (gas: 77605)
EVM2EVMMultiOffRamp_commit:test_ValidPriceUpdateThenStaleReportWithRoot_Success() (gas: 207057)
EVM2EVMMultiOffRamp_commit:test_WrongConfigWithoutSigners_Revert() (gas: 6389130)
EVM2EVMMultiOffRamp_commit:test_WrongConfigWithoutSigners_Revert() (gas: 6389196)
EVM2EVMMultiOffRamp_commit:test_ZeroEpochAndRound_Revert() (gas: 47785)
EVM2EVMMultiOffRamp_constructor:test_Constructor_Success() (gas: 5980336)
EVM2EVMMultiOffRamp_constructor:test_SourceChainSelector_Revert() (gas: 157326)
Expand All @@ -169,12 +169,12 @@ EVM2EVMMultiOffRamp_execute:test_IncorrectArrayType_Revert() (gas: 17280)
EVM2EVMMultiOffRamp_execute:test_LargeBatch_Success() (gas: 1559406)
EVM2EVMMultiOffRamp_execute:test_MultipleReportsWithPartialValidationFailures_Success() (gas: 342924)
EVM2EVMMultiOffRamp_execute:test_MultipleReports_Success() (gas: 260178)
EVM2EVMMultiOffRamp_execute:test_NoConfigWithOtherConfigPresent_Revert() (gas: 6445247)
EVM2EVMMultiOffRamp_execute:test_NoConfig_Revert() (gas: 6028193)
EVM2EVMMultiOffRamp_execute:test_NoConfigWithOtherConfigPresent_Revert() (gas: 6445313)
EVM2EVMMultiOffRamp_execute:test_NoConfig_Revert() (gas: 6028259)
EVM2EVMMultiOffRamp_execute:test_NonArray_Revert() (gas: 27681)
EVM2EVMMultiOffRamp_execute:test_SingleReport_Success() (gas: 165181)
EVM2EVMMultiOffRamp_execute:test_UnauthorizedTransmitter_Revert() (gas: 149137)
EVM2EVMMultiOffRamp_execute:test_WrongConfigWithSigners_Revert() (gas: 6807322)
EVM2EVMMultiOffRamp_execute:test_WrongConfigWithSigners_Revert() (gas: 6807388)
EVM2EVMMultiOffRamp_execute:test_ZeroReports_Revert() (gas: 17154)
EVM2EVMMultiOffRamp_executeSingleMessage:test_MessageSender_Revert() (gas: 18413)
EVM2EVMMultiOffRamp_executeSingleMessage:test_NonContractWithTokens_Success() (gas: 249346)
Expand Down Expand Up @@ -526,42 +526,42 @@ MultiAggregateRateLimiter_applyRateLimiterConfigUpdates:test_UpdateExistingConfi
MultiAggregateRateLimiter_applyRateLimiterConfigUpdates:test_UpdateExistingConfig_Success() (gas: 53092)
MultiAggregateRateLimiter_applyRateLimiterConfigUpdates:test_ZeroChainSelector_Revert() (gas: 17019)
MultiAggregateRateLimiter_applyRateLimiterConfigUpdates:test_ZeroConfigs_Success() (gas: 12295)
MultiAggregateRateLimiter_constructor:test_ConstructorNoAuthorizedCallers_Success() (gas: 1971805)
MultiAggregateRateLimiter_constructor:test_Constructor_Success() (gas: 2085252)
MultiAggregateRateLimiter_constructor:test_ConstructorNoAuthorizedCallers_Success() (gas: 2006714)
MultiAggregateRateLimiter_constructor:test_Constructor_Success() (gas: 2122927)
MultiAggregateRateLimiter_getTokenBucket:test_GetTokenBucket_Success() (gas: 30248)
MultiAggregateRateLimiter_getTokenBucket:test_Refill_Success() (gas: 47358)
MultiAggregateRateLimiter_getTokenBucket:test_TimeUnderflow_Revert() (gas: 15821)
MultiAggregateRateLimiter_getTokenValue:test_GetTokenValue_Success() (gas: 19668)
MultiAggregateRateLimiter_getTokenValue:test_NoTokenPrice_Reverts() (gas: 21253)
MultiAggregateRateLimiter_getTokenValue:test_GetTokenValue_Success() (gas: 19690)
MultiAggregateRateLimiter_getTokenValue:test_NoTokenPrice_Reverts() (gas: 21275)
MultiAggregateRateLimiter_onInboundMessage:test_ValidateMessageFromUnauthorizedCaller_Revert() (gas: 14527)
MultiAggregateRateLimiter_onInboundMessage:test_ValidateMessageWithDifferentTokensOnDifferentChains_Success() (gas: 189450)
MultiAggregateRateLimiter_onInboundMessage:test_ValidateMessageWithDisabledRateLimitToken_Success() (gas: 59927)
MultiAggregateRateLimiter_onInboundMessage:test_ValidateMessageWithDifferentTokensOnDifferentChains_Success() (gas: 189472)
MultiAggregateRateLimiter_onInboundMessage:test_ValidateMessageWithDisabledRateLimitToken_Success() (gas: 59949)
MultiAggregateRateLimiter_onInboundMessage:test_ValidateMessageWithNoTokens_Success() (gas: 17593)
MultiAggregateRateLimiter_onInboundMessage:test_ValidateMessageWithRateLimitDisabled_Success() (gas: 44895)
MultiAggregateRateLimiter_onInboundMessage:test_ValidateMessageWithRateLimitExceeded_Revert() (gas: 50598)
MultiAggregateRateLimiter_onInboundMessage:test_ValidateMessageWithRateLimitReset_Success() (gas: 78780)
MultiAggregateRateLimiter_onInboundMessage:test_ValidateMessageWithTokensOnDifferentChains_Success() (gas: 263510)
MultiAggregateRateLimiter_onInboundMessage:test_ValidateMessageWithTokensOnDifferentChains_Success() (gas: 263532)
MultiAggregateRateLimiter_onInboundMessage:test_ValidateMessageWithTokens_Success() (gas: 54784)
MultiAggregateRateLimiter_onOutboundMessage:test_RateLimitValueDifferentLanes_Success() (gas: 9223372036854754743)
MultiAggregateRateLimiter_onOutboundMessage:test_ValidateMessageWithNoTokens_Success() (gas: 19104)
MultiAggregateRateLimiter_onOutboundMessage:test_onOutboundMessage_ValidateMessageFromUnauthorizedCaller_Revert() (gas: 15778)
MultiAggregateRateLimiter_onOutboundMessage:test_onOutboundMessage_ValidateMessageWithDifferentTokensOnDifferentChains_Success() (gas: 189438)
MultiAggregateRateLimiter_onOutboundMessage:test_onOutboundMessage_ValidateMessageWithDisabledRateLimitToken_Success() (gas: 61662)
MultiAggregateRateLimiter_onOutboundMessage:test_onOutboundMessage_ValidateMessageWithDifferentTokensOnDifferentChains_Success() (gas: 189460)
MultiAggregateRateLimiter_onOutboundMessage:test_onOutboundMessage_ValidateMessageWithDisabledRateLimitToken_Success() (gas: 61684)
MultiAggregateRateLimiter_onOutboundMessage:test_onOutboundMessage_ValidateMessageWithRateLimitDisabled_Success() (gas: 46683)
MultiAggregateRateLimiter_onOutboundMessage:test_onOutboundMessage_ValidateMessageWithRateLimitExceeded_Revert() (gas: 52371)
MultiAggregateRateLimiter_onOutboundMessage:test_onOutboundMessage_ValidateMessageWithRateLimitReset_Success() (gas: 79845)
MultiAggregateRateLimiter_onOutboundMessage:test_onOutboundMessage_ValidateMessageWithTokensOnDifferentChains_Success() (gas: 263724)
MultiAggregateRateLimiter_onOutboundMessage:test_onOutboundMessage_ValidateMessageWithTokensOnDifferentChains_Success() (gas: 263746)
MultiAggregateRateLimiter_onOutboundMessage:test_onOutboundMessage_ValidateMessageWithTokens_Success() (gas: 56541)
MultiAggregateRateLimiter_setPriceRegistry:test_OnlyOwner_Revert() (gas: 11336)
MultiAggregateRateLimiter_setPriceRegistry:test_Owner_Success() (gas: 19124)
MultiAggregateRateLimiter_setPriceRegistry:test_ZeroAddress_Revert() (gas: 10608)
MultiAggregateRateLimiter_updateRateLimitTokens:test_NonOwner_Revert() (gas: 16085)
MultiAggregateRateLimiter_updateRateLimitTokens:test_UpdateRateLimitTokensMultipleChains_Success() (gas: 225643)
MultiAggregateRateLimiter_updateRateLimitTokens:test_UpdateRateLimitTokensSingleChain_Success() (gas: 200192)
MultiAggregateRateLimiter_updateRateLimitTokens:test_UpdateRateLimitTokens_AddsAndRemoves_Success() (gas: 162053)
MultiAggregateRateLimiter_updateRateLimitTokens:test_UpdateRateLimitTokens_RemoveNonExistentToken_Success() (gas: 28509)
MultiAggregateRateLimiter_updateRateLimitTokens:test_ZeroDestToken_Revert() (gas: 17430)
MultiAggregateRateLimiter_updateRateLimitTokens:test_ZeroSourceToken_Revert() (gas: 17485)
MultiAggregateRateLimiter_setPriceRegistry:test_OnlyOwner_Revert() (gas: 11358)
MultiAggregateRateLimiter_setPriceRegistry:test_Owner_Success() (gas: 19146)
MultiAggregateRateLimiter_setPriceRegistry:test_ZeroAddress_Revert() (gas: 10630)
MultiAggregateRateLimiter_updateRateLimitTokens:test_NonOwner_Revert() (gas: 16107)
MultiAggregateRateLimiter_updateRateLimitTokens:test_UpdateRateLimitTokensMultipleChains_Success() (gas: 225533)
MultiAggregateRateLimiter_updateRateLimitTokens:test_UpdateRateLimitTokensSingleChain_Success() (gas: 200148)
MultiAggregateRateLimiter_updateRateLimitTokens:test_UpdateRateLimitTokens_AddsAndRemoves_Success() (gas: 162036)
MultiAggregateRateLimiter_updateRateLimitTokens:test_UpdateRateLimitTokens_RemoveNonExistentToken_Success() (gas: 28465)
MultiAggregateRateLimiter_updateRateLimitTokens:test_ZeroDestToken_Revert() (gas: 17452)
MultiAggregateRateLimiter_updateRateLimitTokens:test_ZeroSourceToken_Revert() (gas: 17507)
MultiOCR3Base_setOCR3Configs:test_FMustBePositive_Revert() (gas: 59331)
MultiOCR3Base_setOCR3Configs:test_FTooHigh_Revert() (gas: 44298)
MultiOCR3Base_setOCR3Configs:test_RepeatSignerAddress_Revert() (gas: 283711)
Expand Down Expand Up @@ -609,12 +609,13 @@ NonceManager_OnRampUpgrade:test_UpgradeNonceNewSenderStartsAtZero_Success() (gas
NonceManager_OnRampUpgrade:test_UpgradeNonceStartsAtV1Nonce_Success() (gas: 237762)
NonceManager_OnRampUpgrade:test_UpgradeSenderNoncesReadsPreviousRamp_Success() (gas: 125070)
NonceManager_OnRampUpgrade:test_Upgrade_Success() (gas: 125923)
NonceManager_applyPreviousRampsUpdates:test_MultipleRampsUpdates() (gas: 122899)
NonceManager_applyPreviousRampsUpdates:test_MultipleRampsUpdates() (gas: 122943)
NonceManager_applyPreviousRampsUpdates:test_PreviousRampAlreadySetOffRamp_Revert() (gas: 42959)
NonceManager_applyPreviousRampsUpdates:test_PreviousRampAlreadySetOnRampAndOffRamp_Revert() (gas: 64282)
NonceManager_applyPreviousRampsUpdates:test_PreviousRampAlreadySetOnRamp_Revert() (gas: 42823)
NonceManager_applyPreviousRampsUpdates:test_SingleRampUpdate() (gas: 66548)
NonceManager_applyPreviousRampsUpdates:test_SingleRampUpdate() (gas: 66570)
NonceManager_applyPreviousRampsUpdates:test_ZeroInput() (gas: 12025)
NonceManager_typeAndVersion:test_typeAndVersion() (gas: 9675)
OCR2BaseNoChecks_setOCR2Config:test_FMustBePositive_Revert() (gas: 12171)
OCR2BaseNoChecks_setOCR2Config:test_RepeatAddress_Revert() (gas: 42233)
OCR2BaseNoChecks_setOCR2Config:test_SetConfigSuccess_gas() (gas: 84124)
Expand Down
5 changes: 4 additions & 1 deletion contracts/src/v0.8/ccip/MultiAggregateRateLimiter.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.24;

import {ITypeAndVersion} from "../shared/interfaces/ITypeAndVersion.sol";
import {IMessageInterceptor} from "./interfaces/IMessageInterceptor.sol";
import {IPriceRegistry} from "./interfaces/IPriceRegistry.sol";

Expand All @@ -17,7 +18,7 @@ import {EnumerableSet} from "./../vendor/openzeppelin-solidity/v4.7.3/contracts/
/// token transfers, using a price registry to convert to a numeraire asset (e.g. USD).
/// The contract is a standalone multi-lane message validator contract, which can be called by authorized
/// ramp contracts to apply rate limit changes to lanes, and revert when the rate limits get breached.
contract MultiAggregateRateLimiter is IMessageInterceptor, AuthorizedCallers {
contract MultiAggregateRateLimiter is IMessageInterceptor, AuthorizedCallers, ITypeAndVersion {
using RateLimiter for RateLimiter.TokenBucket;
using USDPriceWith18Decimals for uint224;
using EnumerableMapAddresses for EnumerableMapAddresses.AddressToBytes32Map;
Expand Down Expand Up @@ -57,6 +58,8 @@ contract MultiAggregateRateLimiter is IMessageInterceptor, AuthorizedCallers {
RateLimiter.TokenBucket outboundLaneBucket; // Bucket for the outbound lane (local -> remote)
}

string public constant override typeAndVersion = "MultiAggregateRateLimiter 1.6.0-dev";

/// @dev Tokens that should be included in Aggregate Rate Limiting (from local chain (this chain) -> remote),
/// grouped per-remote chain.
mapping(uint64 remoteChainSelector => EnumerableMapAddresses.AddressToBytes32Map tokensLocalToRemote) internal
Expand Down
5 changes: 4 additions & 1 deletion contracts/src/v0.8/ccip/NonceManager.sol
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.24;

import {ITypeAndVersion} from "../shared/interfaces/ITypeAndVersion.sol";
import {IEVM2AnyOnRamp} from "./interfaces/IEVM2AnyOnRamp.sol";
import {INonceManager} from "./interfaces/INonceManager.sol";

import {AuthorizedCallers} from "../shared/access/AuthorizedCallers.sol";

/// @title NonceManager
/// @notice NonceManager contract that manages sender nonces for the on/off ramps
contract NonceManager is INonceManager, AuthorizedCallers {
contract NonceManager is INonceManager, AuthorizedCallers, ITypeAndVersion {
error PreviousRampAlreadySet();

event PreviousRampsUpdated(uint64 indexed remoteChainSelector, PreviousRamps prevRamp);
Expand All @@ -27,6 +28,8 @@ contract NonceManager is INonceManager, AuthorizedCallers {
PreviousRamps prevRamps; // Previous on/off ramps
}

string public constant override typeAndVersion = "NonceManager 1.6.0-dev";

/// @dev previous ramps
mapping(uint64 chainSelector => PreviousRamps previousRamps) private s_previousRamps;
/// @dev The current outbound nonce per sender used on the onramp
Expand Down
13 changes: 13 additions & 0 deletions contracts/src/v0.8/ccip/test/NonceManager.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@ import {EVM2EVMOnRampHelper} from "./helpers/EVM2EVMOnRampHelper.sol";
import {MockCommitStore} from "./mocks/MockCommitStore.sol";
import {EVM2EVMMultiOffRampSetup} from "./offRamp/EVM2EVMMultiOffRampSetup.t.sol";
import {EVM2EVMMultiOnRampSetup} from "./onRamp/EVM2EVMMultiOnRampSetup.t.sol";
import {Test} from "forge-std/Test.sol";

contract NonceManager_typeAndVersion is Test {
NonceManager private s_nonceManager;

function setUp() public {
s_nonceManager = new NonceManager(new address[](0));
}

function test_typeAndVersion() public {
assertEq(s_nonceManager.typeAndVersion(), "NonceManager 1.6.0-dev");
}
}

contract NonceManager_NonceIncrementation is BaseTest {
NonceManager private s_nonceManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ contract MultiAggregateRateLimiter_constructor is MultiAggregateRateLimiterSetup

assertEq(OWNER, s_rateLimiter.owner());
assertEq(address(s_priceRegistry), s_rateLimiter.getPriceRegistry());
assertEq(s_rateLimiter.typeAndVersion(), "MultiAggregateRateLimiter 1.6.0-dev");
}
}

Expand Down
Loading

0 comments on commit 59ac4e4

Please sign in to comment.