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

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