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

refactor(primitvies): remove roundtrip-safe structs from primitives #605

Open
scarmuega opened this issue Feb 18, 2025 · 3 comments
Open
Assignees

Comments

@scarmuega
Copy link
Member

No description provided.

@sterraf
Copy link
Contributor

sterraf commented Feb 20, 2025

It seems necessary to implement the corresponding serde traits for KeepRaw, in order to have the same functionality. Should they be "transparent", i.e., ignoring the CBOR data? Or the derived ones for KeepRaw work well?

Today, derived traits are not the same for Minted vs plain structs:

#[derive(Serialize, Deserialize, Encode, Decode, Debug)]
pub struct Tx {
    ...

vs

#[derive(Encode, Decode, Debug, Clone)]
pub struct MintedTx<'b> {
    ...

@scarmuega
Copy link
Member Author

@sterraf KeepRaw should be transparent for serde.

@sterraf
Copy link
Contributor

sterraf commented Feb 24, 2025

There are instances of roundtrip-safe structs that have to be moved inside of a KeepRaw, namely:

pub struct MintedBlock<'b> {
    #[n(0)]
    pub header: KeepRaw<'b, MintedHeader<'b>>,

    #[b(1)]
    pub transaction_bodies: MaybeIndefArray<KeepRaw<'b, TransactionBody>>,

In order to safely switch to Vec, it would be natural to do:

    pub transaction_bodies: KeepRaw<'b, Vec<TransactionBody>>,

This motivates: Should Minted structs (which are going to be default by #604) have a more uniform layout, as in "each field is a KeepRaw?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

2 participants