Skip to content

feat: implement rlp decoding for common types#12

Merged
MegaRedHand merged 32 commits intomainfrom
implement_rlp_decoding
Jun 28, 2024
Merged

feat: implement rlp decoding for common types#12
MegaRedHand merged 32 commits intomainfrom
implement_rlp_decoding

Conversation

@juanbono
Copy link
Collaborator

@juanbono juanbono commented Jun 10, 2024

Motivation

This PR adds a RLPDecode trait for decoding RLP encoded data. It also adds implementations for common types.

Description

Closes #18

@juanbono juanbono marked this pull request as ready for review June 27, 2024 18:08
@juanbono juanbono requested a review from a team as a code owner June 27, 2024 18:08
}
}

fn decode_rlp_item(data: &[u8]) -> Result<(bool, &[u8], &[u8]), RLPDecodeError> {
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 replace the bool with an enum, either wrapping the current item slice:

enum RLPItem<'a> {
    Int(u8),
    String(&'a [u8]),
    List(&'a [u8]),
}
// -> Result<(RLPItem, &[u8]), RLPDecodeError>

or not:

enum RLPItem {
    String,
    List,
}
// -> Result<(RLPItem, &[u8], &[u8]), RLPDecodeError>

Copy link
Collaborator

@MegaRedHand MegaRedHand left a comment

Choose a reason for hiding this comment

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

LGTM. We can iterate on this.

@MegaRedHand MegaRedHand merged commit 005de73 into main Jun 28, 2024
@MegaRedHand MegaRedHand deleted the implement_rlp_decoding branch June 28, 2024 18:32
@juanbono juanbono self-assigned this Jun 29, 2024
ricomateo added a commit that referenced this pull request Jul 2, 2024
This PR depends on #75 and #12 

**Motivation**

Having some functionality of the discv4 protocol (ping-pong messages)

**Description**

Enables `Pong` message decoding



Closes #81

---------

Co-authored-by: juanbono <juanbono94@gmail.com>
Co-authored-by: Tomás Grüner <47506558+MegaRedHand@users.noreply.github.com>
@fedacking fedacking mentioned this pull request Feb 5, 2026
1 task
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.

Implement RLP encoding and decoding

2 participants