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

Merge rlp and rlp2 #13095

Merged
merged 3 commits into from
Dec 13, 2024
Merged

Merge rlp and rlp2 #13095

merged 3 commits into from
Dec 13, 2024

Conversation

racytech
Copy link
Contributor

Since rlp and rlp2 both had EncodeString function, I decided to change function name in rlp package to EncodeBytes to avoid name collision.
Functions in parse.go file List, String, U256, U64, U32 were changed to ParseList, ParseString, ParseU256 etc.
Function EncodeStructSizePrefix was moved from types package to rlp package which is more semantically suitable

@@ -270,11 +250,11 @@ func (tx *AccessListTx) encodePayload(w io.Writer, b []byte, payloadSize, nonceL
return err
}
// encode Data
if err := rlp.EncodeString(tx.Data, w, b); err != nil {
if err := rlp.EncodeBytes(tx.Data, w, b); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why this rename? Isn't it understood that "string" here means a flat string of bytes.
Additionally it creates naming discrepancy with EncodeStringSizePrefix, ParseString and so on.

Copy link
Contributor Author

@racytech racytech Dec 12, 2024

Choose a reason for hiding this comment

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

Agree. It was a hard decision. We have two functions named EncodeString in a single package one of which had to be changed. I couldn't come up with anything better. EncodeString2 was another candidate, but I didn't like it. Anyways, please drop any ideas.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, maybe we can just get rid of the other one. Till then, EncodeStringBytes is a suitable name. I am hoping we can soon truly merge the two sets of implementations for all other methods too.

Copy link
Member

Choose a reason for hiding this comment

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

I think it's better to use names EncodeString and EncodeString2 to highlight that it's two flavours of the same thing. And eventually we should merge them.

Copy link
Contributor Author

@racytech racytech Dec 13, 2024

Choose a reason for hiding this comment

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

I wish Go had function overloading features. I was trying merging them into one function by adding additional parameter and by defining Writer interface for a type SomeType []byte, but things wasn't looking good

@somnathb1 somnathb1 enabled auto-merge (squash) December 13, 2024 12:36
@somnathb1 somnathb1 merged commit 89a4a1e into main Dec 13, 2024
13 checks passed
@somnathb1 somnathb1 deleted the rlp_rlp2_merge branch December 13, 2024 13:07
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