Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion common/src/messages.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! Definition of Acropolis messages

use crate::address::StakeAddress;
use crate::commands::chain_sync::ChainSyncCommand;
use crate::commands::transactions::{TransactionsCommand, TransactionsCommandResponse};
use crate::genesis_values::GenesisValues;
Expand Down Expand Up @@ -303,7 +304,8 @@ pub struct SPOStateMessage {
pub spos: Vec<PoolRegistration>,

/// SPOs in the above list which retired at the start of this epoch, by operator ID
pub retired_spos: Vec<PoolId>,
/// and the reward account to pay the deposit refund to
pub retired_spos: Vec<(PoolId, StakeAddress)>,
}

/// Cardano message enum
Expand Down
15 changes: 6 additions & 9 deletions modules/accounts_state/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -813,15 +813,12 @@ impl State {

// Check for any SPOs that have retired this epoch and need deposit refunds
self.pool_refunds = Vec::new();
for id in &spo_msg.retired_spos {
if let Some(retired_spo) = new_spos.get(id) {
debug!(
"SPO {} has retired - refunding their deposit to {}",
id, retired_spo.reward_account
);
self.pool_refunds.push((retired_spo.operator, retired_spo.reward_account.clone()));
// Store full StakeAddress
}
for (id, reward_account) in &spo_msg.retired_spos {
debug!(
"SPO {} has retired - refunding their deposit to {}",
id, reward_account
);
self.pool_refunds.push((*id, reward_account.clone()));

// Schedule to retire - we need them to still be in place when we count
// blocks for the previous epoch
Expand Down
49,480 changes: 49,480 additions & 0 deletions modules/accounts_state/test-data/rewards.mainnet.219.csv

Large diffs are not rendered by default.

51,426 changes: 51,426 additions & 0 deletions modules/accounts_state/test-data/rewards.mainnet.220.csv

Large diffs are not rendered by default.

53,503 changes: 53,503 additions & 0 deletions modules/accounts_state/test-data/rewards.mainnet.221.csv

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions modules/spo_state/src/spo_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,9 @@ impl SPOState {
CardanoMessage::SPOState(SPOStateMessage { retired_spos, .. }),
)) = message.as_ref()
{
retired_pools_history
.handle_deregistrations(block_info, retired_spos);
let pool_ids: Vec<PoolId> =
retired_spos.iter().map(|(spo, _sa)| *spo).collect();
retired_pools_history.handle_deregistrations(block_info, &pool_ids);
}

// publish spo message
Expand Down
12 changes: 6 additions & 6 deletions modules/spo_state/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,26 +273,26 @@ impl State {
debug!(epoch = self.epoch, "New epoch");

// Flatten into vector of registrations, before retirement so retiring ones
// are still included
// are still included **
let spos = self.spos.values().cloned().collect();

// Update any pending
// Now apply it fully to persistent state, including creating new ones
for (operator, reg) in &self.pending_updates {
self.spos.insert(*operator, reg.clone());
}
self.pending_updates.clear();

// Deregister any pending
let mut retired_spos: Vec<PoolId> = Vec::new();
let mut retired_spos: Vec<(PoolId, StakeAddress)> = Vec::new();
let deregistrations = self.pending_deregistrations.remove(&self.epoch);
if let Some(deregistrations) = deregistrations {
for dr in deregistrations {
debug!("Retiring SPO {}", dr);
match self.spos.remove(&dr) {
None => vld
.push_anyhow(anyhow!("Retirement requested for unregistered SPO {}", dr,)),
Some(_de_reg) => {
retired_spos.push(dr);
Some(de_reg) => {
retired_spos.push((dr, de_reg.reward_account.clone()));
}
};
}
Expand All @@ -302,7 +302,7 @@ impl State {
block.clone(),
CardanoMessage::SPOState(SPOStateMessage {
epoch: block.epoch - 1,
spos,
spos, // Note - list captured at ** before creation and deletion
retired_spos,
}),
)))
Expand Down