Skip to content
Prev Previous commit
Next Next commit
rename unsafeLookupUpgradableModuleByPort to lookupUpgradableModuleBy…
…PortUnchecked

Signed-off-by: Jun Kimura <[email protected]>
  • Loading branch information
bluele committed Jul 13, 2024
commit 1828f708e4d58f620dc7f107d8f3bddf7240c835
2 changes: 1 addition & 1 deletion .gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ TestICS03Version:testIsSupportedVersion() (gas: 7864)
TestICS03Version:testPickVersion() (gas: 25327)
TestICS03Version:testVerifyProposedVersion() (gas: 11777)
TestICS03Version:testVerifySupportedFeature() (gas: 4153)
TestICS04Handshake:testBindPort() (gas: 429639)
TestICS04Handshake:testBindPort() (gas: 458549)
TestICS04Handshake:testChanClose() (gas: 12938942)
TestICS04Handshake:testChanOpenAck() (gas: 3459492)
TestICS04Handshake:testChanOpenConfirm() (gas: 3770761)
Expand Down
8 changes: 4 additions & 4 deletions contracts/core/04-channel/IBCChannelUpgrade.sol
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ contract IBCChannelUpgradeInitTryAck is IBCChannelUpgradeBase, IIBCChannelUpgrad
return false;
}

IIBCModuleUpgrade module = unsafeLookupUpgradableModuleByPort(msg_.portId);
IIBCModuleUpgrade module = lookupUpgradableModuleByPortUnchecked(msg_.portId);

if (channel.state == Channel.State.STATE_OPEN) {
// prove counterparty and move our own state to flushing
Expand Down Expand Up @@ -630,7 +630,7 @@ contract IBCChannelUpgradeConfirmTimeoutCancel is IBCChannelUpgradeBase, IIBCCha
&& msg_.counterpartyChannelState == Channel.State.STATE_FLUSHCOMPLETE
) {
openUpgradeHandshake(msg_.portId, msg_.channelId);
unsafeLookupUpgradableModuleByPort(msg_.portId).onChanUpgradeOpen(
lookupUpgradableModuleByPortUnchecked(msg_.portId).onChanUpgradeOpen(
msg_.portId, msg_.channelId, channel.upgrade_sequence
);
}
Expand Down Expand Up @@ -699,7 +699,7 @@ contract IBCChannelUpgradeConfirmTimeoutCancel is IBCChannelUpgradeBase, IIBCCha

// open callback must not return error since counterparty successfully upgraded
// make application state changes based on new channel parameters
unsafeLookupUpgradableModuleByPort(msg_.portId).onChanUpgradeOpen(
lookupUpgradableModuleByPortUnchecked(msg_.portId).onChanUpgradeOpen(
msg_.portId, msg_.channelId, channel.upgrade_sequence
);
}
Expand All @@ -720,7 +720,7 @@ contract IBCChannelUpgradeConfirmTimeoutCancel is IBCChannelUpgradeBase, IIBCCha
// otherwise, we can only cancel if the counterparty wrote an
// error receipt during the upgrade handshake
if (
unsafeLookupUpgradableModuleByPort(msg_.portId).isAuthorizedUpgrader(
lookupUpgradableModuleByPortUnchecked(msg_.portId).isAuthorizedUpgrader(
msg_.portId, msg_.channelId, _msgSender()
) && channel.state != Channel.State.STATE_FLUSHCOMPLETE
) {
Expand Down
6 changes: 3 additions & 3 deletions contracts/core/26-router/IBCModuleManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ contract IBCModuleManager is IBCHost, Context {
}

/**
* @dev unsafeLookupUpgradableModuleByPort will return the IBCModule corresponding to the portID
* @dev lookupUpgradableModuleByPortUnchecked will return the IBCModule corresponding to the portID
* It will revert if the module is not found
*
* Since the function does not check if the module supports the `IIBCModuleUpgrade` interface via ERC-165, it is unsafe but cheaper in gas cost than `lookupUpgradableModuleByPort`
*/
function unsafeLookupUpgradableModuleByPort(string calldata portId) internal view returns (IIBCModuleUpgrade) {
function lookupUpgradableModuleByPortUnchecked(string calldata portId) internal view returns (IIBCModuleUpgrade) {
return IIBCModuleUpgrade(address(lookupModuleByPort(portId)));
}

Expand Down Expand Up @@ -108,7 +108,7 @@ contract IBCModuleManager is IBCHost, Context {
return true;
}
}
return unsafeLookupUpgradableModuleByPort(portId).canTransitionToFlushComplete(
return lookupUpgradableModuleByPortUnchecked(portId).canTransitionToFlushComplete(
portId, channelId, upgradeSequence, _msgSender()
);
}
Expand Down