From 2f8531dc607b9626253ce141d648d3a6392eb52f Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Mon, 14 Feb 2022 23:57:23 +0000 Subject: [PATCH] Update to consensus-specs v1.1.9 (#3016) ## Issue Addressed Closes #3014 ## Proposed Changes - Rename `receipt_root` to `receipts_root` - Rename `execute_payload` to `notify_new_payload` - This is slightly weird since we modify everything except the actual HTTP call to the engine API. That change is expected to be implemented in #2985 (cc @ethDreamer) - Enable "random" tests for Bellatrix. ## Notes This will break *partially* compatibility with Kintusgi testnets in order to gain compatibility with [Kiln](https://hackmd.io/@n0ble/kiln-spec) testnets. I think it will only break the BN APIs due to the `receipts_root` change, however it might have some other effects too. Co-authored-by: Michael Sproul --- .../beacon_chain/src/block_verification.rs | 4 ++-- .../beacon_chain/src/execution_payload.rs | 12 ++++++------ beacon_node/execution_layer/src/engine_api.rs | 2 +- .../execution_layer/src/engine_api/http.rs | 16 ++++++++-------- .../src/engine_api/json_structures.rs | 6 +++--- beacon_node/execution_layer/src/lib.rs | 12 ++++++------ .../test_utils/execution_block_generator.rs | 4 ++-- .../src/test_utils/handle_rpc.rs | 4 ++-- .../src/test_utils/mock_execution_layer.rs | 2 +- .../execution_layer/src/test_utils/mod.rs | 7 ++++--- .../gnosis/config.yaml | 1 + .../mainnet/config.yaml | 1 + .../prater/config.yaml | 1 + common/eth2_network_config/src/lib.rs | 1 + .../src/per_block_processing.rs | 2 +- consensus/types/src/chain_spec.rs | 18 ++++++++++++++++++ consensus/types/src/config_and_preset.rs | 1 - consensus/types/src/execution_payload.rs | 2 +- .../types/src/execution_payload_header.rs | 2 +- testing/ef_tests/Makefile | 2 +- testing/ef_tests/src/handler.rs | 5 ----- 21 files changed, 61 insertions(+), 44 deletions(-) diff --git a/beacon_node/beacon_chain/src/block_verification.rs b/beacon_node/beacon_chain/src/block_verification.rs index c2dc0028e..8d61d9cbf 100644 --- a/beacon_node/beacon_chain/src/block_verification.rs +++ b/beacon_node/beacon_chain/src/block_verification.rs @@ -41,7 +41,7 @@ //! //! ``` use crate::execution_payload::{ - execute_payload, validate_execution_payload_for_gossip, validate_merge_block, + notify_new_payload, validate_execution_payload_for_gossip, validate_merge_block, }; use crate::snapshot_cache::PreProcessingSnapshot; use crate::validator_monitor::HISTORIC_EPOCHS as VALIDATOR_MONITOR_HISTORIC_EPOCHS; @@ -1125,7 +1125,7 @@ impl<'a, T: BeaconChainTypes> FullyVerifiedBlock<'a, T> { // // It is important that this function is called *after* `per_slot_processing`, since the // `randao` may change. - let payload_verification_status = execute_payload(chain, &state, block.message())?; + let payload_verification_status = notify_new_payload(chain, &state, block.message())?; // If the block is sufficiently recent, notify the validator monitor. if let Some(slot) = chain.slot_clock.now() { diff --git a/beacon_node/beacon_chain/src/execution_payload.rs b/beacon_node/beacon_chain/src/execution_payload.rs index 21d51be99..ba2015669 100644 --- a/beacon_node/beacon_chain/src/execution_payload.rs +++ b/beacon_node/beacon_chain/src/execution_payload.rs @@ -27,11 +27,11 @@ use types::*; /// /// ## Specification /// -/// Equivalent to the `execute_payload` function in the merge Beacon Chain Changes, although it +/// Equivalent to the `notify_new_payload` function in the merge Beacon Chain Changes, although it /// contains a few extra checks by running `partially_verify_execution_payload` first: /// -/// https://github.com/ethereum/consensus-specs/blob/v1.1.5/specs/merge/beacon-chain.md#execute_payload -pub fn execute_payload( +/// https://github.com/ethereum/consensus-specs/blob/v1.1.9/specs/bellatrix/beacon-chain.md#notify_new_payload +pub fn notify_new_payload( chain: &BeaconChain, state: &BeaconState, block: BeaconBlockRef, @@ -53,10 +53,10 @@ pub fn execute_payload( .execution_layer .as_ref() .ok_or(ExecutionPayloadError::NoExecutionConnection)?; - let execute_payload_response = execution_layer - .block_on(|execution_layer| execution_layer.execute_payload(execution_payload)); + let notify_new_payload_response = execution_layer + .block_on(|execution_layer| execution_layer.notify_new_payload(execution_payload)); - match execute_payload_response { + match notify_new_payload_response { Ok((status, _latest_valid_hash)) => match status { ExecutePayloadResponseStatus::Valid => Ok(PayloadVerificationStatus::Verified), // TODO(merge): invalidate any invalid ancestors of this block in fork choice. diff --git a/beacon_node/execution_layer/src/engine_api.rs b/beacon_node/execution_layer/src/engine_api.rs index f9654a497..e59a706b2 100644 --- a/beacon_node/execution_layer/src/engine_api.rs +++ b/beacon_node/execution_layer/src/engine_api.rs @@ -55,7 +55,7 @@ pub trait EngineApi { block_hash: Hash256, ) -> Result, Error>; - async fn execute_payload_v1( + async fn notify_new_payload_v1( &self, execution_payload: ExecutionPayload, ) -> Result; diff --git a/beacon_node/execution_layer/src/engine_api/http.rs b/beacon_node/execution_layer/src/engine_api/http.rs index c7c60a900..39312e660 100644 --- a/beacon_node/execution_layer/src/engine_api/http.rs +++ b/beacon_node/execution_layer/src/engine_api/http.rs @@ -133,7 +133,7 @@ impl EngineApi for HttpJsonRpc { .await } - async fn execute_payload_v1( + async fn notify_new_payload_v1( &self, execution_payload: ExecutionPayload, ) -> Result { @@ -486,16 +486,16 @@ mod test { } #[tokio::test] - async fn execute_payload_v1_request() { + async fn notify_new_payload_v1_request() { Tester::new() .assert_request_equals( |client| async move { let _ = client - .execute_payload_v1::(ExecutionPayload { + .notify_new_payload_v1::(ExecutionPayload { parent_hash: Hash256::repeat_byte(0), fee_recipient: Address::repeat_byte(1), state_root: Hash256::repeat_byte(1), - receipt_root: Hash256::repeat_byte(0), + receipts_root: Hash256::repeat_byte(0), logs_bloom: vec![1; 256].into(), random: Hash256::repeat_byte(1), block_number: 0, @@ -702,7 +702,7 @@ mod test { parent_hash: Hash256::from_str("0x3b8fb240d288781d4aac94d3fd16809ee413bc99294a085798a589dae51ddd4a").unwrap(), fee_recipient: Address::from_str("0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b").unwrap(), state_root: Hash256::from_str("0xca3149fa9e37db08d1cd49c9061db1002ef1cd58db2210f2115c8c989b2bdf45").unwrap(), - receipt_root: Hash256::from_str("0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421").unwrap(), + receipts_root: Hash256::from_str("0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421").unwrap(), logs_bloom: vec![0; 256].into(), random: Hash256::zero(), block_number: 1, @@ -723,11 +723,11 @@ mod test { // engine_executePayloadV1 REQUEST validation |client| async move { let _ = client - .execute_payload_v1::(ExecutionPayload { + .notify_new_payload_v1::(ExecutionPayload { parent_hash: Hash256::from_str("0x3b8fb240d288781d4aac94d3fd16809ee413bc99294a085798a589dae51ddd4a").unwrap(), fee_recipient: Address::from_str("0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b").unwrap(), state_root: Hash256::from_str("0xca3149fa9e37db08d1cd49c9061db1002ef1cd58db2210f2115c8c989b2bdf45").unwrap(), - receipt_root: Hash256::from_str("0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421").unwrap(), + receipts_root: Hash256::from_str("0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421").unwrap(), logs_bloom: vec![0; 256].into(), random: Hash256::zero(), block_number: 1, @@ -776,7 +776,7 @@ mod test { })], |client| async move { let response = client - .execute_payload_v1::(ExecutionPayload::default()) + .notify_new_payload_v1::(ExecutionPayload::default()) .await .unwrap(); diff --git a/beacon_node/execution_layer/src/engine_api/json_structures.rs b/beacon_node/execution_layer/src/engine_api/json_structures.rs index ae6d730fa..ae542f9a5 100644 --- a/beacon_node/execution_layer/src/engine_api/json_structures.rs +++ b/beacon_node/execution_layer/src/engine_api/json_structures.rs @@ -89,7 +89,7 @@ impl From> for JsonExecutionPayloadV1 { parent_hash, fee_recipient, state_root, - receipt_root, + receipts_root, logs_bloom, random, block_number, @@ -106,7 +106,7 @@ impl From> for JsonExecutionPayloadV1 { parent_hash, fee_recipient, state_root, - receipts_root: receipt_root, + receipts_root, logs_bloom, random, block_number, @@ -145,7 +145,7 @@ impl From> for ExecutionPayload { parent_hash, fee_recipient, state_root, - receipt_root: receipts_root, + receipts_root, logs_bloom, random, block_number, diff --git a/beacon_node/execution_layer/src/lib.rs b/beacon_node/execution_layer/src/lib.rs index cb267e5f0..2fbd72e15 100644 --- a/beacon_node/execution_layer/src/lib.rs +++ b/beacon_node/execution_layer/src/lib.rs @@ -441,7 +441,7 @@ impl ExecutionLayer { .map_err(Error::EngineErrors) } - /// Maps to the `engine_executePayload` JSON-RPC call. + /// Maps to the `engine_newPayload` JSON-RPC call. /// /// ## Fallback Behaviour /// @@ -453,7 +453,7 @@ impl ExecutionLayer { /// - Invalid, if any nodes return invalid. /// - Syncing, if any nodes return syncing. /// - An error, if all nodes return an error. - pub async fn execute_payload( + pub async fn notify_new_payload( &self, execution_payload: &ExecutionPayload, ) -> Result<(ExecutePayloadResponseStatus, Option), Error> { @@ -467,7 +467,7 @@ impl ExecutionLayer { let broadcast_results = self .engines() - .broadcast(|engine| engine.api.execute_payload_v1(execution_payload.clone())) + .broadcast(|engine| engine.api.notify_new_payload_v1(execution_payload.clone())) .await; let mut errors = vec![]; @@ -486,7 +486,7 @@ impl ExecutionLayer { id: "unknown".to_string(), error: engine_api::Error::BadResponse( format!( - "execute_payload: response.status = Valid but invalid latest_valid_hash. Expected({:?}) Found({:?})", + "notify_new_payload: response.status = Valid but invalid latest_valid_hash. Expected({:?}) Found({:?})", execution_payload.block_hash, latest_hash, ) @@ -503,7 +503,7 @@ impl ExecutionLayer { Ok((None, status)) => errors.push(EngineError::Api { id: "unknown".to_string(), error: engine_api::Error::BadResponse(format!( - "execute_payload: status {:?} returned with null latest_valid_hash", + "notify_new_payload: status {:?} returned with null latest_valid_hash", status )), }), @@ -515,7 +515,7 @@ impl ExecutionLayer { crit!( self.log(), "Consensus failure between execution nodes"; - "method" => "execute_payload" + "method" => "notify_new_payload" ); } diff --git a/beacon_node/execution_layer/src/test_utils/execution_block_generator.rs b/beacon_node/execution_layer/src/test_utils/execution_block_generator.rs index 552bea0ea..61aaedd35 100644 --- a/beacon_node/execution_layer/src/test_utils/execution_block_generator.rs +++ b/beacon_node/execution_layer/src/test_utils/execution_block_generator.rs @@ -235,7 +235,7 @@ impl ExecutionBlockGenerator { self.payload_ids.remove(id) } - pub fn execute_payload(&mut self, payload: ExecutionPayload) -> ExecutePayloadResponse { + pub fn notify_new_payload(&mut self, payload: ExecutionPayload) -> ExecutePayloadResponse { let parent = if let Some(parent) = self.blocks.get(&payload.parent_hash) { parent } else { @@ -325,7 +325,7 @@ impl ExecutionBlockGenerator { let mut execution_payload = ExecutionPayload { parent_hash: forkchoice_state.head_block_hash, fee_recipient: attributes.suggested_fee_recipient, - receipt_root: Hash256::repeat_byte(42), + receipts_root: Hash256::repeat_byte(42), state_root: Hash256::repeat_byte(43), logs_bloom: vec![0; 256].into(), random: attributes.random, diff --git a/beacon_node/execution_layer/src/test_utils/handle_rpc.rs b/beacon_node/execution_layer/src/test_utils/handle_rpc.rs index 131bc8ba0..11232bc08 100644 --- a/beacon_node/execution_layer/src/test_utils/handle_rpc.rs +++ b/beacon_node/execution_layer/src/test_utils/handle_rpc.rs @@ -57,7 +57,7 @@ pub async fn handle_rpc( ENGINE_EXECUTE_PAYLOAD_V1 => { let request: JsonExecutionPayloadV1 = get_param(params, 0)?; - let response = if let Some(status) = *ctx.static_execute_payload_response.lock() { + let response = if let Some(status) = *ctx.static_notify_new_payload_response.lock() { match status { ExecutePayloadResponseStatus::Valid => ExecutePayloadResponse { status, @@ -74,7 +74,7 @@ pub async fn handle_rpc( } else { ctx.execution_block_generator .write() - .execute_payload(request.into()) + .notify_new_payload(request.into()) }; Ok(serde_json::to_value(JsonExecutePayloadV1Response::from(response)).unwrap()) diff --git a/beacon_node/execution_layer/src/test_utils/mock_execution_layer.rs b/beacon_node/execution_layer/src/test_utils/mock_execution_layer.rs index 295e82914..4f5337075 100644 --- a/beacon_node/execution_layer/src/test_utils/mock_execution_layer.rs +++ b/beacon_node/execution_layer/src/test_utils/mock_execution_layer.rs @@ -146,7 +146,7 @@ impl MockExecutionLayer { assert_eq!(payload.random, random); let (payload_response, latest_valid_hash) = - self.el.execute_payload(&payload).await.unwrap(); + self.el.notify_new_payload(&payload).await.unwrap(); assert_eq!(payload_response, ExecutePayloadResponseStatus::Valid); assert_eq!(latest_valid_hash, Some(payload.block_hash)); diff --git a/beacon_node/execution_layer/src/test_utils/mod.rs b/beacon_node/execution_layer/src/test_utils/mod.rs index cd45d34a1..fbc375178 100644 --- a/beacon_node/execution_layer/src/test_utils/mod.rs +++ b/beacon_node/execution_layer/src/test_utils/mod.rs @@ -62,7 +62,7 @@ impl MockServer { last_echo_request: last_echo_request.clone(), execution_block_generator: RwLock::new(execution_block_generator), preloaded_responses, - static_execute_payload_response: <_>::default(), + static_notify_new_payload_response: <_>::default(), _phantom: PhantomData, }); @@ -117,7 +117,8 @@ impl MockServer { } pub fn all_payloads_valid(&self) { - *self.ctx.static_execute_payload_response.lock() = Some(ExecutePayloadResponseStatus::Valid) + *self.ctx.static_notify_new_payload_response.lock() = + Some(ExecutePayloadResponseStatus::Valid) } pub fn insert_pow_block( @@ -187,7 +188,7 @@ pub struct Context { pub last_echo_request: Arc>>, pub execution_block_generator: RwLock>, pub preloaded_responses: Arc>>, - pub static_execute_payload_response: Arc>>, + pub static_notify_new_payload_response: Arc>>, pub _phantom: PhantomData, } diff --git a/common/eth2_network_config/built_in_network_configs/gnosis/config.yaml b/common/eth2_network_config/built_in_network_configs/gnosis/config.yaml index c34ebed7d..12d799528 100644 --- a/common/eth2_network_config/built_in_network_configs/gnosis/config.yaml +++ b/common/eth2_network_config/built_in_network_configs/gnosis/config.yaml @@ -1,6 +1,7 @@ # Gnosis Beacon Chain config # Extends the gnosis preset +CONFIG_NAME: 'gnosis' PRESET_BASE: 'gnosis' # Transition diff --git a/common/eth2_network_config/built_in_network_configs/mainnet/config.yaml b/common/eth2_network_config/built_in_network_configs/mainnet/config.yaml index b889b8288..6993c24b8 100644 --- a/common/eth2_network_config/built_in_network_configs/mainnet/config.yaml +++ b/common/eth2_network_config/built_in_network_configs/mainnet/config.yaml @@ -1,6 +1,7 @@ # Mainnet config # Extends the mainnet preset +CONFIG_NAME: 'mainnet' PRESET_BASE: 'mainnet' # Transition diff --git a/common/eth2_network_config/built_in_network_configs/prater/config.yaml b/common/eth2_network_config/built_in_network_configs/prater/config.yaml index 72a106f36..106c95595 100644 --- a/common/eth2_network_config/built_in_network_configs/prater/config.yaml +++ b/common/eth2_network_config/built_in_network_configs/prater/config.yaml @@ -1,6 +1,7 @@ # Prater config # Extends the mainnet preset +CONFIG_NAME: 'prater' PRESET_BASE: 'mainnet' # Transition diff --git a/common/eth2_network_config/src/lib.rs b/common/eth2_network_config/src/lib.rs index fa8e1a3dd..8df54a5a8 100644 --- a/common/eth2_network_config/src/lib.rs +++ b/common/eth2_network_config/src/lib.rs @@ -275,6 +275,7 @@ mod tests { "{:?}", net.name ); + assert_eq!(config.config.config_name, Some(net.name.to_string())); } } diff --git a/consensus/state_processing/src/per_block_processing.rs b/consensus/state_processing/src/per_block_processing.rs index 857c77633..a874ce642 100644 --- a/consensus/state_processing/src/per_block_processing.rs +++ b/consensus/state_processing/src/per_block_processing.rs @@ -366,7 +366,7 @@ pub fn process_execution_payload( parent_hash: payload.parent_hash, fee_recipient: payload.fee_recipient, state_root: payload.state_root, - receipt_root: payload.receipt_root, + receipts_root: payload.receipts_root, logs_bloom: payload.logs_bloom.clone(), random: payload.random, block_number: payload.block_number, diff --git a/consensus/types/src/chain_spec.rs b/consensus/types/src/chain_spec.rs index fa74f9d29..d391fe01e 100644 --- a/consensus/types/src/chain_spec.rs +++ b/consensus/types/src/chain_spec.rs @@ -28,6 +28,11 @@ pub enum Domain { #[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))] #[derive(PartialEq, Debug, Clone)] pub struct ChainSpec { + /* + * Config name + */ + pub config_name: Option, + /* * Constants */ @@ -405,6 +410,10 @@ impl ChainSpec { /// Returns a `ChainSpec` compatible with the Ethereum Foundation specification. pub fn mainnet() -> Self { Self { + /* + * Config name + */ + config_name: Some("mainnet".to_string()), /* * Constants */ @@ -563,6 +572,7 @@ impl ChainSpec { let boot_nodes = vec![]; Self { + config_name: None, max_committees_per_slot: 4, target_committee_size: 4, churn_limit_quotient: 32, @@ -600,6 +610,7 @@ impl ChainSpec { /// Returns a `ChainSpec` compatible with the Gnosis Beacon Chain specification. pub fn gnosis() -> Self { Self { + config_name: Some("gnosis".to_string()), /* * Constants */ @@ -763,6 +774,10 @@ impl Default for ChainSpec { #[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] #[serde(rename_all = "UPPERCASE")] pub struct Config { + #[serde(default)] + #[serde(skip_serializing_if = "Option::is_none")] + pub config_name: Option, + #[serde(default)] pub preset_base: String, @@ -914,6 +929,7 @@ impl Config { pub fn from_chain_spec(spec: &ChainSpec) -> Self { Self { + config_name: spec.config_name.clone(), preset_base: T::spec_name().to_string(), terminal_total_difficulty: spec.terminal_total_difficulty, @@ -964,6 +980,7 @@ impl Config { pub fn apply_to_chain_spec(&self, chain_spec: &ChainSpec) -> Option { // Pattern match here to avoid missing any fields. let &Config { + ref config_name, ref preset_base, terminal_total_difficulty, terminal_block_hash, @@ -997,6 +1014,7 @@ impl Config { } Some(ChainSpec { + config_name: config_name.clone(), min_genesis_active_validator_count, min_genesis_time, genesis_fork_version, diff --git a/consensus/types/src/config_and_preset.rs b/consensus/types/src/config_and_preset.rs index affda1a06..d782f4d8b 100644 --- a/consensus/types/src/config_and_preset.rs +++ b/consensus/types/src/config_and_preset.rs @@ -46,7 +46,6 @@ impl ConfigAndPreset { let u32_hex = |v: u32| hex_string(&v.to_le_bytes()); let u8_hex = |v: u8| hex_string(&v.to_le_bytes()); let fields = vec![ - ("config_name", self.config.preset_base.clone()), ( "bls_withdrawal_prefix", u8_hex(spec.bls_withdrawal_prefix_byte), diff --git a/consensus/types/src/execution_payload.rs b/consensus/types/src/execution_payload.rs index 2fb253f12..781fb7460 100644 --- a/consensus/types/src/execution_payload.rs +++ b/consensus/types/src/execution_payload.rs @@ -18,7 +18,7 @@ pub struct ExecutionPayload { pub parent_hash: Hash256, pub fee_recipient: Address, pub state_root: Hash256, - pub receipt_root: Hash256, + pub receipts_root: Hash256, #[serde(with = "ssz_types::serde_utils::hex_fixed_vec")] pub logs_bloom: FixedVector, pub random: Hash256, diff --git a/consensus/types/src/execution_payload_header.rs b/consensus/types/src/execution_payload_header.rs index 6cb76a646..aa022f642 100644 --- a/consensus/types/src/execution_payload_header.rs +++ b/consensus/types/src/execution_payload_header.rs @@ -12,7 +12,7 @@ pub struct ExecutionPayloadHeader { pub parent_hash: Hash256, pub fee_recipient: Address, pub state_root: Hash256, - pub receipt_root: Hash256, + pub receipts_root: Hash256, #[serde(with = "ssz_types::serde_utils::hex_fixed_vec")] pub logs_bloom: FixedVector, pub random: Hash256, diff --git a/testing/ef_tests/Makefile b/testing/ef_tests/Makefile index 3cd6d17c0..816651bb4 100644 --- a/testing/ef_tests/Makefile +++ b/testing/ef_tests/Makefile @@ -1,4 +1,4 @@ -TESTS_TAG := v1.1.8 +TESTS_TAG := v1.1.9 TESTS = general minimal mainnet TARBALLS = $(patsubst %,%-$(TESTS_TAG).tar.gz,$(TESTS)) diff --git a/testing/ef_tests/src/handler.rs b/testing/ef_tests/src/handler.rs index 636119cdb..be6c495aa 100644 --- a/testing/ef_tests/src/handler.rs +++ b/testing/ef_tests/src/handler.rs @@ -307,11 +307,6 @@ pub struct RandomHandler(PhantomData); impl Handler for RandomHandler { type Case = cases::SanityBlocks; - // FIXME(merge): enable merge tests once available - fn is_enabled_for_fork(&self, fork_name: ForkName) -> bool { - fork_name != ForkName::Merge - } - fn config_name() -> &'static str { E::name() }