Skip to content

Commit

Permalink
fix(experimental): log duplicate addresses
Browse files Browse the repository at this point in the history
This fixes an issue where the redis set was being manipulated during the
update process.
  • Loading branch information
marcelstanley committed Aug 26, 2024
1 parent bea5c7f commit d61103f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 35 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.5.1] 2024-08-16
## [1.5.1] 2024-08-26

### Added

Expand Down
29 changes: 0 additions & 29 deletions offchain/authority-claimer/src/listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -531,35 +531,6 @@ mod tests {
assert_listen(&mut listener, &dapps, &vec![0]).await;
}

#[tokio::test]
async fn multidapp_listen_with_duplicate_dapps() {
let docker = Cli::default();
let (fixture, mut listener, dapps) =
setup_multidapp_listener(&docker, false).await.unwrap();
fixture.dapps_set(vec![]).await;

// Initializes with 0 addresses in the set.
assert_eq!(0, fixture.dapps_members().await.len());

// We add a lowercase and an uppercase version of the same address.
let dapp: Address = [10; 20].into();
fixture.dapps_add(dapp.to_string().to_lowercase()).await;
fixture.dapps_add(dapp.to_string().to_uppercase()).await;

// We now have 2 addresses in the set.
assert_eq!(2, fixture.dapps_members().await.len());

// We then produce some claims and listen for them.
let mut epochs = vec![0; dapps.len()];
let indexes = vec![2, 2, 0];
multidapp_produce_claims(&fixture, &mut epochs, &dapps, &indexes).await;
let indexes = vec![2, 2];
assert_listen(&mut listener, &dapps, &indexes).await;

// Now we have 1 address because one of the duplicates got deleted.
assert_eq!(1, fixture.dapps_members().await.len());
}

#[tokio::test]
async fn multidapp_listen_with_changing_dapps() {
let docker = Cli::default();
Expand Down
9 changes: 4 additions & 5 deletions offchain/rollups-events/src/broker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,11 +380,10 @@ impl Broker {
match dapp_address {
Ok(dapp_address) => {
if dapp_addresses.contains(&dapp_address) {
let _: () = self
.connection
.clone()
.srem(DAPPS_KEY, value)
.await?;
tracing::info!(
"Ignored duplicate DApp address {:?}",
value,
)
} else {
dapp_addresses.push(dapp_address);
}
Expand Down

0 comments on commit d61103f

Please sign in to comment.