From 78a509fdf6085886ec14a2f23025f286689ab9e1 Mon Sep 17 00:00:00 2001 From: cryptoAtwill Date: Tue, 1 Oct 2024 15:51:02 +0800 Subject: [PATCH] align with previous PR --- fendermint/vm/topdown/src/observation.rs | 12 +++++++++++- fendermint/vm/topdown/src/syncer/mod.rs | 4 ++-- fendermint/vm/topdown/src/vote/store.rs | 4 ++-- fendermint/vm/topdown/src/vote/tally.rs | 4 ++-- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/fendermint/vm/topdown/src/observation.rs b/fendermint/vm/topdown/src/observation.rs index eea36ffde..760580d40 100644 --- a/fendermint/vm/topdown/src/observation.rs +++ b/fendermint/vm/topdown/src/observation.rs @@ -1,7 +1,9 @@ // Copyright 2022-2024 Protocol Labs // SPDX-License-Identifier: Apache-2.0, MIT -use crate::{BlockHeight, Bytes}; +use crate::syncer::error::Error; +use crate::syncer::store::ParentViewStore; +use crate::{BlockHeight, Bytes, Checkpoint}; use anyhow::anyhow; use arbitrary::Arbitrary; use fendermint_crypto::secp::RecoverableECDSASignature; @@ -41,6 +43,14 @@ pub struct CertifiedObservation { signature: RecoverableECDSASignature, } +/// check in the store to see if there is a new observation available +pub fn deduce_new_observation( + _store: &S, + _checkpoint: &Checkpoint, +) -> Result { + todo!() +} + impl TryFrom<&[u8]> for CertifiedObservation { type Error = anyhow::Error; diff --git a/fendermint/vm/topdown/src/syncer/mod.rs b/fendermint/vm/topdown/src/syncer/mod.rs index 3b111a298..421c93c93 100644 --- a/fendermint/vm/topdown/src/syncer/mod.rs +++ b/fendermint/vm/topdown/src/syncer/mod.rs @@ -1,7 +1,7 @@ // Copyright 2022-2024 Protocol Labs // SPDX-License-Identifier: Apache-2.0, MIT -use crate::observation::ObservationCommitment; +use crate::observation::Observation; use crate::proxy::ParentQueryProxy; use crate::syncer::poll::ParentPoll; use crate::syncer::store::ParentViewStore; @@ -19,7 +19,7 @@ pub mod store; pub enum TopDownSyncEvent { /// The fendermint node is syncing with peers NodeSyncing, - NewProposal(Box), + NewProposal(Box), } pub struct ParentSyncerConfig { diff --git a/fendermint/vm/topdown/src/vote/store.rs b/fendermint/vm/topdown/src/vote/store.rs index 3de09a6d9..5757b0926 100644 --- a/fendermint/vm/topdown/src/vote/store.rs +++ b/fendermint/vm/topdown/src/vote/store.rs @@ -138,13 +138,13 @@ mod tests { (sk, ValidatorKey::new(public_key)) } - fn random_observation() -> ObservationCommitment { + fn random_observation() -> Observation { let mut bytes = [0; 100]; let mut rng = rand::thread_rng(); rng.fill_bytes(&mut bytes); let mut unstructured = Unstructured::new(&bytes); - ObservationCommitment::arbitrary(&mut unstructured).unwrap() + Observation::arbitrary(&mut unstructured).unwrap() } #[test] diff --git a/fendermint/vm/topdown/src/vote/tally.rs b/fendermint/vm/topdown/src/vote/tally.rs index 5ed1beca0..376d9ff5b 100644 --- a/fendermint/vm/topdown/src/vote/tally.rs +++ b/fendermint/vm/topdown/src/vote/tally.rs @@ -230,13 +230,13 @@ mod tests { (sk, ValidatorKey::new(public_key)) } - fn random_observation() -> ObservationCommitment { + fn random_observation() -> Observation { let mut bytes = [0; 100]; let mut rng = rand::thread_rng(); rng.fill_bytes(&mut bytes); let mut unstructured = Unstructured::new(&bytes); - ObservationCommitment::arbitrary(&mut unstructured).unwrap() + Observation::arbitrary(&mut unstructured).unwrap() } #[test]