Skip to content

Commit

Permalink
node: track reward for dusk key
Browse files Browse the repository at this point in the history
  • Loading branch information
herr-seppia committed Mar 12, 2024
1 parent 88e05fb commit f87df68
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 9 additions & 2 deletions node/src/chain/acceptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use node_data::message::Payload;

use node_data::{Serializable, StepName};
use stake_contract_types::Unstake;
use std::sync::Arc;
use std::sync::{Arc, LazyLock};
use std::time::Duration;
use tokio::sync::RwLock;
use tracing::{debug, info, warn};
Expand Down Expand Up @@ -101,6 +101,12 @@ impl ProvisionerChange {
}
}

pub static DUSK_KEY: LazyLock<PublicKey> = LazyLock::new(|| {
let dusk_cpk_bytes = include_bytes!("../../../rusk/src/assets/dusk.cpk");
PublicKey::try_from(*dusk_cpk_bytes)
.expect("Dusk consensus public key to be valid")
});

impl<DB: database::DB, VM: vm::VMExecution, N: Network> Acceptor<N, DB, VM> {
/// Initializes a new `Acceptor` struct,
///
Expand Down Expand Up @@ -269,7 +275,8 @@ impl<DB: database::DB, VM: vm::VMExecution, N: Network> Acceptor<N, DB, VM> {
.try_into()
.map_err(|e| anyhow::anyhow!("Cannot deserialize bytes {e:?}"))?;
let reward = ProvisionerChange::Reward(generator);
let mut changed_provisioners = vec![reward];
let dusk_reward = ProvisionerChange::Reward(DUSK_KEY.clone());
let mut changed_provisioners = vec![reward, dusk_reward];

// Update provisioners if a slash has been applied
for bytes in blk.header().failed_iterations.to_missed_generators_bytes()
Expand Down
2 changes: 2 additions & 0 deletions node/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
//
// Copyright (c) DUSK NETWORK. All rights reserved.

#![feature(lazy_cell)]

pub mod chain;
pub mod database;
pub mod databroker;
Expand Down

0 comments on commit f87df68

Please sign in to comment.