Skip to content

Commit

Permalink
refactor(consensus): switch ValidatorId to a plain Felt
Browse files Browse the repository at this point in the history
  • Loading branch information
matan-starkware committed Jun 25, 2024
1 parent 9c88127 commit 394f4c5
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions crates/papyrus_protobuf/src/consensus.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use starknet_api::block::BlockHash;
use starknet_api::core::ContractAddress;
use starknet_api::transaction::Transaction;
use starknet_types_core::felt::Felt;

#[derive(Debug, Clone, Eq, PartialEq)]
pub struct Proposal {
pub height: u64,
pub proposer: ContractAddress,
pub proposer: Felt,
pub transactions: Vec<Transaction>,
pub block_hash: BlockHash,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import "p2p/proto/common.proto";

message Proposal {
uint64 height = 1;
Address proposer = 2;
Felt252 proposer = 2;
repeated Transaction transactions = 3;
Hash block_hash = 4;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ use papyrus_storage::body::BodyStorageWriter;
use papyrus_storage::header::HeaderStorageWriter;
use papyrus_storage::test_utils::get_test_storage;
use starknet_api::block::Block;
use starknet_api::core::ContractAddress;
use starknet_api::transaction::Transaction;
use test_utils::get_test_block;

use crate::papyrus_consensus_context::PapyrusConsensusContext;
use crate::types::{ConsensusBlock, ConsensusContext, ProposalInit};
use crate::types::{ConsensusBlock, ConsensusContext, ProposalInit, ValidatorId};

// TODO(dvir): consider adding tests for times, i.e, the calls are returned immediately and nothing
// happen until it should (for example, not creating a block before we have it in storage).
Expand Down Expand Up @@ -84,7 +83,7 @@ async fn propose() {
let (fin_sender, fin_receiver) = oneshot::channel();
fin_sender.send(block.header.block_hash).unwrap();

let proposal_init = ProposalInit { height: block_number, proposer: ContractAddress::default() };
let proposal_init = ProposalInit { height: block_number, proposer: ValidatorId::default() };
papyrus_context.propose(proposal_init.clone(), content_receiver, fin_receiver).await.unwrap();

let expected_message = ConsensusMessage::Proposal(Proposal {
Expand Down
4 changes: 2 additions & 2 deletions crates/sequencing/papyrus_consensus/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ mod types_test;
use async_trait::async_trait;
use futures::channel::{mpsc, oneshot};
use starknet_api::block::{BlockHash, BlockNumber};
use starknet_api::core::ContractAddress;
use starknet_types_core::felt::Felt;

/// Used to identify the node by consensus.
/// 1. This ID is derived from the id registered with Starknet's L2 staking contract.
/// 2. We must be able to derive the public key associated with this ID for the sake of validating
/// signatures.
// TODO(matan): Determine the actual type of NodeId.
pub type ValidatorId = ContractAddress;
pub type ValidatorId = Felt;

/// Interface that any concrete block type must implement to be used by consensus.
///
Expand Down

0 comments on commit 394f4c5

Please sign in to comment.