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

Cleanup #672

Merged
merged 6 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions .cargo/audit.toml

This file was deleted.

2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 2 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "signup-sequencer"
version = "0.1.0"
version = "1.0.1"
authors = [
"Remco Bloemen <remco@worldcoin.org>",
"Lucas Ege <lucas@worldcoin.org>",
Expand All @@ -13,7 +13,7 @@ description = "A tool that processes WorldID signups on-chain."
keywords = ["worldcoin", "protocol", "signup"]
categories = ["cryptography::cryptocurrencies"]
readme = "Readme.md"
license-file = "mit-license.md"
license-file = "LICENSE.md"

[workspace]
members = ["crates/*"]
Expand Down Expand Up @@ -78,9 +78,6 @@ tracing = "0.1"
tracing-futures = "0.2"
tx-sitter-client = { path = "crates/tx-sitter-client" }
url = { version = "2.2", features = ["serde"] }
# `ethers-rs` requires an older version of primitive-types.
# But `ruint` supports the latest version. So we need to override it.
# `cargo update --package primitive-types@0.12.1 --precise 0.11.1`
zeroize = "1.6.0"

[dev-dependencies]
Expand Down
20 changes: 0 additions & 20 deletions codecov.yml

This file was deleted.

36 changes: 0 additions & 36 deletions compose.yml

This file was deleted.

Empty file removed error.txt
Empty file.
9 changes: 4 additions & 5 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use std::collections::HashSet;
use std::sync::Arc;
use std::time::Instant;

use anyhow::Result as AnyhowResult;
use chrono::{Duration, Utc};
use clap::Parser;
use ruint::Uint;
Expand Down Expand Up @@ -86,7 +85,7 @@ impl App {
/// Will return `Err` if the internal Ethereum handler errors or if the
/// `options.storage_file` is not accessible.
#[instrument(name = "App::new", level = "debug")]
pub async fn new(options: Options) -> AnyhowResult<Self> {
pub async fn new(options: Options) -> anyhow::Result<Self> {
let ethereum = Ethereum::new(options.ethereum);
let db = Database::new(options.database);

Expand Down Expand Up @@ -212,7 +211,7 @@ impl App {
initial_root_hash: Hash,
mmap_file_path: &str,
force_cache_purge: bool,
) -> AnyhowResult<TreeState> {
) -> anyhow::Result<TreeState> {
let mut mined_items = database
.get_commitments_by_status(ProcessedStatus::Mined)
.await?;
Expand Down Expand Up @@ -362,7 +361,7 @@ impl App {
initial_leaf_value: Hash,
mined_items: Vec<TreeUpdate>,
mmap_file_path: &str,
) -> AnyhowResult<TreeState> {
) -> anyhow::Result<TreeState> {
// Flatten the updates for initial leaves
let mined_items = dedup_tree_updates(mined_items);

Expand Down Expand Up @@ -819,7 +818,7 @@ impl App {
///
/// Will return an Error if any of the components cannot be shut down
/// gracefully.
pub async fn shutdown(&self) -> AnyhowResult<()> {
pub async fn shutdown(&self) -> anyhow::Result<()> {
info!("Shutting down identity committer.");
self.identity_committer.shutdown().await
}
Expand Down
3 changes: 1 addition & 2 deletions src/ethereum/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::collections::HashMap;
use std::sync::Arc;

use anyhow::Result as AnyhowResult;
use clap::Parser;
use ethers::types::transaction::eip2718::TypedTransaction;
use ethers::types::Address;
Expand Down Expand Up @@ -45,7 +44,7 @@ pub struct Ethereum {

impl Ethereum {
#[instrument(name = "Ethereum::new", level = "debug", skip_all)]
pub async fn new(options: Options) -> AnyhowResult<Self> {
pub async fn new(options: Options) -> anyhow::Result<Self> {
let read_provider = ReadProvider::new(options.ethereum_provider).await?;

let mut secondary_read_providers = HashMap::new();
Expand Down
4 changes: 2 additions & 2 deletions src/ethereum/read/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use anyhow::{anyhow, Result as AnyhowResult};
use anyhow::anyhow;
use chrono::{Duration as ChronoDuration, Utc};
use ethers::abi::Error as AbiError;
use ethers::providers::{Http, Middleware, Provider};
Expand All @@ -22,7 +22,7 @@ pub struct ReadProvider {
}

impl ReadProvider {
pub async fn new(url: Url) -> AnyhowResult<Self> {
pub async fn new(url: Url) -> anyhow::Result<Self> {
// Connect to the Ethereum provider
// TODO: Allow multiple providers with failover / broadcast.
// TODO: Requests don't seem to process in parallel. Check if this is
Expand Down
3 changes: 1 addition & 2 deletions src/ethereum/write_provider/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::fmt;
use std::sync::Arc;

use anyhow::Result as AnyhowResult;
use ethers::providers::Middleware;
use ethers::types::transaction::eip2718::TypedTransaction;
use ethers::types::{Address, U64};
Expand Down Expand Up @@ -39,7 +38,7 @@ impl fmt::Debug for WriteProvider {
}

impl WriteProvider {
pub async fn new(read_provider: ReadProvider, options: &Options) -> AnyhowResult<Self> {
pub async fn new(read_provider: ReadProvider, options: &Options) -> anyhow::Result<Self> {
let options = options.to_parsed()?;
let address = options.address();

Expand Down
3 changes: 1 addition & 2 deletions src/ethereum/write_provider/openzeppelin.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::fmt::Debug;
use std::time::Duration;

use anyhow::Result as AnyhowResult;
use ethers::types::transaction::eip2718::TypedTransaction;
use once_cell::sync::Lazy;
use oz_api::data::transactions::{RelayerTransactionBase, SendBaseTransactionRequest, Status};
Expand Down Expand Up @@ -33,7 +32,7 @@ pub struct OzRelay {
}

impl OzRelay {
pub async fn new(options: &OzOptions) -> AnyhowResult<Self> {
pub async fn new(options: &OzOptions) -> anyhow::Result<Self> {
let oz_api = if options.oz_api_key.is_empty() && options.oz_api_secret.is_empty() {
tracing::warn!(
"OpenZeppelin Defender API Key and Secret are empty. Connection will operate \
Expand Down
3 changes: 1 addition & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ pub mod utils;

use std::sync::Arc;

use anyhow::Result as AnyhowResult;
use clap::Parser;
use tracing::info;

Expand All @@ -40,7 +39,7 @@ pub struct Options {
/// assert!(true);
/// ```
#[allow(clippy::missing_errors_doc)]
pub async fn main(options: Options) -> AnyhowResult<()> {
pub async fn main(options: Options) -> anyhow::Result<()> {
// Create App struct
let app = Arc::new(App::new(options.app).await?);
let app_for_server = app.clone();
Expand Down
6 changes: 3 additions & 3 deletions src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::net::{IpAddr, Ipv4Addr, SocketAddr, TcpListener};
use std::sync::Arc;
use std::time::Duration;

use anyhow::{bail, ensure, Result as AnyhowResult};
use anyhow::{bail, ensure};
use axum::extract::{Query, State};
use axum::routing::{get, post};
use axum::{middleware, Json, Router};
Expand Down Expand Up @@ -148,7 +148,7 @@ async fn list_batch_sizes(
/// Will return `Err` if `options.server` URI is not http, incorrectly includes
/// a path beyond `/`, or cannot be cast into an IP address. Also returns an
/// `Err` if the server cannot bind to the given address.
pub async fn main(app: Arc<App>, options: Options) -> AnyhowResult<()> {
pub async fn main(app: Arc<App>, options: Options) -> anyhow::Result<()> {
ensure!(
options.server.scheme() == "http",
"Only http:// is supported in {}",
Expand Down Expand Up @@ -186,7 +186,7 @@ pub async fn bind_from_listener(
app: Arc<App>,
serve_timeout: Duration,
listener: TcpListener,
) -> AnyhowResult<()> {
) -> anyhow::Result<()> {
let router = Router::new()
.route("/verifySemaphoreProof", post(verify_semaphore_proof))
.route("/inclusionProof", post(inclusion_proof))
Expand Down
11 changes: 5 additions & 6 deletions src/task_monitor.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::sync::Arc;
use std::time::Duration;

use anyhow::Result as AnyhowResult;
use clap::Parser;
use once_cell::sync::Lazy;
use prometheus::{linear_buckets, register_gauge, register_histogram, Gauge, Histogram};
Expand Down Expand Up @@ -52,7 +51,7 @@ static BATCH_SIZES: Lazy<Histogram> = Lazy::new(|| {
});

impl RunningInstance {
async fn shutdown(self) -> AnyhowResult<()> {
async fn shutdown(self) -> anyhow::Result<()> {
info!("Sending a shutdown signal to the committer.");
// Ignoring errors here, since we have two options: either the channel is full,
// which is impossible, since this is the only use, and this method takes
Expand Down Expand Up @@ -286,19 +285,19 @@ impl TaskMonitor {
});
}

async fn log_pending_identities_count(database: &Database) -> AnyhowResult<()> {
async fn log_pending_identities_count(database: &Database) -> anyhow::Result<()> {
let identities = database.count_pending_identities().await?;
PENDING_IDENTITIES.set(f64::from(identities));
Ok(())
}

async fn log_unprocessed_identities_count(database: &Database) -> AnyhowResult<()> {
async fn log_unprocessed_identities_count(database: &Database) -> anyhow::Result<()> {
let identities = database.count_unprocessed_identities().await?;
UNPROCESSED_IDENTITIES.set(f64::from(identities));
Ok(())
}

async fn log_identities_queues(database: &Database) -> AnyhowResult<()> {
async fn log_identities_queues(database: &Database) -> anyhow::Result<()> {
TaskMonitor::log_unprocessed_identities_count(database).await?;
TaskMonitor::log_pending_identities_count(database).await?;
Ok(())
Expand All @@ -313,7 +312,7 @@ impl TaskMonitor {
///
/// Will return an Error if the committer thread cannot be shut down
/// gracefully.
pub async fn shutdown(&self) -> AnyhowResult<()> {
pub async fn shutdown(&self) -> anyhow::Result<()> {
let mut instance = self.instance.write().await;
if let Some(instance) = instance.take() {
instance.shutdown().await?;
Expand Down
3 changes: 1 addition & 2 deletions src/task_monitor/tasks/delete_identities.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::collections::HashSet;
use std::sync::Arc;

use anyhow::Result as AnyhowResult;
use chrono::Utc;
use tokio::sync::Notify;
use tracing::info;
Expand Down Expand Up @@ -53,7 +52,7 @@ async fn delete_identities(
deletion_time_interval: i64,
min_deletion_batch_size: usize,
wake_up_notify: Arc<Notify>,
) -> AnyhowResult<()> {
) -> anyhow::Result<()> {
info!("Starting deletion processor.");

let deletion_time_interval = chrono::Duration::seconds(deletion_time_interval);
Expand Down
4 changes: 2 additions & 2 deletions src/task_monitor/tasks/finalize_identities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::collections::HashMap;
use std::sync::Arc;
use std::time::Duration;

use anyhow::{Context, Result as AnyhowResult};
use anyhow::Context;
use chrono::Utc;
use ethers::abi::RawLog;
use ethers::contract::EthEvent;
Expand Down Expand Up @@ -76,7 +76,7 @@ async fn finalize_roots_loop(
scanning_chain_head_offset: u64,
time_between_scans: Duration,
max_epoch_duration: Duration,
) -> AnyhowResult<()> {
) -> anyhow::Result<()> {
let mainnet_abi = identity_manager.abi();
let secondary_abis = identity_manager.secondary_abis();

Expand Down
5 changes: 2 additions & 3 deletions src/task_monitor/tasks/insert_identities.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::sync::Arc;
use std::time::Duration;

use anyhow::Result as AnyhowResult;
use tokio::sync::Notify;
use tokio::time::sleep;
use tracing::instrument;
Expand Down Expand Up @@ -38,7 +37,7 @@ async fn insert_identities_loop(
database: &Database,
latest_tree: &TreeVersion<Latest>,
wake_up_notify: &Notify,
) -> AnyhowResult<()> {
) -> anyhow::Result<()> {
loop {
// get commits from database
let unprocessed = database
Expand All @@ -60,7 +59,7 @@ async fn insert_identities(
database: &Database,
latest_tree: &TreeVersion<Latest>,
identities: Vec<UnprocessedCommitment>,
) -> AnyhowResult<()> {
) -> anyhow::Result<()> {
// Filter out any identities that are already in the `identities` table
let mut filtered_identities = vec![];
for identity in identities {
Expand Down
3 changes: 1 addition & 2 deletions src/task_monitor/tasks/monitor_txs.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::sync::Arc;

use anyhow::Result as AnyhowResult;
use tokio::sync::{mpsc, Mutex};

use crate::contracts::{IdentityManager, SharedIdentityManager};
Expand Down Expand Up @@ -32,7 +31,7 @@ impl MonitorTxs {
async fn monitor_txs_loop(
identity_manager: &IdentityManager,
monitored_txs_receiver: &Mutex<mpsc::Receiver<TransactionId>>,
) -> AnyhowResult<()> {
) -> anyhow::Result<()> {
let mut monitored_txs_receiver = monitored_txs_receiver.lock().await;

while let Some(tx) = monitored_txs_receiver.recv().await {
Expand Down
Loading
Loading