Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Low Hanging Gas Optimizations #224

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions contracts/core/Dispatcher.sol
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ contract Dispatcher is Ownable2StepUpgradeable, UUPSUpgradeable, ReentrancyGuard
mapping(address => mapping(bytes32 => mapping(uint64 => bool))) private _sendPacketCommitment;
// keep track of received packets to prevent replay attack
mapping(address => mapping(bytes32 => mapping(uint64 => bool))) private _recvPacketReceipt;
// keep track of outbound ack packets to prevent replay attack
mapping(address => mapping(bytes32 => mapping(uint64 => bool))) private _ackPacketCommitment;

ILightClient _UNUSED; // From previous dispatcher version
mapping(bytes32 => string) private _channelIdToConnection;
Expand Down Expand Up @@ -624,13 +622,6 @@ contract Dispatcher is Ownable2StepUpgradeable, UUPSUpgradeable, ReentrancyGuard
} else {
ack = AckPacket(false, data);
}
bool hasAckPacketCommitment = _ackPacketCommitment[receiver][packet.dest.channelId][packet.sequence];
// check is not necessary for sync-acks
if (hasAckPacketCommitment) {
revert IBCErrors.ackPacketCommitmentAlreadyExists();
}

_ackPacketCommitment[receiver][packet.dest.channelId][packet.sequence] = true;

emit WriteAckPacket(receiver, packet.dest.channelId, packet.sequence, ack);
}
Expand Down
3 changes: 2 additions & 1 deletion test/utils/Dispatcher.base.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ contract Base is IbcEventsEmitter, ProofBase, TestUtilsTest {

uint32 CONNECTION_TO_CLIENT_ID_STARTING_SLOT = 259;
uint32 SEND_PACKET_COMMITMENT_STARTING_SLOT = 255;
uint32 CHANNEL_ID_TO_CONNECTION_STARTING_SLOT = 258;
uint64 UINT64_MAX = 18_446_744_073_709_551_615;
bytes32 PEPTIDE_CHAIN_ID = bytes32(uint256(444));

Expand Down Expand Up @@ -269,7 +270,7 @@ contract Base is IbcEventsEmitter, ProofBase, TestUtilsTest {

// Store connection in channelid to connection mapping using store
function _storeChannelidToConnectionMapping(bytes32 channelId, bytes32 connection) internal {
bytes32 chanIdToConnectionMapping = keccak256(abi.encode(channelId, uint32(259)));
bytes32 chanIdToConnectionMapping = keccak256(abi.encode(channelId, CHANNEL_ID_TO_CONNECTION_STARTING_SLOT));
vm.store(address(dispatcherProxy), chanIdToConnectionMapping, connection);
}

Expand Down
Loading