This repository was archived by the owner on Jan 8, 2025. It is now read-only.
generated from keep-starknet-strange/alexandria
-
Notifications
You must be signed in to change notification settings - Fork 83
dev: improve rlp.cairo to support recursive list #457
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Eikix
reviewed
Oct 25, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First review, will have more questions in the coming days as I have more time to do a second review
Made a better recursive implementation for the rlp_decode(). |
2860336
to
7a34842
Compare
Interestingly, there was a bug in the compiler, it'll be fixed in the next release |
bajpai244
reviewed
Oct 31, 2023
bajpai244
reviewed
Oct 31, 2023
bajpai244
reviewed
Oct 31, 2023
9cfb973
to
758eeb2
Compare
Eikix
reviewed
Nov 1, 2023
Eikix
reviewed
Nov 1, 2023
Eikix
previously approved these changes
Nov 1, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Eikix
reviewed
Nov 1, 2023
Eikix
approved these changes
Nov 1, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Congratulations! Well fought
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Implemented recursive struct in rlp.cairo to be able to handle recursive list. I also tried to be as close as the code given in the ethereum doc ; https://ethereum.org/en/developers/docs/data-structures-and-encoding/rlp/ .
Here is a list of the biggest changes :
decode_type()
( formerfrom_bytes()
) now takes an array to be able to retrieve the long strings/lists size. It does now return the type which is either a string or a list, the offset at which it starts and its size.decode()
is now recursively called in case of recursive lists.Here is a screenshot of gas consommation before the modifications ;
And here is one after the modifications ;
It's worth noting that some tests show improvement.
For instance, the
test_decode_string
appears to consume more gas than before, but this test is essentially a loop that converts a single character into an array, explaining the increased gas consumption. But on the other hand, thetest_decode_long_list
test, which deals with a larger amount of bytes, consumes less gas than it did originally.I am certain that there is still potential for further improvement, and I would appreciate feedback on the direction these changes are taking. Whether you agree or disagree with some of the modifications.
Pull Request type
Please check the type of change your PR introduces:
What is the current behavior?
rlp.cairo.decode()
doesn't handle recusrive list.Resolves: #428
What is the new behavior?
Does this introduce a breaking change?