Skip to content

Commit

Permalink
fix: feedbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
leruaa committed Mar 5, 2025
1 parent 7ce865c commit aca4ca9
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 15 deletions.
35 changes: 28 additions & 7 deletions bin/continuous/src/db.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::fmt::Display;

use alloy_consensus::{Block, BlockHeader};
use reth_primitives::NodePrimitives;
use rsp_host_executor::ExecutionHooks;
Expand Down Expand Up @@ -46,14 +48,31 @@ impl ExecutionHooks for PersistToPostgres {
#[derive(Debug)]
pub struct ProvableBlock {
pub block_number: i64,
pub status: String,
pub status: ProvableBlockStatus,
pub gas_used: i64,
pub tx_count: i64,
pub num_cycles: i64,
pub start_time: Option<NaiveDateTime>,
pub end_time: Option<NaiveDateTime>,
}

#[derive(Debug)]
pub enum ProvableBlockStatus {
Queued,
Executed,
Failed,
}

impl Display for ProvableBlockStatus {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
ProvableBlockStatus::Queued => write!(f, "queued"),
ProvableBlockStatus::Executed => write!(f, "executed"),
ProvableBlockStatus::Failed => write!(f, "failed"),
}
}
}

pub async fn build_db_pool(database_url: &str) -> Result<Pool<Postgres>, sqlx::Error> {
PgPoolOptions::new().max_connections(64).connect(database_url).await
}
Expand All @@ -62,7 +81,7 @@ pub async fn insert_block(pool: &Pool<Postgres>, block_number: u64) -> Result<()
let now = Local::now().naive_local();
let block = ProvableBlock {
block_number: block_number as i64,
status: "queued".to_string(),
status: ProvableBlockStatus::Queued,
gas_used: 0,
tx_count: 0,
num_cycles: 0,
Expand All @@ -85,7 +104,7 @@ pub async fn insert_block(pool: &Pool<Postgres>, block_number: u64) -> Result<()
end_time = EXCLUDED.end_time
"#,
block.block_number,
&block.status,
block.status.to_string(),
block.gas_used,
block.tx_count,
block.num_cycles,
Expand All @@ -108,7 +127,7 @@ pub async fn update_block_status(
sqlx::query!(
r#"
UPDATE rsp_blocks
SET status = 'executed',
SET status = $5,
gas_used = $2,
tx_count = $3,
num_cycles = $4,
Expand All @@ -118,7 +137,8 @@ pub async fn update_block_status(
block_number as i64,
gas_used as i64,
tx_count as i64,
num_cycles as i64
num_cycles as i64,
ProvableBlockStatus::Executed.to_string()
)
.execute(pool)
.await?;
Expand All @@ -133,11 +153,12 @@ pub async fn update_block_status_as_failed(
sqlx::query!(
r#"
UPDATE rsp_blocks
SET status = 'failed',
SET status = $2,
end_time = NOW()
WHERE block_number = $1
"#,
block_number as i64
block_number as i64,
ProvableBlockStatus::Failed.to_string()
)
.execute(pool)
.await?;
Expand Down
2 changes: 1 addition & 1 deletion crates/executor/host/src/alerting.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! We don't use `pagerduty-rs` because requests to PG weren't working and it's unmaintained.
//! Can't use `pagerduty-rs` because the library is unmaintained.
use serde::Serialize;
use tracing::{error, info};
Expand Down
15 changes: 8 additions & 7 deletions crates/executor/host/src/full_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use std::{

use alloy_provider::{Network, Provider};
use either::Either;
use eyre::bail;
use reth_evm::execute::BlockExecutionStrategyFactory;
use reth_primitives::NodePrimitives;
use revm_primitives::B256;
Expand Down Expand Up @@ -54,7 +55,7 @@ where
));
}

todo!()
bail!("Either a RPC URL or a cache dir must be provided")
}

pub trait BlockExecutor {
Expand Down Expand Up @@ -297,15 +298,15 @@ where
}

fn client(&self) -> Arc<EnvProver> {
todo!()
self.client.clone()
}

fn pk(&self) -> Arc<SP1ProvingKey> {
todo!()
self.pk.clone()
}

fn vk(&self) -> Arc<SP1VerifyingKey> {
todo!()
self.vk.clone()
}
}

Expand Down Expand Up @@ -382,15 +383,15 @@ where
}

fn client(&self) -> Arc<EnvProver> {
todo!()
self.client.clone()
}

fn pk(&self) -> Arc<SP1ProvingKey> {
todo!()
self.pk.clone()
}

fn vk(&self) -> Arc<SP1VerifyingKey> {
todo!()
self.vk.clone()
}
}

Expand Down

0 comments on commit aca4ca9

Please sign in to comment.