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: refactor configuration #41

Merged
merged 3 commits into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from 2 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
1,994 changes: 163 additions & 1,831 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ unexpected_cfgs = { level = "warn", check-cfg = [
# Project dependencies
aggchain-proof-builder = { path = "crates/aggchain-proof-builder" }
aggchain-proof-core = { path = "crates/aggchain-proof-core" }
aggchain-proof-service = { path = "crates/aggchain-proof-service" }
aggkit-prover = { path = "crates/aggkit-prover" }
aggkit-prover-config = { path = "crates/aggkit-prover-config" }
aggkit-prover-types = { path = "crates/aggkit-prover-types" }
Expand Down Expand Up @@ -86,5 +87,5 @@ test-log = "0.2.16"

# SP1 dependencies
sp1-core-machine = "=4.0.0"
sp1-sdk = "=4.0.0"
sp1-sdk = { version="4.0.0", features = ["native-gnark"] }
sp1-prover = "=4.0.0"
4 changes: 1 addition & 3 deletions crates/aggchain-proof-builder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@ anyhow.workspace = true
futures.workspace = true
thiserror.workspace = true
tower = { workspace = true, features = ["timeout"] }
tracing.workspace = true
serde = { workspace = true, features = ["derive"] }
sp1-sdk = { workspace = true, features = ["native-gnark"] }
sp1-sdk.workspace = true
url.workspace = true

aggchain-proof-core.workspace = true
aggkit-prover-config.workspace = true

[lints]
workspace = true
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
use std::str::FromStr;

use jsonrpsee::core::Serialize;
use serde::Deserialize;
use serde::{Deserialize, Serialize};
use url::Url;

pub(crate) const HTTP_RPC_NODE_INITIAL_BACKOFF_MS: u64 = 5000;

pub(crate) const HTTP_RPC_NODE_BACKOFF_MAX_RETRIES: u32 = 64;

/// The Aggchain proof builder configuration
#[derive(Serialize, Deserialize, Clone, Debug)]
#[serde(rename_all = "kebab-case")]
Expand Down
14 changes: 6 additions & 8 deletions crates/aggchain-proof-builder/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
pub mod config;
mod provider;

use std::sync::Arc;
use std::task::{Context, Poll};

use aggchain_proof_core::proof::AggchainProofWitness;
use aggkit_prover_config::aggchain_proof_service::{
HTTP_RPC_NODE_BACKOFF_MAX_RETRIES, HTTP_RPC_NODE_INITIAL_BACKOFF_MS,
};
use aggkit_prover_config::AggchainProofBuilderConfig;
use alloy::eips::{BlockId, BlockNumberOrTag};
use alloy::network::primitives::BlockTransactionsKind;
use alloy::primitives::B256;
Expand All @@ -17,6 +14,7 @@ use futures::{future::BoxFuture, FutureExt};
use serde::{Deserialize, Serialize};
use sp1_sdk::SP1ProofWithPublicValues;

use crate::config::AggchainProofBuilderConfig;
use crate::provider::json_rpc::{build_http_retry_provider, AlloyProvider};

/// Aggchain proof is generated from FEP proof and additional
Expand Down Expand Up @@ -64,16 +62,16 @@ impl AggchainProofBuilder {
l1_client: Arc::new(
build_http_retry_provider(
&config.l1_rpc_endpoint,
HTTP_RPC_NODE_INITIAL_BACKOFF_MS,
HTTP_RPC_NODE_BACKOFF_MAX_RETRIES,
config::HTTP_RPC_NODE_INITIAL_BACKOFF_MS,
config::HTTP_RPC_NODE_BACKOFF_MAX_RETRIES,
)
.map_err(Error::AlloyProviderError)?,
),
_l2_client: Arc::new(
build_http_retry_provider(
&config.l2_rpc_endpoint,
HTTP_RPC_NODE_INITIAL_BACKOFF_MS,
HTTP_RPC_NODE_BACKOFF_MAX_RETRIES,
config::HTTP_RPC_NODE_INITIAL_BACKOFF_MS,
config::HTTP_RPC_NODE_BACKOFF_MAX_RETRIES,
)
.map_err(Error::AlloyProviderError)?,
),
Expand Down
18 changes: 18 additions & 0 deletions crates/aggchain-proof-service/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[package]
name = "aggchain-proof-service"
version.workspace = true
edition.workspace = true
license.workspace = true

[lints]
workspace = true

[dependencies]
serde.workspace = true
thiserror.workspace = true
tower = { workspace = true, features = ["timeout"] }
tracing.workspace = true

aggchain-proof-builder.workspace = true
aggkit-prover-types.workspace = true
proposer-service.workspace = true
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
use std::fmt::Debug;

use aggchain_proof_builder::config::AggchainProofBuilderConfig;
use proposer_service::config::ProposerServiceConfig;
use serde::{Deserialize, Serialize};

use crate::aggchain_proof_builder::AggchainProofBuilderConfig;
use crate::proposer_service::ProposerServiceConfig;

pub const HTTP_RPC_NODE_INITIAL_BACKOFF_MS: u64 = 5000;

pub const HTTP_RPC_NODE_BACKOFF_MAX_RETRIES: u32 = 64;

/// The Aggchain proof service configuration
#[derive(Serialize, Deserialize, Clone, Debug, Default)]
#[serde(rename_all = "kebab-case")]
Expand Down
5 changes: 5 additions & 0 deletions crates/aggchain-proof-service/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pub mod config;

pub mod error;

pub mod service;
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ use std::{
use aggchain_proof_builder::{
AggchainProof, AggchainProofBuilder, AggchainProofBuilderRequest as ProofBuilderRequest,
};
use aggkit_prover_config::aggchain_proof_service::AggchainProofServiceConfig;
use aggkit_prover_types::Hash;
use proposer_service::{ProposerRequest, ProposerService};
use tracing::debug;

use super::error::Error;
use crate::config::AggchainProofServiceConfig;
use crate::error::Error;

/// A request for the AggchainProofService to generate the
/// aggchain proof for the range of blocks.
Expand Down Expand Up @@ -42,7 +42,7 @@ pub struct AggchainProofServiceResponse {
/// proposer service and the `aggchain-proof-builder` service to generate the
/// Aggchain proof.
#[derive(Clone)]
pub(crate) struct AggchainProofService {
pub struct AggchainProofService {
pub(crate) proposer_service: ProposerService,
pub(crate) aggchain_proof_builder: AggchainProofBuilder,
}
Expand Down
15 changes: 1 addition & 14 deletions crates/aggkit-prover-config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,16 @@ version.workspace = true
edition.workspace = true

[dependencies]
dirs.workspace = true
ethers.workspace = true
humantime-serde = "1.1.1"
jsonrpsee.workspace = true
serde = { workspace = true, features = ["derive"] }
serde_with.workspace = true
sp1-sdk = { workspace = true, features = ["native-gnark"] }
thiserror.workspace = true
toml.workspace = true
tracing.workspace = true
tracing-subscriber = { workspace = true, features = ["env-filter"] }
url = { workspace = true, features = ["serde"] }

aggchain-proof-service.workspace = true
prover-logger.workspace = true
prover-utils.workspace = true
prover-config.workspace = true

[dev-dependencies]
insta = { workspace = true, features = ["toml", "redactions", "filters"] }
pretty_assertions = "1.4.0"
rstest.workspace = true
serde_json = { workspace = true }

[features]
default = []
testutils = []
11 changes: 2 additions & 9 deletions crates/aggkit-prover-config/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
use std::path::Path;

use aggchain_proof_service::config::AggchainProofServiceConfig;
use prover_config::{NetworkProverConfig, ProverType};
use prover_logger::log::Log;
use serde::{Deserialize, Serialize};

use crate::aggchain_proof_service::AggchainProofServiceConfig;
pub use crate::{
aggchain_proof_builder::AggchainProofBuilderConfig, shutdown::ShutdownConfig,
telemetry::TelemetryConfig,
};
pub use crate::{shutdown::ShutdownConfig, telemetry::TelemetryConfig};

pub mod aggchain_proof_service;

pub mod aggchain_proof_builder;
pub mod proposer_service;
pub mod shutdown;
pub(crate) mod telemetry;

Expand Down
6 changes: 1 addition & 5 deletions crates/aggkit-prover/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,17 @@ workspace = true
[dependencies]
anyhow.workspace = true
bincode.workspace = true
futures.workspace = true
http = "1.2.0"
thiserror.workspace = true
tokio = { workspace = true, features = ["full"] }
tokio-util.workspace = true
tonic = { workspace = true, features = ["zstd"] }
tonic-types = { workspace = true }
tower = { workspace = true, features = ["timeout"] }
tracing.workspace = true

aggchain-proof-builder.workspace = true
aggchain-proof-service.workspace = true
aggkit-prover-config.workspace = true
aggkit-prover-types.workspace = true
proposer-client.workspace = true
proposer-service.workspace = true
prover-engine.workspace = true
prover-logger.workspace = true

Expand Down
8 changes: 0 additions & 8 deletions crates/aggkit-prover/src/aggchain_proof/mod.rs

This file was deleted.

4 changes: 3 additions & 1 deletion crates/aggkit-prover/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
pub mod aggchain_proof;
pub mod rpc;
#[cfg(test)]
mod tests;
6 changes: 3 additions & 3 deletions crates/aggkit-prover/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::sync::Arc;

use aggkit_prover::aggchain_proof::GrpcService;
use aggkit_prover_types::v1::aggchain_proof_service_server::AggchainProofServiceServer;
use prover_engine::ProverEngine;
use tokio_util::sync::CancellationToken;
Expand Down Expand Up @@ -28,8 +27,9 @@ fn main() -> anyhow::Result<()> {
.build()?;

// TODO: implement the aggchain-proof service
let aggchain_proof_service =
AggchainProofServiceServer::new(GrpcService::new(&config.aggchain_proof_service)?);
let aggchain_proof_service = AggchainProofServiceServer::new(
aggkit_prover::rpc::GrpcService::new(&config.aggchain_proof_service)?,
);

_ = ProverEngine::builder()
.add_rpc_service(aggchain_proof_service)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use aggkit_prover_config::aggchain_proof_service::AggchainProofServiceConfig;
use aggchain_proof_service::config::AggchainProofServiceConfig;
use aggchain_proof_service::service::{AggchainProofService, AggchainProofServiceRequest};
use aggkit_prover_types::v1::{
aggchain_proof_service_server::AggchainProofService as AggchainProofGrpcService,
GenerateAggchainProofRequest, GenerateAggchainProofResponse,
Expand All @@ -10,8 +11,6 @@ use tonic_types::{ErrorDetails, StatusExt};
use tower::{Service, ServiceExt};
use tracing::instrument;

use super::service::{AggchainProofService, AggchainProofServiceRequest};

#[derive(Clone)]
pub struct GrpcService {
service: AggchainProofService,
Expand All @@ -20,7 +19,7 @@ pub struct GrpcService {
impl GrpcService {
pub fn new(
config: &AggchainProofServiceConfig,
) -> Result<Self, crate::aggchain_proof::error::Error> {
) -> Result<Self, aggchain_proof_service::error::Error> {
Ok(GrpcService {
service: AggchainProofService::new(config)?,
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::collections::HashMap;

use aggkit_prover_config::aggchain_proof_service::AggchainProofServiceConfig;
use aggchain_proof_service::config::AggchainProofServiceConfig;
use aggchain_proof_service::service::{AggchainProofService, AggchainProofServiceRequest};
use aggkit_prover_types::v1::{
aggchain_proof_service_client::AggchainProofServiceClient,
aggchain_proof_service_server::AggchainProofServiceServer, GenerateAggchainProofRequest,
Expand All @@ -11,10 +12,7 @@ use tonic::transport::{Endpoint, Server};
use tonic_types::StatusExt;
use tower::{service_fn, Service};

use crate::aggchain_proof::{
service::{AggchainProofService, AggchainProofServiceRequest},
GrpcService,
};
use crate::rpc::GrpcService;

#[tokio::test]
#[ignore]
Expand Down
13 changes: 0 additions & 13 deletions crates/agglayer-prover-config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,9 @@ version.workspace = true
edition.workspace = true

[dependencies]
dirs.workspace = true
ethers.workspace = true
humantime-serde = "1.1.1"
jsonrpsee.workspace = true
serde = { workspace = true, features = ["derive"] }
serde_with.workspace = true
thiserror.workspace = true
toml.workspace = true
tracing.workspace = true
tracing-subscriber = { workspace = true, features = ["env-filter"] }
url = { workspace = true, features = ["serde"] }

prover-logger.workspace = true
prover-utils.workspace = true
Expand All @@ -23,9 +15,4 @@ prover-config.workspace = true
[dev-dependencies]
insta = { workspace = true, features = ["toml", "redactions", "filters"] }
pretty_assertions = "1.4.0"
rstest.workspace = true
serde_json = { workspace = true }

[features]
default = []
testutils = []
4 changes: 2 additions & 2 deletions crates/agglayer-prover-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ edition.workspace = true
license.workspace = true

[dependencies]
anyhow.workspace = true
bincode.workspace = true
prost.workspace = true
serde.workspace = true
sp1-sdk.workspace = true
thiserror.workspace = true
tonic = { workspace = true, default-features = false, features = [
"prost",
"codegen",
"transport",
] }

sp1-sdk.workspace = true


[build-dependencies]
tonic-build = { version = "0.12", default-features = false, features = [
Expand Down
8 changes: 2 additions & 6 deletions crates/agglayer-prover/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,9 @@ workspace = true
anyhow.workspace = true
bincode.workspace = true
buildstructor.workspace = true
futures.workspace = true
thiserror.workspace = true
sp1-sdk.workspace = true
tokio = { workspace = true, features = ["full"] }
tokio-util.workspace = true
toml.workspace = true
tracing-subscriber = { workspace = true, features = ["env-filter", "json"] }
tracing.workspace = true
tower = { workspace = true, features = ["timeout"] }
tonic = { workspace = true, features = ["zstd"] }
Expand All @@ -30,8 +27,7 @@ prover-engine.workspace = true
prover-executor.workspace = true
prover-logger.workspace = true

sp1-sdk = { workspace = true, features = ["native-gnark"] }
sp1-prover = { workspace = true, features = ["native-gnark"] }


[features]
default = []
Expand Down
Loading