Skip to content

free function serialization DSL#32

Merged
UkoeHB merged 1 commit intoUkoeHB:seraphis_libfrom
jeffro256:free_function_serial
Mar 5, 2024
Merged

free function serialization DSL#32
UkoeHB merged 1 commit intoUkoeHB:seraphis_libfrom
jeffro256:free_function_serial

Conversation

@jeffro256
Copy link
Copy Markdown

Useful for PR #25

@jeffro256
Copy link
Copy Markdown
Author

jeffro256 commented Feb 21, 2024

Example usage (replacing serialization_demo_utils):

BLOB_SERIALIZER(sp::jamtis::address_index_t);
BLOB_SERIALIZER(sp::jamtis::address_tag_t);
BLOB_SERIALIZER(sp::jamtis::encrypted_address_tag_t);
BLOB_SERIALIZER(sp::jamtis::encoded_amount_t);

BEGIN_SERIALIZE_OBJECT_FN(sp::SpCoinbaseEnoteCore)
    FIELD_F(onetime_address)
    VARINT_FIELD_F(amount)
END_SERIALIZE()

BEGIN_SERIALIZE_OBJECT_FN(sp::SpEnoteCore)
    FIELD_F(onetime_address)
    FIELD_F(amount_commitment)
END_SERIALIZE()

BEGIN_SERIALIZE_OBJECT_FN(sp::SpEnoteImageCore)
    FIELD_F(masked_address)
    FIELD_F(masked_commitment)
    FIELD_F(key_image)
END_SERIALIZE()

BEGIN_SERIALIZE_OBJECT_FN(sp::SpEnoteImageCore)
    FIELD_F(masked_address)
    FIELD_F(masked_commitment)
    FIELD_F(key_image)
END_SERIALIZE()

BEGIN_SERIALIZE_OBJECT_FN(sp::BulletproofPlus2)
    FIELD_F(A)
    FIELD_F(A1)
    FIELD_F(B)
    FIELD_F(r1)
    FIELD_F(s1)
    FIELD_F(d1)
    FIELD_F(L)
    FIELD_F(R)
END_SERIALIZE()

... continue pattern here 

We can serialize directly from seraphis types non-intrusively and don't need all the extra types and boilerplate eventually

@DangerousFreedom1984
Copy link
Copy Markdown

That should make things much easier. Thanks.

@UkoeHB
Copy link
Copy Markdown
Owner

UkoeHB commented Feb 21, 2024

You should parallel-PR this to the monero repo.

Copy link
Copy Markdown
Owner

@UkoeHB UkoeHB left a comment

Choose a reason for hiding this comment

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

@vtnerd can you review this?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I don't understand what this does, other than it allows the macro to be used outside of a class scope. Presumably that is the goal here?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yes, that's the current design goal with the Seraphis lib AFAIK: separate class definitions and their serialization.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I agree that the comment needs some fixing - the goal is to allow a standalone function in a cpp or something? Difficult to say without any example uses.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

There's some sample uses in an earlier comment in this thread. Should I put it into the code?

@jeffro256 jeffro256 force-pushed the free_function_serial branch from d79a5d1 to 394b18e Compare February 21, 2024 22:52
@jeffro256 jeffro256 force-pushed the free_function_serial branch from 394b18e to 2ca414a Compare February 21, 2024 22:53
@jeffro256
Copy link
Copy Markdown
Author

Fixed comments, thanks @UkoeHB

@UkoeHB UkoeHB merged this pull request into UkoeHB:seraphis_lib Mar 5, 2024
UkoeHB pushed a commit that referenced this pull request Mar 6, 2024
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