Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: store and retrieve aux field #384

Merged
merged 4 commits into from
Jun 14, 2024

Conversation

mFragaBA
Copy link
Contributor

@mFragaBA mFragaBA commented Jun 12, 2024

addresses #342.

I tried testing this using the integration tests on miden-client but they fail because I still can't use any other value than 0 for the aux field until 0xPolygonMiden/miden-base#731 is done.

That being said, I somewhat tested this change by changing the hardcoded 0 value in the transaction kernel's create_note and using the same value for notes on the integration tests. They ran successfully with some fixes present in 0xPolygonMiden/miden-client#381 (mainly removing hardcoded values from the client side)

  • the client was able to consume the notes
  • I checked the node's db using sqlite3 and the aux column of notes had the proper values

let merkle_path = MerklePath::read_from_bytes(merkle_path_data)?;
let details_data = row.get_ref(8)?.as_blob_or_null()?;
let details_data = row.get_ref(9)?.as_blob_or_null()?;
let details = details_data.map(<Vec<u8>>::read_from_bytes).transpose()?;

// TODO: Properly retrieve aux
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should be good to remove this TODO!

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also, these same changes need to be applied to the other note queries

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done! I removed the TODO and applied the same change to select_note and select_note_by_id

@@ -483,17 +486,19 @@ pub fn select_notes_since_block_by_tag_and_sender(
let note_type = row.get::<_, u8>(4)?;
let sender = column_value_as_u64(row, 5)?;
let tag: u32 = row.get(6)?;
let merkle_path_data = row.get_ref(7)?.as_blob()?;
let aux: u64 = row.get(7)?;
let aux = aux.try_into().map_err(|err| DatabaseError::DeserializationError(DeserializationError::InvalidValue(err)))?;
Copy link
Collaborator

@igamigo igamigo Jun 12, 2024

Choose a reason for hiding this comment

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

I'm not sure this error represents the problem correctly here. Looking at the definition it seems that it's related to problems deserializing SQL blobs where here, the u64 was already deserialized from the database. But also, not sure if there is a better representation there. Maybe introducing a new InvalidFelt variant?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done!

@mFragaBA mFragaBA marked this pull request as ready for review June 13, 2024 18:18
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.

All looks good! Thank you!

@Dominik1999 - could you tackle 0xPolygonMiden/miden-client#381 next so that we can test/close this as well?

@Dominik1999
Copy link
Contributor

There you go 0xPolygonMiden/miden-base#752

@bobbinth
Copy link
Contributor

@mFragaBA - now that 0xPolygonMiden/miden-base#752 is merged, could you confirm that all is working here as well? After this we can merge this PR as well.

@igamigo
Copy link
Collaborator

igamigo commented Jun 14, 2024

Was able to test this works correctly by doing the whole circuit from the client: minting an asset, consuming and sending it with different aux values, and the node data validates correctly:

image

@igamigo igamigo merged commit a0bd2c7 into next Jun 14, 2024
6 checks passed
@igamigo igamigo deleted the mFragaBA-store-and-retrieve-note-metadata-aux-field branch June 14, 2024 18:59
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.

4 participants