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

feat(evm): fix commitment & more test variants #3113

Merged
merged 3 commits into from
Oct 17, 2024
Merged
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
5 changes: 3 additions & 2 deletions evm/contracts/core/04-channel/IBCPacket.sol
Original file line number Diff line number Diff line change
Expand Up @@ -217,18 +217,19 @@ abstract contract IBCPacketImpl is IBCStore, IIBCPacket {
if (l == 0) {
revert IBCErrors.ErrNotEnoughPackets();
}
uint32 sourceChannel = packets[0].sourceChannel;
uint32 destinationChannel = packets[0].destinationChannel;
IBCChannel storage channel = ensureChannelState(destinationChannel);
uint32 clientId = ensureConnectionState(channel.connectionId);
if (!intent) {
bytes32 proofCommitmentKey;
if (l == 1) {
proofCommitmentKey = IBCCommitment.batchReceiptsCommitmentKey(
destinationChannel, IBCPacketLib.commitPacket(packets[0])
sourceChannel, IBCPacketLib.commitPacket(packets[0])
);
} else {
proofCommitmentKey = IBCCommitment.batchReceiptsCommitmentKey(
destinationChannel, IBCPacketLib.commitPackets(packets)
sourceChannel, IBCPacketLib.commitPackets(packets)
);
}
if (
Expand Down
38 changes: 19 additions & 19 deletions evm/contracts/core/24-host/IBCCommitment.sol
Original file line number Diff line number Diff line change
@@ -1,78 +1,78 @@
pragma solidity ^0.8.27;

library IBCCommitment {
bytes1 public constant CLIENT_STATE = 0x00;
bytes1 public constant CONSENSUS_STATE = 0x01;
bytes1 public constant CONNECTIONS = 0x02;
bytes1 public constant CHANNELS = 0x03;
bytes1 public constant PACKETS = 0x04;
bytes1 public constant PACKET_ACKS = 0x05;
bytes1 public constant NEXT_SEQ_SEND = 0x06;
bytes1 public constant NEXT_SEQ_RECV = 0x07;
bytes1 public constant NEXT_SEQ_ACK = 0x08;
uint256 public constant CLIENT_STATE = 0x00;
uint256 public constant CONSENSUS_STATE = 0x01;
uint256 public constant CONNECTIONS = 0x02;
uint256 public constant CHANNELS = 0x03;
uint256 public constant PACKETS = 0x04;
uint256 public constant PACKET_ACKS = 0x05;
uint256 public constant NEXT_SEQ_SEND = 0x06;
uint256 public constant NEXT_SEQ_RECV = 0x07;
uint256 public constant NEXT_SEQ_ACK = 0x08;

function clientStatePath(
uint32 clientId
) internal pure returns (bytes memory) {
return abi.encodePacked(CLIENT_STATE, clientId);
return abi.encode(CLIENT_STATE, clientId);
}

function consensusStatePath(
uint32 clientId,
uint64 height
) internal pure returns (bytes memory) {
return abi.encodePacked(CONSENSUS_STATE, clientId, height);
return abi.encode(CONSENSUS_STATE, clientId, height);
}

function connectionPath(
uint32 connectionId
) internal pure returns (bytes memory) {
return abi.encodePacked(CONNECTIONS, connectionId);
return abi.encode(CONNECTIONS, connectionId);
}

function channelPath(
uint32 channelId
) internal pure returns (bytes memory) {
return abi.encodePacked(CHANNELS, channelId);
return abi.encode(CHANNELS, channelId);
}

function packetCommitmentPath(
uint32 channelId,
uint64 sequence
) internal pure returns (bytes memory) {
return abi.encodePacked(PACKETS, channelId, sequence);
return abi.encode(PACKETS, channelId, sequence);
}

function batchPacketsCommitmentPath(
uint32 channelId,
bytes32 batchHash
) internal pure returns (bytes memory) {
return abi.encodePacked(PACKETS, channelId, batchHash);
return abi.encode(PACKETS, channelId, batchHash);
}

function batchReceiptsCommitmentPath(
uint32 channelId,
bytes32 batchHash
) internal pure returns (bytes memory) {
return abi.encodePacked(PACKET_ACKS, channelId, batchHash);
return abi.encode(PACKET_ACKS, channelId, batchHash);
}

function nextSequenceSendCommitmentPath(
uint32 channelId
) internal pure returns (bytes memory) {
return abi.encodePacked(NEXT_SEQ_SEND, channelId);
return abi.encode(NEXT_SEQ_SEND, channelId);
}

function nextSequenceRecvCommitmentPath(
uint32 channelId
) internal pure returns (bytes memory) {
return abi.encodePacked(NEXT_SEQ_RECV, channelId);
return abi.encode(NEXT_SEQ_RECV, channelId);
}

function nextSequenceAckCommitmentPath(
uint32 channelId
) internal pure returns (bytes memory) {
return abi.encodePacked(NEXT_SEQ_ACK, channelId);
return abi.encode(NEXT_SEQ_ACK, channelId);
}

// Key generators for Commitment mapping
Expand Down
Loading