From 58e2a6afb9ceaec271e64e805b5f850924c4de61 Mon Sep 17 00:00:00 2001 From: Rens Rooimans Date: Wed, 13 Nov 2024 12:16:26 +0100 Subject: [PATCH] Revert "optimize transfer and approve function by removing unnec. error check that only applied to 677" This reverts commit dce25c7fd803b23ae0821c041c27943acef85eb6. --- contracts/gas-snapshots/ccip.gas-snapshot | 180 +++++++++--------- contracts/gas-snapshots/shared.gas-snapshot | 24 +-- .../BurnMintERC20/BurnMintERC20.approve.t.sol | 8 + .../BurnMintERC20.transfer.t.sol | 8 + .../v0.8/shared/token/ERC20/BurnMintERC20.sol | 18 ++ 5 files changed, 137 insertions(+), 101 deletions(-) diff --git a/contracts/gas-snapshots/ccip.gas-snapshot b/contracts/gas-snapshots/ccip.gas-snapshot index 974ea117e8d..32f87cc6326 100644 --- a/contracts/gas-snapshots/ccip.gas-snapshot +++ b/contracts/gas-snapshots/ccip.gas-snapshot @@ -20,7 +20,7 @@ BurnWithFromMintTokenPool_lockOrBurn:test_ChainNotAllowed_Revert() (gas: 28962) BurnWithFromMintTokenPool_lockOrBurn:test_PoolBurnRevertNotHealthy_Revert() (gas: 55385) BurnWithFromMintTokenPool_lockOrBurn:test_PoolBurn_Success() (gas: 244349) BurnWithFromMintTokenPool_lockOrBurn:test_Setup_Success() (gas: 24255) -CCIPClientExample_sanity:test_ImmutableExamples_Success() (gas: 2075695) +CCIPClientExample_sanity:test_ImmutableExamples_Success() (gas: 2076959) CCIPHome__validateConfig:test__validateConfigLessTransmittersThanSigners_Success() (gas: 332619) CCIPHome__validateConfig:test__validateConfigSmallerFChain_Success() (gas: 458568) CCIPHome__validateConfig:test__validateConfig_ABIEncodedAddress_OfframpAddressCannotBeZero_Reverts() (gas: 289191) @@ -66,9 +66,9 @@ CCIPHome_setCandidate:test_setCandidate_CanOnlySelfCall_reverts() (gas: 29383) CCIPHome_setCandidate:test_setCandidate_ConfigDigestMismatch_reverts() (gas: 1395154) CCIPHome_setCandidate:test_setCandidate_success() (gas: 1365439) CCIPHome_supportsInterface:test_supportsInterface_success() (gas: 9885) -DefensiveExampleTest:test_HappyPath_Success() (gas: 200476) -DefensiveExampleTest:test_Recovery() (gas: 424950) -E2E:test_E2E_3MessagesMMultiOffRampSuccess_gas() (gas: 1518558) +DefensiveExampleTest:test_HappyPath_Success() (gas: 200540) +DefensiveExampleTest:test_Recovery() (gas: 425013) +E2E:test_E2E_3MessagesMMultiOffRampSuccess_gas() (gas: 1520217) EtherSenderReceiverTest_ccipReceive:test_ccipReceive_fallbackToWethTransfer() (gas: 96962) EtherSenderReceiverTest_ccipReceive:test_ccipReceive_happyPath() (gas: 49812) EtherSenderReceiverTest_ccipReceive:test_ccipReceive_wrongToken() (gas: 17457) @@ -173,20 +173,20 @@ FeeQuoter_getValidatedFee:test_NotAFeeToken_Revert() (gas: 21280) FeeQuoter_getValidatedFee:test_SingleTokenMessage_Success() (gas: 114442) FeeQuoter_getValidatedFee:test_TooManyTokens_Revert() (gas: 23473) FeeQuoter_getValidatedFee:test_ZeroDataAvailabilityMultiplier_Success() (gas: 63843) -FeeQuoter_getValidatedTokenPrice:test_GetValidatedTokenPriceFromFeedErc20Above18Decimals_Success() (gas: 1862152) -FeeQuoter_getValidatedTokenPrice:test_GetValidatedTokenPriceFromFeedErc20Below18Decimals_Success() (gas: 1862110) -FeeQuoter_getValidatedTokenPrice:test_GetValidatedTokenPriceFromFeedFeedAt0Decimals_Success() (gas: 1842229) -FeeQuoter_getValidatedTokenPrice:test_GetValidatedTokenPriceFromFeedFeedAt18Decimals_Success() (gas: 1861884) -FeeQuoter_getValidatedTokenPrice:test_GetValidatedTokenPriceFromFeedFlippedDecimals_Success() (gas: 1862088) -FeeQuoter_getValidatedTokenPrice:test_GetValidatedTokenPriceFromFeedMaxInt224Value_Success() (gas: 1861900) +FeeQuoter_getValidatedTokenPrice:test_GetValidatedTokenPriceFromFeedErc20Above18Decimals_Success() (gas: 1887407) +FeeQuoter_getValidatedTokenPrice:test_GetValidatedTokenPriceFromFeedErc20Below18Decimals_Success() (gas: 1887365) +FeeQuoter_getValidatedTokenPrice:test_GetValidatedTokenPriceFromFeedFeedAt0Decimals_Success() (gas: 1867484) +FeeQuoter_getValidatedTokenPrice:test_GetValidatedTokenPriceFromFeedFeedAt18Decimals_Success() (gas: 1887139) +FeeQuoter_getValidatedTokenPrice:test_GetValidatedTokenPriceFromFeedFlippedDecimals_Success() (gas: 1887343) +FeeQuoter_getValidatedTokenPrice:test_GetValidatedTokenPriceFromFeedMaxInt224Value_Success() (gas: 1887155) FeeQuoter_getValidatedTokenPrice:test_GetValidatedTokenPriceFromFeedOverStalenessPeriod_Success() (gas: 65210) FeeQuoter_getValidatedTokenPrice:test_GetValidatedTokenPriceFromFeed_Success() (gas: 65090) FeeQuoter_getValidatedTokenPrice:test_GetValidatedTokenPrice_Success() (gas: 58872) -FeeQuoter_getValidatedTokenPrice:test_OverflowFeedPrice_Revert() (gas: 1861526) +FeeQuoter_getValidatedTokenPrice:test_OverflowFeedPrice_Revert() (gas: 1886781) FeeQuoter_getValidatedTokenPrice:test_StaleFeeToken_Success() (gas: 61821) FeeQuoter_getValidatedTokenPrice:test_TokenNotSupportedFeed_Revert() (gas: 116926) FeeQuoter_getValidatedTokenPrice:test_TokenNotSupported_Revert() (gas: 14160) -FeeQuoter_getValidatedTokenPrice:test_UnderflowFeedPrice_Revert() (gas: 1860203) +FeeQuoter_getValidatedTokenPrice:test_UnderflowFeedPrice_Revert() (gas: 1885458) FeeQuoter_onReport:test_OnReport_StaleUpdate_SkipPriceUpdate_Success() (gas: 43936) FeeQuoter_onReport:test_onReport_InvalidForwarder_Reverts() (gas: 23657) FeeQuoter_onReport:test_onReport_Success() (gas: 80700) @@ -227,13 +227,13 @@ FeeQuoter_validateDestFamilyAddress:test_InvalidEVMAddressPrecompiles_Revert() ( FeeQuoter_validateDestFamilyAddress:test_InvalidEVMAddress_Revert() (gas: 10884) FeeQuoter_validateDestFamilyAddress:test_ValidEVMAddress_Success() (gas: 6819) FeeQuoter_validateDestFamilyAddress:test_ValidNonEVMAddress_Success() (gas: 6545) -HybridLockReleaseUSDCTokenPool_TransferLiquidity:test_cannotTransferLiquidityDuringPendingMigration_Revert() (gas: 176823) -HybridLockReleaseUSDCTokenPool_TransferLiquidity:test_transferLiquidity_Success() (gas: 166836) -HybridLockReleaseUSDCTokenPool_lockOrBurn:test_PrimaryMechanism_Success() (gas: 135833) -HybridLockReleaseUSDCTokenPool_lockOrBurn:test_WhileMigrationPause_Revert() (gas: 109634) -HybridLockReleaseUSDCTokenPool_lockOrBurn:test_onLockReleaseMechanism_Success() (gas: 146929) -HybridLockReleaseUSDCTokenPool_lockOrBurn:test_onLockReleaseMechanism_thenswitchToPrimary_Success() (gas: 209069) -HybridLockReleaseUSDCTokenPool_releaseOrMint:test_OnLockReleaseMechanism_Success() (gas: 216701) +HybridLockReleaseUSDCTokenPool_TransferLiquidity:test_cannotTransferLiquidityDuringPendingMigration_Revert() (gas: 176981) +HybridLockReleaseUSDCTokenPool_TransferLiquidity:test_transferLiquidity_Success() (gas: 167025) +HybridLockReleaseUSDCTokenPool_lockOrBurn:test_PrimaryMechanism_Success() (gas: 135960) +HybridLockReleaseUSDCTokenPool_lockOrBurn:test_WhileMigrationPause_Revert() (gas: 109713) +HybridLockReleaseUSDCTokenPool_lockOrBurn:test_onLockReleaseMechanism_Success() (gas: 147008) +HybridLockReleaseUSDCTokenPool_lockOrBurn:test_onLockReleaseMechanism_thenswitchToPrimary_Success() (gas: 209322) +HybridLockReleaseUSDCTokenPool_releaseOrMint:test_OnLockReleaseMechanism_Success() (gas: 216938) HybridLockReleaseUSDCTokenPool_releaseOrMint:test_WhileMigrationPause_Revert() (gas: 113472) HybridLockReleaseUSDCTokenPool_releaseOrMint:test_incomingMessageWithPrimaryMechanism() (gas: 269080) LockReleaseTokenPool_canAcceptLiquidity:test_CanAcceptLiquidity_Success() (gas: 2788658) @@ -244,13 +244,13 @@ LockReleaseTokenPool_provideLiquidity:test_LiquidityNotAccepted_Revert() (gas: 2 LockReleaseTokenPool_provideLiquidity:test_Unauthorized_Revert() (gas: 11489) LockReleaseTokenPool_releaseOrMint:test_ChainNotAllowed_Revert() (gas: 72956) LockReleaseTokenPool_releaseOrMint:test_PoolMintNotHealthy_Revert() (gas: 56520) -LockReleaseTokenPool_releaseOrMint:test_ReleaseOrMint_Success() (gas: 225737) +LockReleaseTokenPool_releaseOrMint:test_ReleaseOrMint_Success() (gas: 225800) LockReleaseTokenPool_setRebalancer:test_SetRebalancer_Revert() (gas: 10981) LockReleaseTokenPool_setRebalancer:test_SetRebalancer_Success() (gas: 18160) LockReleaseTokenPool_supportsInterface:test_SupportsInterface_Success() (gas: 10250) -LockReleaseTokenPool_transferLiquidity:test_transferLiquidity_Success() (gas: 83227) +LockReleaseTokenPool_transferLiquidity:test_transferLiquidity_Success() (gas: 83306) LockReleaseTokenPool_transferLiquidity:test_transferLiquidity_transferTooMuch_Revert() (gas: 56079) -LockReleaseTokenPool_withdrawalLiquidity:test_InsufficientLiquidity_Revert() (gas: 59980) +LockReleaseTokenPool_withdrawalLiquidity:test_InsufficientLiquidity_Revert() (gas: 60170) LockReleaseTokenPool_withdrawalLiquidity:test_Unauthorized_Revert() (gas: 11464) MerkleMultiProofTest:test_CVE_2023_34459() (gas: 5500) MerkleMultiProofTest:test_EmptyLeaf_Revert() (gas: 3607) @@ -259,7 +259,7 @@ MerkleMultiProofTest:test_MerkleRootSingleLeaf_Success() (gas: 3661) MerkleMultiProofTest:test_SpecSync_gas() (gas: 34107) MockRouterTest:test_ccipSendWithInsufficientNativeTokens_Revert() (gas: 34081) MockRouterTest:test_ccipSendWithInvalidMsgValue_Revert() (gas: 60886) -MockRouterTest:test_ccipSendWithLinkFeeTokenAndValidMsgValue_Success() (gas: 126473) +MockRouterTest:test_ccipSendWithLinkFeeTokenAndValidMsgValue_Success() (gas: 126631) MockRouterTest:test_ccipSendWithLinkFeeTokenbutInsufficientAllowance_Revert() (gas: 63521) MockRouterTest:test_ccipSendWithSufficientNativeFeeTokens_Success() (gas: 44056) MultiAggregateRateLimiter_applyRateLimiterConfigUpdates:test_ConfigRateMoreThanCapacity_Revert() (gas: 16554) @@ -384,7 +384,7 @@ OffRamp_batchExecute:test_MultipleReportsSameChain_Success() (gas: 276441) OffRamp_batchExecute:test_MultipleReportsSkipDuplicate_Success() (gas: 168334) OffRamp_batchExecute:test_OutOfBoundsGasLimitsAccess_Revert() (gas: 187853) OffRamp_batchExecute:test_SingleReport_Success() (gas: 156369) -OffRamp_batchExecute:test_Unhealthy_Success() (gas: 553429) +OffRamp_batchExecute:test_Unhealthy_Success() (gas: 553587) OffRamp_batchExecute:test_ZeroReports_Revert() (gas: 10600) OffRamp_ccipReceive:test_RevertWhen_Always() (gas: 9303) OffRamp_commit:test_CommitOnRampMismatch_Revert() (gas: 92744) @@ -427,18 +427,18 @@ OffRamp_execute:test_UnauthorizedTransmitter_Revert() (gas: 147783) OffRamp_execute:test_WrongConfigWithSigners_Revert() (gas: 6940958) OffRamp_execute:test_ZeroReports_Revert() (gas: 17361) OffRamp_executeSingleMessage:test_MessageSender_Revert() (gas: 18533) -OffRamp_executeSingleMessage:test_NonContractWithTokens_Success() (gas: 244166) +OffRamp_executeSingleMessage:test_NonContractWithTokens_Success() (gas: 244245) OffRamp_executeSingleMessage:test_NonContract_Success() (gas: 20363) -OffRamp_executeSingleMessage:test_TokenHandlingError_Revert() (gas: 205607) +OffRamp_executeSingleMessage:test_TokenHandlingError_Revert() (gas: 205686) OffRamp_executeSingleMessage:test_ZeroGasDONExecution_Revert() (gas: 48880) OffRamp_executeSingleMessage:test_executeSingleMessage_NoTokens_Success() (gas: 56102) OffRamp_executeSingleMessage:test_executeSingleMessage_WithFailingValidationNoRouterCall_Revert() (gas: 212824) OffRamp_executeSingleMessage:test_executeSingleMessage_WithFailingValidation_Revert() (gas: 85495) -OffRamp_executeSingleMessage:test_executeSingleMessage_WithTokens_Success() (gas: 274274) +OffRamp_executeSingleMessage:test_executeSingleMessage_WithTokens_Success() (gas: 274353) OffRamp_executeSingleMessage:test_executeSingleMessage_WithVInterception_Success() (gas: 91918) OffRamp_executeSingleReport:test_DisabledSourceChain_Revert() (gas: 28636) OffRamp_executeSingleReport:test_EmptyReport_Revert() (gas: 15580) -OffRamp_executeSingleReport:test_InvalidSourcePoolAddress_Success() (gas: 481428) +OffRamp_executeSingleReport:test_InvalidSourcePoolAddress_Success() (gas: 481507) OffRamp_executeSingleReport:test_ManualExecutionNotYetEnabled_Revert() (gas: 48295) OffRamp_executeSingleReport:test_MismatchingDestChainSelector_Revert() (gas: 34188) OffRamp_executeSingleReport:test_NonExistingSourceChain_Revert() (gas: 28823) @@ -451,15 +451,15 @@ OffRamp_executeSingleReport:test_SingleMessageNoTokensUnordered_Success() (gas: OffRamp_executeSingleReport:test_SingleMessageNoTokens_Success() (gas: 212228) OffRamp_executeSingleReport:test_SingleMessageToNonCCIPReceiver_Success() (gas: 243641) OffRamp_executeSingleReport:test_SingleMessagesNoTokensSuccess_gas() (gas: 141397) -OffRamp_executeSingleReport:test_SkippedIncorrectNonceStillExecutes_Success() (gas: 408626) +OffRamp_executeSingleReport:test_SkippedIncorrectNonceStillExecutes_Success() (gas: 408705) OffRamp_executeSingleReport:test_SkippedIncorrectNonce_Success() (gas: 58241) OffRamp_executeSingleReport:test_TokenDataMismatch_Revert() (gas: 73786) -OffRamp_executeSingleReport:test_TwoMessagesWithTokensAndGE_Success() (gas: 582436) -OffRamp_executeSingleReport:test_TwoMessagesWithTokensSuccess_gas() (gas: 531102) +OffRamp_executeSingleReport:test_TwoMessagesWithTokensAndGE_Success() (gas: 582594) +OffRamp_executeSingleReport:test_TwoMessagesWithTokensSuccess_gas() (gas: 531260) OffRamp_executeSingleReport:test_UnexpectedTokenData_Revert() (gas: 26751) -OffRamp_executeSingleReport:test_UnhealthySingleChainCurse_Revert() (gas: 549047) -OffRamp_executeSingleReport:test_Unhealthy_Success() (gas: 549083) -OffRamp_executeSingleReport:test_WithCurseOnAnotherSourceChain_Success() (gas: 460194) +OffRamp_executeSingleReport:test_UnhealthySingleChainCurse_Revert() (gas: 549205) +OffRamp_executeSingleReport:test_Unhealthy_Success() (gas: 549241) +OffRamp_executeSingleReport:test_WithCurseOnAnotherSourceChain_Success() (gas: 460352) OffRamp_executeSingleReport:test__execute_SkippedAlreadyExecutedMessageUnordered_Success() (gas: 135139) OffRamp_executeSingleReport:test__execute_SkippedAlreadyExecutedMessage_Success() (gas: 164782) OffRamp_getExecutionState:test_FillExecutionState_Success() (gas: 3888824) @@ -475,35 +475,35 @@ OffRamp_manuallyExecute:test_manuallyExecute_InvalidReceiverExecutionGasLimit_Re OffRamp_manuallyExecute:test_manuallyExecute_InvalidTokenGasOverride_Revert() (gas: 55274) OffRamp_manuallyExecute:test_manuallyExecute_LowGasLimit_Success() (gas: 489352) OffRamp_manuallyExecute:test_manuallyExecute_MultipleReportsWithSingleCursedLane_Revert() (gas: 314370) -OffRamp_manuallyExecute:test_manuallyExecute_ReentrancyFails_Success() (gas: 2227688) +OffRamp_manuallyExecute:test_manuallyExecute_ReentrancyFails_Success() (gas: 2227767) OffRamp_manuallyExecute:test_manuallyExecute_SourceChainSelectorMismatch_Revert() (gas: 165133) OffRamp_manuallyExecute:test_manuallyExecute_Success() (gas: 225844) OffRamp_manuallyExecute:test_manuallyExecute_WithGasOverride_Success() (gas: 226384) OffRamp_manuallyExecute:test_manuallyExecute_WithMultiReportGasOverride_Success() (gas: 773426) OffRamp_manuallyExecute:test_manuallyExecute_WithPartialMessages_Success() (gas: 344159) OffRamp_releaseOrMintSingleToken:test__releaseOrMintSingleToken_NotACompatiblePool_Revert() (gas: 37654) -OffRamp_releaseOrMintSingleToken:test__releaseOrMintSingleToken_Success() (gas: 104607) +OffRamp_releaseOrMintSingleToken:test__releaseOrMintSingleToken_Success() (gas: 104686) OffRamp_releaseOrMintSingleToken:test__releaseOrMintSingleToken_TokenHandlingError_transfer_Revert() (gas: 83114) OffRamp_releaseOrMintSingleToken:test_releaseOrMintToken_InvalidDataLength_Revert() (gas: 36812) -OffRamp_releaseOrMintSingleToken:test_releaseOrMintToken_ReleaseOrMintBalanceMismatch_Revert() (gas: 94564) +OffRamp_releaseOrMintSingleToken:test_releaseOrMintToken_ReleaseOrMintBalanceMismatch_Revert() (gas: 94643) OffRamp_releaseOrMintSingleToken:test_releaseOrMintToken_TokenHandlingError_BalanceOf_Revert() (gas: 37323) -OffRamp_releaseOrMintSingleToken:test_releaseOrMintToken_skip_ReleaseOrMintBalanceMismatch_if_pool_Revert() (gas: 86676) -OffRamp_releaseOrMintTokens:test_TokenHandlingError_Reverts() (gas: 162871) +OffRamp_releaseOrMintSingleToken:test_releaseOrMintToken_skip_ReleaseOrMintBalanceMismatch_if_pool_Revert() (gas: 86755) +OffRamp_releaseOrMintTokens:test_TokenHandlingError_Reverts() (gas: 162950) OffRamp_releaseOrMintTokens:test__releaseOrMintTokens_PoolIsNotAPool_Reverts() (gas: 23836) OffRamp_releaseOrMintTokens:test_releaseOrMintTokens_InvalidDataLengthReturnData_Revert() (gas: 62866) OffRamp_releaseOrMintTokens:test_releaseOrMintTokens_PoolDoesNotSupportDest_Reverts() (gas: 80036) -OffRamp_releaseOrMintTokens:test_releaseOrMintTokens_Success() (gas: 175028) -OffRamp_releaseOrMintTokens:test_releaseOrMintTokens_WithGasOverride_Success() (gas: 176940) -OffRamp_releaseOrMintTokens:test_releaseOrMintTokens_destDenominatedDecimals_Success() (gas: 188162) +OffRamp_releaseOrMintTokens:test_releaseOrMintTokens_Success() (gas: 175107) +OffRamp_releaseOrMintTokens:test_releaseOrMintTokens_WithGasOverride_Success() (gas: 177019) +OffRamp_releaseOrMintTokens:test_releaseOrMintTokens_destDenominatedDecimals_Success() (gas: 188241) OffRamp_setDynamicConfig:test_FeeQuoterZeroAddress_Revert() (gas: 11509) OffRamp_setDynamicConfig:test_NonOwner_Revert() (gas: 14019) OffRamp_setDynamicConfig:test_SetDynamicConfigWithInterceptor_Success() (gas: 47579) OffRamp_setDynamicConfig:test_SetDynamicConfig_Success() (gas: 25552) -OffRamp_trialExecute:test_RateLimitError_Success() (gas: 219888) -OffRamp_trialExecute:test_TokenHandlingErrorIsCaught_Success() (gas: 228565) -OffRamp_trialExecute:test_TokenPoolIsNotAContract_Success() (gas: 295597) -OffRamp_trialExecute:test_trialExecute_Success() (gas: 278071) -OnRampTokenPoolReentrancy:test_OnRampTokenPoolReentrancy_Success() (gas: 251325) +OffRamp_trialExecute:test_RateLimitError_Success() (gas: 219967) +OffRamp_trialExecute:test_TokenHandlingErrorIsCaught_Success() (gas: 228644) +OffRamp_trialExecute:test_TokenPoolIsNotAContract_Success() (gas: 295676) +OffRamp_trialExecute:test_trialExecute_Success() (gas: 278150) +OnRampTokenPoolReentrancy:test_OnRampTokenPoolReentrancy_Success() (gas: 251641) OnRamp_applyAllowlistUpdates:test_applyAllowlistUpdates_InvalidAllowListRequestDisabledAllowListWithAdds() (gas: 17227) OnRamp_applyAllowlistUpdates:test_applyAllowlistUpdates_Revert() (gas: 67101) OnRamp_applyAllowlistUpdates:test_applyAllowlistUpdates_Success() (gas: 325983) @@ -515,15 +515,15 @@ OnRamp_constructor:test_Constructor_InvalidConfigNonceManagerEqAddressZero_Rever OnRamp_constructor:test_Constructor_InvalidConfigRMNProxyEqAddressZero_Revert() (gas: 98066) OnRamp_constructor:test_Constructor_InvalidConfigTokenAdminRegistryEqAddressZero_Revert() (gas: 93146) OnRamp_constructor:test_Constructor_Success() (gas: 2647459) -OnRamp_forwardFromRouter:test_ForwardFromRouterExtraArgsV2AllowOutOfOrderTrue_Success() (gas: 115252) -OnRamp_forwardFromRouter:test_ForwardFromRouterExtraArgsV2_Success() (gas: 146098) -OnRamp_forwardFromRouter:test_ForwardFromRouterSuccessCustomExtraArgs() (gas: 145695) -OnRamp_forwardFromRouter:test_ForwardFromRouterSuccessEmptyExtraArgs() (gas: 143811) -OnRamp_forwardFromRouter:test_ForwardFromRouterSuccessLegacyExtraArgs() (gas: 145892) -OnRamp_forwardFromRouter:test_ForwardFromRouter_Success() (gas: 145290) -OnRamp_forwardFromRouter:test_ForwardFromRouter_Success_ConfigurableSourceRouter() (gas: 140551) +OnRamp_forwardFromRouter:test_ForwardFromRouterExtraArgsV2AllowOutOfOrderTrue_Success() (gas: 115410) +OnRamp_forwardFromRouter:test_ForwardFromRouterExtraArgsV2_Success() (gas: 146256) +OnRamp_forwardFromRouter:test_ForwardFromRouterSuccessCustomExtraArgs() (gas: 145853) +OnRamp_forwardFromRouter:test_ForwardFromRouterSuccessEmptyExtraArgs() (gas: 143969) +OnRamp_forwardFromRouter:test_ForwardFromRouterSuccessLegacyExtraArgs() (gas: 146050) +OnRamp_forwardFromRouter:test_ForwardFromRouter_Success() (gas: 145448) +OnRamp_forwardFromRouter:test_ForwardFromRouter_Success_ConfigurableSourceRouter() (gas: 140709) OnRamp_forwardFromRouter:test_InvalidExtraArgsTag_Revert() (gas: 38504) -OnRamp_forwardFromRouter:test_MessageInterceptionError_Revert() (gas: 142976) +OnRamp_forwardFromRouter:test_MessageInterceptionError_Revert() (gas: 143134) OnRamp_forwardFromRouter:test_MesssageFeeTooHigh_Revert() (gas: 36611) OnRamp_forwardFromRouter:test_MultiCannotSendZeroTokens_Revert() (gas: 36493) OnRamp_forwardFromRouter:test_OriginalSender_Revert() (gas: 18290) @@ -531,13 +531,13 @@ OnRamp_forwardFromRouter:test_Paused_Revert() (gas: 38434) OnRamp_forwardFromRouter:test_Permissions_Revert() (gas: 23651) OnRamp_forwardFromRouter:test_ShouldIncrementNonceOnlyOnOrdered_Success() (gas: 186649) OnRamp_forwardFromRouter:test_ShouldIncrementSeqNumAndNonce_Success() (gas: 213078) -OnRamp_forwardFromRouter:test_ShouldStoreLinkFees() (gas: 146901) -OnRamp_forwardFromRouter:test_ShouldStoreNonLinkFees() (gas: 161090) +OnRamp_forwardFromRouter:test_ShouldStoreLinkFees() (gas: 147059) +OnRamp_forwardFromRouter:test_ShouldStoreNonLinkFees() (gas: 161248) OnRamp_forwardFromRouter:test_SourceTokenDataTooLarge_Revert() (gas: 3528787) OnRamp_forwardFromRouter:test_UnAllowedOriginalSender_Revert() (gas: 24015) OnRamp_forwardFromRouter:test_UnsupportedToken_Revert() (gas: 75854) OnRamp_forwardFromRouter:test_forwardFromRouter_UnsupportedToken_Revert() (gas: 38610) -OnRamp_forwardFromRouter:test_forwardFromRouter_WithInterception_Success() (gas: 280198) +OnRamp_forwardFromRouter:test_forwardFromRouter_WithInterception_Success() (gas: 280356) OnRamp_getFee:test_EmptyMessage_Success() (gas: 98692) OnRamp_getFee:test_EnforceOutOfOrder_Revert() (gas: 65453) OnRamp_getFee:test_GetFeeOfZeroForTokenMessage_Success() (gas: 87185) @@ -552,12 +552,12 @@ OnRamp_setDynamicConfig:test_setDynamicConfig_InvalidConfigInvalidConfig_Revert( OnRamp_setDynamicConfig:test_setDynamicConfig_InvalidConfigOnlyOwner_Revert() (gas: 11938) OnRamp_setDynamicConfig:test_setDynamicConfig_InvalidConfigReentrancyGuardEnteredEqTrue_Revert() (gas: 13264) OnRamp_setDynamicConfig:test_setDynamicConfig_Success() (gas: 56440) -OnRamp_withdrawFeeTokens:test_WithdrawFeeTokens_Success() (gas: 125743) -PingPong_ccipReceive:test_CcipReceive_Success() (gas: 172779) +OnRamp_withdrawFeeTokens:test_WithdrawFeeTokens_Success() (gas: 125901) +PingPong_ccipReceive:test_CcipReceive_Success() (gas: 172858) PingPong_setOutOfOrderExecution:test_OutOfOrderExecution_Success() (gas: 20283) PingPong_setPaused:test_Pausing_Success() (gas: 17738) -PingPong_startPingPong:test_StartPingPong_With_OOO_Success() (gas: 151892) -PingPong_startPingPong:test_StartPingPong_With_Sequenced_Ordered_Success() (gas: 177507) +PingPong_startPingPong:test_StartPingPong_With_OOO_Success() (gas: 151971) +PingPong_startPingPong:test_StartPingPong_With_Sequenced_Ordered_Success() (gas: 177586) RMNHome_getConfigDigests:test_getConfigDigests_success() (gas: 1079685) RMNHome_promoteCandidateAndRevokeActive:test_promoteCandidateAndRevokeActive_ConfigDigestMismatch_reverts() (gas: 23879) RMNHome_promoteCandidateAndRevokeActive:test_promoteCandidateAndRevokeActive_NoOpStateTransitionNotAllowed_reverts() (gas: 10597) @@ -626,20 +626,20 @@ Router_applyRampUpdates:test_OffRampMismatch_Revert() (gas: 89591) Router_applyRampUpdates:test_OffRampUpdatesWithRouting() (gas: 10749462) Router_applyRampUpdates:test_OnRampDisable() (gas: 56428) Router_applyRampUpdates:test_OnlyOwner_Revert() (gas: 12414) -Router_ccipSend:test_CCIPSendLinkFeeNoTokenSuccess_gas() (gas: 131267) -Router_ccipSend:test_CCIPSendLinkFeeOneTokenSuccess_gas() (gas: 221006) -Router_ccipSend:test_FeeTokenAmountTooLow_Revert() (gas: 71779) +Router_ccipSend:test_CCIPSendLinkFeeNoTokenSuccess_gas() (gas: 131425) +Router_ccipSend:test_CCIPSendLinkFeeOneTokenSuccess_gas() (gas: 221322) +Router_ccipSend:test_FeeTokenAmountTooLow_Revert() (gas: 71858) Router_ccipSend:test_InvalidMsgValue() (gas: 32411) Router_ccipSend:test_NativeFeeTokenInsufficientValue() (gas: 69524) Router_ccipSend:test_NativeFeeTokenOverpay_Success() (gas: 193296) Router_ccipSend:test_NativeFeeTokenZeroValue() (gas: 61550) Router_ccipSend:test_NativeFeeToken_Success() (gas: 191900) -Router_ccipSend:test_NonLinkFeeToken_Success() (gas: 226302) +Router_ccipSend:test_NonLinkFeeToken_Success() (gas: 226539) Router_ccipSend:test_UnsupportedDestinationChain_Revert() (gas: 25056) Router_ccipSend:test_WhenNotHealthy_Revert() (gas: 45056) Router_ccipSend:test_WrappedNativeFeeToken_Success() (gas: 194209) Router_ccipSend:test_ccipSend_nativeFeeNoTokenSuccess_gas() (gas: 140674) -Router_ccipSend:test_ccipSend_nativeFeeOneTokenSuccess_gas() (gas: 230348) +Router_ccipSend:test_ccipSend_nativeFeeOneTokenSuccess_gas() (gas: 230506) Router_constructor:test_Constructor_Success() (gas: 13222) Router_getArmProxy:test_getArmProxy() (gas: 10573) Router_getFee:test_GetFeeSupportedChain_Success() (gas: 51934) @@ -649,7 +649,7 @@ Router_recoverTokens:test_RecoverTokensInvalidRecipient_Revert() (gas: 11410) Router_recoverTokens:test_RecoverTokensNoFunds_Revert() (gas: 20199) Router_recoverTokens:test_RecoverTokensNonOwner_Revert() (gas: 11236) Router_recoverTokens:test_RecoverTokensValueReceiver_Revert() (gas: 349502) -Router_recoverTokens:test_RecoverTokens_Success() (gas: 52540) +Router_recoverTokens:test_RecoverTokens_Success() (gas: 52667) Router_routeMessage:test_routeMessage_AutoExec_Success() (gas: 43213) Router_routeMessage:test_routeMessage_ExecutionEvent_Success() (gas: 159418) Router_routeMessage:test_routeMessage_ManualExec_Success() (gas: 35723) @@ -714,42 +714,42 @@ TokenPool_setRateLimitAdmin:test_SetRateLimitAdmin_Success() (gas: 37584) TokenPool_setRemotePool:test_setRemotePool_NonExistentChain_Reverts() (gas: 15796) TokenPool_setRemotePool:test_setRemotePool_OnlyOwner_Reverts() (gas: 13285) TokenPool_setRemotePool:test_setRemotePool_Success() (gas: 282581) -USDCBridgeMigrator_BurnLockedUSDC:test_PrimaryMechanism_Success() (gas: 135842) -USDCBridgeMigrator_BurnLockedUSDC:test_WhileMigrationPause_Revert() (gas: 109667) +USDCBridgeMigrator_BurnLockedUSDC:test_PrimaryMechanism_Success() (gas: 135968) +USDCBridgeMigrator_BurnLockedUSDC:test_WhileMigrationPause_Revert() (gas: 109746) USDCBridgeMigrator_BurnLockedUSDC:test_invalidPermissions_Revert() (gas: 39343) -USDCBridgeMigrator_BurnLockedUSDC:test_lockOrBurn_then_BurnInCCTPMigration_Success() (gas: 309688) -USDCBridgeMigrator_BurnLockedUSDC:test_onLockReleaseMechanism_Success() (gas: 146953) -USDCBridgeMigrator_BurnLockedUSDC:test_onLockReleaseMechanism_thenswitchToPrimary_Success() (gas: 209087) +USDCBridgeMigrator_BurnLockedUSDC:test_lockOrBurn_then_BurnInCCTPMigration_Success() (gas: 309877) +USDCBridgeMigrator_BurnLockedUSDC:test_onLockReleaseMechanism_Success() (gas: 147032) +USDCBridgeMigrator_BurnLockedUSDC:test_onLockReleaseMechanism_thenswitchToPrimary_Success() (gas: 209340) USDCBridgeMigrator_cancelMigrationProposal:test_cancelExistingCCTPMigrationProposal_Success() (gas: 56190) USDCBridgeMigrator_cancelMigrationProposal:test_cannotCancelANonExistentMigrationProposal_Revert() (gas: 12691) USDCBridgeMigrator_excludeTokensFromBurn:test_excludeTokensWhenNoMigrationProposalPending_Revert() (gas: 13579) USDCBridgeMigrator_proposeMigration:test_ChainNotUsingLockRelease_Revert() (gas: 15765) -USDCBridgeMigrator_provideLiquidity:test_PrimaryMechanism_Success() (gas: 135824) -USDCBridgeMigrator_provideLiquidity:test_WhileMigrationPause_Revert() (gas: 109689) +USDCBridgeMigrator_provideLiquidity:test_PrimaryMechanism_Success() (gas: 135951) +USDCBridgeMigrator_provideLiquidity:test_WhileMigrationPause_Revert() (gas: 109768) USDCBridgeMigrator_provideLiquidity:test_cannotModifyLiquidityWithoutPermissions_Revert() (gas: 13378) USDCBridgeMigrator_provideLiquidity:test_cannotProvideLiquidityWhenMigrationProposalPending_Revert() (gas: 67436) -USDCBridgeMigrator_provideLiquidity:test_cannotProvideLiquidity_AfterMigration_Revert() (gas: 313528) +USDCBridgeMigrator_provideLiquidity:test_cannotProvideLiquidity_AfterMigration_Revert() (gas: 313717) USDCBridgeMigrator_provideLiquidity:test_invalidPermissions_Revert() (gas: 39343) -USDCBridgeMigrator_provideLiquidity:test_lockOrBurn_then_BurnInCCTPMigration_Success() (gas: 309688) -USDCBridgeMigrator_provideLiquidity:test_onLockReleaseMechanism_Success() (gas: 146998) -USDCBridgeMigrator_provideLiquidity:test_onLockReleaseMechanism_thenswitchToPrimary_Success() (gas: 209123) -USDCBridgeMigrator_releaseOrMint:test_OnLockReleaseMechanism_Success() (gas: 216734) +USDCBridgeMigrator_provideLiquidity:test_lockOrBurn_then_BurnInCCTPMigration_Success() (gas: 309877) +USDCBridgeMigrator_provideLiquidity:test_onLockReleaseMechanism_Success() (gas: 147077) +USDCBridgeMigrator_provideLiquidity:test_onLockReleaseMechanism_thenswitchToPrimary_Success() (gas: 209376) +USDCBridgeMigrator_releaseOrMint:test_OnLockReleaseMechanism_Success() (gas: 216971) USDCBridgeMigrator_releaseOrMint:test_WhileMigrationPause_Revert() (gas: 113505) USDCBridgeMigrator_releaseOrMint:test_incomingMessageWithPrimaryMechanism() (gas: 269132) -USDCBridgeMigrator_releaseOrMint:test_unstickManualTxAfterMigration_destChain_Success() (gas: 155863) -USDCBridgeMigrator_releaseOrMint:test_unstickManualTxAfterMigration_homeChain_Success() (gas: 516090) -USDCBridgeMigrator_updateChainSelectorMechanism:test_PrimaryMechanism_Success() (gas: 135842) -USDCBridgeMigrator_updateChainSelectorMechanism:test_WhileMigrationPause_Revert() (gas: 109667) -USDCBridgeMigrator_updateChainSelectorMechanism:test_cannotRevertChainMechanism_afterMigration_Revert() (gas: 313125) +USDCBridgeMigrator_releaseOrMint:test_unstickManualTxAfterMigration_destChain_Success() (gas: 156100) +USDCBridgeMigrator_releaseOrMint:test_unstickManualTxAfterMigration_homeChain_Success() (gas: 516280) +USDCBridgeMigrator_updateChainSelectorMechanism:test_PrimaryMechanism_Success() (gas: 135968) +USDCBridgeMigrator_updateChainSelectorMechanism:test_WhileMigrationPause_Revert() (gas: 109746) +USDCBridgeMigrator_updateChainSelectorMechanism:test_cannotRevertChainMechanism_afterMigration_Revert() (gas: 313315) USDCBridgeMigrator_updateChainSelectorMechanism:test_invalidPermissions_Revert() (gas: 39321) -USDCBridgeMigrator_updateChainSelectorMechanism:test_lockOrBurn_then_BurnInCCTPMigration_Success() (gas: 309688) -USDCBridgeMigrator_updateChainSelectorMechanism:test_onLockReleaseMechanism_Success() (gas: 146953) -USDCBridgeMigrator_updateChainSelectorMechanism:test_onLockReleaseMechanism_thenswitchToPrimary_Success() (gas: 209087) +USDCBridgeMigrator_updateChainSelectorMechanism:test_lockOrBurn_then_BurnInCCTPMigration_Success() (gas: 309877) +USDCBridgeMigrator_updateChainSelectorMechanism:test_onLockReleaseMechanism_Success() (gas: 147032) +USDCBridgeMigrator_updateChainSelectorMechanism:test_onLockReleaseMechanism_thenswitchToPrimary_Success() (gas: 209340) USDCTokenPool__validateMessage:test_ValidateInvalidMessage_Revert() (gas: 25854) USDCTokenPool_lockOrBurn:test_CallerIsNotARampOnRouter_Revert() (gas: 35504) USDCTokenPool_lockOrBurn:test_LockOrBurnWithAllowList_Revert() (gas: 30235) -USDCTokenPool_lockOrBurn:test_LockOrBurn_Success() (gas: 133382) -USDCTokenPool_lockOrBurn:test_UnknownDomain_Revert() (gas: 478328) +USDCTokenPool_lockOrBurn:test_LockOrBurn_Success() (gas: 133508) +USDCTokenPool_lockOrBurn:test_UnknownDomain_Revert() (gas: 478407) USDCTokenPool_releaseOrMint:test_ReleaseOrMintRealTx_Success() (gas: 268847) USDCTokenPool_releaseOrMint:test_TokenMaxCapacityExceeded_Revert() (gas: 51004) USDCTokenPool_releaseOrMint:test_UnlockingUSDCFailed_Revert() (gas: 99046) diff --git a/contracts/gas-snapshots/shared.gas-snapshot b/contracts/gas-snapshots/shared.gas-snapshot index 3a92787cade..3f31180a7ba 100644 --- a/contracts/gas-snapshots/shared.gas-snapshot +++ b/contracts/gas-snapshots/shared.gas-snapshot @@ -7,28 +7,30 @@ AuthorizedCallers_applyAuthorizedCallerUpdates:test_SkipRemove_Success() (gas: 3 AuthorizedCallers_applyAuthorizedCallerUpdates:test_ZeroAddressNotAllowed_Revert() (gas: 64413) AuthorizedCallers_constructor:test_ZeroAddressNotAllowed_Revert() (gas: 64390) AuthorizedCallers_constructor:test_constructor_Success() (gas: 674931) -BurnMintERC20approve:test_approve_Success() (gas: 57492) +BurnMintERC20approve:test_approve_InvalidAddress_Reverts() (gas: 11280) +BurnMintERC20approve:test_approve_Success() (gas: 57653) BurnMintERC20burn:test_BasicBurn_Success() (gas: 153605) BurnMintERC20burn:test_burn_BurnFromZeroAddress_Reverts() (gas: 43836) BurnMintERC20burn:test_burn_ExceedsBalance_Reverts() (gas: 21892) BurnMintERC20burn:test_burn_SenderNotBurner_Reverts() (gas: 68104) -BurnMintERC20burnFrom:test_BurnFrom_Success() (gas: 57905) -BurnMintERC20burnFrom:test_burnFrom_ExceedsBalance_Reverts() (gas: 35756) +BurnMintERC20burnFrom:test_BurnFrom_Success() (gas: 58012) +BurnMintERC20burnFrom:test_burnFrom_ExceedsBalance_Reverts() (gas: 35864) BurnMintERC20burnFrom:test_burnFrom_InsufficientAllowance_Reverts() (gas: 21858) BurnMintERC20burnFrom:test_burnFrom_SenderNotBurner_Reverts() (gas: 68126) -BurnMintERC20burnFromAlias:test_burn_ExceedsBalance_Reverts() (gas: 35798) +BurnMintERC20burnFromAlias:test_burn_ExceedsBalance_Reverts() (gas: 35905) BurnMintERC20burnFromAlias:test_burn_InsufficientAllowance_Reverts() (gas: 21889) BurnMintERC20burnFromAlias:test_burn_SenderNotBurner_Reverts() (gas: 68157) -BurnMintERC20burnFromAlias:test_burn_Success() (gas: 57896) -BurnMintERC20constructor:test_Constructor_Success() (gas: 1628529) +BurnMintERC20burnFromAlias:test_burn_Success() (gas: 58004) +BurnMintERC20constructor:test_Constructor_Success() (gas: 1694875) BurnMintERC20getCCIPAdmin:test_getCCIPAdmin_Success() (gas: 10525) BurnMintERC20getCCIPAdmin:test_setCCIPAdmin_Success() (gas: 21612) BurnMintERC20grantMintAndBurnRoles:test_GrantMintAndBurnRoles_Success() (gas: 79120) -BurnMintERC20mint:test_mint_MaxSupplyExceeded_Reverts() (gas: 50360) +BurnMintERC20mint:test_mint_MaxSupplyExceeded_Reverts() (gas: 50416) BurnMintERC20mint:test_mint_SenderNotMinter_Reverts() (gas: 66337) -BurnMintERC20mint:test_mint_Success() (gas: 101842) +BurnMintERC20mint:test_mint_Success() (gas: 101870) BurnMintERC20supportsInterface:test_SupportsInterface_Success() (gas: 11217) -BurnMintERC20transfer:test_transfer_Success() (gas: 42315) +BurnMintERC20transfer:test_transfer_InvalidAddress_Reverts() (gas: 11301) +BurnMintERC20transfer:test_transfer_Success() (gas: 42316) BurnMintERC677_approve:testApproveSuccess() (gas: 55512) BurnMintERC677_approve:testInvalidAddressReverts() (gas: 10663) BurnMintERC677_burn:testBasicBurnSuccess() (gas: 172100) @@ -61,10 +63,10 @@ CallWithExactGas__callWithExactGas:test_CallWithExactGasSafeReturnDataExactGas() CallWithExactGas__callWithExactGas:test_NoContractReverts() (gas: 11559) CallWithExactGas__callWithExactGas:test_NoGasForCallExactCheckReverts() (gas: 15788) CallWithExactGas__callWithExactGas:test_NotEnoughGasForCallReverts() (gas: 16241) -CallWithExactGas__callWithExactGas:test_callWithExactGasSuccess(bytes,bytes4) (runs: 256, μ: 15744, ~: 15697) +CallWithExactGas__callWithExactGas:test_callWithExactGasSuccess(bytes,bytes4) (runs: 257, μ: 15744, ~: 15697) CallWithExactGas__callWithExactGasEvenIfTargetIsNoContract:test_CallWithExactGasEvenIfTargetIsNoContractExactGasSuccess() (gas: 20116) CallWithExactGas__callWithExactGasEvenIfTargetIsNoContract:test_CallWithExactGasEvenIfTargetIsNoContractReceiverErrorSuccess() (gas: 66439) -CallWithExactGas__callWithExactGasEvenIfTargetIsNoContract:test_CallWithExactGasEvenIfTargetIsNoContractSuccess(bytes,bytes4) (runs: 256, μ: 16254, ~: 16207) +CallWithExactGas__callWithExactGasEvenIfTargetIsNoContract:test_CallWithExactGasEvenIfTargetIsNoContractSuccess(bytes,bytes4) (runs: 257, μ: 16254, ~: 16207) CallWithExactGas__callWithExactGasEvenIfTargetIsNoContract:test_NoContractSuccess() (gas: 12962) CallWithExactGas__callWithExactGasEvenIfTargetIsNoContract:test_NoGasForCallExactCheckReturnFalseSuccess() (gas: 13005) CallWithExactGas__callWithExactGasEvenIfTargetIsNoContract:test_NotEnoughGasForCallReturnsFalseSuccess() (gas: 13317) diff --git a/contracts/src/v0.8/shared/test/token/ERC20/BurnMintERC20/BurnMintERC20.approve.t.sol b/contracts/src/v0.8/shared/test/token/ERC20/BurnMintERC20/BurnMintERC20.approve.t.sol index f4469422ee1..b5ff3c2184f 100644 --- a/contracts/src/v0.8/shared/test/token/ERC20/BurnMintERC20/BurnMintERC20.approve.t.sol +++ b/contracts/src/v0.8/shared/test/token/ERC20/BurnMintERC20/BurnMintERC20.approve.t.sol @@ -20,4 +20,12 @@ contract BurnMintERC20approve is BurnMintERC20Setup { assertEq(sendingAmount + balancePre, s_burnMintERC20.balanceOf(STRANGER)); assertEq(ownerBalancePre - sendingAmount, s_burnMintERC20.balanceOf(OWNER)); } + + // Reverts + + function test_approve_InvalidAddress_Reverts() public { + vm.expectRevert(abi.encodeWithSelector(BurnMintERC20.InvalidRecipient.selector, address(s_burnMintERC20))); + + s_burnMintERC20.approve(address(s_burnMintERC20), s_amount); + } } diff --git a/contracts/src/v0.8/shared/test/token/ERC20/BurnMintERC20/BurnMintERC20.transfer.t.sol b/contracts/src/v0.8/shared/test/token/ERC20/BurnMintERC20/BurnMintERC20.transfer.t.sol index 78a4b18cbef..ebaca4c18fc 100644 --- a/contracts/src/v0.8/shared/test/token/ERC20/BurnMintERC20/BurnMintERC20.transfer.t.sol +++ b/contracts/src/v0.8/shared/test/token/ERC20/BurnMintERC20/BurnMintERC20.transfer.t.sol @@ -13,4 +13,12 @@ contract BurnMintERC20transfer is BurnMintERC20Setup { assertEq(sendingAmount + balancePre, s_burnMintERC20.balanceOf(STRANGER)); } + + // Reverts + + function test_transfer_InvalidAddress_Reverts() public { + vm.expectRevert(abi.encodeWithSelector(BurnMintERC20.InvalidRecipient.selector, address(s_burnMintERC20))); + + s_burnMintERC20.transfer(address(s_burnMintERC20), s_amount); + } } diff --git a/contracts/src/v0.8/shared/token/ERC20/BurnMintERC20.sol b/contracts/src/v0.8/shared/token/ERC20/BurnMintERC20.sol index 9638ef32199..b8b6bcd2799 100644 --- a/contracts/src/v0.8/shared/token/ERC20/BurnMintERC20.sol +++ b/contracts/src/v0.8/shared/token/ERC20/BurnMintERC20.sol @@ -15,6 +15,7 @@ import {IERC165} from "../../../vendor/openzeppelin-solidity/v4.8.3/contracts/ut /// @dev The total supply can be limited during deployment. contract BurnMintERC20 is IBurnMintERC20, IGetCCIPAdmin, IERC165, ERC20Burnable, AccessControl { error MaxSupplyExceeded(uint256 supplyAfterMint); + error InvalidRecipient(address recipient); event CCIPAdminTransferred(address indexed previousAdmin, address indexed newAdmin); @@ -75,6 +76,22 @@ contract BurnMintERC20 is IBurnMintERC20, IGetCCIPAdmin, IERC165, ERC20Burnable, return i_maxSupply; } + /// @dev Uses OZ ERC20 _transfer to disallow sending to address(0). + /// @dev Disallows sending to address(this) + function _transfer(address from, address to, uint256 amount) internal virtual override { + if (to == address(this)) revert InvalidRecipient(to); + + super._transfer(from, to, amount); + } + + /// @dev Uses OZ ERC20 _approve to disallow approving for address(0). + /// @dev Disallows approving for address(this) + function _approve(address owner, address spender, uint256 amount) internal virtual override { + if (spender == address(this)) revert InvalidRecipient(spender); + + super._approve(owner, spender, amount); + } + // ================================================================ // │ Burning & minting │ // ================================================================ @@ -108,6 +125,7 @@ contract BurnMintERC20 is IBurnMintERC20, IGetCCIPAdmin, IERC165, ERC20Burnable, /// @dev Disallows minting to address(this) /// @dev Increases the total supply. function mint(address account, uint256 amount) external override onlyRole(MINTER_ROLE) { + if (account == address(this)) revert InvalidRecipient(account); if (i_maxSupply != 0 && totalSupply() + amount > i_maxSupply) revert MaxSupplyExceeded(totalSupply() + amount); _mint(account, amount);