-
Notifications
You must be signed in to change notification settings - Fork 149
feat(l1): bal types and engine_newPayloadV5
#5726
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
base: main
Are you sure you want to change the base?
Changes from all commits
6540036
733f4bd
c838262
b860d7b
282a56d
d7bbe93
fe588a0
c0aa92f
fcf0063
c007745
4ce3e76
5412b37
5dcb02c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -43,6 +43,14 @@ pub static DEPOSIT_TOPIC: LazyLock<H256> = LazyLock::new(|| { | |||||||||||||||
| .expect("Failed to decode hex from string") | ||||||||||||||||
| }); | ||||||||||||||||
|
|
||||||||||||||||
| // = Keccak256(RLP([])) as of EIP-7928 | ||||||||||||||||
| pub static EMPTY_BLOCK_ACCESS_LIST_HASH: LazyLock<H256> = LazyLock::new(|| { | ||||||||||||||||
| H256::from_slice( | ||||||||||||||||
| &hex::decode("1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347") | ||||||||||||||||
| .expect("Failed to decode hex from string"), | ||||||||||||||||
| ) | ||||||||||||||||
| }); | ||||||||||||||||
|
Comment on lines
+47
to
+52
|
||||||||||||||||
| pub static EMPTY_BLOCK_ACCESS_LIST_HASH: LazyLock<H256> = LazyLock::new(|| { | |
| H256::from_slice( | |
| &hex::decode("1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347") | |
| .expect("Failed to decode hex from string"), | |
| ) | |
| }); | |
| pub use DEFAULT_OMMERS_HASH as EMPTY_BLOCK_ACCESS_LIST_HASH; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -605,6 +605,77 @@ fn parse_duration(input: String) -> Option<Duration> { | |
| Some(res) | ||
| } | ||
|
|
||
| pub mod block_access_list { | ||
|
|
||
| use super::*; | ||
| use ethrex_rlp::decode::RLPDecode; | ||
| use ethrex_rlp::encode::RLPEncode; | ||
|
|
||
| pub mod rlp_str { | ||
|
|
||
| use crate::types::block_access_list::BlockAccessList; | ||
|
|
||
| use super::*; | ||
| pub fn deserialize<'de, D>(d: D) -> Result<BlockAccessList, D::Error> | ||
| where | ||
| D: Deserializer<'de>, | ||
| { | ||
| let value = String::deserialize(d)?; | ||
| let bytes = hex::decode(value.trim_start_matches("0x")) | ||
| .map_err(|e| D::Error::custom(e.to_string()))?; | ||
| BlockAccessList::decode(&bytes) | ||
| .map_err(|_| D::Error::custom("Failed to RLP decode BAL")) | ||
| } | ||
|
|
||
| pub fn serialize<S>(value: &BlockAccessList, serializer: S) -> Result<S::Ok, S::Error> | ||
| where | ||
| S: Serializer, | ||
| { | ||
| let buf = value.encode_to_vec(); | ||
| serializer.serialize_str(&hex::encode(buf)) | ||
|
Comment on lines
+634
to
+635
|
||
| } | ||
| } | ||
|
|
||
| pub mod rlp_str_opt { | ||
|
|
||
| use serde::Serialize; | ||
|
|
||
| use crate::types::block_access_list::BlockAccessList; | ||
|
|
||
| use super::*; | ||
| pub fn deserialize<'de, D>(d: D) -> Result<Option<BlockAccessList>, D::Error> | ||
| where | ||
| D: Deserializer<'de>, | ||
| { | ||
| let value = Option::<String>::deserialize(d)?; | ||
| match value { | ||
| Some(s) if !s.is_empty() => hex::decode(s.trim_start_matches("0x")) | ||
| .map_err(|e| D::Error::custom(e.to_string())) | ||
| .and_then(|b| { | ||
| BlockAccessList::decode(&b) | ||
| .map_err(|_| D::Error::custom("Failed to RLP decode BAL")) | ||
| }) | ||
| .map(Some), | ||
| _ => Ok(None), | ||
| } | ||
| } | ||
|
|
||
| pub fn serialize<S>( | ||
| value: &Option<BlockAccessList>, | ||
| serializer: S, | ||
| ) -> Result<S::Ok, S::Error> | ||
| where | ||
| S: Serializer, | ||
| { | ||
| let bal = value | ||
| .as_ref() | ||
| .map(|bal| bal.encode_to_vec()) | ||
| .map(hex::encode); | ||
|
Comment on lines
+670
to
+673
|
||
| Option::<String>::serialize(&bal, serializer) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| #[cfg(test)] | ||
| mod tests { | ||
| use super::*; | ||
|
|
||
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.
The comment states "EIP-7928" but this appears to be referencing a hypothetical or future EIP. The EIP number should be verified and corrected if this is not the correct EIP number for Block Access Lists.