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: SpanSerde #3145

Merged
merged 1 commit into from
Jun 6, 2023
Merged

Conversation

milancermak
Copy link
Contributor

@milancermak milancermak commented May 15, 2023

There's no Serde implementation for Spans. That means we can't for example emit events with Spans. This won't compile:

#[contract]
mod Foo {
    use array::SpanTrait;

    #[event]
    fn Sup(values: Span<u8>) {}

    #[external]
    fn do_something(s: Span<u8>) {
        Sup(s);
    }
}

The error is:

error: Trait has no implementation in context: core::serde::Serde::<core::array::Span::<core::integer::u8>>
 --> contract:21:35
        serde::Serde::<Span<u8>>::serialize(@values, ref __data);
                                  ^*******^

error: Trait has no implementation in context: core::serde::Serde::<core::array::Span::<core::integer::u8>>
 --> contract:53:43
                serde::Serde::<Span<u8>>::deserialize(ref data).expect('Input too short for arguments');
                                          ^*********^

Error: Compilation failed.

This PR adds a SpanSerde that fixes the above error. I hope it's just as simple as I imagine it to be, please tell me if I'm missing something.


This change is Reviewable

@milancermak
Copy link
Contributor Author

Bump.

Could this still get merged into 1.1.0? I don't care if it's my PR or you do it internally, but people run into this issue all the time, so the sooner it's fixed the better.

Copy link
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 1 of 1 files at r1, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @milancermak)

Copy link
Contributor

@spapinistarkware spapinistarkware left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @milancermak)

Copy link
Contributor

@spapinistarkware spapinistarkware left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r1, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @milancermak)

Copy link
Contributor

@spapinistarkware spapinistarkware left a comment

Choose a reason for hiding this comment

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

Approved. Just fix the conflicts

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @milancermak)

auto-merge was automatically disabled June 6, 2023 10:19

Head branch was pushed to by a user without write access

Copy link
Contributor Author

@milancermak milancermak left a comment

Choose a reason for hiding this comment

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

Conflicts resolved. Moved the impl to array.cairo and slightly improved deserialize.

Reviewable status: 0 of 2 files reviewed, all discussions resolved (waiting on @orizi and @spapinistarkware)

Copy link
Contributor

@spapinistarkware spapinistarkware left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 2 files at r2, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @milancermak)

@spapinistarkware spapinistarkware added this pull request to the merge queue Jun 6, 2023
Merged via the queue into starkware-libs:main with commit 0e9d963 Jun 6, 2023
@milancermak milancermak deleted the feat/spanserde branch June 6, 2023 12:37
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.

3 participants