Skip to content

Commit a9ea673

Browse files
chore: better constant and refactor lens creation event
1 parent c07d968 commit a9ea673

File tree

9 files changed

+26
-31
lines changed

9 files changed

+26
-31
lines changed

cosmwasm/ibc-union/core/src/contract.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use ibc_union_spec::{
2828
path::{
2929
commit_packets, BatchPacketsPath, BatchReceiptsPath, ChannelPath, ClientStatePath,
3030
ConnectionPath, ConsensusStatePath, COMMITMENT_MAGIC, COMMITMENT_MAGIC_ACK,
31-
COSMWASM_COMMITMENT_PREFIX,
31+
IBC_UNION_COSMWASM_COMMITMENT_PREFIX,
3232
},
3333
types::{Channel, ChannelState, Connection, ConnectionState, Packet},
3434
};
@@ -1689,12 +1689,12 @@ fn merge_ack(mut ack: H256) -> H256 {
16891689
}
16901690

16911691
fn store_commit(deps: DepsMut, key: &H256, value: &H256) {
1692-
let canonical_path = [&COSMWASM_COMMITMENT_PREFIX, key.as_ref()].concat();
1692+
let canonical_path = [&IBC_UNION_COSMWASM_COMMITMENT_PREFIX, key.as_ref()].concat();
16931693
deps.storage.set(&canonical_path, value.as_ref());
16941694
}
16951695

16961696
fn read_commit(deps: Deps, key: &H256) -> Option<H256> {
1697-
let canonical_path = [&COSMWASM_COMMITMENT_PREFIX, key.as_ref()].concat();
1697+
let canonical_path = [&IBC_UNION_COSMWASM_COMMITMENT_PREFIX, key.as_ref()].concat();
16981698
deps.storage.get(&canonical_path).map(|bz| {
16991699
bz.try_into()
17001700
.expect("H256 is the only value ever written to this storage; qed;")

evm/contracts/clients/CometblsClient.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ contract CometblsClient is
431431
abi.encodePacked(
432432
IBCStoreLib.WASMD_CONTRACT_STORE_PREFIX,
433433
contractAddress,
434-
IBCStoreLib.COSMWASM_COMMITMENT_PREFIX,
434+
IBCStoreLib.IBC_UNION_COSMWASM_COMMITMENT_PREFIX,
435435
path
436436
),
437437
value
@@ -456,7 +456,7 @@ contract CometblsClient is
456456
abi.encodePacked(
457457
IBCStoreLib.WASMD_CONTRACT_STORE_PREFIX,
458458
contractAddress,
459-
IBCStoreLib.COSMWASM_COMMITMENT_PREFIX,
459+
IBCStoreLib.IBC_UNION_COSMWASM_COMMITMENT_PREFIX,
460460
path
461461
)
462462
);

evm/contracts/clients/StateLensIcs23Ics23Client.sol

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,6 @@ library StateLensIcs23Ics23Lib {
4747
error ErrInvalidInitialConsensusState();
4848
error ErrInvalidMisbehaviour();
4949

50-
event CreateLensClient(
51-
uint32 clientId, uint32 l1ClientId, uint32 l2ClientId, string l2ChainId
52-
);
53-
5450
function encode(
5551
ConsensusState memory consensusState
5652
) internal pure returns (bytes memory) {
@@ -142,7 +138,7 @@ contract StateLensIcs23Ics23Client is
142138
height: block.number
143139
});
144140

145-
emit StateLensIcs23Ics23Lib.CreateLensClient(
141+
emit CreateLensClient(
146142
clientId,
147143
clientState.l1ClientId,
148144
clientState.l2ClientId,
@@ -254,7 +250,7 @@ contract StateLensIcs23Ics23Client is
254250
abi.encodePacked(
255251
IBCStoreLib.WASMD_CONTRACT_STORE_PREFIX,
256252
contractAddress,
257-
IBCStoreLib.COSMWASM_COMMITMENT_PREFIX,
253+
IBCStoreLib.IBC_UNION_COSMWASM_COMMITMENT_PREFIX,
258254
path
259255
),
260256
value
@@ -279,7 +275,7 @@ contract StateLensIcs23Ics23Client is
279275
abi.encodePacked(
280276
IBCStoreLib.WASMD_CONTRACT_STORE_PREFIX,
281277
contractAddress,
282-
IBCStoreLib.COSMWASM_COMMITMENT_PREFIX,
278+
IBCStoreLib.IBC_UNION_COSMWASM_COMMITMENT_PREFIX,
283279
path
284280
)
285281
);

evm/contracts/clients/StateLensIcs23MptClient.sol

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,6 @@ struct ConsensusState {
3636
}
3737

3838
library StateLensIcs23MptLib {
39-
uint256 public constant EVM_IBC_COMMITMENT_SLOT = 0;
40-
41-
event CreateLensClient(
42-
uint32 clientId, uint32 l1ClientId, uint32 l2ClientId, string l2ChainId
43-
);
44-
4539
error ErrNotIBC();
4640
error ErrTrustedConsensusStateNotFound();
4741
error ErrClientFrozen();
@@ -148,7 +142,7 @@ contract StateLensIcs23MptClient is
148142
clientStates[clientId] = clientState;
149143
consensusStates[clientId][clientState.l2LatestHeight] = consensusState;
150144

151-
emit StateLensIcs23MptLib.CreateLensClient(
145+
emit CreateLensClient(
152146
clientId,
153147
clientState.l1ClientId,
154148
clientState.l2ClientId,
@@ -257,7 +251,7 @@ contract StateLensIcs23MptClient is
257251
}
258252
bytes32 storageRoot = consensusStates[clientId][height].storageRoot;
259253
bytes32 slot = keccak256(
260-
abi.encodePacked(path, StateLensIcs23MptLib.EVM_IBC_COMMITMENT_SLOT)
254+
abi.encodePacked(path, IBCStoreLib.IBC_UNION_EVM_COMMITMENT_SLOT)
261255
);
262256
(bool exists, bytes calldata provenValue) = MPTVerifier.verifyTrieValue(
263257
proof, keccak256(abi.encodePacked(slot)), storageRoot
@@ -278,7 +272,7 @@ contract StateLensIcs23MptClient is
278272
}
279273
bytes32 storageRoot = consensusStates[clientId][height].storageRoot;
280274
bytes32 slot = keccak256(
281-
abi.encodePacked(path, StateLensIcs23MptLib.EVM_IBC_COMMITMENT_SLOT)
275+
abi.encodePacked(path, IBCStoreLib.IBC_UNION_EVM_COMMITMENT_SLOT)
282276
);
283277
(bool exists,) = MPTVerifier.verifyTrieValue(
284278
proof, keccak256(abi.encodePacked(slot)), storageRoot

evm/contracts/clients/StateLensIcs23SmtClient.sol

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,6 @@ struct ConsensusState {
3333
}
3434

3535
library StateLensIcs23SmtLib {
36-
uint256 public constant EVM_IBC_COMMITMENT_SLOT = 0;
37-
38-
event CreateLensClient(
39-
uint32 clientId, uint32 l1ClientId, uint32 l2ClientId, string l2ChainId
40-
);
41-
4236
error ErrNotIBC();
4337
error ErrTrustedConsensusStateNotFound();
4438
error ErrClientFrozen();
@@ -152,7 +146,7 @@ contract StateLensIcs23SmtClient is
152146
clientStates[clientId] = clientState;
153147
consensusStates[clientId][clientState.l2LatestHeight] = consensusState;
154148

155-
emit StateLensIcs23SmtLib.CreateLensClient(
149+
emit CreateLensClient(
156150
clientId,
157151
clientState.l1ClientId,
158152
clientState.l2ClientId,

evm/contracts/core/02-client/IBCClient.sol

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ import "../02-client/IIBCClient.sol";
99
library IBCClientLib {
1010
event RegisterClient(string indexed clientType, address clientAddress);
1111
event CreateClient(
12-
string indexed clientType, uint32 indexed clientId, string counterpartyChainId
12+
string indexed clientType,
13+
uint32 indexed clientId,
14+
string counterpartyChainId
1315
);
1416
event UpdateClient(uint32 indexed clientId, uint64 height);
1517
event Misbehaviour(uint32 indexed clientId);

evm/contracts/core/02-client/ILightClient.sol

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ struct ConsensusStateUpdate {
88
uint64 height;
99
}
1010

11+
event CreateLensClient(
12+
uint32 indexed clientId,
13+
uint32 indexed l1ClientId,
14+
uint32 indexed l2ClientId,
15+
string l2ChainId
16+
);
17+
1118
/**
1219
* @dev This defines an interface for Light Client contract can be integrated with ibc-solidity.
1320
* You can register the Light Client contract that implements this through `registerClient` on IBCHandler.

evm/contracts/core/24-host/IBCStore.sol

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ import "../Types.sol";
77
library IBCStoreLib {
88
bytes public constant WASMD_MODULE_STORE_KEY = bytes("wasm");
99
bytes1 public constant WASMD_CONTRACT_STORE_PREFIX = 0x03;
10-
bytes1 public constant COSMWASM_COMMITMENT_PREFIX = 0x00;
10+
bytes1 public constant IBC_UNION_COSMWASM_COMMITMENT_PREFIX = 0x00;
11+
12+
uint256 public constant IBC_UNION_EVM_COMMITMENT_SLOT = 0;
1113
}
1214

1315
abstract contract IBCStore {

lib/ibc-union-spec/src/path.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use voyager_core::IbcStorePathKey;
99
use super::IbcUnion;
1010
use crate::types::{Channel, ChannelId, ClientId, Connection, ConnectionId, Packet};
1111

12-
pub const COSMWASM_COMMITMENT_PREFIX: [u8; 1] = [0x00];
12+
pub const IBC_UNION_COSMWASM_COMMITMENT_PREFIX: [u8; 1] = [0x00];
1313

1414
/// 0x0100000000000000000000000000000000000000000000000000000000000000
1515
pub const COMMITMENT_MAGIC: H256 = {

0 commit comments

Comments
 (0)