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

feat(consensus): hardcoded stuff #3181

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
35 changes: 28 additions & 7 deletions core/node/consensus/src/en.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,17 @@ impl EN {
s.spawn_bg(async { Ok(runner.run(ctx).await?) });

let attestation = Arc::new(attestation::Controller::new(attester));
s.spawn_bg(self.run_attestation_controller(
ctx,
global_config.clone(),
attestation.clone(),
));
s.spawn_bg({
let attestation = attestation.clone();
let global_config = global_config.clone();
async {
// Hardcoded panic on failure.
self.run_attestation_controller(ctx, global_config, attestation)
.await
.unwrap();
Ok(())
}
});

let executor = executor::Executor {
config: config::executor(&cfg, &secrets, &global_config, build_version)?,
Expand Down Expand Up @@ -214,9 +220,15 @@ impl EN {
async fn run_attestation_controller(
&self,
ctx: &ctx::Ctx,
cfg: consensus_dal::GlobalConfig,
mut cfg: consensus_dal::GlobalConfig,
attestation: Arc<attestation::Controller>,
) -> ctx::Result<()> {
// Hardcoded registry address.
cfg.registry_address = Some(
"0xd35b99bdad58baa6b912022c77d1f409001442a4"
.parse()
.unwrap(),
);
const POLL_INTERVAL: time::Duration = time::Duration::seconds(5);
let registry = registry::Registry::new(cfg.genesis.clone(), self.pool.clone()).await;
let mut next = attester::BatchNumber(0);
Expand All @@ -228,7 +240,16 @@ impl EN {
.wrap("fetch_attestation_status()")
{
Err(err) => tracing::warn!("{err:#}"),
Ok(status) => {
Ok(mut status) => {
// Hardcoded batch selection.
status.next_batch_to_attest = self
.pool
.connection(ctx)
.await
.wrap("connection()")?
.batch_to_attest(ctx)
.await
.wrap("batch_to_attest()")?;
if status.genesis != cfg.genesis.hash() {
return Err(anyhow::format_err!("genesis mismatch").into());
}
Expand Down
11 changes: 11 additions & 0 deletions core/node/consensus/src/storage/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,17 @@ impl<'a> Connection<'a> {
.await??)
}

pub(crate) async fn batch_to_attest(
&mut self,
ctx: &ctx::Ctx,
) -> ctx::Result<attester::BatchNumber> {
let n = self.next_block(ctx).await?;
Ok(ctx
.wait(self.0.consensus_dal().batch_of_block(n))
.await??
.context("unknown batch")?)
}

/// (Re)initializes consensus genesis to start at the last L2 block in storage.
/// Noop if `spec` matches the current genesis.
pub(crate) async fn adjust_global_config(
Expand Down
Loading