Skip to content

Commit

Permalink
fix(l1): update rpc-compat hive tests to Prague and fix failing ones (
Browse files Browse the repository at this point in the history
#2043)

**Description**

This PR updates the hive tests suite to a new hive revision and fixes
new tests by removing the `total_difficulty` field on the block scheme.
This field was already removed in #304 and reintroduced in #566 due to
the usage in hive engine test suite.

Hive tests related to the wrong encoding of `nonce` field were also
fixed

---------

Co-authored-by: Julian Ventura <julian.ventura@lambdaclass.com>
  • Loading branch information
JulianVentura and Julian Ventura authored Feb 21, 2025
1 parent d2259b9 commit 34fbff9
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci_l1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ jobs:
include:
- name: "Rpc Compat tests"
simulation: ethereum/rpc-compat
test_pattern: /eth_chainId|eth_getTransactionByBlockHashAndIndex|eth_getTransactionByBlockNumberAndIndex|eth_getCode|eth_getStorageAt|eth_call|eth_getTransactionByHash|eth_getBlockByHash|eth_getBlockByNumber|eth_createAccessList|eth_getBlockTransactionCountByNumber|eth_getBlockTransactionCountByHash|eth_getBlockReceipts|eth_getTransactionReceipt|eth_blobGasPrice|eth_blockNumber|ethGetTransactionCount|debug_getRawHeader|debug_getRawBlock|debug_getRawTransaction|debug_getRawReceipts|eth_estimateGas|eth_getBalance|eth_sendRawTransaction|eth_getProof|eth_getLogs|eth_syncing
test_pattern: /debug_getRawBlock|debug_getRawHeader|debug_getRawReceipts|debug_getRawTransaction|eth_blobBaseFee|eth_blockNumber|eth_call|eth_chainId|eth_createAccessList|eth_estimateGas|eth_getBalance|eth_getBlockByHash|eth_getBlockByNumber|eth_getBlockReceipts|eth_getBlockTransactionCountByHash|eth_getBlockTransactionCountByNumber|eth_getCode|eth_getLogs|eth_getProof|eth_getStorageAt|eth_getTransactionByBlockHashAndIndex|eth_getTransactionByBlockNumberAndIndex|eth_getTransactionByHash|eth_getTransactionCount|eth_getTransactionReceipt|eth_sendRawTransaction|eth_syncing
- name: "Devp2p discv4 tests"
simulation: devp2p
test_pattern: discv4
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,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 := feb4333db7fe9f6dc161326ebb11957d4306d2f9
HIVE_REVISION := b21c217ba5f48949b6b64ef28f7fb11e40584652
# 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
1 change: 1 addition & 0 deletions crates/common/types/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1582,6 +1582,7 @@ mod serde_impl {
pub struct AuthorizationTupleEntry {
pub chain_id: U256,
pub address: Address,
#[serde(default, with = "crate::serde_utils::u64::hex_str")]
pub nonce: u64,
pub y_parity: U256,
pub r: U256,
Expand Down
28 changes: 4 additions & 24 deletions crates/networking/rpc/eth/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,8 @@ use crate::{
utils::RpcErr,
RpcApiContext, RpcHandler,
};
use ethrex_common::{
types::{
calculate_base_fee_per_blob_gas, Block, BlockBody, BlockHash, BlockHeader, BlockNumber,
Receipt,
},
U256,
use ethrex_common::types::{
calculate_base_fee_per_blob_gas, Block, BlockBody, BlockHash, BlockHeader, BlockNumber, Receipt,
};
use ethrex_storage::Store;

Expand Down Expand Up @@ -83,15 +79,7 @@ impl RpcHandler for GetBlockByNumberRequest {
_ => return Ok(Value::Null),
};
let hash = header.compute_block_hash();
// TODO (#307): Remove TotalDifficulty.
let total_difficulty = storage.get_block_total_difficulty(hash)?;
let block = RpcBlock::build(
header,
body,
hash,
self.hydrated,
total_difficulty.unwrap_or(U256::zero()),
);
let block = RpcBlock::build(header, body, hash, self.hydrated);

serde_json::to_value(&block).map_err(|error| RpcErr::Internal(error.to_string()))
}
Expand Down Expand Up @@ -125,15 +113,7 @@ impl RpcHandler for GetBlockByHashRequest {
_ => return Ok(Value::Null),
};
let hash = header.compute_block_hash();
// TODO (#307): Remove TotalDifficulty.
let total_difficulty = storage.get_block_total_difficulty(hash)?;
let block = RpcBlock::build(
header,
body,
hash,
self.hydrated,
total_difficulty.unwrap_or(U256::zero()),
);
let block = RpcBlock::build(header, body, hash, self.hydrated);
serde_json::to_value(&block).map_err(|error| RpcErr::Internal(error.to_string()))
}
}
Expand Down
10 changes: 3 additions & 7 deletions crates/networking/rpc/types/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use super::transaction::RpcTransaction;
use ethrex_common::{
serde_utils,
types::{Block, BlockBody, BlockHash, BlockHeader, BlockNumber, Withdrawal},
H256, U256,
H256,
};
use ethrex_rlp::encode::RLPEncode;

Expand All @@ -14,8 +14,6 @@ pub struct RpcBlock {
hash: H256,
#[serde(with = "serde_utils::u64::hex_str")]
size: u64,
// TODO (#307): Remove TotalDifficulty.
total_difficulty: U256,
#[serde(flatten)]
pub header: BlockHeader,
#[serde(flatten)]
Expand Down Expand Up @@ -50,7 +48,6 @@ impl RpcBlock {
body: BlockBody,
hash: H256,
full_transactions: bool,
total_difficulty: U256,
) -> RpcBlock {
let size = Block::new(header.clone(), body.clone())
.encode_to_vec()
Expand All @@ -67,7 +64,6 @@ impl RpcBlock {

RpcBlock {
hash,
total_difficulty,
size: size as u64,
header,
body: body_wrapper,
Expand Down Expand Up @@ -192,8 +188,8 @@ mod test {
};
let hash = block_header.compute_block_hash();

let block = RpcBlock::build(block_header, block_body, hash, true, U256::zero());
let expected_block = r#"{"hash":"0x94fb81ef7259ad4cef032745a2a5254babe26037f2850d320b872692f7c60178","size":"0x2f7","totalDifficulty":"0x0","parentHash":"0x48e29e7357408113a4166e04e9f1aeff0680daa2b97ba93df6512a73ddf7a154","sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","miner":"0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba","stateRoot":"0x9de6f95cb4ff4ef22a73705d6ba38c4b927c7bca9887ef5d24a734bb863218d9","transactionsRoot":"0x578602b2b7e3a3291c3eefca3a08bc13c0d194f9845a39b6f3bcf843d9fed79d","receiptsRoot":"0x035d56bac3f47246c5eed0e6642ca40dc262f9144b582f058bc23ded72aa72fa","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x1","gasLimit":"0x16345785d8a0000","gasUsed":"0xa8de","timestamp":"0x3e8","extraData":"0x","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x7","withdrawalsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","blobGasUsed":"0x0","excessBlobGas":"0x0","parentBeaconBlockRoot":"0x0000000000000000000000000000000000000000000000000000000000000000","requestsHash":"0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470","transactions":[{"type":"0x2","nonce":"0x0","to":"0x6177843db3138ae69679a54b95cf345ed759450d","gas":"0xf618","value":"0xaa87bee538000","input":"0x307831353638","maxPriorityFeePerGas":"0x11","maxFeePerGas":"0x4e","gasPrice":"0x4e","accessList":[{"address":"0x6177843db3138ae69679a54b95cf345ed759450d","storageKeys":[]}],"chainId":"0x301824","yParity":"0x0","v":"0x0","r":"0x151ccc02146b9b11adf516e6787b59acae3e76544fdcd75e77e67c6b598ce65d","s":"0x64c5dd5aae2fbb535830ebbdad0234975cd7ece3562013b63ea18cc0df6c97d4","blockNumber":"0x1","blockHash":"0x94fb81ef7259ad4cef032745a2a5254babe26037f2850d320b872692f7c60178","from":"0x35af8ea983a3ba94c655e19b82b932a30d6b9558","hash":"0x0b8c8f37731d9493916b06d666c3fd5dee2c3bbda06dfe866160d717e00dda91","transactionIndex":"0x0"}],"uncles":[],"withdrawals":[]}"#;
let block = RpcBlock::build(block_header, block_body, hash, true);
let expected_block = r#"{"hash":"0x94fb81ef7259ad4cef032745a2a5254babe26037f2850d320b872692f7c60178","size":"0x2f7","parentHash":"0x48e29e7357408113a4166e04e9f1aeff0680daa2b97ba93df6512a73ddf7a154","sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","miner":"0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba","stateRoot":"0x9de6f95cb4ff4ef22a73705d6ba38c4b927c7bca9887ef5d24a734bb863218d9","transactionsRoot":"0x578602b2b7e3a3291c3eefca3a08bc13c0d194f9845a39b6f3bcf843d9fed79d","receiptsRoot":"0x035d56bac3f47246c5eed0e6642ca40dc262f9144b582f058bc23ded72aa72fa","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x1","gasLimit":"0x16345785d8a0000","gasUsed":"0xa8de","timestamp":"0x3e8","extraData":"0x","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x7","withdrawalsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","blobGasUsed":"0x0","excessBlobGas":"0x0","parentBeaconBlockRoot":"0x0000000000000000000000000000000000000000000000000000000000000000","requestsHash":"0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470","transactions":[{"type":"0x2","nonce":"0x0","to":"0x6177843db3138ae69679a54b95cf345ed759450d","gas":"0xf618","value":"0xaa87bee538000","input":"0x307831353638","maxPriorityFeePerGas":"0x11","maxFeePerGas":"0x4e","gasPrice":"0x4e","accessList":[{"address":"0x6177843db3138ae69679a54b95cf345ed759450d","storageKeys":[]}],"chainId":"0x301824","yParity":"0x0","v":"0x0","r":"0x151ccc02146b9b11adf516e6787b59acae3e76544fdcd75e77e67c6b598ce65d","s":"0x64c5dd5aae2fbb535830ebbdad0234975cd7ece3562013b63ea18cc0df6c97d4","blockNumber":"0x1","blockHash":"0x94fb81ef7259ad4cef032745a2a5254babe26037f2850d320b872692f7c60178","from":"0x35af8ea983a3ba94c655e19b82b932a30d6b9558","hash":"0x0b8c8f37731d9493916b06d666c3fd5dee2c3bbda06dfe866160d717e00dda91","transactionIndex":"0x0"}],"uncles":[],"withdrawals":[]}"#;
assert_eq!(serde_json::to_string(&block).unwrap(), expected_block)
}
}

0 comments on commit 34fbff9

Please sign in to comment.