Skip to content

Commit

Permalink
small nits (#258)
Browse files Browse the repository at this point in the history
  • Loading branch information
matYang authored Nov 6, 2023
1 parent c11ee05 commit 147e0ab
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 37 deletions.
60 changes: 30 additions & 30 deletions contracts/gas-snapshots/ccip.gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ CommitStore_verify:testPausedReverts() (gas: 18438)
CommitStore_verify:testTooManyLeavesReverts() (gas: 36830)
DefensiveExampleTest:testHappyPathSuccess() (gas: 174862)
DefensiveExampleTest:testRecovery() (gas: 399786)
E2E:testE2E_3MessagesSuccess_gas() (gas: 887246)
E2E:testE2E_3MessagesSuccess_gas() (gas: 887381)
EVM2EVMOffRamp__releaseOrMintTokens:testRateLimitErrorsReverts() (gas: 443866)
EVM2EVMOffRamp__releaseOrMintTokens:testTokenHandlingErrorReverts() (gas: 103420)
EVM2EVMOffRamp__releaseOrMintTokens:testUnsupportedTokenReverts() (gas: 18202)
EVM2EVMOffRamp__releaseOrMintTokens:test_releaseOrMintTokensSuccess() (gas: 140615)
EVM2EVMOffRamp__report:testReportSuccess() (gas: 127123)
EVM2EVMOffRamp__report:testReportSuccess() (gas: 127168)
EVM2EVMOffRamp__trialExecute:testRateLimitErrorSuccess() (gas: 174918)
EVM2EVMOffRamp__trialExecute:testTokenHandlingErrorIsCaughtSuccess() (gas: 183240)
EVM2EVMOffRamp__trialExecute:test_trialExecuteSuccess() (gas: 236663)
EVM2EVMOffRamp__trialExecute:test_trialExecuteSuccess() (gas: 236708)
EVM2EVMOffRamp_applyPoolUpdates:testApplyPoolUpdatesSuccess() (gas: 2435136)
EVM2EVMOffRamp_applyPoolUpdates:testInvalidTokenPoolConfigReverts() (gas: 17445)
EVM2EVMOffRamp_applyPoolUpdates:testOnlyCallableByOwnerReverts() (gas: 16012)
Expand All @@ -111,53 +111,53 @@ EVM2EVMOffRamp_constructor:testCommitStoreAlreadyInUseReverts() (gas: 168848)
EVM2EVMOffRamp_constructor:testConstructorSuccess() (gas: 5728147)
EVM2EVMOffRamp_constructor:testTokenConfigMismatchReverts() (gas: 145215)
EVM2EVMOffRamp_constructor:testZeroOnRampAddressReverts() (gas: 2538111)
EVM2EVMOffRamp_execute:testAlreadyExecutedReverts() (gas: 137175)
EVM2EVMOffRamp_execute:testAlreadyExecutedReverts() (gas: 137220)
EVM2EVMOffRamp_execute:testEmptyReportReverts() (gas: 19016)
EVM2EVMOffRamp_execute:testInvalidMessageIdReverts() (gas: 34063)
EVM2EVMOffRamp_execute:testInvalidSourceChainReverts() (gas: 49347)
EVM2EVMOffRamp_execute:testManualExecutionNotYetEnabledReverts() (gas: 44104)
EVM2EVMOffRamp_execute:testMessageTooLargeReverts() (gas: 150111)
EVM2EVMOffRamp_execute:testPausedReverts() (gas: 74942)
EVM2EVMOffRamp_execute:testReceiverErrorSuccess() (gas: 163541)
EVM2EVMOffRamp_execute:testReceiverErrorSuccess() (gas: 163586)
EVM2EVMOffRamp_execute:testRootNotCommittedReverts() (gas: 38980)
EVM2EVMOffRamp_execute:testRouterYULCallReverts() (gas: 413610)
EVM2EVMOffRamp_execute:testSingleMessageNoTokensSuccess() (gas: 173239)
EVM2EVMOffRamp_execute:testRouterYULCallReverts() (gas: 413655)
EVM2EVMOffRamp_execute:testSingleMessageNoTokensSuccess() (gas: 173329)
EVM2EVMOffRamp_execute:testSingleMessageToNonCCIPReceiverSuccess() (gas: 246243)
EVM2EVMOffRamp_execute:testSingleMessagesNoTokensSuccess_gas() (gas: 114519)
EVM2EVMOffRamp_execute:testSkippedIncorrectNonceStillExecutesSuccess() (gas: 323942)
EVM2EVMOffRamp_execute:testSingleMessagesNoTokensSuccess_gas() (gas: 114564)
EVM2EVMOffRamp_execute:testSkippedIncorrectNonceStillExecutesSuccess() (gas: 323987)
EVM2EVMOffRamp_execute:testSkippedIncorrectNonceSuccess() (gas: 51868)
EVM2EVMOffRamp_execute:testStrictUntouchedToSuccessSuccess() (gas: 130741)
EVM2EVMOffRamp_execute:testStrictUntouchedToSuccessSuccess() (gas: 130786)
EVM2EVMOffRamp_execute:testTokenDataMismatchReverts() (gas: 49702)
EVM2EVMOffRamp_execute:testTwoMessagesWithTokensAndGESuccess() (gas: 443058)
EVM2EVMOffRamp_execute:testTwoMessagesWithTokensSuccess_gas() (gas: 402232)
EVM2EVMOffRamp_execute:testTwoMessagesWithTokensAndGESuccess() (gas: 443148)
EVM2EVMOffRamp_execute:testTwoMessagesWithTokensSuccess_gas() (gas: 402322)
EVM2EVMOffRamp_execute:testUnexpectedTokenDataReverts() (gas: 33032)
EVM2EVMOffRamp_execute:testUnhealthyReverts() (gas: 419659)
EVM2EVMOffRamp_execute:testUnhealthyReverts() (gas: 419749)
EVM2EVMOffRamp_execute:testUnsupportedNumberOfTokensReverts() (gas: 61416)
EVM2EVMOffRamp_execute:testUnsupportedTokenReverts() (gas: 130374)
EVM2EVMOffRamp_executeSingleMessage:testMessageSenderReverts() (gas: 20545)
EVM2EVMOffRamp_executeSingleMessage:testNoTokensSuccess() (gas: 47920)
EVM2EVMOffRamp_executeSingleMessage:testNoTokensSuccess() (gas: 47965)
EVM2EVMOffRamp_executeSingleMessage:testNonContractSuccess() (gas: 20105)
EVM2EVMOffRamp_executeSingleMessage:testNonContractWithTokensSuccess() (gas: 205101)
EVM2EVMOffRamp_executeSingleMessage:testTokenHandlingErrorReverts() (gas: 140016)
EVM2EVMOffRamp_executeSingleMessage:testTokensSuccess() (gas: 233948)
EVM2EVMOffRamp_executeSingleMessage:testZeroGasDONExecutionReverts() (gas: 48468)
EVM2EVMOffRamp_execute_upgrade:testV2NonceNewSenderStartsAtZeroSuccess() (gas: 231801)
EVM2EVMOffRamp_execute_upgrade:testV2NonceStartsAtV1NonceSuccess() (gas: 279573)
EVM2EVMOffRamp_execute_upgrade:testV2OffRampNonceSkipsIfMsgInFlightSuccess() (gas: 260853)
EVM2EVMOffRamp_execute_upgrade:testV2SenderNoncesReadsPreviousRampSuccess() (gas: 224863)
EVM2EVMOffRamp_execute_upgrade:testV2Success() (gas: 131256)
EVM2EVMOffRamp_executeSingleMessage:testTokensSuccess() (gas: 233993)
EVM2EVMOffRamp_executeSingleMessage:testZeroGasDONExecutionReverts() (gas: 48513)
EVM2EVMOffRamp_execute_upgrade:testV2NonceNewSenderStartsAtZeroSuccess() (gas: 231891)
EVM2EVMOffRamp_execute_upgrade:testV2NonceStartsAtV1NonceSuccess() (gas: 279708)
EVM2EVMOffRamp_execute_upgrade:testV2OffRampNonceSkipsIfMsgInFlightSuccess() (gas: 260943)
EVM2EVMOffRamp_execute_upgrade:testV2SenderNoncesReadsPreviousRampSuccess() (gas: 224998)
EVM2EVMOffRamp_execute_upgrade:testV2Success() (gas: 131301)
EVM2EVMOffRamp_getDestinationToken:testGetDestinationTokenSuccess() (gas: 32786)
EVM2EVMOffRamp_getDestinationToken:testUnsupportedTokenReverts() (gas: 13763)
EVM2EVMOffRamp_getDestinationTokens:testGetDestinationTokensSuccess() (gas: 26091)
EVM2EVMOffRamp_getExecutionState:testFillExecutionStateSuccess() (gas: 3047481)
EVM2EVMOffRamp_getExecutionState:test_GetExecutionStateSuccess() (gas: 76354)
EVM2EVMOffRamp_manuallyExecute:testLowGasLimitManualExecSuccess() (gas: 496653)
EVM2EVMOffRamp_manuallyExecute:testLowGasLimitManualExecSuccess() (gas: 496743)
EVM2EVMOffRamp_manuallyExecute:testManualExecForkedChainReverts() (gas: 25977)
EVM2EVMOffRamp_manuallyExecute:testManualExecGasLimitMismatchReverts() (gas: 43615)
EVM2EVMOffRamp_manuallyExecute:testManualExecInvalidGasLimitReverts() (gas: 26018)
EVM2EVMOffRamp_manuallyExecute:testManualExecSuccess() (gas: 189333)
EVM2EVMOffRamp_manuallyExecute:testManualExecWithGasOverrideSuccess() (gas: 189960)
EVM2EVMOffRamp_manuallyExecute:testReentrancyManualExecuteFAILS() (gas: 1856089)
EVM2EVMOffRamp_manuallyExecute:testManualExecSuccess() (gas: 189423)
EVM2EVMOffRamp_manuallyExecute:testManualExecWithGasOverrideSuccess() (gas: 190050)
EVM2EVMOffRamp_manuallyExecute:testReentrancyManualExecuteFAILS() (gas: 1856134)
EVM2EVMOffRamp_metadataHash:testMetadataHashSuccess() (gas: 6086)
EVM2EVMOffRamp_setDynamicConfig:testNonOwnerReverts() (gas: 44539)
EVM2EVMOffRamp_setDynamicConfig:testRouterZeroAddressReverts() (gas: 38587)
Expand Down Expand Up @@ -338,7 +338,7 @@ RateLimiter_currentTokenBucketState:testCurrentTokenBucketStateSuccess() (gas: 3
RateLimiter_currentTokenBucketState:testRefillSuccess() (gas: 41673)
RateLimiter_setTokenBucketConfig:testSetRateLimiterConfigSuccess() (gas: 35459)
Router_applyRampUpdates:testOffRampMismatchReverts() (gas: 89355)
Router_applyRampUpdates:testOffRampUpdatesWithRouting() (gas: 8484115)
Router_applyRampUpdates:testOffRampUpdatesWithRouting() (gas: 8494015)
Router_applyRampUpdates:testOnRampDisable() (gas: 52544)
Router_applyRampUpdates:testOnlyOwnerReverts() (gas: 12305)
Router_ccipSend:testCCIPSendLinkFeeNoTokenSuccess_gas() (gas: 110664)
Expand Down Expand Up @@ -366,10 +366,10 @@ Router_recoverTokens:testRecoverTokensNoFundsReverts() (gas: 17770)
Router_recoverTokens:testRecoverTokensNonOwnerReverts() (gas: 15354)
Router_recoverTokens:testRecoverTokensSuccess() (gas: 48644)
Router_recoverTokens:testRecoverTokensValueReceiverReverts() (gas: 444763)
Router_routeMessage:testAutoExecSuccess() (gas: 39277)
Router_routeMessage:testExecutionEventSuccess() (gas: 210166)
Router_routeMessage:testManualExecSuccess() (gas: 31374)
Router_routeMessage:testOnlyOffRampReverts() (gas: 27270)
Router_routeMessage:testAutoExecSuccess() (gas: 39367)
Router_routeMessage:testExecutionEventSuccess() (gas: 210301)
Router_routeMessage:testManualExecSuccess() (gas: 31419)
Router_routeMessage:testOnlyOffRampReverts() (gas: 27315)
Router_routeMessage:testWhenNotHealthyReverts() (gas: 43002)
Router_setWrappedNative:testOnlyOwnerReverts() (gas: 10978)
SelfFundedPingPong_ccipReceive:test_FundingIfNotANopReverts() (gas: 53509)
Expand Down
9 changes: 4 additions & 5 deletions contracts/src/v0.8/ccip/Router.sol
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,8 @@ contract Router is IRouter, IRouterClient, ITypeAndVersion, OwnerIsCreator {
uint256 gasLimit,
address receiver
) external override whenHealthy returns (bool success, bytes memory retData) {
// We only permit offRamps to call this function. We have to encode the sourceChainSelector
// and msg.sender into a uint256 to use as a key in the set.
if (!s_chainSelectorAndOffRamps.contains(_mergeChainSelectorAndOffRamp(message.sourceChainSelector, msg.sender)))
revert OnlyOffRamp();
// We only permit offRamps to call this function.
if (!isOffRamp(message.sourceChainSelector, msg.sender)) revert OnlyOffRamp();

// We encode here instead of the offRamps to constrain specifically what functions
// can be called from the router.
Expand Down Expand Up @@ -229,7 +227,8 @@ contract Router is IRouter, IRouterClient, ITypeAndVersion, OwnerIsCreator {
return offRamps;
}

function isOffRamp(uint64 sourceChainSelector, address offRamp) external view returns (bool) {
function isOffRamp(uint64 sourceChainSelector, address offRamp) public view returns (bool) {
// We have to encode the sourceChainSelector and offRamp into a uint256 to use as a key in the set.
return s_chainSelectorAndOffRamps.contains(_mergeChainSelectorAndOffRamp(sourceChainSelector, offRamp));
}

Expand Down
2 changes: 1 addition & 1 deletion core/gethwrappers/ccip/generated/router/router.go

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ maybe_revert_message_receiver: ../../../contracts/solc/v0.8.19/MaybeRevertMessag
mock_arm_contract: ../../../contracts/solc/v0.8.19/MockARM.abi ../../../contracts/solc/v0.8.19/MockARM.bin efcf4cb260a2b6a6e189639f62bb50ab650a135715c1fcd42c92dfa9d04aa0e3
ping_pong_demo: ../../../contracts/solc/v0.8.19/PingPongDemo.abi ../../../contracts/solc/v0.8.19/PingPongDemo.bin 61e6f809128174e884559a2015f6a60b29b56ffde1a1a380912f631a48508a6e
price_registry: ../../../contracts/solc/v0.8.19/PriceRegistry.abi ../../../contracts/solc/v0.8.19/PriceRegistry.bin 36e8d2c44a16fefb5258557cb1eae25eca1cc12efcd3c3270f91a90a5f81e7ea
router: ../../../contracts/solc/v0.8.19/Router.abi ../../../contracts/solc/v0.8.19/Router.bin 78a5f557cb3925da28aa755c8c69742b936e2db3c524bdff34a9f5ce024b8b0e
router: ../../../contracts/solc/v0.8.19/Router.abi ../../../contracts/solc/v0.8.19/Router.bin d990e74b6032d4f75ef6e733e31ac5d34a3ac3f453b14f8c3a71367bb011c6db
self_funded_ping_pong: ../../../contracts/solc/v0.8.19/SelfFundedPingPong.abi ../../../contracts/solc/v0.8.19/SelfFundedPingPong.bin fc2f9ac93f49f4a2a0a0008c2a660444cc5c127688f64beeb63e5f96a10c995e
usdc_token_pool: ../../../contracts/solc/v0.8.19/USDCTokenPool.abi ../../../contracts/solc/v0.8.19/USDCTokenPool.bin 1b96c5a03654d5c9167b21678b0f41dbd3ff4713dffeb255bdaa840ea80570e1
weth9: ../../../contracts/solc/v0.8.19/WETH9.abi ../../../contracts/solc/v0.8.19/WETH9.bin 5a7d64fb19b62ec523c7667ce4c2983295c05f74935b5f994c06a6f70d440f8b
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ func NewPriceRegistryV1_0_0(lggr logger.Logger, priceRegistryAddr common.Address
}, nil
}

// ApplyPriceRegistryUpdateV1_0_0 is a helper function used in tests only.
func ApplyPriceRegistryUpdateV1_0_0(t *testing.T, user *bind.TransactOpts, addr common.Address, ec client.Client, gasPrice []GasPrice, tokenPrices []TokenPrice) {
require.True(t, len(gasPrice) <= 1)
pr, err := price_registry_1_0_0.NewPriceRegistry(addr, ec)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ func (p *PriceRegistryV1_2_0) GetTokenPrices(ctx context.Context, wantedTokens [
return tpu, nil
}

// ApplyPriceRegistryUpdateV1_2_0 is a helper function used in tests only.
func ApplyPriceRegistryUpdateV1_2_0(t *testing.T, user *bind.TransactOpts, addr common.Address, ec client.Client, gasPrices []GasPrice, tokenPrices []TokenPrice) common.Hash {
require.True(t, len(gasPrices) <= 1)
pr, err := price_registry.NewPriceRegistry(addr, ec)
Expand Down

0 comments on commit 147e0ab

Please sign in to comment.