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