mirror of
https://github.com/sigp/lighthouse.git
synced 2026-07-01 03:44:30 +00:00
Gloas alpha spec 11 (#9511)
Alpha spec 11 changes Co-Authored-By: Eitan Seri-Levi <eserilev@ucsc.edu> Co-Authored-By: Michael Sproul <michael@sigmaprime.io>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use crate::PayloadStatus;
|
||||
use safe_arith::ArithError;
|
||||
use types::{Epoch, ExecutionBlockHash, Hash256};
|
||||
use types::{Epoch, ExecutionBlockHash, Hash256, Slot};
|
||||
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub enum Error {
|
||||
@@ -63,6 +63,14 @@ pub enum Error {
|
||||
block_root: Hash256,
|
||||
payload_status: PayloadStatus,
|
||||
},
|
||||
/// `should_extend_payload` was called for a block whose slot is not the previous slot.
|
||||
///
|
||||
/// Spec equivalent: `assert store.blocks[root].slot + 1 == get_current_slot(store)`.
|
||||
ShouldExtendPayloadInvalidSlot {
|
||||
block_root: Hash256,
|
||||
block_slot: Slot,
|
||||
current_slot: Slot,
|
||||
},
|
||||
}
|
||||
|
||||
impl From<ArithError> for Error {
|
||||
|
||||
@@ -1564,7 +1564,12 @@ impl ProtoArray {
|
||||
Ok(fc_node.payload_status as u8)
|
||||
} else if fc_node.payload_status == PayloadStatus::Empty {
|
||||
Ok(1)
|
||||
} else if self.should_extend_payload::<E>(fc_node, proto_node, proposer_boost_root)? {
|
||||
} else if self.should_extend_payload::<E>(
|
||||
fc_node,
|
||||
proto_node,
|
||||
current_slot,
|
||||
proposer_boost_root,
|
||||
)? {
|
||||
Ok(2)
|
||||
} else {
|
||||
Ok(0)
|
||||
@@ -1614,8 +1619,17 @@ impl ProtoArray {
|
||||
&self,
|
||||
fc_node: &IndexedForkChoiceNode,
|
||||
proto_node: &ProtoNode,
|
||||
current_slot: Slot,
|
||||
proposer_boost_root: Hash256,
|
||||
) -> Result<bool, Error> {
|
||||
if proto_node.slot().saturating_add(1u64) != current_slot {
|
||||
return Err(Error::ShouldExtendPayloadInvalidSlot {
|
||||
block_root: fc_node.root,
|
||||
block_slot: proto_node.slot(),
|
||||
current_slot,
|
||||
});
|
||||
}
|
||||
|
||||
let Ok(node) = proto_node.as_v29() else {
|
||||
return Err(Error::InvalidNodeVariant {
|
||||
block_root: fc_node.root,
|
||||
|
||||
@@ -999,6 +999,7 @@ impl ProtoArrayForkChoice {
|
||||
pub fn should_extend_payload<E: EthSpec>(
|
||||
&self,
|
||||
block_root: &Hash256,
|
||||
current_slot: Slot,
|
||||
proposer_boost_root: Hash256,
|
||||
) -> Result<bool, String> {
|
||||
let block_index = self
|
||||
@@ -1017,7 +1018,7 @@ impl ProtoArrayForkChoice {
|
||||
payload_status: proto_node.get_parent_payload_status(),
|
||||
};
|
||||
self.proto_array
|
||||
.should_extend_payload::<E>(&fc_node, proto_node, proposer_boost_root)
|
||||
.should_extend_payload::<E>(&fc_node, proto_node, current_slot, proposer_boost_root)
|
||||
.map_err(|e| format!("{e:?}"))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user