mirror of
https://github.com/sigp/lighthouse.git
synced 2026-07-03 04:44:28 +00:00
fix migration SszContainer scripts
This commit is contained in:
@@ -1722,7 +1722,7 @@ where
|
|||||||
PersistedForkChoice {
|
PersistedForkChoice {
|
||||||
proto_array: self
|
proto_array: self
|
||||||
.proto_array()
|
.proto_array()
|
||||||
.as_ssz_container(self.justified_checkpoint(), self.finalized_checkpoint()),
|
.as_ssz_container(),
|
||||||
queued_attestations: self.queued_attestations().to_vec(),
|
queued_attestations: self.queued_attestations().to_vec(),
|
||||||
queued_payload_attestations: self.queued_payload_attestations.clone(),
|
queued_payload_attestations: self.queued_payload_attestations.clone(),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -522,8 +522,7 @@ fn get_checkpoint(i: u64) -> Checkpoint {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn check_bytes_round_trip(original: &ProtoArrayForkChoice) {
|
fn check_bytes_round_trip(original: &ProtoArrayForkChoice) {
|
||||||
// The checkpoint are ignored `ProtoArrayForkChoice::from_bytes` so any value is ok
|
let bytes = original.as_bytes();
|
||||||
let bytes = original.as_bytes(Checkpoint::default(), Checkpoint::default());
|
|
||||||
let decoded = ProtoArrayForkChoice::from_bytes(&bytes, original.balances.clone())
|
let decoded = ProtoArrayForkChoice::from_bytes(&bytes, original.balances.clone())
|
||||||
.expect("fork choice should decode from bytes");
|
.expect("fork choice should decode from bytes");
|
||||||
assert!(
|
assert!(
|
||||||
|
|||||||
@@ -1037,18 +1037,14 @@ impl ProtoArrayForkChoice {
|
|||||||
|
|
||||||
pub fn as_ssz_container(
|
pub fn as_ssz_container(
|
||||||
&self,
|
&self,
|
||||||
justified_checkpoint: Checkpoint,
|
|
||||||
finalized_checkpoint: Checkpoint,
|
|
||||||
) -> SszContainer {
|
) -> SszContainer {
|
||||||
SszContainer::from_proto_array(self, justified_checkpoint, finalized_checkpoint)
|
SszContainer::from_proto_array(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn as_bytes(
|
pub fn as_bytes(
|
||||||
&self,
|
&self,
|
||||||
justified_checkpoint: Checkpoint,
|
|
||||||
finalized_checkpoint: Checkpoint,
|
|
||||||
) -> Vec<u8> {
|
) -> Vec<u8> {
|
||||||
self.as_ssz_container(justified_checkpoint, finalized_checkpoint)
|
self.as_ssz_container()
|
||||||
.as_ssz_bytes()
|
.as_ssz_bytes()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,10 +49,6 @@ pub struct SszContainerV28 {
|
|||||||
pub struct SszContainerV29 {
|
pub struct SszContainerV29 {
|
||||||
pub votes: Vec<VoteTracker>,
|
pub votes: Vec<VoteTracker>,
|
||||||
pub prune_threshold: usize,
|
pub prune_threshold: usize,
|
||||||
// Deprecated, remove in a future schema migration
|
|
||||||
justified_checkpoint: Checkpoint,
|
|
||||||
// Deprecated, remove in a future schema migration
|
|
||||||
finalized_checkpoint: Checkpoint,
|
|
||||||
pub nodes: Vec<ProtoNode>,
|
pub nodes: Vec<ProtoNode>,
|
||||||
pub indices: Vec<(Hash256, usize)>,
|
pub indices: Vec<(Hash256, usize)>,
|
||||||
pub previous_proposer_boost: ProposerBoost,
|
pub previous_proposer_boost: ProposerBoost,
|
||||||
@@ -61,16 +57,12 @@ pub struct SszContainerV29 {
|
|||||||
impl SszContainerV29 {
|
impl SszContainerV29 {
|
||||||
pub fn from_proto_array(
|
pub fn from_proto_array(
|
||||||
from: &ProtoArrayForkChoice,
|
from: &ProtoArrayForkChoice,
|
||||||
justified_checkpoint: Checkpoint,
|
|
||||||
finalized_checkpoint: Checkpoint,
|
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let proto_array = &from.proto_array;
|
let proto_array = &from.proto_array;
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
votes: from.votes.0.clone(),
|
votes: from.votes.0.clone(),
|
||||||
prune_threshold: proto_array.prune_threshold,
|
prune_threshold: proto_array.prune_threshold,
|
||||||
justified_checkpoint,
|
|
||||||
finalized_checkpoint,
|
|
||||||
nodes: proto_array.nodes.clone(),
|
nodes: proto_array.nodes.clone(),
|
||||||
indices: proto_array.indices.iter().map(|(k, v)| (*k, *v)).collect(),
|
indices: proto_array.indices.iter().map(|(k, v)| (*k, *v)).collect(),
|
||||||
previous_proposer_boost: proto_array.previous_proposer_boost,
|
previous_proposer_boost: proto_array.previous_proposer_boost,
|
||||||
@@ -134,8 +126,6 @@ impl From<SszContainerV28> for SszContainerV29 {
|
|||||||
Self {
|
Self {
|
||||||
votes: v28.votes,
|
votes: v28.votes,
|
||||||
prune_threshold: v28.prune_threshold,
|
prune_threshold: v28.prune_threshold,
|
||||||
justified_checkpoint: v28.justified_checkpoint,
|
|
||||||
finalized_checkpoint: v28.finalized_checkpoint,
|
|
||||||
nodes: v28.nodes.into_iter().map(ProtoNode::V17).collect(),
|
nodes: v28.nodes.into_iter().map(ProtoNode::V17).collect(),
|
||||||
indices: v28.indices,
|
indices: v28.indices,
|
||||||
previous_proposer_boost: v28.previous_proposer_boost,
|
previous_proposer_boost: v28.previous_proposer_boost,
|
||||||
@@ -149,8 +139,10 @@ impl From<SszContainerV29> for SszContainerV28 {
|
|||||||
Self {
|
Self {
|
||||||
votes: v29.votes,
|
votes: v29.votes,
|
||||||
prune_threshold: v29.prune_threshold,
|
prune_threshold: v29.prune_threshold,
|
||||||
justified_checkpoint: v29.justified_checkpoint,
|
// These checkpoints are not consumed in v28 paths since the upgrade from v17,
|
||||||
finalized_checkpoint: v29.finalized_checkpoint,
|
// we can safely default the values.
|
||||||
|
justified_checkpoint: Checkpoint::default(),
|
||||||
|
finalized_checkpoint: Checkpoint::default(),
|
||||||
nodes: v29
|
nodes: v29
|
||||||
.nodes
|
.nodes
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
|||||||
Reference in New Issue
Block a user