diff --git a/light-client/src/client.rs b/light-client/src/client.rs index 7c8001e..65176fb 100644 --- a/light-client/src/client.rs +++ b/light-client/src/client.rs @@ -710,16 +710,15 @@ mod test { #[rstest] #[case::localnet(localnet())] fn test_success_update_state_continuous(#[case] hp: Box) { - let client = ParliaLightClient::default(); let client_id = ClientId::new(&client.client_type(), 1).unwrap(); - let header_groups= hp.success_update_client_continuous_input(); + let header_groups = hp.success_update_client_continuous_input(); for headers in header_groups { let any: Any = headers.first().unwrap().clone().try_into().unwrap(); - let first= Header::try_from(any.clone()).unwrap(); + let first = Header::try_from(any.clone()).unwrap(); if !first.eth_header().target.is_epoch() { - panic!("first header of each group must be epoch") ; + panic!("first header of each group must be epoch"); } // create client let mut mock_consensus_state = BTreeMap::new(); @@ -745,18 +744,20 @@ mod test { let result = client.update_client(&ctx, client_id.clone(), any).unwrap(); match result { UpdateClientResult::UpdateState(state) => { - ctx.consensus_state.insert(header.height(), state.new_any_consensus_state.try_into().unwrap()); + ctx.consensus_state.insert( + header.height(), + state.new_any_consensus_state.try_into().unwrap(), + ); cs.latest_height = state.height; } - _ => unreachable!("invalid update_client result") + _ => unreachable!("invalid update_client result"), } } let any: Any = headers.last().unwrap().clone().try_into().unwrap(); - let last= Header::try_from(any.clone()).unwrap(); + let last = Header::try_from(any.clone()).unwrap(); assert_eq!(cs.latest_height, last.height()); } - } #[rstest] diff --git a/light-client/src/header/eth_header.rs b/light-client/src/header/eth_header.rs index 13cfd56..919a146 100644 --- a/light-client/src/header/eth_header.rs +++ b/light-client/src/header/eth_header.rs @@ -304,6 +304,7 @@ impl TryFrom for ETHHeader { let withdrawals_hash: Option> = rlp.try_next_as_val().map(Some).unwrap_or(None); let blob_gas_used: Option = rlp.try_next_as_val().map(Some).unwrap_or(None); let excess_blob_gas: Option = rlp.try_next_as_val().map(Some).unwrap_or(None); + let parent_beacon_root: Option> = rlp.try_next_as_val().map(Some).unwrap_or(None); // Check that the extra-data contains the vanity, validators and signature let extra_size = extra_data.len(); @@ -359,11 +360,12 @@ impl TryFrom for ETHHeader { stream.append(&extra_data); stream.append(&mix_digest); stream.append(&nonce); - // https://github.com/bnb-chain/bsc/blob/4b45c5993c87d12c520a89e0d3d059e4d6b6eb9c/core/types/gen_header_rlp.go#L57 + if base_fee_per_gas.is_some() || withdrawals_hash.is_some() || blob_gas_used.is_some() || excess_blob_gas.is_some() + || parent_beacon_root.is_some() { if let Some(v) = base_fee_per_gas { stream.append(&v); @@ -371,27 +373,38 @@ impl TryFrom for ETHHeader { stream.append_empty_data(); } } - if withdrawals_hash.is_some() || blob_gas_used.is_some() || excess_blob_gas.is_some() { + if withdrawals_hash.is_some() + || blob_gas_used.is_some() + || excess_blob_gas.is_some() + || parent_beacon_root.is_some() + { if let Some(v) = withdrawals_hash { stream.append(&v); } else { stream.append_empty_data(); } } - if blob_gas_used.is_some() || excess_blob_gas.is_some() { + if blob_gas_used.is_some() || excess_blob_gas.is_some() || parent_beacon_root.is_some() { if let Some(v) = blob_gas_used { stream.append(&v); } else { stream.append_empty_data(); } } - if excess_blob_gas.is_some() { + if excess_blob_gas.is_some() || parent_beacon_root.is_some() { if let Some(v) = excess_blob_gas { stream.append(&v); } else { stream.append_empty_data(); } } + if parent_beacon_root.is_some() { + if let Some(v) = parent_beacon_root { + stream.append(&v); + } else { + stream.append_empty_data(); + } + } stream.finalize_unbounded_list(); let buffer_vec: Vec = stream.out().to_vec(); let hash: Hash = keccak_256(&buffer_vec);