Skip to content

Comments

fix: TransactionHeader serialization#1701

Merged
juan518munoz merged 2 commits intonextfrom
jmunoz-fix-tx-header-serialization
Feb 24, 2026
Merged

fix: TransactionHeader serialization#1701
juan518munoz merged 2 commits intonextfrom
jmunoz-fix-tx-header-serialization

Conversation

@juan518munoz
Copy link
Collaborator

@juan518munoz juan518munoz commented Feb 23, 2026

Debugging #1691 with the miden client, found the following errors:

The TransactionHeader type changes from miden-base #1973 introduce a serialization mismatch in TransactionSummaryRowInsert::new.

The read side (TransactionRecordRaw::try_into) deserializes stored bytes as Vec<Nullifier> and Vec<NoteId>, but after the base update:

  • transaction_header.input_notes() returns InputNotes<InputNoteCommitment> (was Vec<Nullifier>), where InputNoteCommitment includes an Option<NoteHeader> alongside the nullifier.
  • transaction_header.output_notes() returns &[NoteHeader] (was Vec<NoteId>), where NoteHeader includes NoteMetadata alongside the note ID.

Calling .to_bytes() on these richer types produces a different binary format than what the read side expects, so we need to extract just the nullifiers and note IDs before serializing.

Cursor/push logic

Old code accumulated transactions in the loop but only stored the last one in last_added_tx. After the loop, it pushed that single transaction and updated the cursor. This was a bug — only the last transaction from each chunk was actually pushed to all_transactions, thus all earlier transactions in the chunk were silently dropped.

Fix pushes each transaction and updates the cursor immediately inside the loop, so every transaction that fits within the size limit is correctly added to all_transactions.

Copy link
Contributor

@mmagician mmagician left a comment

Choose a reason for hiding this comment

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

LGTM, let's maybe add a roundtrip test for serialization here?

@drahnr
Copy link
Contributor

drahnr commented Feb 23, 2026

This also needs a migration which is about to be introduced in #1700 , or do we never query the TX header from DB?

@juan518munoz
Copy link
Collaborator Author

LGTM, let's maybe add a roundtrip test for serialization here?

Added here

@juan518munoz
Copy link
Collaborator Author

This also needs a migration which is about to be introduced in #1700 , or do we never query the TX header from DB?

There's no schema change so we don't need to wait for #1700

Copy link
Collaborator

@igamigo igamigo left a comment

Choose a reason for hiding this comment

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

LGTM in terms of the code actually fixing the issue. However, we still cannot reconstruct the transaction header AFAIK. Not sure if this is something we want (I think it was discussed it at some point, but couldn't find much after a quick search cc @PhilippGackstatter), but I don't think we need it so this PR should be fine to merge.

Copy link
Contributor

@bobbinth bobbinth left a comment

Choose a reason for hiding this comment

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

Looks good! Thank you!

However, we still cannot reconstruct the transaction header AFAIK. Not sure if this is something we want (I think it was discussed it at some point, but couldn't find much after a quick search cc @PhilippGackstatter), but I don't think we need it so this PR should be fine to merge.

I thought we had an issue about this somewhere (to try to make transaction header consistent between protocol and protobuf implementations). If not, it may make sense to create one.


This endpoint enables clients to maintain an updated view of account storage.

### SyncChainMmr
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: why did we remove this section (and also the entry on line 26 above)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It was mistakenly removed, fixed!

@Mirko-von-Leipzig
Copy link
Collaborator

This also needs a migration which is about to be introduced in #1700 , or do we never query the TX header from DB?

There's no schema change so we don't need to wait for #1700

Just so we're on the same page here -- this, and the protocol migration, are not intended for v0.13 correct? If they are, then this becomes a much bigger lift.

@bobbinth
Copy link
Contributor

Just so we're on the same page here -- this, and the protocol migration, are not intended for v0.13 correct? If they are, then this becomes a much bigger lift.

No - this should go into next with the intent to be deployed to devnet around Wednesday this week.

// Serialize input notes using binary format (store nullifiers)
let nullifiers_binary = transaction_header.input_notes().to_bytes();
// Extract nullifiers from input notes and serialize them.
// We only store the nullifiers (not the full InputNoteCommitment) since
Copy link
Contributor

@drahnr drahnr Feb 24, 2026

Choose a reason for hiding this comment

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

nit: I'd appreciate backticks for types in comments


impl BundledValidatorConfig {
/// Converts the [`ValidatorConfig`] into a URL and an optional [`SocketAddr`].
/// Converts the `ValidatorConfig` into a URL and an optional [`SocketAddr`].
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// Converts the `ValidatorConfig` into a URL and an optional [`SocketAddr`].
/// Converts the [`crate::commands::ValidatorConfig`] into a URL and an optional [`SocketAddr`].

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Linting was not part of actual code changes, as of rebasing into next, suggestion no longer applies.

Copy link
Contributor

@drahnr drahnr left a comment

Choose a reason for hiding this comment

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

Bar the removal of SyncChainMmr from the docs and some nits, LGTM

Copy link
Contributor

@mmagician mmagician left a comment

Choose a reason for hiding this comment

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

lgtm, but this should go to next as the bug is already there and not on the migration branch

@juan518munoz juan518munoz force-pushed the jmunoz-fix-tx-header-serialization branch from a652138 to 12a0a74 Compare February 24, 2026 14:32
@juan518munoz juan518munoz changed the base branch from mmagician-base-update to next February 24, 2026 14:32
@juan518munoz
Copy link
Collaborator Author

I thought we had an issue about this somewhere (to try to make transaction header consistent between protocol and protobuf implementations). If not, it may make sense to create one.

@bobbinth I believe you were refering to #1605

Copy link
Collaborator

@igamigo igamigo left a comment

Choose a reason for hiding this comment

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

Thanks!

@juan518munoz juan518munoz merged commit 0504583 into next Feb 24, 2026
19 checks passed
@juan518munoz juan518munoz deleted the jmunoz-fix-tx-header-serialization branch February 24, 2026 15:05
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.

6 participants