Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ function endBlockFactory(
currentEpochIndex,
proposersPaidCount: rsResponse.proposersPaidCount,
paidEpochIndex: rsResponse.paidEpochIndex,
}, `${rsResponse.proposersPaidCount} masternodes were paid for epoch #${rsResponse.paidEpochIndex}`);
refundedEpochsCount: rsResponse.refundedEpochsCount,
}, `${rsResponse.proposersPaidCount} masternodes were paid for epoch #${rsResponse.paidEpochIndex}. ${rsResponse.refundedEpochsCount} epochs were refunded.`);
Comment thread
shumkov marked this conversation as resolved.
Outdated
}

const consensusParamUpdates = await createConsensusParamUpdate(height, round, consensusLogger);
Expand Down
23 changes: 14 additions & 9 deletions packages/rs-drive-abci/src/abci/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,26 +116,31 @@ pub struct BlockEndResponse {
pub proposers_paid_count: Option<u16>,
/// Index of the last epoch that marked as paid
pub paid_epoch_index: Option<u16>,
/// A number of epochs which had refunded
pub refunded_epochs_count: Option<usize>,
}

impl BlockEndResponse {
/// Retrieves fee info for the block to be implemented in the BlockEndResponse
pub(crate) fn from_process_block_fees_result(
process_block_fees_result: &ProcessedBlockFeesResult,
) -> Self {
let (proposers_paid_count, paid_epoch_index) = process_block_fees_result
.payouts
.as_ref()
.map_or((None, None), |proposer_payouts| {
(
Some(proposer_payouts.proposers_paid_count),
Some(proposer_payouts.paid_epoch_index),
)
});
let (proposers_paid_count, paid_epoch_index, refunded_epochs_count) =
process_block_fees_result.payouts.as_ref().map_or(
(None, None, None),
|proposer_payouts| {
(
Some(proposer_payouts.proposers_paid_count),
Some(proposer_payouts.paid_epoch_index),
Some(proposer_payouts.refunded_epochs_count),
)
},
);

Self {
proposers_paid_count,
paid_epoch_index,
refunded_epochs_count,
}
}
}
Expand Down
23 changes: 19 additions & 4 deletions packages/rs-drive-abci/src/execution/fee_pools/fee_distribution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ pub struct ProposersPayouts {
pub proposers_paid_count: u16,
/// Index of last epoch marked as paid
pub paid_epoch_index: u16,
/// A number of epochs which had refunded
pub refunded_epochs_count: usize,
}

/// Struct containing the amount of processing and storage fees in the distribution pools
Expand Down Expand Up @@ -100,6 +102,7 @@ impl Platform {
&self,
current_epoch_index: u16,
cached_current_epoch_start_block_height: Option<u64>,
refunded_epochs_count: usize,
transaction: TransactionArg,
batch: &mut GroveDbOpBatch,
) -> Result<Option<ProposersPayouts>, Error> {
Expand Down Expand Up @@ -145,6 +148,7 @@ impl Platform {
Ok(Some(ProposersPayouts {
proposers_paid_count,
paid_epoch_index: unpaid_epoch.epoch_index,
refunded_epochs_count,
}))
}

Expand Down Expand Up @@ -449,6 +453,7 @@ mod tests {
.add_distribute_fees_from_oldest_unpaid_epoch_pool_to_proposers_operations(
current_epoch_index,
None,
0,
Some(&transaction),
&mut batch,
)
Expand Down Expand Up @@ -510,6 +515,7 @@ mod tests {
.add_distribute_fees_from_oldest_unpaid_epoch_pool_to_proposers_operations(
current_epoch_index,
None,
0,
Some(&transaction),
&mut batch,
)
Expand All @@ -524,7 +530,8 @@ mod tests {
proposer_payouts,
Some(ProposersPayouts {
proposers_paid_count: 50,
paid_epoch_index: 0
paid_epoch_index: 0,
refunded_epochs_count: 0,
})
));
}
Expand Down Expand Up @@ -597,6 +604,7 @@ mod tests {
.add_distribute_fees_from_oldest_unpaid_epoch_pool_to_proposers_operations(
current_epoch_index,
None,
0,
Some(&transaction),
&mut batch,
)
Expand All @@ -611,7 +619,8 @@ mod tests {
proposer_payouts,
Some(ProposersPayouts {
proposers_paid_count: 100,
paid_epoch_index: 0
paid_epoch_index: 0,
refunded_epochs_count: 0
})
));
}
Expand Down Expand Up @@ -699,6 +708,7 @@ mod tests {
.add_distribute_fees_from_oldest_unpaid_epoch_pool_to_proposers_operations(
current_epoch_index,
None,
1,
Some(&transaction),
&mut batch,
)
Expand All @@ -713,7 +723,8 @@ mod tests {
proposer_payouts,
Some(ProposersPayouts {
proposers_paid_count: 150,
paid_epoch_index: 0
paid_epoch_index: 0,
refunded_epochs_count: 1
})
));
}
Expand Down Expand Up @@ -769,6 +780,7 @@ mod tests {
.add_distribute_fees_from_oldest_unpaid_epoch_pool_to_proposers_operations(
current_epoch.index,
None,
0,
Some(&transaction),
&mut batch,
)
Expand Down Expand Up @@ -861,6 +873,7 @@ mod tests {
.add_distribute_fees_from_oldest_unpaid_epoch_pool_to_proposers_operations(
current_epoch.index,
None,
0,
Some(&transaction),
&mut batch,
)
Expand All @@ -875,7 +888,8 @@ mod tests {
proposer_payouts,
Some(ProposersPayouts {
proposers_paid_count: proposers_count,
paid_epoch_index: 0
paid_epoch_index: 0,
refunded_epochs_count: 0
Comment thread
shumkov marked this conversation as resolved.
Outdated
})
));

Expand All @@ -895,6 +909,7 @@ mod tests {
.add_distribute_fees_from_oldest_unpaid_epoch_pool_to_proposers_operations(
current_epoch.index,
None,
0,
Some(&transaction),
&mut batch,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ impl Platform {
.add_distribute_fees_from_oldest_unpaid_epoch_pool_to_proposers_operations(
epoch_info.current_epoch_index,
cached_current_epoch_start_block_height,
storage_fee_distribution_result
.as_ref()
.map(|result| result.refunded_epochs_count)
.unwrap_or(0),
transaction,
&mut batch,
)?;
Expand Down
1 change: 1 addition & 0 deletions packages/rs-drive-nodejs/Drive.js
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,7 @@ Drive.calculateStorageFeeDistributionAmountAndLeftovers = calculateStorageFeeDis
* @typedef BlockEndResponse
* @property {number} [proposersPaidCount]
* @property {number} [paidEpochIndex]
* @property {number} [refundedEpochsCount]
*/

/**
Expand Down
1 change: 1 addition & 0 deletions packages/rs-drive-nodejs/test/Drive.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,7 @@ describe('Drive', () => {

expect(response).to.have.property('proposersPaidCount');
expect(response).to.have.property('paidEpochIndex');
expect(response).to.have.property('refundedEpochsCount');
});
});

Expand Down