Skip to content

Commit

Permalink
runtime/consensus/tendermint/verifier: Remove trust in computed results
Browse files Browse the repository at this point in the history
  • Loading branch information
peternose committed Jul 3, 2023
1 parent 6bb084e commit d640e69
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 52 deletions.
11 changes: 1 addition & 10 deletions runtime/src/consensus/tendermint/verifier/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use tokio::sync::oneshot;
use crate::{
consensus::{
beacon::EpochTime,
roothash::{ComputeResultsHeader, Header},
roothash::Header,
state::ConsensusState,
tendermint::decode_light_block,
verifier::{self, Error},
Expand Down Expand Up @@ -122,13 +122,4 @@ impl verifier::Verifier for Handle {

receiver.await.map_err(|_| Error::Internal)?
}

async fn trust(&self, header: &ComputeResultsHeader) -> Result<(), Error> {
let (sender, receiver) = oneshot::channel();
self.command_sender
.send(Command::Trust(header.clone(), sender))
.map_err(|_| Error::Internal)?;

receiver.await.map_err(|_| Error::Internal)?
}
}
18 changes: 1 addition & 17 deletions runtime/src/consensus/tendermint/verifier/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use crate::{
consensus::{
beacon::EpochTime,
registry::METHOD_PROVE_FRESHNESS,
roothash::{ComputeResultsHeader, Header},
roothash::Header,
state::ConsensusState,
tendermint::{
chain_id, decode_light_block, merkle, state_root_from_header,
Expand Down Expand Up @@ -549,17 +549,6 @@ impl Verifier {
);
}

fn trust(&self, cache: &mut Cache, header: ComputeResultsHeader) -> Result<(), Error> {
if let Some(state_root) = header.state_root {
cache
.verified_state_roots
.put(header.round, (state_root, cache.last_verified_epoch));
cache.last_verified_round = header.round;
}

Ok(())
}

/// Start the verifier in a separate thread.
pub fn start(self) {
std::thread::spawn(move || {
Expand Down Expand Up @@ -740,11 +729,6 @@ impl Verifier {
))
.map_err(|_| Error::Internal)?;
}
Command::Trust(header, sender) => {
sender
.send(self.trust(&mut cache, header))
.map_err(|_| Error::Internal)?;
}
Command::LatestState(sender) => {
sender
.send(self.latest_consensus_state(&mut cache, &mut instance))
Expand Down
6 changes: 1 addition & 5 deletions runtime/src/consensus/tendermint/verifier/noop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use async_trait::async_trait;
use crate::{
consensus::{
beacon::EpochTime,
roothash::{ComputeResultsHeader, Header},
roothash::Header,
state::ConsensusState,
tendermint::decode_light_block,
verifier::{self, Error},
Expand Down Expand Up @@ -106,8 +106,4 @@ impl verifier::Verifier for NopVerifier {
async fn latest_height(&self) -> Result<u64, Error> {
Ok(self.fetch_light_block(HEIGHT_LATEST).await?.height)
}

async fn trust(&self, _header: &ComputeResultsHeader) -> Result<(), Error> {
Ok(())
}
}
8 changes: 2 additions & 6 deletions runtime/src/consensus/tendermint/verifier/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@ use tokio::sync::oneshot;

use crate::{
consensus::{
beacon::EpochTime,
roothash::{ComputeResultsHeader, Header},
state::ConsensusState,
verifier::Error,
Event, LightBlock,
beacon::EpochTime, roothash::Header, state::ConsensusState, verifier::Error, Event,
LightBlock,
},
types::EventKind,
};
Expand All @@ -27,7 +24,6 @@ pub enum Command {
oneshot::Sender<Result<ConsensusState, Error>>,
bool,
),
Trust(ComputeResultsHeader, oneshot::Sender<Result<(), Error>>),
LatestState(oneshot::Sender<Result<ConsensusState, Error>>),
LatestHeight(oneshot::Sender<Result<u64, Error>>),
StateAt(u64, oneshot::Sender<Result<ConsensusState, Error>>),
Expand Down
9 changes: 1 addition & 8 deletions runtime/src/consensus/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use thiserror::Error;

use super::{
beacon::EpochTime,
roothash::{ComputeResultsHeader, Header},
roothash::Header,
state::{registry::ImmutableState as RegistryState, ConsensusState},
Event, LightBlock,
};
Expand Down Expand Up @@ -129,9 +129,6 @@ pub trait Verifier: Send + Sync {

/// Return the latest known consensus layer height.
async fn latest_height(&self) -> Result<u64, Error>;

/// Record the given (locally computed and thus verified) results header as trusted.
async fn trust(&self, header: &ComputeResultsHeader) -> Result<(), Error>;
}

#[async_trait]
Expand Down Expand Up @@ -177,10 +174,6 @@ impl<T: ?Sized + Verifier> Verifier for Arc<T> {
async fn latest_height(&self) -> Result<u64, Error> {
Verifier::latest_height(&**self).await
}

async fn trust(&self, header: &ComputeResultsHeader) -> Result<(), Error> {
Verifier::trust(&**self, header).await
}
}

/// Consensus layer trust root.
Expand Down
6 changes: 0 additions & 6 deletions runtime/src/dispatcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -684,12 +684,6 @@ impl Dispatcher {
in_msgs_count: results.in_msgs_count.try_into().unwrap(),
};

// Since we've computed the batch, we can trust it.
// TODO: Make this async.
tokio::runtime::Handle::current()
.block_on(state.consensus_verifier.trust(&header))
.expect("trusting a computed header must succeed");

debug!(self.logger, "Transaction batch execution complete";
"previous_hash" => ?header.previous_hash,
"io_root" => ?header.io_root,
Expand Down

0 comments on commit d640e69

Please sign in to comment.