diff --git a/offchain/authority-claimer/README.md b/offchain/authority-claimer/README.md index 71d934e4d..34582a06e 100644 --- a/offchain/authority-claimer/README.md +++ b/offchain/authority-claimer/README.md @@ -17,12 +17,11 @@ All dapps must share the same History contract and the same chain ID. Instead of using evironment variables, the claimer will get the list of application addresses from Redis, through the `experimental-dapp-addresses-config` key. -You must set this key with a string of comma separated (`", "`) - hex encoded addresses (without `"0x"`) - **before** starting the `authority-claimer`. +This key holds a Redis Set value. +You must use commands such as SADD and SREM to manipulate the list of addresses. +Addresses are encoded as hex strings without the leading `"0x"`. +Example address value: `"0202020202020202020202020202020202020202"`. -You may rewrite the list of addresses at any time, -The claimer will adjust accordingly. +You must set `experimental-dapp-addresses-config` **before** starting the `authority-claimer`. The `authority-claimer` stops with an error if the list is empty. - -Example key value: `"0202020202020202020202020202020202020202, 0505050505050505050505050505050505050505"`. +You may rewrite the list of addresses at any time, the claimer will adjust accordingly. diff --git a/offchain/authority-claimer/src/listener.rs b/offchain/authority-claimer/src/listener.rs index e559779c2..19103244d 100644 --- a/offchain/authority-claimer/src/listener.rs +++ b/offchain/authority-claimer/src/listener.rs @@ -589,8 +589,6 @@ mod tests { assert_eq_vec(fourth_batch_dapps, dapps); println!("--- All good with the fourth batch!"); } - - assert!(false); } #[tokio::test] @@ -605,7 +603,7 @@ mod tests { .await; let result = listener.listen().await; - assert!(result.is_ok()); + assert!(result.is_ok(), "{:?}", result); let expected_dapp = dapps.get(index).unwrap().clone(); let actual_dapp = result.unwrap().dapp_address; diff --git a/offchain/rollups-events/src/broker/mod.rs b/offchain/rollups-events/src/broker/mod.rs index 74e33587d..d44d4fb5c 100644 --- a/offchain/rollups-events/src/broker/mod.rs +++ b/offchain/rollups-events/src/broker/mod.rs @@ -28,7 +28,6 @@ pub mod indexer; pub const INITIAL_ID: &str = "0"; const DAPPS_KEY: &str = "experimental-dapp-addresses-config"; -const DAPPS_DIVIDER: &str = ", "; /// The `BrokerConnection` enum implements the `ConnectionLike` trait /// to satisfy the `AsyncCommands` trait bounds. @@ -368,14 +367,13 @@ impl Broker { pub async fn get_dapps(&mut self) -> Result, BrokerError> { retry(self.backoff.clone(), || async { tracing::trace!(key = DAPPS_KEY, "getting key"); - let reply: String = self.connection.clone().get(DAPPS_KEY).await?; - if reply.is_empty() { - return Ok(vec![]); - } - Ok(reply - .split(DAPPS_DIVIDER) + let reply: Vec = + self.connection.clone().smembers(DAPPS_KEY).await?; + let dapp_addresses: Vec
= reply + .iter() .map(|s| Address::from_str(s).unwrap()) - .collect::>()) + .collect(); + Ok(dapp_addresses) }) .await .context(ConnectionSnafu) @@ -388,17 +386,15 @@ impl Broker { dapp_addresses: Vec
, ) -> Result<(), BrokerError> { tracing::trace!(key = DAPPS_KEY, "setting key"); - let dapp_addresses: Vec<_> = dapp_addresses - .iter() - .map(|address| address.to_string()) - .collect(); - let dapp_addresses = dapp_addresses.join(DAPPS_DIVIDER); - let _: () = self - .connection - .clone() - .set(DAPPS_KEY, dapp_addresses) - .await - .unwrap(); + let _: () = self.connection.clone().del(DAPPS_KEY).await.unwrap(); + for dapp_address in dapp_addresses { + let _: () = self + .connection + .clone() + .sadd(DAPPS_KEY, dapp_address.to_string()) + .await + .unwrap(); + } Ok(()) } }