diff --git a/beacon_node/execution_layer/src/engine_api.rs b/beacon_node/execution_layer/src/engine_api.rs index d6877b13a26..da52befa64f 100644 --- a/beacon_node/execution_layer/src/engine_api.rs +++ b/beacon_node/execution_layer/src/engine_api.rs @@ -109,7 +109,7 @@ pub struct ExecutionBlock { #[derive(Clone, Copy, Debug)] pub struct PayloadAttributes { pub timestamp: u64, - pub random: Hash256, + pub prev_randao: Hash256, pub suggested_fee_recipient: Address, } diff --git a/beacon_node/execution_layer/src/engine_api/http.rs b/beacon_node/execution_layer/src/engine_api/http.rs index ce4c3beff04..72387c865d5 100644 --- a/beacon_node/execution_layer/src/engine_api/http.rs +++ b/beacon_node/execution_layer/src/engine_api/http.rs @@ -288,7 +288,7 @@ mod test { "stateRoot": HASH_01, "receiptsRoot": HASH_00, "logsBloom": LOGS_BLOOM_01, - "random": HASH_01, + "prevRandao": HASH_01, "blockNumber": "0x0", "gasLimit": "0x1", "gasUsed": "0x2", @@ -439,7 +439,7 @@ mod test { }, Some(PayloadAttributes { timestamp: 5, - random: Hash256::zero(), + prev_randao: Hash256::zero(), suggested_fee_recipient: Address::repeat_byte(0), }), ) @@ -456,7 +456,7 @@ mod test { }, { "timestamp":"0x5", - "random": HASH_00, + "prevRandao": HASH_00, "suggestedFeeRecipient": ADDRESS_00 }] }), @@ -493,7 +493,7 @@ mod test { state_root: Hash256::repeat_byte(1), receipts_root: Hash256::repeat_byte(0), logs_bloom: vec![1; 256].into(), - random: Hash256::repeat_byte(1), + prev_randao: Hash256::repeat_byte(1), block_number: 0, gas_limit: 1, gas_used: 2, @@ -515,7 +515,7 @@ mod test { "stateRoot": HASH_01, "receiptsRoot": HASH_00, "logsBloom": LOGS_BLOOM_01, - "random": HASH_01, + "prevRandao": HASH_01, "blockNumber": "0x0", "gasLimit": "0x1", "gasUsed": "0x2", @@ -594,7 +594,7 @@ mod test { }, Some(PayloadAttributes { timestamp: 5, - random: Hash256::zero(), + prev_randao: Hash256::zero(), suggested_fee_recipient: Address::from_str("0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b").unwrap(), }) ) @@ -611,7 +611,7 @@ mod test { }, { "timestamp":"0x5", - "random": HASH_00, + "prevRandao": HASH_00, "suggestedFeeRecipient":"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" }] }) @@ -641,7 +641,7 @@ mod test { }, Some(PayloadAttributes { timestamp: 5, - random: Hash256::zero(), + prev_randao: Hash256::zero(), suggested_fee_recipient: Address::from_str("0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b").unwrap(), }) ) @@ -685,7 +685,7 @@ mod test { "stateRoot":"0xca3149fa9e37db08d1cd49c9061db1002ef1cd58db2210f2115c8c989b2bdf45", "receiptsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "logsBloom": LOGS_BLOOM_00, - "random": HASH_00, + "prevRandao": HASH_00, "blockNumber":"0x1", "gasLimit":"0x1c95111", "gasUsed":"0x0", @@ -708,7 +708,7 @@ mod test { state_root: Hash256::from_str("0xca3149fa9e37db08d1cd49c9061db1002ef1cd58db2210f2115c8c989b2bdf45").unwrap(), receipts_root: Hash256::from_str("0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421").unwrap(), logs_bloom: vec![0; 256].into(), - random: Hash256::zero(), + prev_randao: Hash256::zero(), block_number: 1, gas_limit: u64::from_str_radix("1c95111",16).unwrap(), gas_used: 0, @@ -733,7 +733,7 @@ mod test { state_root: Hash256::from_str("0xca3149fa9e37db08d1cd49c9061db1002ef1cd58db2210f2115c8c989b2bdf45").unwrap(), receipts_root: Hash256::from_str("0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421").unwrap(), logs_bloom: vec![0; 256].into(), - random: Hash256::zero(), + prev_randao: Hash256::zero(), block_number: 1, gas_limit: u64::from_str_radix("1c9c380",16).unwrap(), gas_used: 0, @@ -755,7 +755,7 @@ mod test { "stateRoot":"0xca3149fa9e37db08d1cd49c9061db1002ef1cd58db2210f2115c8c989b2bdf45", "receiptsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "logsBloom": LOGS_BLOOM_00, - "random": HASH_00, + "prevRandao": HASH_00, "blockNumber":"0x1", "gasLimit":"0x1c9c380", "gasUsed":"0x0", 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 03d981d439d..0cb25643f0c 100644 --- a/beacon_node/execution_layer/src/engine_api/json_structures.rs +++ b/beacon_node/execution_layer/src/engine_api/json_structures.rs @@ -64,7 +64,7 @@ pub struct JsonExecutionPayloadV1 { pub receipts_root: Hash256, #[serde(with = "serde_logs_bloom")] pub logs_bloom: FixedVector, - pub random: Hash256, + pub prev_randao: Hash256, #[serde(with = "eth2_serde_utils::u64_hex_be")] pub block_number: u64, #[serde(with = "eth2_serde_utils::u64_hex_be")] @@ -91,7 +91,7 @@ impl From> for JsonExecutionPayloadV1 { state_root, receipts_root, logs_bloom, - random, + prev_randao, block_number, gas_limit, gas_used, @@ -108,7 +108,7 @@ impl From> for JsonExecutionPayloadV1 { state_root, receipts_root, logs_bloom, - random, + prev_randao, block_number, gas_limit, gas_used, @@ -130,7 +130,7 @@ impl From> for ExecutionPayload { state_root, receipts_root, logs_bloom, - random, + prev_randao, block_number, gas_limit, gas_used, @@ -147,7 +147,7 @@ impl From> for ExecutionPayload { state_root, receipts_root, logs_bloom, - random, + prev_randao, block_number, gas_limit, gas_used, @@ -165,7 +165,7 @@ impl From> for ExecutionPayload { pub struct JsonPayloadAttributesV1 { #[serde(with = "eth2_serde_utils::u64_hex_be")] pub timestamp: u64, - pub random: Hash256, + pub prev_randao: Hash256, pub suggested_fee_recipient: Address, } @@ -174,13 +174,13 @@ impl From for JsonPayloadAttributesV1 { // Use this verbose deconstruction pattern to ensure no field is left unused. let PayloadAttributes { timestamp, - random, + prev_randao, suggested_fee_recipient, } = p; Self { timestamp, - random, + prev_randao, suggested_fee_recipient, } } @@ -191,13 +191,13 @@ impl From for PayloadAttributes { // Use this verbose deconstruction pattern to ensure no field is left unused. let JsonPayloadAttributesV1 { timestamp, - random, + prev_randao, suggested_fee_recipient, } = j; Self { timestamp, - random, + prev_randao, suggested_fee_recipient, } } diff --git a/beacon_node/execution_layer/src/engines.rs b/beacon_node/execution_layer/src/engines.rs index 03801f3168d..35f74fee26f 100644 --- a/beacon_node/execution_layer/src/engines.rs +++ b/beacon_node/execution_layer/src/engines.rs @@ -50,7 +50,7 @@ impl Logging { struct PayloadIdCacheKey { pub head_block_hash: Hash256, pub timestamp: u64, - pub random: Hash256, + pub prev_randao: Hash256, pub suggested_fee_recipient: Address, } @@ -77,7 +77,7 @@ impl Engine { &self, head_block_hash: Hash256, timestamp: u64, - random: Hash256, + prev_randao: Hash256, suggested_fee_recipient: Address, ) -> Option { self.payload_id_cache @@ -86,7 +86,7 @@ impl Engine { .get(&PayloadIdCacheKey { head_block_hash, timestamp, - random, + prev_randao, suggested_fee_recipient, }) .cloned() @@ -393,7 +393,7 @@ impl PayloadIdCacheKey { Self { head_block_hash: state.head_block_hash, timestamp: attributes.timestamp, - random: attributes.random, + prev_randao: attributes.prev_randao, suggested_fee_recipient: attributes.suggested_fee_recipient, } } diff --git a/beacon_node/execution_layer/src/lib.rs b/beacon_node/execution_layer/src/lib.rs index 10ae6b3eb02..995d910a630 100644 --- a/beacon_node/execution_layer/src/lib.rs +++ b/beacon_node/execution_layer/src/lib.rs @@ -386,7 +386,7 @@ impl ExecutionLayer { &self, parent_hash: Hash256, timestamp: u64, - random: Hash256, + prev_randao: Hash256, finalized_block_hash: Hash256, proposer_index: u64, ) -> Result, Error> { @@ -396,14 +396,14 @@ impl ExecutionLayer { self.log(), "Issuing engine_getPayload"; "suggested_fee_recipient" => ?suggested_fee_recipient, - "random" => ?random, + "prev_randao" => ?prev_randao, "timestamp" => timestamp, "parent_hash" => ?parent_hash, ); self.engines() .first_success(|engine| async move { let payload_id = if let Some(id) = engine - .get_payload_id(parent_hash, timestamp, random, suggested_fee_recipient) + .get_payload_id(parent_hash, timestamp, prev_randao, suggested_fee_recipient) .await { // The payload id has been cached for this engine. @@ -422,7 +422,7 @@ impl ExecutionLayer { }; let payload_attributes = PayloadAttributes { timestamp, - random, + prev_randao, suggested_fee_recipient, }; 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 8fd6ebfcd19..56730e13840 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 @@ -327,7 +327,7 @@ impl ExecutionBlockGenerator { receipts_root: Hash256::repeat_byte(42), state_root: Hash256::repeat_byte(43), logs_bloom: vec![0; 256].into(), - random: attributes.random, + prev_randao: attributes.prev_randao, block_number: parent.block_number() + 1, gas_limit: GAS_LIMIT, gas_used: GAS_USED, 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 0622da473fc..215c1d3c764 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 @@ -111,7 +111,7 @@ impl MockExecutionLayer { let parent_hash = latest_execution_block.block_hash(); let block_number = latest_execution_block.block_number() + 1; let timestamp = block_number; - let random = Hash256::from_low_u64_be(block_number); + let prev_randao = Hash256::from_low_u64_be(block_number); let finalized_block_hash = parent_hash; self.el @@ -120,7 +120,7 @@ impl MockExecutionLayer { Hash256::zero(), Some(PayloadAttributes { timestamp, - random, + prev_randao, suggested_fee_recipient: Address::repeat_byte(42), }), ) @@ -133,7 +133,7 @@ impl MockExecutionLayer { .get_payload::( parent_hash, timestamp, - random, + prev_randao, finalized_block_hash, validator_index, ) @@ -143,7 +143,7 @@ impl MockExecutionLayer { assert_eq!(payload.parent_hash, parent_hash); assert_eq!(payload.block_number, block_number); assert_eq!(payload.timestamp, timestamp); - assert_eq!(payload.random, random); + assert_eq!(payload.prev_randao, prev_randao); let (payload_response, latest_valid_hash) = self.el.notify_new_payload(&payload).await.unwrap(); diff --git a/consensus/state_processing/src/per_block_processing.rs b/consensus/state_processing/src/per_block_processing.rs index a874ce64284..f87756c122e 100644 --- a/consensus/state_processing/src/per_block_processing.rs +++ b/consensus/state_processing/src/per_block_processing.rs @@ -329,10 +329,10 @@ pub fn partially_verify_execution_payload( ); } block_verify!( - payload.random == *state.get_randao_mix(state.current_epoch())?, + payload.prev_randao == *state.get_randao_mix(state.current_epoch())?, BlockProcessingError::ExecutionRandaoMismatch { expected: *state.get_randao_mix(state.current_epoch())?, - found: payload.random, + found: payload.prev_randao, } ); @@ -368,7 +368,7 @@ pub fn process_execution_payload( state_root: payload.state_root, receipts_root: payload.receipts_root, logs_bloom: payload.logs_bloom.clone(), - random: payload.random, + prev_randao: payload.prev_randao, block_number: payload.block_number, gas_limit: payload.gas_limit, gas_used: payload.gas_used, diff --git a/consensus/types/src/execution_payload.rs b/consensus/types/src/execution_payload.rs index 781fb7460f1..023b9efc9f2 100644 --- a/consensus/types/src/execution_payload.rs +++ b/consensus/types/src/execution_payload.rs @@ -21,7 +21,7 @@ pub struct ExecutionPayload { pub receipts_root: Hash256, #[serde(with = "ssz_types::serde_utils::hex_fixed_vec")] pub logs_bloom: FixedVector, - pub random: Hash256, + pub prev_randao: Hash256, #[serde(with = "eth2_serde_utils::quoted_u64")] pub block_number: u64, #[serde(with = "eth2_serde_utils::quoted_u64")] diff --git a/consensus/types/src/execution_payload_header.rs b/consensus/types/src/execution_payload_header.rs index aa022f6420c..784a00d5516 100644 --- a/consensus/types/src/execution_payload_header.rs +++ b/consensus/types/src/execution_payload_header.rs @@ -15,7 +15,7 @@ pub struct ExecutionPayloadHeader { pub receipts_root: Hash256, #[serde(with = "ssz_types::serde_utils::hex_fixed_vec")] pub logs_bloom: FixedVector, - pub random: Hash256, + pub prev_randao: Hash256, #[serde(with = "eth2_serde_utils::quoted_u64")] pub block_number: u64, #[serde(with = "eth2_serde_utils::quoted_u64")] diff --git a/lcli/src/create_payload_header.rs b/lcli/src/create_payload_header.rs index 814a57f264c..1c68d48b886 100644 --- a/lcli/src/create_payload_header.rs +++ b/lcli/src/create_payload_header.rs @@ -23,7 +23,7 @@ pub fn run(matches: &ArgMatches) -> Result<(), String> { base_fee_per_gas, timestamp: genesis_time, block_hash: eth1_block_hash, - random: eth1_block_hash, + prev_randao: eth1_block_hash, ..ExecutionPayloadHeader::default() }; let mut file = File::create(file_name).map_err(|_| "Unable to create file".to_string())?; diff --git a/testing/execution_engine_integration/src/test_rig.rs b/testing/execution_engine_integration/src/test_rig.rs index e8253036fbf..1ca588231a8 100644 --- a/testing/execution_engine_integration/src/test_rig.rs +++ b/testing/execution_engine_integration/src/test_rig.rs @@ -138,7 +138,7 @@ impl TestRig { let parent_hash = terminal_pow_block_hash; let timestamp = timestamp_now(); - let random = Hash256::zero(); + let prev_randao = Hash256::zero(); let finalized_block_hash = Hash256::zero(); let proposer_index = 0; let valid_payload = self @@ -147,7 +147,7 @@ impl TestRig { .get_payload::( parent_hash, timestamp, - random, + prev_randao, finalized_block_hash, proposer_index, ) @@ -210,7 +210,7 @@ impl TestRig { */ let mut invalid_payload = valid_payload.clone(); - invalid_payload.random = Hash256::from_low_u64_be(42); + invalid_payload.prev_randao = Hash256::from_low_u64_be(42); let (status, _) = self .ee_a .execution_layer @@ -230,7 +230,7 @@ impl TestRig { let parent_hash = valid_payload.block_hash; let timestamp = valid_payload.timestamp + 1; - let random = Hash256::zero(); + let prev_randao = Hash256::zero(); let finalized_block_hash = Hash256::zero(); let proposer_index = 0; let second_payload = self @@ -239,7 +239,7 @@ impl TestRig { .get_payload::( parent_hash, timestamp, - random, + prev_randao, finalized_block_hash, proposer_index, ) @@ -269,7 +269,7 @@ impl TestRig { let finalized_block_hash = Hash256::zero(); let payload_attributes = Some(PayloadAttributes { timestamp: second_payload.timestamp + 1, - random: Hash256::zero(), + prev_randao: Hash256::zero(), suggested_fee_recipient: Address::zero(), }); let (status, _) = self