Skip to content

Commit

Permalink
chore(l1): update hive for prague (#1820)
Browse files Browse the repository at this point in the history
**Motivation**

In order to begin implementing the Prague EIPs, we need to update our
Hive fork to incorporate the new tests.

**Description**

- Updates the pointer to our updated Hive fork
- Makes our CI tests pass in the updated version.
  • Loading branch information
avilagaston9 authored Jan 28, 2025
1 parent 69b0e30 commit 6f6dbb9
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ stop-localnet-silent:
@kurtosis enclave stop $(ENCLAVE) >/dev/null 2>&1 || true
@kurtosis enclave rm $(ENCLAVE) --force >/dev/null 2>&1 || true

HIVE_REVISION := 37bde6deee7044b86fff88a39a52b33be460ae9c
HIVE_REVISION := e95ca293cc3fb95a6d964938cd24958e8afa55fa
# Shallow clones can't specify a single revision, but at least we avoid working
# the whole history by making it shallow since a given date (one day before our
# target revision).
Expand Down
3 changes: 2 additions & 1 deletion cmd/ef_tests/ethrex/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ pub struct Header {
pub blob_gas_used: Option<U256>,
pub excess_blob_gas: Option<U256>,
pub parent_beacon_block_root: Option<H256>,
pub requests_root: Option<H256>,
pub requests_hash: Option<H256>,
}

#[derive(Debug, PartialEq, Eq, Deserialize, Clone)]
Expand Down Expand Up @@ -235,6 +235,7 @@ impl From<Header> for BlockHeader {
blob_gas_used: val.blob_gas_used.map(|x| x.as_u64()),
excess_blob_gas: val.excess_blob_gas.map(|x| x.as_u64()),
parent_beacon_block_root: val.parent_beacon_block_root,
requests_hash: val.requests_hash,
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions crates/blockchain/payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ pub fn create_payload(args: &BuildPayloadArgs, storage: &Store) -> Result<Block,
),
),
parent_beacon_block_root: args.beacon_root,
requests_hash: chain_config
.is_prague_activated(args.timestamp)
.then_some(H256::zero()), // TODO: set the value properly
};

let body = BlockBody {
Expand Down
7 changes: 7 additions & 0 deletions crates/common/types/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ pub struct BlockHeader {
)]
pub excess_blob_gas: Option<u64>,
pub parent_beacon_block_root: Option<H256>,
#[serde(skip_serializing_if = "Option::is_none")]
pub requests_hash: Option<H256>,
}

impl RLPEncode for BlockHeader {
Expand All @@ -150,6 +152,7 @@ impl RLPEncode for BlockHeader {
.encode_optional_field(&self.blob_gas_used)
.encode_optional_field(&self.excess_blob_gas)
.encode_optional_field(&self.parent_beacon_block_root)
.encode_optional_field(&self.requests_hash)
.finish();
}
}
Expand Down Expand Up @@ -178,6 +181,7 @@ impl RLPDecode for BlockHeader {
let (blob_gas_used, decoder) = decoder.decode_optional_field();
let (excess_blob_gas, decoder) = decoder.decode_optional_field();
let (parent_beacon_block_root, decoder) = decoder.decode_optional_field();
let (requests_hash, decoder) = decoder.decode_optional_field();

Ok((
BlockHeader {
Expand All @@ -201,6 +205,7 @@ impl RLPDecode for BlockHeader {
blob_gas_used,
excess_blob_gas,
parent_beacon_block_root,
requests_hash,
},
decoder.finish()?,
))
Expand Down Expand Up @@ -664,6 +669,7 @@ mod test {
blob_gas_used: Some(0x00),
excess_blob_gas: Some(0x00),
parent_beacon_block_root: Some(H256::zero()),
requests_hash: None,
};
let block = BlockHeader {
parent_hash: H256::from_str(
Expand Down Expand Up @@ -706,6 +712,7 @@ mod test {
blob_gas_used: Some(0x00),
excess_blob_gas: Some(0x00),
parent_beacon_block_root: Some(H256::zero()),
requests_hash: None,
};
assert!(validate_block_header(&block, &parent_block).is_ok())
}
Expand Down
14 changes: 11 additions & 3 deletions crates/common/types/genesis.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
use bytes::Bytes;
use ethereum_types::{Address, Bloom, H256, U256};
use ethrex_rlp::encode::RLPEncode;
use ethrex_trie::Trie;
use serde::{Deserialize, Serialize};
use sha3::{Digest, Keccak256};
use std::collections::HashMap;

use ethrex_rlp::encode::RLPEncode;

use super::{
compute_receipts_root, compute_transactions_root, compute_withdrawals_root, AccountState,
Block, BlockBody, BlockHeader, BlockNumber, DEFAULT_OMMERS_HASH, INITIAL_BASE_FEE,
Expand Down Expand Up @@ -149,6 +148,9 @@ impl ChainConfig {
pub fn is_cancun_activated(&self, block_timestamp: u64) -> bool {
self.cancun_time.is_some_and(|time| time <= block_timestamp)
}
pub fn is_prague_activated(&self, block_timestamp: u64) -> bool {
self.prague_time.is_some_and(|time| time <= block_timestamp)
}

pub fn is_istanbul_activated(&self, block_number: BlockNumber) -> bool {
self.istanbul_block.is_some_and(|num| num <= block_number)
Expand All @@ -159,7 +161,9 @@ impl ChainConfig {
}

pub fn get_fork(&self, block_timestamp: u64) -> Fork {
if self.is_cancun_activated(block_timestamp) {
if self.is_prague_activated(block_timestamp) {
Fork::Prague
} else if self.is_cancun_activated(block_timestamp) {
Fork::Cancun
} else if self.is_shanghai_activated(block_timestamp) {
Fork::Shanghai
Expand Down Expand Up @@ -268,6 +272,10 @@ impl Genesis {
.config
.is_cancun_activated(self.timestamp)
.then_some(H256::zero()),
requests_hash: self
.config
.is_prague_activated(self.timestamp)
.then_some(H256::zero()), // TODO: set the value properly
}
}

Expand Down
1 change: 1 addition & 0 deletions crates/networking/rpc/eth/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ pub mod test_utils {
blob_gas_used: Some(0x00),
excess_blob_gas: Some(0x00),
parent_beacon_block_root: Some(H256::zero()),
requests_hash: None,
}
}

Expand Down
1 change: 1 addition & 0 deletions crates/networking/rpc/types/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ mod test {
blob_gas_used: Some(0x00),
excess_blob_gas: Some(0x00),
parent_beacon_block_root: Some(H256::zero()),
requests_hash: None,
};

let tx = EIP1559Transaction {
Expand Down
2 changes: 2 additions & 0 deletions crates/networking/rpc/types/payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ impl ExecutionPayload {
blob_gas_used: self.blob_gas_used,
excess_blob_gas: self.excess_blob_gas,
parent_beacon_block_root,
// TODO: set the value properly
requests_hash: None,
};

Ok(Block::new(header, body))
Expand Down
1 change: 1 addition & 0 deletions crates/storage/store/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1176,6 +1176,7 @@ mod tests {
blob_gas_used: Some(0x00),
excess_blob_gas: Some(0x00),
parent_beacon_block_root: Some(H256::zero()),
requests_hash: None,
};
let block_body = BlockBody {
transactions: vec![Transaction::decode(&hex::decode("b86f02f86c8330182480114e82f618946177843db3138ae69679a54b95cf345ed759450d870aa87bee53800080c080a0151ccc02146b9b11adf516e6787b59acae3e76544fdcd75e77e67c6b598ce65da064c5dd5aae2fbb535830ebbdad0234975cd7ece3562013b63ea18cc0df6c97d4").unwrap()).unwrap(),
Expand Down

0 comments on commit 6f6dbb9

Please sign in to comment.