Skip to content

fix: remove padding from output note inputs#1360

Merged
Fumuran merged 3 commits intonextfrom
tomyrd-output-note-inputs
May 15, 2025
Merged

fix: remove padding from output note inputs#1360
Fumuran merged 3 commits intonextfrom
tomyrd-output-note-inputs

Conversation

@tomyrd
Copy link
Copy Markdown
Contributor

@tomyrd tomyrd commented May 14, 2025

After cargo updateing in the client we started getting errors related to the number of note inputs. It seems like there was an error after #1327 with output notes that were then used as input notes. Specifically, the input note derived from the output note contained padding in its note inputs.
Our solution was to add the number of note inputs into the recipient's advice map entry, we're not sure if this is the correct approach though.

@tomyrd tomyrd added no changelog This PR does not require an entry in the `CHANGELOG.md` file no docs labels May 14, 2025
@tomyrd tomyrd marked this pull request as ready for review May 14, 2025 19:34
@igamigo
Copy link
Copy Markdown
Collaborator

igamigo commented May 14, 2025

Something that would probably be good to have (even if we decide this PR is not the best solution) is a test that executes a transaction that uses a note that was output from a previous transaction. This was the only difference between client and base tests, and why it wasn't caught here in the first place.

Copy link
Copy Markdown
Contributor

@Fumuran Fumuran 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 very much for spotting this bug! I left just a few comments inline.

let inputs = match inputs_data {
None => NoteInputs::default(),
Some(inputs) => {
let num_inputs = data[12].as_int() as usize;
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.

Since we moved the number of inputs to the 0'th position in the vector, should we get it using data[0]? Also probably other data indexes should be updated because of that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes! Just realized the CI was failing, was trying to create a unit test for the failing case but wasn't able to. I'll create an issue for this so we can merge this.

Copy link
Copy Markdown
Contributor

@Fumuran Fumuran left a comment

Choose a reason for hiding this comment

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

LGTM!

I think that solution with adding the length to the vector of recipient values is good. Potentially we could change that if we decide to move the entire note inputs to the memory, but it is still an open question.

@Fumuran Fumuran requested a review from bobbinth May 14, 2025 22:24
Copy link
Copy Markdown
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! I left one comment for the future inline.

Comment on lines +60 to +71
/// Returns the recipient formatted to be used with the advice map.
///
/// The format is `inputs_length || INPUTS_COMMITMENT || SCRIPT_ROOT || SERIAL_NUMBER`
///
/// Where:
/// - inputs_length is the length of the note inputs
/// - INPUTS_COMMITMENT is the commitment of the note inputs
/// - SCRIPT_ROOT is the commitment of the note script (i.e., the script's MAST root)
/// - SERIAL_NUMBER is the recipient's serial number
pub fn format_for_advice(&self) -> Vec<Felt> {
let mut result = Vec::with_capacity(13);
result.push(self.inputs.num_values().into());
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.

I think this is fine for now, but ideally we'd move towards a setup where a key in the advice map corresponds to the hash of the underlying data. It's not clear to me what's the best way to do this - so, let's just create an issue for this.

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.

Created an issue: #1365

@Fumuran Fumuran merged commit a30142d into next May 15, 2025
16 checks passed
@Fumuran Fumuran deleted the tomyrd-output-note-inputs branch May 15, 2025 11:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no changelog This PR does not require an entry in the `CHANGELOG.md` file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants