Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

feat: batcher alt-DA CLI flags and service wiring#3615

Closed
patnir wants to merge 8 commits into
rahulpatni/priv-1972-3-batcher-shadowfrom
rahulpatni/priv-1972-4-batcher-cli
Closed

feat: batcher alt-DA CLI flags and service wiring#3615
patnir wants to merge 8 commits into
rahulpatni/priv-1972-3-batcher-shadowfrom
rahulpatni/priv-1972-4-batcher-cli

Conversation

@patnir

@patnir patnir commented Jun 18, 2026

Copy link
Copy Markdown

wire batcher CLI flags for alt-DA dual-write on privacy devnet:

Summary

  • Add BATCHER_ALTDA_ENABLED and BATCHER_ALTDA_DA_SERVER CLI flags
  • Inject base-alt-da client via binary adapter (keeps crate layering)

Context

Depends on #3614. Enables dual-write on the privacy L3 devnet once merged; privacy-enclave compose follow-up sets flags on base-batcher after this stack lands.

Test plan

  • cargo test -p base-batcher-bin
  • cargo check -p base-batcher-bin

type=routine
risk=low
impact=sev5

@linear

linear Bot commented Jun 18, 2026

Copy link
Copy Markdown

PRIV-1972

Comment thread bin/batcher/src/cli.rs
Comment on lines +334 to +344
alt_da: if self.altda_enabled {
let server_url = self
.altda_da_server
.ok_or_else(|| eyre::eyre!("--altda-enabled requires --altda-da-server"))?;
let client = base_alt_da::Client::new(server_url)
.map_err(|e| eyre::eyre!("failed to create alt-da client: {e}"))?;
Some(std::sync::Arc::new(AltDaClientAdapter(client))
as base_batcher_core::DynAltDaClient)
} else {
None
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: --altda-da-server without --altda-enabled is silently discarded. An operator could set the server URL, forget the enable flag, and wonder why alt-DA isn't working. Consider warning in validate() (or here) when altda_da_server.is_some() && !altda_enabled:

if !self.altda_enabled && self.altda_da_server.is_some() {
    tracing::warn!("--altda-da-server is set but --altda-enabled is false; alt-DA is disabled");
}

Comment thread bin/batcher/Cargo.toml
Comment on lines 19 to 26
url.workspace = true
eyre.workspace = true
base-alt-da.workspace = true
base-protocol.workspace = true
base-cli-utils.workspace = true
async-trait.workspace = true
base-batcher-core.workspace = true
alloy-signer-local.workspace = true

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per project convention (CLAUDE.md): dependencies should be sorted by line length (waterfall style). async-trait (shorter) is listed after base-cli-utils (longer). Suggested order:

Suggested change
url.workspace = true
eyre.workspace = true
base-alt-da.workspace = true
base-protocol.workspace = true
base-cli-utils.workspace = true
async-trait.workspace = true
base-batcher-core.workspace = true
alloy-signer-local.workspace = true
url.workspace = true
eyre.workspace = true
async-trait.workspace = true
base-alt-da.workspace = true
base-protocol.workspace = true
base-cli-utils.workspace = true
base-batcher-core.workspace = true
alloy-signer-local.workspace = true

@patnir patnir force-pushed the rahulpatni/priv-1972-3-batcher-shadow branch from 6306d4b to fb85817 Compare June 18, 2026 06:37
@patnir patnir force-pushed the rahulpatni/priv-1972-4-batcher-cli branch from c8801b6 to bb1063d Compare June 18, 2026 06:37
@patnir patnir force-pushed the rahulpatni/priv-1972-3-batcher-shadow branch from fb85817 to 4c02168 Compare June 18, 2026 06:42
@patnir patnir force-pushed the rahulpatni/priv-1972-4-batcher-cli branch from bb1063d to 005bfaa Compare June 18, 2026 06:42
Comment on lines +163 to +168
if self.alt_da.is_some() && self.encoder_config.da_type != DaType::Calldata {
eyre::bail!(
"alt-da dual-write requires --data-availability-type calldata; \
blob submissions are not dual-written to the DA server"
);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When alt_da is enabled and force_blobs_when_throttling is true (the default), a DA-backlog throttle event will silently switch the encoder to blob mode and stop dual-writing to alt-DA — the submission queue only clones alt_da_body for DaType::Calldata. An operator relying on the dual-write shadow path for validation may not realize it has gaps during throttle windows.

Consider warning here (or rejecting the combination) so operators are aware:

if self.alt_da.is_some() && self.force_blobs_when_throttling {
    tracing::warn!(
        "alt-da dual-write will pause during DA-backlog throttle events \
         (throttling forces blob mode, which skips alt-DA); \
         pass --no-force-blobs-when-throttling to keep dual-write continuous"
    );
}

patnir added 4 commits June 18, 2026 13:05
- Client::put uploads batch bytes and returns a validated 34-byte generic commitment for L1 posting
- read a bounded snippet of the server error body on non-2xx responses so operators see diagnostics
- encode_commitment_tx_data prefixes DERIVATION_VERSION_1 for the commitment L1 tx
- CommitmentError decouples commitment validation from the server Error enum
- drop redundant reqwest dev-dependency
Move test imports to mod scope and drop redundant DERIVATION_VERSION_1 import.
Fire-and-forget PUT plus commitment txs alongside calldata, with shadow concurrency cap and reorg abort.
Log submission ids in shadow tasks, warn on missing commitment block number, and avoid redundant alt_da clone in SubmissionQueue::new.
@patnir patnir force-pushed the rahulpatni/priv-1972-3-batcher-shadow branch from 4c02168 to 3ca9749 Compare June 18, 2026 20:08
@patnir patnir force-pushed the rahulpatni/priv-1972-4-batcher-cli branch from 005bfaa to c0c56ed Compare June 18, 2026 20:09
patnir added 3 commits June 18, 2026 13:11
Fix lib.rs re-export ordering and shadow-path indentation.
Add BATCHER_ALTDA_ENABLED and BATCHER_ALTDA_DA_SERVER; inject base-alt-da client via binary adapter.
Warn when alt-DA server URL is set without enable flag or when dual-write conflicts with throttle-driven blob override; sort batcher bin deps by line length.
@patnir patnir force-pushed the rahulpatni/priv-1972-4-batcher-cli branch from c0c56ed to 9bfee0f Compare June 18, 2026 20:11
Wrap long warn! string to satisfy workspace rustfmt.
@github-actions

Copy link
Copy Markdown
Contributor

Review Summary

Clean PR that adds alt-DA CLI flags and wires the base-alt-da client into the batcher via a well-structured adapter pattern. The binary-level adapter (AltDaClientAdapter) correctly keeps the crate layering intact — base-batcher-core defines the trait, the binary bridges to the concrete base-alt-da client, and the service crate stays unaware of the infra dependency.

Architecture

The adapter pattern here is the right call. The AltDaClient trait in base-batcher-core takes alloy_primitives::Bytes while base_alt_da::Client::put takes &[u8]; the adapter bridges this cleanly with body.as_ref(). The GenericCommitment types are structurally identical [u8; 34] arrays in both crates, so the implicit coercion through the Result mapping is sound.

Validation

The validation has good layered coverage:

  • CLI-level: warns on --altda-da-server without --altda-enabled, warns on throttle+alt-DA interaction
  • Config-level: validate() rejects alt_da.is_some() when DA type is not calldata
  • Client construction: errors if --altda-enabled is set without --altda-da-server

Test coverage is adequate — the three new tests cover the missing-server-URL, happy-path, and blob-DA-rejection cases.

Existing inline comments

The three inline comments from the previous review run are still relevant and cover the notable findings. No additional issues found.

@github-actions

Copy link
Copy Markdown
Contributor

❌ base-std fork tests did not run

The build or setup step failed before any tests could execute. Check the workflow logs for details.

@patnir patnir force-pushed the rahulpatni/priv-1972-3-batcher-shadow branch from 20e24f1 to 2e8679c Compare June 18, 2026 20:56
patnir added a commit that referenced this pull request Jun 18, 2026
- Stub alt_da: None in batcher service until #3615 wires the client
- Collapse nested if in shadow path for clippy
- Point UPGRADES.md hardfork test link at l3 branch
@patnir

patnir commented Jun 19, 2026

Copy link
Copy Markdown
Author

Combined into #3614 for PRIV-1972.

@patnir patnir closed this Jun 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant