Skip to content

Commit 8e396c3

Browse files
committed
feat: add EnvelopeTagEncoder for main binary
1 parent 13f21cd commit 8e396c3

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bin/strata-client/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ strata-eectl.workspace = true
2222
strata-evmexec.workspace = true
2323
strata-ol-chain-types.workspace = true
2424
strata-ol-chainstate-types.workspace = true
25+
strata-asm-proto-checkpoint-txs.workspace = true
2526
strata-primitives.workspace = true
27+
strata-l1-txfmt.workspace = true
2628
strata-rpc-api = { workspace = true, default-features = true }
2729
strata-rpc-types.workspace = true
2830
strata-rpc-utils.workspace = true

bin/strata-client/src/main.rs

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ use bitcoind_async_client::{traits::Reader, Client};
1919
use errors::InitError;
2020
use jsonrpsee::Methods;
2121
use rpc_client::sync_client;
22+
use strata_asm_proto_checkpoint_txs::{CHECKPOINT_V0_SUBPROTOCOL_ID, OL_STF_CHECKPOINT_TX_TYPE};
2223
use strata_btcio::{
2324
broadcaster::{spawn_broadcaster_task, L1BroadcastHandle},
2425
reader::query::bitcoin_data_reader_task,
25-
writer::start_envelope_task,
26+
writer::{start_envelope_task, EnvelopeTagEncoder},
2627
};
2728
use strata_common::{
2829
logging,
@@ -39,7 +40,11 @@ use strata_db::{
3940
};
4041
use strata_eectl::engine::{ExecEngineCtl, L2BlockRef};
4142
use strata_evmexec::{engine::RpcExecEngineCtl, EngineRpcClient};
42-
use strata_primitives::params::{Params, ProofPublishMode};
43+
use strata_l1_txfmt::MagicBytes;
44+
use strata_primitives::{
45+
l1::payload::L1PayloadType,
46+
params::{Params, ProofPublishMode},
47+
};
4348
use strata_rpc_api::{
4449
StrataAdminApiServer, StrataApiServer, StrataDebugApiServer, StrataSequencerApiServer,
4550
};
@@ -401,6 +406,26 @@ fn start_sequencer_tasks(
401406
))?;
402407

403408
let btcio_config = Arc::new(config.btcio.clone());
409+
let magic_bytes: MagicBytes = params.rollup().magic_bytes;
410+
// NOTE: Only checkpoint envelopes are supported today. When new SPS-50 tagged transactions
411+
// are introduced, extend this encoder so btcio stays agnostic of protocol-specific details.
412+
413+
let tag_encoder: Arc<EnvelopeTagEncoder> =
414+
Arc::new(move |payload| -> anyhow::Result<Vec<u8>> {
415+
match payload.payload_type() {
416+
L1PayloadType::Checkpoint => {
417+
let mut tag = Vec::with_capacity(6);
418+
tag.extend_from_slice(&magic_bytes);
419+
tag.push(CHECKPOINT_V0_SUBPROTOCOL_ID);
420+
tag.push(OL_STF_CHECKPOINT_TX_TYPE);
421+
Ok(tag)
422+
}
423+
other => Err(anyhow!(
424+
"unsupported SPS-50 tag for payload type {:?}",
425+
other
426+
)),
427+
}
428+
});
404429

405430
// Start envelope tasks
406431
let envelope_handle = start_envelope_task(
@@ -413,6 +438,7 @@ fn start_sequencer_tasks(
413438
status_channel.clone(),
414439
pool.clone(),
415440
broadcast_handle.clone(),
441+
tag_encoder,
416442
)?;
417443

418444
let template_manager_handle = start_template_manager_task(&ctx, executor);

0 commit comments

Comments
 (0)