mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-11 18:04:18 +00:00
Remove use of ethers core (#5301)
* Remove use of ethers_core::RlpStream
* Merge branch 'unstable' of https://github.com/sigp/lighthouse into remove_use_of_ethers_core
* Remove old code
* Simplify keccak call
* Remove unused package
* Merge branch 'unstable' of https://github.com/ethDreamer/lighthouse into remove_use_of_ethers_core
* Merge branch 'unstable' into remove_use_of_ethers_core
* Run clippy
* Merge branch 'remove_use_of_ethers_core' of https://github.com/dospore/lighthouse into remove_use_of_ethers_core
* Check all cargo fmt
* Merge branch 'unstable' of https://github.com/sigp/lighthouse into remove_use_of_ethers_core
* Revert lock
* Merge branch 'unstable' of https://github.com/sigp/lighthouse into remove_use_of_ethers_core
* introduce a shim to convert between the two u256 types
* move alloy to wrokspace
* align alloy versions
* update
* update web3signer test certs
* Revert "update web3signer test certs"
This reverts commit effd5910ad.
* Consolidate alloy versions
* Delete empty file
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
use crate::{
|
||||
json_structures::JsonWithdrawal,
|
||||
json_structures::{EncodableJsonWithdrawal, JsonWithdrawal},
|
||||
keccak::{keccak256, KeccakHasher},
|
||||
};
|
||||
use ethers_core::utils::rlp::RlpStream;
|
||||
use alloy_rlp::Encodable;
|
||||
use keccak_hash::KECCAK_EMPTY_LIST_RLP;
|
||||
use triehash::ordered_trie_root;
|
||||
use types::{
|
||||
map_execution_block_header_fields_base, Address, EthSpec, ExecutionBlockHash,
|
||||
ExecutionBlockHeader, ExecutionPayloadRef, Hash256, Hash64, Uint256,
|
||||
EncodableExecutionBlockHeader, EthSpec, ExecutionBlockHash, ExecutionBlockHeader,
|
||||
ExecutionPayloadRef, Hash256,
|
||||
};
|
||||
|
||||
/// Calculate the block hash of an execution block.
|
||||
@@ -60,36 +60,16 @@ pub fn calculate_execution_block_hash<E: EthSpec>(
|
||||
|
||||
/// RLP encode a withdrawal.
|
||||
pub fn rlp_encode_withdrawal(withdrawal: &JsonWithdrawal) -> Vec<u8> {
|
||||
let mut rlp_stream = RlpStream::new();
|
||||
rlp_stream.begin_list(4);
|
||||
rlp_stream.append(&withdrawal.index);
|
||||
rlp_stream.append(&withdrawal.validator_index);
|
||||
rlp_stream.append(&withdrawal.address);
|
||||
rlp_stream.append(&withdrawal.amount);
|
||||
rlp_stream.out().into()
|
||||
let mut out: Vec<u8> = vec![];
|
||||
EncodableJsonWithdrawal::from(withdrawal).encode(&mut out);
|
||||
out
|
||||
}
|
||||
|
||||
/// RLP encode an execution block header.
|
||||
pub fn rlp_encode_block_header(header: &ExecutionBlockHeader) -> Vec<u8> {
|
||||
let mut rlp_header_stream = RlpStream::new();
|
||||
rlp_header_stream.begin_unbounded_list();
|
||||
map_execution_block_header_fields_base!(&header, |_, field| {
|
||||
rlp_header_stream.append(field);
|
||||
});
|
||||
if let Some(withdrawals_root) = &header.withdrawals_root {
|
||||
rlp_header_stream.append(withdrawals_root);
|
||||
}
|
||||
if let Some(blob_gas_used) = &header.blob_gas_used {
|
||||
rlp_header_stream.append(blob_gas_used);
|
||||
}
|
||||
if let Some(excess_blob_gas) = &header.excess_blob_gas {
|
||||
rlp_header_stream.append(excess_blob_gas);
|
||||
}
|
||||
if let Some(parent_beacon_block_root) = &header.parent_beacon_block_root {
|
||||
rlp_header_stream.append(parent_beacon_block_root);
|
||||
}
|
||||
rlp_header_stream.finalize_unbounded_list();
|
||||
rlp_header_stream.out().into()
|
||||
let mut out: Vec<u8> = vec![];
|
||||
EncodableExecutionBlockHeader::from(header).encode(&mut out);
|
||||
out
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -97,6 +77,7 @@ mod test {
|
||||
use super::*;
|
||||
use hex::FromHex;
|
||||
use std::str::FromStr;
|
||||
use types::{Address, Hash256, Hash64};
|
||||
|
||||
fn test_rlp_encoding(
|
||||
header: &ExecutionBlockHeader,
|
||||
|
||||
Reference in New Issue
Block a user