Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set eth block height on new blocks #698

Merged
merged 4 commits into from
Oct 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions fuel-core/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ use fuel_core_interfaces::{
FuelBlockHeader,
Message,
},
relayer::RelayerDb,
};
use fuel_storage::{
StorageAsMut,
Expand Down Expand Up @@ -103,13 +104,15 @@ impl Executor {
// setup and execute block
let current_height = db.get_block_height()?.unwrap_or_default();
let current_hash = db.get_block_id(current_height)?.unwrap_or_default();
let da_height = db.get_finalized_da_height().await.unwrap_or_default();
Voxelot marked this conversation as resolved.
Show resolved Hide resolved
let new_block_height = current_height + 1u32.into();

let mut block = FuelBlock {
header: FuelBlockHeader {
height: new_block_height,
parent_hash: current_hash,
time: Utc::now(),
da_height,
..Default::default()
},
transactions: txs.into_iter().map(|t| t.as_ref().clone()).collect(),
Expand Down
19 changes: 19 additions & 0 deletions fuel-core/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,23 @@ impl FuelService {
}
self.modules.stop().await;
}

#[cfg(feature = "relayer")]
/// Wait for the [`Relayer`] to be in sync with
/// the data availability layer.
///
/// Yields until the relayer reaches a point where it
/// considered up to date. Note that there's no guarantee
/// the relayer will ever catch up to the da layer and
/// may fall behind immediately after this future completes.
///
/// The only guarantee is that if this future completes then
/// the relayer did reach consistency with the da layer for
/// some period of time.
pub async fn await_relayer_synced(&self) -> anyhow::Result<()> {
if let Some(relayer_handle) = &self.modules.relayer {
relayer_handle.await_synced().await?;
}
Ok(())
}
}
Loading