Skip to content

Commit

Permalink
align with previous PR
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptoAtwill committed Oct 1, 2024
1 parent 6fdc68c commit 78a509f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
12 changes: 11 additions & 1 deletion fendermint/vm/topdown/src/observation.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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<S: ParentViewStore>(
_store: &S,
_checkpoint: &Checkpoint,
) -> Result<Observation, Error> {
todo!()
}

impl TryFrom<&[u8]> for CertifiedObservation {
type Error = anyhow::Error;

Expand Down
4 changes: 2 additions & 2 deletions fendermint/vm/topdown/src/syncer/mod.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -19,7 +19,7 @@ pub mod store;
pub enum TopDownSyncEvent {
/// The fendermint node is syncing with peers
NodeSyncing,
NewProposal(Box<ObservationCommitment>),
NewProposal(Box<Observation>),
}

pub struct ParentSyncerConfig {
Expand Down
4 changes: 2 additions & 2 deletions fendermint/vm/topdown/src/vote/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions fendermint/vm/topdown/src/vote/tally.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 78a509f

Please sign in to comment.