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

Reformat all imports #788

Merged
merged 2 commits into from
Feb 11, 2025
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
11 changes: 8 additions & 3 deletions firewood/benches/hashops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,20 @@

// hash benchmarks; run with 'cargo bench'

use criterion::{criterion_group, criterion_main, profiler::Profiler, BatchSize, Criterion};
use criterion::profiler::Profiler;
use criterion::{criterion_group, criterion_main, BatchSize, Criterion};
use firewood::db::{BatchOp, DbConfig};
use firewood::merkle::Merkle;
use firewood::v2::api::{Db as _, Proposal as _};
use pprof::ProfilerGuard;
use rand::{rngs::StdRng, Rng, SeedableRng};
use rand::rngs::StdRng;
use rand::{Rng, SeedableRng};
use rand_distr::Alphanumeric;
use std::fs::File;
use std::iter::repeat_with;
use std::os::raw::c_int;
use std::path::Path;
use std::sync::Arc;
use std::{fs::File, iter::repeat_with, os::raw::c_int, path::Path};
use storage::{MemStore, NodeStore};

// To enable flamegraph output
Expand Down
20 changes: 10 additions & 10 deletions firewood/examples/insert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
// insert some random keys using the front-end API.

use clap::Parser;
use std::{
borrow::BorrowMut as _, collections::HashMap, error::Error, num::NonZeroUsize,
ops::RangeInclusive, time::Instant,
};

use firewood::{
db::{Batch, BatchOp, Db, DbConfig},
manager::RevisionManagerConfig,
v2::api::{Db as _, DbView, Proposal as _},
};
use std::borrow::BorrowMut as _;
use std::collections::HashMap;
use std::error::Error;
use std::num::NonZeroUsize;
use std::ops::RangeInclusive;
use std::time::Instant;

use firewood::db::{Batch, BatchOp, Db, DbConfig};
use firewood::manager::RevisionManagerConfig;
use firewood::v2::api::{Db as _, DbView, Proposal as _};
use rand::{Rng, SeedableRng as _};
use rand_distr::Alphanumeric;

Expand Down
7 changes: 4 additions & 3 deletions firewood/src/v2/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
// See the file LICENSE.md for licensing terms.

use crate::manager::RevisionManagerError;
use crate::proof::ProofNode;
use crate::merkle::MerkleError;
use crate::proof::{Proof, ProofNode};
pub use crate::range_proof::RangeProof;
use crate::{merkle::MerkleError, proof::Proof};
use async_trait::async_trait;
use futures::Stream;
use std::{fmt::Debug, sync::Arc};
use std::fmt::Debug;
use std::sync::Arc;
use storage::TrieHash;

/// A `KeyType` is something that can be xcast to a u8 reference,
Expand Down
14 changes: 5 additions & 9 deletions firewood/src/v2/emptydb.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
// Copyright (C) 2023, Ava Labs, Inc. All rights reserved.
// See the file LICENSE.md for licensing terms.

use crate::{
proof::{Proof, ProofNode},
range_proof::RangeProof,
};

use super::{
api::{Batch, Db, DbView, Error, HashKey, KeyType, ValueType},
propose::{Proposal, ProposalBase},
};
use crate::proof::{Proof, ProofNode};
use crate::range_proof::RangeProof;

use super::api::{Batch, Db, DbView, Error, HashKey, KeyType, ValueType};
use super::propose::{Proposal, ProposalBase};
use async_trait::async_trait;
use futures::Stream;
use std::sync::Arc;
Expand Down
4 changes: 3 additions & 1 deletion firewood/src/v2/propose.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Copyright (C) 2023, Ava Labs, Inc. All rights reserved.
// See the file LICENSE.md for licensing terms.

use std::{collections::BTreeMap, fmt::Debug, sync::Arc};
use std::collections::BTreeMap;
use std::fmt::Debug;
use std::sync::Arc;

use async_trait::async_trait;
use futures::stream::Empty;
Expand Down
5 changes: 4 additions & 1 deletion firewood/tests/common/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
// Copyright (C) 2023, Ava Labs, Inc. All rights reserved.
// See the file LICENSE.md for licensing terms.

use std::{env::temp_dir, fs::remove_file, ops::Deref, path::PathBuf};
use std::env::temp_dir;
use std::fs::remove_file;
use std::ops::Deref;
use std::path::PathBuf;

use firewood::db::{Db, DbConfig};
use typed_builder::TypedBuilder;
Expand Down
16 changes: 11 additions & 5 deletions grpc-testtool/benches/insert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@
// See the file LICENSE.md for licensing terms.

use criterion::{criterion_group, criterion_main, BatchSize, BenchmarkId, Criterion};
use rand::{distributions::Alphanumeric, Rng, SeedableRng};
use std::{
borrow::BorrowMut as _, cell::RefCell, env, fs::remove_dir_all, net::TcpStream,
os::unix::process::CommandExt, path::PathBuf, thread::sleep, time::Duration,
};
use rand::distributions::Alphanumeric;
use rand::{Rng, SeedableRng};
use std::borrow::BorrowMut as _;
use std::cell::RefCell;
use std::env;
use std::fs::remove_dir_all;
use std::net::TcpStream;
use std::os::unix::process::CommandExt;
use std::path::PathBuf;
use std::thread::sleep;
use std::time::Duration;

use rpc::rpcdb::{self, PutRequest, WriteBatchRequest};
pub use rpc::service::Database as DatabaseService;
Expand Down
24 changes: 11 additions & 13 deletions grpc-testtool/src/bin/process-server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,18 @@ use chrono::Local;
use clap::Parser;
use env_logger::Builder;
use log::{info, LevelFilter};
use rpc::{
process_server::process_server_service_server::ProcessServerServiceServer,
rpcdb::database_server::DatabaseServer as RpcServer, sync::db_server::DbServer as SyncServer,
DatabaseService,
};
use rpc::process_server::process_server_service_server::ProcessServerServiceServer;
use rpc::rpcdb::database_server::DatabaseServer as RpcServer;
use rpc::sync::db_server::DbServer as SyncServer;
use rpc::DatabaseService;
use serde::Deserialize;
use std::{
error::Error,
io::Write,
net::{IpAddr::V4, Ipv4Addr},
path::PathBuf,
str::FromStr,
sync::Arc,
};
use std::error::Error;
use std::io::Write;
use std::net::IpAddr::V4;
use std::net::Ipv4Addr;
use std::path::PathBuf;
use std::str::FromStr;
use std::sync::Arc;
use tonic::transport::Server;

#[derive(Clone, Debug, Deserialize)]
Expand Down
15 changes: 5 additions & 10 deletions grpc-testtool/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,13 @@
// See the file LICENSE.md for licensing terms.

use firewood::db::{Db, DbConfig};
use firewood::v2::api::Db as _;
use firewood::v2::api::Error;
use firewood::v2::api::{Db as _, Error};

use std::collections::HashMap;
use std::ops::Deref;
use std::path::Path;
use std::{
collections::HashMap,
ops::Deref,
sync::{
atomic::{AtomicU64, Ordering},
Arc,
},
};
use std::sync::atomic::{AtomicU64, Ordering};
use std::sync::Arc;
use tokio::sync::Mutex;
use tonic::Status;

Expand Down
13 changes: 7 additions & 6 deletions grpc-testtool/src/service/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
// See the file LICENSE.md for licensing terms.

use super::{Database as DatabaseService, IntoStatusResultExt as _, Iter};
use crate::rpcdb::database_server::Database;
use crate::rpcdb::{
database_server::Database, CloseRequest, CloseResponse, CompactRequest, CompactResponse,
DeleteRequest, DeleteResponse, GetRequest, GetResponse, HasRequest, HasResponse,
HealthCheckResponse, IteratorErrorRequest, IteratorErrorResponse, IteratorNextRequest,
IteratorNextResponse, IteratorReleaseRequest, IteratorReleaseResponse,
NewIteratorWithStartAndPrefixRequest, NewIteratorWithStartAndPrefixResponse, PutRequest,
PutResponse, WriteBatchRequest, WriteBatchResponse,
CloseRequest, CloseResponse, CompactRequest, CompactResponse, DeleteRequest, DeleteResponse,
GetRequest, GetResponse, HasRequest, HasResponse, HealthCheckResponse, IteratorErrorRequest,
IteratorErrorResponse, IteratorNextRequest, IteratorNextResponse, IteratorReleaseRequest,
IteratorReleaseResponse, NewIteratorWithStartAndPrefixRequest,
NewIteratorWithStartAndPrefixResponse, PutRequest, PutResponse, WriteBatchRequest,
WriteBatchResponse,
};
use firewood::v2::api::{BatchOp, Db as _, DbView as _, Proposal as _};

Expand Down
7 changes: 4 additions & 3 deletions grpc-testtool/src/service/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
// See the file LICENSE.md for licensing terms.

use super::Database;
use crate::sync::db_server::Db as DbServerTrait;
use crate::sync::{
db_server::Db as DbServerTrait, CommitChangeProofRequest, CommitRangeProofRequest,
GetChangeProofRequest, GetChangeProofResponse, GetMerkleRootResponse, GetProofRequest,
GetProofResponse, GetRangeProofRequest, GetRangeProofResponse, VerifyChangeProofRequest,
CommitChangeProofRequest, CommitRangeProofRequest, GetChangeProofRequest,
GetChangeProofResponse, GetMerkleRootResponse, GetProofRequest, GetProofResponse,
GetRangeProofRequest, GetRangeProofResponse, VerifyChangeProofRequest,
VerifyChangeProofResponse,
};
use tonic::{async_trait, Request, Response, Status};
Expand Down
8 changes: 6 additions & 2 deletions storage/benches/serializer.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
// Copyright (C) 2023, Ava Labs, Inc. All rights reserved.
// See the file LICENSE.md for licensing terms.

use std::{array::from_fn, fs::File, num::NonZeroU64, os::raw::c_int};
use std::array::from_fn;
use std::fs::File;
use std::num::NonZeroU64;
use std::os::raw::c_int;

use bincode::Options;
use criterion::{criterion_group, criterion_main, profiler::Profiler, Criterion};
use criterion::profiler::Profiler;
use criterion::{criterion_group, criterion_main, Criterion};
use pprof::ProfilerGuard;
use smallvec::SmallVec;
use storage::{LeafNode, Node, Path};
Expand Down
3 changes: 1 addition & 2 deletions storage/src/hashednode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
use sha2::{Digest, Sha256};
use std::iter::{self};

use crate::{BranchNode, Child, LeafNode, TrieHash};
use crate::{Node, Path};
use crate::{BranchNode, Child, LeafNode, Node, Path, TrieHash};

use integer_encoding::VarInt;

Expand Down
8 changes: 4 additions & 4 deletions storage/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ pub mod logger;
// re-export these so callers don't need to know where they are
pub use hashednode::{hash_node, hash_preimage, Hashable, Preimage, ValueDigest};
pub use linear::{ReadableStorage, WritableStorage};
pub use node::{
path::NibblesIterator, path::Path, BranchNode, Child, LeafNode, Node, PathIterItem,
};
pub use node::path::{NibblesIterator, Path};
pub use node::{BranchNode, Child, LeafNode, Node, PathIterItem};
pub use nodestore::{
Committed, HashedNodeReader, ImmutableProposal, LinearAddress, MutableProposal, NodeReader,
NodeStore, Parentable, ReadInMemoryNode, RootReader, TrieReader, UpdateError,
};

pub use linear::{filebacked::FileBacked, memory::MemStore};
pub use linear::filebacked::FileBacked;
pub use linear::memory::MemStore;

pub use trie_hash::TrieHash;
6 changes: 2 additions & 4 deletions storage/src/linear/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
// See the file LICENSE.md for licensing terms.

use super::{ReadableStorage, WritableStorage};
use std::{
io::{Cursor, Read},
sync::Mutex,
};
use std::io::{Cursor, Read};
use std::sync::Mutex;

#[derive(Debug, Default)]
/// An in-memory impelementation of [WritableStorage] and [ReadableStorage]
Expand Down
3 changes: 2 additions & 1 deletion storage/src/node/branch.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// Copyright (C) 2023, Ava Labs, Inc. All rights reserved.
// See the file LICENSE.md for licensing terms.

use serde::{ser::SerializeStruct as _, Deserialize, Serialize};
use serde::ser::SerializeStruct as _;
use serde::{Deserialize, Serialize};
use smallvec::SmallVec;

use crate::{LeafNode, LinearAddress, Node, Path, TrieHash};
Expand Down
12 changes: 5 additions & 7 deletions storage/src/node/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ use bitfield::bitfield;
use enum_as_inner::EnumAsInner;
use integer_encoding::{VarIntReader as _, VarIntWriter as _};
use serde::{Deserialize, Serialize};
use std::fmt::Debug;
use std::io::{Error, ErrorKind, Read, Write};
use std::num::NonZero;
use std::sync::Arc;
use std::vec;
use std::{fmt::Debug, sync::Arc};

mod branch;
mod leaf;
pub mod path;

pub use branch::BranchNode;
pub use branch::Child;
pub use branch::{BranchNode, Child};
pub use leaf::LeafNode;

use crate::Path;
Expand Down Expand Up @@ -464,10 +464,8 @@ pub struct PathIterItem {

#[cfg(test)]
mod test {
use crate::{
node::{BranchNode, LeafNode, Node},
Child, LinearAddress, Path,
};
use crate::node::{BranchNode, LeafNode, Node};
use crate::{Child, LinearAddress, Path};
use test_case::test_case;

#[test_case(
Expand Down
7 changes: 2 additions & 5 deletions storage/src/node/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@
use bitflags::bitflags;
use serde::{Deserialize, Serialize};
use smallvec::SmallVec;
use std::iter::FusedIterator;
use std::{
fmt::{self, Debug},
iter::once,
};
use std::fmt::{self, Debug};
use std::iter::{once, FusedIterator};

static NIBBLES: [u8; 16] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15];

Expand Down
6 changes: 4 additions & 2 deletions storage/src/trie_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@

use std::fmt::{self, Debug};

use serde::{de::Visitor, Deserialize, Serialize};
use sha2::digest::{generic_array::GenericArray, typenum};
use serde::de::Visitor;
use serde::{Deserialize, Serialize};
use sha2::digest::generic_array::GenericArray;
use sha2::digest::typenum;

/// A hash value inside a merkle trie
/// We use the same type as returned by sha2 here to avoid copies
Expand Down
Loading