Ver Fonte

consensus: chopped Participants

aggstam há 3 anos atrás
pai
commit
0bd7d8a376

+ 1 - 11
bin/darkfid/src/main.rs

@@ -32,9 +32,7 @@ use darkfi::{
             MAINNET_GENESIS_HASH_BYTES, MAINNET_GENESIS_TIMESTAMP, TESTNET_GENESIS_HASH_BYTES,
             TESTNET_GENESIS_TIMESTAMP,
         },
-        proto::{
-            ProtocolParticipant, ProtocolProposal, ProtocolSync, ProtocolSyncConsensus, ProtocolTx,
-        },
+        proto::{ProtocolProposal, ProtocolSync, ProtocolSyncConsensus, ProtocolTx},
         state::ValidatorStatePtr,
         task::{block_sync_task, proposal_task},
         ValidatorState,
@@ -399,14 +397,6 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'_>>) -> Result<()> {
             let p2p = net::P2p::new(consensus_network_settings).await;
             let registry = p2p.protocol_registry();
 
-            let _state = state.clone();
-            registry
-                .register(net::SESSION_ALL, move |channel, p2p| {
-                    let state = _state.clone();
-                    async move { ProtocolParticipant::init(channel, state, p2p).await.unwrap() }
-                })
-                .await;
-
             let _state = state.clone();
             registry
                 .register(net::SESSION_ALL, move |channel, p2p| {

+ 4 - 2
example/less_than.rs

@@ -141,8 +141,10 @@ fn simple_lessthan(k: u32) -> Result<(), halo2_proofs::plonk::Error> {
 }
 
 fn fullrange_lessthan(k: u32) -> Result<(), halo2_proofs::plonk::Error> {
-    let y_str: &'static str = "2485393101277319054866673974886504690592360759087472860138246047042221199789";
-    let t_str: &'static str = "20228360686725123198855333388287068776098384779255635716769234906173337213460";
+    let y_str: &'static str =
+        "2485393101277319054866673974886504690592360759087472860138246047042221199789";
+    let t_str: &'static str =
+        "20228360686725123198855333388287068776098384779255635716769234906173337213460";
     let y: pallas::Base =
         fbig2base(Float10::from_str_native(y_str).unwrap().with_precision(*RADIX_BITS).value());
     let t: pallas::Base =

+ 1 - 1
script/research/nodes-tool/Cargo.toml

@@ -10,7 +10,7 @@ edition = "2021"
 [dependencies]
 async-std = "1.12.0"
 blake3 = "1.3.1"
-darkfi = {path = "../../../", features = ["blockchain", "node", "wallet"]}
+darkfi = {path = "../../../", features = ["blockchain", "wallet"]}
 darkfi-sdk = {path = "../../../src/sdk"}
 darkfi-serial = {path = "../../../src/serial"}
 serde = "1.0.147"

+ 10 - 34
script/research/nodes-tool/src/main.rs

@@ -16,7 +16,6 @@
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-use async_std::sync::Arc;
 use std::{fs::File, io::Write};
 
 use darkfi::{
@@ -27,13 +26,11 @@ use darkfi::{
     },
     consensus::{
         block::{Block, BlockProposal, Header, ProposalChain},
+        constants::TESTNET_GENESIS_HASH_BYTES,
         metadata::Metadata,
-        participant::Participant,
-        state::{ConsensusState, ValidatorState},
-        TESTNET_GENESIS_HASH_BYTES,
+        state::{ConsensusState, ValidatorState},        
     },
-    node::Client,
-    tx::Transaction,
+    tx2::Transaction,
     util::{path::expand_path, time::Timestamp},
     wallet::walletdb::init_wallet,
     Result,
@@ -42,32 +39,15 @@ use darkfi_sdk::crypto::MerkleNode;
 use darkfi_serial::serialize;
 
 // TODO: Add missing fields
-#[derive(Debug)]
-struct ParticipantInfo {
-    _address: String,
-}
-
-impl ParticipantInfo {
-    pub fn new(participant: &Participant) -> ParticipantInfo {
-        let _address = participant.address.to_string();
-        ParticipantInfo { _address }
-    }
-}
-
 #[derive(Debug)]
 struct MetadataInfo {
-    _address: String,
-    _participants: Vec<ParticipantInfo>,
+    _public_key: String,
 }
 
 impl MetadataInfo {
     pub fn new(metadata: &Metadata) -> MetadataInfo {
-        let _address = metadata.address.to_string();
-        let mut _participants = Vec::new();
-        for participant in &metadata.participants {
-            _participants.push(ParticipantInfo::new(&participant));
-        }
-        MetadataInfo { _address, _participants }
+        let _public_key = metadata.public_key.to_string();
+        MetadataInfo { _public_key }
     }
 }
 
@@ -294,17 +274,15 @@ impl BlockchainInfo {
 
 #[derive(Debug)]
 struct StateInfo {
-    _address: String,
     _consensus: ConsensusInfo,
     _blockchain: BlockchainInfo,
 }
 
 impl StateInfo {
     pub fn new(state: &ValidatorState) -> StateInfo {
-        let _address = state.address.to_string();
         let _consensus = ConsensusInfo::new(&state.consensus);
         let _blockchain = BlockchainInfo::new(&state.blockchain);
-        StateInfo { _address, _consensus, _blockchain }
+        StateInfo { _consensus, _blockchain }
     }
 }
 
@@ -315,18 +293,16 @@ async fn generate(name: &str, folder: &str) -> Result<()> {
     // Initialize or load wallet
     let path = folder.to_owned() + "/wallet.db";
     let wallet = init_wallet(&path, &pass).await?;
-    let client = Arc::new(Client::new(wallet.clone()).await?);
-    let address = wallet.get_default_address().await?;
 
     // Initialize or load sled database
     let path = folder.to_owned() + "/blockchain/testnet";
     let db_path = expand_path(&path).unwrap();
     let sled_db = sled::open(&db_path)?;
 
-    // Data export
-    println!("Exporting data for {:?} - {:?}", name, address.to_string());
+    // Data export    
     let state =
-        ValidatorState::new(&sled_db, genesis_ts, genesis_data, client, vec![], vec![]).await?;
+        ValidatorState::new(&sled_db, genesis_ts, genesis_data, wallet, vec![], vec![]).await?;
+    println!("Exporting data for {:?}", name);
     let info = StateInfo::new(&*state.read().await);
     let info_string = format!("{:#?}", info);
     let path = name.to_owned() + "_testnet_db";

+ 4 - 36
src/consensus/metadata.rs

@@ -24,7 +24,7 @@ use darkfi_serial::{SerialDecodable, SerialEncodable};
 use log::error;
 use rand::rngs::OsRng;
 
-use super::{leadcoin::LeadCoin, Participant};
+use super::leadcoin::LeadCoin;
 use crate::{
     crypto::{
         proof::{Proof, ProvingKey, VerifyingKey},
@@ -39,21 +39,15 @@ pub struct Metadata {
     /// Block owner signature
     pub signature: Signature,
     /// Block owner public_key
-    pub public_key: PublicKey,
+    pub public_key: PublicKey, // TODO: remove this(to be derived by proof)
     /// Block owner slot competing coins public inputs
     pub public_inputs: Vec<pallas::Base>,
-    /// Block owner newlly minted coin public inputs
-    pub new_public_inputs: Vec<pallas::Base>,
     /// Block owner winning coin index
     pub winning_index: usize,
-    /// Block owner winning coin serial number
-    pub serial_number: pallas::Base,
     /// Response of global random oracle, or it's emulation.
     pub eta: [u8; 32],
     /// Leader NIZK proof
     pub proof: LeadProof,
-    /// Nodes participating in the consensus process
-    pub participants: Vec<Participant>,
 }
 
 // FIXME: Why do we even need default() ?
@@ -62,23 +56,10 @@ impl Default for Metadata {
         let keypair = Keypair::random(&mut OsRng);
         let signature = Signature::dummy();
         let public_inputs = vec![];
-        let new_public_inputs = vec![];
         let winning_index = 0;
-        let serial_number = pallas::Base::from(0);
         let eta: [u8; 32] = *blake3::hash(b"let there be dark!").as_bytes();
         let proof = LeadProof::default();
-        let participants = vec![];
-        Self {
-            signature,
-            public_key: keypair.public,
-            public_inputs,
-            new_public_inputs,
-            winning_index,
-            serial_number,
-            eta,
-            proof,
-            participants,
-        }
+        Self { signature, public_key: keypair.public, public_inputs, winning_index, eta, proof }
     }
 }
 
@@ -87,24 +68,11 @@ impl Metadata {
         signature: Signature,
         public_key: PublicKey,
         public_inputs: Vec<pallas::Base>,
-        new_public_inputs: Vec<pallas::Base>,
         winning_index: usize,
-        serial_number: pallas::Base,
         eta: [u8; 32],
         proof: LeadProof,
-        participants: Vec<Participant>,
     ) -> Self {
-        Self {
-            signature,
-            public_key,
-            public_inputs,
-            new_public_inputs,
-            winning_index,
-            serial_number,
-            eta,
-            proof,
-            participants,
-        }
+        Self { signature, public_key, public_inputs, winning_index, eta, proof }
     }
 }
 

+ 0 - 4
src/consensus/mod.rs

@@ -27,10 +27,6 @@ pub mod constants;
 pub mod metadata;
 pub use metadata::{LeadProof, Metadata};
 
-/// Consensus participant
-pub mod participant;
-pub use participant::Participant;
-
 /// Consensus state
 pub mod state;
 pub use state::{ValidatorState, ValidatorStatePtr};

+ 0 - 44
src/consensus/participant.rs

@@ -1,44 +0,0 @@
-/* This file is part of DarkFi (https://dark.fi)
- *
- * Copyright (C) 2020-2022 Dyne.org foundation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <https://www.gnu.org/licenses/>.
- */
-
-use darkfi_sdk::{crypto::PublicKey, pasta::pallas};
-use darkfi_serial::{SerialDecodable, SerialEncodable};
-
-use crate::net;
-
-/// This struct represents a tuple of the form:
-/// (`public_key`, `node_address`, `last_slot_seen`,`slot_quarantined`)
-#[derive(Debug, Clone, PartialEq, Eq, SerialEncodable, SerialDecodable)]
-pub struct Participant {
-    /// Node public key
-    pub public_key: PublicKey,
-    /// Node current epoch competing coins public inputs
-    pub coins: Vec<Vec<Vec<pallas::Base>>>,
-}
-
-impl Participant {
-    pub fn new(public_key: PublicKey, coins: Vec<Vec<Vec<pallas::Base>>>) -> Self {
-        Self { public_key, coins }
-    }
-}
-
-impl net::Message for Participant {
-    fn name() -> &'static str {
-        "participant"
-    }
-}

+ 0 - 4
src/consensus/proto/mod.rs

@@ -16,10 +16,6 @@
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-/// Participant announce protocol
-mod protocol_participant;
-pub use protocol_participant::ProtocolParticipant;
-
 /// Block proposal protocol
 mod protocol_proposal;
 pub use protocol_proposal::ProtocolProposal;

+ 0 - 104
src/consensus/proto/protocol_participant.rs

@@ -1,104 +0,0 @@
-/* This file is part of DarkFi (https://dark.fi)
- *
- * Copyright (C) 2020-2022 Dyne.org foundation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <https://www.gnu.org/licenses/>.
- */
-
-use async_std::sync::Arc;
-use async_trait::async_trait;
-use log::{debug, error};
-use smol::Executor;
-use url::Url;
-
-use crate::{
-    consensus::{Participant, ValidatorStatePtr},
-    net::{
-        ChannelPtr, MessageSubscription, P2pPtr, ProtocolBase, ProtocolBasePtr,
-        ProtocolJobsManager, ProtocolJobsManagerPtr,
-    },
-    Result,
-};
-
-pub struct ProtocolParticipant {
-    participant_sub: MessageSubscription<Participant>,
-    jobsman: ProtocolJobsManagerPtr,
-    state: ValidatorStatePtr,
-    p2p: P2pPtr,
-    channel_address: Url,
-}
-
-impl ProtocolParticipant {
-    pub async fn init(
-        channel: ChannelPtr,
-        state: ValidatorStatePtr,
-        p2p: P2pPtr,
-    ) -> Result<ProtocolBasePtr> {
-        debug!("Adding ProtocolParticipant to the protocol registry");
-        let msg_subsystem = channel.get_message_subsystem();
-        msg_subsystem.add_dispatch::<Participant>().await;
-
-        let participant_sub = channel.subscribe_msg::<Participant>().await?;
-        let channel_address = channel.address();
-
-        Ok(Arc::new(Self {
-            participant_sub,
-            jobsman: ProtocolJobsManager::new("ParticipantProtocol", channel),
-            state,
-            p2p,
-            channel_address,
-        }))
-    }
-
-    async fn handle_receive_participant(self: Arc<Self>) -> Result<()> {
-        debug!("ProtocolParticipant::handle_receive_participant() [START]");
-        let exclude_list = vec![self.channel_address.clone()];
-        loop {
-            let participant = match self.participant_sub.receive().await {
-                Ok(v) => v,
-                Err(e) => {
-                    error!("ProtocolParticipant::handle_receive_participant(): recv error: {}", e);
-                    continue
-                }
-            };
-
-            debug!("ProtocolParticipant::handle_receive_participant() recv: {:?}", participant);
-
-            if self.state.write().await.append_participant(&participant) {
-                let p = (*participant).clone();
-                if let Err(e) = self.p2p.broadcast_with_exclude(p, &exclude_list).await {
-                    error!("ProtocolParticipant::handle_receive_participant(): p2p broadcast failed: {}", e);
-                };
-            }
-        }
-    }
-}
-
-#[async_trait]
-impl ProtocolBase for ProtocolParticipant {
-    async fn start(self: Arc<Self>, executor: Arc<Executor<'_>>) -> Result<()> {
-        debug!("ProtocolParticipant::start() [START]");
-        self.jobsman.clone().start(executor.clone());
-        self.jobsman
-            .clone()
-            .spawn(self.clone().handle_receive_participant(), executor.clone())
-            .await;
-        debug!("ProtocolParticipant::start() [END]");
-        Ok(())
-    }
-
-    fn name(&self) -> &'static str {
-        "ProtocolParticipant"
-    }
-}

+ 1 - 2
src/consensus/proto/protocol_sync_consensus.rs

@@ -75,8 +75,7 @@ impl ProtocolSyncConsensus {
             // Extra validations can be added here.
             let lock = self.state.read().await;
             let proposals = lock.consensus.proposals.clone();
-            let participants = lock.consensus.participants.clone();
-            let response = ConsensusResponse { proposals, participants };
+            let response = ConsensusResponse { proposals };
             if let Err(e) = self.channel.send(response).await {
                 error!("ProtocolSyncConsensus::handle_receive_request() channel send fail: {}", e);
             };

+ 23 - 94
src/consensus/state.rs

@@ -16,12 +16,7 @@
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-use std::{
-    collections::{hash_map::DefaultHasher, BTreeMap},
-    hash::{Hash, Hasher},
-    io::Cursor,
-    time::Duration,
-};
+use std::{io::Cursor, time::Duration};
 
 use async_std::sync::{Arc, RwLock};
 use chrono::{NaiveDateTime, Utc};
@@ -31,7 +26,7 @@ use darkfi_sdk::crypto::{
     poseidon_hash,
     schnorr::{SchnorrPublic, SchnorrSecret},
     util::mod_r_p,
-    ContractId, MerkleNode, PublicKey, SecretKey,
+    ContractId, MerkleNode, PublicKey,
 };
 use darkfi_serial::{serialize, Decodable, Encodable, SerialDecodable, SerialEncodable, WriteExt};
 use incrementalmerkletree::{bridgetree::BridgeTree, Tree};
@@ -47,8 +42,7 @@ use super::{
     constants::{DELTA, EPOCH_LENGTH, LEADER_PROOF_K, LOTTERY_HEAD_START, P, RADIX_BITS, REWARD},
     leadcoin::{LeadCoin, LeadCoinSecrets},
     utils::fbig2base,
-    Block, BlockInfo, BlockProposal, Float10, Header, LeadProof, Metadata, Participant,
-    ProposalChain,
+    Block, BlockInfo, BlockProposal, Float10, Header, LeadProof, Metadata, ProposalChain,
 };
 
 use crate::{
@@ -72,10 +66,6 @@ pub struct ConsensusState {
     pub genesis_block: blake3::Hash,
     /// Fork chains containing block proposals
     pub proposals: Vec<ProposalChain>,
-    /// Validators currently participating in the consensus
-    pub participants: BTreeMap<[u8; 32], Participant>,
-    /// Last slot participants where refreshed
-    pub refreshed: u64,
     /// Current epoch
     pub epoch: u64,
     /// Current epoch eta
@@ -93,8 +83,6 @@ impl ConsensusState {
             genesis_ts,
             genesis_block,
             proposals: vec![],
-            participants: BTreeMap::new(),
-            refreshed: 0,
             epoch: 0,
             epoch_eta: pallas::Base::one(),
             coins: vec![],
@@ -104,10 +92,7 @@ impl ConsensusState {
 
 /// Auxiliary structure used for consensus syncing.
 #[derive(Debug, SerialEncodable, SerialDecodable)]
-pub struct ConsensusRequest {
-    /// Validator wallet address
-    pub public_key: PublicKey,
-}
+pub struct ConsensusRequest {}
 
 impl net::Message for ConsensusRequest {
     fn name() -> &'static str {
@@ -120,7 +105,6 @@ impl net::Message for ConsensusRequest {
 pub struct ConsensusResponse {
     /// Hot/live data used by the consensus algorithm
     pub proposals: Vec<ProposalChain>,
-    pub participants: BTreeMap<[u8; 32], Participant>,
 }
 
 impl net::Message for ConsensusResponse {
@@ -134,10 +118,6 @@ pub type ValidatorStatePtr = Arc<RwLock<ValidatorState>>;
 
 /// This struct represents the state of a validator node.
 pub struct ValidatorState {
-    /// Node wallet public key
-    pub public_key: PublicKey,
-    /// Secret key used to sign messages
-    pub secret_key: SecretKey,
     /// Leader proof proving key
     pub lead_proving_key: ProvingKey,
     /// Leader proof verifying key
@@ -173,9 +153,6 @@ impl ValidatorState {
         //wallet.exec_sql(consensus_tree_init_query).await?;
         //wallet.exec_sql(consensus_keys_init_query).await?;
 
-        let secret_key = SecretKey::random(&mut OsRng);
-        let public_key = PublicKey::from_secret(secret_key);
-
         info!("Generating leader proof keys with k: {}", LEADER_PROOF_K);
         let lead_proving_key = ProvingKey::build(LEADER_PROOF_K, &LeadContract::default());
         let lead_verifying_key = VerifyingKey::build(LEADER_PROOF_K, &LeadContract::default());
@@ -213,8 +190,6 @@ impl ValidatorState {
         // -----END ARTIFACT-----
 
         let state = Arc::new(RwLock::new(ValidatorState {
-            public_key,
-            secret_key,
             lead_proving_key,
             lead_verifying_key,
             consensus,
@@ -331,24 +306,6 @@ impl ValidatorState {
         Ok(())
     }
 
-    /// Find slot leader, using a simple hash method.
-    /// Leader calculation is based on how many nodes are participating
-    /// in the network.
-    /// Note: leaving this for future usage
-    /// TODO: if not used, participants BTreeMap can become a HashSet
-    pub fn slot_leader(&mut self) -> Participant {
-        let slot = self.current_slot();
-        // DefaultHasher is used to hash the slot number
-        // because it produces a number string which then can be modulated by the len.
-        // blake3 produces alphanumeric
-        let mut hasher = DefaultHasher::new();
-        slot.hash(&mut hasher);
-        let pos = hasher.finish() % (self.consensus.participants.len() as u64);
-        // Since BTreeMap orders by key in asceding order, each node will have
-        // the same key in calculated position.
-        self.consensus.participants.iter().nth(pos as usize).unwrap().1.clone()
-    }
-
     /// Check if new epoch has started, to create new epoch coins.
     /// Returns flag to signify if epoch has changed and vector of
     /// new epoch competing coins.
@@ -530,10 +487,7 @@ impl ValidatorState {
         }
         */
         let root = tree.root(0).unwrap();
-        let header =
-            Header::new(prev_hash, self.slot_epoch(slot), slot, Timestamp::current_time(), root);
 
-        let signed_proposal = self.secret_key.sign(&mut OsRng, &header.headerhash().as_bytes()[..]);
         let eta = self.consensus.epoch_eta.to_repr();
         // Generating leader proof
         let relative_slot = self.relative_slot(slot) as usize;
@@ -541,17 +495,21 @@ impl ValidatorState {
         // TODO: Generate new LeadCoin from newlly minted coin, will reuse original coin for now
         //let coin2 = something();
         let proof = coin.create_lead_proof(&self.lead_proving_key)?;
-        let participants = self.consensus.participants.values().cloned().collect();
+
+        // Signing using coin
+        let secret_key = coin.secret_key;
+        let header =
+            Header::new(prev_hash, self.slot_epoch(slot), slot, Timestamp::current_time(), root);
+        let signed_proposal = secret_key.sign(&mut OsRng, &header.headerhash().as_bytes()[..]);
+        let public_key = PublicKey::from_secret(secret_key);
+
         let metadata = Metadata::new(
             signed_proposal,
-            self.public_key,
-            coin.public_inputs(),
+            public_key,
             coin.public_inputs(),
             idx,
-            coin.sn,
             eta,
             LeadProof::from(proof),
-            participants,
         );
         // TODO: replace old coin with new coin
         self.consensus.coins[relative_slot][idx] = coin;
@@ -629,15 +587,17 @@ impl ValidatorState {
             None => return Ok(None),
         }
 
+        // TODO: proposal should contain encrypted block info
+        // we decrypt and check blockhash/headerhash is not tampered with
         let md = &proposal.block.metadata;
         let hdr = &proposal.block.header;
 
-        // Check if leader is a known consensus participant
-        let Some(leader) = self.consensus.participants.get(&md.public_key.to_bytes()) else {
-            warn!("receive_proposal(): Received proposal from unknown node: ({})", md.public_key);
-            return Err(Error::UnknownNodeError)
-        };
-        let mut leader = leader.clone();
+        // Verify proposal signature is valid based on producer public key
+        // TODO: derive public key from proof
+        if !md.public_key.verify(proposal.header.as_bytes(), &md.signature) {
+            warn!("receive_proposal(): Proposer {} signature could not be verified", md.public_key);
+            return Err(Error::InvalidSignature)
+        }
 
         // Check if proposal header matches actual one
         let proposal_header = hdr.headerhash();
@@ -649,27 +609,14 @@ impl ValidatorState {
             return Err(Error::ProposalHeadersMissmatchError)
         }
 
-        // Verify proposal winning coin public inputs match known ones
-        let public_inputs = &leader.coins[self.relative_slot(current) as usize][md.winning_index];
-        if public_inputs != &md.public_inputs {
-            warn!("receive_proposal(): Received proposal public inputs are invalid.");
-            return Err(Error::InvalidPublicInputsError)
-        }
-
-        // TODO: Verify winning coin serial number
-
         // Verify proposal leader proof
-        if let Err(e) = md.proof.verify(&self.lead_verifying_key, public_inputs) {
+        if let Err(e) = md.proof.verify(&self.lead_verifying_key, &md.public_inputs) {
             error!("receive_proposal(): Error during leader proof verification: {}", e);
             return Err(Error::LeaderProofVerification)
         };
         info!("receive_proposal(): Leader proof verified successfully!");
 
-        // Verify proposal signature is valid based on leader known valid key
-        if !leader.public_key.verify(proposal.header.as_bytes(), &md.signature) {
-            warn!("receive_proposal(): Proposer {} signature could not be verified", md.public_key);
-            return Err(Error::InvalidSignature)
-        }
+        // TODO: Verify proposal public inputs
 
         // Check if proposal extends any existing fork chains
         let index = self.find_extended_chain_index(proposal)?;
@@ -686,12 +633,6 @@ impl ValidatorState {
         };
 
         // TODO: [PLACEHOLDER] Add rewards validation
-        // TODO: Append serial to merkle tree
-
-        // Replacing participants public inputs with the newlly minted ones
-        leader.coins[self.relative_slot(current) as usize][md.winning_index] =
-            md.new_public_inputs.clone();
-        self.append_participant(&leader);
 
         // Check if proposal fork has can be finalized, to broadcast those blocks
         let mut to_broadcast = vec![];
@@ -855,18 +796,6 @@ impl ValidatorState {
         Ok(finalized)
     }
 
-    /// Append a new participant to the participants list.
-    pub fn append_participant(&mut self, participant: &Participant) -> bool {
-        if let Some(p) = self.consensus.participants.get(&participant.public_key.to_bytes()) {
-            if p == participant {
-                return false
-            }
-        }
-        // TODO: [PLACEHOLDER] don't blintly trust the public inputs/validate them
-        self.consensus.participants.insert(participant.public_key.to_bytes(), participant.clone());
-        true
-    }
-
     /// Utility function to extract leader selection lottery randomness(eta),
     /// defined as the hash of the previous lead proof converted to pallas base.
     fn get_eta(&self) -> pallas::Base {

+ 2 - 3
src/consensus/task/consensus_sync.rs

@@ -43,13 +43,13 @@ pub async fn consensus_sync_task(p2p: P2pPtr, state: ValidatorStatePtr) -> Resul
             let response_sub = channel.subscribe_msg::<ConsensusResponse>().await?;
 
             // Node creates a `ConsensusRequest` and sends it
-            let request = ConsensusRequest { public_key: state.read().await.public_key };
+            let request = ConsensusRequest {};
             channel.send(request).await?;
 
             // Node verifies response came from a participating node.
             // Extra validations can be added here.
             let response = response_sub.receive().await?;
-            if response.participants.is_empty() {
+            if response.proposals.is_empty() {
                 warn!("Retrieved consensus state from a new node, retrying...");
                 continue
             }
@@ -57,7 +57,6 @@ pub async fn consensus_sync_task(p2p: P2pPtr, state: ValidatorStatePtr) -> Resul
             // Node stores response data.
             let mut lock = state.write().await;
             lock.consensus.proposals = response.proposals.clone();
-            lock.consensus.participants = response.participants.clone();
 
             break
         }

+ 1 - 20
src/consensus/task/proposal.rs

@@ -21,11 +21,7 @@ use std::time::Duration;
 use log::{debug, error, info};
 
 use super::consensus_sync_task;
-use crate::{
-    consensus::{Participant, ValidatorStatePtr},
-    net::P2pPtr,
-    util::async_util::sleep,
-};
+use crate::{consensus::ValidatorStatePtr, net::P2pPtr, util::async_util::sleep};
 
 /// async task used for participating in the consensus protocol
 pub async fn proposal_task(consensus_p2p: P2pPtr, sync_p2p: P2pPtr, state: ValidatorStatePtr) {
@@ -73,7 +69,6 @@ pub async fn proposal_task(consensus_p2p: P2pPtr, sync_p2p: P2pPtr, state: Valid
             Ok(changed) => {
                 if changed {
                     info!("consensus: New epoch started: {}", state.read().await.current_epoch());
-                    let public_key = state.read().await.public_key;
                     let mut coins = vec![];
                     for slot_coins in &state.read().await.consensus.coins {
                         let mut slot_coins_inputs = vec![];
@@ -82,20 +77,6 @@ pub async fn proposal_task(consensus_p2p: P2pPtr, sync_p2p: P2pPtr, state: Valid
                         }
                         coins.push(slot_coins_inputs);
                     }
-                    let participant = Participant::new(public_key, coins);
-                    state.write().await.append_participant(&participant);
-
-                    match consensus_p2p.broadcast(participant).await {
-                        Ok(()) => {
-                            info!("consensus: Participation message broadcasted successfully.")
-                        }
-                        Err(e) => {
-                            error!("consensus: Failed broadcasting consensus participation: {}", e)
-                        }
-                    }
-                    // Node sleeps 2 seconds so all nodes can have the new epoch participants
-                    //TODO: optimize this
-                    sleep(2).await;
                 }
             }
             Err(e) => {