Skip to content

Commit 10b263f

Browse files
michaelsproulpaulhauner
authored andcommitted
Update merge consensus to v1.1.0-beta.5 (#2630)
1 parent c10e8ce commit 10b263f

File tree

4 files changed

+28
-16
lines changed

4 files changed

+28
-16
lines changed

consensus/state_processing/src/per_block_processing.rs

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,17 @@ pub fn per_block_processing<T: EthSpec>(
135135
state.build_committee_cache(RelativeEpoch::Previous, spec)?;
136136
state.build_committee_cache(RelativeEpoch::Current, spec)?;
137137

138+
// The call to the `process_execution_payload` must happen before the call to the
139+
// `process_randao` as the former depends on the `randao_mix` computed with the reveal of the
140+
// previous block.
141+
if is_execution_enabled(state, block.body()) {
142+
let payload = block
143+
.body()
144+
.execution_payload()
145+
.ok_or(BlockProcessingError::IncorrectStateType)?;
146+
process_execution_payload(state, payload, spec)?;
147+
}
148+
138149
process_randao(state, block, verify_randao, spec)?;
139150
process_eth1_data(state, block.body().eth1_data())?;
140151
process_operations(state, block.body(), proposer_index, verify_signatures, spec)?;
@@ -149,14 +160,6 @@ pub fn per_block_processing<T: EthSpec>(
149160
)?;
150161
}
151162

152-
if is_execution_enabled(state, block.body()) {
153-
let payload = block
154-
.body()
155-
.execution_payload()
156-
.ok_or(BlockProcessingError::IncorrectStateType)?;
157-
process_execution_payload(state, payload, spec)?;
158-
}
159-
160163
Ok(())
161164
}
162165

@@ -352,13 +355,6 @@ pub fn process_execution_payload<T: EthSpec>(
352355
found: payload.block_number,
353356
}
354357
);
355-
block_verify!(
356-
payload.random == *state.get_randao_mix(state.current_epoch())?,
357-
BlockProcessingError::ExecutionRandaoMismatch {
358-
expected: *state.get_randao_mix(state.current_epoch())?,
359-
found: payload.random,
360-
}
361-
);
362358
block_verify!(
363359
is_valid_gas_limit(payload, state.latest_execution_payload_header()?)?,
364360
BlockProcessingError::ExecutionInvalidGasLimit {
@@ -367,6 +363,13 @@ pub fn process_execution_payload<T: EthSpec>(
367363
}
368364
);
369365
}
366+
block_verify!(
367+
payload.random == *state.get_randao_mix(state.current_epoch())?,
368+
BlockProcessingError::ExecutionRandaoMismatch {
369+
expected: *state.get_randao_mix(state.current_epoch())?,
370+
found: payload.random,
371+
}
372+
);
370373

371374
let timestamp = compute_timestamp_at_slot(state, spec)?;
372375
block_verify!(
@@ -388,6 +391,7 @@ pub fn process_execution_payload<T: EthSpec>(
388391
gas_limit: payload.gas_limit,
389392
gas_used: payload.gas_used,
390393
timestamp: payload.timestamp,
394+
extra_data: payload.extra_data.clone(),
391395
base_fee_per_gas: payload.base_fee_per_gas,
392396
block_hash: payload.block_hash,
393397
transactions_root: payload.transactions.tree_hash_root(),

consensus/types/src/eth_spec.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ pub trait EthSpec: 'static + Default + Sync + Send + Clone + Debug + PartialEq +
9191
type BytesPerLogsBloom: Unsigned + Clone + Sync + Send + Debug + PartialEq;
9292
type GasLimitDenominator: Unsigned + Clone + Sync + Send + Debug + PartialEq;
9393
type MinGasLimit: Unsigned + Clone + Sync + Send + Debug + PartialEq;
94+
type MaxExtraDataBytes: Unsigned + Clone + Sync + Send + Debug + PartialEq;
9495
/*
9596
* Derived values (set these CAREFULLY)
9697
*/
@@ -262,6 +263,7 @@ impl EthSpec for MainnetEthSpec {
262263
type BytesPerLogsBloom = U256;
263264
type GasLimitDenominator = U1024;
264265
type MinGasLimit = U5000;
266+
type MaxExtraDataBytes = U32;
265267
type SyncSubcommitteeSize = U128; // 512 committee size / 4 sync committee subnet count
266268
type MaxPendingAttestations = U4096; // 128 max attestations * 32 slots per epoch
267269
type SlotsPerEth1VotingPeriod = U2048; // 64 epochs * 32 slots per epoch
@@ -308,7 +310,8 @@ impl EthSpec for MinimalEthSpec {
308310
MaxTransactionsPerPayload,
309311
BytesPerLogsBloom,
310312
GasLimitDenominator,
311-
MinGasLimit
313+
MinGasLimit,
314+
MaxExtraDataBytes
312315
});
313316

314317
fn default_spec() -> ChainSpec {

consensus/types/src/execution_payload.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ pub struct ExecutionPayload<T: EthSpec> {
5757
pub gas_used: u64,
5858
#[serde(with = "eth2_serde_utils::quoted_u64")]
5959
pub timestamp: u64,
60+
#[serde(with = "ssz_types::serde_utils::hex_var_list")]
61+
pub extra_data: VariableList<u8, T::MaxExtraDataBytes>,
6062
pub base_fee_per_gas: Hash256,
6163
pub block_hash: Hash256,
6264
#[test_random(default)]
@@ -77,6 +79,7 @@ impl<T: EthSpec> ExecutionPayload<T> {
7779
gas_limit: 0,
7880
gas_used: 0,
7981
timestamp: 0,
82+
extra_data: VariableList::empty(),
8083
base_fee_per_gas: Hash256::zero(),
8184
block_hash: Hash256::zero(),
8285
transactions: VariableList::empty(),

consensus/types/src/execution_payload_header.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ pub struct ExecutionPayloadHeader<T: EthSpec> {
2424
pub gas_used: u64,
2525
#[serde(with = "eth2_serde_utils::quoted_u64")]
2626
pub timestamp: u64,
27+
#[serde(with = "ssz_types::serde_utils::hex_var_list")]
28+
pub extra_data: VariableList<u8, T::MaxExtraDataBytes>,
2729
pub base_fee_per_gas: Hash256,
2830
pub block_hash: Hash256,
2931
pub transactions_root: Hash256,

0 commit comments

Comments
 (0)