Midnight Bridge Implementation - #106
Draft
ladislavdubravsky wants to merge 21 commits into
Draft
Conversation
Skip building the C++ attestation client if the Azure Guest Attestation header is absent; emit a cargo warning. Document in README that local dev with mock attestation does not require the SDK.
optional_index_db_url() now returns None for sqlite:/sqlite3: URLs (since this provider uses PgPool). Log when SQLite is detected and document that commitment-tree sync then uses rollup REST endpoints.
…ement) Implement executor HTTP client and call it from the TEE manager: - After computing batch_hash: POST /commit-batch (commitBatch on L1). - After attestation and publishing to DA: POST /build-signatures then POST /finalize-batch (finalizeBatch on L1). Config: tee_configuration.executor_url and rollup_id_hex (optional; when unset, no L1 calls). Executor holds sequencer/finalizer keys; rollup only calls the HTTP API.
New contract storage model at `midnight-l2-contracts`, indexer at ledger-v7.
…tion The rollup now owns the full L1 Bridge contract lifecycle: it auto- deploys the contract on genesis (using print-genesis-info to compute the deterministic state root and batch hash), spawns the executor service as a child process, persists the contract address, and tears everything down on shutdown. This replaces the previous manual workflow.
After a crash or shutdown between commitBatch and finalizeBatch, the L1 Bridge contract rejects new commits with COMMIT_OUT_OF_ORDER. Persist BatchPublicDataV1Full to pending_finalize.json after each successful commit and complete finalization automatically on startup or during graceful shutdown, making the rollup resilient to mid-cycle interruptions.
…s cleaned properly
WIP Midnight bridge: withdrawals
…settlement resilience - Bridge worker automatically relays L2→L1 withdrawal proofs to the executor's POST /relay-withdraw-night-with-proof after each batch finalization, with persistent cursor tracking and root-mismatch guard. - Wire STF's MidnightWithdrawals.withdraw_root into BatchPublicDataV1 via the prover querying the rollup REST API, breaking the circular dependency where the L1 contract only had the empty tree root. - Add TEE batch settlement resilience: L1 state resync before each commit (handles committed-but-not-finalized, cursor drift, prev_batch_hash mismatch), exponential backoff on failures, and diagnostic logging. - Add sov-cli binary to rollup-ligero (required due to ed25519-dalek version mismatch between Risc0 and Ligero adapters). - Fix sender_bytes zero-padding for 28-byte addresses in MidnightWithdrawals. - Add withdrawRoot to executor /state endpoint (bridge-cli TS). - Update MIDNIGHT_BRIDGE.md with deposit and withdrawal CLI walkthroughs.
… add executor timeout - When the L1 state resync detects the contract is ahead of our cursor (e.g. after a transient executor error where the L1 tx actually succeeded), return early from process_stf_info instead of using the current proof. The proof was generated for the now-skipped batch range and its initial_state_root won't chain from L1's new lastFinalizedStateRoot, causing BAD_PREV_STATE_ROOT. - Add 180s timeout to the executor HTTP client so the rollup fails fast and can recover via resync when the Midnight SDK hangs on response parsing. - Log a "Sending request to executor service" line before each executor call so it's clear when the rollup is blocked on the executor vs idle. - Log batch state roots from the prover for diagnostics. - Promote withdrawal relay state and root-mismatch guard logs back to info so the relay loop's progress is visible without enabling debug logging. - Fix prover's message_queue_hash lookup to use last_processed_l1_index instead of nextCrossDomainMessageIndex-1, fixing BAD_MESSAGE_QUEUE_HASH after deposits.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Depends on https://github.com/dcSpark/midnight-l2-contracts, which is checked out here as a submodule.