diff --git a/Cargo.lock b/Cargo.lock index 7ad1d1e2..b637399e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1341,7 +1341,6 @@ dependencies = [ "hex", "log", "logos-blockchain-common-http-client", - "logos-blockchain-core", "nssa", "nssa_core", "reqwest", diff --git a/common/Cargo.toml b/common/Cargo.toml index def7f2fa..14d00f09 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -17,6 +17,5 @@ log.workspace = true hex.workspace = true borsh.workspace = true base64.workspace = true -logos-blockchain-core.workspace = true url.workspace = true logos-blockchain-common-http-client.workspace = true diff --git a/common/src/block.rs b/common/src/block.rs index 1eab90d5..391bc57d 100644 --- a/common/src/block.rs +++ b/common/src/block.rs @@ -1,10 +1,10 @@ use borsh::{BorshDeserialize, BorshSerialize}; -use logos_blockchain_core::mantle::ops::channel::MsgId; use sha2::{Digest, Sha256, digest::FixedOutput}; use crate::transaction::EncodedTransaction; pub type HashType = [u8; 32]; +pub type MantleMsgId = [u8; 32]; #[derive(Debug, Clone)] /// Our own hasher. @@ -50,11 +50,7 @@ pub struct Block { pub header: BlockHeader, pub body: BlockBody, pub bedrock_status: BedrockStatus, - #[borsh( - serialize_with = "borsh_msg_id::serialize", - deserialize_with = "borsh_msg_id::deserialize" - )] - pub bedrock_parent_id: MsgId, + pub bedrock_parent_id: MantleMsgId, } #[derive(Debug, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)] @@ -69,7 +65,7 @@ impl HashableBlockData { pub fn into_pending_block( self, signing_key: &nssa::PrivateKey, - bedrock_parent_id: MsgId, + bedrock_parent_id: MantleMsgId, ) -> Block { let data_bytes = borsh::to_vec(&self).unwrap(); let signature = nssa::Signature::new(signing_key, &data_bytes); @@ -106,22 +102,6 @@ impl From for HashableBlockData { } } -mod borsh_msg_id { - use std::io::{Read, Write}; - - use logos_blockchain_core::mantle::ops::channel::MsgId; - - pub fn serialize(v: &MsgId, w: &mut W) -> std::io::Result<()> { - w.write_all(v.as_ref()) - } - - pub fn deserialize(r: &mut R) -> std::io::Result { - let mut buf = [0u8; 32]; - r.read_exact(&mut buf)?; - Ok(MsgId::from(buf)) - } -} - #[cfg(test)] mod tests { use crate::{block::HashableBlockData, test_utils}; diff --git a/common/src/test_utils.rs b/common/src/test_utils.rs index 8ae97599..80703342 100644 --- a/common/src/test_utils.rs +++ b/common/src/test_utils.rs @@ -1,5 +1,3 @@ -use logos_blockchain_core::mantle::ops::channel::MsgId; - use crate::{ block::{Block, HashableBlockData}, transaction::{EncodedTransaction, NSSATransaction}, @@ -32,7 +30,7 @@ pub fn produce_dummy_block( transactions, }; - block_data.into_pending_block(&sequencer_sign_key_for_testing(), MsgId::from([0; 32])) + block_data.into_pending_block(&sequencer_sign_key_for_testing(), [0; 32]) } pub fn produce_dummy_empty_transaction() -> EncodedTransaction { diff --git a/indexer_service/protocol/src/convert.rs b/indexer_service/protocol/src/convert.rs index 2c5d4b09..b6d9d348 100644 --- a/indexer_service/protocol/src/convert.rs +++ b/indexer_service/protocol/src/convert.rs @@ -606,7 +606,7 @@ impl TryFrom for Block { header: header.into(), body: body.try_into()?, bedrock_status: bedrock_status.into(), - bedrock_parent_id: bedrock_parent_id.into(), + bedrock_parent_id: MsgId(bedrock_parent_id), }) } } @@ -626,7 +626,7 @@ impl TryFrom for common::block::Block { header: header.try_into()?, body: body.try_into()?, bedrock_status: bedrock_status.into(), - bedrock_parent_id: bedrock_parent_id.into(), + bedrock_parent_id: bedrock_parent_id.0, }) } } diff --git a/sequencer_core/src/block_settlement_client.rs b/sequencer_core/src/block_settlement_client.rs index 53839159..f99a116e 100644 --- a/sequencer_core/src/block_settlement_client.rs +++ b/sequencer_core/src/block_settlement_client.rs @@ -47,7 +47,7 @@ impl BlockSettlementClient { let inscribe_op = InscriptionOp { channel_id: self.bedrock_channel_id, inscription: inscription_data, - parent: block.bedrock_parent_id, + parent: block.bedrock_parent_id.into(), signer: verifying_key, }; let inscribe_op_id = inscribe_op.id(); diff --git a/sequencer_core/src/block_store.rs b/sequencer_core/src/block_store.rs index 3aed2143..a0b07445 100644 --- a/sequencer_core/src/block_store.rs +++ b/sequencer_core/src/block_store.rs @@ -108,7 +108,6 @@ pub(crate) fn block_to_transactions_map(block: &Block) -> HashMap #[cfg(test)] mod tests { use common::{block::HashableBlockData, test_utils::sequencer_sign_key_for_testing}; - use logos_blockchain_core::mantle::ops::channel::MsgId; use tempfile::tempdir; use super::*; @@ -127,8 +126,7 @@ mod tests { transactions: vec![], }; - let genesis_block = - genesis_block_hashable_data.into_pending_block(&signing_key, MsgId::from([0; 32])); + let genesis_block = genesis_block_hashable_data.into_pending_block(&signing_key, [0; 32]); // Start an empty node store let mut node_store = SequencerStore::open_db_with_genesis(path, Some(genesis_block), signing_key).unwrap(); diff --git a/sequencer_core/src/lib.rs b/sequencer_core/src/lib.rs index 119d5d73..efddcd7e 100644 --- a/sequencer_core/src/lib.rs +++ b/sequencer_core/src/lib.rs @@ -5,12 +5,11 @@ use anyhow::Result; use common::PINATA_BASE58; use common::{ HashType, - block::{BedrockStatus, Block, HashableBlockData}, + block::{BedrockStatus, Block, HashableBlockData, MantleMsgId}, transaction::{EncodedTransaction, NSSATransaction}, }; use config::SequencerConfig; use log::{info, warn}; -use logos_blockchain_core::mantle::ops::channel::MsgId; use mempool::{MemPool, MemPoolHandle}; use serde::{Deserialize, Serialize}; @@ -27,7 +26,7 @@ pub struct SequencerCore { sequencer_config: SequencerConfig, chain_height: u64, block_settlement_client: Option, - last_bedrock_msg_id: MsgId, + last_bedrock_msg_id: MantleMsgId, } #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] @@ -59,7 +58,7 @@ impl SequencerCore { }; let signing_key = nssa::PrivateKey::try_new(config.signing_key).unwrap(); - let channel_genesis_msg_id = MsgId::from([0; 32]); + let channel_genesis_msg_id = [0; 32]; let genesis_block = hashable_data.into_pending_block(&signing_key, channel_genesis_msg_id); // Sequencer should panic if unable to open db, @@ -91,7 +90,7 @@ impl SequencerCore { acc.program_owner = nssa::program::Program::authenticated_transfer_program().id(); - nssa_core::Commitment::new(&npk, &acc) + nssa_core::Commitment::new(npk, &acc) }) .collect(); @@ -152,7 +151,7 @@ impl SequencerCore { let block = block_data.into_pending_block(self.store.signing_key(), self.last_bedrock_msg_id); let msg_id = client.submit_block_to_bedrock(&block).await?; - self.last_bedrock_msg_id = msg_id; + self.last_bedrock_msg_id = msg_id.into(); log::info!("Posted block data to Bedrock"); }