Skip to content

Commit d07bc55

Browse files
author
Rano | Ranadeep
authored
fix: use contract addresses to filter events (#469)
1 parent f6ef32a commit d07bc55

5 files changed

Lines changed: 18 additions & 23 deletions

File tree

  • relayer/crates

relayer/crates/starknet-chain-components/src/components/encoding/event.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,10 @@ mod preset {
8686
]:
8787
DecodeClientRelayEvents,
8888
(ViaCairo, Option<Erc20Event>):
89+
// Only used in erc20 e2e test
8990
DecodeOptionalByClassHash<symbol!("erc20_hashes")>,
9091
(ViaCairo, Option<IbcTransferEvent>):
91-
DecodeOptionalByClassHash<symbol!("ics20_hashes")>,
92+
DecodeOptionalByContractAddress<symbol!("ics20_contract_addresses")>,
9293
[
9394
(ViaCairo, Option<ConnectionHandshakeEvents>),
9495
(ViaCairo, Option<ChannelHandshakeEvents>),

relayer/crates/starknet-chain-context/src/contexts/encoding/event.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ use crate::impls::HandleStarknetChainError;
2626
#[derive(HasField, Default, Clone)]
2727
pub struct StarknetEventEncoding {
2828
pub erc20_hashes: OnceLock<HashSet<Felt>>,
29-
pub ics20_hashes: OnceLock<HashSet<Felt>>,
30-
pub ibc_client_hashes: OnceLock<HashSet<Felt>>,
29+
pub ics20_contract_addresses: OnceLock<HashSet<StarknetAddress>>,
30+
pub ibc_client_contract_addresses: OnceLock<HashSet<StarknetAddress>>,
3131
pub ibc_core_contract_addresses: OnceLock<HashSet<StarknetAddress>>,
3232
}
3333

relayer/crates/starknet-cli/src/contexts/app.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -243,14 +243,8 @@ impl ConfigUpdater<StarknetChainDriver, StarknetRelayerConfig> for UpdateStarkne
243243
.erc20_hashes
244244
.get()
245245
.and_then(|hashes| hashes.iter().cloned().next()),
246-
ics20: event_encoding
247-
.ics20_hashes
248-
.get()
249-
.and_then(|hashes| hashes.iter().cloned().next()),
250-
ibc_client: event_encoding
251-
.ibc_client_hashes
252-
.get()
253-
.and_then(|hashes| hashes.iter().cloned().next()),
246+
ics20: None,
247+
ibc_client: None,
254248
};
255249

256250
let relayer_wallet_path_1 = chain_driver

relayer/crates/starknet-relayer/src/contexts/builder.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -399,12 +399,12 @@ impl StarknetBuilder {
399399
.set(HashSet::from_iter(contract_classes.erc20))
400400
.unwrap();
401401
event_encoding
402-
.ics20_hashes
403-
.set(HashSet::from_iter(contract_classes.ics20))
402+
.ics20_contract_addresses
403+
.set(HashSet::from_iter(contract_addresses.ibc_ics20))
404404
.unwrap();
405405
event_encoding
406-
.ibc_client_hashes
407-
.set(HashSet::from_iter(contract_classes.ibc_client))
406+
.ibc_client_contract_addresses
407+
.set(HashSet::from_iter(contract_addresses.ibc_client))
408408
.unwrap();
409409
event_encoding
410410
.ibc_core_contract_addresses

relayer/crates/starknet-test-components/src/impls/bootstrap/deploy_contracts.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ where
6767
{
6868
fn erc20_hashes(&self) -> &OnceLock<HashSet<Chain::ContractClassHash>>;
6969

70-
fn ics20_hashes(&self) -> &OnceLock<HashSet<Chain::ContractClassHash>>;
70+
fn ics20_contract_addresses(&self) -> &OnceLock<HashSet<Chain::Address>>;
7171

72-
fn ibc_client_hashes(&self) -> &OnceLock<HashSet<Chain::ContractClassHash>>;
72+
fn ibc_client_contract_addresses(&self) -> &OnceLock<HashSet<Chain::Address>>;
7373

7474
fn ibc_core_contract_addresses(&self) -> &OnceLock<HashSet<Chain::Address>>;
7575
}
@@ -344,17 +344,17 @@ where
344344
})?;
345345

346346
event_encoding
347-
.ics20_hashes()
348-
.set([ics20_class_hash].into())
347+
.ics20_contract_addresses()
348+
.set([ics20_contract_address].into())
349349
.map_err(|_| {
350-
Bootstrap::raise_error("failed to set ics20_class_hash on event encoding")
350+
Bootstrap::raise_error("failed to set ics20_contract_address on event encoding")
351351
})?;
352352

353353
event_encoding
354-
.ibc_client_hashes()
355-
.set([comet_client_class_hash].into())
354+
.ibc_client_contract_addresses()
355+
.set([comet_client_address].into())
356356
.map_err(|_| {
357-
Bootstrap::raise_error("failed to set comet_client_class_hash on event encoding")
357+
Bootstrap::raise_error("failed to set comet_client_address on event encoding")
358358
})?;
359359

360360
event_encoding

0 commit comments

Comments
 (0)