mirror of
https://github.com/sigp/lighthouse.git
synced 2026-07-01 20:04:41 +00:00
Merge remote-tracking branch 'upstream/unstable' into electra_attestation_changes
This commit is contained in:
@@ -2424,6 +2424,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
proposer_slashing: ProposerSlashing,
|
||||
) -> Result<ObservationOutcome<ProposerSlashing, T::EthSpec>, Error> {
|
||||
let wall_clock_state = self.wall_clock_state()?;
|
||||
|
||||
Ok(self.observed_proposer_slashings.lock().verify_and_observe(
|
||||
proposer_slashing,
|
||||
&wall_clock_state,
|
||||
@@ -2436,6 +2437,14 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
&self,
|
||||
proposer_slashing: SigVerifiedOp<ProposerSlashing, T::EthSpec>,
|
||||
) {
|
||||
if let Some(event_handler) = self.event_handler.as_ref() {
|
||||
if event_handler.has_proposer_slashing_subscribers() {
|
||||
event_handler.register(EventKind::ProposerSlashing(Box::new(
|
||||
proposer_slashing.clone().into_inner(),
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
||||
if self.eth1_chain.is_some() {
|
||||
self.op_pool.insert_proposer_slashing(proposer_slashing)
|
||||
}
|
||||
@@ -2447,6 +2456,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
attester_slashing: AttesterSlashing<T::EthSpec>,
|
||||
) -> Result<ObservationOutcome<AttesterSlashing<T::EthSpec>, T::EthSpec>, Error> {
|
||||
let wall_clock_state = self.wall_clock_state()?;
|
||||
|
||||
Ok(self.observed_attester_slashings.lock().verify_and_observe(
|
||||
attester_slashing,
|
||||
&wall_clock_state,
|
||||
@@ -2467,6 +2477,14 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
.fork_choice_write_lock()
|
||||
.on_attester_slashing(attester_slashing.as_inner().to_ref());
|
||||
|
||||
if let Some(event_handler) = self.event_handler.as_ref() {
|
||||
if event_handler.has_attester_slashing_subscribers() {
|
||||
event_handler.register(EventKind::AttesterSlashing(Box::new(
|
||||
attester_slashing.clone().into_inner(),
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
||||
// Add to the op pool (if we have the ability to propose blocks).
|
||||
if self.eth1_chain.is_some() {
|
||||
self.op_pool.insert_attester_slashing(attester_slashing)
|
||||
@@ -2523,7 +2541,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
/// Check if the current slot is greater than or equal to the Capella fork epoch.
|
||||
pub fn current_slot_is_post_capella(&self) -> Result<bool, Error> {
|
||||
let current_fork = self.spec.fork_name_at_slot::<T::EthSpec>(self.slot()?);
|
||||
if let ForkName::Base | ForkName::Altair | ForkName::Merge = current_fork {
|
||||
if let ForkName::Base | ForkName::Altair | ForkName::Bellatrix = current_fork {
|
||||
Ok(false)
|
||||
} else {
|
||||
Ok(true)
|
||||
@@ -3839,7 +3857,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
if block.slot() + 2 * T::EthSpec::slots_per_epoch() >= current_slot {
|
||||
metrics::observe(
|
||||
&metrics::OPERATIONS_PER_BLOCK_ATTESTATION,
|
||||
block.body().attestations().count() as f64,
|
||||
block.body().attestations_len() as f64,
|
||||
);
|
||||
|
||||
if let Ok(sync_aggregate) = block.body().sync_aggregate() {
|
||||
@@ -4399,12 +4417,6 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
if cached_head.head_block_root() == parent_block_root {
|
||||
(Cow::Borrowed(head_state), cached_head.head_state_root())
|
||||
} else {
|
||||
info!(
|
||||
self.log,
|
||||
"Missed snapshot cache during withdrawals calculation";
|
||||
"slot" => proposal_slot,
|
||||
"parent_block_root" => ?parent_block_root
|
||||
);
|
||||
let block = self
|
||||
.get_blinded_block(&parent_block_root)?
|
||||
.ok_or(Error::MissingBeaconBlock(parent_block_root))?;
|
||||
@@ -4825,7 +4837,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
// allows it to run concurrently with things like attestation packing.
|
||||
let prepare_payload_handle = match &state {
|
||||
BeaconState::Base(_) | BeaconState::Altair(_) => None,
|
||||
BeaconState::Merge(_)
|
||||
BeaconState::Bellatrix(_)
|
||||
| BeaconState::Capella(_)
|
||||
| BeaconState::Deneb(_)
|
||||
| BeaconState::Electra(_) => {
|
||||
@@ -5067,7 +5079,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
match &state {
|
||||
BeaconState::Base(_)
|
||||
| BeaconState::Altair(_)
|
||||
| BeaconState::Merge(_)
|
||||
| BeaconState::Bellatrix(_)
|
||||
| BeaconState::Capella(_)
|
||||
| BeaconState::Deneb(_) => {
|
||||
if !attestations_electra.is_empty() {
|
||||
@@ -5152,17 +5164,17 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
None,
|
||||
Uint256::zero(),
|
||||
),
|
||||
BeaconState::Merge(_) => {
|
||||
BeaconState::Bellatrix(_) => {
|
||||
let block_proposal_contents =
|
||||
block_contents.ok_or(BlockProductionError::MissingExecutionPayload)?;
|
||||
let execution_payload_value = block_proposal_contents.block_value().to_owned();
|
||||
(
|
||||
BeaconBlock::Merge(BeaconBlockMerge {
|
||||
BeaconBlock::Bellatrix(BeaconBlockBellatrix {
|
||||
slot,
|
||||
proposer_index,
|
||||
parent_root,
|
||||
state_root: Hash256::zero(),
|
||||
body: BeaconBlockBodyMerge {
|
||||
body: BeaconBlockBodyBellatrix {
|
||||
randao_reveal,
|
||||
eth1_data,
|
||||
graffiti,
|
||||
@@ -5612,7 +5624,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
} else {
|
||||
let prepare_slot_fork = self.spec.fork_name_at_slot::<T::EthSpec>(prepare_slot);
|
||||
let withdrawals = match prepare_slot_fork {
|
||||
ForkName::Base | ForkName::Altair | ForkName::Merge => None,
|
||||
ForkName::Base | ForkName::Altair | ForkName::Bellatrix => None,
|
||||
ForkName::Capella | ForkName::Deneb | ForkName::Electra => {
|
||||
let chain = self.clone();
|
||||
self.spawn_blocking_handle(
|
||||
@@ -5627,7 +5639,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
};
|
||||
|
||||
let parent_beacon_block_root = match prepare_slot_fork {
|
||||
ForkName::Base | ForkName::Altair | ForkName::Merge | ForkName::Capella => None,
|
||||
ForkName::Base | ForkName::Altair | ForkName::Bellatrix | ForkName::Capella => None,
|
||||
ForkName::Deneb | ForkName::Electra => {
|
||||
Some(pre_payload_attributes.parent_beacon_block_root)
|
||||
}
|
||||
@@ -6670,7 +6682,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
|
||||
match fork_name {
|
||||
ForkName::Altair
|
||||
| ForkName::Merge
|
||||
| ForkName::Bellatrix
|
||||
| ForkName::Capella
|
||||
| ForkName::Deneb
|
||||
| ForkName::Electra => {
|
||||
|
||||
Reference in New Issue
Block a user