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 <micsproul@gmail.com>
This commit is contained in:
Paul Hauner 2022-02-14 23:57:23 +00:00
parent 886afd684a
commit 2f8531dc60
21 changed files with 61 additions and 44 deletions

View File

@ -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() {

View File

@ -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<T: BeaconChainTypes>(
/// https://github.com/ethereum/consensus-specs/blob/v1.1.9/specs/bellatrix/beacon-chain.md#notify_new_payload
pub fn notify_new_payload<T: BeaconChainTypes>(
chain: &BeaconChain<T>,
state: &BeaconState<T::EthSpec>,
block: BeaconBlockRef<T::EthSpec>,
@ -53,10 +53,10 @@ pub fn execute_payload<T: BeaconChainTypes>(
.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.

View File

@ -55,7 +55,7 @@ pub trait EngineApi {
block_hash: Hash256,
) -> Result<Option<ExecutionBlock>, Error>;
async fn execute_payload_v1<T: EthSpec>(
async fn notify_new_payload_v1<T: EthSpec>(
&self,
execution_payload: ExecutionPayload<T>,
) -> Result<ExecutePayloadResponse, Error>;

View File

@ -133,7 +133,7 @@ impl EngineApi for HttpJsonRpc {
.await
}
async fn execute_payload_v1<T: EthSpec>(
async fn notify_new_payload_v1<T: EthSpec>(
&self,
execution_payload: ExecutionPayload<T>,
) -> Result<ExecutePayloadResponse, Error> {
@ -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::<MainnetEthSpec>(ExecutionPayload {
.notify_new_payload_v1::<MainnetEthSpec>(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::<MainnetEthSpec>(ExecutionPayload {
.notify_new_payload_v1::<MainnetEthSpec>(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::<MainnetEthSpec>(ExecutionPayload::default())
.notify_new_payload_v1::<MainnetEthSpec>(ExecutionPayload::default())
.await
.unwrap();

View File

@ -89,7 +89,7 @@ impl<T: EthSpec> From<ExecutionPayload<T>> for JsonExecutionPayloadV1<T> {
parent_hash,
fee_recipient,
state_root,
receipt_root,
receipts_root,
logs_bloom,
random,
block_number,
@ -106,7 +106,7 @@ impl<T: EthSpec> From<ExecutionPayload<T>> for JsonExecutionPayloadV1<T> {
parent_hash,
fee_recipient,
state_root,
receipts_root: receipt_root,
receipts_root,
logs_bloom,
random,
block_number,
@ -145,7 +145,7 @@ impl<T: EthSpec> From<JsonExecutionPayloadV1<T>> for ExecutionPayload<T> {
parent_hash,
fee_recipient,
state_root,
receipt_root: receipts_root,
receipts_root,
logs_bloom,
random,
block_number,

View File

@ -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<T: EthSpec>(
pub async fn notify_new_payload<T: EthSpec>(
&self,
execution_payload: &ExecutionPayload<T>,
) -> Result<(ExecutePayloadResponseStatus, Option<Hash256>), 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"
);
}

View File

@ -235,7 +235,7 @@ impl<T: EthSpec> ExecutionBlockGenerator<T> {
self.payload_ids.remove(id)
}
pub fn execute_payload(&mut self, payload: ExecutionPayload<T>) -> ExecutePayloadResponse {
pub fn notify_new_payload(&mut self, payload: ExecutionPayload<T>) -> ExecutePayloadResponse {
let parent = if let Some(parent) = self.blocks.get(&payload.parent_hash) {
parent
} else {
@ -325,7 +325,7 @@ impl<T: EthSpec> ExecutionBlockGenerator<T> {
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,

View File

@ -57,7 +57,7 @@ pub async fn handle_rpc<T: EthSpec>(
ENGINE_EXECUTE_PAYLOAD_V1 => {
let request: JsonExecutionPayloadV1<T> = 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<T: EthSpec>(
} else {
ctx.execution_block_generator
.write()
.execute_payload(request.into())
.notify_new_payload(request.into())
};
Ok(serde_json::to_value(JsonExecutePayloadV1Response::from(response)).unwrap())

View File

@ -146,7 +146,7 @@ impl<T: EthSpec> MockExecutionLayer<T> {
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));

View File

@ -62,7 +62,7 @@ impl<T: EthSpec> MockServer<T> {
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<T: EthSpec> MockServer<T> {
}
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<T: EthSpec> {
pub last_echo_request: Arc<RwLock<Option<Bytes>>>,
pub execution_block_generator: RwLock<ExecutionBlockGenerator<T>>,
pub preloaded_responses: Arc<Mutex<Vec<serde_json::Value>>>,
pub static_execute_payload_response: Arc<Mutex<Option<ExecutePayloadResponseStatus>>>,
pub static_notify_new_payload_response: Arc<Mutex<Option<ExecutePayloadResponseStatus>>>,
pub _phantom: PhantomData<T>,
}

View File

@ -1,6 +1,7 @@
# Gnosis Beacon Chain config
# Extends the gnosis preset
CONFIG_NAME: 'gnosis'
PRESET_BASE: 'gnosis'
# Transition

View File

@ -1,6 +1,7 @@
# Mainnet config
# Extends the mainnet preset
CONFIG_NAME: 'mainnet'
PRESET_BASE: 'mainnet'
# Transition

View File

@ -1,6 +1,7 @@
# Prater config
# Extends the mainnet preset
CONFIG_NAME: 'prater'
PRESET_BASE: 'mainnet'
# Transition

View File

@ -275,6 +275,7 @@ mod tests {
"{:?}",
net.name
);
assert_eq!(config.config.config_name, Some(net.name.to_string()));
}
}

View File

@ -366,7 +366,7 @@ pub fn process_execution_payload<T: EthSpec>(
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,

View File

@ -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<String>,
/*
* 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<String>,
#[serde(default)]
pub preset_base: String,
@ -914,6 +929,7 @@ impl Config {
pub fn from_chain_spec<T: EthSpec>(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<T: EthSpec>(&self, chain_spec: &ChainSpec) -> Option<ChainSpec> {
// 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,

View File

@ -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),

View File

@ -18,7 +18,7 @@ pub struct ExecutionPayload<T: EthSpec> {
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<u8, T::BytesPerLogsBloom>,
pub random: Hash256,

View File

@ -12,7 +12,7 @@ pub struct ExecutionPayloadHeader<T: EthSpec> {
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<u8, T::BytesPerLogsBloom>,
pub random: Hash256,

View File

@ -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))

View File

@ -307,11 +307,6 @@ pub struct RandomHandler<E>(PhantomData<E>);
impl<E: EthSpec + TypeName> Handler for RandomHandler<E> {
type Case = cases::SanityBlocks<E>;
// 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()
}