From 34fbff98c74e5851f3a49cd45a9a6324ecb5e371 Mon Sep 17 00:00:00 2001 From: Julian Ventura <43799596+JulianVentura@users.noreply.github.com> Date: Fri, 21 Feb 2025 15:45:47 -0300 Subject: [PATCH] fix(l1): update `rpc-compat` hive tests to Prague and fix failing ones (#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 --- .github/workflows/ci_l1.yaml | 2 +- Makefile | 2 +- crates/common/types/transaction.rs | 1 + crates/networking/rpc/eth/block.rs | 28 ++++------------------------ crates/networking/rpc/types/block.rs | 10 +++------- 5 files changed, 10 insertions(+), 33 deletions(-) diff --git a/.github/workflows/ci_l1.yaml b/.github/workflows/ci_l1.yaml index 1ea807c3af..038f20bebe 100644 --- a/.github/workflows/ci_l1.yaml +++ b/.github/workflows/ci_l1.yaml @@ -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 diff --git a/Makefile b/Makefile index 82a7dd2856..4d58263d74 100644 --- a/Makefile +++ b/Makefile @@ -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). diff --git a/crates/common/types/transaction.rs b/crates/common/types/transaction.rs index c5f3b0493a..8f813b1b25 100644 --- a/crates/common/types/transaction.rs +++ b/crates/common/types/transaction.rs @@ -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, diff --git a/crates/networking/rpc/eth/block.rs b/crates/networking/rpc/eth/block.rs index 742e50c6a0..3136c3eda8 100644 --- a/crates/networking/rpc/eth/block.rs +++ b/crates/networking/rpc/eth/block.rs @@ -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; @@ -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())) } @@ -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())) } } diff --git a/crates/networking/rpc/types/block.rs b/crates/networking/rpc/types/block.rs index f6f2a4c4f2..8c311bae4b 100644 --- a/crates/networking/rpc/types/block.rs +++ b/crates/networking/rpc/types/block.rs @@ -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; @@ -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)] @@ -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() @@ -67,7 +64,6 @@ impl RpcBlock { RpcBlock { hash, - total_difficulty, size: size as u64, header, body: body_wrapper, @@ -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) } }