From 4105eecacec617dbc04cc3af3efd16c0b0f0629d Mon Sep 17 00:00:00 2001 From: Sergio Chouhy Date: Fri, 16 Jan 2026 19:50:54 -0300 Subject: [PATCH] fix msg id in mantle tx --- sequencer_core/src/block_settlement_client.rs | 21 ++++++++++--------- sequencer_core/src/lib.rs | 2 +- .../configs/debug/sequencer_config.json | 2 +- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/sequencer_core/src/block_settlement_client.rs b/sequencer_core/src/block_settlement_client.rs index 1964f37f..68a95dd3 100644 --- a/sequencer_core/src/block_settlement_client.rs +++ b/sequencer_core/src/block_settlement_client.rs @@ -18,6 +18,7 @@ pub struct BlockSettlementClient { bedrock_client: BedrockClient, bedrock_signing_key: Ed25519Key, bedrock_channel_id: ChannelId, + last_message_id: MsgId, } impl BlockSettlementClient { @@ -34,11 +35,12 @@ impl BlockSettlementClient { bedrock_client, bedrock_signing_key, bedrock_channel_id, + last_message_id: MsgId::from([0; 32]), } } /// Create and sign a transaction for inscribing data - pub fn create_inscribe_tx(&self, data: Vec, parent: MsgId) -> SignedMantleTx { + pub fn create_inscribe_tx(&self, data: Vec) -> SignedMantleTx { let verifying_key_bytes = self.bedrock_signing_key.public_key().to_bytes(); let verifying_key = Ed25519PublicKey::from_bytes(&verifying_key_bytes).expect("valid ed25519 public key"); @@ -46,7 +48,7 @@ impl BlockSettlementClient { let inscribe_op = InscriptionOp { channel_id: self.bedrock_channel_id, inscription: data, - parent, + parent: self.last_message_id, signer: verifying_key, }; @@ -75,15 +77,9 @@ impl BlockSettlementClient { } /// Post a transaction to the node and wait for inclusion - pub async fn post_and_wait(&self, block_data: &HashableBlockData) -> Result { - let msg_id: MsgId = { - let mut this = [0; 32]; - this[0..8].copy_from_slice(&block_data.block_id.to_le_bytes()); - this.into() - }; - + pub async fn post_and_wait(&mut self, block_data: &HashableBlockData) -> Result { let inscription_data = borsh::to_vec(&block_data)?; - let tx = self.create_inscribe_tx(inscription_data, msg_id); + let tx = self.create_inscribe_tx(inscription_data); // Post the transaction self.bedrock_client @@ -91,6 +87,11 @@ impl BlockSettlementClient { .post_transaction(self.bedrock_node_url.clone(), tx.clone()) .await?; + match tx.mantle_tx.ops.first() { + Some(Op::ChannelInscribe(inscribe)) => self.last_message_id = inscribe.id(), + _ => {} + } + Ok(block_data.block_id) } } diff --git a/sequencer_core/src/lib.rs b/sequencer_core/src/lib.rs index 52b389f0..561f5ef6 100644 --- a/sequencer_core/src/lib.rs +++ b/sequencer_core/src/lib.rs @@ -148,7 +148,7 @@ impl SequencerCore { pub async fn produce_new_block_and_post_to_settlement_layer(&mut self) -> Result { let block_data = self.produce_new_block_with_mempool_transactions()?; - if let Some(block_settlement) = &self.block_settlement_client { + if let Some(block_settlement) = self.block_settlement_client.as_mut() { block_settlement.post_and_wait(&block_data).await?; log::info!("Posted block data to Bedrock"); } diff --git a/sequencer_runner/configs/debug/sequencer_config.json b/sequencer_runner/configs/debug/sequencer_config.json index ab65ea70..ad43ba65 100644 --- a/sequencer_runner/configs/debug/sequencer_config.json +++ b/sequencer_runner/configs/debug/sequencer_config.json @@ -157,6 +157,6 @@ ], "bedrock_config": { "channel_id": [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1], - "node_url": "http://localhost:45403" + "node_url": "http://localhost:8080" } }