Skip to content

Commit

Permalink
fix low-level connectiontolightclientmapping calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
RnkSngh committed Oct 22, 2024
1 parent 1afd1ce commit d2c9eae
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 3 additions & 1 deletion test/Dispatcher/Dispatcher.multiclient.sol
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ contract DispatcherRealProofMultiClient is Base {
}

function test_Dispatcher_removeConnection() public {
// Make sure that the connection exists before we delete it
assertEq(_getConnectiontoClientIdMapping(connectionHops1[0]), address(opLightClient));
Ics23Proof memory openChannelProof =
load_proof("/test/payload/channel_confirm_pending_proof.hex", address(opLightClient));

Expand All @@ -153,7 +155,7 @@ contract DispatcherRealProofMultiClient is Base {

// Remove connection to ensure packet can't be acked after removing light client
dispatcherProxy.removeConnection(connectionHops1[0]);
assertEq(_getConnectiontoClientIdMapping(connectionHops1[0]), 0);
assertEq(_getConnectiontoClientIdMapping(connectionHops1[0]), address(0));

vm.expectRevert(abi.encodeWithSelector(IBCErrors.lightClientNotFound.selector, connectionHops1[0]));
dispatcherProxy.acknowledgement(packet, bytes("ack"), openChannelProof);
Expand Down
9 changes: 5 additions & 4 deletions test/utils/Dispatcher.base.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ contract Base is IbcEventsEmitter, ProofBase, TestUtilsTest {
uint256 fees
);

uint32 CONNECTION_TO_CLIENT_ID_STARTING_SLOT = 259;
uint32 CONNECTION_TO_CLIENT_ID_STARTING_SLOT = 260;
uint32 SEND_PACKET_COMMITMENT_STARTING_SLOT = 255;
uint64 UINT64_MAX = 18_446_744_073_709_551_615;
bytes32 PEPTIDE_CHAIN_ID = bytes32(uint256(444));
Expand Down Expand Up @@ -286,9 +286,10 @@ contract Base is IbcEventsEmitter, ProofBase, TestUtilsTest {
}

// Store connection in channelid to connection mapping using store
function _getConnectiontoClientIdMapping(string memory connection) internal view returns (uint256 clientId) {
bytes32 clientIdSlot = keccak256(abi.encode(connection, CONNECTION_TO_CLIENT_ID_STARTING_SLOT));
clientId = uint256(vm.load(address(dispatcherProxy), clientIdSlot));
function _getConnectiontoClientIdMapping(string memory connection) internal view returns (address clientId) {
bytes32 clientIdSlot =
keccak256(abi.encodePacked(bytes(connection), uint256(CONNECTION_TO_CLIENT_ID_STARTING_SLOT)));
clientId = address(uint160(uint256(vm.load(address(dispatcherProxy), clientIdSlot))));
}

function load_proof(string memory filepath, address lightClient) internal returns (Ics23Proof memory) {
Expand Down

0 comments on commit d2c9eae

Please sign in to comment.