mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-14 10:22:38 +00:00
Fix some compilation errors in tests
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
use crate::test_utils::TestRandom;
|
||||
use crate::{Blob, ChainSpec, Domain, EthSpec, Fork, Hash256, SignedBlobSidecar, SignedRoot, Slot};
|
||||
use bls::SecretKey;
|
||||
use crate::{Blob, EthSpec, Hash256, SignedRoot, Slot};
|
||||
use derivative::Derivative;
|
||||
use kzg::{Kzg, KzgCommitment, KzgPreset, KzgProof};
|
||||
use rand::Rng;
|
||||
@@ -10,7 +9,6 @@ use ssz_derive::{Decode, Encode};
|
||||
use ssz_types::{FixedVector, VariableList};
|
||||
use std::fmt::Debug;
|
||||
use std::hash::Hash;
|
||||
use std::marker::PhantomData;
|
||||
use std::sync::Arc;
|
||||
use test_random_derive::TestRandom;
|
||||
use tree_hash::TreeHash;
|
||||
@@ -171,31 +169,6 @@ impl<T: EthSpec> BlobSidecar<T> {
|
||||
// Fixed part
|
||||
Self::empty().as_ssz_bytes().len()
|
||||
}
|
||||
|
||||
// this is mostly not used except for in testing
|
||||
pub fn sign(
|
||||
self: Arc<Self>,
|
||||
secret_key: &SecretKey,
|
||||
fork: &Fork,
|
||||
genesis_validators_root: Hash256,
|
||||
spec: &ChainSpec,
|
||||
) -> SignedBlobSidecar<T> {
|
||||
let signing_epoch = self.slot.epoch(T::slots_per_epoch());
|
||||
let domain = spec.get_domain(
|
||||
signing_epoch,
|
||||
Domain::BlobSidecar,
|
||||
fork,
|
||||
genesis_validators_root,
|
||||
);
|
||||
let message = self.signing_root(domain);
|
||||
let signature = secret_key.sign(message);
|
||||
|
||||
SignedBlobSidecar {
|
||||
message: self,
|
||||
signature,
|
||||
_phantom: PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(
|
||||
|
||||
@@ -2,14 +2,17 @@ use crate::beacon_block_body::KzgCommitments;
|
||||
use crate::test_utils::TestRandom;
|
||||
use crate::{
|
||||
AbstractExecPayload, BeaconBlock, BlindedBlobSidecar, BlindedBlobSidecarList, BlobRootsList,
|
||||
BlobSidecar, BlobSidecarList, BlobsList, EthSpec, SidecarList, SignedRoot, Slot,
|
||||
BlobSidecar, BlobSidecarList, BlobsList, ChainSpec, Domain, EthSpec, Fork, Hash256,
|
||||
SidecarList, SignedRoot, SignedSidecar, Slot,
|
||||
};
|
||||
use bls::SecretKey;
|
||||
use kzg::KzgProof;
|
||||
use serde::de::DeserializeOwned;
|
||||
use ssz::{Decode, Encode};
|
||||
use ssz_types::VariableList;
|
||||
use std::fmt::Debug;
|
||||
use std::hash::Hash;
|
||||
use std::marker::PhantomData;
|
||||
use std::sync::Arc;
|
||||
use tree_hash::TreeHash;
|
||||
|
||||
@@ -29,13 +32,40 @@ pub trait Sidecar<E: EthSpec>:
|
||||
+ for<'a> arbitrary::Arbitrary<'a>
|
||||
{
|
||||
type BlobItems: BlobItems<E>;
|
||||
|
||||
fn slot(&self) -> Slot;
|
||||
|
||||
fn build_sidecar<Payload: AbstractExecPayload<E>>(
|
||||
blob_items: Self::BlobItems,
|
||||
block: &BeaconBlock<E, Payload>,
|
||||
expected_kzg_commitments: &KzgCommitments<E>,
|
||||
kzg_proofs: Vec<KzgProof>,
|
||||
) -> Result<SidecarList<E, Self>, String>;
|
||||
|
||||
// this is mostly not used except for in testing
|
||||
fn sign(
|
||||
self: Arc<Self>,
|
||||
secret_key: &SecretKey,
|
||||
fork: &Fork,
|
||||
genesis_validators_root: Hash256,
|
||||
spec: &ChainSpec,
|
||||
) -> SignedSidecar<E, Self> {
|
||||
let signing_epoch = self.slot().epoch(E::slots_per_epoch());
|
||||
let domain = spec.get_domain(
|
||||
signing_epoch,
|
||||
Domain::BlobSidecar,
|
||||
fork,
|
||||
genesis_validators_root,
|
||||
);
|
||||
let message = self.signing_root(domain);
|
||||
let signature = secret_key.sign(message);
|
||||
|
||||
SignedSidecar {
|
||||
message: self,
|
||||
signature,
|
||||
_phantom: PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub trait BlobItems<T: EthSpec>: Sync + Send + Sized {
|
||||
|
||||
Reference in New Issue
Block a user