From 5704183b73f7d035c9cf813985f2798fbdb18888 Mon Sep 17 00:00:00 2001 From: voidash Date: Tue, 27 Aug 2024 10:19:48 +0545 Subject: [PATCH 1/4] chore: add import ordering rule --- Contributing.md | 49 +++++++++++++ crates/btcio/src/broadcaster/handle.rs | 10 ++- crates/btcio/src/broadcaster/task.rs | 15 ++-- crates/btcio/src/reader/query.rs | 23 ++++--- crates/btcio/src/rpc/client.rs | 36 +++++----- crates/btcio/src/rpc/types.rs | 3 +- crates/btcio/src/status.rs | 3 +- crates/btcio/src/writer/broadcast.rs | 9 ++- crates/btcio/src/writer/builder.rs | 3 +- crates/btcio/src/writer/config.rs | 3 +- crates/btcio/src/writer/utils.rs | 25 +++---- crates/btcio/src/writer/watcher.rs | 6 +- crates/btcio/src/writer/writer_handler.rs | 25 ++++--- crates/chaintsn/src/errors.rs | 1 - crates/chaintsn/src/transition.rs | 3 +- .../consensus-logic/src/client_transition.rs | 14 ++-- crates/consensus-logic/src/credential.rs | 5 +- crates/consensus-logic/src/ctl.rs | 5 +- .../src/duty/block_assembly.rs | 49 +++++++------ crates/consensus-logic/src/duty/types.rs | 3 +- crates/consensus-logic/src/duty/worker.rs | 45 +++++++----- crates/consensus-logic/src/errors.rs | 6 +- .../src/fork_choice_manager.rs | 35 +++++----- crates/consensus-logic/src/genesis.rs | 3 +- crates/consensus-logic/src/l1_handler.rs | 13 ++-- crates/consensus-logic/src/reorg.rs | 3 +- crates/consensus-logic/src/state_tracker.rs | 9 +-- crates/consensus-logic/src/sync_manager.rs | 16 +++-- crates/consensus-logic/src/worker.rs | 7 +- crates/db/src/database.rs | 3 +- crates/db/src/stubs/chain_state.rs | 5 +- crates/db/src/stubs/l2.rs | 10 +-- crates/db/src/traits.rs | 23 +++---- crates/db/src/types.rs | 6 +- crates/eectl/src/engine.rs | 3 +- crates/eectl/src/stub.rs | 11 +-- crates/evmexec/src/block.rs | 5 +- crates/evmexec/src/el_payload.rs | 11 ++- crates/evmexec/src/engine.rs | 50 +++++++------- crates/evmexec/src/fork_choice_state.rs | 7 +- crates/evmexec/src/http_client.rs | 8 +-- crates/primitives/src/buf.rs | 11 +-- crates/primitives/src/l1.rs | 3 +- crates/primitives/src/prelude.rs | 3 +- crates/prover/adapters/sp1/src/sp1.rs | 4 +- crates/prover/primitives/src/db.rs | 10 +-- crates/prover/primitives/src/lib.rs | 17 +++-- crates/prover/primitives/src/mpt.rs | 16 ++--- crates/prover/primitives/src/processor.rs | 11 +-- crates/reth/db/src/lib.rs | 4 +- crates/reth/db/src/rocksdb/db.rs | 3 +- crates/reth/db/src/rocksdb/schema.rs | 7 +- crates/reth/rpc/src/lib.rs | 3 +- crates/rocksdb-store/src/broadcaster/db.rs | 24 +++---- .../rocksdb-store/src/broadcaster/schemas.rs | 8 +-- crates/rocksdb-store/src/chain_state/db.rs | 16 ++--- .../rocksdb-store/src/chain_state/schemas.rs | 7 +- crates/rocksdb-store/src/client_state/db.rs | 11 +-- .../rocksdb-store/src/client_state/schemas.rs | 7 +- crates/rocksdb-store/src/l1/db.rs | 18 +++-- crates/rocksdb-store/src/l1/schemas.rs | 8 +-- crates/rocksdb-store/src/l2/db.rs | 6 +- crates/rocksdb-store/src/l2/schemas.rs | 11 ++- crates/rocksdb-store/src/lib.rs | 18 ++--- crates/rocksdb-store/src/sequencer/db.rs | 22 +++--- crates/rocksdb-store/src/sequencer/schemas.rs | 10 +-- crates/rocksdb-store/src/sync_event/db.rs | 17 +++-- .../rocksdb-store/src/sync_event/schemas.rs | 7 +- crates/rocksdb-store/src/test_utils.rs | 3 +- crates/rocksdb-store/src/utils.rs | 3 +- crates/state/src/block.rs | 3 +- crates/state/src/bridge_ops.rs | 3 +- crates/state/src/bridge_state.rs | 3 +- crates/state/src/chain_state.rs | 13 ++-- crates/state/src/da_blob.rs | 3 +- crates/state/src/exec_env.rs | 3 +- crates/state/src/exec_update.rs | 3 +- crates/state/src/forced_inclusion.rs | 3 +- crates/state/src/header.rs | 8 +-- crates/state/src/id.rs | 3 +- crates/state/src/l1.rs | 3 +- crates/state/src/operation.rs | 8 ++- crates/state/src/prelude.rs | 12 ++-- crates/state/src/state_op.rs | 8 +-- crates/storage/src/cache.rs | 7 +- crates/storage/src/managers/l2.rs | 13 ++-- crates/storage/src/ops/l1tx_broadcast.rs | 8 ++- crates/tasks/src/manager.rs | 29 ++++---- crates/tasks/src/shutdown.rs | 10 +-- crates/util/mmr/src/hasher.rs | 3 +- crates/util/mmr/src/lib.rs | 4 +- proofs/risc0/Cargo.toml | 2 +- proofs/risc0/guest-reth-stf/Cargo.toml | 2 +- proofs/sp1/Cargo.toml | 2 +- proofs/sp1/build.rs | 3 +- proofs/sp1/guest-reth-stf/Cargo.toml | 2 +- rustfmt.toml | 2 + sequencer/src/l1_reader.rs | 12 ++-- sequencer/src/main.rs | 69 ++++++++++--------- sequencer/src/rpc_server.rs | 50 +++++++------- 100 files changed, 554 insertions(+), 597 deletions(-) create mode 100644 Contributing.md diff --git a/Contributing.md b/Contributing.md new file mode 100644 index 000000000..997f0c8f8 --- /dev/null +++ b/Contributing.md @@ -0,0 +1,49 @@ +## Contribution Guidelines + +### Development Tools + +Please install the following tools in your development environment to make sure that +you can run the basic CI checks in your local environment: + +- `taplo` + + This is a tool that is used to lint and format `TOML` files. You can install it with: + + ```bash + brew install taplo + ``` + + You can learn more [here](https://taplo.tamasfe.dev/cli/installation/binary.html). + +- `codespell` + + This is a tool that is used to check for common misspellings in code. You can install it with: + + ```bash + pip install codespell # or `pip3 install codespell` + ``` + + You can learn more [here](https://github.com/codespell-project/codespell). + +- `nextest` + + This is a modern test runner for Rust. You can install it with: + + ```bash + cargo install --locked nextest + ``` + + Learn more [here](https://nexte.st). + +- Functional test runner + + For dependencies required to run functional tests, see instructions in its [`README.md`](./functional-tests/README.md). + +### Before Creating a PR + +Before you create a PR, make sure that all the required CI checks pass locally. +For your convenience, a `Makefile` recipe has been created which you can run via: + +```bash +make pr # `make` should already be installed in most systems +``` diff --git a/crates/btcio/src/broadcaster/handle.rs b/crates/btcio/src/broadcaster/handle.rs index cbd644b1c..13f95036d 100644 --- a/crates/btcio/src/broadcaster/handle.rs +++ b/crates/btcio/src/broadcaster/handle.rs @@ -1,19 +1,17 @@ use std::sync::Arc; -use express_tasks::TaskExecutor; -use tokio::sync::mpsc; -use tracing::*; - use alpen_express_db::{ types::{L1TxEntry, L1TxStatus}, DbResult, }; use alpen_express_primitives::buf::Buf32; use express_storage::BroadcastDbOps; - -use crate::rpc::traits::{L1Client, SeqL1Client}; +use express_tasks::TaskExecutor; +use tokio::sync::mpsc; +use tracing::*; use super::task::broadcaster_task; +use crate::rpc::traits::{L1Client, SeqL1Client}; pub struct L1BroadcastHandle { ops: Arc, diff --git a/crates/btcio/src/broadcaster/task.rs b/crates/btcio/src/broadcaster/task.rs index c7e382b5b..2a31e1f8a 100644 --- a/crates/btcio/src/broadcaster/task.rs +++ b/crates/btcio/src/broadcaster/task.rs @@ -1,13 +1,13 @@ use std::{collections::BTreeMap, sync::Arc, time::Duration}; +use alpen_express_db::types::{ExcludeReason, L1TxEntry, L1TxStatus}; use alpen_express_primitives::buf::Buf32; use bitcoin::{hashes::Hash, Txid}; use express_storage::{ops::l1tx_broadcast, BroadcastDbOps}; use tokio::sync::mpsc::Receiver; use tracing::*; -use alpen_express_db::types::{ExcludeReason, L1TxEntry, L1TxStatus}; - +use super::error::BroadcasterResult; use crate::{ broadcaster::{error::BroadcasterError, state::BroadcasterState}, rpc::{ @@ -16,8 +16,6 @@ use crate::{ }, }; -use super::error::BroadcasterResult; - // TODO: make these configurable, get from config const BROADCAST_POLL_INTERVAL: u64 = 1000; // millis const FINALITY_DEPTH: u64 = 6; @@ -206,14 +204,15 @@ async fn send_tx( #[cfg(test)] mod test { use alpen_express_db::{traits::TxBroadcastDatabase, types::ExcludeReason}; - use alpen_express_rocksdb::broadcaster::db::{BroadcastDatabase, BroadcastDb}; - use alpen_express_rocksdb::test_utils::get_rocksdb_tmp_instance; + use alpen_express_rocksdb::{ + broadcaster::db::{BroadcastDatabase, BroadcastDb}, + test_utils::get_rocksdb_tmp_instance, + }; use alpen_test_utils::ArbitraryGenerator; use express_storage::ops::l1tx_broadcast::Context; - use crate::test_utils::TestBitcoinClient; - use super::*; + use crate::test_utils::TestBitcoinClient; fn get_db() -> Arc { let (db, dbops) = get_rocksdb_tmp_instance().unwrap(); diff --git a/crates/btcio/src/reader/query.rs b/crates/btcio/src/reader/query.rs index cca2e60a2..944ca98b8 100644 --- a/crates/btcio/src/reader/query.rs +++ b/crates/btcio/src/reader/query.rs @@ -1,18 +1,23 @@ -use std::collections::VecDeque; -use std::sync::Arc; -use std::time::{Duration, SystemTime, UNIX_EPOCH}; +use std::{ + collections::VecDeque, + sync::Arc, + time::{Duration, SystemTime, UNIX_EPOCH}, +}; +use alpen_express_rpc_types::types::L1Status; use anyhow::bail; use bitcoin::{Block, BlockHash}; use tokio::sync::{mpsc, RwLock}; use tracing::*; -use alpen_express_rpc_types::types::L1Status; - -use super::config::ReaderConfig; -use super::messages::{BlockData, L1Event}; -use crate::rpc::traits::L1Client; -use crate::status::{apply_status_updates, StatusUpdate}; +use super::{ + config::ReaderConfig, + messages::{BlockData, L1Event}, +}; +use crate::{ + rpc::traits::L1Client, + status::{apply_status_updates, StatusUpdate}, +}; fn filter_interesting_txs(block: &Block) -> Vec { // TODO actually implement the filter logic. Now it returns everything diff --git a/crates/btcio/src/rpc/client.rs b/crates/btcio/src/rpc/client.rs index a1c8ee106..9ae3ce892 100644 --- a/crates/btcio/src/rpc/client.rs +++ b/crates/btcio/src/rpc/client.rs @@ -1,32 +1,30 @@ -use std::sync::atomic::AtomicU64; -use std::time::Duration; -use std::{fmt::Display, str::FromStr}; +use std::{fmt::Display, str::FromStr, sync::atomic::AtomicU64, time::Duration}; use async_trait::async_trait; -use bitcoin::consensus::encode::{deserialize_hex, serialize_hex}; -use bitcoin::Txid; - -use base64::engine::general_purpose; -use base64::Engine; +use base64::{engine::general_purpose, Engine}; use bitcoin::{ block::{Header, Version}, - consensus::deserialize, + consensus::{ + deserialize, + encode::{deserialize_hex, serialize_hex}, + }, hash_types::TxMerkleNode, hashes::Hash as _, - Address, Block, BlockHash, CompactTarget, Network, Transaction, + Address, Block, BlockHash, CompactTarget, Network, Transaction, Txid, }; -use reqwest::header::HeaderMap; -use reqwest::StatusCode; +use reqwest::{header::HeaderMap, StatusCode}; use serde::{Deserialize, Serialize}; -use serde_json::{json, to_value, value::RawValue, value::Value}; -use tracing::*; - -use super::{traits::SeqL1Client, types::RPCTransactionInfo}; - +use serde_json::{ + json, to_value, + value::{RawValue, Value}, +}; use thiserror::Error; +use tracing::*; -use super::traits::L1Client; -use super::types::{RawUTXO, RpcBlockchainInfo}; +use super::{ + traits::{L1Client, SeqL1Client}, + types::{RPCTransactionInfo, RawUTXO, RpcBlockchainInfo}, +}; const MAX_RETRIES: u32 = 3; diff --git a/crates/btcio/src/rpc/types.rs b/crates/btcio/src/rpc/types.rs index c70e26d26..41dfb6497 100644 --- a/crates/btcio/src/rpc/types.rs +++ b/crates/btcio/src/rpc/types.rs @@ -104,9 +104,10 @@ where #[cfg(test)] mod test { - use super::*; use serde::Deserialize; + use super::*; + #[derive(Deserialize)] struct TestStruct { #[serde(deserialize_with = "deserialize_satoshis")] diff --git a/crates/btcio/src/status.rs b/crates/btcio/src/status.rs index 1604d3d5d..a69cab16b 100644 --- a/crates/btcio/src/status.rs +++ b/crates/btcio/src/status.rs @@ -1,8 +1,7 @@ use std::sync::Arc; -use tokio::sync::RwLock; - use alpen_express_rpc_types::types::L1Status; +use tokio::sync::RwLock; #[derive(Debug, Clone)] pub enum StatusUpdate { diff --git a/crates/btcio/src/writer/broadcast.rs b/crates/btcio/src/writer/broadcast.rs index 8ce4e72fd..b4a506b78 100644 --- a/crates/btcio/src/writer/broadcast.rs +++ b/crates/btcio/src/writer/broadcast.rs @@ -2,17 +2,16 @@ use std::{sync::Arc, time::Duration}; +use alpen_express_db::{ + traits::{SeqDataProvider, SeqDataStore, SequencerDatabase}, + types::BlobL1Status, +}; use alpen_express_rpc_types::L1Status; use anyhow::anyhow; use bitcoin::{consensus::deserialize, Txid}; use tokio::sync::RwLock; use tracing::*; -use alpen_express_db::{ - traits::{SeqDataProvider, SeqDataStore, SequencerDatabase}, - types::BlobL1Status, -}; - use crate::{ rpc::{ traits::{L1Client, SeqL1Client}, diff --git a/crates/btcio/src/writer/builder.rs b/crates/btcio/src/writer/builder.rs index f2e9cfe02..8c173b1ee 100644 --- a/crates/btcio/src/writer/builder.rs +++ b/crates/btcio/src/writer/builder.rs @@ -31,13 +31,12 @@ use bitcoin::{ use rand::RngCore; use thiserror::Error; +use super::config::{InscriptionFeePolicy, WriterConfig}; use crate::rpc::{ traits::{L1Client, SeqL1Client}, types::RawUTXO, }; -use super::config::{InscriptionFeePolicy, WriterConfig}; - const BITCOIN_DUST_LIMIT: u64 = 546; // TODO: these might need to be in rollup params diff --git a/crates/btcio/src/writer/config.rs b/crates/btcio/src/writer/config.rs index 3975f028e..cc17373d5 100644 --- a/crates/btcio/src/writer/config.rs +++ b/crates/btcio/src/writer/config.rs @@ -1,6 +1,7 @@ -use bitcoin::Address; use std::str::FromStr; +use bitcoin::Address; + #[derive(Debug, Clone)] pub struct WriterConfig { /// The sequencer change_address. This is where the reveal txn spends it's utxo to diff --git a/crates/btcio/src/writer/utils.rs b/crates/btcio/src/writer/utils.rs index da40c9077..6937282c6 100644 --- a/crates/btcio/src/writer/utils.rs +++ b/crates/btcio/src/writer/utils.rs @@ -1,20 +1,16 @@ use std::sync::Arc; +use alpen_express_db::{ + traits::{SeqDataProvider, SeqDataStore, SequencerDatabase}, + types::{BlobEntry, BlobL1Status}, +}; use alpen_express_primitives::buf::Buf32; use anyhow::Context; -use bitcoin::hashes::Hash; -use bitcoin::{consensus::serialize, Transaction}; +use bitcoin::{consensus::serialize, hashes::Hash, Transaction}; use sha2::{Digest, Sha256}; +use super::{builder::build_inscription_txs, config::WriterConfig}; use crate::rpc::traits::{L1Client, SeqL1Client}; -use alpen_express_db::types::BlobL1Status; -use alpen_express_db::{ - traits::{SeqDataProvider, SeqDataStore, SequencerDatabase}, - types::BlobEntry, -}; - -use super::builder::build_inscription_txs; -use super::config::WriterConfig; // Helper function to fetch a blob entry from within tokio pub async fn get_blob_by_idx( @@ -143,16 +139,17 @@ pub fn calculate_blob_hash(blob: &[u8]) -> Buf32 { mod test { use std::{str::FromStr, sync::Arc}; - use bitcoin::{Address, Network}; - use alpen_express_db::traits::SequencerDatabase; use alpen_express_rocksdb::{ sequencer::db::SequencerDB, test_utils::get_rocksdb_tmp_instance, SeqDb, }; + use bitcoin::{Address, Network}; use super::*; - use crate::test_utils::TestBitcoinClient; - use crate::writer::config::{InscriptionFeePolicy, WriterConfig}; + use crate::{ + test_utils::TestBitcoinClient, + writer::config::{InscriptionFeePolicy, WriterConfig}, + }; fn get_db() -> Arc> { let (db, db_ops) = get_rocksdb_tmp_instance().unwrap(); diff --git a/crates/btcio/src/writer/watcher.rs b/crates/btcio/src/writer/watcher.rs index fe75ff08d..817cd2254 100644 --- a/crates/btcio/src/writer/watcher.rs +++ b/crates/btcio/src/writer/watcher.rs @@ -1,20 +1,18 @@ use std::{sync::Arc, time::Duration}; -use tracing::*; - use alpen_express_db::{ traits::SequencerDatabase, types::{BlobEntry, BlobL1Status}, }; use bitcoin::{hashes::Hash, Txid}; +use tracing::*; +use super::{config::WriterConfig, utils::update_blob_by_idx}; use crate::{ rpc::traits::{L1Client, SeqL1Client}, writer::utils::{create_and_sign_blob_inscriptions, get_blob_by_idx}, }; -use super::{config::WriterConfig, utils::update_blob_by_idx}; - const FINALITY_DEPTH: u64 = 6; /// Watches for inscription transactions status in bitcoin diff --git a/crates/btcio/src/writer/writer_handler.rs b/crates/btcio/src/writer/writer_handler.rs index 192144ed4..f2a8305c4 100644 --- a/crates/btcio/src/writer/writer_handler.rs +++ b/crates/btcio/src/writer/writer_handler.rs @@ -1,11 +1,5 @@ use std::sync::Arc; -use tokio::sync::{ - mpsc::{self, Receiver, Sender}, - RwLock, -}; -use tracing::*; - use alpen_express_db::{ traits::{SeqDataProvider, SeqDataStore, SequencerDatabase}, types::{BlobEntry, BlobL1Status}, @@ -14,10 +8,17 @@ use alpen_express_primitives::buf::Buf32; use alpen_express_rpc_types::L1Status; use alpen_express_state::da_blob::BlobIntent; use express_tasks::TaskExecutor; +use tokio::sync::{ + mpsc::{self, Receiver, Sender}, + RwLock, +}; +use tracing::*; -use super::broadcast::broadcaster_task; -use super::config::WriterConfig; -use super::utils::{create_and_sign_blob_inscriptions, get_blob_by_id, put_blob, BlobIdx}; +use super::{ + broadcast::broadcaster_task, + config::WriterConfig, + utils::{create_and_sign_blob_inscriptions, get_blob_by_id, put_blob, BlobIdx}, +}; use crate::{ rpc::traits::{L1Client, SeqL1Client}, writer::watcher::watcher_task, @@ -219,15 +220,13 @@ fn initialize_writer_state(db: Arc) -> anyhow::Result bool { let sigcom = compute_header_sig_commitment(header); diff --git a/crates/consensus-logic/src/ctl.rs b/crates/consensus-logic/src/ctl.rs index 11cfc9732..669b19f10 100644 --- a/crates/consensus-logic/src/ctl.rs +++ b/crates/consensus-logic/src/ctl.rs @@ -1,10 +1,9 @@ use std::sync::Arc; -use tokio::sync::{mpsc, oneshot}; -use tracing::*; - use alpen_express_db::{errors::DbError, traits::*}; use alpen_express_state::sync_event::SyncEvent; +use tokio::sync::{mpsc, oneshot}; +use tracing::*; use crate::message::CsmMessage; diff --git a/crates/consensus-logic/src/duty/block_assembly.rs b/crates/consensus-logic/src/duty/block_assembly.rs index 8ca5c3c35..bf69f18c2 100644 --- a/crates/consensus-logic/src/duty/block_assembly.rs +++ b/crates/consensus-logic/src/duty/block_assembly.rs @@ -1,37 +1,34 @@ //! Impl logic for the block assembly duties. #![allow(unused)] -use std::sync::Arc; -use std::thread; -use std::time; - -use alpen_express_db::traits::L1DataProvider; -use alpen_express_state::client_state::LocalL1State; -use alpen_express_state::l1::L1HeaderPayload; -use alpen_express_state::l1::L1HeaderRecord; -use tracing::*; +use std::{sync::Arc, thread, time}; use alpen_express_db::traits::{ - ChainstateProvider, ClientStateProvider, Database, L2DataProvider, L2DataStore, + ChainstateProvider, ClientStateProvider, Database, L1DataProvider, L2DataProvider, L2DataStore, +}; +use alpen_express_eectl::{ + engine::{ExecEngineCtl, PayloadStatus}, + errors::EngineError, + messages::{ExecPayloadData, PayloadEnv}, +}; +use alpen_express_primitives::{ + buf::{Buf32, Buf64}, + params::Params, }; -use alpen_express_eectl::engine::{ExecEngineCtl, PayloadStatus}; -use alpen_express_eectl::errors::EngineError; -use alpen_express_eectl::messages::{ExecPayloadData, PayloadEnv}; -use alpen_express_primitives::buf::{Buf32, Buf64}; -use alpen_express_primitives::params::Params; -use alpen_express_state::block::L2BlockAccessory; -use alpen_express_state::block::L2BlockBundle; -use alpen_express_state::block::{ExecSegment, L1Segment}; -use alpen_express_state::chain_state::ChainState; -use alpen_express_state::client_state::ClientState; -use alpen_express_state::exec_update::{ExecUpdate, UpdateOutput}; -use alpen_express_state::header::L2BlockHeader; -use alpen_express_state::prelude::*; -use alpen_express_state::state_op::*; +use alpen_express_state::{ + block::{ExecSegment, L1Segment, L2BlockAccessory, L2BlockBundle}, + chain_state::ChainState, + client_state::{ClientState, LocalL1State}, + exec_update::{ExecUpdate, UpdateOutput}, + header::L2BlockHeader, + l1::{L1HeaderPayload, L1HeaderRecord}, + prelude::*, + state_op::*, +}; +use tracing::*; use super::types::*; -use crate::credential::sign_schnorr_sig; -use crate::errors::Error; +use crate::{credential::sign_schnorr_sig, errors::Error}; /// Signs and stores a block in the database. Does not submit it to the /// forkchoice manager. diff --git a/crates/consensus-logic/src/duty/types.rs b/crates/consensus-logic/src/duty/types.rs index 1b8d4f8c3..ebc064b0a 100644 --- a/crates/consensus-logic/src/duty/types.rs +++ b/crates/consensus-logic/src/duty/types.rs @@ -2,10 +2,9 @@ use std::time; -use borsh::{BorshDeserialize, BorshSerialize}; - use alpen_express_primitives::{buf::Buf32, hash::compute_borsh_hash}; use alpen_express_state::id::L2BlockId; +use borsh::{BorshDeserialize, BorshSerialize}; /// Describes when we'll stop working to fulfill a duty. #[derive(Clone, Debug)] diff --git a/crates/consensus-logic/src/duty/worker.rs b/crates/consensus-logic/src/duty/worker.rs index d5be60479..22e24df8e 100644 --- a/crates/consensus-logic/src/duty/worker.rs +++ b/crates/consensus-logic/src/duty/worker.rs @@ -1,30 +1,39 @@ //! Executes duties. -use std::collections::HashMap; -use std::sync::{Arc, RwLock}; -use std::time; - -use tokio::sync::broadcast; -use tracing::*; +use std::{ + collections::HashMap, + sync::{Arc, RwLock}, + time, +}; use alpen_express_btcio::writer::DaWriter; use alpen_express_db::traits::*; use alpen_express_eectl::engine::ExecEngineCtl; -use alpen_express_primitives::buf::{Buf32, Buf64}; -use alpen_express_primitives::params::Params; -use alpen_express_state::batch::{BatchCommitment, SignedBatchCommitment}; -use alpen_express_state::client_state::ClientState; -use alpen_express_state::da_blob::{BlobDest, BlobIntent}; -use alpen_express_state::prelude::*; +use alpen_express_primitives::{ + buf::{Buf32, Buf64}, + params::Params, +}; +use alpen_express_state::{ + batch::{BatchCommitment, SignedBatchCommitment}, + client_state::ClientState, + da_blob::{BlobDest, BlobIntent}, + prelude::*, +}; use express_storage::L2BlockManager; use express_tasks::{ShutdownGuard, TaskExecutor}; +use tokio::sync::broadcast; +use tracing::*; -use super::types::{self, Duty, DutyBatch, Identity, IdentityKey}; -use super::{block_assembly, extractor}; -use crate::credential::sign_schnorr_sig; -use crate::errors::Error; -use crate::message::{ClientUpdateNotif, ForkChoiceMessage}; -use crate::sync_manager::SyncManager; +use super::{ + block_assembly, extractor, + types::{self, Duty, DutyBatch, Identity, IdentityKey}, +}; +use crate::{ + credential::sign_schnorr_sig, + errors::Error, + message::{ClientUpdateNotif, ForkChoiceMessage}, + sync_manager::SyncManager, +}; pub fn duty_tracker_task( shutdown: ShutdownGuard, diff --git a/crates/consensus-logic/src/errors.rs b/crates/consensus-logic/src/errors.rs index d5f85e3ef..ce1fe13f5 100644 --- a/crates/consensus-logic/src/errors.rs +++ b/crates/consensus-logic/src/errors.rs @@ -1,9 +1,7 @@ use alpen_express_eectl::errors::EngineError; -use thiserror::Error; - -use alpen_express_state::id::L2BlockId; -use alpen_express_state::l1::L1BlockId; +use alpen_express_state::{id::L2BlockId, l1::L1BlockId}; use express_chaintsn::errors::TsnError; +use thiserror::Error; #[derive(Debug, Error)] pub enum Error { diff --git a/crates/consensus-logic/src/fork_choice_manager.rs b/crates/consensus-logic/src/fork_choice_manager.rs index df3bc83f6..1c5aad789 100644 --- a/crates/consensus-logic/src/fork_choice_manager.rs +++ b/crates/consensus-logic/src/fork_choice_manager.rs @@ -2,28 +2,25 @@ use std::sync::Arc; -use alpen_express_primitives::hash; -use tokio::sync::mpsc; -use tracing::*; - -use alpen_express_db::errors::DbError; -use alpen_express_db::traits::{BlockStatus, ChainstateProvider, ChainstateStore, Database}; -use alpen_express_eectl::engine::ExecEngineCtl; -use alpen_express_eectl::messages::ExecPayloadData; -use alpen_express_primitives::params::Params; -use alpen_express_state::block::L2BlockBundle; -use alpen_express_state::client_state::ClientState; -use alpen_express_state::operation::SyncAction; -use alpen_express_state::prelude::*; -use alpen_express_state::state_op::StateCache; -use alpen_express_state::sync_event::SyncEvent; +use alpen_express_db::{ + errors::DbError, + traits::{BlockStatus, ChainstateProvider, ChainstateStore, Database}, +}; +use alpen_express_eectl::{engine::ExecEngineCtl, messages::ExecPayloadData}; +use alpen_express_primitives::{hash, params::Params}; +use alpen_express_state::{ + block::L2BlockBundle, client_state::ClientState, operation::SyncAction, prelude::*, + state_op::StateCache, sync_event::SyncEvent, +}; use express_storage::L2BlockManager; use express_tasks::ShutdownGuard; +use tokio::sync::mpsc; +use tracing::*; -use crate::ctl::CsmController; -use crate::message::ForkChoiceMessage; -use crate::unfinalized_tracker::UnfinalizedBlockTracker; -use crate::{credential, errors::*, reorg, unfinalized_tracker}; +use crate::{ + credential, ctl::CsmController, errors::*, message::ForkChoiceMessage, reorg, + unfinalized_tracker, unfinalized_tracker::UnfinalizedBlockTracker, +}; /// Tracks the parts of the chain that haven't been finalized on-chain yet. pub struct ForkChoiceManager { diff --git a/crates/consensus-logic/src/genesis.rs b/crates/consensus-logic/src/genesis.rs index 89be25aaa..92610467f 100644 --- a/crates/consensus-logic/src/genesis.rs +++ b/crates/consensus-logic/src/genesis.rs @@ -1,5 +1,3 @@ -use tracing::*; - use alpen_express_db::{errors::DbError, traits::*}; use alpen_express_primitives::{ buf::{Buf32, Buf64}, @@ -17,6 +15,7 @@ use alpen_express_state::{ l1::{L1HeaderRecord, L1ViewState}, prelude::*, }; +use tracing::*; use crate::errors::Error; diff --git a/crates/consensus-logic/src/l1_handler.rs b/crates/consensus-logic/src/l1_handler.rs index 78b445f16..0fd5b8ade 100644 --- a/crates/consensus-logic/src/l1_handler.rs +++ b/crates/consensus-logic/src/l1_handler.rs @@ -1,17 +1,12 @@ use std::sync::Arc; -use alpen_express_primitives::params::Params; -use bitcoin::consensus::serialize; -use bitcoin::hashes::Hash; -use bitcoin::Block; -use tokio::sync::mpsc; -use tracing::*; - use alpen_express_btcio::reader::messages::L1Event; use alpen_express_db::traits::{Database, L1DataStore}; -use alpen_express_primitives::buf::Buf32; -use alpen_express_primitives::l1::L1BlockManifest; +use alpen_express_primitives::{buf::Buf32, l1::L1BlockManifest, params::Params}; use alpen_express_state::sync_event::SyncEvent; +use bitcoin::{consensus::serialize, hashes::Hash, Block}; +use tokio::sync::mpsc; +use tracing::*; use crate::ctl::CsmController; diff --git a/crates/consensus-logic/src/reorg.rs b/crates/consensus-logic/src/reorg.rs index 8c8451153..fd5e3acd8 100644 --- a/crates/consensus-logic/src/reorg.rs +++ b/crates/consensus-logic/src/reorg.rs @@ -133,9 +133,8 @@ mod tests { use alpen_express_state::id::L2BlockId; use rand::RngCore; - use crate::unfinalized_tracker; - use super::{compute_reorg, Reorg}; + use crate::unfinalized_tracker; fn rand_blkid() -> L2BlockId { use rand::rngs::OsRng; diff --git a/crates/consensus-logic/src/state_tracker.rs b/crates/consensus-logic/src/state_tracker.rs index acfe9fbd6..cba53e0b9 100644 --- a/crates/consensus-logic/src/state_tracker.rs +++ b/crates/consensus-logic/src/state_tracker.rs @@ -3,17 +3,15 @@ use std::sync::Arc; -use tracing::*; - use alpen_express_db::traits::*; use alpen_express_primitives::params::Params; use alpen_express_state::{ client_state::ClientState, operation::{self, ClientUpdateOutput}, }; +use tracing::*; -use crate::client_transition; -use crate::errors::Error; +use crate::{client_transition, errors::Error}; pub struct StateTracker { params: Arc, @@ -173,8 +171,7 @@ pub fn reconstruct_state( #[cfg(test)] mod tests { - use alpen_express_db::traits::ClientStateStore; - use alpen_express_db::traits::Database; + use alpen_express_db::traits::{ClientStateStore, Database}; use alpen_express_rocksdb::test_utils::get_common_db; use alpen_express_state::{ block::L2Block, diff --git a/crates/consensus-logic/src/sync_manager.rs b/crates/consensus-logic/src/sync_manager.rs index 2ee5b608e..0bddb9c00 100644 --- a/crates/consensus-logic/src/sync_manager.rs +++ b/crates/consensus-logic/src/sync_manager.rs @@ -4,20 +4,22 @@ use std::sync::Arc; -use tokio::sync::{broadcast, mpsc, watch}; -use tracing::*; - use alpen_express_db::traits::Database; use alpen_express_eectl::engine::ExecEngineCtl; use alpen_express_primitives::params::Params; use alpen_express_state::client_state::ClientState; use express_storage::L2BlockManager; use express_tasks::TaskExecutor; +use tokio::sync::{broadcast, mpsc, watch}; +use tracing::*; -use crate::ctl::CsmController; -use crate::message::{ClientUpdateNotif, CsmMessage, ForkChoiceMessage}; -use crate::status::CsmStatus; -use crate::{fork_choice_manager, genesis, worker}; +use crate::{ + ctl::CsmController, + fork_choice_manager, genesis, + message::{ClientUpdateNotif, CsmMessage, ForkChoiceMessage}, + status::CsmStatus, + worker, +}; /// Handle to the core pipeline tasks. pub struct SyncManager { diff --git a/crates/consensus-logic/src/worker.rs b/crates/consensus-logic/src/worker.rs index f223e4bec..87df56a0e 100644 --- a/crates/consensus-logic/src/worker.rs +++ b/crates/consensus-logic/src/worker.rs @@ -2,15 +2,14 @@ use std::sync::Arc; -use express_storage::L2BlockManager; -use tokio::sync::{broadcast, mpsc, watch}; -use tracing::*; - use alpen_express_db::traits::*; use alpen_express_eectl::engine::ExecEngineCtl; use alpen_express_primitives::prelude::*; use alpen_express_state::{client_state::ClientState, operation::SyncAction}; +use express_storage::L2BlockManager; use express_tasks::ShutdownGuard; +use tokio::sync::{broadcast, mpsc, watch}; +use tracing::*; use crate::{ errors::Error, diff --git a/crates/db/src/database.rs b/crates/db/src/database.rs index 2d9f7d8d6..ab038bb43 100644 --- a/crates/db/src/database.rs +++ b/crates/db/src/database.rs @@ -1,8 +1,7 @@ use std::sync::Arc; -use crate::traits::SequencerDatabase; - use super::traits::*; +use crate::traits::SequencerDatabase; /// Shim database type that assumes that all the database impls are wrapped in /// `Arc`s and that the provider and stores are actually the same types. We diff --git a/crates/db/src/stubs/chain_state.rs b/crates/db/src/stubs/chain_state.rs index 71b28516d..539012bf6 100644 --- a/crates/db/src/stubs/chain_state.rs +++ b/crates/db/src/stubs/chain_state.rs @@ -1,12 +1,9 @@ use std::collections::*; +use alpen_express_state::{chain_state::ChainState, state_op, state_op::WriteBatch}; use parking_lot::Mutex; use tracing::*; -use alpen_express_state::chain_state::ChainState; -use alpen_express_state::state_op; -use alpen_express_state::state_op::WriteBatch; - use crate::{errors::DbError, traits::*, DbResult}; struct InnerState { diff --git a/crates/db/src/stubs/l2.rs b/crates/db/src/stubs/l2.rs index b91a1cda1..2bd8bb822 100644 --- a/crates/db/src/stubs/l2.rs +++ b/crates/db/src/stubs/l2.rs @@ -1,12 +1,12 @@ use std::collections::*; -use alpen_express_state::block::L2BlockBundle; +use alpen_express_state::{block::L2BlockBundle, prelude::*}; use parking_lot::Mutex; -use alpen_express_state::prelude::*; - -use crate::traits::BlockStatus; -use crate::{traits::*, DbResult}; +use crate::{ + traits::{BlockStatus, *}, + DbResult, +}; /// Dummy implementation that isn't really compliant with the spec, but we don't /// care because we just want to get something running. :sunglasses:. diff --git a/crates/db/src/traits.rs b/crates/db/src/traits.rs index c91748846..e538c822d 100644 --- a/crates/db/src/traits.rs +++ b/crates/db/src/traits.rs @@ -3,23 +3,20 @@ use std::sync::Arc; -use alpen_express_state::block::L2BlockBundle; +use alpen_express_mmr::CompactMmr; +use alpen_express_primitives::{l1::*, prelude::*}; +use alpen_express_state::{ + block::L2BlockBundle, chain_state::ChainState, client_state::ClientState, operation::*, + prelude::*, state_op::WriteBatch, sync_event::SyncEvent, +}; use borsh::{BorshDeserialize, BorshSerialize}; #[cfg(feature = "mocks")] use mockall::automock; -use alpen_express_mmr::CompactMmr; -use alpen_express_primitives::{l1::*, prelude::*}; -use alpen_express_state::chain_state::ChainState; -use alpen_express_state::client_state::ClientState; -use alpen_express_state::operation::*; -use alpen_express_state::prelude::*; -use alpen_express_state::state_op::WriteBatch; -use alpen_express_state::sync_event::SyncEvent; - -use crate::types::BlobEntry; -use crate::types::L1TxEntry; -use crate::DbResult; +use crate::{ + types::{BlobEntry, L1TxEntry}, + DbResult, +}; /// Common database interface that we can parameterize worker tasks over if /// parameterizing them over each individual trait gets cumbersome or if we need diff --git a/crates/db/src/types.rs b/crates/db/src/types.rs index 676a0a898..4645f68d5 100644 --- a/crates/db/src/types.rs +++ b/crates/db/src/types.rs @@ -1,10 +1,9 @@ //! Module for database local types +use alpen_express_primitives::buf::Buf32; use arbitrary::Arbitrary; use bitcoin::{consensus::serialize, Transaction}; use borsh::{BorshDeserialize, BorshSerialize}; - -use alpen_express_primitives::buf::Buf32; use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, PartialEq, BorshSerialize, BorshDeserialize, Arbitrary)] @@ -118,9 +117,10 @@ pub enum ExcludeReason { #[cfg(test)] mod tests { - use super::*; use serde_json; + use super::*; + #[test] fn check_serde_of_l1txstatus() { let test_cases: Vec<(L1TxStatus, &str)> = vec![ diff --git a/crates/eectl/src/engine.rs b/crates/eectl/src/engine.rs index ae8c8ba11..102b4324f 100644 --- a/crates/eectl/src/engine.rs +++ b/crates/eectl/src/engine.rs @@ -10,8 +10,7 @@ use alpen_express_state::id::L2BlockId; -use crate::errors::*; -use crate::messages::*; +use crate::{errors::*, messages::*}; /// Interface to control an execution engine. This is defined in terms of /// express semantics which will be produced inside the EL impl according to diff --git a/crates/eectl/src/stub.rs b/crates/eectl/src/stub.rs index 4b213cffa..8142c65f1 100644 --- a/crates/eectl/src/stub.rs +++ b/crates/eectl/src/stub.rs @@ -5,17 +5,12 @@ //! returning `Ready` with dummy state. We might extend this slightly to make //! it more believable. -use std::collections::*; -use std::sync::Mutex; -use std::time; +use std::{collections::*, sync::Mutex, time}; use alpen_express_primitives::buf::Buf32; -use alpen_express_state::exec_update::UpdateInput; -use alpen_express_state::prelude::*; +use alpen_express_state::{exec_update::UpdateInput, prelude::*}; -use crate::engine::*; -use crate::errors::*; -use crate::messages::*; +use crate::{engine::*, errors::*, messages::*}; struct State { next_idx: u64, diff --git a/crates/evmexec/src/block.rs b/crates/evmexec/src/block.rs index 7c7c89b9d..ba6fd212c 100644 --- a/crates/evmexec/src/block.rs +++ b/crates/evmexec/src/block.rs @@ -1,10 +1,9 @@ +use alpen_express_primitives::evm_exec::EVMExtraPayload; +use alpen_express_state::block::{L2Block, L2BlockBundle}; use borsh::BorshDeserialize; use reth_primitives::B256; use thiserror::Error; -use alpen_express_primitives::evm_exec::EVMExtraPayload; -use alpen_express_state::block::{L2Block, L2BlockBundle}; - pub(crate) struct EVML2Block { #[allow(dead_code)] l2_block: L2Block, diff --git a/crates/evmexec/src/el_payload.rs b/crates/evmexec/src/el_payload.rs index 962403c8c..a6ce9570f 100644 --- a/crates/evmexec/src/el_payload.rs +++ b/crates/evmexec/src/el_payload.rs @@ -1,3 +1,8 @@ +use alpen_express_primitives::{ + buf::{Buf20, Buf32}, + evm_exec::create_evm_extra_payload, +}; +use alpen_express_state::exec_update::UpdateInput; use arbitrary::Arbitrary; use borsh::{BorshDeserialize, BorshSerialize}; use reth_primitives::B256; @@ -5,12 +10,6 @@ use reth_rpc_types::ExecutionPayloadV1; use reth_rpc_types_compat::engine::try_payload_v1_to_block; use thiserror::Error; -use alpen_express_primitives::{ - buf::{Buf20, Buf32}, - evm_exec::create_evm_extra_payload, -}; -use alpen_express_state::exec_update::UpdateInput; - #[derive(Debug, Clone, PartialEq, BorshSerialize, BorshDeserialize, Arbitrary)] pub(crate) struct ElPayload { /// The parent hash of the block. diff --git a/crates/evmexec/src/engine.rs b/crates/evmexec/src/engine.rs index 4903663f7..99cae38fa 100644 --- a/crates/evmexec/src/engine.rs +++ b/crates/evmexec/src/engine.rs @@ -1,26 +1,24 @@ use std::sync::Arc; +use alpen_express_eectl::{ + engine::{BlockStatus, ExecEngineCtl, PayloadStatus}, + errors::{EngineError, EngineResult}, + messages::{ELDepositData, ExecPayloadData, Op, PayloadEnv}, +}; +use alpen_express_state::{block::L2BlockBundle, exec_update::UpdateInput, id::L2BlockId}; +use express_storage::L2BlockManager; use futures::future::TryFutureExt; use reth_primitives::{Address, B256}; -use reth_rpc_types::engine::{ - ExecutionPayloadFieldV2, ExecutionPayloadInputV2, ForkchoiceState, PayloadAttributes, - PayloadId, PayloadStatusEnum, +use reth_rpc_types::{ + engine::{ + ExecutionPayloadFieldV2, ExecutionPayloadInputV2, ForkchoiceState, PayloadAttributes, + PayloadId, PayloadStatusEnum, + }, + Withdrawal, }; -use reth_rpc_types::Withdrawal; -use tokio::runtime::Handle; -use tokio::sync::Mutex; - -use alpen_express_eectl::engine::{BlockStatus, ExecEngineCtl, PayloadStatus}; -use alpen_express_eectl::errors::{EngineError, EngineResult}; -use alpen_express_eectl::messages::{ELDepositData, ExecPayloadData, Op, PayloadEnv}; -use alpen_express_state::block::L2BlockBundle; -use alpen_express_state::exec_update::UpdateInput; -use alpen_express_state::id::L2BlockId; -use express_storage::L2BlockManager; +use tokio::{runtime::Handle, sync::Mutex}; -use crate::block::EVML2Block; -use crate::el_payload::ElPayload; -use crate::http_client::EngineRpc; +use crate::{block::EVML2Block, el_payload::ElPayload, http_client::EngineRpc}; fn address_from_slice(slice: &[u8]) -> Option
{ let slice: Option<[u8; 20]> = slice.try_into().ok(); @@ -328,20 +326,18 @@ struct ForkchoiceStatePartial { #[cfg(test)] mod tests { - use rand::Rng; - use reth_primitives::revm_primitives::FixedBytes; - use reth_primitives::{Bloom, Bytes, U256}; - use reth_rpc_types::engine::{ExecutionPayloadEnvelopeV2, ForkchoiceUpdated}; - use reth_rpc_types::ExecutionPayloadV1; - - use alpen_express_eectl::errors::EngineResult; - use alpen_express_eectl::messages::PayloadEnv; + use alpen_express_eectl::{errors::EngineResult, messages::PayloadEnv}; use alpen_express_primitives::buf::Buf32; use alpen_express_state::block::{L2Block, L2BlockAccessory}; - - use crate::http_client::MockEngineRpc; + use rand::Rng; + use reth_primitives::{revm_primitives::FixedBytes, Bloom, Bytes, U256}; + use reth_rpc_types::{ + engine::{ExecutionPayloadEnvelopeV2, ForkchoiceUpdated}, + ExecutionPayloadV1, + }; use super::*; + use crate::http_client::MockEngineRpc; fn random_el_payload() -> ElPayload { random_execution_payload_v1().into() diff --git a/crates/evmexec/src/fork_choice_state.rs b/crates/evmexec/src/fork_choice_state.rs index 9b96dcd89..b692d0d3b 100644 --- a/crates/evmexec/src/fork_choice_state.rs +++ b/crates/evmexec/src/fork_choice_state.rs @@ -1,15 +1,14 @@ use std::sync::Arc; -use anyhow::{Context, Result}; -use reth_primitives::B256; -use reth_rpc_types::engine::ForkchoiceState; - use alpen_express_db::{ errors::DbError, traits::{ClientStateProvider, Database, L2DataProvider}, }; use alpen_express_primitives::params::RollupParams; use alpen_express_state::{block::L2BlockBundle, client_state::ClientState, id::L2BlockId}; +use anyhow::{Context, Result}; +use reth_primitives::B256; +use reth_rpc_types::engine::ForkchoiceState; use crate::block::EVML2Block; diff --git a/crates/evmexec/src/http_client.rs b/crates/evmexec/src/http_client.rs index c587f7dd4..fbb97e927 100644 --- a/crates/evmexec/src/http_client.rs +++ b/crates/evmexec/src/http_client.rs @@ -1,7 +1,8 @@ use std::sync::Arc; -use jsonrpsee::http_client::HttpClient; -use jsonrpsee::http_client::{transport::HttpBackend, HttpClientBuilder}; +use jsonrpsee::http_client::{transport::HttpBackend, HttpClient, HttpClientBuilder}; +#[cfg(test)] +use mockall::automock; use reth_node_ethereum::EthEngineTypes; use reth_primitives::{Block, BlockHash}; use reth_rpc_api::{EngineApiClient, EthApiClient}; @@ -11,9 +12,6 @@ use reth_rpc_types::engine::{ ForkchoiceUpdated, JwtSecret, PayloadAttributes, PayloadId, }; -#[cfg(test)] -use mockall::automock; - fn http_client(http_url: &str, secret: JwtSecret) -> HttpClient> { let middleware = tower::ServiceBuilder::new().layer(AuthClientLayer::new(secret)); diff --git a/crates/primitives/src/buf.rs b/crates/primitives/src/buf.rs index 9520a7329..c718d0a59 100644 --- a/crates/primitives/src/buf.rs +++ b/crates/primitives/src/buf.rs @@ -1,10 +1,11 @@ -use std::fmt; -use std::io::{self, Read, Write}; -use std::str; +use std::{ + fmt, + io::{self, Read, Write}, + str, +}; use arbitrary::Arbitrary; -use bitcoin::hashes::Hash; -use bitcoin::BlockHash; +use bitcoin::{hashes::Hash, BlockHash}; use borsh::{BorshDeserialize, BorshSerialize}; use reth_primitives::alloy_primitives::FixedBytes; use serde::{Deserialize, Deserializer}; diff --git a/crates/primitives/src/l1.rs b/crates/primitives/src/l1.rs index 2eb2ec070..3eac5d6e5 100644 --- a/crates/primitives/src/l1.rs +++ b/crates/primitives/src/l1.rs @@ -1,8 +1,7 @@ use std::fmt; use arbitrary::Arbitrary; -use bitcoin::hashes::Hash; -use bitcoin::{consensus::serialize, Block}; +use bitcoin::{consensus::serialize, hashes::Hash, Block}; use borsh::{BorshDeserialize, BorshSerialize}; use crate::buf::Buf32; diff --git a/crates/primitives/src/prelude.rs b/crates/primitives/src/prelude.rs index f4c7c7791..dbd6a209f 100644 --- a/crates/primitives/src/prelude.rs +++ b/crates/primitives/src/prelude.rs @@ -1,3 +1,2 @@ // Reexports from elsewhere in the crate. -pub use crate::buf::*; -pub use crate::params::*; +pub use crate::{buf::*, params::*}; diff --git a/crates/prover/adapters/sp1/src/sp1.rs b/crates/prover/adapters/sp1/src/sp1.rs index 62f08d27f..398af63e5 100644 --- a/crates/prover/adapters/sp1/src/sp1.rs +++ b/crates/prover/adapters/sp1/src/sp1.rs @@ -1,9 +1,7 @@ use anyhow::Ok; - +use express_zkvm::{Proof, ProverOptions, VerifcationKey, ZKVMHost, ZKVMVerifier}; use serde::{de::DeserializeOwned, Serialize}; use serde_json::to_vec; - -use express_zkvm::{Proof, ProverOptions, VerifcationKey, ZKVMHost, ZKVMVerifier}; use sp1_sdk::{ProverClient, SP1ProofWithPublicValues, SP1Stdin, SP1VerifyingKey}; /// A host for the `SP1` zkVM that stores the guest program in ELF format. diff --git a/crates/prover/primitives/src/db.rs b/crates/prover/primitives/src/db.rs index 04f7f3075..261974c84 100644 --- a/crates/prover/primitives/src/db.rs +++ b/crates/prover/primitives/src/db.rs @@ -18,11 +18,6 @@ use std::collections::hash_map::Entry; -use crate::{ - mpt::{keccak, StateAccount, KECCAK_EMPTY}, - ZKVMInput, -}; - use anyhow::{anyhow, Result}; // use hashbrown::hash_map::Entry; use reth_primitives::{Address, Bytes, B256, U256}; @@ -31,6 +26,11 @@ use revm::{ primitives::{AccountInfo, Bytecode, HashMap}, }; +use crate::{ + mpt::{keccak, StateAccount, KECCAK_EMPTY}, + ZKVMInput, +}; + /// A helper trait to extend [InMemoryDB] with additional functionality. pub trait InMemoryDBHelper { /// Create an [InMemoryDB] from a given [SP1RethInput]. diff --git a/crates/prover/primitives/src/lib.rs b/crates/prover/primitives/src/lib.rs index 8be4fd61c..5eb1e6337 100644 --- a/crates/prover/primitives/src/lib.rs +++ b/crates/prover/primitives/src/lib.rs @@ -20,18 +20,19 @@ pub mod db; pub mod mpt; pub mod processor; -use crate::mpt::{MptNode, StorageEntry}; +use std::collections::HashMap; use db::InMemoryDBHelper; use mpt::keccak; use processor::{EvmConfig, EvmProcessor}; -use reth_primitives::alloy_primitives::FixedBytes; -use reth_primitives::{Address, Bytes, Header, TransactionSignedNoHash, Withdrawal, B256}; +use reth_primitives::{ + alloy_primitives::FixedBytes, Address, Bytes, Header, TransactionSignedNoHash, Withdrawal, B256, +}; use revm::InMemoryDB; -use std::collections::HashMap; - use serde::{Deserialize, Serialize}; +use crate::mpt::{MptNode, StorageEntry}; + /// Public Parameters that proof asserts #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct ELProofPublicParams { @@ -129,9 +130,11 @@ pub fn process_block_transaction( #[cfg(test)] mod tests { - use super::*; - use revm::primitives::SpecId; use std::path::PathBuf; + + use revm::primitives::SpecId; + + use super::*; const EVM_CONFIG: EvmConfig = EvmConfig { chain_id: 12345, spec_id: SpecId::SHANGHAI, diff --git a/crates/prover/primitives/src/mpt.rs b/crates/prover/primitives/src/mpt.rs index 6fe15e239..8b94ddfa6 100644 --- a/crates/prover/primitives/src/mpt.rs +++ b/crates/prover/primitives/src/mpt.rs @@ -17,27 +17,27 @@ // limitations under the License. use alloc::boxed::Box; -use alloy_rlp::Encodable; -use alloy_rpc_types::EIP1186AccountProofResponse; use core::{ cell::RefCell, cmp, fmt::{Debug, Write}, iter, mem, }; -use reth_primitives::alloy_primitives::{b256, B256}; // use hashbrown::HashMap; use std::collections::HashMap; +use alloy_rlp::Encodable; +use alloy_rlp_derive::{RlpDecodable, RlpEncodable, RlpMaxEncodedLen}; +use alloy_rpc_types::EIP1186AccountProofResponse; +use anyhow::{Context, Result}; +use reth_primitives::{ + alloy_primitives::{b256, TxNumber, B256, U256}, + Address, +}; use rlp::{Decodable, DecoderError, Prototype, Rlp}; use serde::{Deserialize, Serialize}; use thiserror::Error as ThisError; -use alloy_rlp_derive::{RlpDecodable, RlpEncodable, RlpMaxEncodedLen}; -use anyhow::{Context, Result}; -use reth_primitives::alloy_primitives::{TxNumber, U256}; -use reth_primitives::Address; - pub type StorageEntry = (MptNode, Vec); /// Represents an Ethereum account within the state trie. diff --git a/crates/prover/primitives/src/processor.rs b/crates/prover/primitives/src/processor.rs index c7b493e55..b110c7631 100644 --- a/crates/prover/primitives/src/processor.rs +++ b/crates/prover/primitives/src/processor.rs @@ -16,10 +16,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::{ - mpt::{keccak, RlpBytes, StateAccount}, - ZKVMInput, -}; +use std::{mem, mem::take}; use alloy_eips::eip1559::BaseFeeParams; use alloy_rlp::BufMut; @@ -37,7 +34,11 @@ use revm::{ primitives::{SpecId, TransactTo, TxEnv}, Database, DatabaseCommit, Evm, }; -use std::{mem, mem::take}; + +use crate::{ + mpt::{keccak, RlpBytes, StateAccount}, + ZKVMInput, +}; /// The divisor for the gas limit bound. pub const GAS_LIMIT_DIVISOR: u64 = 1024; diff --git a/crates/reth/db/src/lib.rs b/crates/reth/db/src/lib.rs index 6ec080a59..da4678e24 100644 --- a/crates/reth/db/src/lib.rs +++ b/crates/reth/db/src/lib.rs @@ -1,7 +1,5 @@ pub mod rocksdb; -pub use alpen_express_db::errors; -pub use alpen_express_db::DbResult; - +pub use alpen_express_db::{errors, DbResult}; use reth_primitives::B256; use zkvm_primitives::ZKVMInput; diff --git a/crates/reth/db/src/rocksdb/db.rs b/crates/reth/db/src/rocksdb/db.rs index 4269a15b9..132e46f79 100644 --- a/crates/reth/db/src/rocksdb/db.rs +++ b/crates/reth/db/src/rocksdb/db.rs @@ -4,9 +4,8 @@ use reth_primitives::B256; use rockbound::{SchemaDBOperations, SchemaDBOperationsExt}; use zkvm_primitives::ZKVMInput; -use crate::{errors::DbError, DbResult, WitnessProvider, WitnessStore}; - use super::schema::BlockWitnessSchema; +use crate::{errors::DbError, DbResult, WitnessProvider, WitnessStore}; #[derive(Debug)] pub struct WitnessDB { diff --git a/crates/reth/db/src/rocksdb/schema.rs b/crates/reth/db/src/rocksdb/schema.rs index abe48f09b..9b151d8df 100644 --- a/crates/reth/db/src/rocksdb/schema.rs +++ b/crates/reth/db/src/rocksdb/schema.rs @@ -1,9 +1,8 @@ +use alpen_express_rocksdb::{ + define_table_with_seek_key_codec, define_table_without_codec, impl_borsh_value_codec, +}; use reth_primitives::B256; -use alpen_express_rocksdb::define_table_with_seek_key_codec; -use alpen_express_rocksdb::define_table_without_codec; -use alpen_express_rocksdb::impl_borsh_value_codec; - // NOTE: using seek_key_codec as B256 does not derive borsh serialization define_table_with_seek_key_codec!( /// store of block witness data. Data stored as serialized bytes for directly serving in rpc diff --git a/crates/reth/rpc/src/lib.rs b/crates/reth/rpc/src/lib.rs index d6356b140..2ca75a6a2 100644 --- a/crates/reth/rpc/src/lib.rs +++ b/crates/reth/rpc/src/lib.rs @@ -2,10 +2,9 @@ mod rpc; +use jsonrpsee::{core::RpcResult, proc_macros::rpc}; use reth_primitives::B256; pub use rpc::AlpenRPC; - -use jsonrpsee::{core::RpcResult, proc_macros::rpc}; use serde::{Deserialize, Serialize}; use zkvm_primitives::ZKVMInput; diff --git a/crates/rocksdb-store/src/broadcaster/db.rs b/crates/rocksdb-store/src/broadcaster/db.rs index 476502cdb..3d049eb35 100644 --- a/crates/rocksdb-store/src/broadcaster/db.rs +++ b/crates/rocksdb-store/src/broadcaster/db.rs @@ -1,9 +1,5 @@ use std::sync::Arc; -use rockbound::{ - utils::get_last, OptimisticTransactionDB as DB, SchemaDBOperationsExt, TransactionRetry, -}; - use alpen_express_db::{ errors::DbError, traits::{BcastProvider, BcastStore, TxBroadcastDatabase}, @@ -11,10 +7,12 @@ use alpen_express_db::{ DbResult, }; use alpen_express_primitives::buf::Buf32; - -use crate::DbOpsConfig; +use rockbound::{ + utils::get_last, OptimisticTransactionDB as DB, SchemaDBOperationsExt, TransactionRetry, +}; use super::schemas::{BcastL1TxIdSchema, BcastL1TxSchema}; +use crate::DbOpsConfig; pub struct BroadcastDb { db: Arc, @@ -132,16 +130,18 @@ impl TxBroadcastDatabase for BroadcastDatabase { #[cfg(test)] mod tests { - use crate::test_utils::get_rocksdb_tmp_instance; - - use super::*; - use alpen_express_db::errors::DbError; - use alpen_express_db::traits::{BcastProvider, BcastStore}; - use alpen_express_db::types::L1TxStatus; + use alpen_express_db::{ + errors::DbError, + traits::{BcastProvider, BcastStore}, + types::L1TxStatus, + }; use alpen_express_primitives::buf::Buf32; use alpen_test_utils::bitcoin::get_test_bitcoin_txns; use bitcoin::hashes::Hash; + use super::*; + use crate::test_utils::get_rocksdb_tmp_instance; + fn setup_db() -> BroadcastDb { let (db, db_ops) = get_rocksdb_tmp_instance().unwrap(); BroadcastDb::new(db, db_ops) diff --git a/crates/rocksdb-store/src/broadcaster/schemas.rs b/crates/rocksdb-store/src/broadcaster/schemas.rs index 53947f351..42c078c21 100644 --- a/crates/rocksdb-store/src/broadcaster/schemas.rs +++ b/crates/rocksdb-store/src/broadcaster/schemas.rs @@ -1,10 +1,10 @@ use alpen_express_db::types::L1TxEntry; use alpen_express_primitives::buf::Buf32; -use crate::define_table_with_default_codec; -use crate::define_table_with_seek_key_codec; -use crate::define_table_without_codec; -use crate::impl_borsh_value_codec; +use crate::{ + define_table_with_default_codec, define_table_with_seek_key_codec, define_table_without_codec, + impl_borsh_value_codec, +}; define_table_with_seek_key_codec!( /// A table to store mapping of idx to L1 txid diff --git a/crates/rocksdb-store/src/chain_state/db.rs b/crates/rocksdb-store/src/chain_state/db.rs index a77e27524..035c7f80d 100644 --- a/crates/rocksdb-store/src/chain_state/db.rs +++ b/crates/rocksdb-store/src/chain_state/db.rs @@ -1,16 +1,14 @@ use std::sync::Arc; -use rockbound::OptimisticTransactionDB; -use rockbound::{SchemaBatch, SchemaDBOperationsExt}; - -use alpen_express_db::errors::DbError; -use alpen_express_db::traits::*; -use alpen_express_db::DbResult; +use alpen_express_db::{errors::DbError, traits::*, DbResult}; use alpen_express_state::state_op; +use rockbound::{OptimisticTransactionDB, SchemaBatch, SchemaDBOperationsExt}; use super::schemas::{ChainStateSchema, WriteBatchSchema}; -use crate::utils::{get_first_idx, get_last_idx}; -use crate::DbOpsConfig; +use crate::{ + utils::{get_first_idx, get_last_idx}, + DbOpsConfig, +}; pub struct ChainStateDb { db: Arc, @@ -150,12 +148,12 @@ impl ChainstateStore for ChainStateDb { #[cfg(feature = "test_utils")] #[cfg(test)] mod tests { - use crate::test_utils::get_rocksdb_tmp_instance; use alpen_express_state::chain_state::ChainState; use alpen_test_utils::ArbitraryGenerator; use state_op::WriteBatch; use super::*; + use crate::test_utils::get_rocksdb_tmp_instance; fn setup_db() -> ChainStateDb { let (db, db_ops) = get_rocksdb_tmp_instance().unwrap(); diff --git a/crates/rocksdb-store/src/chain_state/schemas.rs b/crates/rocksdb-store/src/chain_state/schemas.rs index 3e19dfc96..671e5dd44 100644 --- a/crates/rocksdb-store/src/chain_state/schemas.rs +++ b/crates/rocksdb-store/src/chain_state/schemas.rs @@ -1,9 +1,6 @@ -use alpen_express_state::chain_state::ChainState; -use alpen_express_state::state_op::WriteBatch; +use alpen_express_state::{chain_state::ChainState, state_op::WriteBatch}; -use crate::define_table_with_seek_key_codec; -use crate::define_table_without_codec; -use crate::impl_borsh_value_codec; +use crate::{define_table_with_seek_key_codec, define_table_without_codec, impl_borsh_value_codec}; // Consensus Output Schema and corresponding codecs implementation define_table_with_seek_key_codec!( diff --git a/crates/rocksdb-store/src/client_state/db.rs b/crates/rocksdb-store/src/client_state/db.rs index 88b4caa04..c65939f2a 100644 --- a/crates/rocksdb-store/src/client_state/db.rs +++ b/crates/rocksdb-store/src/client_state/db.rs @@ -1,15 +1,11 @@ use std::sync::Arc; -use rockbound::OptimisticTransactionDB; -use rockbound::Schema; -use rockbound::SchemaDBOperationsExt; - use alpen_express_db::{errors::*, traits::*, DbResult}; use alpen_express_state::operation::*; - -use crate::DbOpsConfig; +use rockbound::{OptimisticTransactionDB, Schema, SchemaDBOperationsExt}; use super::schemas::{ClientStateSchema, ClientUpdateOutputSchema}; +use crate::DbOpsConfig; pub struct ClientStateDb { db: Arc, @@ -132,9 +128,8 @@ mod tests { use alpen_express_state::client_state::ClientState; use alpen_test_utils::*; - use crate::test_utils::get_rocksdb_tmp_instance; - use super::*; + use crate::test_utils::get_rocksdb_tmp_instance; fn setup_db() -> ClientStateDb { let (db, db_ops) = get_rocksdb_tmp_instance().unwrap(); diff --git a/crates/rocksdb-store/src/client_state/schemas.rs b/crates/rocksdb-store/src/client_state/schemas.rs index 7ee8aab81..ca3dd47b7 100644 --- a/crates/rocksdb-store/src/client_state/schemas.rs +++ b/crates/rocksdb-store/src/client_state/schemas.rs @@ -1,9 +1,6 @@ -use alpen_express_state::client_state::ClientState; -use alpen_express_state::operation::ClientUpdateOutput; +use alpen_express_state::{client_state::ClientState, operation::ClientUpdateOutput}; -use crate::define_table_with_seek_key_codec; -use crate::define_table_without_codec; -use crate::impl_borsh_value_codec; +use crate::{define_table_with_seek_key_codec, define_table_without_codec, impl_borsh_value_codec}; // Consensus Output Schema and corresponding codecs implementation define_table_with_seek_key_codec!( diff --git a/crates/rocksdb-store/src/l1/db.rs b/crates/rocksdb-store/src/l1/db.rs index b12fe6529..03e625567 100644 --- a/crates/rocksdb-store/src/l1/db.rs +++ b/crates/rocksdb-store/src/l1/db.rs @@ -1,20 +1,19 @@ use std::sync::Arc; -use rockbound::rocksdb::ReadOptions; -use rockbound::schema::KeyEncoder; -use rockbound::{OptimisticTransactionDB, SchemaBatch, SchemaDBOperationsExt}; -use tracing::*; - +use alpen_express_db::{errors::DbError, traits::*, DbResult}; use alpen_express_mmr::CompactMmr; use alpen_express_primitives::{ buf::Buf32, l1::{L1BlockManifest, L1Tx, L1TxRef}, }; - -use crate::DbOpsConfig; +use rockbound::{ + rocksdb::ReadOptions, schema::KeyEncoder, OptimisticTransactionDB, SchemaBatch, + SchemaDBOperationsExt, +}; +use tracing::*; use super::schemas::{L1BlockSchema, MmrSchema, TxnSchema}; -use alpen_express_db::{errors::DbError, traits::*, DbResult}; +use crate::DbOpsConfig; pub struct L1Db { db: Arc, @@ -191,9 +190,8 @@ mod tests { use alpen_express_primitives::l1::L1TxProof; use alpen_test_utils::ArbitraryGenerator; - use crate::test_utils::get_rocksdb_tmp_instance; - use super::*; + use crate::test_utils::get_rocksdb_tmp_instance; fn setup_db() -> L1Db { let (db, db_ops) = get_rocksdb_tmp_instance().unwrap(); diff --git a/crates/rocksdb-store/src/l1/schemas.rs b/crates/rocksdb-store/src/l1/schemas.rs index e9339d528..e68fb4f29 100644 --- a/crates/rocksdb-store/src/l1/schemas.rs +++ b/crates/rocksdb-store/src/l1/schemas.rs @@ -4,10 +4,10 @@ use alpen_express_primitives::{ l1::{L1BlockManifest, L1Tx}, }; -use crate::define_table_with_default_codec; -use crate::define_table_with_seek_key_codec; -use crate::define_table_without_codec; -use crate::impl_borsh_value_codec; +use crate::{ + define_table_with_default_codec, define_table_with_seek_key_codec, define_table_without_codec, + impl_borsh_value_codec, +}; // Readability for header hash type HeaderHash = Buf32; diff --git a/crates/rocksdb-store/src/l2/db.rs b/crates/rocksdb-store/src/l2/db.rs index 41d368764..36697e0d2 100644 --- a/crates/rocksdb-store/src/l2/db.rs +++ b/crates/rocksdb-store/src/l2/db.rs @@ -1,13 +1,12 @@ use std::sync::Arc; -use rockbound::{OptimisticTransactionDB, SchemaBatch, SchemaDBOperationsExt}; - use alpen_express_db::{ errors::DbError, traits::{BlockStatus, L2DataProvider, L2DataStore}, DbResult, }; use alpen_express_state::{block::L2BlockBundle, prelude::*}; +use rockbound::{OptimisticTransactionDB, SchemaBatch, SchemaDBOperationsExt}; use super::schemas::{L2BlockSchema, L2BlockStatusSchema}; use crate::{l2::schemas::L2BlockHeightSchema, DbOpsConfig}; @@ -114,10 +113,9 @@ impl L2DataProvider for L2Db { #[cfg(feature = "test_utils")] #[cfg(test)] mod tests { - use super::*; - use alpen_test_utils::ArbitraryGenerator; + use super::*; use crate::test_utils::get_rocksdb_tmp_instance; fn get_mock_data() -> L2BlockBundle { diff --git a/crates/rocksdb-store/src/l2/schemas.rs b/crates/rocksdb-store/src/l2/schemas.rs index 356b44ace..4f673675f 100644 --- a/crates/rocksdb-store/src/l2/schemas.rs +++ b/crates/rocksdb-store/src/l2/schemas.rs @@ -1,11 +1,10 @@ use alpen_express_db::traits::BlockStatus; -use alpen_express_state::block::L2BlockBundle; -use alpen_express_state::id::L2BlockId; +use alpen_express_state::{block::L2BlockBundle, id::L2BlockId}; -use crate::define_table_with_default_codec; -use crate::define_table_with_seek_key_codec; -use crate::define_table_without_codec; -use crate::impl_borsh_value_codec; +use crate::{ + define_table_with_default_codec, define_table_with_seek_key_codec, define_table_without_codec, + impl_borsh_value_codec, +}; define_table_with_default_codec!( /// A table to store L2 Block data. Maps block id to Block diff --git a/crates/rocksdb-store/src/lib.rs b/crates/rocksdb-store/src/lib.rs index ac5869502..be2b1c5b3 100644 --- a/crates/rocksdb-store/src/lib.rs +++ b/crates/rocksdb-store/src/lib.rs @@ -35,24 +35,24 @@ pub const STORE_COLUMN_FAMILIES: &[ColumnFamilyName] = &[ // TODO add col families for other store types ]; -use broadcaster::schemas::{BcastL1TxIdSchema, BcastL1TxSchema}; // Re-exports pub use broadcaster::db::BroadcastDb; +use broadcaster::schemas::{BcastL1TxIdSchema, BcastL1TxSchema}; pub use chain_state::db::ChainStateDb; pub use client_state::db::ClientStateDb; pub use l1::db::L1Db; -pub use sequencer::db::SeqDb; -pub use sync_event::db::SyncEventDb; - use l2::schemas::{L2BlockHeightSchema, L2BlockSchema, L2BlockStatusSchema}; - use rockbound::{schema::ColumnFamilyName, Schema}; +pub use sequencer::db::SeqDb; use sequencer::schemas::{SeqBlobIdSchema, SeqBlobSchema, SeqL1TxIdSchema, SeqL1TxnSchema}; +pub use sync_event::db::SyncEventDb; -use crate::chain_state::schemas::{ChainStateSchema, WriteBatchSchema}; -use crate::client_state::schemas::{ClientStateSchema, ClientUpdateOutputSchema}; -use crate::l1::schemas::{L1BlockSchema, MmrSchema, TxnSchema}; -use crate::sync_event::schemas::SyncEventSchema; +use crate::{ + chain_state::schemas::{ChainStateSchema, WriteBatchSchema}, + client_state::schemas::{ClientStateSchema, ClientUpdateOutputSchema}, + l1::schemas::{L1BlockSchema, MmrSchema, TxnSchema}, + sync_event::schemas::SyncEventSchema, +}; /// database operations configuration #[derive(Clone, Copy, Debug)] diff --git a/crates/rocksdb-store/src/sequencer/db.rs b/crates/rocksdb-store/src/sequencer/db.rs index e28726d2e..1ae36cc5f 100644 --- a/crates/rocksdb-store/src/sequencer/db.rs +++ b/crates/rocksdb-store/src/sequencer/db.rs @@ -1,7 +1,5 @@ use std::sync::Arc; -use rockbound::{OptimisticTransactionDB, SchemaBatch, SchemaDBOperationsExt}; - use alpen_express_db::{ errors::DbError, traits::{SeqDataProvider, SeqDataStore, SequencerDatabase}, @@ -9,6 +7,7 @@ use alpen_express_db::{ DbResult, }; use alpen_express_primitives::buf::Buf32; +use rockbound::{OptimisticTransactionDB, SchemaBatch, SchemaDBOperationsExt}; use super::schemas::{SeqBlobIdSchema, SeqBlobSchema, SeqL1TxnSchema}; use crate::DbOpsConfig; @@ -127,20 +126,17 @@ impl SequencerDatabase for SequencerDB { #[cfg(feature = "test_utils")] #[cfg(test)] mod tests { - use bitcoin::consensus::serialize; - use bitcoin::hashes::Hash; - - use alpen_express_db::errors::DbError; - use alpen_express_db::traits::{SeqDataProvider, SeqDataStore}; + use alpen_express_db::{ + errors::DbError, + traits::{SeqDataProvider, SeqDataStore}, + }; use alpen_express_primitives::buf::Buf32; - use alpen_test_utils::bitcoin::get_test_bitcoin_txns; - use alpen_test_utils::ArbitraryGenerator; - - use crate::test_utils::get_rocksdb_tmp_instance; + use alpen_test_utils::{bitcoin::get_test_bitcoin_txns, ArbitraryGenerator}; + use bitcoin::{consensus::serialize, hashes::Hash}; + use test; use super::*; - - use test; + use crate::test_utils::get_rocksdb_tmp_instance; fn get_commit_reveal_txns() -> ((Buf32, Vec), (Buf32, Vec)) { let txns = get_test_bitcoin_txns(); diff --git a/crates/rocksdb-store/src/sequencer/schemas.rs b/crates/rocksdb-store/src/sequencer/schemas.rs index 4dff751aa..859f4e70e 100644 --- a/crates/rocksdb-store/src/sequencer/schemas.rs +++ b/crates/rocksdb-store/src/sequencer/schemas.rs @@ -1,10 +1,10 @@ +use alpen_express_db::types::BlobEntry; use alpen_express_primitives::buf::Buf32; -use crate::define_table_with_default_codec; -use crate::define_table_with_seek_key_codec; -use crate::define_table_without_codec; -use crate::impl_borsh_value_codec; -use alpen_express_db::types::BlobEntry; +use crate::{ + define_table_with_default_codec, define_table_with_seek_key_codec, define_table_without_codec, + impl_borsh_value_codec, +}; define_table_with_default_codec!( /// A table to store L1 txns diff --git a/crates/rocksdb-store/src/sync_event/db.rs b/crates/rocksdb-store/src/sync_event/db.rs index e17c5a85c..8b2e19166 100644 --- a/crates/rocksdb-store/src/sync_event/db.rs +++ b/crates/rocksdb-store/src/sync_event/db.rs @@ -1,15 +1,15 @@ use std::sync::Arc; -use rockbound::{OptimisticTransactionDB, SchemaBatch, SchemaDBOperationsExt}; - -use alpen_express_db::errors::DbError; -use alpen_express_db::traits::{SyncEventProvider, SyncEventStore}; -use alpen_express_db::DbResult; +use alpen_express_db::{ + errors::DbError, + traits::{SyncEventProvider, SyncEventStore}, + DbResult, +}; use alpen_express_state::sync_event::SyncEvent; - -use crate::DbOpsConfig; +use rockbound::{OptimisticTransactionDB, SchemaBatch, SchemaDBOperationsExt}; use super::schemas::{SyncEventSchema, SyncEventWithTimestamp}; +use crate::DbOpsConfig; pub struct SyncEventDb { db: Arc, @@ -122,9 +122,8 @@ mod tests { use alpen_test_utils::*; - use crate::test_utils::get_rocksdb_tmp_instance; - use super::*; + use crate::test_utils::get_rocksdb_tmp_instance; fn setup_db() -> SyncEventDb { let (db, db_ops) = get_rocksdb_tmp_instance().unwrap(); diff --git a/crates/rocksdb-store/src/sync_event/schemas.rs b/crates/rocksdb-store/src/sync_event/schemas.rs index ceed31420..3316adf72 100644 --- a/crates/rocksdb-store/src/sync_event/schemas.rs +++ b/crates/rocksdb-store/src/sync_event/schemas.rs @@ -1,10 +1,9 @@ +use std::time::{SystemTime, UNIX_EPOCH}; + use alpen_express_state::sync_event::SyncEvent; use borsh::{BorshDeserialize, BorshSerialize}; -use std::time::{SystemTime, UNIX_EPOCH}; -use crate::define_table_with_seek_key_codec; -use crate::define_table_without_codec; -use crate::impl_borsh_value_codec; +use crate::{define_table_with_seek_key_codec, define_table_without_codec, impl_borsh_value_codec}; #[derive(Clone, Debug, PartialEq, Eq, BorshSerialize, BorshDeserialize)] pub struct SyncEventWithTimestamp { diff --git a/crates/rocksdb-store/src/test_utils.rs b/crates/rocksdb-store/src/test_utils.rs index 2eed95af3..cefde9bbe 100644 --- a/crates/rocksdb-store/src/test_utils.rs +++ b/crates/rocksdb-store/src/test_utils.rs @@ -1,10 +1,9 @@ use std::sync::Arc; +use alpen_express_db::database::CommonDatabase; use rockbound::{rocksdb, OptimisticTransactionDB}; use tempfile::TempDir; -use alpen_express_db::database::CommonDatabase; - use crate::{l2::db::L2Db, ChainStateDb, ClientStateDb, DbOpsConfig, L1Db, SyncEventDb}; pub fn get_rocksdb_tmp_instance() -> anyhow::Result<(Arc, DbOpsConfig)> { diff --git a/crates/rocksdb-store/src/utils.rs b/crates/rocksdb-store/src/utils.rs index 423c02338..3c436fcc7 100644 --- a/crates/rocksdb-store/src/utils.rs +++ b/crates/rocksdb-store/src/utils.rs @@ -1,6 +1,5 @@ -use rockbound::{rocksdb, OptimisticTransactionDB as DB, Schema, SchemaDBOperationsExt}; - use alpen_express_db::{errors::DbError, DbResult}; +use rockbound::{rocksdb, OptimisticTransactionDB as DB, Schema, SchemaDBOperationsExt}; pub fn get_last_idx(db: &DB) -> DbResult> where diff --git a/crates/state/src/block.rs b/crates/state/src/block.rs index 045f98c39..4c82a2215 100644 --- a/crates/state/src/block.rs +++ b/crates/state/src/block.rs @@ -1,10 +1,9 @@ use std::ops::Deref; +use alpen_express_primitives::prelude::*; use arbitrary::Arbitrary; use borsh::{BorshDeserialize, BorshSerialize}; -use alpen_express_primitives::prelude::*; - use crate::{ exec_update, header::{L2BlockHeader, SignedL2BlockHeader}, diff --git a/crates/state/src/bridge_ops.rs b/crates/state/src/bridge_ops.rs index 674ba0287..fcc6e048e 100644 --- a/crates/state/src/bridge_ops.rs +++ b/crates/state/src/bridge_ops.rs @@ -1,10 +1,9 @@ //! Types for managing pending bridging operations in the CL state. +use alpen_express_primitives::buf::Buf64; use arbitrary::Arbitrary; use borsh::{BorshDeserialize, BorshSerialize}; -use alpen_express_primitives::buf::Buf64; - /// Describes an intent to withdraw that hasn't been dispatched yet. #[derive(Clone, Debug, Eq, PartialEq, Arbitrary, BorshDeserialize, BorshSerialize)] pub struct WithdrawalIntent { diff --git a/crates/state/src/bridge_state.rs b/crates/state/src/bridge_state.rs index 03d9842f3..071220d67 100644 --- a/crates/state/src/bridge_state.rs +++ b/crates/state/src/bridge_state.rs @@ -3,12 +3,11 @@ //! This just implements a very simple n-of-n multisig bridge. It will be //! extended to a more sophisticated design when we have that specced out. -use borsh::{BorshDeserialize, BorshSerialize}; - use alpen_express_primitives::{ buf::Buf32, l1::{self, OutputRef}, }; +use borsh::{BorshDeserialize, BorshSerialize}; /// Global operator idx. pub type OperatorIdx = u32; diff --git a/crates/state/src/chain_state.rs b/crates/state/src/chain_state.rs index 43a2411ac..976281519 100644 --- a/crates/state/src/chain_state.rs +++ b/crates/state/src/chain_state.rs @@ -1,14 +1,11 @@ +use alpen_express_primitives::{buf::Buf32, hash::compute_borsh_hash}; use arbitrary::Arbitrary; use borsh::{BorshDeserialize, BorshSerialize}; -use alpen_express_primitives::buf::Buf32; -use alpen_express_primitives::hash::compute_borsh_hash; - -use crate::bridge_state::DepositsTable; -use crate::exec_env::ExecEnvState; -use crate::l1::L1ViewState; -use crate::prelude::*; -use crate::{bridge_ops, bridge_state, exec_env, l1}; +use crate::{ + bridge_ops, bridge_state, bridge_state::DepositsTable, exec_env, exec_env::ExecEnvState, l1, + l1::L1ViewState, prelude::*, +}; /// L2 blockchain state. This is the state computed as a function of a /// pre-state and a block. diff --git a/crates/state/src/da_blob.rs b/crates/state/src/da_blob.rs index a7ca264ed..b168cf320 100644 --- a/crates/state/src/da_blob.rs +++ b/crates/state/src/da_blob.rs @@ -2,12 +2,11 @@ //! //! These types don't care about the *purpose* of the blobs, we only care about what's in them. +use alpen_express_primitives::buf::Buf32; use arbitrary::Arbitrary; use borsh::{BorshDeserialize, BorshSerialize}; use num_enum::{IntoPrimitive, TryFromPrimitive}; -use alpen_express_primitives::buf::Buf32; - /// DA destination identifier. This will eventually be used to enable /// storing blobs on alternative availability schemes. #[derive( diff --git a/crates/state/src/exec_env.rs b/crates/state/src/exec_env.rs index 11970df21..52166fda3 100644 --- a/crates/state/src/exec_env.rs +++ b/crates/state/src/exec_env.rs @@ -1,10 +1,9 @@ //! Types relating to the state of an execution environment in the CL state. +use alpen_express_primitives::buf::Buf32; use arbitrary::Arbitrary; use borsh::{BorshDeserialize, BorshSerialize}; -use alpen_express_primitives::buf::Buf32; - use crate::{bridge_ops, da_blob, exec_update, forced_inclusion, state_queue::StateQueue}; #[derive(Debug, Clone, Eq, PartialEq, BorshDeserialize, BorshSerialize)] diff --git a/crates/state/src/exec_update.rs b/crates/state/src/exec_update.rs index d8a44d454..6fe605bbf 100644 --- a/crates/state/src/exec_update.rs +++ b/crates/state/src/exec_update.rs @@ -1,11 +1,10 @@ //! Chain data types relating to the CL's updating view of an execution //! environment's state. For now the EVM EL is the only execution environment. +use alpen_express_primitives::{buf::Buf32, evm_exec::create_evm_extra_payload}; use arbitrary::Arbitrary; use borsh::{BorshDeserialize, BorshSerialize}; -use alpen_express_primitives::{buf::Buf32, evm_exec::create_evm_extra_payload}; - use crate::{bridge_ops, da_blob}; /// Full update payload containing inputs and outputs to an EE state update. diff --git a/crates/state/src/forced_inclusion.rs b/crates/state/src/forced_inclusion.rs index f2db8764c..68974fc55 100644 --- a/crates/state/src/forced_inclusion.rs +++ b/crates/state/src/forced_inclusion.rs @@ -2,11 +2,10 @@ //! //! This is all stubs now so that we can define data structures later. +use alpen_express_primitives::l1; use arbitrary::Arbitrary; use borsh::{BorshDeserialize, BorshSerialize}; -use alpen_express_primitives::l1; - #[derive(Clone, Debug, Eq, PartialEq, Arbitrary, BorshDeserialize, BorshSerialize)] pub struct ForcedInclusion { payload: Vec, diff --git a/crates/state/src/header.rs b/crates/state/src/header.rs index 659e65fe9..5915a6ca1 100644 --- a/crates/state/src/header.rs +++ b/crates/state/src/header.rs @@ -1,15 +1,13 @@ use std::io::{self, Cursor, Write}; -use arbitrary::Arbitrary; -use borsh::{BorshDeserialize, BorshSerialize}; - use alpen_express_primitives::{ buf::{Buf32, Buf64}, hash, }; +use arbitrary::Arbitrary; +use borsh::{BorshDeserialize, BorshSerialize}; -use crate::block::L2BlockBody; -use crate::id::L2BlockId; +use crate::{block::L2BlockBody, id::L2BlockId}; pub trait L2Header { fn blockidx(&self) -> u64; diff --git a/crates/state/src/id.rs b/crates/state/src/id.rs index d74458f3d..502bb6846 100644 --- a/crates/state/src/id.rs +++ b/crates/state/src/id.rs @@ -1,10 +1,9 @@ use std::fmt; +use alpen_express_primitives::buf::Buf32; use arbitrary::Arbitrary; use borsh::{BorshDeserialize, BorshSerialize}; -use alpen_express_primitives::buf::Buf32; - /// ID of an L2 block, usually the hash of its root header. #[derive( Copy, diff --git a/crates/state/src/l1.rs b/crates/state/src/l1.rs index 196c3bc77..a439ce706 100644 --- a/crates/state/src/l1.rs +++ b/crates/state/src/l1.rs @@ -1,10 +1,9 @@ use core::fmt; +use alpen_express_primitives::{l1, prelude::*}; use arbitrary::Arbitrary; use borsh::{BorshDeserialize, BorshSerialize}; -use alpen_express_primitives::{l1, prelude::*}; - use crate::state_queue::StateQueue; /// ID of an L1 block, usually the hash of its header. diff --git a/crates/state/src/operation.rs b/crates/state/src/operation.rs index 24c1e3d40..0491fd4e6 100644 --- a/crates/state/src/operation.rs +++ b/crates/state/src/operation.rs @@ -5,9 +5,11 @@ use arbitrary::Arbitrary; use borsh::{BorshDeserialize, BorshSerialize}; use tracing::*; -use crate::client_state::{ClientState, SyncState}; -use crate::id::L2BlockId; -use crate::l1::L1BlockId; +use crate::{ + client_state::{ClientState, SyncState}, + id::L2BlockId, + l1::L1BlockId, +}; /// Output of a consensus state transition. Both the consensus state writes and /// sync actions. diff --git a/crates/state/src/prelude.rs b/crates/state/src/prelude.rs index c14e90eb3..12a2adcba 100644 --- a/crates/state/src/prelude.rs +++ b/crates/state/src/prelude.rs @@ -1,5 +1,7 @@ -pub use crate::block::{L2Block, L2BlockBody}; -pub use crate::header::{L2BlockHeader, L2Header, SignedL2BlockHeader}; -pub use crate::id::L2BlockId; -pub use crate::l1::L1BlockId; -pub use crate::state_queue::StateQueue; +pub use crate::{ + block::{L2Block, L2BlockBody}, + header::{L2BlockHeader, L2Header, SignedL2BlockHeader}, + id::L2BlockId, + l1::L1BlockId, + state_queue::StateQueue, +}; diff --git a/crates/state/src/state_op.rs b/crates/state/src/state_op.rs index 43288b709..e47ec11d9 100644 --- a/crates/state/src/state_op.rs +++ b/crates/state/src/state_op.rs @@ -6,11 +6,9 @@ use alpen_express_primitives::buf::Buf32; use borsh::{BorshDeserialize, BorshSerialize}; -use crate::chain_state::ChainState; -use crate::header::L2Header; -use crate::id::L2BlockId; -use crate::l1::L1MaturationEntry; -use crate::{bridge_ops, l1}; +use crate::{ + bridge_ops, chain_state::ChainState, header::L2Header, id::L2BlockId, l1, l1::L1MaturationEntry, +}; #[derive(Clone, Debug, PartialEq, BorshDeserialize, BorshSerialize)] pub enum StateOp { diff --git a/crates/storage/src/cache.rs b/crates/storage/src/cache.rs index 6e725689a..d169b6793 100644 --- a/crates/storage/src/cache.rs +++ b/crates/storage/src/cache.rs @@ -1,14 +1,11 @@ //! Generic cache utility for what we're inserting into the database. -use std::hash::Hash; -use std::num::NonZeroUsize; -use std::sync::Arc; +use std::{hash::Hash, num::NonZeroUsize, sync::Arc}; +use alpen_express_db::{DbError, DbResult}; use tokio::sync::{broadcast, Mutex, RwLock}; use tracing::*; -use alpen_express_db::{DbError, DbResult}; - use crate::exec::DbRecv; /// Entry for something we can put into the cache without actually knowing what it is, and so we can diff --git a/crates/storage/src/managers/l2.rs b/crates/storage/src/managers/l2.rs index f77671696..88fe5edd5 100644 --- a/crates/storage/src/managers/l2.rs +++ b/crates/storage/src/managers/l2.rs @@ -1,14 +1,13 @@ use std::sync::Arc; -use alpen_express_db::traits::BlockStatus; -use alpen_express_db::DbResult; -use threadpool::ThreadPool; - -use alpen_express_db::traits::Database; +use alpen_express_db::{ + traits::{BlockStatus, Database}, + DbResult, +}; use alpen_express_state::{block::L2BlockBundle, header::L2Header, id::L2BlockId}; +use threadpool::ThreadPool; -use crate::cache; -use crate::ops; +use crate::{cache, ops}; /// Caching manager of L2 blocks in the block database. pub struct L2BlockManager { diff --git a/crates/storage/src/ops/l1tx_broadcast.rs b/crates/storage/src/ops/l1tx_broadcast.rs index e739fe0df..fb81d419d 100644 --- a/crates/storage/src/ops/l1tx_broadcast.rs +++ b/crates/storage/src/ops/l1tx_broadcast.rs @@ -1,8 +1,10 @@ use std::sync::Arc; -use alpen_express_db::traits::*; -use alpen_express_db::types::{L1TxEntry, L1TxStatus}; -use alpen_express_db::DbResult; +use alpen_express_db::{ + traits::*, + types::{L1TxEntry, L1TxStatus}, + DbResult, +}; use alpen_express_primitives::buf::Buf32; use crate::exec::*; diff --git a/crates/tasks/src/manager.rs b/crates/tasks/src/manager.rs index a1ee606ba..2a3c96566 100644 --- a/crates/tasks/src/manager.rs +++ b/crates/tasks/src/manager.rs @@ -1,16 +1,19 @@ -use std::any::Any; -use std::fmt::{Display, Formatter}; -use std::future::Future; -use std::sync::atomic::{AtomicUsize, Ordering}; -use std::sync::Arc; -use std::thread::JoinHandle; -use std::time::Duration; -use std::{panic, pin::pin}; - -use futures_util::future::select; -use futures_util::{FutureExt, TryFutureExt}; -use tokio::runtime::Handle; -use tokio::sync::mpsc; +use std::{ + any::Any, + fmt::{Display, Formatter}, + future::Future, + panic, + pin::pin, + sync::{ + atomic::{AtomicUsize, Ordering}, + Arc, + }, + thread::JoinHandle, + time::Duration, +}; + +use futures_util::{future::select, FutureExt, TryFutureExt}; +use tokio::{runtime::Handle, sync::mpsc}; use tracing::{debug, error, info, warn}; use crate::shutdown::{Shutdown, ShutdownGuard, ShutdownSignal}; diff --git a/crates/tasks/src/shutdown.rs b/crates/tasks/src/shutdown.rs index 971f84da1..18b2f5faa 100644 --- a/crates/tasks/src/shutdown.rs +++ b/crates/tasks/src/shutdown.rs @@ -1,7 +1,9 @@ -use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; -use std::sync::Arc; -use tokio::sync::futures::Notified; -use tokio::sync::Notify; +use std::sync::{ + atomic::{AtomicBool, AtomicUsize, Ordering}, + Arc, +}; + +use tokio::sync::{futures::Notified, Notify}; /// Allows to send a signal to trigger shutdown #[derive(Debug, Clone)] diff --git a/crates/util/mmr/src/hasher.rs b/crates/util/mmr/src/hasher.rs index 9a9fa311c..fcba5c00c 100644 --- a/crates/util/mmr/src/hasher.rs +++ b/crates/util/mmr/src/hasher.rs @@ -1,5 +1,4 @@ -use digest::generic_array::GenericArray; -use digest::Digest; +use digest::{generic_array::GenericArray, Digest}; pub type Hash = [u8; 32]; diff --git a/crates/util/mmr/src/lib.rs b/crates/util/mmr/src/lib.rs index 221906dd0..086106b67 100644 --- a/crates/util/mmr/src/lib.rs +++ b/crates/util/mmr/src/lib.rs @@ -6,7 +6,6 @@ use std::marker::PhantomData; use arbitrary::Arbitrary; use borsh::{BorshDeserialize, BorshSerialize}; - use error::MerkleError; use hasher::{Hash, MerkleHasher}; @@ -313,9 +312,8 @@ mod test { use sha2::{Digest, Sha256}; - use crate::error::MerkleError; - use super::{hasher::Hash, MerkleMr, MerkleProof}; + use crate::error::MerkleError; fn generate_for_n_integers(n: usize) -> (MerkleMr, Vec>) { let mut mmr: MerkleMr = MerkleMr::new(14); diff --git a/proofs/risc0/Cargo.toml b/proofs/risc0/Cargo.toml index 117949900..14972344c 100644 --- a/proofs/risc0/Cargo.toml +++ b/proofs/risc0/Cargo.toml @@ -1,7 +1,7 @@ [package] +edition = "2021" name = "risc0-guest-builder" version = "0.1.0" -edition = "2021" [dependencies] express-risc0-adapter = { path = "../../crates/prover/adapters/risc0", features = [ diff --git a/proofs/risc0/guest-reth-stf/Cargo.toml b/proofs/risc0/guest-reth-stf/Cargo.toml index 99c30fca9..b7135b784 100644 --- a/proofs/risc0/guest-reth-stf/Cargo.toml +++ b/proofs/risc0/guest-reth-stf/Cargo.toml @@ -1,7 +1,7 @@ [package] +edition = "2021" name = "reth-risc0" version = "0.1.0" -edition = "2021" [workspace] diff --git a/proofs/sp1/Cargo.toml b/proofs/sp1/Cargo.toml index d5d982ff1..6fe0ec889 100644 --- a/proofs/sp1/Cargo.toml +++ b/proofs/sp1/Cargo.toml @@ -1,7 +1,7 @@ [package] +edition = "2021" name = "sp1-guest-builder" version = "0.1.0" -edition = "2021" [dependencies] express-sp1-adapter = { path = "../../crates/prover/adapters/sp1", features = [ diff --git a/proofs/sp1/build.rs b/proofs/sp1/build.rs index c24c16b2a..6327c520a 100644 --- a/proofs/sp1/build.rs +++ b/proofs/sp1/build.rs @@ -1,9 +1,10 @@ -use sp1_helper::build_program; use std::{ env, fs, path::{Path, PathBuf}, }; +use sp1_helper::build_program; + const RISC_V_COMPILER: &str = "/opt/riscv/bin/riscv-none-elf-gcc"; const ELF_FILE_PATH: &str = "guest-reth-stf/elf/riscv32im-succinct-zkvm-elf"; const MOCK_ELF_CONTENT: &str = r#" diff --git a/proofs/sp1/guest-reth-stf/Cargo.toml b/proofs/sp1/guest-reth-stf/Cargo.toml index a4d3bc7bb..e46ee5a7a 100644 --- a/proofs/sp1/guest-reth-stf/Cargo.toml +++ b/proofs/sp1/guest-reth-stf/Cargo.toml @@ -1,7 +1,7 @@ [package] +edition = "2021" name = "reth-sp1" version = "0.1.0" -edition = "2021" [workspace] diff --git a/rustfmt.toml b/rustfmt.toml index 923f52d5b..bb766364e 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -6,3 +6,5 @@ use_field_init_shorthand = true format_code_in_doc_comments = true doc_comment_code_block_width = 100 comment_width = 100 +group_imports = "StdExternalCrate" +imports_granularity = "Crate" diff --git a/sequencer/src/l1_reader.rs b/sequencer/src/l1_reader.rs index e3dc307d2..ae445c24f 100644 --- a/sequencer/src/l1_reader.rs +++ b/sequencer/src/l1_reader.rs @@ -1,17 +1,15 @@ use std::sync::Arc; -use tokio::sync::{mpsc, RwLock}; - -use alpen_express_btcio::reader::{ - config::ReaderConfig, messages::L1Event, query::bitcoin_data_reader_task, +use alpen_express_btcio::{ + reader::{config::ReaderConfig, messages::L1Event, query::bitcoin_data_reader_task}, + rpc::traits::L1Client, }; -use alpen_express_btcio::rpc::traits::L1Client; -use alpen_express_consensus_logic::ctl::CsmController; -use alpen_express_consensus_logic::l1_handler::bitcoin_data_handler_task; +use alpen_express_consensus_logic::{ctl::CsmController, l1_handler::bitcoin_data_handler_task}; use alpen_express_db::traits::{Database, L1DataProvider}; use alpen_express_primitives::params::Params; use alpen_express_rpc_types::L1Status; use express_tasks::TaskExecutor; +use tokio::sync::{mpsc, RwLock}; use crate::config::Config; diff --git a/sequencer/src/main.rs b/sequencer/src/main.rs index 24fd59ce2..849dbb66a 100644 --- a/sequencer/src/main.rs +++ b/sequencer/src/main.rs @@ -1,48 +1,49 @@ #![allow(dead_code)] // TODO: remove this once `Args.network` is used -use std::fs; -use std::io; -use std::path::Path; -use std::path::PathBuf; -use std::sync::Arc; -use std::time::Duration; - -use alpen_express_btcio::broadcaster::L1BroadcastHandle; +use std::{ + fs, io, + path::{Path, PathBuf}, + sync::Arc, + time::Duration, +}; + +use alpen_express_btcio::{ + broadcaster::{spawn_broadcaster_task, L1BroadcastHandle}, + writer::{config::WriterConfig, start_writer_task, DaWriter}, +}; +use alpen_express_common::logging; +use alpen_express_consensus_logic::{ + duty::{ + types::{DutyBatch, Identity, IdentityData, IdentityKey}, + worker::{self as duty_worker}, + }, + sync_manager, + sync_manager::SyncManager, +}; +use alpen_express_db::traits::{Database, SequencerDatabase}; +use alpen_express_evmexec::{fork_choice_state_initial, EngineRpcClient}; +use alpen_express_primitives::{ + block_credential, + buf::Buf32, + params::{Params, RollupParams, RunParams}, +}; +use alpen_express_rocksdb::{ + broadcaster::db::BroadcastDatabase, sequencer::db::SequencerDB, DbOpsConfig, SeqDb, +}; +use alpen_express_rpc_api::{AlpenAdminApiServer, AlpenApiServer}; +use alpen_express_rpc_types::L1Status; // use alpen_express_btcio::broadcaster::manager::BroadcastDbManager; use anyhow::Context; use bitcoin::Network; use config::Config; - +use express_storage::L2BlockManager; +use express_tasks::{ShutdownSignal, TaskManager}; use format_serde_error::SerdeError; -use reth_rpc_types::engine::JwtError; -use reth_rpc_types::engine::JwtSecret; +use reth_rpc_types::engine::{JwtError, JwtSecret}; use rockbound::rocksdb; use thiserror::Error; use tokio::sync::{broadcast, oneshot, RwLock}; use tracing::*; -use alpen_express_btcio::broadcaster::spawn_broadcaster_task; -use alpen_express_btcio::writer::config::WriterConfig; -use alpen_express_btcio::writer::start_writer_task; -use alpen_express_btcio::writer::DaWriter; -use alpen_express_common::logging; -use alpen_express_consensus_logic::duty::types::{DutyBatch, Identity, IdentityData, IdentityKey}; -use alpen_express_consensus_logic::duty::worker::{self as duty_worker}; -use alpen_express_consensus_logic::sync_manager; -use alpen_express_consensus_logic::sync_manager::SyncManager; -use alpen_express_db::traits::{Database, SequencerDatabase}; -use alpen_express_evmexec::{fork_choice_state_initial, EngineRpcClient}; -use alpen_express_primitives::block_credential; -use alpen_express_primitives::buf::Buf32; -use alpen_express_primitives::params::{Params, RollupParams, RunParams}; -use alpen_express_rocksdb::broadcaster::db::BroadcastDatabase; -use alpen_express_rocksdb::sequencer::db::SequencerDB; -use alpen_express_rocksdb::DbOpsConfig; -use alpen_express_rocksdb::SeqDb; -use alpen_express_rpc_api::{AlpenAdminApiServer, AlpenApiServer}; -use alpen_express_rpc_types::L1Status; -use express_storage::L2BlockManager; -use express_tasks::{ShutdownSignal, TaskManager}; - use crate::args::Args; mod args; diff --git a/sequencer/src/rpc_server.rs b/sequencer/src/rpc_server.rs index 98039ddf3..580219a71 100644 --- a/sequencer/src/rpc_server.rs +++ b/sequencer/src/rpc_server.rs @@ -2,37 +2,16 @@ use std::{borrow::BorrowMut, sync::Arc}; -use async_trait::async_trait; -use bitcoin::{consensus::deserialize, hashes::Hash, Transaction as BTransaction, Txid}; -use jsonrpsee::{ - core::RpcResult, - types::{ErrorObject, ErrorObjectOwned}, -}; -use reth_primitives::{Address, BlockId, BlockNumberOrTag, Bytes, B256, B64, U256, U64}; -use reth_rpc_api::EthApiServer; -use reth_rpc_types::{ - state::StateOverride, AccessListWithGasUsed, AnyTransactionReceipt, BlockOverrides, Bundle, - EIP1186AccountProofResponse, EthCallResponse, FeeHistory, Header, Index, RichBlock, - StateContext, SyncInfo, SyncStatus, Transaction, TransactionRequest, Work, -}; -use thiserror::Error; -use tokio::sync::{ - mpsc::{self, Sender}, - oneshot, watch, Mutex, RwLock, +use alpen_express_btcio::{ + broadcaster::L1BroadcastHandle, + writer::{utils::calculate_blob_hash, DaWriter}, }; - -use alpen_express_btcio::broadcaster::L1BroadcastHandle; -use alpen_express_btcio::writer::{utils::calculate_blob_hash, DaWriter}; use alpen_express_consensus_logic::sync_manager::SyncManager; use alpen_express_db::{ - traits::{ChainstateProvider, Database, L2DataProvider}, - types::L1TxEntry, + traits::{ChainstateProvider, Database, L1DataProvider, L2DataProvider, SequencerDatabase}, + types::{L1TxEntry, L1TxStatus}, DbResult, }; -use alpen_express_db::{ - traits::{L1DataProvider, SequencerDatabase}, - types::L1TxStatus, -}; use alpen_express_primitives::buf::Buf32; use alpen_express_rpc_api::{AlpenAdminApiServer, AlpenApiServer, HexBytes, HexBytes32}; use alpen_express_rpc_types::{ @@ -49,7 +28,24 @@ use alpen_express_state::{ id::L2BlockId, l1::L1BlockId, }; - +use async_trait::async_trait; +use bitcoin::{consensus::deserialize, hashes::Hash, Transaction as BTransaction, Txid}; +use jsonrpsee::{ + core::RpcResult, + types::{ErrorObject, ErrorObjectOwned}, +}; +use reth_primitives::{Address, BlockId, BlockNumberOrTag, Bytes, B256, B64, U256, U64}; +use reth_rpc_api::EthApiServer; +use reth_rpc_types::{ + state::StateOverride, AccessListWithGasUsed, AnyTransactionReceipt, BlockOverrides, Bundle, + EIP1186AccountProofResponse, EthCallResponse, FeeHistory, Header, Index, RichBlock, + StateContext, SyncInfo, SyncStatus, Transaction, TransactionRequest, Work, +}; +use thiserror::Error; +use tokio::sync::{ + mpsc::{self, Sender}, + oneshot, watch, Mutex, RwLock, +}; use tracing::*; #[derive(Debug, Error)] From 4f160df21c99b4a25ab0dddca653a0929e8065a5 Mon Sep 17 00:00:00 2001 From: voidash Date: Tue, 27 Aug 2024 12:29:01 +0545 Subject: [PATCH 2/4] remove contributing section from README.md, add cargo audit on Contributing.md --- Contributing.md | 10 ++++++++++ README.md | 49 ------------------------------------------------- 2 files changed, 10 insertions(+), 49 deletions(-) diff --git a/Contributing.md b/Contributing.md index 997f0c8f8..ca8d3537e 100644 --- a/Contributing.md +++ b/Contributing.md @@ -35,6 +35,16 @@ you can run the basic CI checks in your local environment: Learn more [here](https://nexte.st). + +- `cargo audit` + + This is a tool to check Cargo.lock files for crates containing security vulnerabilities. + + ```bash + cargo install --locked cargo-audit + ``` + Learn more [here](https://docs.rs/cargo-audit/latest/cargo_audit/). + - Functional test runner For dependencies required to run functional tests, see instructions in its [`README.md`](./functional-tests/README.md). diff --git a/README.md b/README.md index e606a4342..7a311b948 100644 --- a/README.md +++ b/README.md @@ -87,52 +87,3 @@ Start CL Client/Sequencer cargo run --bin alpen-express-sequencer -- --config config.toml ``` -## Contribution Guidelines - -### Development Tools - -Please install the following tools in your development environment to make sure that -you can run the basic CI checks in your local environment: - -- `taplo` - - This is a tool that is used to lint and format `TOML` files. You can install it with: - - ```bash - brew install taplo - ``` - - You can learn more [here](https://taplo.tamasfe.dev/cli/installation/binary.html). - -- `codespell` - - This is a tool that is used to check for common misspellings in code. You can install it with: - - ```bash - pip install codespell # or `pip3 install codespell` - ``` - - You can learn more [here](https://github.com/codespell-project/codespell). - -- `nextest` - - This is a modern test runner for Rust. You can install it with: - - ```bash - cargo install --locked nextest - ``` - - Learn more [here](https://nexte.st). - -- Functional test runner - - For dependencies required to run functional tests, see instructions in its [`README.md`](./functional-tests/README.md). - -### Before Creating a PR - -Before you create a PR, make sure that all the required CI checks pass locally. -For your convenience, a `Makefile` recipe has been created which you can run via: - -```bash -make pr # `make` should already be installed in most systems -``` From de1d7c8236f285720fb48735d39e381526b24d64 Mon Sep 17 00:00:00 2001 From: voidash Date: Tue, 27 Aug 2024 12:33:54 +0545 Subject: [PATCH 3/4] CONTRIBUTING.md is now screaming-case --- Contributing.md => CONTRIBUTING.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename Contributing.md => CONTRIBUTING.md (95%) diff --git a/Contributing.md b/CONTRIBUTING.md similarity index 95% rename from Contributing.md rename to CONTRIBUTING.md index ca8d3537e..97dded5db 100644 --- a/Contributing.md +++ b/CONTRIBUTING.md @@ -1,6 +1,6 @@ -## Contribution Guidelines +# Contribution Guidelines -### Development Tools +## Development Tools Please install the following tools in your development environment to make sure that you can run the basic CI checks in your local environment: @@ -49,7 +49,7 @@ you can run the basic CI checks in your local environment: For dependencies required to run functional tests, see instructions in its [`README.md`](./functional-tests/README.md). -### Before Creating a PR +## Before Creating a PR Before you create a PR, make sure that all the required CI checks pass locally. For your convenience, a `Makefile` recipe has been created which you can run via: From 493d9d3f2e420e3c89e9e74223d18e64cb8c7870 Mon Sep 17 00:00:00 2001 From: Ashish Thapa Date: Tue, 27 Aug 2024 13:02:24 +0545 Subject: [PATCH 4/4] Update CONTRIBUTING.md Co-authored-by: Rajil Bajracharya --- CONTRIBUTING.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 97dded5db..e5582ec6e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -35,7 +35,6 @@ you can run the basic CI checks in your local environment: Learn more [here](https://nexte.st). - - `cargo audit` This is a tool to check Cargo.lock files for crates containing security vulnerabilities.