Merge branch 'unstable' of https://github.com/sigp/lighthouse into electra_attestation_changes

This commit is contained in:
realbigsean
2024-06-20 09:36:56 -04:00
31 changed files with 310 additions and 329 deletions

View File

@@ -145,24 +145,24 @@ impl TryInto<ProtoNode> for ProtoNodeV16 {
}
}
impl Into<ProtoNodeV16> for ProtoNode {
fn into(self) -> ProtoNodeV16 {
impl From<ProtoNode> for ProtoNodeV16 {
fn from(from: ProtoNode) -> ProtoNodeV16 {
ProtoNodeV16 {
slot: self.slot,
state_root: self.state_root,
target_root: self.target_root,
current_epoch_shuffling_id: self.current_epoch_shuffling_id,
next_epoch_shuffling_id: self.next_epoch_shuffling_id,
root: self.root,
parent: self.parent,
justified_checkpoint: Some(self.justified_checkpoint),
finalized_checkpoint: Some(self.finalized_checkpoint),
weight: self.weight,
best_child: self.best_child,
best_descendant: self.best_descendant,
execution_status: self.execution_status,
unrealized_justified_checkpoint: self.unrealized_justified_checkpoint,
unrealized_finalized_checkpoint: self.unrealized_finalized_checkpoint,
slot: from.slot,
state_root: from.state_root,
target_root: from.target_root,
current_epoch_shuffling_id: from.current_epoch_shuffling_id,
next_epoch_shuffling_id: from.next_epoch_shuffling_id,
root: from.root,
parent: from.parent,
justified_checkpoint: Some(from.justified_checkpoint),
finalized_checkpoint: Some(from.finalized_checkpoint),
weight: from.weight,
best_child: from.best_child,
best_descendant: from.best_descendant,
execution_status: from.execution_status,
unrealized_justified_checkpoint: from.unrealized_justified_checkpoint,
unrealized_finalized_checkpoint: from.unrealized_finalized_checkpoint,
}
}
}

View File

@@ -55,19 +55,19 @@ impl TryInto<SszContainer> for SszContainerV16 {
}
}
impl Into<SszContainerV16> for SszContainer {
fn into(self) -> SszContainerV16 {
let nodes = self.nodes.into_iter().map(Into::into).collect();
impl From<SszContainer> for SszContainerV16 {
fn from(from: SszContainer) -> SszContainerV16 {
let nodes = from.nodes.into_iter().map(Into::into).collect();
SszContainerV16 {
votes: self.votes,
balances: self.balances,
prune_threshold: self.prune_threshold,
justified_checkpoint: self.justified_checkpoint,
finalized_checkpoint: self.finalized_checkpoint,
votes: from.votes,
balances: from.balances,
prune_threshold: from.prune_threshold,
justified_checkpoint: from.justified_checkpoint,
finalized_checkpoint: from.finalized_checkpoint,
nodes,
indices: self.indices,
previous_proposer_boost: self.previous_proposer_boost,
indices: from.indices,
previous_proposer_boost: from.previous_proposer_boost,
}
}
}

View File

@@ -6,10 +6,7 @@ use crate::{
use crate::{KzgProofs, SignedBeaconBlock};
use bls::Signature;
use derivative::Derivative;
use kzg::{
Blob as KzgBlob, Kzg, KzgCommitment, KzgProof, BYTES_PER_BLOB, BYTES_PER_FIELD_ELEMENT,
FIELD_ELEMENTS_PER_BLOB,
};
use kzg::{Blob as KzgBlob, Kzg, KzgCommitment, KzgProof, BYTES_PER_BLOB, BYTES_PER_FIELD_ELEMENT};
use merkle_proof::{merkle_root_from_branch, verify_merkle_proof, MerkleTreeError};
use rand::Rng;
use safe_arith::ArithError;
@@ -221,13 +218,7 @@ impl<E: EthSpec> BlobSidecar<E> {
rng.fill_bytes(&mut blob_bytes);
// Ensure that the blob is canonical by ensuring that
// each field element contained in the blob is < BLS_MODULUS
for i in 0..FIELD_ELEMENTS_PER_BLOB {
let Some(byte) = blob_bytes.get_mut(
i.checked_mul(BYTES_PER_FIELD_ELEMENT)
.ok_or("overflow".to_string())?,
) else {
return Err(format!("blob byte index out of bounds: {:?}", i));
};
for byte in blob_bytes.iter_mut().step_by(BYTES_PER_FIELD_ELEMENT) {
*byte = 0;
}

View File

@@ -37,9 +37,9 @@ impl From<[u8; GRAFFITI_BYTES_LEN]> for Graffiti {
}
}
impl Into<[u8; GRAFFITI_BYTES_LEN]> for Graffiti {
fn into(self) -> [u8; GRAFFITI_BYTES_LEN] {
self.0
impl From<Graffiti> for [u8; GRAFFITI_BYTES_LEN] {
fn from(from: Graffiti) -> [u8; GRAFFITI_BYTES_LEN] {
from.0
}
}
@@ -77,9 +77,9 @@ impl<'de> Deserialize<'de> for GraffitiString {
}
}
impl Into<Graffiti> for GraffitiString {
fn into(self) -> Graffiti {
let graffiti_bytes = self.0.as_bytes();
impl From<GraffitiString> for Graffiti {
fn from(from: GraffitiString) -> Graffiti {
let graffiti_bytes = from.0.as_bytes();
let mut graffiti = [0; GRAFFITI_BYTES_LEN];
let graffiti_len = std::cmp::min(graffiti_bytes.len(), GRAFFITI_BYTES_LEN);

View File

@@ -77,9 +77,9 @@ impl SelectionProof {
}
}
impl Into<Signature> for SelectionProof {
fn into(self) -> Signature {
self.0
impl From<SelectionProof> for Signature {
fn from(from: SelectionProof) -> Signature {
from.0
}
}

View File

@@ -6,9 +6,9 @@ macro_rules! impl_from_into_u64 {
}
}
impl Into<u64> for $main {
fn into(self) -> u64 {
self.0
impl From<$main> for u64 {
fn from(from: $main) -> u64 {
from.0
}
}
@@ -28,9 +28,9 @@ macro_rules! impl_from_into_usize {
}
}
impl Into<usize> for $main {
fn into(self) -> usize {
self.0 as usize
impl From<$main> for usize {
fn from(from: $main) -> usize {
from.0 as usize
}
}

View File

@@ -152,15 +152,15 @@ impl From<u64> for SubnetId {
}
}
impl Into<u64> for SubnetId {
fn into(self) -> u64 {
self.0
impl From<SubnetId> for u64 {
fn from(from: SubnetId) -> u64 {
from.0
}
}
impl Into<u64> for &SubnetId {
fn into(self) -> u64 {
self.0
impl From<&SubnetId> for u64 {
fn from(from: &SubnetId) -> u64 {
from.0
}
}

View File

@@ -90,9 +90,9 @@ impl SyncSelectionProof {
}
}
impl Into<Signature> for SyncSelectionProof {
fn into(self) -> Signature {
self.0
impl From<SyncSelectionProof> for Signature {
fn from(from: SyncSelectionProof) -> Signature {
from.0
}
}

View File

@@ -78,15 +78,15 @@ impl From<u64> for SyncSubnetId {
}
}
impl Into<u64> for SyncSubnetId {
fn into(self) -> u64 {
self.0
impl From<SyncSubnetId> for u64 {
fn from(from: SyncSubnetId) -> u64 {
from.0
}
}
impl Into<u64> for &SyncSubnetId {
fn into(self) -> u64 {
self.0
impl From<&SyncSubnetId> for u64 {
fn from(from: &SyncSubnetId) -> u64 {
from.0
}
}