mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-23 06:44:35 +00:00
introduce a shim to convert between the two u256 types
This commit is contained in:
41
Cargo.lock
generated
41
Cargo.lock
generated
@@ -183,7 +183,7 @@ source = "git+https://github.com/alloy-rs/alloy.git?rev=974d488bab5e21e9f17452a3
|
||||
dependencies = [
|
||||
"alloy-eips",
|
||||
"alloy-network",
|
||||
"alloy-primitives",
|
||||
"alloy-primitives 0.6.4",
|
||||
"alloy-rlp",
|
||||
]
|
||||
|
||||
@@ -192,7 +192,7 @@ name = "alloy-eips"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/alloy-rs/alloy.git?rev=974d488bab5e21e9f17452a39a4bfa56677367b2#974d488bab5e21e9f17452a39a4bfa56677367b2"
|
||||
dependencies = [
|
||||
"alloy-primitives",
|
||||
"alloy-primitives 0.6.4",
|
||||
"alloy-rlp",
|
||||
"serde",
|
||||
"thiserror",
|
||||
@@ -203,7 +203,7 @@ name = "alloy-json-rpc"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/alloy-rs/alloy.git?rev=974d488bab5e21e9f17452a39a4bfa56677367b2#974d488bab5e21e9f17452a39a4bfa56677367b2"
|
||||
dependencies = [
|
||||
"alloy-primitives",
|
||||
"alloy-primitives 0.6.4",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"thiserror",
|
||||
@@ -216,7 +216,7 @@ source = "git+https://github.com/alloy-rs/alloy.git?rev=974d488bab5e21e9f17452a3
|
||||
dependencies = [
|
||||
"alloy-eips",
|
||||
"alloy-json-rpc",
|
||||
"alloy-primitives",
|
||||
"alloy-primitives 0.6.4",
|
||||
"alloy-rlp",
|
||||
"serde",
|
||||
]
|
||||
@@ -243,6 +243,28 @@ dependencies = [
|
||||
"tiny-keccak",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "alloy-primitives"
|
||||
version = "0.7.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ccb3ead547f4532bc8af961649942f0b9c16ee9226e26caa3f38420651cc0bf4"
|
||||
dependencies = [
|
||||
"alloy-rlp",
|
||||
"bytes",
|
||||
"cfg-if",
|
||||
"const-hex",
|
||||
"derive_more",
|
||||
"hex-literal",
|
||||
"itoa",
|
||||
"k256 0.13.3",
|
||||
"keccak-asm",
|
||||
"proptest",
|
||||
"rand",
|
||||
"ruint",
|
||||
"serde",
|
||||
"tiny-keccak",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "alloy-rlp"
|
||||
version = "0.3.5"
|
||||
@@ -2864,7 +2886,7 @@ name = "execution_layer"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"alloy-consensus",
|
||||
"alloy-primitives",
|
||||
"alloy-primitives 0.6.4",
|
||||
"alloy-rlp",
|
||||
"arc-swap",
|
||||
"builder_client",
|
||||
@@ -6944,9 +6966,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ruint"
|
||||
version = "1.12.1"
|
||||
version = "1.12.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8f308135fef9fc398342da5472ce7c484529df23743fb7c734e0f3d472971e62"
|
||||
checksum = "2c3cc4c2511671f327125da14133d0c5c5d137f006a1017a16f557bc85b16286"
|
||||
dependencies = [
|
||||
"alloy-rlp",
|
||||
"ark-ff 0.3.0",
|
||||
@@ -6968,9 +6990,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ruint-macro"
|
||||
version = "1.2.0"
|
||||
version = "1.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f86854cf50259291520509879a5c294c3c9a4c334e9ff65071c51e42ef1e2343"
|
||||
checksum = "48fd7bd8a6377e15ad9d42a8ec25371b94ddc67abe7c8b9127bec79bebaaae18"
|
||||
|
||||
[[package]]
|
||||
name = "rusqlite"
|
||||
@@ -8783,6 +8805,7 @@ checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825"
|
||||
name = "types"
|
||||
version = "0.2.1"
|
||||
dependencies = [
|
||||
"alloy-primitives 0.7.7",
|
||||
"alloy-rlp",
|
||||
"arbitrary",
|
||||
"beacon_chain",
|
||||
|
||||
@@ -9,6 +9,7 @@ name = "benches"
|
||||
harness = false
|
||||
|
||||
[dependencies]
|
||||
alloy-primitives = "0.7.7"
|
||||
merkle_proof = { workspace = true }
|
||||
bls = { workspace = true, features = ["arbitrary"] }
|
||||
kzg = { workspace = true }
|
||||
|
||||
@@ -101,15 +101,15 @@ pub struct EncodableExecutionBlockHeader<'a> {
|
||||
pub transactions_root: &'a [u8],
|
||||
pub receipts_root: &'a [u8],
|
||||
pub logs_bloom: &'a [u8],
|
||||
pub difficulty: u64,
|
||||
pub number: u64,
|
||||
pub gas_limit: u64,
|
||||
pub gas_used: u64,
|
||||
pub difficulty: alloy_primitives::U256,
|
||||
pub number: alloy_primitives::U256,
|
||||
pub gas_limit: alloy_primitives::U256,
|
||||
pub gas_used: alloy_primitives::U256,
|
||||
pub timestamp: u64,
|
||||
pub extra_data: &'a [u8],
|
||||
pub mix_hash: &'a [u8],
|
||||
pub nonce: &'a [u8],
|
||||
pub base_fee_per_gas: u64,
|
||||
pub base_fee_per_gas: alloy_primitives::U256,
|
||||
pub withdrawals_root: Option<&'a [u8]>,
|
||||
pub blob_gas_used: Option<u64>,
|
||||
pub excess_blob_gas: Option<u64>,
|
||||
@@ -126,15 +126,15 @@ impl<'a> From<&'a ExecutionBlockHeader> for EncodableExecutionBlockHeader<'a> {
|
||||
transactions_root: header.transactions_root.as_bytes(),
|
||||
receipts_root: header.receipts_root.as_bytes(),
|
||||
logs_bloom: header.logs_bloom.as_slice(),
|
||||
difficulty: header.difficulty.as_u64(), // TODO this might panic
|
||||
number: header.number.as_u64(), // TODO this might panic
|
||||
gas_limit: header.gas_limit.as_u64(), // TODO this might panic
|
||||
gas_used: header.gas_used.as_u64(), // TODO this might panic
|
||||
difficulty: U256Shim(header.difficulty).into(),
|
||||
number: U256Shim(header.number).into(),
|
||||
gas_limit: U256Shim(header.gas_limit).into(),
|
||||
gas_used: U256Shim(header.gas_used).into(),
|
||||
timestamp: header.timestamp,
|
||||
extra_data: header.extra_data.as_slice(),
|
||||
mix_hash: header.mix_hash.as_bytes(),
|
||||
nonce: header.nonce.as_bytes(),
|
||||
base_fee_per_gas: header.base_fee_per_gas.as_u64(), // TODO this might panic
|
||||
base_fee_per_gas: U256Shim(header.base_fee_per_gas).into(),
|
||||
withdrawals_root: None,
|
||||
blob_gas_used: header.blob_gas_used,
|
||||
excess_blob_gas: header.excess_blob_gas,
|
||||
@@ -149,3 +149,16 @@ impl<'a> From<&'a ExecutionBlockHeader> for EncodableExecutionBlockHeader<'a> {
|
||||
encodable
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// TODO(alloy) this shim can be removed once we fully migrate
|
||||
// from ethereum types to alloy primitives
|
||||
struct U256Shim(Uint256);
|
||||
|
||||
impl From<U256Shim> for alloy_primitives::U256 {
|
||||
fn from(value: U256Shim) -> Self {
|
||||
let mut buffer: [u8; 32] = [0; 32];
|
||||
value.0.to_little_endian(&mut buffer);
|
||||
Self::from_le_slice(&buffer)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user