mirror of
https://github.com/logos-blockchain/logos-execution-zone.git
synced 2026-05-21 07:29:26 +00:00
Merge branch 'schouhy/adapt-sequencer-to-bedrock' into Pravdyvy/block-parsing-validation
This commit is contained in:
commit
bec78ae70f
@ -18,6 +18,7 @@ pub struct BlockSettlementClient {
|
|||||||
bedrock_client: BedrockClient,
|
bedrock_client: BedrockClient,
|
||||||
bedrock_signing_key: Ed25519Key,
|
bedrock_signing_key: Ed25519Key,
|
||||||
bedrock_channel_id: ChannelId,
|
bedrock_channel_id: ChannelId,
|
||||||
|
last_message_id: MsgId,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BlockSettlementClient {
|
impl BlockSettlementClient {
|
||||||
@ -34,11 +35,12 @@ impl BlockSettlementClient {
|
|||||||
bedrock_client,
|
bedrock_client,
|
||||||
bedrock_signing_key,
|
bedrock_signing_key,
|
||||||
bedrock_channel_id,
|
bedrock_channel_id,
|
||||||
|
last_message_id: MsgId::from([0; 32]),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create and sign a transaction for inscribing data
|
/// Create and sign a transaction for inscribing data
|
||||||
pub fn create_inscribe_tx(&self, data: Vec<u8>, parent: MsgId) -> SignedMantleTx {
|
pub fn create_inscribe_tx(&self, data: Vec<u8>) -> SignedMantleTx {
|
||||||
let verifying_key_bytes = self.bedrock_signing_key.public_key().to_bytes();
|
let verifying_key_bytes = self.bedrock_signing_key.public_key().to_bytes();
|
||||||
let verifying_key =
|
let verifying_key =
|
||||||
Ed25519PublicKey::from_bytes(&verifying_key_bytes).expect("valid ed25519 public key");
|
Ed25519PublicKey::from_bytes(&verifying_key_bytes).expect("valid ed25519 public key");
|
||||||
@ -46,7 +48,7 @@ impl BlockSettlementClient {
|
|||||||
let inscribe_op = InscriptionOp {
|
let inscribe_op = InscriptionOp {
|
||||||
channel_id: self.bedrock_channel_id,
|
channel_id: self.bedrock_channel_id,
|
||||||
inscription: data,
|
inscription: data,
|
||||||
parent,
|
parent: self.last_message_id,
|
||||||
signer: verifying_key,
|
signer: verifying_key,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -75,16 +77,9 @@ impl BlockSettlementClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Post a transaction to the node and wait for inclusion
|
/// Post a transaction to the node and wait for inclusion
|
||||||
pub async fn post_and_wait(&self, block_data: &HashableBlockData) -> Result<u64> {
|
pub async fn post_and_wait(&mut self, block_data: &HashableBlockData) -> Result<u64> {
|
||||||
let msg_id: MsgId = {
|
|
||||||
let mut this = [0; 32];
|
|
||||||
// Bandaid solution
|
|
||||||
this[0..8].copy_from_slice(&(block_data.block_id - 2).to_le_bytes());
|
|
||||||
this.into()
|
|
||||||
};
|
|
||||||
|
|
||||||
let inscription_data = borsh::to_vec(&block_data)?;
|
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
|
// Post the transaction
|
||||||
self.bedrock_client
|
self.bedrock_client
|
||||||
@ -92,6 +87,11 @@ impl BlockSettlementClient {
|
|||||||
.post_transaction(self.bedrock_node_url.clone(), tx.clone())
|
.post_transaction(self.bedrock_node_url.clone(), tx.clone())
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
match tx.mantle_tx.ops.first() {
|
||||||
|
Some(Op::ChannelInscribe(inscribe)) => self.last_message_id = inscribe.id(),
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
|
||||||
Ok(block_data.block_id)
|
Ok(block_data.block_id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -157,7 +157,7 @@ impl SequencerCore {
|
|||||||
pub async fn produce_new_block_and_post_to_settlement_layer(&mut self) -> Result<u64> {
|
pub async fn produce_new_block_and_post_to_settlement_layer(&mut self) -> Result<u64> {
|
||||||
let block_data = self.produce_new_block_with_mempool_transactions()?;
|
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?;
|
block_settlement.post_and_wait(&block_data).await?;
|
||||||
log::info!("Posted block data to Bedrock");
|
log::info!("Posted block data to Bedrock");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -157,6 +157,6 @@
|
|||||||
],
|
],
|
||||||
"bedrock_config": {
|
"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],
|
"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"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user