Deneb pr updates 2 (#4851)

* use workspace deps in kzg crate

* delete unused blobs dp path field

* full match on fork name in engine api get payload v3

* only accept v3 payloads on get payload v3 endpoint in mock el

* remove FIXMEs related to merge transition tests

* move static tx to test utils

* default max_per_epoch_activation_churn_limit to mainnet value

* remove unnecessary async

* remove comment

* use task executor in `blob_sidecars` endpoint
This commit is contained in:
realbigsean 2023-10-16 18:53:46 -04:00 committed by GitHub
parent ba0567d3ef
commit 283ec8cf24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 60 additions and 80 deletions

1
Cargo.lock generated
View File

@ -3829,7 +3829,6 @@ dependencies = [
"ethereum_ssz_derive", "ethereum_ssz_derive",
"hex", "hex",
"serde", "serde",
"serde_derive",
"tree_hash", "tree_hash",
] ]

View File

@ -71,7 +71,6 @@ pub struct ClientBuilder<T: BeaconChainTypes> {
gossipsub_registry: Option<Registry>, gossipsub_registry: Option<Registry>,
db_path: Option<PathBuf>, db_path: Option<PathBuf>,
freezer_db_path: Option<PathBuf>, freezer_db_path: Option<PathBuf>,
blobs_db_path: Option<PathBuf>,
http_api_config: http_api::Config, http_api_config: http_api::Config,
http_metrics_config: http_metrics::Config, http_metrics_config: http_metrics::Config,
slasher: Option<Arc<Slasher<T::EthSpec>>>, slasher: Option<Arc<Slasher<T::EthSpec>>>,
@ -106,7 +105,6 @@ where
gossipsub_registry: None, gossipsub_registry: None,
db_path: None, db_path: None,
freezer_db_path: None, freezer_db_path: None,
blobs_db_path: None,
http_api_config: <_>::default(), http_api_config: <_>::default(),
http_metrics_config: <_>::default(), http_metrics_config: <_>::default(),
slasher: None, slasher: None,
@ -927,7 +925,6 @@ where
self.db_path = Some(hot_path.into()); self.db_path = Some(hot_path.into());
self.freezer_db_path = Some(cold_path.into()); self.freezer_db_path = Some(cold_path.into());
self.blobs_db_path = blobs_path.clone();
let inner_spec = spec.clone(); let inner_spec = spec.clone();
let deposit_contract_deploy_block = context let deposit_contract_deploy_block = context

View File

@ -897,10 +897,9 @@ impl HttpJsonRpc {
.await?; .await?;
Ok(JsonGetPayloadResponse::V3(response).into()) Ok(JsonGetPayloadResponse::V3(response).into())
} }
_ => Err(Error::UnsupportedForkVariant(format!( ForkName::Base | ForkName::Altair | ForkName::Merge | ForkName::Capella => Err(
"called get_payload_v3 with {}", Error::UnsupportedForkVariant(format!("called get_payload_v3 with {}", fork_name)),
fork_name ),
))),
} }
} }

View File

@ -48,7 +48,7 @@ use types::{
AbstractExecPayload, BeaconStateError, BlindedPayload, BlockType, ChainSpec, Epoch, AbstractExecPayload, BeaconStateError, BlindedPayload, BlockType, ChainSpec, Epoch,
ExecPayload, ExecutionPayloadCapella, ExecutionPayloadDeneb, ExecutionPayloadMerge, ExecPayload, ExecutionPayloadCapella, ExecutionPayloadDeneb, ExecutionPayloadMerge,
}; };
use types::{ProposerPreparationData, PublicKeyBytes, Signature, Slot, Transaction}; use types::{ProposerPreparationData, PublicKeyBytes, Signature, Slot};
mod block_hash; mod block_hash;
mod engine_api; mod engine_api;
@ -2163,31 +2163,6 @@ fn timestamp_now() -> u64 {
.as_secs() .as_secs()
} }
fn static_valid_tx<T: EthSpec>() -> Result<Transaction<T::MaxBytesPerTransaction>, String> {
// This is a real transaction hex encoded, but we don't care about the contents of the transaction.
let transaction: EthersTransaction = serde_json::from_str(
r#"{
"blockHash":"0x1d59ff54b1eb26b013ce3cb5fc9dab3705b415a67127a003c3e61eb445bb8df2",
"blockNumber":"0x5daf3b",
"from":"0xa7d9ddbe1f17865597fbd27ec712455208b6b76d",
"gas":"0xc350",
"gasPrice":"0x4a817c800",
"hash":"0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b",
"input":"0x68656c6c6f21",
"nonce":"0x15",
"to":"0xf02c1c8e6114b1dbe8937a39260b5b0a374432bb",
"transactionIndex":"0x41",
"value":"0xf3dbb76162000",
"v":"0x25",
"r":"0x1b5e176d927f8e9ab405058b2d2457392da3e20f328b16ddabcebc33eaac5fea",
"s":"0x4ba69724e8f69de52f0125ad8b3c5c2cef33019bac3249e2c0a2192766d1721c"
}"#,
)
.unwrap();
VariableList::new(transaction.rlp().to_vec())
.map_err(|e| format!("Failed to convert transaction to SSZ: {:?}", e))
}
fn noop<T: EthSpec>( fn noop<T: EthSpec>(
_: &ExecutionLayer<T>, _: &ExecutionLayer<T>,
_: PayloadContentsRefTuple<T>, _: PayloadContentsRefTuple<T>,

View File

@ -1,4 +1,5 @@
use crate::engines::ForkchoiceState; use crate::engines::ForkchoiceState;
use crate::EthersTransaction;
use crate::{ use crate::{
engine_api::{ engine_api::{
json_structures::{ json_structures::{
@ -6,13 +7,14 @@ use crate::{
}, },
ExecutionBlock, PayloadAttributes, PayloadId, PayloadStatusV1, PayloadStatusV1Status, ExecutionBlock, PayloadAttributes, PayloadId, PayloadStatusV1, PayloadStatusV1Status,
}, },
static_valid_tx, ExecutionBlockWithTransactions, ExecutionBlockWithTransactions,
}; };
use eth2::types::BlobsBundle; use eth2::types::BlobsBundle;
use kzg::Kzg; use kzg::Kzg;
use parking_lot::Mutex; use parking_lot::Mutex;
use rand::{rngs::StdRng, Rng, SeedableRng}; use rand::{rngs::StdRng, Rng, SeedableRng};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use ssz_types::VariableList;
use std::collections::HashMap; use std::collections::HashMap;
use std::sync::Arc; use std::sync::Arc;
use tree_hash::TreeHash; use tree_hash::TreeHash;
@ -20,7 +22,7 @@ use tree_hash_derive::TreeHash;
use types::{ use types::{
BlobSidecar, ChainSpec, EthSpec, ExecutionBlockHash, ExecutionPayload, ExecutionPayloadCapella, BlobSidecar, ChainSpec, EthSpec, ExecutionBlockHash, ExecutionPayload, ExecutionPayloadCapella,
ExecutionPayloadDeneb, ExecutionPayloadHeader, ExecutionPayloadMerge, ForkName, Hash256, ExecutionPayloadDeneb, ExecutionPayloadHeader, ExecutionPayloadMerge, ForkName, Hash256,
Transactions, Uint256, Transaction, Transactions, Uint256,
}; };
use super::DEFAULT_TERMINAL_BLOCK; use super::DEFAULT_TERMINAL_BLOCK;
@ -681,6 +683,31 @@ pub fn generate_random_blobs<T: EthSpec, R: Rng>(
Ok((bundle, transactions.into())) Ok((bundle, transactions.into()))
} }
fn static_valid_tx<T: EthSpec>() -> Result<Transaction<T::MaxBytesPerTransaction>, String> {
// This is a real transaction hex encoded, but we don't care about the contents of the transaction.
let transaction: EthersTransaction = serde_json::from_str(
r#"{
"blockHash":"0x1d59ff54b1eb26b013ce3cb5fc9dab3705b415a67127a003c3e61eb445bb8df2",
"blockNumber":"0x5daf3b",
"from":"0xa7d9ddbe1f17865597fbd27ec712455208b6b76d",
"gas":"0xc350",
"gasPrice":"0x4a817c800",
"hash":"0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b",
"input":"0x68656c6c6f21",
"nonce":"0x15",
"to":"0xf02c1c8e6114b1dbe8937a39260b5b0a374432bb",
"transactionIndex":"0x41",
"value":"0xf3dbb76162000",
"v":"0x25",
"r":"0x1b5e176d927f8e9ab405058b2d2457392da3e20f328b16ddabcebc33eaac5fea",
"s":"0x4ba69724e8f69de52f0125ad8b3c5c2cef33019bac3249e2c0a2192766d1721c"
}"#,
)
.unwrap();
VariableList::new(transaction.rlp().to_vec())
.map_err(|e| format!("Failed to convert transaction to SSZ: {:?}", e))
}
fn payload_id_from_u64(n: u64) -> PayloadId { fn payload_id_from_u64(n: u64) -> PayloadId {
n.to_le_bytes() n.to_le_bytes()
} }

View File

@ -282,20 +282,6 @@ pub async fn handle_rpc<T: EthSpec>(
_ => unreachable!(), _ => unreachable!(),
}), }),
ENGINE_GET_PAYLOAD_V3 => Ok(match JsonExecutionPayload::from(response) { ENGINE_GET_PAYLOAD_V3 => Ok(match JsonExecutionPayload::from(response) {
JsonExecutionPayload::V1(execution_payload) => {
serde_json::to_value(JsonGetPayloadResponseV1 {
execution_payload,
block_value: DEFAULT_MOCK_EL_PAYLOAD_VALUE_WEI.into(),
})
.unwrap()
}
JsonExecutionPayload::V2(execution_payload) => {
serde_json::to_value(JsonGetPayloadResponseV2 {
execution_payload,
block_value: DEFAULT_MOCK_EL_PAYLOAD_VALUE_WEI.into(),
})
.unwrap()
}
JsonExecutionPayload::V3(execution_payload) => { JsonExecutionPayload::V3(execution_payload) => {
serde_json::to_value(JsonGetPayloadResponseV3 { serde_json::to_value(JsonGetPayloadResponseV3 {
execution_payload, execution_payload,
@ -310,6 +296,7 @@ pub async fn handle_rpc<T: EthSpec>(
}) })
.unwrap() .unwrap()
} }
_ => unreachable!(),
}), }),
_ => unreachable!(), _ => unreachable!(),
} }

View File

@ -103,14 +103,8 @@ impl<T: EthSpec> MockExecutionLayer<T> {
justified_hash: None, justified_hash: None,
finalized_hash: None, finalized_hash: None,
}; };
let payload_attributes = PayloadAttributes::new( let payload_attributes =
timestamp, PayloadAttributes::new(timestamp, prev_randao, Address::repeat_byte(42), None, None);
prev_randao,
Address::repeat_byte(42),
// FIXME: think about how to handle different forks here..
None,
None,
);
// Insert a proposer to ensure the fork choice updated command works. // Insert a proposer to ensure the fork choice updated command works.
let slot = Slot::new(0); let slot = Slot::new(0);
@ -146,7 +140,6 @@ impl<T: EthSpec> MockExecutionLayer<T> {
&payload_attributes, &payload_attributes,
forkchoice_update_params, forkchoice_update_params,
builder_params, builder_params,
// FIXME: do we need to consider other forks somehow?
ForkName::Merge, ForkName::Merge,
&self.spec, &self.spec,
) )
@ -181,7 +174,6 @@ impl<T: EthSpec> MockExecutionLayer<T> {
&payload_attributes, &payload_attributes,
forkchoice_update_params, forkchoice_update_params,
builder_params, builder_params,
// FIXME: do we need to consider other forks somehow? What about withdrawals?
ForkName::Merge, ForkName::Merge,
&self.spec, &self.spec,
) )

View File

@ -253,7 +253,7 @@ impl BlockId {
} }
/// Return the `BlobSidecarList` identified by `self`. /// Return the `BlobSidecarList` identified by `self`.
pub async fn blob_sidecar_list<T: BeaconChainTypes>( pub fn blob_sidecar_list<T: BeaconChainTypes>(
&self, &self,
chain: &BeaconChain<T>, chain: &BeaconChain<T>,
) -> Result<BlobSidecarList<T::EthSpec>, warp::Rejection> { ) -> Result<BlobSidecarList<T::EthSpec>, warp::Rejection> {
@ -263,12 +263,12 @@ impl BlockId {
.map_err(warp_utils::reject::beacon_chain_error) .map_err(warp_utils::reject::beacon_chain_error)
} }
pub async fn blob_sidecar_list_filtered<T: BeaconChainTypes>( pub fn blob_sidecar_list_filtered<T: BeaconChainTypes>(
&self, &self,
indices: BlobIndicesQuery, indices: BlobIndicesQuery,
chain: &BeaconChain<T>, chain: &BeaconChain<T>,
) -> Result<BlobSidecarList<T::EthSpec>, warp::Rejection> { ) -> Result<BlobSidecarList<T::EthSpec>, warp::Rejection> {
let blob_sidecar_list = self.blob_sidecar_list(chain).await?; let blob_sidecar_list = self.blob_sidecar_list(chain)?;
let blob_sidecar_list_filtered = match indices.indices { let blob_sidecar_list_filtered = match indices.indices {
Some(vec) => { Some(vec) => {
let list = blob_sidecar_list let list = blob_sidecar_list

View File

@ -1729,16 +1729,18 @@ pub fn serve<T: BeaconChainTypes>(
.and(block_id_or_err) .and(block_id_or_err)
.and(warp::query::<api_types::BlobIndicesQuery>()) .and(warp::query::<api_types::BlobIndicesQuery>())
.and(warp::path::end()) .and(warp::path::end())
.and(task_spawner_filter.clone())
.and(chain_filter.clone()) .and(chain_filter.clone())
.and(warp::header::optional::<api_types::Accept>("accept")) .and(warp::header::optional::<api_types::Accept>("accept"))
.and_then( .then(
|block_id: BlockId, |block_id: BlockId,
indices: api_types::BlobIndicesQuery, indices: api_types::BlobIndicesQuery,
task_spawner: TaskSpawner<T::EthSpec>,
chain: Arc<BeaconChain<T>>, chain: Arc<BeaconChain<T>>,
accept_header: Option<api_types::Accept>| { accept_header: Option<api_types::Accept>| {
async move { task_spawner.blocking_response_task(Priority::P1, move || {
let blob_sidecar_list_filtered = let blob_sidecar_list_filtered =
block_id.blob_sidecar_list_filtered(indices, &chain).await?; block_id.blob_sidecar_list_filtered(indices, &chain)?;
match accept_header { match accept_header {
Some(api_types::Accept::Ssz) => Response::builder() Some(api_types::Accept::Ssz) => Response::builder()
.status(200) .status(200)
@ -1755,7 +1757,7 @@ pub fn serve<T: BeaconChainTypes>(
)) ))
.into_response()), .into_response()),
} }
} })
}, },
); );

View File

@ -75,8 +75,7 @@ pub async fn publish_block<T: BeaconChainTypes, B: IntoGossipVerifiedBlockConten
.unwrap_or_else(|| Duration::from_secs(0)); .unwrap_or_else(|| Duration::from_secs(0));
info!(log, "Signed block published to network via HTTP API"; "slot" => block.slot(), "publish_delay" => ?publish_delay); info!(log, "Signed block published to network via HTTP API"; "slot" => block.slot(), "publish_delay" => ?publish_delay);
// Send the block, regardless of whether or not it is valid. The API
// specification is very clear that this is the desired behaviour.
match block.as_ref() { match block.as_ref() {
SignedBeaconBlock::Base(_) SignedBeaconBlock::Base(_)
| SignedBeaconBlock::Altair(_) | SignedBeaconBlock::Altair(_)

View File

@ -1019,7 +1019,7 @@ pub struct Config {
ejection_balance: u64, ejection_balance: u64,
#[serde(with = "serde_utils::quoted_u64")] #[serde(with = "serde_utils::quoted_u64")]
min_per_epoch_churn_limit: u64, min_per_epoch_churn_limit: u64,
#[serde(default)] #[serde(default = "default_max_per_epoch_activation_churn_limit")]
#[serde(with = "serde_utils::quoted_u64")] #[serde(with = "serde_utils::quoted_u64")]
max_per_epoch_activation_churn_limit: u64, max_per_epoch_activation_churn_limit: u64,
#[serde(with = "serde_utils::quoted_u64")] #[serde(with = "serde_utils::quoted_u64")]
@ -1106,6 +1106,10 @@ fn default_subnets_per_node() -> u8 {
2u8 2u8
} }
const fn default_max_per_epoch_activation_churn_limit() -> u64 {
8
}
const fn default_gossip_max_size() -> u64 { const fn default_gossip_max_size() -> u64 {
10485760 10485760
} }

View File

@ -7,18 +7,17 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
ethereum_ssz = "0.5.0" arbitrary = { workspace = true }
ethereum_ssz_derive = "0.5.3" ethereum_ssz = { workspace = true }
tree_hash = "0.5.2" ethereum_ssz_derive = { workspace = true }
derivative = "2.1.1" tree_hash = { workspace = true }
serde = "1.0.116" derivative = { workspace = true }
serde_derive = "1.0.116" serde = { workspace = true }
ethereum_serde_utils = "0.5.0" ethereum_serde_utils = { workspace = true }
hex = "0.4.2" hex = { workspace = true }
ethereum_hashing = "1.0.0-beta.2" ethereum_hashing = { workspace = true }
c-kzg = { git = "https://github.com/ethereum/c-kzg-4844", rev = "f5f6f863d475847876a2bd5ee252058d37c3a15d" , features = ["mainnet-spec", "serde"]} c-kzg = { git = "https://github.com/ethereum/c-kzg-4844", rev = "f5f6f863d475847876a2bd5ee252058d37c3a15d" , features = ["mainnet-spec", "serde"]}
c_kzg_min = { package = "c-kzg", git = "https://github.com/ethereum//c-kzg-4844", rev = "f5f6f863d475847876a2bd5ee252058d37c3a15d", features = ["minimal-spec", "serde"], optional = true } c_kzg_min = { package = "c-kzg", git = "https://github.com/ethereum//c-kzg-4844", rev = "f5f6f863d475847876a2bd5ee252058d37c3a15d", features = ["minimal-spec", "serde"], optional = true }
arbitrary = { version = "1.0", features = ["derive"] }
[features] [features]
# TODO(deneb): enabled by default for convenience, would need more cfg magic to disable # TODO(deneb): enabled by default for convenience, would need more cfg magic to disable