Merge remote-tracking branch 'origin/unstable' into tree-states

This commit is contained in:
Michael Sproul
2023-11-12 22:19:07 +03:00
161 changed files with 3635 additions and 2227 deletions

View File

@@ -9,6 +9,7 @@ edition = { workspace = true }
ef_tests = []
milagro = ["bls/milagro"]
fake_crypto = ["bls/fake_crypto"]
portable = ["beacon_chain/portable"]
[dependencies]
bls = { workspace = true }

View File

@@ -1,4 +1,4 @@
TESTS_TAG := v1.4.0-beta.2-hotfix
TESTS_TAG := v1.4.0-beta.3
TESTS = general minimal mainnet
TARBALLS = $(patsubst %,%-$(TESTS_TAG).tar.gz,$(TESTS))

View File

@@ -32,7 +32,7 @@ impl<E: EthSpec> Case for KZGBlobToKZGCommitment<E> {
}
fn result(&self, _case_index: usize, _fork_name: ForkName) -> Result<(), Error> {
let kzg = get_kzg::<E::Kzg>()?;
let kzg = get_kzg()?;
let commitment = parse_blob::<E>(&self.input.blob).and_then(|blob| {
blob_to_kzg_commitment::<E>(&kzg, &blob).map_err(|e| {

View File

@@ -39,7 +39,7 @@ impl<E: EthSpec> Case for KZGComputeBlobKZGProof<E> {
Ok((blob, commitment))
};
let kzg = get_kzg::<E::Kzg>()?;
let kzg = get_kzg()?;
let proof = parse_input(&self.input).and_then(|(blob, commitment)| {
compute_blob_kzg_proof::<E>(&kzg, &blob, commitment)
.map_err(|e| Error::InternalError(format!("Failed to compute kzg proof: {:?}", e)))

View File

@@ -46,7 +46,7 @@ impl<E: EthSpec> Case for KZGComputeKZGProof<E> {
Ok((blob, z))
};
let kzg = get_kzg::<E::Kzg>()?;
let kzg = get_kzg()?;
let proof = parse_input(&self.input).and_then(|(blob, z)| {
compute_kzg_proof::<E>(&kzg, &blob, z)
.map_err(|e| Error::InternalError(format!("Failed to compute kzg proof: {:?}", e)))

View File

@@ -1,15 +1,15 @@
use super::*;
use crate::case_result::compare_result;
use beacon_chain::kzg_utils::validate_blob;
use eth2_network_config::get_trusted_setup;
use kzg::{Kzg, KzgCommitment, KzgPreset, KzgProof, TrustedSetup};
use eth2_network_config::TRUSTED_SETUP_BYTES;
use kzg::{Kzg, KzgCommitment, KzgProof, TrustedSetup};
use serde::Deserialize;
use std::convert::TryInto;
use std::marker::PhantomData;
use types::Blob;
pub fn get_kzg<P: KzgPreset>() -> Result<Kzg<P>, Error> {
let trusted_setup: TrustedSetup = serde_json::from_reader(get_trusted_setup::<P>())
pub fn get_kzg() -> Result<Kzg, Error> {
let trusted_setup: TrustedSetup = serde_json::from_reader(TRUSTED_SETUP_BYTES)
.map_err(|e| Error::InternalError(format!("Failed to initialize kzg: {:?}", e)))?;
Kzg::new_from_trusted_setup(trusted_setup)
.map_err(|e| Error::InternalError(format!("Failed to initialize kzg: {:?}", e)))
@@ -89,7 +89,7 @@ impl<E: EthSpec> Case for KZGVerifyBlobKZGProof<E> {
Ok((blob, commitment, proof))
};
let kzg = get_kzg::<E::Kzg>()?;
let kzg = get_kzg()?;
let result = parse_input(&self.input).and_then(|(blob, commitment, proof)| {
validate_blob::<E>(&kzg, &blob, commitment, proof)
.map_err(|e| Error::InternalError(format!("Failed to validate blob: {:?}", e)))

View File

@@ -52,7 +52,7 @@ impl<E: EthSpec> Case for KZGVerifyBlobKZGProofBatch<E> {
Ok((commitments, blobs, proofs))
};
let kzg = get_kzg::<E::Kzg>()?;
let kzg = get_kzg()?;
let result = parse_input(&self.input).and_then(|(commitments, blobs, proofs)| {
validate_blobs::<E>(&kzg, &commitments, blobs.iter().collect(), &proofs)
.map_err(|e| Error::InternalError(format!("Failed to validate blobs: {:?}", e)))

View File

@@ -42,7 +42,7 @@ impl<E: EthSpec> Case for KZGVerifyKZGProof<E> {
Ok((commitment, z, y, proof))
};
let kzg = get_kzg::<E::Kzg>()?;
let kzg = get_kzg()?;
let result = parse_input(&self.input).and_then(|(commitment, z, y, proof)| {
verify_kzg_proof::<E>(&kzg, commitment, proof, z, y)
.map_err(|e| Error::InternalError(format!("Failed to validate proof: {:?}", e)))

View File

@@ -51,13 +51,10 @@ impl<E: EthSpec> Case for MerkleProofValidity<E> {
fn result(&self, _case_index: usize, _fork_name: ForkName) -> Result<(), Error> {
let mut state = self.state.clone();
state.update_tree_hash_cache().unwrap();
let proof = match state.compute_merkle_proof(self.merkle_proof.leaf_index) {
Ok(proof) => proof,
Err(_) => {
return Err(Error::FailedToParseTest(
"Could not retrieve merkle proof".to_string(),
))
}
let Ok(proof) = state.compute_merkle_proof(self.merkle_proof.leaf_index) else {
return Err(Error::FailedToParseTest(
"Could not retrieve merkle proof".to_string(),
));
};
let proof_len = proof.len();
let branch_len = self.merkle_proof.branch.len();

View File

@@ -22,3 +22,6 @@ reqwest = { workspace = true }
hex = { workspace = true }
fork_choice = { workspace = true }
logging = { workspace = true }
[features]
portable = ["types/portable"]

View File

@@ -1,5 +1,5 @@
test:
cargo run --release --locked
cargo run --release --locked --features "$(TEST_FEATURES)"
clean:
rm -rf execution_clients

View File

@@ -4,7 +4,8 @@ use crate::execution_engine::{
use crate::transactions::transactions;
use ethers_providers::Middleware;
use execution_layer::{
BuilderParams, ChainHealth, ExecutionLayer, PayloadAttributes, PayloadStatus,
BlockProposalContentsType, BuilderParams, ChainHealth, ExecutionLayer, PayloadAttributes,
PayloadStatus,
};
use fork_choice::ForkchoiceUpdateParameters;
use reqwest::{header::CONTENT_TYPE, Client};
@@ -14,9 +15,10 @@ use std::sync::Arc;
use std::time::{Duration, Instant, SystemTime, UNIX_EPOCH};
use task_executor::TaskExecutor;
use tokio::time::sleep;
use types::payload::BlockProductionVersion;
use types::{
Address, ChainSpec, EthSpec, ExecutionBlockHash, ExecutionPayload, ExecutionPayloadHeader,
ForkName, FullPayload, Hash256, MainnetEthSpec, PublicKeyBytes, Slot, Uint256,
ForkName, Hash256, MainnetEthSpec, PublicKeyBytes, Slot, Uint256,
};
const EXECUTION_ENGINE_START_TIMEOUT: Duration = Duration::from_secs(60);
@@ -322,21 +324,26 @@ impl<E: GenericExecutionEngine> TestRig<E> {
Some(vec![]),
None,
);
let valid_payload = self
let block_proposal_content_type = self
.ee_a
.execution_layer
.get_payload::<FullPayload<MainnetEthSpec>>(
.get_payload(
parent_hash,
&payload_attributes,
forkchoice_update_params,
builder_params,
TEST_FORK,
&self.spec,
BlockProductionVersion::FullV2,
)
.await
.unwrap()
.to_payload()
.execution_payload();
.unwrap();
let valid_payload = match block_proposal_content_type {
BlockProposalContentsType::Full(block) => block.to_payload().execution_payload(),
BlockProposalContentsType::Blinded(_) => panic!("Should always be a full payload"),
};
assert_eq!(valid_payload.transactions().len(), pending_txs.len());
/*
@@ -468,21 +475,25 @@ impl<E: GenericExecutionEngine> TestRig<E> {
Some(vec![]),
None,
);
let second_payload = self
let block_proposal_content_type = self
.ee_a
.execution_layer
.get_payload::<FullPayload<MainnetEthSpec>>(
.get_payload(
parent_hash,
&payload_attributes,
forkchoice_update_params,
builder_params,
TEST_FORK,
&self.spec,
BlockProductionVersion::FullV2,
)
.await
.unwrap()
.to_payload()
.execution_payload();
.unwrap();
let second_payload = match block_proposal_content_type {
BlockProposalContentsType::Full(block) => block.to_payload().execution_payload(),
BlockProposalContentsType::Blinded(_) => panic!("Should always be a full payload"),
};
/*
* Execution Engine A:

View File

@@ -13,3 +13,6 @@ ethereum_ssz = { workspace = true }
beacon_chain = { workspace = true }
lazy_static = { workspace = true }
tokio = { workspace = true }
[features]
portable = ["beacon_chain/portable"]

View File

@@ -2,7 +2,7 @@ produce-vectors:
cargo run --release
test:
cargo test --release
cargo test --release --features "$(TEST_FEATURES)"
clean:
rm -r vectors/