Skip to content

Commit

Permalink
Deneb pr updates 2 (#4851)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
realbigsean authored Oct 16, 2023
1 parent ba0567d commit 283ec8c
Show file tree
Hide file tree
Showing 12 changed files with 60 additions and 80 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions beacon_node/client/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ pub struct ClientBuilder<T: BeaconChainTypes> {
gossipsub_registry: Option<Registry>,
db_path: Option<PathBuf>,
freezer_db_path: Option<PathBuf>,
blobs_db_path: Option<PathBuf>,
http_api_config: http_api::Config,
http_metrics_config: http_metrics::Config,
slasher: Option<Arc<Slasher<T::EthSpec>>>,
Expand Down Expand Up @@ -106,7 +105,6 @@ where
gossipsub_registry: None,
db_path: None,
freezer_db_path: None,
blobs_db_path: None,
http_api_config: <_>::default(),
http_metrics_config: <_>::default(),
slasher: None,
Expand Down Expand Up @@ -927,7 +925,6 @@ where

self.db_path = Some(hot_path.into());
self.freezer_db_path = Some(cold_path.into());
self.blobs_db_path = blobs_path.clone();

let inner_spec = spec.clone();
let deposit_contract_deploy_block = context
Expand Down
7 changes: 3 additions & 4 deletions beacon_node/execution_layer/src/engine_api/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -897,10 +897,9 @@ impl HttpJsonRpc {
.await?;
Ok(JsonGetPayloadResponse::V3(response).into())
}
_ => Err(Error::UnsupportedForkVariant(format!(
"called get_payload_v3 with {}",
fork_name
))),
ForkName::Base | ForkName::Altair | ForkName::Merge | ForkName::Capella => Err(
Error::UnsupportedForkVariant(format!("called get_payload_v3 with {}", fork_name)),
),
}
}

Expand Down
27 changes: 1 addition & 26 deletions beacon_node/execution_layer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ use types::{
AbstractExecPayload, BeaconStateError, BlindedPayload, BlockType, ChainSpec, Epoch,
ExecPayload, ExecutionPayloadCapella, ExecutionPayloadDeneb, ExecutionPayloadMerge,
};
use types::{ProposerPreparationData, PublicKeyBytes, Signature, Slot, Transaction};
use types::{ProposerPreparationData, PublicKeyBytes, Signature, Slot};

mod block_hash;
mod engine_api;
Expand Down Expand Up @@ -2163,31 +2163,6 @@ fn timestamp_now() -> u64 {
.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>(
_: &ExecutionLayer<T>,
_: PayloadContentsRefTuple<T>,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
use crate::engines::ForkchoiceState;
use crate::EthersTransaction;
use crate::{
engine_api::{
json_structures::{
JsonForkchoiceUpdatedV1Response, JsonPayloadStatusV1, JsonPayloadStatusV1Status,
},
ExecutionBlock, PayloadAttributes, PayloadId, PayloadStatusV1, PayloadStatusV1Status,
},
static_valid_tx, ExecutionBlockWithTransactions,
ExecutionBlockWithTransactions,
};
use eth2::types::BlobsBundle;
use kzg::Kzg;
use parking_lot::Mutex;
use rand::{rngs::StdRng, Rng, SeedableRng};
use serde::{Deserialize, Serialize};
use ssz_types::VariableList;
use std::collections::HashMap;
use std::sync::Arc;
use tree_hash::TreeHash;
use tree_hash_derive::TreeHash;
use types::{
BlobSidecar, ChainSpec, EthSpec, ExecutionBlockHash, ExecutionPayload, ExecutionPayloadCapella,
ExecutionPayloadDeneb, ExecutionPayloadHeader, ExecutionPayloadMerge, ForkName, Hash256,
Transactions, Uint256,
Transaction, Transactions, Uint256,
};

use super::DEFAULT_TERMINAL_BLOCK;
Expand Down Expand Up @@ -681,6 +683,31 @@ pub fn generate_random_blobs<T: EthSpec, R: Rng>(
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 {
n.to_le_bytes()
}
Expand Down
15 changes: 1 addition & 14 deletions beacon_node/execution_layer/src/test_utils/handle_rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,20 +282,6 @@ pub async fn handle_rpc<T: EthSpec>(
_ => unreachable!(),
}),
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) => {
serde_json::to_value(JsonGetPayloadResponseV3 {
execution_payload,
Expand All @@ -310,6 +296,7 @@ pub async fn handle_rpc<T: EthSpec>(
})
.unwrap()
}
_ => unreachable!(),
}),
_ => unreachable!(),
}
Expand Down
12 changes: 2 additions & 10 deletions beacon_node/execution_layer/src/test_utils/mock_execution_layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,8 @@ impl<T: EthSpec> MockExecutionLayer<T> {
justified_hash: None,
finalized_hash: None,
};
let payload_attributes = PayloadAttributes::new(
timestamp,
prev_randao,
Address::repeat_byte(42),
// FIXME: think about how to handle different forks here..
None,
None,
);
let payload_attributes =
PayloadAttributes::new(timestamp, prev_randao, Address::repeat_byte(42), None, None);

// Insert a proposer to ensure the fork choice updated command works.
let slot = Slot::new(0);
Expand Down Expand Up @@ -146,7 +140,6 @@ impl<T: EthSpec> MockExecutionLayer<T> {
&payload_attributes,
forkchoice_update_params,
builder_params,
// FIXME: do we need to consider other forks somehow?
ForkName::Merge,
&self.spec,
)
Expand Down Expand Up @@ -181,7 +174,6 @@ impl<T: EthSpec> MockExecutionLayer<T> {
&payload_attributes,
forkchoice_update_params,
builder_params,
// FIXME: do we need to consider other forks somehow? What about withdrawals?
ForkName::Merge,
&self.spec,
)
Expand Down
6 changes: 3 additions & 3 deletions beacon_node/http_api/src/block_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ impl BlockId {
}

/// Return the `BlobSidecarList` identified by `self`.
pub async fn blob_sidecar_list<T: BeaconChainTypes>(
pub fn blob_sidecar_list<T: BeaconChainTypes>(
&self,
chain: &BeaconChain<T>,
) -> Result<BlobSidecarList<T::EthSpec>, warp::Rejection> {
Expand All @@ -263,12 +263,12 @@ impl BlockId {
.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,
indices: BlobIndicesQuery,
chain: &BeaconChain<T>,
) -> 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 {
Some(vec) => {
let list = blob_sidecar_list
Expand Down
10 changes: 6 additions & 4 deletions beacon_node/http_api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1729,16 +1729,18 @@ pub fn serve<T: BeaconChainTypes>(
.and(block_id_or_err)
.and(warp::query::<api_types::BlobIndicesQuery>())
.and(warp::path::end())
.and(task_spawner_filter.clone())
.and(chain_filter.clone())
.and(warp::header::optional::<api_types::Accept>("accept"))
.and_then(
.then(
|block_id: BlockId,
indices: api_types::BlobIndicesQuery,
task_spawner: TaskSpawner<T::EthSpec>,
chain: Arc<BeaconChain<T>>,
accept_header: Option<api_types::Accept>| {
async move {
task_spawner.blocking_response_task(Priority::P1, move || {
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 {
Some(api_types::Accept::Ssz) => Response::builder()
.status(200)
Expand All @@ -1755,7 +1757,7 @@ pub fn serve<T: BeaconChainTypes>(
))
.into_response()),
}
}
})
},
);

Expand Down
3 changes: 1 addition & 2 deletions beacon_node/http_api/src/publish_blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ pub async fn publish_block<T: BeaconChainTypes, B: IntoGossipVerifiedBlockConten
.unwrap_or_else(|| Duration::from_secs(0));

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() {
SignedBeaconBlock::Base(_)
| SignedBeaconBlock::Altair(_)
Expand Down
6 changes: 5 additions & 1 deletion consensus/types/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1019,7 +1019,7 @@ pub struct Config {
ejection_balance: u64,
#[serde(with = "serde_utils::quoted_u64")]
min_per_epoch_churn_limit: u64,
#[serde(default)]
#[serde(default = "default_max_per_epoch_activation_churn_limit")]
#[serde(with = "serde_utils::quoted_u64")]
max_per_epoch_activation_churn_limit: u64,
#[serde(with = "serde_utils::quoted_u64")]
Expand Down Expand Up @@ -1106,6 +1106,10 @@ fn default_subnets_per_node() -> u8 {
2u8
}

const fn default_max_per_epoch_activation_churn_limit() -> u64 {
8
}

const fn default_gossip_max_size() -> u64 {
10485760
}
Expand Down
19 changes: 9 additions & 10 deletions crypto/kzg/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,17 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
ethereum_ssz = "0.5.0"
ethereum_ssz_derive = "0.5.3"
tree_hash = "0.5.2"
derivative = "2.1.1"
serde = "1.0.116"
serde_derive = "1.0.116"
ethereum_serde_utils = "0.5.0"
hex = "0.4.2"
ethereum_hashing = "1.0.0-beta.2"
arbitrary = { workspace = true }
ethereum_ssz = { workspace = true }
ethereum_ssz_derive = { workspace = true }
tree_hash = { workspace = true }
derivative = { workspace = true }
serde = { workspace = true }
ethereum_serde_utils = { workspace = true }
hex = { workspace = true }
ethereum_hashing = { workspace = true }
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 }
arbitrary = { version = "1.0", features = ["derive"] }

[features]
# TODO(deneb): enabled by default for convenience, would need more cfg magic to disable
Expand Down

0 comments on commit 283ec8c

Please sign in to comment.