Skip to content

Commit eddb15c

Browse files
committed
fix to call _msgSender() once
Signed-off-by: Jun Kimura <[email protected]>
1 parent d745ca8 commit eddb15c

File tree

2 files changed

+29
-24
lines changed

2 files changed

+29
-24
lines changed

.gas-snapshot

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
IBCMockAppTest:testHandshake() (gas: 4420356)
22
IBCMockAppTest:testHandshakeBetweenDifferentPorts() (gas: 3334286)
3-
IBCMockAppTest:testPacketRelay() (gas: 13931833)
4-
IBCMockAppTest:testPacketTimeout() (gas: 4279248)
3+
IBCMockAppTest:testPacketRelay() (gas: 13932025)
4+
IBCMockAppTest:testPacketTimeout() (gas: 4279264)
55
IBCTest:testBenchmarkCreateMockClient() (gas: 233366)
66
IBCTest:testBenchmarkLCUpdateMockClient() (gas: 62005)
77
IBCTest:testBenchmarkRecvPacket() (gas: 158921)
8-
IBCTest:testBenchmarkSendPacket() (gas: 128424)
8+
IBCTest:testBenchmarkSendPacket() (gas: 128432)
99
IBCTest:testBenchmarkUpdateMockClient() (gas: 160229)
1010
IBCTest:testToUint128((uint64,uint64)) (runs: 256, μ: 947, ~: 947)
11-
TestICS02:testCreateClient() (gas: 36495526)
12-
TestICS02:testInvalidCreateClient() (gas: 36392801)
13-
TestICS02:testInvalidUpdateClient() (gas: 36391653)
14-
TestICS02:testRegisterClient() (gas: 36047252)
15-
TestICS02:testRegisterClientDuplicatedClientType() (gas: 36032561)
16-
TestICS02:testRegisterClientInvalidClientType() (gas: 36061888)
17-
TestICS02:testUpdateClient() (gas: 36559853)
11+
TestICS02:testCreateClient() (gas: 36491844)
12+
TestICS02:testInvalidCreateClient() (gas: 36389119)
13+
TestICS02:testInvalidUpdateClient() (gas: 36387971)
14+
TestICS02:testRegisterClient() (gas: 36043570)
15+
TestICS02:testRegisterClientDuplicatedClientType() (gas: 36028879)
16+
TestICS02:testRegisterClientInvalidClientType() (gas: 36058206)
17+
TestICS02:testUpdateClient() (gas: 36556171)
1818
TestICS03Handshake:testConnOpenAck() (gas: 1858296)
1919
TestICS03Handshake:testConnOpenConfirm() (gas: 2054231)
2020
TestICS03Handshake:testConnOpenInit() (gas: 1429882)
@@ -40,29 +40,29 @@ TestICS04Handshake:testInvalidChanOpenConfirm() (gas: 2517409)
4040
TestICS04Handshake:testInvalidChanOpenInit() (gas: 1758661)
4141
TestICS04Handshake:testInvalidChanOpenTry() (gas: 1773244)
4242
TestICS04Packet:testAcknowledgementPacket() (gas: 3351462)
43-
TestICS04Packet:testInvalidSendPacket() (gas: 3551771)
44-
TestICS04Packet:testRecvPacket() (gas: 10996557)
45-
TestICS04Packet:testRecvPacketTimeoutHeight() (gas: 3260153)
46-
TestICS04Packet:testRecvPacketTimeoutTimestamp() (gas: 3279303)
47-
TestICS04Packet:testSendPacket() (gas: 6413328)
48-
TestICS04Packet:testTimeoutOnClose() (gas: 3553803)
43+
TestICS04Packet:testInvalidSendPacket() (gas: 3551893)
44+
TestICS04Packet:testRecvPacket() (gas: 10996621)
45+
TestICS04Packet:testRecvPacketTimeoutHeight() (gas: 3260169)
46+
TestICS04Packet:testRecvPacketTimeoutTimestamp() (gas: 3279319)
47+
TestICS04Packet:testSendPacket() (gas: 6413456)
48+
TestICS04Packet:testTimeoutOnClose() (gas: 3553819)
4949
TestICS04Upgrade:testUpgradeAuthorityCancel() (gas: 46740549)
5050
TestICS04Upgrade:testUpgradeCannotCancelWithOldErrorReceipt() (gas: 3455585)
51-
TestICS04Upgrade:testUpgradeCannotRecvNextUpgradePacket() (gas: 5266805)
51+
TestICS04Upgrade:testUpgradeCannotRecvNextUpgradePacket() (gas: 5266813)
5252
TestICS04Upgrade:testUpgradeCounterpartyAdvanceNextSequenceBeforeOpen() (gas: 5235961)
5353
TestICS04Upgrade:testUpgradeCrossingHelloIncompatibleProposals() (gas: 4405943)
5454
TestICS04Upgrade:testUpgradeFull() (gas: 57782504)
5555
TestICS04Upgrade:testUpgradeInit() (gas: 3068733)
5656
TestICS04Upgrade:testUpgradeNoChanges() (gas: 2471886)
5757
TestICS04Upgrade:testUpgradeOutOfSync() (gas: 3902195)
58-
TestICS04Upgrade:testUpgradeRelaySuccessAtCounterpartyFlushComplete() (gas: 5238569)
59-
TestICS04Upgrade:testUpgradeRelaySuccessAtFlushing() (gas: 5612538)
58+
TestICS04Upgrade:testUpgradeRelaySuccessAtCounterpartyFlushComplete() (gas: 5238577)
59+
TestICS04Upgrade:testUpgradeRelaySuccessAtFlushing() (gas: 5612554)
6060
TestICS04Upgrade:testUpgradeSendPacketFailAtFlushingOrFlushComplete() (gas: 4070944)
6161
TestICS04Upgrade:testUpgradeTimeoutAbortAck() (gas: 17679407)
6262
TestICS04Upgrade:testUpgradeTimeoutAbortConfirm() (gas: 21317099)
6363
TestICS04Upgrade:testUpgradeTimeoutUpgrade() (gas: 44263811)
64-
TestICS04Upgrade:testUpgradeToOrdered() (gas: 56495097)
65-
TestICS04Upgrade:testUpgradeToUnordered() (gas: 45103883)
64+
TestICS04Upgrade:testUpgradeToOrdered() (gas: 56495273)
65+
TestICS04Upgrade:testUpgradeToUnordered() (gas: 45104027)
6666
TestICS04UpgradeApp:testUpgradeAuthorizationChanneNotFound() (gas: 61712)
6767
TestICS04UpgradeApp:testUpgradeAuthorizationRePropose() (gas: 2565510)
6868
TestICS04UpgradeApp:testUpgradeAuthorizationRemove() (gas: 2473948)

contracts/core/26-router/IBCModuleManager.sol

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ contract IBCModuleManager is IBCHost, Context {
2222
}
2323

2424
/**
25-
* @dev claimCapability allows the IBC app module to claim a capability that core IBC passes to it
25+
* @dev claimChannelCapability allows the IBC app module to claim a capability that core IBC passes to it
2626
*/
2727
function claimChannelCapability(string calldata portId, string memory channelId, address addr) internal {
2828
if (channelCapabilities[portId][channelId] != address(0)) {
@@ -36,13 +36,15 @@ contract IBCModuleManager is IBCHost, Context {
3636
* It allows for a caller to check that a capability does in fact correspond to a particular name.
3737
*/
3838
function authenticateChannelCapability(string calldata portId, string calldata channelId) internal view {
39-
if (channelCapabilities[portId][channelId] != _msgSender()) {
40-
revert IBCHostFailedAuthenticateChannelCapability(portId, channelId, _msgSender());
39+
address msgSender = _msgSender();
40+
if (channelCapabilities[portId][channelId] != msgSender) {
41+
revert IBCHostFailedAuthenticateChannelCapability(portId, channelId, msgSender);
4142
}
4243
}
4344

4445
/**
4546
* @dev lookupModuleByPort will return the IBCModule along with the capability associated with a given portID
47+
* If the module is not found, it will revert
4648
*/
4749
function lookupModuleByPort(string calldata portId) internal view virtual returns (IIBCModule) {
4850
address module = portCapabilities[portId];
@@ -54,6 +56,7 @@ contract IBCModuleManager is IBCHost, Context {
5456

5557
/**
5658
* @dev lookupModuleByChannel will return the IBCModule along with the capability associated with a given channel defined by its portID and channelID
59+
* If the module is not found, it will revert
5760
*/
5861
function lookupModuleByChannel(string calldata portId, string calldata channelId)
5962
internal
@@ -70,13 +73,15 @@ contract IBCModuleManager is IBCHost, Context {
7073

7174
/**
7275
* @dev lookupUpgradableModuleByPort will return the IBCModule along with the capability associated with a given portID
76+
* If the module is not found, it will revert
7377
*/
7478
function lookupUpgradableModuleByPort(string calldata portId) internal view returns (IIBCModuleUpgrade) {
7579
return IIBCModuleUpgrade(address(lookupModuleByPort(portId)));
7680
}
7781

7882
/**
7983
* @dev canTransitionToFlushComplete checks if the module can transition to flush complete at the given upgrade sequence
84+
* If the module is not found, it will revert
8085
*/
8186
function canTransitionToFlushComplete(
8287
Channel.Order ordering,

0 commit comments

Comments
 (0)