fix(primitives) : Check first byte for EOF#1479
Closed
DoTheBestToGetTheBest wants to merge 4 commits intobluealloy:mainfrom
Closed
fix(primitives) : Check first byte for EOF#1479DoTheBestToGetTheBest wants to merge 4 commits intobluealloy:mainfrom
DoTheBestToGetTheBest wants to merge 4 commits intobluealloy:mainfrom
Conversation
rakita
reviewed
Jun 3, 2024
crates/primitives/src/bytecode.rs
Outdated
| /// Checks if the bytecode starts with the EOF prefix followed by the correct version. | ||
| #[inline] | ||
| pub fn is_eof_format(bytes: &Bytes) -> bool { | ||
| bytes.len() >= 2 && bytes[0] == EOF_PREFIX && bytes[1] == EOF_VERSION |
Member
There was a problem hiding this comment.
This is not correct. EOF_MAGIC is 0xEF00 while EOF_VERSION (At least version one) is 0x01. Would be good to move those in revm-primitives crate
prefix is 0xEF0001
rakita
reviewed
Jun 3, 2024
|
|
||
| /// Creates a new raw [`Bytecode`]. | ||
| #[inline] | ||
| pub fn new_raw(bytecode: Bytes) -> Self { |
Member
There was a problem hiding this comment.
Would return Error here as Legacy bytecode with 0xEF is considered invalid. And only valid EOF can have 0xEF prefix.
Would additionally add new_legacy function for legacy codes.
rakita
reviewed
Jun 22, 2024
Comment on lines
+77
to
+82
| if bytes.len() >= 3 { | ||
| let prefix = u16::from_be_bytes([bytes[0], bytes[1]]); | ||
| let version = bytes[2]; | ||
|
|
||
| prefix == EOF_PREFIX && version == EOF_VERSION | ||
| } else { |
Member
There was a problem hiding this comment.
This can be missleading in tx create case. For EOF only first two bytes should be checked.
You can do this as:
inputs.init_code.get(..2) == Some(&EOF_MAGIC_BYTES)
rakita
reviewed
Jun 22, 2024
|
|
||
| /// Version byte that immediately follows the EOF prefix in EIP-3540. | ||
| // See https://github.com/bluealloy/revm/issues/1464 | ||
| pub const EOF_VERSION: u8 = 0x01; |
Member
There was a problem hiding this comment.
EOF_MAGIC_BYTES const were added to src/bytecode/eof.rs
Member
|
Superseded by #1607 |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #1464