diff --git a/bin/node/src/commands/store.rs b/bin/node/src/commands/store.rs index 7fb62278d..d3ea6038f 100644 --- a/bin/node/src/commands/store.rs +++ b/bin/node/src/commands/store.rs @@ -7,7 +7,7 @@ use miden_node_store::{DEFAULT_MAX_CONCURRENT_PROOFS, Store}; use miden_node_utils::clap::{GrpcOptionsInternal, StorageOptions}; use miden_node_utils::fs::ensure_empty_directory; use miden_node_utils::grpc::UrlExt; -use miden_protocol::block::ProvenBlock; +use miden_protocol::block::SignedBlock; use miden_protocol::utils::serde::Deserializable; use url::Url; @@ -175,10 +175,10 @@ impl StoreCommand { pub fn bootstrap_store(data_directory: &Path, genesis_block_path: &Path) -> anyhow::Result<()> { // Read and deserialize the genesis block file. let bytes = fs_err::read(genesis_block_path).context("failed to read genesis block")?; - let proven_block = ProvenBlock::read_from_bytes(&bytes) + let signed_block = SignedBlock::read_from_bytes(&bytes) .context("failed to deserialize genesis block from file")?; let genesis_block = - GenesisBlock::try_from(proven_block).context("genesis block validation failed")?; + GenesisBlock::try_from(signed_block).context("genesis block validation failed")?; Store::bootstrap(genesis_block, data_directory) } diff --git a/bin/stress-test/src/seeding/mod.rs b/bin/stress-test/src/seeding/mod.rs index 0b860838c..79b461848 100644 --- a/bin/stress-test/src/seeding/mod.rs +++ b/bin/stress-test/src/seeding/mod.rs @@ -28,7 +28,6 @@ use miden_protocol::block::{ BlockNumber, FeeParameters, ProposedBlock, - ProvenBlock, SignedBlock, }; use miden_protocol::crypto::dsa::ecdsa_k256_keccak::SecretKey as EcdsaSecretKey; @@ -111,12 +110,12 @@ pub async fn seed_store( let accounts_filepath = data_directory.join(ACCOUNTS_FILENAME); let data_directory = miden_node_store::DataDirectory::load(data_directory).expect("data directory should exist"); - let genesis_header = genesis_state.into_block().await.unwrap().into_inner(); + let genesis_block = genesis_state.into_block().await.unwrap().into_inner(); let metrics = generate_blocks( num_accounts, public_accounts_percentage, faucet, - genesis_header, + genesis_block, &store_client, data_directory, accounts_filepath, @@ -137,7 +136,7 @@ async fn generate_blocks( num_accounts: usize, public_accounts_percentage: u8, mut faucet: Account, - genesis_block: ProvenBlock, + genesis_block: SignedBlock, store_client: &StoreClient, data_directory: DataDirectory, accounts_filepath: PathBuf, diff --git a/crates/store/src/db/mod.rs b/crates/store/src/db/mod.rs index 51e487cab..11bec1c1f 100644 --- a/crates/store/src/db/mod.rs +++ b/crates/store/src/db/mod.rs @@ -260,9 +260,8 @@ impl Db { // Run migrations. apply_migrations(&mut conn).context("failed to apply database migrations")?; - // Insert genesis block data. Deconstruct into signed block. - let (header, body, signature, _proof) = genesis.into_inner().into_parts(); - let genesis_block = SignedBlock::new_unchecked(header, body, signature); + // Insert genesis block data. + let genesis_block = genesis.into_inner(); conn.transaction(move |conn| models::queries::apply_block(conn, &genesis_block, &[], None)) .context("failed to insert genesis block")?; Ok(()) diff --git a/crates/store/src/genesis/mod.rs b/crates/store/src/genesis/mod.rs index 6c4624fb0..b875aa5f3 100644 --- a/crates/store/src/genesis/mod.rs +++ b/crates/store/src/genesis/mod.rs @@ -9,9 +9,8 @@ use miden_protocol::block::{ BlockHeader, BlockNoteTree, BlockNumber, - BlockProof, FeeParameters, - ProvenBlock, + SignedBlock, }; use miden_protocol::crypto::merkle::mmr::{Forest, MmrPeaks}; use miden_protocol::crypto::merkle::smt::{LargeSmt, MemoryStorage, Smt}; @@ -35,23 +34,23 @@ pub struct GenesisState { } /// A type-safety wrapper ensuring that genesis block data can only be created from -/// [`GenesisState`] or validated from a [`ProvenBlock`] via [`GenesisBlock::try_from`]. -pub struct GenesisBlock(ProvenBlock); +/// [`GenesisState`] or validated from a [`SignedBlock`] via [`GenesisBlock::try_from`]. +pub struct GenesisBlock(SignedBlock); impl GenesisBlock { - pub fn inner(&self) -> &ProvenBlock { + pub fn inner(&self) -> &SignedBlock { &self.0 } - pub fn into_inner(self) -> ProvenBlock { + pub fn into_inner(self) -> SignedBlock { self.0 } } -impl TryFrom for GenesisBlock { +impl TryFrom for GenesisBlock { type Error = anyhow::Error; - fn try_from(block: ProvenBlock) -> anyhow::Result { + fn try_from(block: SignedBlock) -> anyhow::Result { anyhow::ensure!( block.header().block_num() == BlockNumber::GENESIS, "expected genesis block number (0), got {}", @@ -152,15 +151,11 @@ impl GenesisState { empty_transactions, ); - let block_proof = BlockProof::new_dummy(); - // Sign and assert verification for sanity (no mismatch between frontend and backend signing // impls). let signature = self.block_signer.sign(&header).await?; assert!(signature.verify(header.commitment(), &self.block_signer.public_key())); - // SAFETY: Header and accounts should be valid by construction. - // No notes or nullifiers are created at genesis, which is consistent with the above empty - // block note tree root and empty nullifier tree root. - Ok(GenesisBlock(ProvenBlock::new_unchecked(header, body, signature, block_proof))) + let signed_block = SignedBlock::new(header, body, signature)?; + Ok(GenesisBlock(signed_block)) } }