Update merge consensus to v1.1.0-beta.5 (#2630)

This commit is contained in:
Michael Sproul
2021-09-27 09:42:29 +10:00
committed by Paul Hauner
parent b48f133a8c
commit 251ddbd696
5 changed files with 43 additions and 45 deletions

44
Cargo.lock generated
View File

@@ -895,6 +895,7 @@ dependencies = [
"environment", "environment",
"error-chain", "error-chain",
"eth1", "eth1",
"eth2",
"eth2_config", "eth2_config",
"eth2_libp2p", "eth2_libp2p",
"eth2_ssz", "eth2_ssz",
@@ -909,6 +910,7 @@ dependencies = [
"parking_lot", "parking_lot",
"prometheus", "prometheus",
"reqwest", "reqwest",
"sensitive_url",
"serde", "serde",
"serde_derive", "serde_derive",
"serde_yaml", "serde_yaml",
@@ -938,17 +940,6 @@ dependencies = [
"cc", "cc",
] ]
[[package]]
name = "colored"
version = "1.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f4ffc801dacf156c5854b9df4f425a626539c3a6ef7893cc0c5084a23f0b6c59"
dependencies = [
"atty",
"lazy_static",
"winapi",
]
[[package]] [[package]]
name = "compare_fields" name = "compare_fields"
version = "0.2.0" version = "0.2.0"
@@ -1749,6 +1740,7 @@ dependencies = [
"sensitive_url", "sensitive_url",
"serde", "serde",
"serde_json", "serde_json",
"store",
"types", "types",
"zeroize", "zeroize",
] ]
@@ -2943,6 +2935,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bee0328b1209d157ef001c94dd85b4f8f64139adb0eac2659f4b08382b2f474d" checksum = "bee0328b1209d157ef001c94dd85b4f8f64139adb0eac2659f4b08382b2f474d"
dependencies = [ dependencies = [
"cfg-if 1.0.0", "cfg-if 1.0.0",
"js-sys",
"wasm-bindgen",
"web-sys",
] ]
[[package]] [[package]]
@@ -3067,8 +3062,10 @@ dependencies = [
"deposit_contract", "deposit_contract",
"directory", "directory",
"dirs", "dirs",
"env_logger 0.9.0",
"environment", "environment",
"eth1_test_rig", "eth1_test_rig",
"eth2",
"eth2_keystore", "eth2_keystore",
"eth2_libp2p", "eth2_libp2p",
"eth2_network_config", "eth2_network_config",
@@ -3083,8 +3080,8 @@ dependencies = [
"regex", "regex",
"sensitive_url", "sensitive_url",
"serde", "serde",
"serde_json",
"serde_yaml", "serde_yaml",
"simple_logger",
"state_processing", "state_processing",
"tokio", "tokio",
"tree_hash", "tree_hash",
@@ -5630,19 +5627,6 @@ dependencies = [
"rand_core 0.6.3", "rand_core 0.6.3",
] ]
[[package]]
name = "simple_logger"
version = "1.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b7de33c687404ec3045d4a0d437580455257c0436f858d702f244e7d652f9f07"
dependencies = [
"atty",
"chrono",
"colored",
"log",
"winapi",
]
[[package]] [[package]]
name = "simulator" name = "simulator"
version = "0.2.0" version = "0.2.0"
@@ -6340,13 +6324,14 @@ dependencies = [
[[package]] [[package]]
name = "tiny-bip39" name = "tiny-bip39"
version = "0.8.0" version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9e44c4759bae7f1032e286a7ef990bd9ed23fe831b7eeba0beb97484c2e59b8" checksum = "524daa5624d9d4ffb5a0625971d35205b882111daa6b6338a7a6c578a3c36928"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"hmac 0.8.1", "hmac 0.8.1",
"once_cell", "once_cell",
"parking_lot",
"pbkdf2 0.4.0", "pbkdf2 0.4.0",
"rand 0.7.3", "rand 0.7.3",
"rustc-hash", "rustc-hash",
@@ -6758,6 +6743,7 @@ dependencies = [
"serde_json", "serde_json",
"serde_yaml", "serde_yaml",
"slog", "slog",
"state_processing",
"superstruct", "superstruct",
"swap_or_not_shuffle", "swap_or_not_shuffle",
"tempfile", "tempfile",
@@ -7462,9 +7448,9 @@ dependencies = [
[[package]] [[package]]
name = "zeroize" name = "zeroize"
version = "1.4.1" version = "1.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "377db0846015f7ae377174787dd452e1c5f5a9050bc6f954911d01f116daa0cd" checksum = "bf68b08513768deaa790264a7fac27a58cbf2705cfcdc9448362229217d7e970"
dependencies = [ dependencies = [
"zeroize_derive", "zeroize_derive",
] ]

View File

@@ -127,6 +127,17 @@ pub fn per_block_processing<T: EthSpec>(
state.build_committee_cache(RelativeEpoch::Previous, spec)?; state.build_committee_cache(RelativeEpoch::Previous, spec)?;
state.build_committee_cache(RelativeEpoch::Current, spec)?; state.build_committee_cache(RelativeEpoch::Current, spec)?;
// The call to the `process_execution_payload` must happen before the call to the
// `process_randao` as the former depends on the `randao_mix` computed with the reveal of the
// previous block.
if is_execution_enabled(state, block.body()) {
let payload = block
.body()
.execution_payload()
.ok_or(BlockProcessingError::IncorrectStateType)?;
process_execution_payload(state, payload, spec)?;
}
process_randao(state, block, verify_signatures, spec)?; process_randao(state, block, verify_signatures, spec)?;
process_eth1_data(state, block.body().eth1_data())?; process_eth1_data(state, block.body().eth1_data())?;
process_operations(state, block.body(), proposer_index, verify_signatures, spec)?; process_operations(state, block.body(), proposer_index, verify_signatures, spec)?;
@@ -141,14 +152,6 @@ pub fn per_block_processing<T: EthSpec>(
)?; )?;
} }
if is_execution_enabled(state, block.body()) {
let payload = block
.body()
.execution_payload()
.ok_or(BlockProcessingError::IncorrectStateType)?;
process_execution_payload(state, payload, spec)?;
}
Ok(()) Ok(())
} }
@@ -344,13 +347,6 @@ pub fn process_execution_payload<T: EthSpec>(
found: payload.block_number, found: payload.block_number,
} }
); );
block_verify!(
payload.random == *state.get_randao_mix(state.current_epoch())?,
BlockProcessingError::ExecutionRandaoMismatch {
expected: *state.get_randao_mix(state.current_epoch())?,
found: payload.random,
}
);
block_verify!( block_verify!(
is_valid_gas_limit(payload, state.latest_execution_payload_header()?)?, is_valid_gas_limit(payload, state.latest_execution_payload_header()?)?,
BlockProcessingError::ExecutionInvalidGasLimit { BlockProcessingError::ExecutionInvalidGasLimit {
@@ -359,6 +355,13 @@ pub fn process_execution_payload<T: EthSpec>(
} }
); );
} }
block_verify!(
payload.random == *state.get_randao_mix(state.current_epoch())?,
BlockProcessingError::ExecutionRandaoMismatch {
expected: *state.get_randao_mix(state.current_epoch())?,
found: payload.random,
}
);
let timestamp = compute_timestamp_at_slot(state, spec)?; let timestamp = compute_timestamp_at_slot(state, spec)?;
block_verify!( block_verify!(
@@ -380,6 +383,7 @@ pub fn process_execution_payload<T: EthSpec>(
gas_limit: payload.gas_limit, gas_limit: payload.gas_limit,
gas_used: payload.gas_used, gas_used: payload.gas_used,
timestamp: payload.timestamp, timestamp: payload.timestamp,
extra_data: payload.extra_data.clone(),
base_fee_per_gas: payload.base_fee_per_gas, base_fee_per_gas: payload.base_fee_per_gas,
block_hash: payload.block_hash, block_hash: payload.block_hash,
transactions_root: payload.transactions.tree_hash_root(), transactions_root: payload.transactions.tree_hash_root(),

View File

@@ -91,6 +91,7 @@ pub trait EthSpec: 'static + Default + Sync + Send + Clone + Debug + PartialEq +
type BytesPerLogsBloom: Unsigned + Clone + Sync + Send + Debug + PartialEq; type BytesPerLogsBloom: Unsigned + Clone + Sync + Send + Debug + PartialEq;
type GasLimitDenominator: Unsigned + Clone + Sync + Send + Debug + PartialEq; type GasLimitDenominator: Unsigned + Clone + Sync + Send + Debug + PartialEq;
type MinGasLimit: Unsigned + Clone + Sync + Send + Debug + PartialEq; type MinGasLimit: Unsigned + Clone + Sync + Send + Debug + PartialEq;
type MaxExtraDataBytes: Unsigned + Clone + Sync + Send + Debug + PartialEq;
/* /*
* Derived values (set these CAREFULLY) * Derived values (set these CAREFULLY)
*/ */
@@ -262,6 +263,7 @@ impl EthSpec for MainnetEthSpec {
type BytesPerLogsBloom = U256; type BytesPerLogsBloom = U256;
type GasLimitDenominator = U1024; type GasLimitDenominator = U1024;
type MinGasLimit = U5000; type MinGasLimit = U5000;
type MaxExtraDataBytes = U32;
type SyncSubcommitteeSize = U128; // 512 committee size / 4 sync committee subnet count type SyncSubcommitteeSize = U128; // 512 committee size / 4 sync committee subnet count
type MaxPendingAttestations = U4096; // 128 max attestations * 32 slots per epoch type MaxPendingAttestations = U4096; // 128 max attestations * 32 slots per epoch
type SlotsPerEth1VotingPeriod = U2048; // 64 epochs * 32 slots per epoch type SlotsPerEth1VotingPeriod = U2048; // 64 epochs * 32 slots per epoch
@@ -308,7 +310,8 @@ impl EthSpec for MinimalEthSpec {
MaxTransactionsPerPayload, MaxTransactionsPerPayload,
BytesPerLogsBloom, BytesPerLogsBloom,
GasLimitDenominator, GasLimitDenominator,
MinGasLimit MinGasLimit,
MaxExtraDataBytes
}); });
fn default_spec() -> ChainSpec { fn default_spec() -> ChainSpec {

View File

@@ -57,6 +57,8 @@ pub struct ExecutionPayload<T: EthSpec> {
pub gas_used: u64, pub gas_used: u64,
#[serde(with = "eth2_serde_utils::quoted_u64")] #[serde(with = "eth2_serde_utils::quoted_u64")]
pub timestamp: u64, pub timestamp: u64,
#[serde(with = "ssz_types::serde_utils::hex_var_list")]
pub extra_data: VariableList<u8, T::MaxExtraDataBytes>,
pub base_fee_per_gas: Hash256, pub base_fee_per_gas: Hash256,
pub block_hash: Hash256, pub block_hash: Hash256,
#[test_random(default)] #[test_random(default)]
@@ -77,6 +79,7 @@ impl<T: EthSpec> ExecutionPayload<T> {
gas_limit: 0, gas_limit: 0,
gas_used: 0, gas_used: 0,
timestamp: 0, timestamp: 0,
extra_data: VariableList::empty(),
base_fee_per_gas: Hash256::zero(), base_fee_per_gas: Hash256::zero(),
block_hash: Hash256::zero(), block_hash: Hash256::zero(),
transactions: VariableList::empty(), transactions: VariableList::empty(),

View File

@@ -24,6 +24,8 @@ pub struct ExecutionPayloadHeader<T: EthSpec> {
pub gas_used: u64, pub gas_used: u64,
#[serde(with = "eth2_serde_utils::quoted_u64")] #[serde(with = "eth2_serde_utils::quoted_u64")]
pub timestamp: u64, pub timestamp: u64,
#[serde(with = "ssz_types::serde_utils::hex_var_list")]
pub extra_data: VariableList<u8, T::MaxExtraDataBytes>,
pub base_fee_per_gas: Hash256, pub base_fee_per_gas: Hash256,
pub block_hash: Hash256, pub block_hash: Hash256,
pub transactions_root: Hash256, pub transactions_root: Hash256,