Skip to content

Commit

Permalink
moar fake proofs
Browse files Browse the repository at this point in the history
  • Loading branch information
vyzo committed Apr 22, 2022
1 parent 217eb9c commit 4d6fbb3
Showing 1 changed file with 39 additions and 1 deletion.
40 changes: 39 additions & 1 deletion actors/runtime/src/runtime/fvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,13 +379,19 @@ where
.map_err(|e| anyhow!("failed to compute unsealed sector CID; exit code: {}", e))
}

#[cfg(not(feature = "fake-proofs"))]
fn verify_seal(&self, vi: &SealVerifyInfo) -> Result<(), Error> {
match fvm::crypto::verify_seal(vi) {
Ok(true) => Ok(()),
Ok(false) | Err(_) => Err(Error::msg("invalid seal")),
}
}

#[cfg(feature = "fake-proofs")]
fn verify_seal(&self, _vi: &SealVerifyInfo) -> Result<(), Error> {
Ok(())
}

#[cfg(not(feature = "fake-proofs"))]
fn verify_post(&self, verify_info: &WindowPoStVerifyInfo) -> Result<(), Error> {
match fvm::crypto::verify_post(verify_info) {
Expand All @@ -395,10 +401,11 @@ where
}

#[cfg(feature = "fake-proofs")]
fn verify_post(&self, verify_info: &WindowPoStVerifyInfo) -> Result<(), Error> {
fn verify_post(&self, _verify_info: &WindowPoStVerifyInfo) -> Result<(), Error> {
Ok(())
}

#[cfg(not(feature = "fake-proofs"))]
fn verify_consensus_fault(
&self,
h1: &[u8],
Expand All @@ -408,10 +415,27 @@ where
fvm::crypto::verify_consensus_fault(h1, h2, extra).map_err(|_| Error::msg("no fault"))
}

#[cfg(feature = "fake-proofs")]
fn verify_consensus_fault(
&self,
_h1: &[u8],
_h2: &[u8],
_extra: &[u8],
) -> Result<Option<ConsensusFault>, Error> {
Ok(None)
}

#[cfg(not(feature = "fake-proofs"))]
fn batch_verify_seals(&self, batch: &[SealVerifyInfo]) -> anyhow::Result<Vec<bool>> {
fvm::crypto::batch_verify_seals(batch).map_err(|_| Error::msg("failed to verify batch"))
}

#[cfg(feature = "fake-proofs")]
fn batch_verify_seals(&self, batch: &[SealVerifyInfo]) -> anyhow::Result<Vec<bool>> {
Ok(batch.map(|_| true))
}

#[cfg(not(feature = "fake-proofs"))]
fn verify_aggregate_seals(
&self,
aggregate: &AggregateSealVerifyProofAndInfos,
Expand All @@ -422,12 +446,26 @@ where
}
}

#[cfg(feature = "fake-proofs")]
fn verify_aggregate_seals(
&self,
_aggregate: &AggregateSealVerifyProofAndInfos,
) -> Result<(), Error> {
Ok(())
}

#[cfg(not(feature = "fake-proofs"))]
fn verify_replica_update(&self, replica: &ReplicaUpdateInfo) -> Result<(), Error> {
match fvm::crypto::verify_replica_update(replica) {
Ok(true) => Ok(()),
Ok(false) | Err(_) => Err(Error::msg("invalid replica")),
}
}

#[cfg(feature = "fake-proofs")]
fn verify_replica_update(&self, _replica: &ReplicaUpdateInfo) -> Result<(), Error> {
Ok(())
}
}

impl<B> RuntimePolicy for FvmRuntime<B>
Expand Down

0 comments on commit 4d6fbb3

Please sign in to comment.