Skip to content

Commit cd471d7

Browse files
authored
Merge pull request #717 from input-output-hk/jpraynaud/716-fix-signer-unable-to-sign-2304.0-prerelease
Fix signer unable to sign with `2304.0 prerelease`
2 parents 513e09c + e3247d8 commit cd471d7

File tree

5 files changed

+62
-3
lines changed

5 files changed

+62
-3
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mithril-aggregator/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mithril-aggregator"
3-
version = "0.2.9"
3+
version = "0.2.10"
44
description = "A Mithril Aggregator server"
55
authors = { workspace = true }
66
edition = { workspace = true }

mithril-aggregator/src/runtime/runner.rs

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,13 @@ pub trait AggregatorRunnerTrait: Sync + Send {
7676
/// Read the stake distribution from the blockchain and store it.
7777
async fn update_stake_distribution(&self, new_beacon: &Beacon) -> Result<(), RuntimeError>;
7878

79-
/// Open the signer registration round for an epoch.
79+
/// Open the signer registration round of an epoch.
8080
async fn open_signer_registration_round(&self, new_beacon: &Beacon)
8181
-> Result<(), RuntimeError>;
8282

83+
/// Close the signer registration round of an epoch.
84+
async fn close_signer_registration_round(&self) -> Result<(), RuntimeError>;
85+
8386
/// Update the multisigner with the protocol parameters from configuration.
8487
async fn update_protocol_parameters_in_multisigner(
8588
&self,
@@ -314,6 +317,17 @@ impl AggregatorRunnerTrait for AggregatorRunner {
314317
Ok(())
315318
}
316319

320+
async fn close_signer_registration_round(&self) -> Result<(), RuntimeError> {
321+
debug!("RUNNER: close signer registration round");
322+
323+
self.dependencies
324+
.signer_registration_round_opener
325+
.close_registration_round()
326+
.await?;
327+
328+
Ok(())
329+
}
330+
317331
async fn update_protocol_parameters_in_multisigner(
318332
&self,
319333
new_beacon: &Beacon,
@@ -770,6 +784,32 @@ pub mod tests {
770784
);
771785
}
772786

787+
#[tokio::test]
788+
async fn test_close_signer_registration_round() {
789+
let (mut deps, config) = initialize_dependencies().await;
790+
let signer_registration_round_opener = Arc::new(MithrilSignerRegisterer::new(
791+
deps.chain_observer.clone(),
792+
deps.verification_key_store.clone(),
793+
));
794+
deps.signer_registration_round_opener = signer_registration_round_opener.clone();
795+
let deps = Arc::new(deps);
796+
let runner = AggregatorRunner::new(config, deps.clone());
797+
798+
let beacon = fake_data::beacon();
799+
runner
800+
.open_signer_registration_round(&beacon)
801+
.await
802+
.expect("opening signer registration should not return an error");
803+
804+
runner
805+
.close_signer_registration_round()
806+
.await
807+
.expect("closing signer registration should not return an error");
808+
809+
let saved_current_round = signer_registration_round_opener.get_current_round().await;
810+
assert!(saved_current_round.is_none());
811+
}
812+
773813
#[tokio::test]
774814
async fn test_update_protocol_parameters_in_multisigner() {
775815
let (deps, config) = initialize_dependencies().await;

mithril-aggregator/src/runtime/state_machine.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ impl AggregatorRuntime {
221221

222222
if maybe_current_beacon.is_none() || maybe_current_beacon.unwrap().epoch < new_beacon.epoch
223223
{
224+
self.runner.close_signer_registration_round().await?;
224225
self.runner.update_stake_distribution(&new_beacon).await?;
225226
self.runner
226227
.open_signer_registration_round(&new_beacon)
@@ -365,6 +366,10 @@ mod tests {
365366
.with(predicate::eq(fake_data::beacon()))
366367
.once()
367368
.returning(|_| Ok(()));
369+
runner
370+
.expect_close_signer_registration_round()
371+
.once()
372+
.returning(|| Ok(()));
368373
runner
369374
.expect_open_signer_registration_round()
370375
.once()
@@ -408,6 +413,10 @@ mod tests {
408413
.with(predicate::eq(fake_data::beacon()))
409414
.once()
410415
.returning(|_| Ok(()));
416+
runner
417+
.expect_close_signer_registration_round()
418+
.once()
419+
.returning(|| Ok(()));
411420
runner
412421
.expect_open_signer_registration_round()
413422
.once()

mithril-aggregator/src/signer_registerer.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ pub trait SignerRegistrationRoundOpener: Sync + Send {
7979
registration_epoch: Epoch,
8080
stake_distribution: StakeDistribution,
8181
) -> Result<(), SignerRegistrationError>;
82+
83+
/// Close a signer registration round
84+
async fn close_registration_round(&self) -> Result<(), SignerRegistrationError>;
8285
}
8386

8487
/// Implementation of a [SignerRegisterer]
@@ -127,6 +130,13 @@ impl SignerRegistrationRoundOpener for MithrilSignerRegisterer {
127130

128131
Ok(())
129132
}
133+
134+
async fn close_registration_round(&self) -> Result<(), SignerRegistrationError> {
135+
let mut current_round = self.current_round.write().await;
136+
*current_round = None;
137+
138+
Ok(())
139+
}
130140
}
131141

132142
#[async_trait]

0 commit comments

Comments
 (0)