Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

node: Reward Voters/Validators of previous block #1873

Merged
merged 31 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
9a4d12b
consensus: Pass a list of voters to be rewarded to both EST and VST c…
Jun 20, 2024
9384784
node: Add voters list to both accept and vst methods
Jun 20, 2024
f984978
rusk: Reward voters with cumulative reward
Jun 20, 2024
76f9207
WIP: Generate a list of Voters from previous block
Jun 20, 2024
c603ea4
node: Return a merged set of voters of previous block
Jun 21, 2024
1700ee0
consensus: Add members method
Jun 21, 2024
3316682
consensus: Return a copy of the generated committee
Jun 21, 2024
31a04d6
node: Return both prev_block_voters and tip_block_voters lists
Jun 21, 2024
192be7e
node: Initialize consensus round with tip_block_voters. Execute VM::a…
Jun 21, 2024
e9f7adc
rusk: Update coinbase_value
Jun 21, 2024
ef363b8
consensus: Rename prev_block_voters to att_voters
Jun 25, 2024
f2287e8
node: Provide the voters of tip attestation to consensus engine
Jun 25, 2024
a175d3a
consensus: Fix aggregator unit test
Jun 26, 2024
2b98f97
rusk: Update coinbase_value doc
Jun 26, 2024
4a20d11
node: Update verify_failed_iterations
Jun 26, 2024
f3f7c07
Merge branch 'master' into fix-1832
goshawk-3 Jun 26, 2024
a1b9cd8
rusk: Fix unit tests
Jun 26, 2024
88283f2
rusk: 10/80/10 reward values to Dusk/Generator/Validators
Jun 27, 2024
635e567
Merge branch 'master' into fix-1832
goshawk-3 Jun 27, 2024
fd71f5b
rusk: Trace reward values in log debug
Jun 27, 2024
3f9f688
consensus: Pass proper set of voters to VST call
Jun 28, 2024
b8a8b84
node: Regenerate committees with provisioners_list.prev() on consensu…
Jun 28, 2024
a14437a
rusk: Handle InvalidCreditsCount. Fix credit_reward calc
Jun 28, 2024
f3c94e7
node: Rename get_voters to get_att_voters
Jun 28, 2024
91ff119
rusk: Wrap voters in Option
Jul 2, 2024
4446ac8
node: Wrap voters in Option
Jul 2, 2024
53205ee
consensus: Wrap voters in Option
Jul 2, 2024
4bfdcbf
Merge branch 'master' into fix-1832
goshawk-3 Jul 3, 2024
15579b7
node: Rename verify_block_att to verify_success_att
Jul 3, 2024
76c34cb
node: Address comments
Jul 3, 2024
7a87345
node: Move merge_committees in verify_block_att
Jul 3, 2024
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
2 changes: 1 addition & 1 deletion node/benches/accept.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ pub fn verify_block_att(c: &mut Criterion) {
),
move |b| {
b.to_async(FuturesExecutor).iter(|| async {
chain::verify_block_att(
chain::verify_success_att(
[0u8; 32],
tip_header.seed,
&provisioners,
Expand Down
2 changes: 1 addition & 1 deletion node/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use crate::{LongLivedService, Message};
use anyhow::Result;
use async_trait::async_trait;
use dusk_consensus::commons::ConsensusError;
pub use header_validation::verify_block_att;
pub use header_validation::verify_success_att;
use node_data::ledger::{to_str, BlockWithLabel, Label};
use node_data::message::AsyncQueue;
use node_data::message::{Payload, Topics};
Expand Down
29 changes: 16 additions & 13 deletions node/src/chain/header_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ impl<'a, DB: database::DB> Validator<'a, DB> {
tip_block_voters = self.verify_winning_att(candidate_block).await?;
}

let res = self.verify_failed_iterations(candidate_block).await?;
Ok((res, prev_block_voters, tip_block_voters))
let pni = self.verify_failed_iterations(candidate_block).await?;
Ok((pni, prev_block_voters, tip_block_voters))
}

/// Verifies any non-attestation field
Expand Down Expand Up @@ -174,7 +174,7 @@ impl<'a, DB: database::DB> Validator<'a, DB> {
Ok::<_, anyhow::Error>(prior_tip.header().seed)
})?;

fed-franz marked this conversation as resolved.
Show resolved Hide resolved
let (_, _, v_committee, r_committee) = verify_block_att(
let (_, _, v_committee, r_committee) = verify_success_att(
self.prev_header.prev_block_hash,
prev_block_seed,
self.provisioners.prev(),
Expand Down Expand Up @@ -218,7 +218,7 @@ impl<'a, DB: database::DB> Validator<'a, DB> {

anyhow::ensure!(pk == &expected_pk, "Invalid generator. Expected {expected_pk:?}, actual {pk:?}");

let (_, rat_quorum, _, _) = verify_block_att(
let (_, rat_quorum, _, _) = verify_success_att(
self.prev_header.hash,
self.prev_header.seed,
self.provisioners.current(),
Expand All @@ -241,7 +241,7 @@ impl<'a, DB: database::DB> Validator<'a, DB> {
&self,
candidate_block: &'a ledger::Header,
) -> anyhow::Result<Vec<VoterWithCredits>> {
let (_, _, v_committee, r_committee) = verify_block_att(
let (_, _, v_committee, r_committee) = verify_success_att(
self.prev_header.hash,
self.prev_header.seed,
self.provisioners.current(),
Expand All @@ -254,27 +254,30 @@ impl<'a, DB: database::DB> Validator<'a, DB> {
Ok(merge_committees(&v_committee, &r_committee))
}

/// Generates and returns voters
/// Extracts voters list of a block.
///
/// Returns a list of voters with their credits for both ratification and
/// validation step
pub async fn get_voters(
fed-franz marked this conversation as resolved.
Show resolved Hide resolved
tip_block: &'a ledger::Header,
blk: &'a ledger::Header,
provisioners: &Provisioners,
prev_block_seed: Seed,
) -> anyhow::Result<Vec<VoterWithCredits>> {
let (_, _, v_committee, r_committee) = verify_block_att(
tip_block.prev_block_hash,
let (_, _, v_committee, r_committee) = verify_success_att(
blk.prev_block_hash,
prev_block_seed,
provisioners,
tip_block.height,
&tip_block.att,
tip_block.iteration,
blk.height,
&blk.att,
blk.iteration,
)
.await?;

Ok(merge_committees(&v_committee, &r_committee))
}
}

pub async fn verify_block_att(
pub async fn verify_success_att(
herr-seppia marked this conversation as resolved.
Show resolved Hide resolved
prev_block_hash: [u8; 32],
curr_seed: Signature,
curr_eligible_provisioners: &Provisioners,
Expand Down
1 change: 0 additions & 1 deletion rusk/src/lib/chain/rusk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,6 @@ fn reward_slash_and_update_root(
)
}

let slash_amount = emission_amount(block_height);
for to_slash in slashing {
let r = session.call::<_, ()>(
STAKE_CONTRACT,
Expand Down
Loading