;
#[cfg(test)]
mod test {
- use super::*;
- use crate::net::*;
+ use std::io::prelude::*;
+ use std::io::{Read, Write};
+ use std::sync::{Arc, Mutex};
+ use std::{io, thread};
+
use rand;
use rand::RngCore;
use stacks_common::util::pipe::*;
use stacks_common::util::secp256k1::*;
use stacks_common::util::*;
- use std::io;
- use std::io::prelude::*;
- use std::io::{Read, Write};
- use std::sync::{Arc, Mutex};
- use std::thread;
-
- use crate::net::test::make_tcp_sockets;
- use crate::net::test::NetCursor;
+ use super::*;
use crate::chainstate::stacks::test::make_codec_test_block;
use crate::net::http::*;
-
+ use crate::net::test::{make_tcp_sockets, NetCursor};
+ use crate::net::*;
use crate::util_lib::test::*;
fn test_connection_relay_producer_consumer(
diff --git a/stackslib/src/net/db.rs b/stackslib/src/net/db.rs
index a11627a638..25c4ed7e62 100644
--- a/stackslib/src/net/db.rs
+++ b/stackslib/src/net/db.rs
@@ -14,65 +14,37 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
-use std::fmt;
-
use std::collections::HashSet;
+use std::convert::{From, TryFrom};
+use std::{fmt, fs};
+use clarity::vm::types::{
+ QualifiedContractIdentifier, StacksAddressExtensions, StandardPrincipalData,
+};
+use rand::seq::SliceRandom;
+use rand::{thread_rng, Rng, RngCore};
use rusqlite::types::ToSql;
-use rusqlite::OptionalExtension;
-use rusqlite::Row;
-use rusqlite::Transaction;
-use rusqlite::{Connection, OpenFlags, NO_PARAMS};
-
-use std::convert::From;
-use std::convert::TryFrom;
-use std::fs;
-
-use clarity::vm::types::QualifiedContractIdentifier;
-use clarity::vm::types::StacksAddressExtensions;
-use clarity::vm::types::StandardPrincipalData;
-
-use crate::util_lib::db::sqlite_open;
-use crate::util_lib::db::tx_begin_immediate;
-use crate::util_lib::db::DBConn;
-use crate::util_lib::db::Error as db_error;
-use crate::util_lib::db::{query_count, query_row, query_rows, u64_to_sql, FromColumn, FromRow};
-
+use rusqlite::{Connection, OpenFlags, OptionalExtension, Row, Transaction, NO_PARAMS};
+use stacks_common::types::net::{PeerAddress, PeerHost};
use stacks_common::util;
-use stacks_common::util::get_epoch_time_secs;
use stacks_common::util::hash::{
bin_bytes, hex_bytes, to_bin, to_hex, Hash160, Sha256Sum, Sha512Trunc256Sum,
};
-use stacks_common::util::log;
use stacks_common::util::macros::is_big_endian;
-use stacks_common::util::secp256k1::Secp256k1PrivateKey;
-use stacks_common::util::secp256k1::Secp256k1PublicKey;
-
-use crate::util_lib::db::tx_busy_handler;
-
-use crate::chainstate::stacks::StacksPrivateKey;
-use crate::chainstate::stacks::StacksPublicKey;
-
-use rand::seq::SliceRandom;
-use rand::thread_rng;
-use rand::Rng;
-use rand::RngCore;
-
-use crate::net::asn::ASEntry4;
-use crate::net::Neighbor;
-use crate::net::NeighborAddress;
-use crate::net::NeighborKey;
-use crate::net::ServiceFlags;
-
-use crate::burnchains::PrivateKey;
-use crate::burnchains::PublicKey;
+use stacks_common::util::secp256k1::{Secp256k1PrivateKey, Secp256k1PublicKey};
+use stacks_common::util::{get_epoch_time_secs, log};
+use crate::burnchains::{PrivateKey, PublicKey};
+use crate::chainstate::stacks::{StacksPrivateKey, StacksPublicKey};
use crate::core::NETWORK_P2P_PORT;
-
+use crate::net::asn::ASEntry4;
+use crate::net::{Neighbor, NeighborAddress, NeighborKey, ServiceFlags};
+use crate::util_lib::db::{
+ query_count, query_row, query_rows, sqlite_open, tx_begin_immediate, tx_busy_handler,
+ u64_to_sql, DBConn, Error as db_error, FromColumn, FromRow,
+};
use crate::util_lib::strings::UrlString;
-use stacks_common::types::net::PeerAddress;
-
pub const PEERDB_VERSION: &'static str = "2";
const NUM_SLOTS: usize = 8;
@@ -1826,17 +1798,13 @@ impl PeerDB {
#[cfg(test)]
mod test {
- use super::*;
- use crate::net::Neighbor;
- use crate::net::NeighborKey;
- use stacks_common::types::net::PeerAddress;
-
+ use clarity::vm::types::{StacksAddressExtensions, StandardPrincipalData};
use stacks_common::types::chainstate::StacksAddress;
-
+ use stacks_common::types::net::{PeerAddress, PeerHost};
use stacks_common::util::hash::Hash160;
- use clarity::vm::types::StacksAddressExtensions;
- use clarity::vm::types::StandardPrincipalData;
+ use super::*;
+ use crate::net::{Neighbor, NeighborKey};
/// Test storage, retrieval, and mutation of LocalPeer, including its stacker DB contract IDs
#[test]
diff --git a/stackslib/src/net/dns.rs b/stackslib/src/net/dns.rs
index ac99ee5d41..aedb73bd62 100644
--- a/stackslib/src/net/dns.rs
+++ b/stackslib/src/net/dns.rs
@@ -14,39 +14,21 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
-use std::sync::mpsc::sync_channel;
-use std::sync::mpsc::Receiver;
-use std::sync::mpsc::RecvError;
-use std::sync::mpsc::RecvTimeoutError;
-use std::sync::mpsc::SyncSender;
-use std::sync::mpsc::TryRecvError;
-use std::sync::mpsc::TrySendError;
-
+use std::collections::{HashMap, HashSet, VecDeque};
use std::hash::{Hash, Hasher};
-use std::net::ToSocketAddrs;
+use std::net::{SocketAddr, ToSocketAddrs};
+use std::sync::mpsc::{
+ sync_channel, Receiver, RecvError, RecvTimeoutError, SyncSender, TryRecvError, TrySendError,
+};
-use crate::net::asn::ASEntry4;
-use crate::net::Error as net_error;
-use crate::net::Neighbor;
-use crate::net::NeighborKey;
+use stacks_common::types::net::PeerAddress;
+use stacks_common::util::hash::to_hex;
+use stacks_common::util::{get_epoch_time_ms, get_epoch_time_secs, log, sleep_ms};
+use crate::net::asn::ASEntry4;
use crate::net::codec::*;
-use crate::net::*;
-
+use crate::net::{Error as net_error, Neighbor, NeighborKey, *};
use crate::util_lib::db::Error as db_error;
-use stacks_common::util::sleep_ms;
-
-use std::net::SocketAddr;
-
-use std::collections::HashMap;
-use std::collections::HashSet;
-use std::collections::VecDeque;
-
-use stacks_common::types::net::PeerAddress;
-use stacks_common::util::get_epoch_time_ms;
-use stacks_common::util::get_epoch_time_secs;
-use stacks_common::util::hash::to_hex;
-use stacks_common::util::log;
/// In Rust, there's no easy way to do non-blocking DNS lookups (I blame getaddrinfo), so do it in
/// a separate thread, and implement a way for the block downloader to periodically poll for
@@ -375,11 +357,13 @@ impl DNSClient {
#[cfg(test)]
mod test {
- use crate::net::test::*;
- use stacks_common::util::*;
use std::collections::HashMap;
use std::error::Error;
+ use stacks_common::util::*;
+
+ use crate::net::test::*;
+
#[test]
fn dns_start_stop() {
let (client, thread_handle) = dns_thread_start(100);
diff --git a/stackslib/src/net/download.rs b/stackslib/src/net/download.rs
index 7f6f7fba1b..5957b9818a 100644
--- a/stackslib/src/net/download.rs
+++ b/stackslib/src/net/download.rs
@@ -14,45 +14,36 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
-use std::collections::HashMap;
-use std::collections::HashSet;
-use std::collections::VecDeque;
+use std::collections::{HashMap, HashSet, VecDeque};
use std::convert::TryFrom;
use std::hash::{Hash, Hasher};
-use std::io::Read;
-use std::io::Write;
-use std::net::IpAddr;
-use std::net::SocketAddr;
-use std::sync::mpsc::sync_channel;
-use std::sync::mpsc::Receiver;
-use std::sync::mpsc::RecvError;
-use std::sync::mpsc::RecvTimeoutError;
-use std::sync::mpsc::SyncSender;
-use std::sync::mpsc::TryRecvError;
-use std::sync::mpsc::TrySendError;
+use std::io::{Read, Write};
+use std::net::{IpAddr, SocketAddr};
+use std::sync::mpsc::{
+ sync_channel, Receiver, RecvError, RecvTimeoutError, SyncSender, TryRecvError, TrySendError,
+};
use rand::seq::SliceRandom;
-use rand::thread_rng;
-use rand::RngCore;
+use rand::{thread_rng, RngCore};
+use stacks_common::types::chainstate::{BlockHeaderHash, PoxId, SortitionId, StacksBlockId};
+use stacks_common::types::net::{PeerAddress, PeerHost};
+use stacks_common::util::hash::to_hex;
+use stacks_common::util::secp256k1::{Secp256k1PrivateKey, Secp256k1PublicKey};
+use stacks_common::util::{get_epoch_time_ms, get_epoch_time_secs, log};
-use crate::burnchains::Burnchain;
-use crate::burnchains::BurnchainView;
+use crate::burnchains::{Burnchain, BurnchainView};
use crate::chainstate::burn::db::sortdb::{BlockHeaderCache, SortitionDB, SortitionDBConn};
use crate::chainstate::burn::BlockSnapshot;
use crate::chainstate::stacks::db::StacksChainState;
-use crate::chainstate::stacks::Error as chainstate_error;
-use crate::chainstate::stacks::StacksBlockHeader;
-use crate::core::mempool::MemPoolDB;
-use crate::core::EMPTY_MICROBLOCK_PARENT_HASH;
-use crate::core::FIRST_BURNCHAIN_CONSENSUS_HASH;
-use crate::core::FIRST_STACKS_BLOCK_HASH;
+use crate::chainstate::stacks::{Error as chainstate_error, StacksBlockHeader};
+use crate::core::{
+ EMPTY_MICROBLOCK_PARENT_HASH, FIRST_BURNCHAIN_CONSENSUS_HASH, FIRST_STACKS_BLOCK_HASH,
+};
use crate::net::asn::ASEntry4;
use crate::net::atlas::AttachmentsDownloader;
use crate::net::codec::*;
-use crate::net::connection::ConnectionOptions;
-use crate::net::connection::ReplyHandleHttp;
-use crate::net::db::PeerDB;
-use crate::net::db::*;
+use crate::net::connection::{ConnectionOptions, ReplyHandleHttp};
+use crate::net::db::{PeerDB, *};
use crate::net::dns::*;
use crate::net::http::HttpRequestContents;
use crate::net::httpcore::{StacksHttpRequest, StacksHttpResponse};
@@ -61,25 +52,10 @@ use crate::net::neighbors::MAX_NEIGHBOR_BLOCK_DELAY;
use crate::net::p2p::PeerNetwork;
use crate::net::rpc::*;
use crate::net::server::HttpPeer;
-use crate::net::Error as net_error;
-use crate::net::GetBlocksInv;
-use crate::net::Neighbor;
-use crate::net::NeighborKey;
-use crate::net::StacksMessage;
-use crate::net::StacksP2P;
-use crate::net::*;
-use crate::util_lib::db::DBConn;
-use crate::util_lib::db::Error as db_error;
-use stacks_common::types::chainstate::StacksBlockId;
-use stacks_common::types::net::PeerAddress;
-use stacks_common::util::get_epoch_time_ms;
-use stacks_common::util::get_epoch_time_secs;
-use stacks_common::util::hash::to_hex;
-use stacks_common::util::log;
-use stacks_common::util::secp256k1::Secp256k1PrivateKey;
-use stacks_common::util::secp256k1::Secp256k1PublicKey;
-
-use stacks_common::types::chainstate::{BlockHeaderHash, PoxId, SortitionId};
+use crate::net::{
+ Error as net_error, GetBlocksInv, Neighbor, NeighborKey, StacksMessage, StacksP2P, *,
+};
+use crate::util_lib::db::{DBConn, Error as db_error};
#[cfg(not(test))]
pub const BLOCK_DOWNLOAD_INTERVAL: u64 = 180;
@@ -2532,8 +2508,16 @@ pub mod test {
use std::collections::HashMap;
use std::convert::TryFrom;
+ use clarity::vm::clarity::ClarityConnection;
+ use clarity::vm::costs::ExecutionCost;
+ use clarity::vm::execute;
+ use clarity::vm::representations::*;
use rand::Rng;
+ use stacks_common::util::hash::*;
+ use stacks_common::util::sleep_ms;
+ use stacks_common::util::vrf::VRFProof;
+ use super::*;
use crate::burnchains::tests::TestMiner;
use crate::chainstate::burn::db::sortdb::*;
use crate::chainstate::burn::operations::*;
@@ -2549,15 +2533,6 @@ pub mod test {
use crate::stacks_common::types::PublicKey;
use crate::util_lib::strings::*;
use crate::util_lib::test::*;
- use clarity::vm::clarity::ClarityConnection;
- use clarity::vm::costs::ExecutionCost;
- use clarity::vm::execute;
- use clarity::vm::representations::*;
- use stacks_common::util::hash::*;
- use stacks_common::util::sleep_ms;
- use stacks_common::util::vrf::VRFProof;
-
- use super::*;
fn get_peer_availability(
peer: &mut TestPeer,
diff --git a/stackslib/src/net/http/common.rs b/stackslib/src/net/http/common.rs
index 0fee2c37bb..476c7c03da 100644
--- a/stackslib/src/net/http/common.rs
+++ b/stackslib/src/net/http/common.rs
@@ -14,16 +14,12 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
-use std::fmt;
-use std::io;
use std::io::Read;
use std::net::SocketAddr;
use std::str::FromStr;
+use std::{fmt, io};
-use stacks_common::codec::read_next;
-use stacks_common::codec::Error as CodecError;
-use stacks_common::codec::StacksMessageCodec;
-use stacks_common::codec::MAX_MESSAGE_LEN;
+use stacks_common::codec::{read_next, Error as CodecError, StacksMessageCodec, MAX_MESSAGE_LEN};
use stacks_common::types::net::PeerHost;
use stacks_common::util::chunked_encoding::*;
use stacks_common::util::retry::BoundReader;
diff --git a/stackslib/src/net/http/error.rs b/stackslib/src/net/http/error.rs
index afe6dce62e..c84c04d585 100644
--- a/stackslib/src/net/http/error.rs
+++ b/stackslib/src/net/http/error.rs
@@ -17,13 +17,12 @@
use std::io;
use std::io::Read;
-use crate::net::http::response::HttpResponse;
-use crate::net::http::{Error, HttpContentType, HttpResponsePayload, HttpResponsePreamble};
-
+use serde_json;
use stacks_common::codec::MAX_MESSAGE_LEN;
use stacks_common::util::retry::BoundReader;
-use serde_json;
+use crate::net::http::response::HttpResponse;
+use crate::net::http::{Error, HttpContentType, HttpResponsePayload, HttpResponsePreamble};
/// Default implementation of `try_parse_response()` for an HTTP error message that implements
/// `HttpReqeust`.
diff --git a/stackslib/src/net/http/mod.rs b/stackslib/src/net/http/mod.rs
index 7d032ddd90..cc6355ca31 100644
--- a/stackslib/src/net/http/mod.rs
+++ b/stackslib/src/net/http/mod.rs
@@ -23,16 +23,14 @@ pub mod stream;
#[cfg(test)]
mod tests;
-use regex::{Captures, Regex};
use std::collections::BTreeMap;
-use std::fmt;
-use std::io;
use std::io::Write;
use std::str::FromStr;
+use std::{fmt, io};
-use stacks_common::codec::Error as CodecError;
-
+use regex::{Captures, Regex};
use serde_json;
+use stacks_common::codec::Error as CodecError;
pub use crate::net::http::common::{
parse_bytes, parse_bytestream, parse_json, HttpReservedHeader, HttpVersion,
diff --git a/stackslib/src/net/http/request.rs b/stackslib/src/net/http/request.rs
index f9a0dd0d92..b0e2eab059 100644
--- a/stackslib/src/net/http/request.rs
+++ b/stackslib/src/net/http/request.rs
@@ -18,27 +18,22 @@ use std::collections::{BTreeMap, HashMap, HashSet};
use std::io::{Read, Write};
use std::string::ToString;
-use crate::net::http::common::HttpReservedHeader;
-use crate::net::http::common::HTTP_PREAMBLE_MAX_ENCODED_SIZE;
-use crate::net::http::common::HTTP_PREAMBLE_MAX_NUM_HEADERS;
-use crate::net::http::{
- default_accept_header, write_headers, Error, HttpContentType, HttpResponseContents,
- HttpResponsePreamble, HttpVersion,
-};
-
-use stacks_common::codec::{write_next, Error as CodecError, StacksMessageCodec};
-use stacks_common::types::net::PeerHost;
-
-use stacks_common::deps_common::httparse;
-
use percent_encoding::percent_decode_str;
+use rand::{thread_rng, Rng};
use regex::{Captures, Regex};
+use serde_json;
+use stacks_common::codec::{write_next, Error as CodecError, StacksMessageCodec};
+use stacks_common::deps_common::httparse;
+use stacks_common::types::net::PeerHost;
use url::form_urlencoded;
-use rand::thread_rng;
-use rand::Rng;
-
-use serde_json;
+use crate::net::http::common::{
+ HttpReservedHeader, HTTP_PREAMBLE_MAX_ENCODED_SIZE, HTTP_PREAMBLE_MAX_NUM_HEADERS,
+};
+use crate::net::http::{
+ default_accept_header, write_headers, Error, HttpContentType, HttpResponseContents,
+ HttpResponsePreamble, HttpVersion,
+};
/// HTTP request preamble. This captures "control plane" data for an HTTP request, and contains
/// everything of use to us from the HTTP requests's headers.
diff --git a/stackslib/src/net/http/response.rs b/stackslib/src/net/http/response.rs
index d8cf2a3d74..57a1afb2ce 100644
--- a/stackslib/src/net/http/response.rs
+++ b/stackslib/src/net/http/response.rs
@@ -20,23 +20,21 @@ use std::io::{Read, Write};
use std::ops::Deref;
use std::time::SystemTime;
-use crate::net::http::{
- common::{HttpReservedHeader, HTTP_PREAMBLE_MAX_ENCODED_SIZE, HTTP_PREAMBLE_MAX_NUM_HEADERS},
- request::{HttpRequestContents, HttpRequestPreamble},
- stream::HttpChunkGenerator,
- write_headers, Error, HttpContentType, HttpVersion,
-};
-
use stacks_common::codec::{Error as CodecError, StacksMessageCodec};
-
use stacks_common::deps_common::httparse;
-use stacks_common::util::chunked_encoding::HttpChunkedTransferWriter;
-use stacks_common::util::chunked_encoding::HttpChunkedTransferWriterState;
+use stacks_common::util::chunked_encoding::{
+ HttpChunkedTransferWriter, HttpChunkedTransferWriterState,
+};
use stacks_common::util::hash::to_hex;
use stacks_common::util::pipe::PipeWrite;
+use {serde, serde_json};
-use serde;
-use serde_json;
+use crate::net::http::common::{
+ HttpReservedHeader, HTTP_PREAMBLE_MAX_ENCODED_SIZE, HTTP_PREAMBLE_MAX_NUM_HEADERS,
+};
+use crate::net::http::request::{HttpRequestContents, HttpRequestPreamble};
+use crate::net::http::stream::HttpChunkGenerator;
+use crate::net::http::{write_headers, Error, HttpContentType, HttpVersion};
/// HTTP response preamble. This captures all HTTP header information, but in a way that
/// certain fields that nodes rely on are guaranteed to have correct, sensible values.
diff --git a/stackslib/src/net/http/stream.rs b/stackslib/src/net/http/stream.rs
index c698b27384..08fe5a26c7 100644
--- a/stackslib/src/net/http/stream.rs
+++ b/stackslib/src/net/http/stream.rs
@@ -17,26 +17,20 @@
use std::io;
use std::io::{Read, Write};
-use stacks_common::types::chainstate::BlockHeaderHash;
-use stacks_common::types::chainstate::StacksBlockId;
-
-use crate::burnchains::Txid;
-use crate::chainstate::stacks::{StacksBlock, StacksBlockHeader, StacksMicroblock};
-
-use crate::chainstate::stacks::db::StacksChainState;
-use crate::chainstate::stacks::Error as ChainstateError;
-
-use crate::util_lib::db::Error as DBError;
-
-use crate::core::mempool::{MemPoolDB, MemPoolSyncData};
-
+use rand::{thread_rng, Rng};
+use stacks_common::types::chainstate::{BlockHeaderHash, StacksBlockId};
use stacks_common::util::chunked_encoding::{
HttpChunkedTransferWriter, HttpChunkedTransferWriterState,
};
use stacks_common::util::pipe::PipeWrite;
-use rand::thread_rng;
-use rand::Rng;
+use crate::burnchains::Txid;
+use crate::chainstate::stacks::db::StacksChainState;
+use crate::chainstate::stacks::{
+ Error as ChainstateError, StacksBlock, StacksBlockHeader, StacksMicroblock,
+};
+use crate::core::mempool::{MemPoolDB, MemPoolSyncData};
+use crate::util_lib::db::Error as DBError;
pub trait HttpChunkGenerator: Send {
fn generate_next_chunk(&mut self) -> Result, String>;
diff --git a/stackslib/src/net/http/tests.rs b/stackslib/src/net/http/tests.rs
index f7c6f204f1..4a6ff91d81 100644
--- a/stackslib/src/net/http/tests.rs
+++ b/stackslib/src/net/http/tests.rs
@@ -14,18 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
+use stacks_common::codec::StacksMessageCodec;
+use stacks_common::types::net::{PeerAddress, PeerHost};
+
+use crate::net::http::common::{HTTP_PREAMBLE_MAX_ENCODED_SIZE, HTTP_PREAMBLE_MAX_NUM_HEADERS};
use crate::net::http::{
HttpContentType, HttpRequestPreamble, HttpReservedHeader, HttpResponsePreamble, HttpVersion,
};
-use crate::net::http::common::HTTP_PREAMBLE_MAX_ENCODED_SIZE;
-use crate::net::http::common::HTTP_PREAMBLE_MAX_NUM_HEADERS;
-
-use stacks_common::types::net::PeerAddress;
-use stacks_common::types::net::PeerHost;
-
-use stacks_common::codec::StacksMessageCodec;
-
#[test]
fn test_parse_reserved_header() {
let tests = vec![
diff --git a/stackslib/src/net/httpcore.rs b/stackslib/src/net/httpcore.rs
index dbdeefce1b..ae4db0c07f 100644
--- a/stackslib/src/net/httpcore.rs
+++ b/stackslib/src/net/httpcore.rs
@@ -14,59 +14,43 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
-use crate::burnchains::Txid;
-use crate::chainstate::burn::db::sortdb::SortitionDB;
-use crate::chainstate::burn::BlockSnapshot;
-use crate::chainstate::stacks::db::blocks::StagingBlock;
-use crate::chainstate::stacks::db::StacksChainState;
-use crate::core::MemPoolDB;
-use crate::core::StacksEpoch;
-use crate::net::connection::ConnectionOptions;
-use crate::net::http::{
- common::HTTP_PREAMBLE_MAX_ENCODED_SIZE, http_reason, Error as HttpError, HttpBadRequest,
- HttpContentType, HttpErrorResponse, HttpNotFound, HttpRequest, HttpRequestContents,
- HttpRequestPreamble, HttpResponse, HttpResponseContents, HttpResponsePayload,
- HttpResponsePreamble, HttpServerError, HttpVersion,
-};
-use crate::net::p2p::PeerNetwork;
-use crate::net::server::HttpPeer;
-use crate::net::Error as NetError;
-use crate::net::MessageSequence;
-use crate::net::ProtocolFamily;
-use crate::net::StacksNodeState;
-use crate::net::UrlString;
/// This module binds the http library to Stacks as a `ProtocolFamily` implementation
use std::collections::{BTreeMap, HashMap};
-use std::fmt;
-use std::io;
use std::io::{Read, Write};
-use std::mem;
use std::net::SocketAddr;
+use std::{fmt, io, mem};
+use clarity::vm::costs::ExecutionCost;
+use clarity::vm::types::{QualifiedContractIdentifier, BOUND_VALUE_SERIALIZATION_HEX};
+use clarity::vm::{ClarityName, ContractName};
+use percent_encoding::percent_decode_str;
use regex::{Captures, Regex};
-
-use url::Url;
-
-use stacks_common::codec::read_next;
-use stacks_common::codec::Error as CodecError;
-use stacks_common::codec::StacksMessageCodec;
-use stacks_common::codec::MAX_MESSAGE_LEN;
-use stacks_common::types::chainstate::ConsensusHash;
-use stacks_common::types::chainstate::StacksAddress;
-use stacks_common::types::chainstate::StacksBlockId;
-use stacks_common::types::chainstate::StacksPublicKey;
+use stacks_common::codec::{read_next, Error as CodecError, StacksMessageCodec, MAX_MESSAGE_LEN};
+use stacks_common::types::chainstate::{
+ ConsensusHash, StacksAddress, StacksBlockId, StacksPublicKey,
+};
use stacks_common::types::net::PeerHost;
use stacks_common::types::Address;
use stacks_common::util::chunked_encoding::*;
use stacks_common::util::retry::{BoundReader, RetryReader};
+use url::Url;
-use clarity::vm::costs::ExecutionCost;
-use clarity::vm::types::QualifiedContractIdentifier;
-use clarity::vm::types::BOUND_VALUE_SERIALIZATION_HEX;
-use clarity::vm::ClarityName;
-use clarity::vm::ContractName;
-
-use percent_encoding::percent_decode_str;
+use crate::burnchains::Txid;
+use crate::chainstate::burn::db::sortdb::SortitionDB;
+use crate::chainstate::burn::BlockSnapshot;
+use crate::chainstate::stacks::db::blocks::StagingBlock;
+use crate::chainstate::stacks::db::StacksChainState;
+use crate::core::{MemPoolDB, StacksEpoch};
+use crate::net::connection::ConnectionOptions;
+use crate::net::http::common::HTTP_PREAMBLE_MAX_ENCODED_SIZE;
+use crate::net::http::{
+ http_reason, Error as HttpError, HttpBadRequest, HttpContentType, HttpErrorResponse,
+ HttpNotFound, HttpRequest, HttpRequestContents, HttpRequestPreamble, HttpResponse,
+ HttpResponseContents, HttpResponsePayload, HttpResponsePreamble, HttpServerError, HttpVersion,
+};
+use crate::net::p2p::PeerNetwork;
+use crate::net::server::HttpPeer;
+use crate::net::{Error as NetError, MessageSequence, ProtocolFamily, StacksNodeState, UrlString};
const CHUNK_BUF_LEN: usize = 32768;
diff --git a/stackslib/src/net/inv.rs b/stackslib/src/net/inv.rs
index ceb08d1dd0..6a3bee20c0 100644
--- a/stackslib/src/net/inv.rs
+++ b/stackslib/src/net/inv.rs
@@ -15,54 +15,37 @@
// along with this program. If not, see .
use std::cmp;
-use std::collections::BTreeMap;
-use std::collections::HashMap;
-use std::collections::HashSet;
+use std::collections::{BTreeMap, HashMap, HashSet};
use std::convert::TryFrom;
-use std::io::Read;
-use std::io::Write;
+use std::io::{Read, Write};
use std::net::SocketAddr;
use rand;
use rand::seq::SliceRandom;
-use rand::thread_rng;
-use rand::Rng;
+use rand::{thread_rng, Rng};
+use stacks_common::types::chainstate::{BlockHeaderHash, PoxId, SortitionId};
+use stacks_common::util::hash::to_hex;
+use stacks_common::util::secp256k1::{Secp256k1PrivateKey, Secp256k1PublicKey};
+use stacks_common::util::{get_epoch_time_ms, get_epoch_time_secs, log};
-use crate::burnchains::Burnchain;
-use crate::burnchains::BurnchainView;
+use crate::burnchains::{Burnchain, BurnchainView};
use crate::chainstate::burn::db::sortdb::{
BlockHeaderCache, SortitionDB, SortitionDBConn, SortitionHandleConn,
};
-use crate::chainstate::burn::BlockSnapshot;
+use crate::chainstate::burn::{BlockSnapshot, ConsensusHashExtensions};
use crate::chainstate::stacks::db::StacksChainState;
use crate::net::asn::ASEntry4;
use crate::net::chat::ConversationP2P;
use crate::net::codec::*;
-use crate::net::connection::ConnectionOptions;
-use crate::net::connection::ConnectionP2P;
-use crate::net::connection::ReplyHandleP2P;
-use crate::net::db::PeerDB;
-use crate::net::db::*;
+use crate::net::connection::{ConnectionOptions, ConnectionP2P, ReplyHandleP2P};
+use crate::net::db::{PeerDB, *};
use crate::net::neighbors::MAX_NEIGHBOR_BLOCK_DELAY;
use crate::net::p2p::PeerNetwork;
-use crate::net::Error as net_error;
-use crate::net::GetBlocksInv;
-use crate::net::Neighbor;
-use crate::net::NeighborKey;
-use crate::net::StacksMessage;
-use crate::net::StacksP2P;
-use crate::net::*;
-use crate::util_lib::db::DBConn;
-use crate::util_lib::db::Error as db_error;
-use stacks_common::util::get_epoch_time_ms;
-use stacks_common::util::get_epoch_time_secs;
-use stacks_common::util::hash::to_hex;
-use stacks_common::util::log;
-use stacks_common::util::secp256k1::Secp256k1PrivateKey;
-use stacks_common::util::secp256k1::Secp256k1PublicKey;
-
-use crate::chainstate::burn::ConsensusHashExtensions;
-use stacks_common::types::chainstate::{BlockHeaderHash, PoxId, SortitionId};
+use crate::net::{
+ Error as net_error, GetBlocksInv, Neighbor, NeighborKey, PeerAddress, StacksMessage, StacksP2P,
+ *,
+};
+use crate::util_lib::db::{DBConn, Error as db_error};
/// This module is responsible for synchronizing block inventories with other peers
#[cfg(not(test))]
@@ -2647,20 +2630,18 @@ impl PeerNetwork {
mod test {
use std::collections::HashMap;
- use crate::burnchains::PoxConstants;
- use crate::chainstate::stacks::*;
- use crate::net::test::*;
- use crate::net::*;
- use crate::util_lib::test::*;
+ use stacks_common::deps_common::bitcoin::network::serialize::BitcoinHash;
use super::*;
-
use crate::burnchains::bitcoin::indexer::BitcoinIndexer;
use crate::burnchains::db::BurnchainHeaderReader;
use crate::burnchains::tests::BURNCHAIN_TEST_BLOCK_TIME;
- use crate::burnchains::BurnchainBlockHeader;
+ use crate::burnchains::{BurnchainBlockHeader, PoxConstants};
use crate::chainstate::coordinator::tests::get_burnchain;
- use stacks_common::deps_common::bitcoin::network::serialize::BitcoinHash;
+ use crate::chainstate::stacks::*;
+ use crate::net::test::*;
+ use crate::net::*;
+ use crate::util_lib::test::*;
#[test]
fn peerblocksinv_has_ith_block() {
diff --git a/stackslib/src/net/mod.rs b/stackslib/src/net/mod.rs
index 564e346c4f..188a4bca31 100644
--- a/stackslib/src/net/mod.rs
+++ b/stackslib/src/net/mod.rs
@@ -17,100 +17,80 @@
use std::borrow::Borrow;
use std::cmp::PartialEq;
use std::collections::{HashMap, HashSet};
-use std::convert::From;
-use std::convert::TryFrom;
-use std::error;
-use std::fmt;
-use std::hash::Hash;
-use std::hash::Hasher;
-use std::io;
+use std::convert::{From, TryFrom};
+use std::hash::{Hash, Hasher};
use std::io::prelude::*;
use std::io::{Read, Write};
-use std::net::IpAddr;
-use std::net::Ipv4Addr;
-use std::net::Ipv6Addr;
-use std::net::SocketAddr;
+use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr};
use std::ops::Deref;
use std::str::FromStr;
+use std::{error, fmt, io};
-use rand::thread_rng;
-use rand::RngCore;
+use clarity::vm::analysis::contract_interface_builder::ContractInterface;
+use clarity::vm::costs::ExecutionCost;
+use clarity::vm::types::{
+ PrincipalData, QualifiedContractIdentifier, StandardPrincipalData, TraitIdentifier,
+};
+use clarity::vm::{ClarityName, ContractName, Value};
+use libstackerdb::{
+ Error as libstackerdb_error, SlotMetadata, StackerDBChunkAckData, StackerDBChunkData,
+};
+use rand::{thread_rng, RngCore};
use regex::Regex;
-use rusqlite;
use rusqlite::types::ToSqlOutput;
use rusqlite::ToSql;
use serde::de::Error as de_Error;
use serde::ser::Error as ser_Error;
use serde::{Deserialize, Serialize};
-use serde_json;
-use url;
+use stacks_common::codec::{
+ read_next, write_next, Error as codec_error, StacksMessageCodec,
+ BURNCHAIN_HEADER_HASH_ENCODED_SIZE,
+};
+use stacks_common::types::chainstate::{
+ BlockHeaderHash, BurnchainHeaderHash, PoxId, StacksAddress, StacksBlockId,
+};
+use stacks_common::types::net::{Error as AddrError, PeerAddress, PeerHost};
+use stacks_common::types::StacksPublicKeyBuffer;
+use stacks_common::util::hash::{
+ hex_bytes, to_hex, Hash160, Sha256Sum, DOUBLE_SHA256_ENCODED_SIZE, HASH160_ENCODED_SIZE,
+};
+use stacks_common::util::secp256k1::{
+ MessageSignature, Secp256k1PublicKey, MESSAGE_SIGNATURE_ENCODED_SIZE,
+};
+use stacks_common::util::{get_epoch_time_secs, log};
+use {rusqlite, serde_json, url};
use crate::burnchains::affirmation::AffirmationMap;
-use crate::burnchains::Burnchain;
-use crate::burnchains::Error as burnchain_error;
-use crate::burnchains::Txid;
+use crate::burnchains::{Error as burnchain_error, Txid};
+use crate::chainstate::burn::db::sortdb::SortitionDB;
use crate::chainstate::burn::ConsensusHash;
use crate::chainstate::coordinator::Error as coordinator_error;
use crate::chainstate::stacks::db::blocks::MemPoolRejection;
+use crate::chainstate::stacks::db::StacksChainState;
use crate::chainstate::stacks::index::Error as marf_error;
-use crate::chainstate::stacks::Error as chainstate_error;
use crate::chainstate::stacks::{
- Error as chain_error, StacksBlock, StacksMicroblock, StacksPublicKey, StacksTransaction,
- TransactionPayload,
+ Error as chainstate_error, Error as chain_error, StacksBlock, StacksBlockHeader,
+ StacksMicroblock, StacksPublicKey, StacksTransaction, TransactionPayload,
};
use crate::clarity_vm::clarity::Error as clarity_error;
-use crate::core::POX_REWARD_CYCLE_LENGTH;
+use crate::core::mempool::*;
+use crate::core::{StacksEpoch, POX_REWARD_CYCLE_LENGTH};
+use crate::cost_estimates::metrics::CostMetric;
+use crate::cost_estimates::{CostEstimator, FeeEstimator, FeeRateEstimate};
use crate::net::atlas::{Attachment, AttachmentInstance};
-use crate::net::httpcore::TipRequest;
+use crate::net::dns::*;
+use crate::net::http::error::{HttpNotFound, HttpServerError};
+use crate::net::http::{
+ Error as HttpErr, HttpRequestContents, HttpRequestPreamble, HttpResponsePreamble,
+};
+use crate::net::httpcore::{
+ HttpRequestContentsExtensions, StacksHttp, StacksHttpRequest, StacksHttpResponse, TipRequest,
+};
+use crate::net::p2p::PeerNetwork;
use crate::util_lib::bloom::{BloomFilter, BloomNodeHasher};
use crate::util_lib::boot::boot_code_tx_auth;
-use crate::util_lib::db::DBConn;
-use crate::util_lib::db::Error as db_error;
+use crate::util_lib::db::{DBConn, Error as db_error};
use crate::util_lib::strings::UrlString;
-use clarity::vm::types::QualifiedContractIdentifier;
-use clarity::vm::types::StandardPrincipalData;
-use clarity::vm::types::TraitIdentifier;
-use clarity::vm::{
- analysis::contract_interface_builder::ContractInterface, types::PrincipalData, ClarityName,
- ContractName, Value,
-};
-use stacks_common::codec::Error as codec_error;
-use stacks_common::codec::StacksMessageCodec;
-use stacks_common::codec::BURNCHAIN_HEADER_HASH_ENCODED_SIZE;
-use stacks_common::codec::{read_next, write_next};
-use stacks_common::types::net::{Error as AddrError, PeerAddress, PeerHost};
-use stacks_common::util::get_epoch_time_secs;
-use stacks_common::util::hash::Hash160;
-use stacks_common::util::hash::DOUBLE_SHA256_ENCODED_SIZE;
-use stacks_common::util::hash::HASH160_ENCODED_SIZE;
-use stacks_common::util::hash::{hex_bytes, to_hex};
-use stacks_common::util::log;
-use stacks_common::util::secp256k1::MessageSignature;
-use stacks_common::util::secp256k1::Secp256k1PublicKey;
-use stacks_common::util::secp256k1::MESSAGE_SIGNATURE_ENCODED_SIZE;
-
-use crate::chainstate::stacks::StacksBlockHeader;
-
-use crate::cost_estimates::FeeRateEstimate;
-use clarity::vm::costs::ExecutionCost;
-use stacks_common::types::chainstate::BlockHeaderHash;
-use stacks_common::types::chainstate::PoxId;
-use stacks_common::types::chainstate::{BurnchainHeaderHash, StacksAddress, StacksBlockId};
-use stacks_common::types::StacksPublicKeyBuffer;
-use stacks_common::util::hash::Sha256Sum;
-
-use crate::net::dns::*;
-use crate::net::http::{HttpContentType, HttpNotFound, HttpServerError};
-pub use crate::net::httpcore::StacksHttp;
-
-use crate::cost_estimates::{metrics::CostMetric, CostEstimator, FeeEstimator};
-
-use crate::core::mempool::{MemPoolDB, MemPoolEventDispatcher};
-use crate::core::StacksEpoch;
-
-use libstackerdb::{
- Error as libstackerdb_error, SlotMetadata, StackerDBChunkAckData, StackerDBChunkData,
-};
/// Implements RPC API
pub mod api;
@@ -153,20 +133,8 @@ pub mod rpc;
pub mod server;
pub mod stackerdb;
-use crate::net::stackerdb::StackerDBConfig;
-use crate::net::stackerdb::StackerDBSync;
-use crate::net::stackerdb::StackerDBSyncResult;
-use crate::net::stackerdb::StackerDBs;
-
pub use crate::net::neighbors::{NeighborComms, PeerNetworkComms};
-
-use crate::chainstate::burn::db::sortdb::SortitionDB;
-use crate::chainstate::stacks::db::StacksChainState;
-use crate::net::p2p::PeerNetwork;
-
-use crate::net::httpcore::{HttpRequestContentsExtensions, StacksHttpRequest, StacksHttpResponse};
-
-use crate::net::http::{Error as HttpErr, HttpRequestContents, HttpRequestPreamble};
+use crate::net::stackerdb::{StackerDBConfig, StackerDBSync, StackerDBSyncResult, StackerDBs};
#[cfg(test)]
pub mod tests;
@@ -1565,30 +1533,40 @@ pub trait Requestable: std::fmt::Display {
#[cfg(test)]
pub mod test {
- use std::fs;
- use std::io;
- use std::io::Cursor;
- use std::io::ErrorKind;
- use std::io::Read;
- use std::io::Write;
+ use std::collections::HashMap;
+ use std::io::{Cursor, ErrorKind, Read, Write};
use std::net::*;
- use std::ops::Deref;
- use std::ops::DerefMut;
+ use std::ops::{Deref, DerefMut};
use std::sync::mpsc::sync_channel;
- use std::thread;
- use std::{collections::HashMap, sync::Mutex};
+ use std::sync::Mutex;
+ use std::{fs, io, thread};
use clarity::vm::ast::ASTRules;
- use mio;
- use rand;
+ use clarity::vm::costs::ExecutionCost;
+ use clarity::vm::database::STXBalance;
+ use clarity::vm::types::*;
+ use clarity::vm::ClarityVersion;
use rand::RngCore;
+ use stacks_common::address::*;
+ use stacks_common::codec::StacksMessageCodec;
+ use stacks_common::deps_common::bitcoin::network::serialize::BitcoinHash;
+ use stacks_common::types::chainstate::TrieHash;
+ use stacks_common::types::StacksEpochId;
+ use stacks_common::util::get_epoch_time_secs;
+ use stacks_common::util::hash::*;
+ use stacks_common::util::secp256k1::*;
+ use stacks_common::util::uint::*;
+ use stacks_common::util::vrf::*;
+ use {mio, rand};
+ use super::*;
use crate::burnchains::bitcoin::address::*;
use crate::burnchains::bitcoin::indexer::BitcoinIndexer;
use crate::burnchains::bitcoin::keys::*;
+ use crate::burnchains::bitcoin::spv::BITCOIN_GENESIS_BLOCK_HASH_REGTEST;
use crate::burnchains::bitcoin::*;
use crate::burnchains::burnchain::*;
- use crate::burnchains::db::BurnchainDB;
+ use crate::burnchains::db::{BurnchainDB, BurnchainHeaderReader};
use crate::burnchains::tests::*;
use crate::burnchains::*;
use crate::chainstate::burn::db::sortdb;
@@ -1598,15 +1576,17 @@ pub mod test {
use crate::chainstate::coordinator::tests::*;
use crate::chainstate::coordinator::*;
use crate::chainstate::stacks::address::PoxAddress;
+ use crate::chainstate::stacks::boot::test::get_parent_tip;
use crate::chainstate::stacks::boot::*;
- use crate::chainstate::stacks::db::StacksChainState;
- use crate::chainstate::stacks::db::*;
+ use crate::chainstate::stacks::db::accounts::MinerReward;
+ use crate::chainstate::stacks::db::{StacksChainState, *};
+ use crate::chainstate::stacks::events::StacksTransactionReceipt;
use crate::chainstate::stacks::miner::*;
use crate::chainstate::stacks::tests::chain_histories::mine_smart_contract_block_contract_call_microblock;
use crate::chainstate::stacks::tests::*;
- use crate::chainstate::stacks::*;
+ use crate::chainstate::stacks::{StacksMicroblockHeader, *};
use crate::chainstate::*;
- use crate::core::NETWORK_P2P_PORT;
+ use crate::core::{StacksEpochExtension, NETWORK_P2P_PORT};
use crate::net::asn::*;
use crate::net::atlas::*;
use crate::net::chat::*;
@@ -1618,35 +1598,8 @@ pub mod test {
use crate::net::poll::*;
use crate::net::relay::*;
use crate::net::Error as net_error;
- use crate::net::RPCHandlerArgs;
- use crate::util_lib::strings::*;
- use clarity::vm::costs::ExecutionCost;
- use clarity::vm::database::STXBalance;
- use clarity::vm::types::*;
- use clarity::vm::ClarityVersion;
- use stacks_common::address::*;
- use stacks_common::address::*;
- use stacks_common::util::get_epoch_time_secs;
- use stacks_common::util::hash::*;
- use stacks_common::util::secp256k1::*;
- use stacks_common::util::uint::*;
- use stacks_common::util::vrf::*;
-
- use stacks_common::deps_common::bitcoin::network::serialize::BitcoinHash;
-
- use super::*;
- use crate::chainstate::stacks::boot::test::get_parent_tip;
- use crate::chainstate::stacks::StacksMicroblockHeader;
- use crate::chainstate::stacks::{db::accounts::MinerReward, events::StacksTransactionReceipt};
- use crate::core::StacksEpochExtension;
use crate::util_lib::boot::boot_code_test_addr;
- use stacks_common::codec::StacksMessageCodec;
- use stacks_common::types::chainstate::TrieHash;
- use stacks_common::types::StacksEpochId;
-
- use crate::burnchains::bitcoin::spv::BITCOIN_GENESIS_BLOCK_HASH_REGTEST;
-
- use crate::burnchains::db::BurnchainHeaderReader;
+ use crate::util_lib::strings::*;
impl StacksMessageCodec for BlockstackOperationType {
fn consensus_serialize(&self, fd: &mut W) -> Result<(), codec_error> {
diff --git a/stackslib/src/net/neighbors/comms.rs b/stackslib/src/net/neighbors/comms.rs
index 92b2a75edb..75ea4c2ab6 100644
--- a/stackslib/src/net/neighbors/comms.rs
+++ b/stackslib/src/net/neighbors/comms.rs
@@ -14,35 +14,28 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
-use crate::core::PEER_VERSION_TESTNET;
+use std::collections::{HashMap, HashSet};
+use std::{cmp, mem};
+use stacks_common::types::chainstate::StacksPublicKey;
+use stacks_common::util::hash::Hash160;
+use stacks_common::util::log;
+use stacks_common::util::secp256k1::Secp256k1PublicKey;
+
+use crate::burnchains::{Address, PublicKey};
+use crate::core::PEER_VERSION_TESTNET;
+use crate::net::connection::{ConnectionOptions, ReplyHandleP2P};
+use crate::net::db::{LocalPeer, PeerDB};
+use crate::net::neighbors::{
+ NeighborWalk, NeighborWalkDB, NeighborWalkResult, MAX_NEIGHBOR_BLOCK_DELAY,
+ NEIGHBOR_MINIMUM_CONTACT_INTERVAL,
+};
+use crate::net::p2p::PeerNetwork;
use crate::net::{
- connection::{ConnectionOptions, ReplyHandleP2P},
- db::{LocalPeer, PeerDB},
- neighbors::{
- NeighborWalk, NeighborWalkDB, NeighborWalkResult, MAX_NEIGHBOR_BLOCK_DELAY,
- NEIGHBOR_MINIMUM_CONTACT_INTERVAL,
- },
- p2p::PeerNetwork,
Error as net_error, HandshakeData, Neighbor, NeighborAddress, NeighborKey, PeerAddress,
StacksMessage, StacksMessageType, NUM_NEIGHBORS,
};
-use stacks_common::util::secp256k1::Secp256k1PublicKey;
-
-use std::cmp;
-use std::mem;
-
-use std::collections::HashMap;
-use std::collections::HashSet;
-
-use crate::burnchains::Address;
-use crate::burnchains::PublicKey;
-
-use stacks_common::types::chainstate::StacksPublicKey;
-use stacks_common::util::hash::Hash160;
-use stacks_common::util::log;
-
/// A trait for representing session state for a set of connected neighbors, for the purposes of executing some P2P
/// algorithm.
pub trait NeighborComms {
diff --git a/stackslib/src/net/neighbors/db.rs b/stackslib/src/net/neighbors/db.rs
index d3afce27a1..fd85f0ce1f 100644
--- a/stackslib/src/net/neighbors/db.rs
+++ b/stackslib/src/net/neighbors/db.rs
@@ -14,35 +14,23 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
-use crate::net::db::PeerDB;
+use std::collections::{HashMap, HashSet};
+use std::{cmp, mem};
+
+use rand::prelude::*;
+use rand::thread_rng;
+use stacks_common::util::hash::Hash160;
+use stacks_common::util::{get_epoch_time_secs, log};
+use crate::burnchains::{Address, Burnchain, BurnchainView};
+use crate::net::db::PeerDB;
+use crate::net::neighbors::{NeighborWalkResult, NEIGHBOR_MINIMUM_CONTACT_INTERVAL, NUM_NEIGHBORS};
+use crate::net::p2p::PeerNetwork;
use crate::net::{
Error as net_error, HandshakeAcceptData, HandshakeData, Neighbor, NeighborAddress, NeighborKey,
Preamble, StackerDBHandshakeData, StacksMessage,
};
-
-use crate::net::neighbors::{NeighborWalkResult, NEIGHBOR_MINIMUM_CONTACT_INTERVAL, NUM_NEIGHBORS};
-
-use crate::net::p2p::PeerNetwork;
-
-use crate::util_lib::db::DBConn;
-use crate::util_lib::db::DBTx;
-
-use std::cmp;
-use std::mem;
-
-use std::collections::HashMap;
-use std::collections::HashSet;
-
-use crate::burnchains::Address;
-use crate::burnchains::Burnchain;
-use crate::burnchains::BurnchainView;
-
-use rand::prelude::*;
-use rand::thread_rng;
-use stacks_common::util::get_epoch_time_secs;
-use stacks_common::util::hash::Hash160;
-use stacks_common::util::log;
+use crate::util_lib::db::{DBConn, DBTx};
/// Capture replacement state
#[derive(Debug, Clone, PartialEq)]
diff --git a/stackslib/src/net/neighbors/mod.rs b/stackslib/src/net/neighbors/mod.rs
index fb276df643..031e9f91a5 100644
--- a/stackslib/src/net/neighbors/mod.rs
+++ b/stackslib/src/net/neighbors/mod.rs
@@ -14,43 +14,22 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
-use crate::net::db::PeerDB;
-use crate::net::Error as net_error;
-use crate::net::Neighbor;
-use crate::net::NeighborKey;
-
-use crate::net::codec::*;
-use crate::net::*;
-
-use crate::net::connection::ConnectionOptions;
-use crate::net::connection::ReplyHandleP2P;
-
-use crate::net::db::LocalPeer;
-
-use crate::net::p2p::PeerNetwork;
-
-use crate::util_lib::db::DBConn;
-use crate::util_lib::db::DBTx;
-use crate::util_lib::db::Error as db_error;
-
-use stacks_common::util::secp256k1::Secp256k1PublicKey;
-
-use std::cmp;
-use std::mem;
+use std::collections::{HashMap, HashSet};
use std::net::SocketAddr;
-
-use std::collections::HashMap;
-use std::collections::HashSet;
-
-use crate::burnchains::Address;
-use crate::burnchains::Burnchain;
-use crate::burnchains::BurnchainView;
-use crate::burnchains::PublicKey;
+use std::{cmp, mem};
use rand::prelude::*;
use rand::thread_rng;
-use stacks_common::util::get_epoch_time_secs;
-use stacks_common::util::log;
+use stacks_common::util::secp256k1::Secp256k1PublicKey;
+use stacks_common::util::{get_epoch_time_secs, log};
+
+use crate::burnchains::{Address, Burnchain, BurnchainView, PublicKey};
+use crate::net::codec::*;
+use crate::net::connection::{ConnectionOptions, ReplyHandleP2P};
+use crate::net::db::{LocalPeer, PeerDB};
+use crate::net::p2p::PeerNetwork;
+use crate::net::{Error as net_error, Neighbor, NeighborKey, PeerAddress, *};
+use crate::util_lib::db::{DBConn, DBTx, Error as db_error};
pub mod comms;
pub mod db;
diff --git a/stackslib/src/net/neighbors/neighbor.rs b/stackslib/src/net/neighbors/neighbor.rs
index 733e0edd8c..a1d513daa2 100644
--- a/stackslib/src/net/neighbors/neighbor.rs
+++ b/stackslib/src/net/neighbors/neighbor.rs
@@ -14,25 +14,20 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
-use crate::net::{db::PeerDB, Error as net_error, Neighbor, NeighborAddress, NeighborKey};
-
-use crate::util_lib::db::{DBConn, DBTx};
-
-use stacks_common::types::chainstate::StacksPublicKey;
-use stacks_common::util::hash::Hash160;
-use stacks_common::util::secp256k1::Secp256k1PublicKey;
-
use std::cmp;
-use crate::burnchains::Address;
-use crate::burnchains::PublicKey;
-
+use clarity::vm::types::QualifiedContractIdentifier;
use rand::prelude::*;
use rand::thread_rng;
-use stacks_common::util::get_epoch_time_secs;
-use stacks_common::util::log;
+use stacks_common::types::chainstate::StacksPublicKey;
+use stacks_common::util::hash::Hash160;
+use stacks_common::util::secp256k1::Secp256k1PublicKey;
+use stacks_common::util::{get_epoch_time_secs, log};
-use clarity::vm::types::QualifiedContractIdentifier;
+use crate::burnchains::{Address, PublicKey};
+use crate::net::db::PeerDB;
+use crate::net::{Error as net_error, Neighbor, NeighborAddress, NeighborKey};
+use crate::util_lib::db::{DBConn, DBTx};
/// Walk-specific helper functions for neighbors
impl Neighbor {
diff --git a/stackslib/src/net/neighbors/walk.rs b/stackslib/src/net/neighbors/walk.rs
index ea31f4b835..5cbda3c774 100644
--- a/stackslib/src/net/neighbors/walk.rs
+++ b/stackslib/src/net/neighbors/walk.rs
@@ -14,46 +14,30 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
-use crate::net::db::PeerDB;
+use std::collections::{HashMap, HashSet};
+use std::{cmp, mem};
+use rand::prelude::*;
+use rand::thread_rng;
+use stacks_common::types::chainstate::StacksPublicKey;
+use stacks_common::util::hash::Hash160;
+use stacks_common::util::secp256k1::Secp256k1PublicKey;
+use stacks_common::util::{get_epoch_time_secs, log};
+
+use crate::burnchains::{Address, Burnchain, BurnchainView, PublicKey};
+use crate::net::connection::{ConnectionOptions, ReplyHandleP2P};
+use crate::net::db::{LocalPeer, PeerDB};
+use crate::net::neighbors::{
+ NeighborComms, NeighborCommsRequest, NeighborReplacements, NeighborWalkDB, ToNeighborKey,
+ MAX_NEIGHBOR_BLOCK_DELAY, NEIGHBOR_MINIMUM_CONTACT_INTERVAL,
+};
+use crate::net::p2p::PeerNetwork;
use crate::net::{
- neighbors::{
- NeighborComms, NeighborReplacements, NeighborWalkDB, ToNeighborKey,
- MAX_NEIGHBOR_BLOCK_DELAY, NEIGHBOR_MINIMUM_CONTACT_INTERVAL,
- },
Error as net_error, HandshakeAcceptData, HandshakeData, MessageSequence, Neighbor,
NeighborAddress, NeighborKey, PeerAddress, Preamble, StackerDBHandshakeData, StacksMessage,
StacksMessageType, NUM_NEIGHBORS,
};
-use crate::net::neighbors::NeighborCommsRequest;
-
-use crate::net::connection::ConnectionOptions;
-use crate::net::connection::ReplyHandleP2P;
-
-use crate::net::db::LocalPeer;
-use crate::net::p2p::PeerNetwork;
-
-use stacks_common::util::secp256k1::Secp256k1PublicKey;
-
-use std::cmp;
-use std::mem;
-
-use std::collections::HashMap;
-use std::collections::HashSet;
-
-use crate::burnchains::Address;
-use crate::burnchains::Burnchain;
-use crate::burnchains::BurnchainView;
-use crate::burnchains::PublicKey;
-
-use rand::prelude::*;
-use rand::thread_rng;
-use stacks_common::types::chainstate::StacksPublicKey;
-use stacks_common::util::get_epoch_time_secs;
-use stacks_common::util::hash::Hash160;
-use stacks_common::util::log;
-
/// This struct records information from an inbound peer that has authenticated to this node. As
/// new remote nodes connect, this node will remember this state for them so that the neighbor walk
/// logic can try to ask them for neighbors. This enables a public peer to ask a NAT'ed peer for
diff --git a/stackslib/src/net/p2p.rs b/stackslib/src/net/p2p.rs
index e0d9528695..0de77c4ff2 100644
--- a/stackslib/src/net/p2p.rs
+++ b/stackslib/src/net/p2p.rs
@@ -14,37 +14,29 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
-use std::cmp;
use std::cmp::Ordering;
-use std::collections::HashMap;
-use std::collections::HashSet;
-use std::collections::VecDeque;
-use std::mem;
-use std::net::IpAddr;
-use std::net::Ipv4Addr;
-use std::net::Ipv6Addr;
-use std::net::SocketAddr;
-use std::sync::mpsc::sync_channel;
-use std::sync::mpsc::Receiver;
-use std::sync::mpsc::RecvError;
-use std::sync::mpsc::SendError;
-use std::sync::mpsc::SyncSender;
-use std::sync::mpsc::TryRecvError;
-use std::sync::mpsc::TrySendError;
-
-use mio;
+use std::collections::{HashMap, HashSet, VecDeque};
+use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr};
+use std::sync::mpsc::{
+ sync_channel, Receiver, RecvError, SendError, SyncSender, TryRecvError, TrySendError,
+};
+use std::{cmp, mem};
+
+use clarity::vm::ast::ASTRules;
+use clarity::vm::database::BurnStateDB;
+use clarity::vm::types::QualifiedContractIdentifier;
use mio::net as mio_net;
use rand::prelude::*;
use rand::thread_rng;
+use stacks_common::types::chainstate::{PoxId, SortitionId};
+use stacks_common::types::net::{PeerAddress, PeerHost};
+use stacks_common::util::hash::to_hex;
+use stacks_common::util::secp256k1::Secp256k1PublicKey;
+use stacks_common::util::{get_epoch_time_ms, get_epoch_time_secs, log};
+use {mio, url};
-use url;
-
-use crate::burnchains::db::BurnchainDB;
-use crate::burnchains::db::BurnchainHeaderReader;
-use crate::burnchains::Address;
-use crate::burnchains::Burnchain;
-use crate::burnchains::BurnchainView;
-use crate::burnchains::PublicKey;
+use crate::burnchains::db::{BurnchainDB, BurnchainHeaderReader};
+use crate::burnchains::{Address, Burnchain, BurnchainView, PublicKey};
use crate::chainstate::burn::db::sortdb::{BlockHeaderCache, SortitionDB};
use crate::chainstate::burn::BlockSnapshot;
use crate::chainstate::coordinator::{
@@ -52,55 +44,25 @@ use crate::chainstate::coordinator::{
static_get_stacks_tip_affirmation_map,
};
use crate::chainstate::stacks::db::StacksChainState;
-use crate::chainstate::stacks::{MAX_BLOCK_LEN, MAX_TRANSACTION_LEN};
-use crate::core::mempool::{MemPoolDB, MemPoolEventDispatcher};
+use crate::chainstate::stacks::{StacksBlockHeader, MAX_BLOCK_LEN, MAX_TRANSACTION_LEN};
use crate::monitoring::{update_inbound_neighbors, update_outbound_neighbors};
use crate::net::asn::ASEntry4;
-use crate::net::atlas::AtlasDB;
-use crate::net::atlas::{AttachmentInstance, AttachmentsDownloader};
-use crate::net::chat::ConversationP2P;
-use crate::net::chat::NeighborStats;
-use crate::net::connection::ConnectionOptions;
-use crate::net::connection::NetworkReplyHandle;
-use crate::net::connection::ReplyHandleP2P;
-use crate::net::db::LocalPeer;
-use crate::net::db::PeerDB;
+use crate::net::atlas::{AtlasDB, AttachmentInstance, AttachmentsDownloader};
+use crate::net::chat::{ConversationP2P, NeighborStats};
+use crate::net::connection::{ConnectionOptions, NetworkReplyHandle, ReplyHandleP2P};
+use crate::net::db::{LocalPeer, PeerDB};
use crate::net::download::BlockDownloader;
+use crate::net::http::HttpRequestContents;
+use crate::net::httpcore::StacksHttpRequest;
use crate::net::inv::*;
use crate::net::neighbors::*;
-use crate::net::poll::NetworkPollState;
-use crate::net::poll::NetworkState;
+use crate::net::poll::{NetworkPollState, NetworkState};
use crate::net::prune::*;
-use crate::net::relay::RelayerStats;
-use crate::net::relay::*;
+use crate::net::relay::{RelayerStats, *, *};
use crate::net::server::*;
use crate::net::stackerdb::{StackerDBConfig, StackerDBSync, StackerDBTx, StackerDBs};
-use crate::net::Error as net_error;
-use crate::net::Neighbor;
-use crate::net::NeighborKey;
-use crate::net::RPCHandlerArgs;
-use crate::net::*;
-use crate::util_lib::db::DBConn;
-use crate::util_lib::db::DBTx;
-use crate::util_lib::db::Error as db_error;
-use clarity::vm::database::BurnStateDB;
-use stacks_common::types::net::PeerAddress;
-use stacks_common::types::net::PeerHost;
-use stacks_common::util::get_epoch_time_ms;
-use stacks_common::util::get_epoch_time_secs;
-use stacks_common::util::hash::to_hex;
-use stacks_common::util::log;
-use stacks_common::util::secp256k1::Secp256k1PublicKey;
-
-use crate::chainstate::stacks::StacksBlockHeader;
-use stacks_common::types::chainstate::{PoxId, SortitionId};
-
-use clarity::vm::ast::ASTRules;
-use clarity::vm::types::QualifiedContractIdentifier;
-
-use crate::net::httpcore::StacksHttpRequest;
-
-use crate::net::http::HttpRequestContents;
+use crate::net::{Error as net_error, Neighbor, NeighborKey, RPCHandlerArgs, *};
+use crate::util_lib::db::{DBConn, DBTx, Error as db_error};
/// inter-thread request to send a p2p message from another thread in this program.
#[derive(Debug)]
@@ -5778,12 +5740,18 @@ impl PeerNetwork {
#[cfg(test)]
mod test {
- use std::thread;
- use std::time;
+ use std::{thread, time};
+ use clarity::vm::ast::stack_depth_checker::AST_CALL_STACK_DEPTH_BUFFER;
+ use clarity::vm::types::StacksAddressExtensions;
+ use clarity::vm::MAX_CALL_STACK_DEPTH;
use rand;
use rand::RngCore;
+ use stacks_common::types::chainstate::BurnchainHeaderHash;
+ use stacks_common::util::secp256k1::Secp256k1PrivateKey;
+ use stacks_common::util::{log, sleep_ms};
+ use super::*;
use crate::burnchains::burnchain::*;
use crate::burnchains::*;
use crate::chainstate::stacks::test::*;
@@ -5796,16 +5764,6 @@ mod test {
use crate::net::test::*;
use crate::net::*;
use crate::util_lib::test::*;
- use clarity::vm::types::StacksAddressExtensions;
- use stacks_common::types::chainstate::BurnchainHeaderHash;
- use stacks_common::util::log;
- use stacks_common::util::secp256k1::Secp256k1PrivateKey;
- use stacks_common::util::sleep_ms;
-
- use clarity::vm::ast::stack_depth_checker::AST_CALL_STACK_DEPTH_BUFFER;
- use clarity::vm::MAX_CALL_STACK_DEPTH;
-
- use super::*;
fn make_random_peer_address() -> PeerAddress {
let mut rng = rand::thread_rng();
diff --git a/stackslib/src/net/poll.rs b/stackslib/src/net/poll.rs
index 00ee4095de..5941741bc1 100644
--- a/stackslib/src/net/poll.rs
+++ b/stackslib/src/net/poll.rs
@@ -14,38 +14,20 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
-use crate::net::Error as net_error;
-use crate::net::Neighbor;
-use crate::net::NeighborKey;
-
-use crate::util_lib::db::DBConn;
-use crate::util_lib::db::Error as db_error;
-
-use std::collections::HashMap;
-use std::collections::HashSet;
-use std::io;
-use std::io::Error as io_error;
-use std::io::ErrorKind;
-use std::io::Read;
-use std::io::Write;
-use std::net;
-use std::net::SocketAddr;
-use std::time;
+use std::collections::{HashMap, HashSet};
+use std::io::{Error as io_error, ErrorKind, Read, Write};
+use std::net::{Shutdown, SocketAddr};
use std::time::Duration;
+use std::{io, net, time};
-use stacks_common::util::log;
-use stacks_common::util::sleep_ms;
-
-use mio;
-use mio::net as mio_net;
-use mio::PollOpt;
-use mio::Ready;
-use mio::Token;
-
-use std::net::Shutdown;
-
-use rand;
+use mio::{net as mio_net, PollOpt, Ready, Token};
use rand::RngCore;
+use stacks_common::types::net::PeerAddress;
+use stacks_common::util::{log, sleep_ms};
+use {mio, rand};
+
+use crate::net::{Error as net_error, Neighbor, NeighborKey};
+use crate::util_lib::db::{DBConn, Error as db_error};
const SERVER: Token = mio::Token(0);
@@ -497,14 +479,12 @@ impl NetworkState {
#[cfg(test)]
mod test {
- use super::*;
+ use std::collections::HashSet;
+
use mio;
- use mio::net as mio_net;
- use mio::PollOpt;
- use mio::Ready;
- use mio::Token;
+ use mio::{net as mio_net, PollOpt, Ready, Token};
- use std::collections::HashSet;
+ use super::*;
#[test]
fn test_bind() {
diff --git a/stackslib/src/net/prune.rs b/stackslib/src/net/prune.rs
index 214bfe2582..b2b7ff6c32 100644
--- a/stackslib/src/net/prune.rs
+++ b/stackslib/src/net/prune.rs
@@ -14,40 +14,25 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
-use crate::net::p2p::*;
-/// This module contains the logic for pruning client and neighbor connections
-use crate::net::*;
-
-use crate::net::Error as net_error;
-
-use crate::net::connection::ConnectionOptions;
-
-use crate::net::chat::NeighborStats;
-
-use crate::net::poll::NetworkPollState;
-use crate::net::poll::NetworkState;
-
-use crate::net::db::LocalPeer;
-use crate::net::db::PeerDB;
-
-use crate::net::neighbors::*;
-
-use crate::util_lib::db::DBConn;
-use crate::util_lib::db::Error as db_error;
-
-use std::net::Shutdown;
-use std::net::SocketAddr;
-
use std::cmp::Ordering;
-use std::collections::HashMap;
-use std::collections::HashSet;
-use std::collections::VecDeque;
-
-use stacks_common::util::get_epoch_time_secs;
-use stacks_common::util::log;
+use std::collections::{HashMap, HashSet, VecDeque};
+use std::net::{Shutdown, SocketAddr};
use rand::prelude::*;
use rand::thread_rng;
+use stacks_common::types::net::PeerAddress;
+use stacks_common::util::{get_epoch_time_secs, log};
+
+use crate::net::chat::NeighborStats;
+use crate::net::connection::ConnectionOptions;
+use crate::net::db::{LocalPeer, PeerDB};
+use crate::net::neighbors::*;
+use crate::net::p2p::*;
+use crate::net::poll::{NetworkPollState, NetworkState};
+use crate::net::Error as net_error;
+/// This module contains the logic for pruning client and neighbor connections
+use crate::net::*;
+use crate::util_lib::db::{DBConn, Error as db_error};
impl PeerNetwork {
/// Find out which organizations have which of our outbound neighbors.
diff --git a/stackslib/src/net/relay.rs b/stackslib/src/net/relay.rs
index 194ffa9c75..eda4a543b9 100644
--- a/stackslib/src/net/relay.rs
+++ b/stackslib/src/net/relay.rs
@@ -14,58 +14,46 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
-use std::cmp;
-use std::collections::BTreeMap;
-use std::collections::HashMap;
-use std::collections::HashSet;
-use std::collections::VecDeque;
-use std::mem;
+use std::collections::{BTreeMap, HashMap, HashSet, VecDeque};
+use std::{cmp, mem};
+use clarity::vm::ast::errors::{ParseError, ParseErrors};
+use clarity::vm::ast::{ast_check_size, ASTRules};
+use clarity::vm::costs::ExecutionCost;
+use clarity::vm::errors::RuntimeErrorType;
+use clarity::vm::types::{QualifiedContractIdentifier, StacksAddressExtensions};
+use clarity::vm::ClarityVersion;
use rand::prelude::*;
-use rand::thread_rng;
-use rand::Rng;
+use rand::{thread_rng, Rng};
+use stacks_common::codec::MAX_PAYLOAD_LEN;
+use stacks_common::types::chainstate::{BurnchainHeaderHash, PoxId, SortitionId, StacksBlockId};
+use stacks_common::types::StacksEpochId;
+use stacks_common::util::get_epoch_time_secs;
+use stacks_common::util::hash::Sha512Trunc256Sum;
-use crate::burnchains::Burnchain;
-use crate::burnchains::BurnchainView;
+use crate::burnchains::{Burnchain, BurnchainView};
use crate::chainstate::burn::db::sortdb::{SortitionDB, SortitionDBConn, SortitionHandleConn};
-use crate::chainstate::burn::BlockSnapshot;
-use crate::chainstate::burn::ConsensusHash;
+use crate::chainstate::burn::{BlockSnapshot, ConsensusHash};
use crate::chainstate::coordinator::comm::CoordinatorChannels;
+use crate::chainstate::coordinator::BlockEventDispatcher;
+use crate::chainstate::stacks::db::unconfirmed::ProcessedUnconfirmedState;
use crate::chainstate::stacks::db::{StacksChainState, StacksEpochReceipt, StacksHeaderInfo};
use crate::chainstate::stacks::events::StacksTransactionReceipt;
-use crate::chainstate::stacks::StacksBlockHeader;
-use crate::chainstate::stacks::TransactionPayload;
+use crate::chainstate::stacks::{StacksBlockHeader, TransactionPayload};
use crate::clarity_vm::clarity::Error as clarity_error;
-use crate::core::mempool::MemPoolDB;
-use crate::core::mempool::*;
+use crate::core::mempool::{MemPoolDB, *};
+use crate::monitoring::update_stacks_tip_height;
use crate::net::chat::*;
use crate::net::connection::*;
use crate::net::db::*;
+use crate::net::httpcore::*;
use crate::net::p2p::*;
use crate::net::poll::*;
use crate::net::rpc::*;
use crate::net::stackerdb::{
StackerDBConfig, StackerDBEventDispatcher, StackerDBSyncResult, StackerDBs,
};
-use crate::net::Error as net_error;
-use crate::net::*;
-use clarity::vm::ast::errors::{ParseError, ParseErrors};
-use clarity::vm::ast::{ast_check_size, ASTRules};
-use clarity::vm::costs::ExecutionCost;
-use clarity::vm::errors::RuntimeErrorType;
-use clarity::vm::types::{QualifiedContractIdentifier, StacksAddressExtensions};
-use clarity::vm::ClarityVersion;
-use stacks_common::types::chainstate::StacksBlockId;
-use stacks_common::util::get_epoch_time_secs;
-use stacks_common::util::hash::Sha512Trunc256Sum;
-
-use crate::chainstate::coordinator::BlockEventDispatcher;
-use crate::chainstate::stacks::db::unconfirmed::ProcessedUnconfirmedState;
-use crate::monitoring::update_stacks_tip_height;
-use stacks_common::codec::MAX_PAYLOAD_LEN;
-use stacks_common::types::chainstate::BurnchainHeaderHash;
-use stacks_common::types::chainstate::{PoxId, SortitionId};
-use stacks_common::types::StacksEpochId;
+use crate::net::{Error as net_error, *};
pub type BlocksAvailableMap = HashMap;
@@ -2457,55 +2445,45 @@ pub mod test {
use std::cell::RefCell;
use std::collections::HashMap;
+ use clarity::vm::ast::stack_depth_checker::AST_CALL_STACK_DEPTH_BUFFER;
+ use clarity::vm::ast::ASTRules;
+ use clarity::vm::costs::LimitedCostTracker;
+ use clarity::vm::database::ClarityDatabase;
+ use clarity::vm::types::QualifiedContractIdentifier;
+ use clarity::vm::{ClarityVersion, MAX_CALL_STACK_DEPTH};
+ use stacks_common::address::AddressHashMode;
+ use stacks_common::types::chainstate::{
+ BlockHeaderHash, StacksBlockId, StacksWorkScore, TrieHash,
+ };
+ use stacks_common::types::Address;
+ use stacks_common::util::hash::MerkleTree;
+ use stacks_common::util::sleep_ms;
+ use stacks_common::util::vrf::VRFProof;
+
+ use super::*;
use crate::burnchains::tests::TestMiner;
- use crate::chainstate::stacks::db::blocks::MINIMUM_TX_FEE;
- use crate::chainstate::stacks::db::blocks::MINIMUM_TX_FEE_RATE_PER_BYTE;
- use crate::chainstate::stacks::Error as ChainstateError;
- use crate::chainstate::stacks::*;
+ use crate::chainstate::stacks::db::blocks::{MINIMUM_TX_FEE, MINIMUM_TX_FEE_RATE_PER_BYTE};
+ use crate::chainstate::stacks::miner::{BlockBuilderSettings, StacksMicroblockBuilder};
+ use crate::chainstate::stacks::test::codec_all_transactions;
+ use crate::chainstate::stacks::tests::{
+ make_coinbase, make_coinbase_with_nonce, make_smart_contract_with_version,
+ make_user_stacks_transfer,
+ };
+ use crate::chainstate::stacks::{Error as ChainstateError, *};
+ use crate::clarity_vm::clarity::ClarityConnection;
+ use crate::core::*;
+ use crate::net::api::getinfo::RPCPeerInfoData;
use crate::net::asn::*;
use crate::net::chat::*;
use crate::net::codec::*;
use crate::net::download::test::run_get_blocks_and_microblocks;
use crate::net::download::*;
use crate::net::http::{HttpRequestContents, HttpRequestPreamble};
+ use crate::net::httpcore::StacksHttpMessage;
use crate::net::inv::*;
use crate::net::test::*;
use crate::net::*;
use crate::util_lib::test::*;
- use clarity::vm::costs::LimitedCostTracker;
- use clarity::vm::database::ClarityDatabase;
- use stacks_common::util::sleep_ms;
- use stacks_common::util::vrf::VRFProof;
-
- use super::*;
- use crate::clarity_vm::clarity::ClarityConnection;
- use crate::core::*;
- use clarity::vm::types::QualifiedContractIdentifier;
- use clarity::vm::ClarityVersion;
- use stacks_common::types::chainstate::BlockHeaderHash;
-
- use clarity::vm::ast::stack_depth_checker::AST_CALL_STACK_DEPTH_BUFFER;
- use clarity::vm::ast::ASTRules;
- use clarity::vm::MAX_CALL_STACK_DEPTH;
-
- use crate::chainstate::stacks::miner::BlockBuilderSettings;
- use crate::chainstate::stacks::miner::StacksMicroblockBuilder;
- use crate::chainstate::stacks::test::codec_all_transactions;
- use crate::chainstate::stacks::tests::make_coinbase;
- use crate::chainstate::stacks::tests::make_coinbase_with_nonce;
- use crate::chainstate::stacks::tests::make_smart_contract_with_version;
- use crate::chainstate::stacks::tests::make_user_stacks_transfer;
- use crate::core::*;
- use stacks_common::address::AddressHashMode;
- use stacks_common::types::chainstate::StacksBlockId;
- use stacks_common::types::chainstate::StacksWorkScore;
- use stacks_common::types::chainstate::TrieHash;
- use stacks_common::types::Address;
- use stacks_common::util::hash::MerkleTree;
-
- use crate::net::api::getinfo::RPCPeerInfoData;
-
- use crate::net::httpcore::StacksHttpMessage;
#[test]
fn test_relayer_stats_add_relyed_messages() {
diff --git a/stackslib/src/net/rpc.rs b/stackslib/src/net/rpc.rs
index e64a60cc84..f66e26a71a 100644
--- a/stackslib/src/net/rpc.rs
+++ b/stackslib/src/net/rpc.rs
@@ -14,128 +14,72 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
-use std::collections::HashMap;
-use std::collections::HashSet;
-use std::collections::VecDeque;
-use std::io;
+use std::collections::{HashMap, HashSet, VecDeque};
+use std::convert::TryFrom;
use std::io::prelude::*;
use std::io::{Read, Seek, SeekFrom, Write};
use std::net::SocketAddr;
use std::time::Instant;
-use std::{convert::TryFrom, fmt};
-
+use std::{fmt, io};
+
+use clarity::vm::analysis::errors::CheckErrors;
+use clarity::vm::ast::ASTRules;
+use clarity::vm::costs::{ExecutionCost, LimitedCostTracker};
+use clarity::vm::database::clarity_store::{make_contract_hash_key, ContractCommitment};
+use clarity::vm::database::{
+ BurnStateDB, ClarityDatabase, ClaritySerializable, STXBalance, StoreType,
+};
+use clarity::vm::errors::Error::Unchecked;
+use clarity::vm::errors::{Error as ClarityRuntimeError, InterpreterError};
+use clarity::vm::types::{
+ PrincipalData, QualifiedContractIdentifier, StandardPrincipalData, TraitIdentifier,
+};
+use clarity::vm::{ClarityName, ClarityVersion, ContractName, SymbolicExpression, Value};
+use libstackerdb::{StackerDBChunkAckData, StackerDBChunkData};
use rand::prelude::*;
use rand::thread_rng;
use rusqlite::{DatabaseName, NO_PARAMS};
+use stacks_common::codec::StacksMessageCodec;
+use stacks_common::types::chainstate::{
+ BlockHeaderHash, BurnchainHeaderHash, StacksAddress, StacksBlockId,
+};
+use stacks_common::types::net::{PeerAddress, PeerHost};
+use stacks_common::types::StacksPublicKeyBuffer;
+use stacks_common::util::chunked_encoding::*;
+use stacks_common::util::get_epoch_time_secs;
+use stacks_common::util::hash::{hex_bytes, to_hex, Hash160, Sha256Sum};
+use stacks_common::util::secp256k1::MessageSignature;
+use stacks_common::{types, util};
use crate::burnchains::affirmation::AffirmationMap;
-use crate::burnchains::Burnchain;
-use crate::burnchains::BurnchainView;
-use crate::burnchains::*;
+use crate::burnchains::{Burnchain, BurnchainView, *};
use crate::chainstate::burn::db::sortdb::SortitionDB;
+use crate::chainstate::burn::operations::leader_block_commit::OUTPUTS_PER_COMMIT;
use crate::chainstate::burn::ConsensusHash;
-use crate::chainstate::stacks::db::blocks::CheckError;
-use crate::chainstate::stacks::db::{blocks::MINIMUM_TX_FEE_RATE_PER_BYTE, StacksChainState};
-use crate::chainstate::stacks::Error as chain_error;
-use crate::chainstate::stacks::*;
-use crate::clarity_vm::clarity::ClarityConnection;
+use crate::chainstate::stacks::boot::{POX_1_NAME, POX_2_NAME, POX_3_NAME};
+use crate::chainstate::stacks::db::blocks::{CheckError, MINIMUM_TX_FEE_RATE_PER_BYTE};
+use crate::chainstate::stacks::db::StacksChainState;
+use crate::chainstate::stacks::{Error as chain_error, StacksBlockHeader, *};
+use crate::clarity_vm::clarity::{ClarityConnection, Error as clarity_error};
+use crate::clarity_vm::database::marf::MarfedKV;
use crate::core::mempool::*;
use crate::cost_estimates::metrics::CostMetric;
-use crate::cost_estimates::CostEstimator;
-use crate::cost_estimates::FeeEstimator;
-use crate::monitoring;
+use crate::cost_estimates::{CostEstimator, FeeEstimator};
use crate::net::atlas::{AtlasDB, Attachment, MAX_ATTACHMENT_INV_PAGES_PER_REQUEST};
-use crate::net::connection::ConnectionHttp;
-use crate::net::connection::ConnectionOptions;
-use crate::net::connection::ReplyHandleHttp;
+use crate::net::connection::{ConnectionHttp, ConnectionOptions, ReplyHandleHttp};
use crate::net::db::PeerDB;
-
use crate::net::http::{HttpRequestContents, HttpResponseContents};
-use crate::net::PeerHostExtensions;
-use crate::net::StacksNodeState;
-
use crate::net::httpcore::{
- HttpPreambleExtensions, HttpRequestContentsExtensions, StacksHttp, StacksHttpMessage,
- StacksHttpRequest, StacksHttpResponse, TipRequest, HTTP_REQUEST_ID_RESERVED,
-};
-
-use crate::core::mempool::MemPoolSyncData;
-use crate::net::api::{
- callreadonly::CallReadOnlyRequestBody, callreadonly::CallReadOnlyResponse,
- getaccount::AccountEntryResponse, getconstantval::ConstantValResponse,
- getcontractsrc::ContractSrcResponse, getdatavar::DataVarResponse, getinfo::RPCAffirmationData,
- getinfo::RPCLastPoxAnchorData, getinfo::RPCPeerInfoData,
- getistraitimplemented::GetIsTraitImplementedResponse, getmapentry::MapEntryResponse,
- getpoxinfo::RPCPoxContractVersion, getpoxinfo::RPCPoxInfoData,
- gettransaction_unconfirmed::UnconfirmedTransactionResponse,
- gettransaction_unconfirmed::UnconfirmedTransactionStatus, postfeerate::RPCFeeEstimate,
- postfeerate::RPCFeeEstimateResponse,
+ StacksHttp, StacksHttpMessage, StacksHttpRequest, StacksHttpResponse, HTTP_REQUEST_ID_RESERVED,
};
-use crate::net::atlas::{AttachmentPage, GetAttachmentResponse, GetAttachmentsInvResponse};
-use crate::net::p2p::PeerMap;
-use crate::net::p2p::PeerNetwork;
+use crate::net::p2p::{PeerMap, PeerNetwork};
use crate::net::relay::Relayer;
-use crate::net::stackerdb::StackerDBTx;
-use crate::net::stackerdb::StackerDBs;
-use crate::net::BlocksData;
-use crate::net::BlocksDatum;
-use crate::net::Error as net_error;
-use crate::net::MicroblocksData;
-use crate::net::NeighborAddress;
-use crate::net::NeighborsData;
-use crate::net::ProtocolFamily;
-use crate::net::StackerDBPushChunkData;
-use crate::net::StacksMessageType;
-use crate::net::UrlString;
-use crate::net::MAX_HEADERS;
-use crate::net::MAX_NEIGHBORS_DATA_LEN;
-use crate::util_lib::db::DBConn;
-use crate::util_lib::db::Error as db_error;
-use clarity::vm::database::clarity_store::make_contract_hash_key;
-use clarity::vm::types::TraitIdentifier;
-use clarity::vm::ClarityVersion;
-use clarity::vm::{
- analysis::errors::CheckErrors,
- ast::ASTRules,
- costs::{ExecutionCost, LimitedCostTracker},
- database::{
- clarity_store::ContractCommitment, BurnStateDB, ClarityDatabase, ClaritySerializable,
- STXBalance, StoreType,
- },
- errors::Error as ClarityRuntimeError,
- errors::Error::Unchecked,
- errors::InterpreterError,
- types::{PrincipalData, QualifiedContractIdentifier, StandardPrincipalData},
- ClarityName, ContractName, SymbolicExpression, Value,
-};
-use libstackerdb::{StackerDBChunkAckData, StackerDBChunkData};
-use stacks_common::codec::StacksMessageCodec;
-use stacks_common::util::get_epoch_time_secs;
-use stacks_common::util::hash::Hash160;
-use stacks_common::util::hash::{hex_bytes, to_hex};
-
-use crate::chainstate::stacks::boot::{POX_1_NAME, POX_2_NAME, POX_3_NAME};
-use crate::chainstate::stacks::StacksBlockHeader;
-use crate::clarity_vm::database::marf::MarfedKV;
-use stacks_common::types::chainstate::BlockHeaderHash;
-use stacks_common::types::chainstate::{BurnchainHeaderHash, StacksAddress, StacksBlockId};
-use stacks_common::types::net::{PeerAddress, PeerHost};
-use stacks_common::types::StacksPublicKeyBuffer;
-use stacks_common::util::chunked_encoding::*;
-use stacks_common::util::secp256k1::MessageSignature;
-
-use crate::clarity_vm::clarity::Error as clarity_error;
-
-use crate::{
- chainstate::burn::operations::leader_block_commit::OUTPUTS_PER_COMMIT, version_string,
-};
-use stacks_common::types;
-use stacks_common::util;
-use stacks_common::util::hash::Sha256Sum;
-
+use crate::net::stackerdb::{StackerDBTx, StackerDBs};
+use crate::net::{Error as net_error, StacksMessageType, StacksNodeState};
use crate::util_lib::boot::boot_code_id;
-
-use crate::net::api::{getpoxinfo::RPCPoxCurrentCycleInfo, getpoxinfo::RPCPoxNextCycleInfo};
+use crate::util_lib::db::{DBConn, Error as db_error};
+use crate::util_lib::strings::UrlString;
+use crate::{monitoring, version_string};
pub const STREAM_CHUNK_SIZE: u64 = 4096;
diff --git a/stackslib/src/net/server.rs b/stackslib/src/net/server.rs
index 58e55760aa..e93819e34e 100644
--- a/stackslib/src/net/server.rs
+++ b/stackslib/src/net/server.rs
@@ -14,40 +14,28 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
-use std::io::Error as io_error;
-use std::io::ErrorKind;
-use std::io::{Read, Write};
-
-use std::collections::HashMap;
-use std::collections::VecDeque;
-
-use std::net::SocketAddr;
-
-use std::sync::mpsc::sync_channel;
-use std::sync::mpsc::Receiver;
-use std::sync::mpsc::RecvError;
-use std::sync::mpsc::SendError;
-use std::sync::mpsc::SyncSender;
-use std::sync::mpsc::TryRecvError;
-
-use crate::net::connection::ConnectionOptions;
-use crate::net::httpcore::{StacksHttpRequest, StacksHttpResponse};
-use crate::net::p2p::PeerNetwork;
-use crate::net::poll::{NetworkPollState, NetworkState};
-use crate::net::rpc::ConversationHttp;
-use crate::net::Error as net_error;
-use crate::net::{NeighborKey, PeerHostExtensions, StacksMessageType, StacksNodeState, UrlString};
-
-use crate::net::http::HttpBadRequest;
-
-use crate::chainstate::stacks::db::StacksChainState;
-use crate::core::mempool::MemPoolDB;
+use std::collections::{HashMap, VecDeque};
+use std::io::{Error as io_error, ErrorKind, Read, Write};
+use std::sync::mpsc::{sync_channel, Receiver, RecvError, SendError, SyncSender, TryRecvError};
use mio::net as mio_net;
-
use stacks_common::types::net::{PeerAddress, PeerHost};
use stacks_common::util::get_epoch_time_secs;
+use crate::burnchains::{Burnchain, BurnchainView};
+use crate::chainstate::burn::db::sortdb::SortitionDB;
+use crate::chainstate::stacks::db::StacksChainState;
+use crate::core::mempool::*;
+use crate::net::atlas::AtlasDB;
+use crate::net::connection::*;
+use crate::net::db::*;
+use crate::net::http::*;
+use crate::net::httpcore::*;
+use crate::net::p2p::{PeerMap, PeerNetwork};
+use crate::net::poll::*;
+use crate::net::rpc::*;
+use crate::net::{Error as net_error, *};
+
#[derive(Debug)]
pub struct HttpPeer {
/// ongoing http conversations (either they reached out to us, or we to them)
@@ -678,50 +666,32 @@ impl HttpPeer {
#[cfg(test)]
mod test {
- use super::*;
- use crate::net::codec::*;
- use crate::net::httpcore::*;
- use crate::net::rpc::*;
- use crate::net::test::*;
- use crate::net::*;
use std::cell::RefCell;
-
- use crate::burnchains::Burnchain;
- use crate::burnchains::BurnchainView;
- use stacks_common::types::chainstate::BurnchainHeaderHash;
-
- use crate::burnchains::*;
- use crate::chainstate::stacks::db::blocks::test::*;
- use crate::chainstate::stacks::db::StacksChainState;
- use crate::chainstate::stacks::test::*;
- use crate::chainstate::stacks::Error as chain_error;
- use crate::chainstate::stacks::*;
- use crate::chainstate::stacks::*;
- use stacks_common::types::chainstate::BlockHeaderHash;
-
- use std::sync::mpsc::sync_channel;
- use std::sync::mpsc::Receiver;
- use std::sync::mpsc::RecvError;
- use std::sync::mpsc::SendError;
- use std::sync::mpsc::SyncSender;
- use std::sync::mpsc::TryRecvError;
-
+ use std::net::{SocketAddr, TcpStream};
+ use std::sync::mpsc::{sync_channel, Receiver, RecvError, SendError, SyncSender, TryRecvError};
use std::thread;
- use std::net::SocketAddr;
- use std::net::TcpStream;
-
- use stacks_common::util::get_epoch_time_secs;
- use stacks_common::util::pipe::*;
- use stacks_common::util::sleep_ms;
-
- use crate::chainstate::burn::ConsensusHash;
- use crate::chainstate::stacks::StacksBlockHeader;
use clarity::vm::contracts::Contract;
- use clarity::vm::representations::ClarityName;
- use clarity::vm::representations::ContractName;
+ use clarity::vm::representations::{ClarityName, ContractName};
use clarity::vm::types::*;
use stacks_common::codec::MAX_MESSAGE_LEN;
+ use stacks_common::types::chainstate::{BlockHeaderHash, BurnchainHeaderHash};
+ use stacks_common::util::pipe::*;
+ use stacks_common::util::{get_epoch_time_secs, sleep_ms};
+
+ use super::*;
+ use crate::burnchains::{Burnchain, BurnchainView, *};
+ use crate::chainstate::burn::ConsensusHash;
+ use crate::chainstate::stacks::db::blocks::test::*;
+ use crate::chainstate::stacks::db::StacksChainState;
+ use crate::chainstate::stacks::test::*;
+ use crate::chainstate::stacks::{Error as chain_error, StacksBlockHeader, *, *};
+ use crate::net::codec::*;
+ use crate::net::http::*;
+ use crate::net::httpcore::*;
+ use crate::net::rpc::*;
+ use crate::net::test::*;
+ use crate::net::*;
fn test_http_server(
test_name: &str,
diff --git a/stackslib/src/net/stackerdb/config.rs b/stackslib/src/net/stackerdb/config.rs
index 07329ae01b..376f57b141 100644
--- a/stackslib/src/net/stackerdb/config.rs
+++ b/stackslib/src/net/stackerdb/config.rs
@@ -37,34 +37,29 @@
use std::collections::{HashMap, HashSet};
use std::mem;
-use crate::net::stackerdb::{
- StackerDBConfig, StackerDBs, STACKERDB_INV_MAX, STACKERDB_MAX_CHUNK_SIZE,
-};
-
-use crate::net::Error as net_error;
-use crate::net::NeighborAddress;
-
-use crate::chainstate::burn::db::sortdb::SortitionDB;
-use crate::chainstate::stacks::db::StacksChainState;
-use crate::chainstate::stacks::Error as chainstate_error;
-
-use crate::clarity_vm::clarity::{ClarityReadOnlyConnection, Error as clarity_error};
use clarity::vm::analysis::ContractAnalysis;
use clarity::vm::clarity::ClarityConnection;
use clarity::vm::database::BurnStateDB;
-use clarity::vm::types::QualifiedContractIdentifier;
-use clarity::vm::types::StandardPrincipalData;
use clarity::vm::types::{
- BufferLength, FixedFunction, FunctionType, ListTypeData, PrincipalData, SequenceSubtype,
- TupleTypeSignature, TypeSignature,
+ BufferLength, FixedFunction, FunctionType, ListTypeData, PrincipalData,
+ QualifiedContractIdentifier, SequenceSubtype, StandardPrincipalData, TupleTypeSignature,
+ TypeSignature,
};
use clarity::vm::ClarityName;
-
use stacks_common::types::chainstate::{StacksAddress, StacksBlockId};
use stacks_common::types::net::PeerAddress;
use stacks_common::types::StacksEpochId;
use stacks_common::util::hash::Hash160;
+use crate::chainstate::burn::db::sortdb::SortitionDB;
+use crate::chainstate::stacks::db::StacksChainState;
+use crate::chainstate::stacks::Error as chainstate_error;
+use crate::clarity_vm::clarity::{ClarityReadOnlyConnection, Error as clarity_error};
+use crate::net::stackerdb::{
+ StackerDBConfig, StackerDBs, STACKERDB_INV_MAX, STACKERDB_MAX_CHUNK_SIZE,
+};
+use crate::net::{Error as net_error, NeighborAddress};
+
const MAX_HINT_REPLICAS: u32 = 128;
lazy_static! {
diff --git a/stackslib/src/net/stackerdb/db.rs b/stackslib/src/net/stackerdb/db.rs
index 4b4232f676..6034f3d059 100644
--- a/stackslib/src/net/stackerdb/db.rs
+++ b/stackslib/src/net/stackerdb/db.rs
@@ -14,38 +14,28 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
-use std::collections::HashMap;
-use std::collections::HashSet;
-
-use std::fs;
-use std::io;
+use std::collections::{HashMap, HashSet};
use std::path::Path;
+use std::{fs, io};
-use libstackerdb::SlotMetadata;
-use libstackerdb::STACKERDB_MAX_CHUNK_SIZE;
+use clarity::vm::types::QualifiedContractIdentifier;
+use clarity::vm::ContractName;
+use libstackerdb::{SlotMetadata, STACKERDB_MAX_CHUNK_SIZE};
+use rusqlite::types::ToSql;
+use rusqlite::{Connection, OpenFlags, OptionalExtension, Row, Transaction, NO_PARAMS};
+use stacks_common::types::chainstate::{ConsensusHash, StacksAddress};
+use stacks_common::util::get_epoch_time_secs;
+use stacks_common::util::hash::Sha512Trunc256Sum;
+use stacks_common::util::secp256k1::MessageSignature;
use crate::chainstate::stacks::address::PoxAddress;
use crate::net::stackerdb::{StackerDBConfig, StackerDBTx, StackerDBs, STACKERDB_INV_MAX};
-use crate::net::Error as net_error;
-use crate::net::{StackerDBChunkData, StackerDBHandshakeData};
-
-use rusqlite::{
- types::ToSql, Connection, OpenFlags, OptionalExtension, Row, Transaction, NO_PARAMS,
-};
-
+use crate::net::{Error as net_error, StackerDBChunkData, StackerDBHandshakeData};
use crate::util_lib::db::{
opt_u64_to_sql, query_row, query_row_panic, query_rows, sql_pragma, sqlite_open,
tx_begin_immediate, tx_busy_handler, u64_to_sql, DBConn, Error as db_error, FromColumn,
FromRow,
};
-use stacks_common::types::chainstate::ConsensusHash;
-use stacks_common::types::chainstate::StacksAddress;
-use stacks_common::util::get_epoch_time_secs;
-use stacks_common::util::hash::Sha512Trunc256Sum;
-use stacks_common::util::secp256k1::MessageSignature;
-
-use clarity::vm::types::QualifiedContractIdentifier;
-use clarity::vm::ContractName;
const STACKER_DB_SCHEMA: &'static [&'static str] = &[
r#"
diff --git a/stackslib/src/net/stackerdb/mod.rs b/stackslib/src/net/stackerdb/mod.rs
index 3862544676..8520cec1f0 100644
--- a/stackslib/src/net/stackerdb/mod.rs
+++ b/stackslib/src/net/stackerdb/mod.rs
@@ -118,36 +118,23 @@ pub mod config;
pub mod db;
pub mod sync;
-use crate::net::Error as net_error;
-use crate::net::NackData;
-use crate::net::NackErrorCodes;
-use crate::net::Neighbor;
-use crate::net::NeighborAddress;
-use crate::net::NeighborKey;
-use crate::net::Preamble;
-use crate::net::StackerDBChunkData;
-use crate::net::StackerDBChunkInvData;
-use crate::net::StackerDBGetChunkData;
-use crate::net::StackerDBPushChunkData;
-use crate::net::StacksMessage;
-use crate::net::StacksMessageType;
+use std::collections::{HashMap, HashSet};
-use crate::util_lib::db::{DBConn, DBTx};
-use stacks_common::types::chainstate::ConsensusHash;
+use clarity::vm::types::QualifiedContractIdentifier;
+use libstackerdb::{SlotMetadata, STACKERDB_MAX_CHUNK_SIZE};
+use stacks_common::types::chainstate::{ConsensusHash, StacksAddress};
+use stacks_common::util::get_epoch_time_secs;
use stacks_common::util::hash::Sha512Trunc256Sum;
use stacks_common::util::secp256k1::MessageSignature;
-use std::collections::{HashMap, HashSet};
use crate::net::neighbors::NeighborComms;
-
use crate::net::p2p::PeerNetwork;
-
-use stacks_common::types::chainstate::StacksAddress;
-use stacks_common::util::get_epoch_time_secs;
-
-use libstackerdb::{SlotMetadata, STACKERDB_MAX_CHUNK_SIZE};
-
-use clarity::vm::types::QualifiedContractIdentifier;
+use crate::net::{
+ Error as net_error, NackData, NackErrorCodes, Neighbor, NeighborAddress, NeighborKey, Preamble,
+ StackerDBChunkData, StackerDBChunkInvData, StackerDBGetChunkData, StackerDBPushChunkData,
+ StacksMessage, StacksMessageType,
+};
+use crate::util_lib::db::{DBConn, DBTx};
/// maximum chunk inventory size
pub const STACKERDB_INV_MAX: u32 = 4096;
diff --git a/stackslib/src/net/stackerdb/sync.rs b/stackslib/src/net/stackerdb/sync.rs
index 3c22df43db..a5d875d86e 100644
--- a/stackslib/src/net/stackerdb/sync.rs
+++ b/stackslib/src/net/stackerdb/sync.rs
@@ -17,35 +17,27 @@
use std::collections::{HashMap, HashSet};
use std::mem;
-use crate::net::stackerdb::{
- StackerDBConfig, StackerDBSync, StackerDBSyncResult, StackerDBSyncState, StackerDBs,
-};
-
-use crate::net::db::PeerDB;
-
-use stacks_common::types::chainstate::ConsensusHash;
-use stacks_common::types::chainstate::StacksAddress;
+use clarity::vm::types::QualifiedContractIdentifier;
+use rand::prelude::SliceRandom;
+use rand::{thread_rng, Rng, RngCore};
+use stacks_common::types::chainstate::{ConsensusHash, StacksAddress};
use stacks_common::util::get_epoch_time_secs;
use stacks_common::util::hash::Hash160;
use crate::net::chat::ConversationP2P;
use crate::net::connection::ReplyHandleP2P;
+use crate::net::db::PeerDB;
+use crate::net::neighbors::NeighborComms;
use crate::net::p2p::PeerNetwork;
-use crate::net::Error as net_error;
+use crate::net::stackerdb::{
+ StackerDBConfig, StackerDBSync, StackerDBSyncResult, StackerDBSyncState, StackerDBs,
+};
use crate::net::{
- NackData, Neighbor, NeighborAddress, NeighborKey, StackerDBChunkData, StackerDBChunkInvData,
- StackerDBGetChunkData, StackerDBGetChunkInvData, StackerDBPushChunkData, StacksMessageType,
+ Error as net_error, NackData, Neighbor, NeighborAddress, NeighborKey, StackerDBChunkData,
+ StackerDBChunkInvData, StackerDBGetChunkData, StackerDBGetChunkInvData, StackerDBPushChunkData,
+ StacksMessageType,
};
-use crate::net::neighbors::NeighborComms;
-
-use clarity::vm::types::QualifiedContractIdentifier;
-
-use rand::prelude::SliceRandom;
-use rand::thread_rng;
-use rand::Rng;
-use rand::RngCore;
-
const MAX_CHUNKS_IN_FLIGHT: usize = 6;
const MAX_DB_NEIGHBORS: usize = 32;
diff --git a/stackslib/src/net/stackerdb/tests/config.rs b/stackslib/src/net/stackerdb/tests/config.rs
index 07a5cd7218..dec38e4691 100644
--- a/stackslib/src/net/stackerdb/tests/config.rs
+++ b/stackslib/src/net/stackerdb/tests/config.rs
@@ -14,37 +14,26 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
-use crate::burnchains::Burnchain;
-use crate::core::StacksEpochExtension;
-use crate::core::BITCOIN_REGTEST_FIRST_BLOCK_HASH;
+use clarity::vm::types::QualifiedContractIdentifier;
+use clarity::vm::{ClarityVersion, ContractName};
+use stacks_common::address::AddressHashMode;
+use stacks_common::types::chainstate::{
+ BurnchainHeaderHash, StacksAddress, StacksPrivateKey, StacksPublicKey,
+};
+use stacks_common::types::StacksEpoch;
+use stacks_common::util::hash::Hash160;
+use crate::burnchains::Burnchain;
use crate::chainstate::stacks::boot::test::{
instantiate_pox_peer, instantiate_pox_peer_with_epoch,
};
-use crate::chainstate::stacks::StacksTransaction;
-use crate::chainstate::stacks::StacksTransactionSigner;
-use crate::chainstate::stacks::TransactionAuth;
-use crate::chainstate::stacks::TransactionPayload;
-use crate::chainstate::stacks::TransactionVersion;
-
+use crate::chainstate::stacks::{
+ StacksTransaction, StacksTransactionSigner, TransactionAuth, TransactionPayload,
+ TransactionVersion,
+};
+use crate::core::{StacksEpochExtension, BITCOIN_REGTEST_FIRST_BLOCK_HASH};
use crate::net::test::TestEventObserver;
-use crate::net::Error as net_error;
-use crate::net::NeighborAddress;
-use crate::net::StackerDBConfig;
-
-use clarity::vm::ClarityVersion;
-use clarity::vm::ContractName;
-
-use stacks_common::address::AddressHashMode;
-use stacks_common::types::chainstate::BurnchainHeaderHash;
-use stacks_common::types::chainstate::StacksAddress;
-use stacks_common::types::chainstate::StacksPrivateKey;
-use stacks_common::types::chainstate::StacksPublicKey;
-use stacks_common::types::net::PeerAddress;
-use stacks_common::types::StacksEpoch;
-use stacks_common::util::hash::Hash160;
-
-use clarity::vm::types::QualifiedContractIdentifier;
+use crate::net::{Error as net_error, NeighborAddress, PeerAddress, StackerDBConfig};
fn make_smart_contract(
name: &str,
diff --git a/stackslib/src/net/stackerdb/tests/db.rs b/stackslib/src/net/stackerdb/tests/db.rs
index 273274e83b..7371b6b9c5 100644
--- a/stackslib/src/net/stackerdb/tests/db.rs
+++ b/stackslib/src/net/stackerdb/tests/db.rs
@@ -17,26 +17,21 @@
use std::fs;
use std::path::Path;
-use crate::net::stackerdb::{db::SlotValidation, StackerDBConfig, StackerDBs};
-use libstackerdb::SlotMetadata;
-
-use crate::net::Error as net_error;
-use crate::net::StackerDBChunkData;
-
+use clarity::vm::types::QualifiedContractIdentifier;
use clarity::vm::ContractName;
-use stacks_common::types::chainstate::ConsensusHash;
-use stacks_common::types::chainstate::StacksAddress;
-
-use stacks_common::util::hash::Hash160;
-use stacks_common::util::hash::Sha512Trunc256Sum;
-use stacks_common::util::secp256k1::MessageSignature;
-
+use libstackerdb::SlotMetadata;
use stacks_common::address::{
AddressHashMode, C32_ADDRESS_VERSION_MAINNET_MULTISIG, C32_ADDRESS_VERSION_MAINNET_SINGLESIG,
};
-use stacks_common::types::chainstate::{StacksPrivateKey, StacksPublicKey};
+use stacks_common::types::chainstate::{
+ ConsensusHash, StacksAddress, StacksPrivateKey, StacksPublicKey,
+};
+use stacks_common::util::hash::{Hash160, Sha512Trunc256Sum};
+use stacks_common::util::secp256k1::MessageSignature;
-use clarity::vm::types::QualifiedContractIdentifier;
+use crate::net::stackerdb::db::SlotValidation;
+use crate::net::stackerdb::{StackerDBConfig, StackerDBs};
+use crate::net::{Error as net_error, StackerDBChunkData};
fn setup_test_path(path: &str) {
let dirname = Path::new(path).parent().unwrap().to_str().unwrap();
diff --git a/stackslib/src/net/stackerdb/tests/sync.rs b/stackslib/src/net/stackerdb/tests/sync.rs
index 87fd47f19e..92187820c0 100644
--- a/stackslib/src/net/stackerdb/tests/sync.rs
+++ b/stackslib/src/net/stackerdb/tests/sync.rs
@@ -16,39 +16,28 @@
use std::fs;
-use crate::net::stackerdb::{db::SlotValidation, StackerDBConfig, StackerDBs};
-use libstackerdb::SlotMetadata;
-
-use crate::net::Error as net_error;
-use crate::net::StackerDBChunkData;
-
+use clarity::vm::types::QualifiedContractIdentifier;
use clarity::vm::ContractName;
-use stacks_common::types::chainstate::ConsensusHash;
-use stacks_common::types::chainstate::StacksAddress;
-
-use stacks_common::util::hash::Hash160;
-use stacks_common::util::hash::Sha512Trunc256Sum;
-use stacks_common::util::secp256k1::{MessageSignature, Secp256k1PrivateKey};
-
+use libstackerdb::SlotMetadata;
+use rand::prelude::*;
+use rand::seq::SliceRandom;
+use rand::{thread_rng, Rng, RngCore};
use stacks_common::address::{
AddressHashMode, C32_ADDRESS_VERSION_MAINNET_MULTISIG, C32_ADDRESS_VERSION_MAINNET_SINGLESIG,
};
-use stacks_common::types::chainstate::{StacksPrivateKey, StacksPublicKey};
-
-use rand::prelude::*;
-use rand::seq::SliceRandom;
-use rand::thread_rng;
-use rand::Rng;
-use rand::RngCore;
+use stacks_common::types::chainstate::{
+ ConsensusHash, StacksAddress, StacksPrivateKey, StacksPublicKey,
+};
+use stacks_common::util::hash::{Hash160, Sha512Trunc256Sum};
+use stacks_common::util::secp256k1::{MessageSignature, Secp256k1PrivateKey};
use crate::net::relay::Relayer;
-use crate::net::test::TestPeer;
-use crate::net::test::TestPeerConfig;
-
+use crate::net::stackerdb::db::SlotValidation;
+use crate::net::stackerdb::{StackerDBConfig, StackerDBs};
+use crate::net::test::{TestPeer, TestPeerConfig};
+use crate::net::{Error as net_error, StackerDBChunkData};
use crate::util_lib::test::with_timeout;
-use clarity::vm::types::QualifiedContractIdentifier;
-
const BASE_PORT: u16 = 33000;
// Minimum chunk size for FROST is 97 + T * 33, where T = 3000
diff --git a/stackslib/src/net/tests/httpcore.rs b/stackslib/src/net/tests/httpcore.rs
index 1b152f42f4..8cd42f45b7 100644
--- a/stackslib/src/net/tests/httpcore.rs
+++ b/stackslib/src/net/tests/httpcore.rs
@@ -18,6 +18,14 @@ use std::io::Write;
use std::net::{SocketAddr, ToSocketAddrs};
use std::str;
+use stacks_common::codec::StacksMessageCodec;
+use stacks_common::types::chainstate::{StacksAddress, StacksBlockId, StacksPrivateKey};
+use stacks_common::types::net::{PeerAddress, PeerHost};
+use stacks_common::util::chunked_encoding::{
+ HttpChunkedTransferWriter, HttpChunkedTransferWriterState,
+};
+use stacks_common::util::hash::{hex_bytes, to_hex, Hash160};
+
use crate::burnchains::Txid;
use crate::chainstate::stacks::db::blocks::test::make_sample_microblock_stream;
use crate::chainstate::stacks::test::make_codec_test_block;
@@ -25,8 +33,7 @@ use crate::chainstate::stacks::{
StacksTransaction, TokenTransferMemo, TransactionAuth, TransactionPayload,
TransactionPostConditionMode, TransactionVersion,
};
-use crate::net::api::getneighbors::RPCNeighbor;
-use crate::net::api::getneighbors::RPCNeighborsInfo;
+use crate::net::api::getneighbors::{RPCNeighbor, RPCNeighborsInfo};
use crate::net::connection::ConnectionOptions;
use crate::net::http::{
http_error_from_code_and_text, http_reason, HttpContentType, HttpErrorResponse,
@@ -34,21 +41,11 @@ use crate::net::http::{
HttpVersion, HTTP_PREAMBLE_MAX_NUM_HEADERS,
};
use crate::net::httpcore::{
- HttpPreambleExtensions, HttpRequestContentsExtensions, StacksHttpRequest, StacksHttpResponse,
+ HttpPreambleExtensions, HttpRequestContentsExtensions, StacksHttp, StacksHttpMessage,
+ StacksHttpPreamble, StacksHttpRequest, StacksHttpResponse,
};
-use crate::net::httpcore::{StacksHttp, StacksHttpMessage, StacksHttpPreamble};
use crate::net::rpc::ConversationHttp;
-use crate::net::ProtocolFamily;
-use crate::net::TipRequest;
-use stacks_common::codec::StacksMessageCodec;
-use stacks_common::types::chainstate::StacksAddress;
-use stacks_common::types::chainstate::StacksBlockId;
-use stacks_common::types::chainstate::StacksPrivateKey;
-use stacks_common::types::net::{PeerAddress, PeerHost};
-use stacks_common::util::chunked_encoding::HttpChunkedTransferWriter;
-use stacks_common::util::chunked_encoding::HttpChunkedTransferWriterState;
-use stacks_common::util::hash::hex_bytes;
-use stacks_common::util::hash::{to_hex, Hash160};
+use crate::net::{ProtocolFamily, TipRequest};
#[test]
fn test_parse_stacks_http_preamble_request_err() {
diff --git a/stackslib/src/net/tests/neighbors.rs b/stackslib/src/net/tests/neighbors.rs
index 149988ff5c..333543e7ca 100644
--- a/stackslib/src/net/tests/neighbors.rs
+++ b/stackslib/src/net/tests/neighbors.rs
@@ -14,26 +14,23 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
-use crate::core::PEER_VERSION_TESTNET;
+use clarity::vm::types::{StacksAddressExtensions, StandardPrincipalData};
+use rand::prelude::*;
+use rand::thread_rng;
+use stacks_common::util::hash::*;
+use stacks_common::util::sleep_ms;
use crate::core::{
- StacksEpoch, StacksEpochId, PEER_VERSION_EPOCH_2_0, PEER_VERSION_EPOCH_2_05, STACKS_EPOCH_MAX,
+ StacksEpoch, StacksEpochId, PEER_VERSION_EPOCH_2_0, PEER_VERSION_EPOCH_2_05,
+ PEER_VERSION_TESTNET, STACKS_EPOCH_MAX,
};
use crate::net::asn::*;
use crate::net::chat::*;
use crate::net::db::*;
use crate::net::neighbors::*;
use crate::net::test::*;
-use crate::net::Error as net_error;
-use crate::net::*;
+use crate::net::{Error as net_error, *};
use crate::util_lib::test::*;
-use clarity::vm::types::StacksAddressExtensions;
-use clarity::vm::types::StandardPrincipalData;
-use stacks_common::util::hash::*;
-use stacks_common::util::sleep_ms;
-
-use rand::prelude::*;
-use rand::thread_rng;
const TEST_IN_OUT_DEGREES: u64 = 0x1;
diff --git a/stackslib/src/util_lib/bloom.rs b/stackslib/src/util_lib/bloom.rs
index e3633288f0..d34fca233a 100644
--- a/stackslib/src/util_lib/bloom.rs
+++ b/stackslib/src/util_lib/bloom.rs
@@ -19,28 +19,15 @@ use std::collections::HashMap;
use std::hash::Hasher;
use std::io::{Read, Seek, SeekFrom, Write};
-use stacks_common::util::hash::Sha512Trunc256Sum;
-
-use siphasher::sip::SipHasher; // this is SipHash-2-4
-
-use stacks_common::codec::Error as codec_error;
-use stacks_common::codec::StacksMessageCodec;
-use stacks_common::codec::{read_next, write_next};
-
-use crate::util_lib::db::query_expect_row;
-use crate::util_lib::db::Error as db_error;
-use crate::util_lib::db::{DBConn, DBTx};
-
-use stacks_common::util::hash::to_hex;
-
-use rusqlite::blob::Blob;
-use rusqlite::Error as sqlite_error;
-use rusqlite::Row;
-use rusqlite::ToSql;
-use rusqlite::NO_PARAMS;
-
use rand::prelude::*;
use rand::thread_rng;
+use rusqlite::blob::Blob;
+use rusqlite::{Error as sqlite_error, Row, ToSql, NO_PARAMS};
+use siphasher::sip::SipHasher; // this is SipHash-2-4
+use stacks_common::codec::{read_next, write_next, Error as codec_error, StacksMessageCodec};
+use stacks_common::util::hash::{to_hex, Sha512Trunc256Sum};
+
+use crate::util_lib::db::{query_expect_row, DBConn, DBTx, Error as db_error};
/// A field of bits of known length!
#[derive(Debug, Clone, PartialEq)]
@@ -605,15 +592,13 @@ impl BloomHash for BloomNodeHasher {
#[cfg(test)]
pub mod test {
- use super::*;
-
use std::fs;
use rand::prelude::*;
use rand::thread_rng;
-
use rusqlite::OpenFlags;
+ use super::*;
use crate::util_lib::db::{sql_pragma, tx_begin_immediate, tx_busy_handler, DBConn, DBTx};
pub fn setup_bloom_counter(db_name: &str) -> DBConn {
diff --git a/stackslib/src/util_lib/boot.rs b/stackslib/src/util_lib/boot.rs
index b580166890..af3f443278 100644
--- a/stackslib/src/util_lib/boot.rs
+++ b/stackslib/src/util_lib/boot.rs
@@ -1,16 +1,17 @@
use std::convert::TryFrom;
-use crate::chainstate::stacks::db::StacksAccount;
-use crate::chainstate::stacks::{
- SinglesigHashMode, SinglesigSpendingCondition, TransactionAuth, TransactionPublicKeyEncoding,
- TransactionSpendingCondition,
-};
use clarity::vm::database::STXBalance;
use clarity::vm::types::{PrincipalData, QualifiedContractIdentifier};
use clarity::vm::ContractName;
use stacks_common::types::chainstate::StacksAddress;
use stacks_common::util::secp256k1::MessageSignature;
+use crate::chainstate::stacks::db::StacksAccount;
+use crate::chainstate::stacks::{
+ SinglesigHashMode, SinglesigSpendingCondition, TransactionAuth, TransactionPublicKeyEncoding,
+ TransactionSpendingCondition,
+};
+
pub fn boot_code_id(name: &str, mainnet: bool) -> QualifiedContractIdentifier {
let addr = boot_code_addr(mainnet);
QualifiedContractIdentifier::new(
diff --git a/stackslib/src/util_lib/db.rs b/stackslib/src/util_lib/db.rs
index 8409b154c1..5d5f6226da 100644
--- a/stackslib/src/util_lib/db.rs
+++ b/stackslib/src/util_lib/db.rs
@@ -15,48 +15,28 @@
// along with this program. If not, see .
use std::convert::TryInto;
-use std::error;
-use std::fmt;
-use std::fs;
-use std::io;
use std::io::Error as IOError;
-use std::ops::Deref;
-use std::ops::DerefMut;
-use std::path::Path;
-use std::path::PathBuf;
+use std::ops::{Deref, DerefMut};
+use std::path::{Path, PathBuf};
use std::time::Duration;
+use std::{error, fmt, fs, io};
-use rand::thread_rng;
-use rand::Rng;
-use rand::RngCore;
+use clarity::vm::types::QualifiedContractIdentifier;
+use rand::{thread_rng, Rng, RngCore};
use rusqlite::types::{FromSql, ToSql};
-use rusqlite::Connection;
-use rusqlite::Error as sqlite_error;
-use rusqlite::OpenFlags;
-use rusqlite::OptionalExtension;
-use rusqlite::Row;
-use rusqlite::Transaction;
-use rusqlite::TransactionBehavior;
-use rusqlite::NO_PARAMS;
+use rusqlite::{
+ Connection, Error as sqlite_error, OpenFlags, OptionalExtension, Row, Transaction,
+ TransactionBehavior, NO_PARAMS,
+};
use serde_json::Error as serde_error;
-
-use clarity::vm::types::QualifiedContractIdentifier;
-use stacks_common::types::chainstate::SortitionId;
-use stacks_common::types::chainstate::StacksAddress;
-use stacks_common::types::chainstate::StacksBlockId;
+use stacks_common::types::chainstate::{SortitionId, StacksAddress, StacksBlockId, TrieHash};
use stacks_common::types::Address;
use stacks_common::util::hash::to_hex;
-use stacks_common::util::secp256k1::Secp256k1PrivateKey;
-use stacks_common::util::secp256k1::Secp256k1PublicKey;
+use stacks_common::util::secp256k1::{Secp256k1PrivateKey, Secp256k1PublicKey};
use stacks_common::util::sleep_ms;
-use crate::chainstate::stacks::index::marf::MarfConnection;
-use crate::chainstate::stacks::index::marf::MarfTransaction;
-use crate::chainstate::stacks::index::marf::MARF;
-use crate::chainstate::stacks::index::Error as MARFError;
-use crate::chainstate::stacks::index::MARFValue;
-use crate::chainstate::stacks::index::MarfTrieId;
-use stacks_common::types::chainstate::TrieHash;
+use crate::chainstate::stacks::index::marf::{MarfConnection, MarfTransaction, MARF};
+use crate::chainstate::stacks::index::{Error as MARFError, MARFValue, MarfTrieId};
pub type DBConn = rusqlite::Connection;
pub type DBTx<'a> = rusqlite::Transaction<'a>;
diff --git a/stackslib/src/util_lib/mod.rs b/stackslib/src/util_lib/mod.rs
index 8d41c60276..85b09a3af6 100644
--- a/stackslib/src/util_lib/mod.rs
+++ b/stackslib/src/util_lib/mod.rs
@@ -6,13 +6,12 @@ pub mod strings;
#[cfg(test)]
pub mod test {
- use super::*;
- use stacks_common::util::get_epoch_time_secs;
- use stacks_common::util::sleep_ms;
- use std::panic;
- use std::process;
use std::sync::mpsc::sync_channel;
- use std::thread;
+ use std::{panic, process, thread};
+
+ use stacks_common::util::{get_epoch_time_secs, sleep_ms};
+
+ use super::*;
pub fn with_timeout(timeout_secs: u64, test_func: F)
where
diff --git a/stackslib/src/util_lib/strings.rs b/stackslib/src/util_lib/strings.rs
index 47291e192d..cb43956274 100644
--- a/stackslib/src/util_lib/strings.rs
+++ b/stackslib/src/util_lib/strings.rs
@@ -16,17 +16,10 @@
use std::borrow::Borrow;
use std::convert::TryFrom;
-use std::fmt;
-use std::io;
use std::io::prelude::*;
use std::io::{Read, Write};
-use std::ops::Deref;
-use std::ops::DerefMut;
-
-use regex::Regex;
-use url;
-
-use stacks_common::codec::Error as codec_error;
+use std::ops::{Deref, DerefMut};
+use std::{fmt, io};
use clarity::vm::errors::RuntimeErrorType;
use clarity::vm::representations::{
@@ -36,10 +29,13 @@ use clarity::vm::representations::{
use clarity::vm::types::{
PrincipalData, QualifiedContractIdentifier, StandardPrincipalData, Value,
};
-use stacks_common::codec::MAX_MESSAGE_LEN;
+use regex::Regex;
+use stacks_common::codec::{
+ read_next, read_next_at_most, write_next, Error as codec_error, StacksMessageCodec,
+ MAX_MESSAGE_LEN,
+};
use stacks_common::util::retry::BoundReader;
-
-use stacks_common::codec::{read_next, read_next_at_most, write_next, StacksMessageCodec};
+use url;
lazy_static! {
static ref URL_STRING_REGEX: Regex =
@@ -326,12 +322,11 @@ impl UrlString {
mod test {
use std::error::Error;
+ use super::*;
use crate::net::codec::test::check_codec_and_corruption;
use crate::net::codec::*;
use crate::net::*;
- use super::*;
-
#[test]
fn tx_stacks_strings_codec() {
let s = "hello-world";
diff --git a/stx-genesis/build.rs b/stx-genesis/build.rs
index bc80838566..710585c248 100644
--- a/stx-genesis/build.rs
+++ b/stx-genesis/build.rs
@@ -1,11 +1,8 @@
use std::fmt::Write as FmtWrite;
-use std::fs;
+use std::fs::File;
+use std::io::{BufRead, BufReader, Read, Write};
use std::path::Path;
-use std::{
- env,
- fs::File,
- io::{BufRead, BufReader, Read, Write},
-};
+use std::{env, fs};
use libflate::deflate;
use sha2::{Digest, Sha256};
diff --git a/stx-genesis/src/lib.rs b/stx-genesis/src/lib.rs
index dc287a36fc..9d25704b7b 100644
--- a/stx-genesis/src/lib.rs
+++ b/stx-genesis/src/lib.rs
@@ -1,5 +1,5 @@
-use std::io::{self, BufReader};
-use std::io::{prelude::*, Cursor, Lines};
+use std::io::prelude::*;
+use std::io::{self, BufReader, Cursor, Lines};
use libflate::deflate::{self, Decoder};
diff --git a/testnet/stacks-node/Cargo.toml b/testnet/stacks-node/Cargo.toml
index 1eb350861c..82ed994ee4 100644
--- a/testnet/stacks-node/Cargo.toml
+++ b/testnet/stacks-node/Cargo.toml
@@ -38,10 +38,10 @@ clarity = { path = "../../clarity", features = ["default", "testing"]}
stacks-common = { path = "../../stacks-common", features = ["default", "testing"] }
stacks = { package = "stackslib", path = "../../stackslib", features = ["default", "testing"] }
stacks-signer = { path = "../../stacks-signer" }
-p256k1 = "5.4.1"
+p256k1 = "5.5"
tracing = "0.1.37"
tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }
-wsts = { git = "https://github.com/Trust-Machines/wsts", tag = "4.0.0rc2" }
+wsts = "4.0.0"
[dev-dependencies.rusqlite]
version = "=0.24.2"
diff --git a/testnet/stacks-node/src/burnchains/bitcoin_regtest_controller.rs b/testnet/stacks-node/src/burnchains/bitcoin_regtest_controller.rs
index 2076c0904f..8f2ba1df5d 100644
--- a/testnet/stacks-node/src/burnchains/bitcoin_regtest_controller.rs
+++ b/testnet/stacks-node/src/burnchains/bitcoin_regtest_controller.rs
@@ -1,24 +1,19 @@
+use std::cmp;
+use std::io::Cursor;
+use std::sync::atomic::{AtomicBool, Ordering};
+use std::sync::Arc;
+use std::time::Instant;
+
use async_h1::client;
use async_std::io::ReadExt;
use async_std::net::TcpStream;
use base64::encode;
use http_types::{Method, Request, Url};
-use std::io::Cursor;
-use std::sync::{
- atomic::{AtomicBool, Ordering},
- Arc,
-};
-use std::time::Instant;
-
use serde::Serialize;
use serde_json::value::RawValue;
-
-use std::cmp;
-
-use super::super::operations::BurnchainOpSigner;
-use super::super::Config;
-use super::{BurnchainController, BurnchainTip, Error as BurnchainControllerError};
-
+use stacks::burnchains::bitcoin::address::{
+ BitcoinAddress, LegacyBitcoinAddress, LegacyBitcoinAddressType, SegwitBitcoinAddress,
+};
use stacks::burnchains::bitcoin::indexer::{
BitcoinIndexer, BitcoinIndexerConfig, BitcoinIndexerRuntime,
};
@@ -26,26 +21,22 @@ use stacks::burnchains::bitcoin::spv::SpvClient;
use stacks::burnchains::bitcoin::BitcoinNetworkType;
use stacks::burnchains::db::BurnchainDB;
use stacks::burnchains::indexer::BurnchainIndexer;
-use stacks::burnchains::BurnchainStateTransitionOps;
-use stacks::burnchains::Error as burnchain_error;
-use stacks::burnchains::PoxConstants;
-use stacks::burnchains::PublicKey;
use stacks::burnchains::{
- bitcoin::address::{
- BitcoinAddress, LegacyBitcoinAddress, LegacyBitcoinAddressType, SegwitBitcoinAddress,
- },
- Txid,
+ Burnchain, BurnchainParameters, BurnchainStateTransitionOps, Error as burnchain_error,
+ PoxConstants, PublicKey, Txid,
};
-use stacks::burnchains::{Burnchain, BurnchainParameters};
use stacks::chainstate::burn::db::sortdb::SortitionDB;
use stacks::chainstate::burn::operations::{
BlockstackOperationType, DelegateStxOp, LeaderBlockCommitOp, LeaderKeyRegisterOp, PreStxOp,
TransferStxOp, UserBurnSupportOp,
};
+#[cfg(test)]
+use stacks::chainstate::burn::Opcodes;
use stacks::chainstate::coordinator::comm::CoordinatorChannels;
#[cfg(test)]
use stacks::chainstate::stacks::address::PoxAddress;
use stacks::core::{StacksEpoch, StacksEpochId};
+use stacks::monitoring::{increment_btc_blocks_received_counter, increment_btc_ops_sent_counter};
use stacks_common::codec::StacksMessageCodec;
use stacks_common::deps_common::bitcoin::blockdata::opcodes;
use stacks_common::deps_common::bitcoin::blockdata::script::{Builder, Script};
@@ -53,21 +44,18 @@ use stacks_common::deps_common::bitcoin::blockdata::transaction::{
OutPoint, Transaction, TxIn, TxOut,
};
use stacks_common::deps_common::bitcoin::network::encodable::ConsensusEncodable;
-use stacks_common::util::hash::{hex_bytes, Hash160};
-use stacks_common::util::secp256k1::Secp256k1PublicKey;
-use stacks_common::util::sleep_ms;
-
#[cfg(test)]
use stacks_common::deps_common::bitcoin::network::serialize::deserialize as btc_deserialize;
-
use stacks_common::deps_common::bitcoin::network::serialize::RawEncoder;
use stacks_common::deps_common::bitcoin::util::hash::Sha256dHash;
-
-use stacks::monitoring::{increment_btc_blocks_received_counter, increment_btc_ops_sent_counter};
-
-#[cfg(test)]
-use stacks::chainstate::burn::Opcodes;
use stacks_common::types::chainstate::BurnchainHeaderHash;
+use stacks_common::util::hash::{hex_bytes, Hash160};
+use stacks_common::util::secp256k1::Secp256k1PublicKey;
+use stacks_common::util::sleep_ms;
+
+use super::super::operations::BurnchainOpSigner;
+use super::super::Config;
+use super::{BurnchainController, BurnchainTip, Error as BurnchainControllerError};
/// The number of bitcoin blocks that can have
/// passed since the UTXO cache was last refreshed before
diff --git a/testnet/stacks-node/src/burnchains/mocknet_controller.rs b/testnet/stacks-node/src/burnchains/mocknet_controller.rs
index 7ae121ac3e..0c1ae9c84e 100644
--- a/testnet/stacks-node/src/burnchains/mocknet_controller.rs
+++ b/testnet/stacks-node/src/burnchains/mocknet_controller.rs
@@ -1,15 +1,16 @@
use std::collections::VecDeque;
use std::time::Instant;
+use clarity::vm::costs::ExecutionCost;
use stacks::burnchains::bitcoin::BitcoinBlock;
use stacks::burnchains::{
Burnchain, BurnchainBlock, BurnchainBlockHeader, BurnchainStateTransitionOps, Txid,
};
use stacks::chainstate::burn::db::sortdb::{SortitionDB, SortitionHandleTx};
-use stacks::chainstate::burn::operations::DelegateStxOp;
+use stacks::chainstate::burn::operations::leader_block_commit::BURN_BLOCK_MINED_AT_MODULUS;
use stacks::chainstate::burn::operations::{
- leader_block_commit::BURN_BLOCK_MINED_AT_MODULUS, BlockstackOperationType, LeaderBlockCommitOp,
- LeaderKeyRegisterOp, PreStxOp, StackStxOp, TransferStxOp, UserBurnSupportOp,
+ BlockstackOperationType, DelegateStxOp, LeaderBlockCommitOp, LeaderKeyRegisterOp, PreStxOp,
+ StackStxOp, TransferStxOp, UserBurnSupportOp,
};
use stacks::chainstate::burn::BlockSnapshot;
use stacks::core::{
@@ -23,7 +24,6 @@ use stacks_common::util::hash::Sha256Sum;
use super::super::operations::BurnchainOpSigner;
use super::super::Config;
use super::{BurnchainController, BurnchainTip, Error as BurnchainControllerError};
-use clarity::vm::costs::ExecutionCost;
/// MocknetController is simulating a simplistic burnchain.
pub struct MocknetController {
diff --git a/testnet/stacks-node/src/burnchains/mod.rs b/testnet/stacks-node/src/burnchains/mod.rs
index f0badf7899..5506cf6231 100644
--- a/testnet/stacks-node/src/burnchains/mod.rs
+++ b/testnet/stacks-node/src/burnchains/mod.rs
@@ -1,24 +1,19 @@
pub mod bitcoin_regtest_controller;
pub mod mocknet_controller;
-pub use self::bitcoin_regtest_controller::BitcoinRegtestController;
-pub use self::mocknet_controller::MocknetController;
-
-use super::operations::BurnchainOpSigner;
-
use std::fmt;
use std::time::Instant;
use stacks::burnchains;
-use stacks::burnchains::BurnchainStateTransitionOps;
-use stacks::burnchains::Txid;
+use stacks::burnchains::{BurnchainStateTransitionOps, Txid};
use stacks::chainstate::burn::db::sortdb::SortitionDB;
use stacks::chainstate::burn::operations::BlockstackOperationType;
use stacks::chainstate::burn::BlockSnapshot;
-
use stacks::core::{StacksEpoch, StacksEpochId};
-pub use self::bitcoin_regtest_controller::make_bitcoin_indexer;
+pub use self::bitcoin_regtest_controller::{make_bitcoin_indexer, BitcoinRegtestController};
+pub use self::mocknet_controller::MocknetController;
+use super::operations::BurnchainOpSigner;
#[derive(Debug)]
pub enum Error {
diff --git a/testnet/stacks-node/src/config.rs b/testnet/stacks-node/src/config.rs
index fb90b7cdd1..b3c1a1a9d4 100644
--- a/testnet/stacks-node/src/config.rs
+++ b/testnet/stacks-node/src/config.rs
@@ -2,44 +2,34 @@ use std::convert::TryInto;
use std::fs;
use std::net::{SocketAddr, ToSocketAddrs};
use std::path::PathBuf;
-use std::sync::Arc;
-use std::sync::Mutex;
-
-use rand::RngCore;
+use std::sync::{Arc, Mutex};
use clarity::vm::costs::ExecutionCost;
use clarity::vm::types::{AssetIdentifier, PrincipalData, QualifiedContractIdentifier};
+use rand::RngCore;
use stacks::burnchains::bitcoin::BitcoinNetworkType;
-use stacks::burnchains::Burnchain;
-use stacks::burnchains::{MagicBytes, BLOCKSTACK_MAGIC_MAINNET};
+use stacks::burnchains::{Burnchain, MagicBytes, BLOCKSTACK_MAGIC_MAINNET};
use stacks::chainstate::stacks::index::marf::MARFOpenOpts;
use stacks::chainstate::stacks::index::storage::TrieHashCalculationMode;
-use stacks::chainstate::stacks::miner::BlockBuilderSettings;
-use stacks::chainstate::stacks::miner::MinerStatus;
+use stacks::chainstate::stacks::miner::{BlockBuilderSettings, MinerStatus};
use stacks::chainstate::stacks::MAX_BLOCK_LEN;
use stacks::core::mempool::MemPoolWalkSettings;
-use stacks::core::StacksEpoch;
-use stacks::core::StacksEpochExtension;
-use stacks::core::StacksEpochId;
use stacks::core::{
- CHAIN_ID_MAINNET, CHAIN_ID_TESTNET, PEER_VERSION_MAINNET, PEER_VERSION_TESTNET,
+ StacksEpoch, StacksEpochExtension, StacksEpochId, CHAIN_ID_MAINNET, CHAIN_ID_TESTNET,
+ PEER_VERSION_MAINNET, PEER_VERSION_TESTNET,
};
use stacks::cost_estimates::fee_medians::WeightedMedianFeeRateEstimator;
use stacks::cost_estimates::fee_rate_fuzzer::FeeRateFuzzer;
use stacks::cost_estimates::fee_scalar::ScalarFeeRateEstimator;
-use stacks::cost_estimates::metrics::CostMetric;
-use stacks::cost_estimates::metrics::ProportionalDotProduct;
-use stacks::cost_estimates::CostEstimator;
-use stacks::cost_estimates::FeeEstimator;
-use stacks::cost_estimates::PessimisticEstimator;
+use stacks::cost_estimates::metrics::{CostMetric, ProportionalDotProduct};
+use stacks::cost_estimates::{CostEstimator, FeeEstimator, PessimisticEstimator};
use stacks::net::atlas::AtlasConfig;
use stacks::net::connection::ConnectionOptions;
use stacks::net::{Neighbor, NeighborKey};
use stacks_common::types::net::PeerAddress;
use stacks_common::util::get_epoch_time_ms;
use stacks_common::util::hash::hex_bytes;
-use stacks_common::util::secp256k1::Secp256k1PrivateKey;
-use stacks_common::util::secp256k1::Secp256k1PublicKey;
+use stacks_common::util::secp256k1::{Secp256k1PrivateKey, Secp256k1PublicKey};
const DEFAULT_SATS_PER_VB: u64 = 50;
const DEFAULT_MAX_RBF_RATE: u64 = 150; // 1.5x
diff --git a/testnet/stacks-node/src/event_dispatcher.rs b/testnet/stacks-node/src/event_dispatcher.rs
index 8849e82573..235627b063 100644
--- a/testnet/stacks-node/src/event_dispatcher.rs
+++ b/testnet/stacks-node/src/event_dispatcher.rs
@@ -5,43 +5,37 @@ use std::time::Duration;
use async_h1::client;
use async_std::net::TcpStream;
-use http_types::{Method, Request, Url};
-use serde_json::json;
-
use clarity::vm::analysis::contract_interface_builder::build_contract_interface;
use clarity::vm::costs::ExecutionCost;
use clarity::vm::events::{FTEventType, NFTEventType, STXEventType};
use clarity::vm::types::{AssetIdentifier, QualifiedContractIdentifier, Value};
+use http_types::{Method, Request, Url};
+pub use libsigner::StackerDBChunksEvent;
+use serde_json::json;
use stacks::burnchains::{PoxConstants, Txid};
+use stacks::chainstate::burn::operations::BlockstackOperationType;
+use stacks::chainstate::burn::ConsensusHash;
use stacks::chainstate::coordinator::BlockEventDispatcher;
use stacks::chainstate::stacks::address::PoxAddress;
-use stacks::chainstate::stacks::db::StacksHeaderInfo;
+use stacks::chainstate::stacks::db::accounts::MinerReward;
+use stacks::chainstate::stacks::db::unconfirmed::ProcessedUnconfirmedState;
+use stacks::chainstate::stacks::db::{MinerRewardInfo, StacksHeaderInfo};
use stacks::chainstate::stacks::events::{
StacksTransactionEvent, StacksTransactionReceipt, TransactionOrigin,
};
+use stacks::chainstate::stacks::miner::TransactionEvent;
use stacks::chainstate::stacks::{
- db::accounts::MinerReward, db::MinerRewardInfo, StacksTransaction,
+ StacksBlock, StacksMicroblock, StacksTransaction, TransactionPayload,
};
-use stacks::chainstate::stacks::{StacksBlock, StacksMicroblock};
-use stacks::core::mempool::MemPoolDropReason;
-use stacks::core::mempool::MemPoolEventDispatcher;
+use stacks::core::mempool::{MemPoolDropReason, MemPoolEventDispatcher};
+use stacks::libstackerdb::StackerDBChunkData;
use stacks::net::atlas::{Attachment, AttachmentInstance};
+use stacks::net::stackerdb::StackerDBEventDispatcher;
use stacks_common::codec::StacksMessageCodec;
use stacks_common::types::chainstate::{BlockHeaderHash, BurnchainHeaderHash, StacksBlockId};
use stacks_common::util::hash::bytes_to_hex;
use super::config::{EventKeyType, EventObserverConfig};
-use stacks::chainstate::burn::operations::BlockstackOperationType;
-use stacks::chainstate::burn::ConsensusHash;
-use stacks::chainstate::stacks::db::unconfirmed::ProcessedUnconfirmedState;
-use stacks::chainstate::stacks::miner::TransactionEvent;
-use stacks::chainstate::stacks::TransactionPayload;
-
-use stacks::net::stackerdb::StackerDBEventDispatcher;
-
-use stacks::libstackerdb::StackerDBChunkData;
-
-pub use libsigner::StackerDBChunksEvent;
#[derive(Debug, Clone)]
struct EventObserver {
@@ -1066,13 +1060,14 @@ impl EventDispatcher {
#[cfg(test)]
mod test {
- use crate::event_dispatcher::EventObserver;
use clarity::vm::costs::ExecutionCost;
use stacks::burnchains::{PoxConstants, Txid};
use stacks::chainstate::stacks::db::StacksHeaderInfo;
use stacks::chainstate::stacks::StacksBlock;
use stacks_common::types::chainstate::{BurnchainHeaderHash, StacksBlockId};
+ use crate::event_dispatcher::EventObserver;
+
#[test]
fn build_block_processed_event() {
let observer = EventObserver {
diff --git a/testnet/stacks-node/src/keychain.rs b/testnet/stacks-node/src/keychain.rs
index b3249f52b4..7ea3b90556 100644
--- a/testnet/stacks-node/src/keychain.rs
+++ b/testnet/stacks-node/src/keychain.rs
@@ -2,18 +2,16 @@ use stacks::burnchains::BurnchainSigner;
use stacks::chainstate::stacks::{
StacksPrivateKey, StacksPublicKey, StacksTransactionSigner, TransactionAuth,
};
-use stacks_common::address::AddressHashMode;
+use stacks_common::address::{
+ AddressHashMode, C32_ADDRESS_VERSION_MAINNET_SINGLESIG, C32_ADDRESS_VERSION_TESTNET_SINGLESIG,
+};
use stacks_common::types::chainstate::StacksAddress;
use stacks_common::util::hash::{Hash160, Sha256Sum};
+use stacks_common::util::secp256k1::Secp256k1PublicKey;
use stacks_common::util::vrf::{VRFPrivateKey, VRFProof, VRFPublicKey, VRF};
use super::operations::BurnchainOpSigner;
-use stacks_common::address::{
- C32_ADDRESS_VERSION_MAINNET_SINGLESIG, C32_ADDRESS_VERSION_TESTNET_SINGLESIG,
-};
-use stacks_common::util::secp256k1::Secp256k1PublicKey;
-
/// A wrapper around a node's seed, coupled with operations for using it
#[derive(Clone)]
pub struct Keychain {
@@ -198,23 +196,17 @@ mod tests {
use stacks::burnchains::PrivateKey;
use stacks::chainstate::stacks::{
- StacksPrivateKey, StacksPublicKey, StacksTransactionSigner, TransactionAuth,
+ StacksPrivateKey, StacksPublicKey, StacksTransaction, StacksTransactionSigner,
+ TokenTransferMemo, TransactionAuth, TransactionPayload, TransactionPostConditionMode,
+ TransactionVersion,
};
use stacks_common::address::AddressHashMode;
use stacks_common::types::chainstate::StacksAddress;
use stacks_common::util::hash::{Hash160, Sha256Sum};
use stacks_common::util::vrf::{VRFPrivateKey, VRFProof, VRFPublicKey, VRF};
- use crate::operations::BurnchainOpSigner;
-
use super::Keychain;
-
- use stacks::chainstate::stacks::StacksTransaction;
- use stacks::chainstate::stacks::TokenTransferMemo;
- use stacks::chainstate::stacks::TransactionPayload;
- use stacks::chainstate::stacks::TransactionPostConditionMode;
- use stacks::chainstate::stacks::TransactionVersion;
-
+ use crate::operations::BurnchainOpSigner;
use crate::stacks_common::types::Address;
/// Legacy implementation; kept around for testing
diff --git a/testnet/stacks-node/src/main.rs b/testnet/stacks-node/src/main.rs
index 987b5e1f03..33f1214dc9 100644
--- a/testnet/stacks-node/src/main.rs
+++ b/testnet/stacks-node/src/main.rs
@@ -35,6 +35,12 @@ pub mod run_loop;
pub mod syncctl;
pub mod tenure;
+use std::convert::TryInto;
+use std::{env, panic, process};
+
+use backtrace::Backtrace;
+use pico_args::Arguments;
+
pub use self::burnchains::{
BitcoinRegtestController, BurnchainController, BurnchainTip, MocknetController,
};
@@ -45,15 +51,6 @@ pub use self::node::{ChainTip, Node};
pub use self::run_loop::{helium, neon};
pub use self::tenure::Tenure;
-use pico_args::Arguments;
-use std::env;
-
-use std::convert::TryInto;
-use std::panic;
-use std::process;
-
-use backtrace::Backtrace;
-
fn main() {
panic::set_hook(Box::new(|panic_info| {
error!("Process abort due to thread panic: {}", panic_info);
@@ -66,8 +63,7 @@ fn main() {
let pid = process::id();
eprintln!("Dumping core for pid {}", std::process::id());
- use libc::kill;
- use libc::SIGQUIT;
+ use libc::{kill, SIGQUIT};
// *should* trigger a core dump, if you run `ulimit -c unlimited` first!
unsafe { kill(pid.try_into().unwrap(), SIGQUIT) };
diff --git a/testnet/stacks-node/src/monitoring/prometheus.rs b/testnet/stacks-node/src/monitoring/prometheus.rs
index 9342a8f8d4..65c427d2bc 100644
--- a/testnet/stacks-node/src/monitoring/prometheus.rs
+++ b/testnet/stacks-node/src/monitoring/prometheus.rs
@@ -1,9 +1,8 @@
use async_std::net::{TcpListener, TcpStream};
use async_std::prelude::*;
use async_std::task;
-use stacks::prometheus::{gather, Encoder, TextEncoder};
-
use http_types::{Body, Response, StatusCode};
+use stacks::prometheus::{gather, Encoder, TextEncoder};
pub fn start_serving_prometheus_metrics(bind_address: String) {
let addr = bind_address.clone();
diff --git a/testnet/stacks-node/src/neon_node.rs b/testnet/stacks-node/src/neon_node.rs
index 82d7f4bbf1..517f080cb6 100644
--- a/testnet/stacks-node/src/neon_node.rs
+++ b/testnet/stacks-node/src/neon_node.rs
@@ -138,93 +138,81 @@
///
/// This file may be refactored in the future into a full-fledged module.
use std::cmp;
-use std::collections::HashMap;
-use std::collections::VecDeque;
+use std::collections::{HashMap, VecDeque};
use std::convert::{TryFrom, TryInto};
-use std::mem;
+use std::default::Default;
use std::net::SocketAddr;
+use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::mpsc::{Receiver, SyncSender, TrySendError};
-use std::sync::{atomic::AtomicBool, atomic::Ordering, Arc, Mutex};
+use std::sync::{Arc, Mutex};
+use std::thread::JoinHandle;
use std::time::Duration;
-use std::{thread, thread::JoinHandle};
+use std::{mem, thread};
+use clarity::vm::ast::ASTRules;
use clarity::vm::costs::ExecutionCost;
-use stacks::burnchains::{
- db::BurnchainHeaderReader, Burnchain, BurnchainParameters, BurnchainSigner, Txid,
-};
+use clarity::vm::types::{PrincipalData, QualifiedContractIdentifier};
+use stacks::burnchains::db::BurnchainHeaderReader;
+use stacks::burnchains::{Burnchain, BurnchainParameters, BurnchainSigner, Txid};
use stacks::chainstate::burn::db::sortdb::SortitionDB;
+use stacks::chainstate::burn::operations::leader_block_commit::{
+ RewardSetInfo, BURN_BLOCK_MINED_AT_MODULUS,
+};
use stacks::chainstate::burn::operations::{
- leader_block_commit::{RewardSetInfo, BURN_BLOCK_MINED_AT_MODULUS},
BlockstackOperationType, LeaderBlockCommitOp, LeaderKeyRegisterOp,
};
-use stacks::chainstate::burn::BlockSnapshot;
-use stacks::chainstate::burn::ConsensusHash;
+use stacks::chainstate::burn::{BlockSnapshot, ConsensusHash};
use stacks::chainstate::coordinator::comm::CoordinatorChannels;
use stacks::chainstate::coordinator::{get_next_recipients, OnChainRewardSetProvider};
use stacks::chainstate::stacks::address::PoxAddress;
use stacks::chainstate::stacks::db::unconfirmed::UnconfirmedTxMap;
-use stacks::chainstate::stacks::db::StacksHeaderInfo;
-use stacks::chainstate::stacks::db::{StacksChainState, MINER_REWARD_MATURITY};
-use stacks::chainstate::stacks::Error as ChainstateError;
-use stacks::chainstate::stacks::StacksPublicKey;
-use stacks::chainstate::stacks::{
- miner::get_mining_spend_amount, miner::signal_mining_blocked, miner::signal_mining_ready,
- miner::BlockBuilderSettings, miner::MinerStatus, miner::StacksMicroblockBuilder,
- StacksBlockBuilder, StacksBlockHeader,
+use stacks::chainstate::stacks::db::{StacksChainState, StacksHeaderInfo, MINER_REWARD_MATURITY};
+use stacks::chainstate::stacks::miner::{
+ get_mining_spend_amount, signal_mining_blocked, signal_mining_ready, BlockBuilderSettings,
+ MinerStatus, StacksMicroblockBuilder,
};
use stacks::chainstate::stacks::{
- CoinbasePayload, StacksBlock, StacksMicroblock, StacksTransaction, StacksTransactionSigner,
+ CoinbasePayload, Error as ChainstateError, StacksBlock, StacksBlockBuilder, StacksBlockHeader,
+ StacksMicroblock, StacksPublicKey, StacksTransaction, StacksTransactionSigner,
TransactionAnchorMode, TransactionPayload, TransactionVersion,
};
use stacks::core::mempool::MemPoolDB;
-use stacks::core::FIRST_BURNCHAIN_CONSENSUS_HASH;
-use stacks::core::STACKS_EPOCH_2_4_MARKER;
-use stacks::cost_estimates::metrics::CostMetric;
-use stacks::cost_estimates::metrics::UnitMetric;
-use stacks::cost_estimates::UnitEstimator;
-use stacks::cost_estimates::{CostEstimator, FeeEstimator};
+use stacks::core::{FIRST_BURNCHAIN_CONSENSUS_HASH, STACKS_EPOCH_2_4_MARKER};
+use stacks::cost_estimates::metrics::{CostMetric, UnitMetric};
+use stacks::cost_estimates::{CostEstimator, FeeEstimator, UnitEstimator};
+use stacks::monitoring;
use stacks::monitoring::{increment_stx_blocks_mined_counter, update_active_miners_count_gauge};
+use stacks::net::atlas::{AtlasConfig, AtlasDB};
+use stacks::net::db::{LocalPeer, PeerDB};
+use stacks::net::dns::{DNSClient, DNSResolver};
+use stacks::net::p2p::PeerNetwork;
+use stacks::net::relay::Relayer;
+use stacks::net::stackerdb::{StackerDBConfig, StackerDBSync, StackerDBs};
use stacks::net::{
- atlas::{AtlasConfig, AtlasDB},
- db::{LocalPeer, PeerDB},
- dns::DNSClient,
- dns::DNSResolver,
- p2p::PeerNetwork,
- relay::Relayer,
- stackerdb::{StackerDBConfig, StackerDBSync, StackerDBs},
Error as NetError, NetworkResult, PeerNetworkComms, RPCHandlerArgs, ServiceFlags,
};
use stacks::util_lib::strings::{UrlString, VecDisplay};
use stacks_common::codec::StacksMessageCodec;
use stacks_common::types::chainstate::{
- BlockHeaderHash, BurnchainHeaderHash, SortitionId, StacksAddress, VRFSeed,
+ BlockHeaderHash, BurnchainHeaderHash, SortitionId, StacksAddress, StacksBlockId,
+ StacksPrivateKey, VRFSeed,
};
use stacks_common::types::net::PeerAddress;
use stacks_common::types::StacksEpochId;
-use stacks_common::util::get_epoch_time_ms;
-use stacks_common::util::get_epoch_time_secs;
use stacks_common::util::hash::{to_hex, Hash160, Sha256Sum};
use stacks_common::util::secp256k1::Secp256k1PrivateKey;
-use stacks_common::util::vrf::VRFPublicKey;
+use stacks_common::util::vrf::{VRFProof, VRFPublicKey};
+use stacks_common::util::{get_epoch_time_ms, get_epoch_time_secs};
-use crate::burnchains::bitcoin_regtest_controller::OngoingBlockCommit;
-use crate::burnchains::bitcoin_regtest_controller::{addr2str, BitcoinRegtestController};
+use super::{BurnchainController, Config, EventDispatcher, Keychain};
+use crate::burnchains::bitcoin_regtest_controller::{
+ addr2str, BitcoinRegtestController, OngoingBlockCommit,
+};
use crate::burnchains::make_bitcoin_indexer;
-use crate::run_loop::neon::Counters;
-use crate::run_loop::neon::RunLoop;
+use crate::run_loop::neon::{Counters, RunLoop};
use crate::run_loop::RegisteredKey;
-use crate::ChainTip;
-
-use super::{BurnchainController, Config, EventDispatcher, Keychain};
use crate::syncctl::PoxSyncWatchdogComms;
-use stacks::monitoring;
-
-use stacks_common::types::chainstate::{StacksBlockId, StacksPrivateKey};
-use stacks_common::util::vrf::VRFProof;
-
-use clarity::vm::ast::ASTRules;
-use clarity::vm::types::PrincipalData;
-use clarity::vm::types::QualifiedContractIdentifier;
+use crate::ChainTip;
pub const RELAYER_MAX_BUFFER: usize = 100;
const VRF_MOCK_MINER_KEY: u64 = 1;
diff --git a/testnet/stacks-node/src/node.rs b/testnet/stacks-node/src/node.rs
index 69d8a51097..b63b4ddbc1 100644
--- a/testnet/stacks-node/src/node.rs
+++ b/testnet/stacks-node/src/node.rs
@@ -1,11 +1,26 @@
+use std::collections::{HashMap, HashSet};
use std::convert::TryFrom;
use std::net::SocketAddr;
-use std::{collections::HashMap, collections::HashSet, env};
-use std::{thread, thread::JoinHandle, time};
+use std::thread::JoinHandle;
+use std::{env, thread, time};
+use clarity::vm::database::BurnStateDB;
+use rand::RngCore;
+use stacks::burnchains::bitcoin::BitcoinNetworkType;
+use stacks::burnchains::db::BurnchainDB;
+use stacks::burnchains::{PoxConstants, Txid};
+use stacks::chainstate::burn::db::sortdb::SortitionDB;
+use stacks::chainstate::burn::operations::leader_block_commit::{
+ RewardSetInfo, BURN_BLOCK_MINED_AT_MODULUS,
+};
+use stacks::chainstate::burn::operations::{
+ BlockstackOperationType, LeaderBlockCommitOp, LeaderKeyRegisterOp,
+};
use stacks::chainstate::burn::ConsensusHash;
+use stacks::chainstate::stacks::address::PoxAddress;
use stacks::chainstate::stacks::db::{
- ChainStateBootData, ClarityTx, StacksChainState, StacksHeaderInfo,
+ ChainStateBootData, ChainstateAccountBalance, ChainstateAccountLockup, ChainstateBNSName,
+ ChainstateBNSNamespace, ClarityTx, StacksChainState, StacksEpochReceipt, StacksHeaderInfo,
};
use stacks::chainstate::stacks::events::{
StacksTransactionEvent, StacksTransactionReceipt, TransactionOrigin,
@@ -14,54 +29,28 @@ use stacks::chainstate::stacks::{
CoinbasePayload, StacksBlock, StacksMicroblock, StacksTransaction, StacksTransactionSigner,
TransactionAnchorMode, TransactionPayload, TransactionVersion,
};
-use stacks::chainstate::{burn::db::sortdb::SortitionDB, stacks::db::StacksEpochReceipt};
use stacks::core::mempool::MemPoolDB;
use stacks::core::STACKS_EPOCH_2_1_MARKER;
use stacks::cost_estimates::metrics::UnitMetric;
use stacks::cost_estimates::UnitEstimator;
-use stacks::net::atlas::AttachmentInstance;
-use stacks::net::{
- atlas::{AtlasConfig, AtlasDB},
- db::PeerDB,
- p2p::PeerNetwork,
- stackerdb::StackerDBs,
- Error as NetError, RPCHandlerArgs,
-};
+use stacks::net::atlas::{AtlasConfig, AtlasDB, AttachmentInstance};
+use stacks::net::db::PeerDB;
+use stacks::net::p2p::PeerNetwork;
+use stacks::net::stackerdb::StackerDBs;
+use stacks::net::{Error as NetError, RPCHandlerArgs};
use stacks::util_lib::strings::UrlString;
-use stacks::{
- burnchains::db::BurnchainDB,
- burnchains::PoxConstants,
- chainstate::burn::operations::{
- leader_block_commit::{RewardSetInfo, BURN_BLOCK_MINED_AT_MODULUS},
- BlockstackOperationType, LeaderBlockCommitOp, LeaderKeyRegisterOp,
- },
-};
-use stacks::{
- burnchains::Txid,
- chainstate::stacks::db::{
- ChainstateAccountBalance, ChainstateAccountLockup, ChainstateBNSName,
- ChainstateBNSNamespace,
- },
-};
-use stacks_common::types::chainstate::TrieHash;
-use stacks_common::types::chainstate::{BlockHeaderHash, BurnchainHeaderHash, VRFSeed};
+use stacks_common::types::chainstate::{BlockHeaderHash, BurnchainHeaderHash, TrieHash, VRFSeed};
use stacks_common::types::net::PeerAddress;
use stacks_common::util::get_epoch_time_secs;
use stacks_common::util::hash::Sha256Sum;
use stacks_common::util::secp256k1::Secp256k1PrivateKey;
use stacks_common::util::vrf::VRFPublicKey;
-use crate::run_loop;
-use crate::{genesis_data::USE_TEST_GENESIS_CHAINSTATE, run_loop::RegisteredKey};
-
-use crate::burnchains::make_bitcoin_indexer;
-
use super::{BurnchainController, BurnchainTip, Config, EventDispatcher, Keychain, Tenure};
-use clarity::vm::database::BurnStateDB;
-use stacks::burnchains::bitcoin::BitcoinNetworkType;
-
-use rand::RngCore;
-use stacks::chainstate::stacks::address::PoxAddress;
+use crate::burnchains::make_bitcoin_indexer;
+use crate::genesis_data::USE_TEST_GENESIS_CHAINSTATE;
+use crate::run_loop;
+use crate::run_loop::RegisteredKey;
#[derive(Debug, Clone)]
pub struct ChainTip {
diff --git a/testnet/stacks-node/src/run_loop/helium.rs b/testnet/stacks-node/src/run_loop/helium.rs
index 436ff1bca5..c7212d4132 100644
--- a/testnet/stacks-node/src/run_loop/helium.rs
+++ b/testnet/stacks-node/src/run_loop/helium.rs
@@ -1,11 +1,11 @@
+use stacks::chainstate::stacks::db::ClarityTx;
+use stacks_common::types::chainstate::BurnchainHeaderHash;
+
use super::RunLoopCallbacks;
use crate::burnchains::Error as BurnchainControllerError;
use crate::{
BitcoinRegtestController, BurnchainController, ChainTip, Config, MocknetController, Node,
};
-use stacks::chainstate::stacks::db::ClarityTx;
-
-use stacks_common::types::chainstate::BurnchainHeaderHash;
/// RunLoop is coordinating a simulated burnchain and some simulated nodes
/// taking turns in producing blocks.
diff --git a/testnet/stacks-node/src/run_loop/mod.rs b/testnet/stacks-node/src/run_loop/mod.rs
index 0f8c8ffb58..bc76a128ca 100644
--- a/testnet/stacks-node/src/run_loop/mod.rs
+++ b/testnet/stacks-node/src/run_loop/mod.rs
@@ -1,25 +1,20 @@
pub mod helium;
pub mod neon;
-use crate::{BurnchainController, BurnchainTip, ChainTip, Tenure};
-
+use clarity::vm::costs::ExecutionCost;
+use clarity::vm::database::BurnStateDB;
+use stacks::burnchains::{PoxConstants, Txid};
use stacks::chainstate::stacks::db::StacksChainState;
+use stacks::chainstate::stacks::events::StacksTransactionReceipt;
use stacks::chainstate::stacks::{
- TransactionAuth, TransactionPayload, TransactionSpendingCondition,
+ StacksBlock, TransactionAuth, TransactionPayload, TransactionSpendingCondition,
};
+use stacks_common::types::chainstate::StacksBlockId;
use stacks_common::util::vrf::VRFPublicKey;
-use clarity::vm::database::BurnStateDB;
-
use crate::stacks::chainstate::coordinator::BlockEventDispatcher;
use crate::stacks::chainstate::stacks::index::ClarityMarfTrieId;
-use crate::EventDispatcher;
-use clarity::vm::costs::ExecutionCost;
-use stacks::burnchains::PoxConstants;
-use stacks::burnchains::Txid;
-use stacks::chainstate::stacks::events::StacksTransactionReceipt;
-use stacks::chainstate::stacks::StacksBlock;
-use stacks_common::types::chainstate::StacksBlockId;
+use crate::{BurnchainController, BurnchainTip, ChainTip, EventDispatcher, Tenure};
macro_rules! info_blue {
($($arg:tt)*) => ({
diff --git a/testnet/stacks-node/src/run_loop/neon.rs b/testnet/stacks-node/src/run_loop/neon.rs
index b3bfe0785f..3688acb153 100644
--- a/testnet/stacks-node/src/run_loop/neon.rs
+++ b/testnet/stacks-node/src/run_loop/neon.rs
@@ -1,19 +1,12 @@
-use std::cmp;
-use std::sync::atomic::{AtomicBool, Ordering};
-
#[cfg(test)]
use std::sync::atomic::AtomicU64;
-
+use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::mpsc::sync_channel;
-
-use std::sync::Arc;
-use std::sync::Mutex;
-use std::thread;
+use std::sync::{Arc, Mutex};
use std::thread::JoinHandle;
+use std::{cmp, thread};
-use stacks_common::deps_common::ctrlc as termination;
-use stacks_common::deps_common::ctrlc::SignalId;
-
+use libc;
use stacks::burnchains::bitcoin::address::{BitcoinAddress, LegacyBitcoinAddressType};
use stacks::burnchains::Burnchain;
use stacks::chainstate::burn::db::sortdb::SortitionDB;
@@ -25,31 +18,29 @@ use stacks::chainstate::coordinator::{
ChainsCoordinatorConfig, CoordinatorCommunication, Error as coord_error,
};
use stacks::chainstate::stacks::db::{ChainStateBootData, StacksChainState};
+use stacks::chainstate::stacks::miner::{signal_mining_blocked, signal_mining_ready, MinerStatus};
use stacks::core::StacksEpochId;
use stacks::net::atlas::{AtlasConfig, AtlasDB, Attachment};
use stacks::util_lib::db::Error as db_error;
+use stacks_common::deps_common::ctrlc as termination;
+use stacks_common::deps_common::ctrlc::SignalId;
+use stacks_common::types::PublicKey;
+use stacks_common::util::hash::Hash160;
+use stacks_common::util::{get_epoch_time_secs, sleep_ms};
use stx_genesis::GenesisData;
use super::RunLoopCallbacks;
use crate::burnchains::make_bitcoin_indexer;
use crate::monitoring::start_serving_monitoring_metrics;
-use crate::neon_node::Globals;
-use crate::neon_node::StacksNode;
-use crate::neon_node::BLOCK_PROCESSOR_STACK_SIZE;
-use crate::neon_node::RELAYER_MAX_BUFFER;
-use crate::node::use_test_genesis_chainstate;
+use crate::neon_node::{Globals, StacksNode, BLOCK_PROCESSOR_STACK_SIZE, RELAYER_MAX_BUFFER};
+use crate::node::{
+ get_account_balances, get_account_lockups, get_names, get_namespaces,
+ use_test_genesis_chainstate,
+};
use crate::syncctl::{PoxSyncWatchdog, PoxSyncWatchdogComms};
use crate::{
- node::{get_account_balances, get_account_lockups, get_names, get_namespaces},
run_loop, BitcoinRegtestController, BurnchainController, Config, EventDispatcher, Keychain,
};
-use stacks::chainstate::stacks::miner::{signal_mining_blocked, signal_mining_ready, MinerStatus};
-use stacks_common::util::get_epoch_time_secs;
-use stacks_common::util::sleep_ms;
-
-use libc;
-use stacks_common::types::PublicKey;
-use stacks_common::util::hash::Hash160;
pub const STDERR: i32 = 2;
#[cfg(test)]
diff --git a/testnet/stacks-node/src/stacks_events.rs b/testnet/stacks-node/src/stacks_events.rs
index 882891398f..f63b17a6ab 100644
--- a/testnet/stacks-node/src/stacks_events.rs
+++ b/testnet/stacks-node/src/stacks_events.rs
@@ -1,11 +1,11 @@
+use std::io::prelude::*;
+use std::io::BufReader;
+use std::net::{TcpListener, TcpStream};
+
use chrono::{SecondsFormat, Utc};
use lazy_static::lazy_static;
use regex::Regex;
use serde_json::{json, Value};
-use std::io::prelude::*;
-use std::io::BufReader;
-use std::net::TcpListener;
-use std::net::TcpStream;
const DEFAULT_ADDR: &str = "127.0.0.1:3700";
diff --git a/testnet/stacks-node/src/syncctl.rs b/testnet/stacks-node/src/syncctl.rs
index 87b082f2af..85a3404c42 100644
--- a/testnet/stacks-node/src/syncctl.rs
+++ b/testnet/stacks-node/src/syncctl.rs
@@ -1,18 +1,14 @@
use std::collections::VecDeque;
+use std::sync::atomic::{AtomicBool, AtomicU64, Ordering};
+use std::sync::Arc;
use stacks::burnchains::{Burnchain, Error as burnchain_error};
use stacks::chainstate::stacks::db::StacksChainState;
-use stacks_common::util::get_epoch_time_secs;
-use stacks_common::util::sleep_ms;
+use stacks_common::util::{get_epoch_time_secs, sleep_ms};
use crate::burnchains::BurnchainTip;
use crate::Config;
-use std::sync::{
- atomic::{AtomicBool, AtomicU64, Ordering},
- Arc,
-};
-
// amount of time to wait for an inv or download sync to complete.
// These _really should_ complete before the PoX sync watchdog permits processing the next reward
// cycle, so this number is intentionally high (like, there's something really wrong with your
diff --git a/testnet/stacks-node/src/tenure.rs b/testnet/stacks-node/src/tenure.rs
index 011e1fbcd3..882a65d06b 100644
--- a/testnet/stacks-node/src/tenure.rs
+++ b/testnet/stacks-node/src/tenure.rs
@@ -1,7 +1,3 @@
-/// Only used by the Helium (Mocknet) node
-use super::node::ChainTip;
-use super::{BurnchainTip, Config};
-
use std::thread;
use std::time::{Duration, Instant};
@@ -11,15 +7,20 @@ use stacks::burnchains::PoxConstants;
use stacks::chainstate::burn::db::sortdb::SortitionDB;
use stacks::chainstate::burn::db::sortdb::SortitionDBConn;
use stacks::chainstate::stacks::db::StacksChainState;
+use stacks::chainstate::stacks::miner::BlockBuilderSettings;
use stacks::chainstate::stacks::{
- miner::BlockBuilderSettings, StacksBlock, StacksBlockBuilder, StacksMicroblock,
- StacksPrivateKey, StacksPublicKey, StacksTransaction,
+ StacksBlock, StacksBlockBuilder, StacksMicroblock, StacksPrivateKey, StacksPublicKey,
+ StacksTransaction,
};
use stacks::core::mempool::MemPoolDB;
use stacks_common::types::chainstate::VRFSeed;
use stacks_common::util::hash::Hash160;
use stacks_common::util::vrf::VRFProof;
+/// Only used by the Helium (Mocknet) node
+use super::node::ChainTip;
+use super::{BurnchainTip, Config};
+
pub struct TenureArtifacts {
pub anchored_block: StacksBlock,
pub microblocks: Vec,
diff --git a/testnet/stacks-node/src/tests/bitcoin_regtest.rs b/testnet/stacks-node/src/tests/bitcoin_regtest.rs
index ff9cc45767..fdb09dd22c 100644
--- a/testnet/stacks-node/src/tests/bitcoin_regtest.rs
+++ b/testnet/stacks-node/src/tests/bitcoin_regtest.rs
@@ -1,10 +1,8 @@
+use std::env;
+use std::io::{BufRead, BufReader};
use std::process::{Child, Command, Stdio};
-use crate::config::InitialBalance;
-use crate::helium::RunLoop;
-use crate::tests::to_addr;
-use crate::Config;
-
+use clarity::vm::costs::ExecutionCost;
use stacks::chainstate::burn::operations::BlockstackOperationType::{
LeaderBlockCommit, LeaderKeyRegister,
};
@@ -13,9 +11,10 @@ use stacks::core::StacksEpochId;
use stacks_common::util::hash::hex_bytes;
use super::PUBLISH_CONTRACT;
-use clarity::vm::costs::ExecutionCost;
-use std::env;
-use std::io::{BufRead, BufReader};
+use crate::config::InitialBalance;
+use crate::helium::RunLoop;
+use crate::tests::to_addr;
+use crate::Config;
pub enum BitcoinCoreError {
SpawnFailed(String),
diff --git a/testnet/stacks-node/src/tests/epoch_205.rs b/testnet/stacks-node/src/tests/epoch_205.rs
index 50601eb3da..60577cb690 100644
--- a/testnet/stacks-node/src/tests/epoch_205.rs
+++ b/testnet/stacks-node/src/tests/epoch_205.rs
@@ -1,54 +1,40 @@
use std::collections::HashMap;
-use std::env;
+use std::convert::TryFrom;
use std::sync::atomic::Ordering;
-use std::thread;
+use std::{env, thread};
+use clarity::vm::costs::ExecutionCost;
use clarity::vm::types::PrincipalData;
use clarity::vm::ContractName;
-use stacks::burnchains::Burnchain;
-use stacks::burnchains::Txid;
-use stacks::chainstate::burn::operations::BlockstackOperationType;
+use stacks::burnchains::{Burnchain, Txid};
+use stacks::chainstate::burn::operations::leader_block_commit::BURN_BLOCK_MINED_AT_MODULUS;
+use stacks::chainstate::burn::operations::{BlockstackOperationType, LeaderBlockCommitOp};
+use stacks::chainstate::stacks::address::PoxAddress;
use stacks::chainstate::stacks::db::StacksChainState;
-use stacks::chainstate::stacks::StacksBlockHeader;
-use stacks::chainstate::stacks::StacksPrivateKey;
-use stacks::chainstate::stacks::StacksTransaction;
-use stacks::chainstate::stacks::TransactionPayload;
-use stacks::core::StacksEpoch;
-use stacks::core::StacksEpochId;
+use stacks::chainstate::stacks::{
+ StacksBlockHeader, StacksPrivateKey, StacksTransaction, TransactionPayload,
+};
+use stacks::core;
use stacks::core::{
- PEER_VERSION_EPOCH_1_0, PEER_VERSION_EPOCH_2_0, PEER_VERSION_EPOCH_2_05, PEER_VERSION_EPOCH_2_1,
+ StacksEpoch, StacksEpochId, PEER_VERSION_EPOCH_1_0, PEER_VERSION_EPOCH_2_0,
+ PEER_VERSION_EPOCH_2_05, PEER_VERSION_EPOCH_2_1,
};
use stacks_common::codec::StacksMessageCodec;
-use stacks_common::types::chainstate::BlockHeaderHash;
-use stacks_common::types::chainstate::BurnchainHeaderHash;
-use stacks_common::types::chainstate::StacksAddress;
+use stacks_common::types::chainstate::{
+ BlockHeaderHash, BurnchainHeaderHash, StacksAddress, VRFSeed,
+};
use stacks_common::util::hash::hex_bytes;
use stacks_common::util::sleep_ms;
-use std::convert::TryFrom;
-use crate::config::EventKeyType;
-use crate::config::EventObserverConfig;
-use crate::config::InitialBalance;
-use crate::neon;
+use crate::config::{EventKeyType, EventObserverConfig, InitialBalance};
use crate::tests::bitcoin_regtest::BitcoinCoreController;
-use crate::tests::make_contract_call;
-use crate::tests::make_contract_call_mblock_only;
-use crate::tests::make_contract_publish;
-use crate::tests::make_contract_publish_microblock_only;
use crate::tests::neon_integrations::*;
-use crate::tests::run_until_burnchain_height;
-use crate::tests::select_transactions_where;
-use crate::tests::to_addr;
-use crate::BitcoinRegtestController;
-use crate::BurnchainController;
-use crate::Keychain;
-use stacks::core;
-
-use clarity::vm::costs::ExecutionCost;
-use stacks::chainstate::burn::operations::leader_block_commit::BURN_BLOCK_MINED_AT_MODULUS;
-use stacks::chainstate::burn::operations::LeaderBlockCommitOp;
-use stacks::chainstate::stacks::address::PoxAddress;
-use stacks_common::types::chainstate::VRFSeed;
+use crate::tests::{
+ make_contract_call, make_contract_call_mblock_only, make_contract_publish,
+ make_contract_publish_microblock_only, run_until_burnchain_height, select_transactions_where,
+ to_addr,
+};
+use crate::{neon, BitcoinRegtestController, BurnchainController, Keychain};
#[test]
#[ignore]
diff --git a/testnet/stacks-node/src/tests/epoch_21.rs b/testnet/stacks-node/src/tests/epoch_21.rs
index 12f00bf066..fb73916964 100644
--- a/testnet/stacks-node/src/tests/epoch_21.rs
+++ b/testnet/stacks-node/src/tests/epoch_21.rs
@@ -1,75 +1,50 @@
-use std::collections::HashMap;
-use std::collections::HashSet;
-use std::env;
-use std::thread;
-
-use stacks::burnchains::Burnchain;
-use stacks::chainstate::stacks::db::StacksChainState;
-use stacks::chainstate::stacks::StacksBlockHeader;
-use stacks_common::types::chainstate::StacksAddress;
-use stacks_common::util::secp256k1::Secp256k1PrivateKey;
-
-use crate::config::Config;
-use crate::config::EventKeyType;
-use crate::config::EventObserverConfig;
-use crate::config::InitialBalance;
-use crate::neon;
-use crate::neon::RunLoopCounter;
-use crate::tests::bitcoin_regtest::BitcoinCoreController;
-use crate::tests::neon_integrations::*;
-use crate::tests::*;
-use crate::BitcoinRegtestController;
-use crate::BurnchainController;
-use stacks::core;
-
-use stacks::chainstate::burn::db::sortdb::SortitionDB;
-use stacks::chainstate::burn::operations::leader_block_commit::BURN_BLOCK_MINED_AT_MODULUS;
-use stacks::chainstate::burn::operations::leader_block_commit::OUTPUTS_PER_COMMIT;
-use stacks::chainstate::burn::operations::BlockstackOperationType;
-use stacks::chainstate::burn::operations::LeaderBlockCommitOp;
-use stacks::chainstate::burn::operations::PreStxOp;
-use stacks::chainstate::burn::operations::TransferStxOp;
-
-use stacks::chainstate::stacks::address::PoxAddress;
+use std::collections::{HashMap, HashSet};
+use std::{env, thread};
+use clarity::vm::types::{PrincipalData, QualifiedContractIdentifier};
+use clarity::vm::ClarityVersion;
use stacks::burnchains::bitcoin::address::{
BitcoinAddress, LegacyBitcoinAddressType, SegwitBitcoinAddress,
};
use stacks::burnchains::bitcoin::BitcoinNetworkType;
-use stacks::burnchains::PoxConstants;
-use stacks::burnchains::Txid;
-
-use crate::stacks_common::address::AddressHashMode;
-use crate::stacks_common::types::Address;
-use crate::stacks_common::util::hash::{bytes_to_hex, hex_bytes};
-
-use stacks_common::types::chainstate::BlockHeaderHash;
-use stacks_common::types::chainstate::BurnchainHeaderHash;
-use stacks_common::types::chainstate::VRFSeed;
-use stacks_common::types::PrivateKey;
-use stacks_common::util::hash::Hash160;
-use stacks_common::util::hash::Sha256Sum;
-use stacks_common::util::secp256k1::Secp256k1PublicKey;
-
+use stacks::burnchains::{Burnchain, PoxConstants, Txid};
+use stacks::chainstate::burn::db::sortdb::SortitionDB;
+use stacks::chainstate::burn::operations::leader_block_commit::{
+ BURN_BLOCK_MINED_AT_MODULUS, OUTPUTS_PER_COMMIT,
+};
+use stacks::chainstate::burn::operations::{
+ BlockstackOperationType, LeaderBlockCommitOp, PreStxOp, TransferStxOp,
+};
use stacks::chainstate::coordinator::comm::CoordinatorChannels;
-use stacks::chainstate::stacks::miner::set_mining_spend_amount;
-use stacks::chainstate::stacks::miner::signal_mining_blocked;
-use stacks::chainstate::stacks::miner::signal_mining_ready;
-
+use stacks::chainstate::stacks::address::PoxAddress;
+use stacks::chainstate::stacks::db::StacksChainState;
+use stacks::chainstate::stacks::miner::{
+ set_mining_spend_amount, signal_mining_blocked, signal_mining_ready,
+};
+use stacks::chainstate::stacks::StacksBlockHeader;
use stacks::clarity_cli::vm_execute as execute;
-
-use clarity::vm::types::{PrincipalData, QualifiedContractIdentifier};
-use clarity::vm::ClarityVersion;
+use stacks::core;
use stacks::core::BURNCHAIN_TX_SEARCH_WINDOW;
+use stacks::util_lib::boot::boot_code_id;
+use stacks_common::types::chainstate::{
+ BlockHeaderHash, BurnchainHeaderHash, StacksAddress, StacksBlockId, VRFSeed,
+};
+use stacks_common::types::PrivateKey;
+use stacks_common::util::hash::{Hash160, Sha256Sum};
+use stacks_common::util::secp256k1::{Secp256k1PrivateKey, Secp256k1PublicKey};
+use stacks_common::util::sleep_ms;
use crate::burnchains::bitcoin_regtest_controller::UTXO;
+use crate::config::{Config, EventKeyType, EventObserverConfig, InitialBalance};
+use crate::neon::RunLoopCounter;
use crate::operations::BurnchainOpSigner;
-use crate::Keychain;
-
-use stacks_common::util::sleep_ms;
-
-use stacks::util_lib::boot::boot_code_id;
-use stacks_common::types::chainstate::StacksBlockId;
+use crate::stacks_common::address::AddressHashMode;
+use crate::stacks_common::types::Address;
+use crate::stacks_common::util::hash::{bytes_to_hex, hex_bytes};
+use crate::tests::bitcoin_regtest::BitcoinCoreController;
+use crate::tests::neon_integrations::*;
+use crate::tests::*;
+use crate::{neon, BitcoinRegtestController, BurnchainController, Keychain};
const MINER_BURN_PUBLIC_KEY: &'static str =
"03dc62fe0b8964d01fc9ca9a5eec0e22e557a12cc656919e648f04e0b26fea5faa";
diff --git a/testnet/stacks-node/src/tests/epoch_22.rs b/testnet/stacks-node/src/tests/epoch_22.rs
index a0bab09e58..4e817452b9 100644
--- a/testnet/stacks-node/src/tests/epoch_22.rs
+++ b/testnet/stacks-node/src/tests/epoch_22.rs
@@ -1,46 +1,32 @@
use std::collections::HashMap;
-use std::env;
-use std::thread;
+use std::{env, thread};
-use stacks::burnchains::Burnchain;
+use clarity::vm::types::PrincipalData;
+use clarity::vm::ClarityVersion;
+use stacks::burnchains::{Burnchain, PoxConstants};
use stacks::chainstate::stacks::address::PoxAddress;
use stacks::chainstate::stacks::db::StacksChainState;
-use stacks::chainstate::stacks::miner::signal_mining_blocked;
-use stacks::chainstate::stacks::miner::signal_mining_ready;
+use stacks::chainstate::stacks::miner::{signal_mining_blocked, signal_mining_ready};
+use stacks::clarity_cli::vm_execute as execute;
+use stacks::core;
use stacks::core::STACKS_EPOCH_MAX;
-use stacks_common::types::chainstate::StacksAddress;
+use stacks::util_lib::boot::boot_code_id;
+use stacks_common::types::chainstate::{StacksAddress, StacksBlockId};
use stacks_common::types::PrivateKey;
+use stacks_common::util::hash::Hash160;
+use stacks_common::util::secp256k1::Secp256k1PublicKey;
+use stacks_common::util::sleep_ms;
-use crate::config::EventKeyType;
-use crate::config::EventObserverConfig;
-use crate::config::InitialBalance;
-use crate::neon;
+use super::neon_integrations::get_account;
+use crate::config::{EventKeyType, EventObserverConfig, InitialBalance};
use crate::neon_node::StacksNode;
+use crate::stacks_common::types::Address;
+use crate::stacks_common::util::hash::bytes_to_hex;
use crate::tests::bitcoin_regtest::BitcoinCoreController;
use crate::tests::epoch_21::wait_pox_stragglers;
use crate::tests::neon_integrations::*;
use crate::tests::*;
-use crate::BitcoinRegtestController;
-use crate::BurnchainController;
-use stacks::core;
-
-use super::neon_integrations::get_account;
-use crate::stacks_common::types::Address;
-use crate::stacks_common::util::hash::bytes_to_hex;
-use stacks::burnchains::PoxConstants;
-
-use stacks_common::util::hash::Hash160;
-use stacks_common::util::secp256k1::Secp256k1PublicKey;
-
-use stacks::clarity_cli::vm_execute as execute;
-
-use clarity::vm::types::PrincipalData;
-use clarity::vm::ClarityVersion;
-
-use stacks_common::util::sleep_ms;
-
-use stacks::util_lib::boot::boot_code_id;
-use stacks_common::types::chainstate::StacksBlockId;
+use crate::{neon, BitcoinRegtestController, BurnchainController};
#[test]
#[ignore]
diff --git a/testnet/stacks-node/src/tests/epoch_23.rs b/testnet/stacks-node/src/tests/epoch_23.rs
index 2b4d817e10..73a731a5bc 100644
--- a/testnet/stacks-node/src/tests/epoch_23.rs
+++ b/testnet/stacks-node/src/tests/epoch_23.rs
@@ -14,28 +14,19 @@
// along with this program. If not, see .
use std::collections::HashMap;
-use std::env;
-use std::thread;
+use std::{env, thread};
-use clarity::vm::types::QualifiedContractIdentifier;
-use stacks::burnchains::Burnchain;
+use clarity::vm::types::{PrincipalData, QualifiedContractIdentifier};
+use stacks::burnchains::{Burnchain, PoxConstants};
+use stacks::core;
use stacks::core::STACKS_EPOCH_MAX;
use stacks_common::util::sleep_ms;
-use crate::config::EventKeyType;
-use crate::config::EventObserverConfig;
-use crate::config::InitialBalance;
-use crate::neon;
+use crate::config::{EventKeyType, EventObserverConfig, InitialBalance};
use crate::tests::bitcoin_regtest::BitcoinCoreController;
use crate::tests::neon_integrations::*;
use crate::tests::*;
-use crate::BitcoinRegtestController;
-use crate::BurnchainController;
-use stacks::core;
-
-use stacks::burnchains::PoxConstants;
-
-use clarity::vm::types::PrincipalData;
+use crate::{neon, BitcoinRegtestController, BurnchainController};
#[test]
#[ignore]
diff --git a/testnet/stacks-node/src/tests/epoch_24.rs b/testnet/stacks-node/src/tests/epoch_24.rs
index a3dd6f95e2..97f9744223 100644
--- a/testnet/stacks-node/src/tests/epoch_24.rs
+++ b/testnet/stacks-node/src/tests/epoch_24.rs
@@ -13,12 +13,9 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
-use crate::config::{EventKeyType, EventObserverConfig, InitialBalance};
-use crate::tests::neon_integrations::{
- get_account, get_chain_info, get_pox_info, neon_integration_test_conf, next_block_and_wait,
- submit_tx, test_observer, wait_for_runloop,
-};
-use crate::tests::{make_contract_call, to_addr};
+use std::collections::HashMap;
+use std::{env, thread};
+
use clarity::boot_util::boot_code_id;
use clarity::vm::types::PrincipalData;
use clarity::vm::{ClarityVersion, Value};
@@ -28,23 +25,26 @@ use stacks::chainstate::stacks::address::PoxAddress;
use stacks::chainstate::stacks::boot::RawRewardSetEntry;
use stacks::chainstate::stacks::db::StacksChainState;
use stacks::chainstate::stacks::{Error, StacksTransaction, TransactionPayload};
-use stacks_common::types::chainstate::{StacksAddress, StacksBlockId, StacksPrivateKey};
-use stacks_common::util::hash::{bytes_to_hex, hex_bytes, Hash160};
-use stacks_common::util::secp256k1::Secp256k1PublicKey;
-use std::collections::HashMap;
-use std::{env, thread};
-
-use crate::tests::bitcoin_regtest::BitcoinCoreController;
-use crate::{neon, BitcoinRegtestController, BurnchainController};
use stacks::clarity_cli::vm_execute as execute;
use stacks::core;
-
use stacks_common::address::{AddressHashMode, C32_ADDRESS_VERSION_TESTNET_SINGLESIG};
use stacks_common::codec::StacksMessageCodec;
use stacks_common::consts::STACKS_EPOCH_MAX;
+use stacks_common::types::chainstate::{StacksAddress, StacksBlockId, StacksPrivateKey};
use stacks_common::types::Address;
+use stacks_common::util::hash::{bytes_to_hex, hex_bytes, Hash160};
+use stacks_common::util::secp256k1::Secp256k1PublicKey;
use stacks_common::util::sleep_ms;
+use crate::config::{EventKeyType, EventObserverConfig, InitialBalance};
+use crate::tests::bitcoin_regtest::BitcoinCoreController;
+use crate::tests::neon_integrations::{
+ get_account, get_chain_info, get_pox_info, neon_integration_test_conf, next_block_and_wait,
+ submit_tx, test_observer, wait_for_runloop,
+};
+use crate::tests::{make_contract_call, to_addr};
+use crate::{neon, BitcoinRegtestController, BurnchainController};
+
#[cfg(test)]
pub fn get_reward_set_entries_at_block(
state: &mut StacksChainState,
diff --git a/testnet/stacks-node/src/tests/integrations.rs b/testnet/stacks-node/src/tests/integrations.rs
index dfa15ed945..c2057d6430 100644
--- a/testnet/stacks-node/src/tests/integrations.rs
+++ b/testnet/stacks-node/src/tests/integrations.rs
@@ -2,51 +2,44 @@ use std::collections::HashMap;
use std::fmt::Write;
use std::sync::Mutex;
-use reqwest;
-
-use crate::config::InitialBalance;
-use crate::helium::RunLoop;
-use crate::tests::make_sponsored_stacks_transfer_on_testnet;
+use clarity::vm::analysis::contract_interface_builder::{
+ build_contract_interface, ContractInterface,
+};
+use clarity::vm::analysis::mem_type_check;
use clarity::vm::costs::ExecutionCost;
-use clarity::vm::types::StacksAddressExtensions;
-use clarity::vm::ClarityVersion;
-use clarity::vm::{
- analysis::{
- contract_interface_builder::{build_contract_interface, ContractInterface},
- mem_type_check,
- },
- types::{QualifiedContractIdentifier, ResponseData, TupleData},
- Value,
+use clarity::vm::types::{
+ QualifiedContractIdentifier, ResponseData, StacksAddressExtensions, TupleData,
};
+use clarity::vm::{ClarityVersion, Value};
+use reqwest;
use stacks::burnchains::Address;
-use stacks::chainstate::stacks::db::blocks::MINIMUM_TX_FEE_RATE_PER_BYTE;
+use stacks::chainstate::stacks::db::blocks::{MemPoolRejection, MINIMUM_TX_FEE_RATE_PER_BYTE};
+use stacks::chainstate::stacks::db::StacksChainState;
use stacks::chainstate::stacks::{
- db::blocks::MemPoolRejection, db::StacksChainState, StacksBlockHeader, StacksPrivateKey,
- StacksTransaction,
+ StacksBlockHeader, StacksPrivateKey, StacksTransaction, TokenTransferMemo,
+ TransactionContractCall, TransactionPayload,
};
-use stacks::chainstate::stacks::{TokenTransferMemo, TransactionContractCall, TransactionPayload};
use stacks::clarity_vm::clarity::ClarityConnection;
use stacks::core::mempool::MAXIMUM_MEMPOOL_TX_CHAINING;
-use stacks::core::StacksEpoch;
-use stacks::core::StacksEpochId;
-use stacks::core::PEER_VERSION_EPOCH_2_0;
-use stacks::core::PEER_VERSION_EPOCH_2_05;
-use stacks::core::PEER_VERSION_EPOCH_2_1;
-use stacks::net::api::{
- callreadonly::CallReadOnlyRequestBody, getaccount::AccountEntryResponse,
- getcontractsrc::ContractSrcResponse, getistraitimplemented::GetIsTraitImplementedResponse,
+use stacks::core::{
+ StacksEpoch, StacksEpochId, PEER_VERSION_EPOCH_2_0, PEER_VERSION_EPOCH_2_05,
+ PEER_VERSION_EPOCH_2_1,
};
+use stacks::net::api::callreadonly::CallReadOnlyRequestBody;
+use stacks::net::api::getaccount::AccountEntryResponse;
+use stacks::net::api::getcontractsrc::ContractSrcResponse;
+use stacks::net::api::getistraitimplemented::GetIsTraitImplementedResponse;
use stacks_common::codec::StacksMessageCodec;
-use stacks_common::types::chainstate::{StacksAddress, VRFSeed};
-use stacks_common::util::hash::Sha256Sum;
-use stacks_common::util::hash::{hex_bytes, to_hex};
-
-use stacks_common::types::chainstate::StacksBlockId;
+use stacks_common::types::chainstate::{StacksAddress, StacksBlockId, VRFSeed};
+use stacks_common::util::hash::{hex_bytes, to_hex, Sha256Sum};
use super::{
make_contract_call, make_contract_publish, make_stacks_transfer, to_addr, ADDR_4, SK_1, SK_2,
SK_3,
};
+use crate::config::InitialBalance;
+use crate::helium::RunLoop;
+use crate::tests::make_sponsored_stacks_transfer_on_testnet;
const OTHER_CONTRACT: &'static str = "
(define-data-var x uint u0)
diff --git a/testnet/stacks-node/src/tests/mempool.rs b/testnet/stacks-node/src/tests/mempool.rs
index 1b65aa37e4..d55c024aa0 100644
--- a/testnet/stacks-node/src/tests/mempool.rs
+++ b/testnet/stacks-node/src/tests/mempool.rs
@@ -1,38 +1,35 @@
-use std::convert::From;
-use std::convert::TryFrom;
+use std::convert::{From, TryFrom};
use std::sync::Mutex;
+use clarity::vm::costs::ExecutionCost;
use clarity::vm::database::NULL_BURN_STATE_DB;
-use clarity::vm::{
- representations::ContractName, types::PrincipalData, types::QualifiedContractIdentifier,
- types::StandardPrincipalData, Value,
-};
-use stacks::chainstate::stacks::TransactionAnchorMode;
+use clarity::vm::representations::ContractName;
+use clarity::vm::types::{PrincipalData, QualifiedContractIdentifier, StandardPrincipalData};
+use clarity::vm::Value;
+use stacks::chainstate::stacks::db::blocks::MemPoolRejection;
use stacks::chainstate::stacks::{
- db::blocks::MemPoolRejection, Error as ChainstateError, StacksBlockHeader,
- StacksMicroblockHeader, StacksPrivateKey, StacksPublicKey, StacksTransaction,
- StacksTransactionSigner, TokenTransferMemo, TransactionAuth, TransactionPayload,
- TransactionSpendingCondition, TransactionVersion, C32_ADDRESS_VERSION_MAINNET_SINGLESIG,
+ Error as ChainstateError, StacksBlockHeader, StacksMicroblockHeader, StacksPrivateKey,
+ StacksPublicKey, StacksTransaction, StacksTransactionSigner, TokenTransferMemo,
+ TransactionAnchorMode, TransactionAuth, TransactionPayload, TransactionSpendingCondition,
+ TransactionVersion, C32_ADDRESS_VERSION_MAINNET_SINGLESIG,
};
use stacks::core::mempool::MemPoolDB;
-use stacks::core::CHAIN_ID_TESTNET;
+use stacks::core::{StacksEpochId, CHAIN_ID_TESTNET};
use stacks::cost_estimates::metrics::UnitMetric;
use stacks::cost_estimates::UnitEstimator;
use stacks::net::Error as NetError;
use stacks_common::address::AddressHashMode;
use stacks_common::codec::StacksMessageCodec;
use stacks_common::types::chainstate::{BlockHeaderHash, StacksAddress};
-use stacks_common::util::{hash::*, secp256k1::*};
-
-use crate::helium::RunLoop;
-use crate::Keychain;
-use clarity::vm::costs::ExecutionCost;
-use stacks::core::StacksEpochId;
+use stacks_common::util::hash::*;
+use stacks_common::util::secp256k1::*;
use super::{
make_coinbase, make_contract_call, make_contract_publish, make_poison, make_stacks_transfer,
serialize_sign_standard_single_sig_tx_anchor_mode_version, to_addr, SK_1, SK_2,
};
+use crate::helium::RunLoop;
+use crate::Keychain;
const FOO_CONTRACT: &'static str = "(define-public (foo) (ok 1))
(define-public (bar (x uint)) (ok x))";
diff --git a/testnet/stacks-node/src/tests/mod.rs b/testnet/stacks-node/src/tests/mod.rs
index b87ed2c739..03f61b5e4c 100644
--- a/testnet/stacks-node/src/tests/mod.rs
+++ b/testnet/stacks-node/src/tests/mod.rs
@@ -2,41 +2,36 @@ use std::convert::TryInto;
use std::sync::atomic::AtomicU64;
use std::sync::Arc;
-use rand::RngCore;
-
use clarity::vm::costs::ExecutionCost;
use clarity::vm::database::BurnStateDB;
use clarity::vm::events::STXEventType;
use clarity::vm::types::PrincipalData;
use clarity::vm::{ClarityName, ContractName, Value};
+use rand::RngCore;
use stacks::chainstate::burn::ConsensusHash;
+use stacks::chainstate::stacks::db::StacksChainState;
use stacks::chainstate::stacks::events::StacksTransactionEvent;
+use stacks::chainstate::stacks::miner::{BlockBuilderSettings, StacksMicroblockBuilder};
use stacks::chainstate::stacks::{
- db::StacksChainState, miner::BlockBuilderSettings, miner::StacksMicroblockBuilder,
CoinbasePayload, StacksBlock, StacksMicroblock, StacksMicroblockHeader, StacksPrivateKey,
StacksPublicKey, StacksTransaction, StacksTransactionSigner, TokenTransferMemo,
TransactionAnchorMode, TransactionAuth, TransactionContractCall, TransactionPayload,
TransactionPostConditionMode, TransactionSmartContract, TransactionSpendingCondition,
TransactionVersion, C32_ADDRESS_VERSION_TESTNET_SINGLESIG,
};
-use stacks::core::CHAIN_ID_TESTNET;
+use stacks::core::{StacksEpoch, StacksEpochExtension, StacksEpochId, CHAIN_ID_TESTNET};
use stacks::util_lib::strings::StacksString;
+use stacks_common::address::AddressHashMode;
use stacks_common::codec::StacksMessageCodec;
use stacks_common::types::chainstate::StacksAddress;
use stacks_common::util::get_epoch_time_secs;
-use stacks_common::util::hash::hex_bytes;
-use stacks_common::{address::AddressHashMode, util::hash::to_hex};
-
-use crate::helium::RunLoop;
-use crate::tests::neon_integrations::get_chain_info;
-use crate::tests::neon_integrations::next_block_and_wait;
-use crate::BitcoinRegtestController;
-use stacks::core::StacksEpoch;
-use stacks::core::StacksEpochExtension;
-use stacks::core::StacksEpochId;
+use stacks_common::util::hash::{hex_bytes, to_hex};
use super::burnchains::bitcoin_regtest_controller::ParsedUTXO;
use super::Config;
+use crate::helium::RunLoop;
+use crate::tests::neon_integrations::{get_chain_info, next_block_and_wait};
+use crate::BitcoinRegtestController;
mod atlas;
mod bitcoin_regtest;
diff --git a/testnet/stacks-node/src/tests/neon_integrations.rs b/testnet/stacks-node/src/tests/neon_integrations.rs
index 049b92e92a..e9664e46dc 100644
--- a/testnet/stacks-node/src/tests/neon_integrations.rs
+++ b/testnet/stacks-node/src/tests/neon_integrations.rs
@@ -1,30 +1,37 @@
-use std::cmp;
-use std::fs;
+use std::collections::{HashMap, HashSet};
+use std::convert::TryFrom;
use std::path::Path;
-use std::sync::mpsc;
-use std::sync::Arc;
+use std::sync::atomic::{AtomicU64, Ordering};
+use std::sync::{mpsc, Arc};
use std::time::{Duration, Instant};
-use std::{
- collections::HashMap,
- collections::HashSet,
- sync::atomic::{AtomicU64, Ordering},
-};
-use std::{env, thread};
-
-use rusqlite::types::ToSql;
+use std::{cmp, env, fs, thread};
+use clarity::vm::ast::stack_depth_checker::AST_CALL_STACK_DEPTH_BUFFER;
+use clarity::vm::ast::ASTRules;
use clarity::vm::costs::ExecutionCost;
use clarity::vm::types::PrincipalData;
-use clarity::vm::ClarityVersion;
-use clarity::vm::Value;
+use clarity::vm::{ClarityName, ClarityVersion, ContractName, Value, MAX_CALL_STACK_DEPTH};
+use rand::Rng;
+use rusqlite::types::ToSql;
use stacks::burnchains::bitcoin::address::{BitcoinAddress, LegacyBitcoinAddressType};
use stacks::burnchains::bitcoin::BitcoinNetworkType;
-use stacks::burnchains::Txid;
-use stacks::burnchains::{Address, Burnchain, PoxConstants};
+use stacks::burnchains::db::BurnchainDB;
+use stacks::burnchains::{Address, Burnchain, PoxConstants, Txid};
+use stacks::chainstate::burn::db::sortdb::SortitionDB;
use stacks::chainstate::burn::operations::{
BlockstackOperationType, DelegateStxOp, PreStxOp, TransferStxOp,
};
+use stacks::chainstate::burn::ConsensusHash;
use stacks::chainstate::coordinator::comm::CoordinatorChannels;
+use stacks::chainstate::stacks::db::StacksChainState;
+use stacks::chainstate::stacks::miner::{
+ signal_mining_blocked, signal_mining_ready, TransactionErrorEvent, TransactionEvent,
+ TransactionSuccessEvent,
+};
+use stacks::chainstate::stacks::{
+ StacksBlock, StacksBlockHeader, StacksMicroblock, StacksMicroblockHeader, StacksPrivateKey,
+ StacksPublicKey, StacksTransaction, TransactionContractCall, TransactionPayload,
+};
use stacks::clarity_cli::vm_execute as execute;
use stacks::core;
use stacks::core::{
@@ -32,75 +39,43 @@ use stacks::core::{
BLOCK_LIMIT_MAINNET_21, CHAIN_ID_TESTNET, HELIUM_BLOCK_LIMIT_20, PEER_VERSION_EPOCH_1_0,
PEER_VERSION_EPOCH_2_0, PEER_VERSION_EPOCH_2_05, PEER_VERSION_EPOCH_2_1,
};
-use stacks::net::api::{
- getaccount::AccountEntryResponse, getcontractsrc::ContractSrcResponse,
- getinfo::RPCPeerInfoData, getpoxinfo::RPCPoxInfoData,
- gettransaction_unconfirmed::UnconfirmedTransactionResponse, postblock::StacksBlockAcceptedData,
- postfeerate::RPCFeeEstimateResponse, posttransaction::PostTransactionRequestBody,
+use stacks::net::api::getaccount::AccountEntryResponse;
+use stacks::net::api::getcontractsrc::ContractSrcResponse;
+use stacks::net::api::getinfo::RPCPeerInfoData;
+use stacks::net::api::getpoxinfo::RPCPoxInfoData;
+use stacks::net::api::gettransaction_unconfirmed::UnconfirmedTransactionResponse;
+use stacks::net::api::postblock::StacksBlockAcceptedData;
+use stacks::net::api::postfeerate::RPCFeeEstimateResponse;
+use stacks::net::api::posttransaction::PostTransactionRequestBody;
+use stacks::net::atlas::{
+ AtlasConfig, AtlasDB, GetAttachmentResponse, GetAttachmentsInvResponse,
+ MAX_ATTACHMENT_INV_PAGES_PER_REQUEST,
};
-use stacks::net::atlas::GetAttachmentResponse;
-use stacks::net::atlas::GetAttachmentsInvResponse;
-use stacks::net::atlas::{AtlasConfig, AtlasDB, MAX_ATTACHMENT_INV_PAGES_PER_REQUEST};
use stacks::util_lib::boot::boot_code_id;
-use stacks::{
- burnchains::db::BurnchainDB,
- chainstate::{burn::ConsensusHash, stacks::StacksMicroblock},
-};
-use stacks::{
- chainstate::stacks::{
- db::StacksChainState, StacksBlock, StacksBlockHeader, StacksMicroblockHeader,
- StacksPrivateKey, StacksPublicKey, StacksTransaction, TransactionContractCall,
- TransactionPayload,
- },
- util_lib::db::query_row_columns,
- util_lib::db::query_rows,
- util_lib::db::u64_to_sql,
-};
+use stacks::util_lib::db::{query_row_columns, query_rows, u64_to_sql};
use stacks_common::codec::StacksMessageCodec;
use stacks_common::types::chainstate::{
BlockHeaderHash, BurnchainHeaderHash, StacksAddress, StacksBlockId,
};
-use stacks_common::util::hash::Hash160;
-use stacks_common::util::hash::{bytes_to_hex, hex_bytes, to_hex};
-use stacks_common::util::secp256k1::Secp256k1PrivateKey;
-use stacks_common::util::secp256k1::Secp256k1PublicKey;
+use stacks_common::util::hash::{bytes_to_hex, hex_bytes, to_hex, Hash160};
+use stacks_common::util::secp256k1::{Secp256k1PrivateKey, Secp256k1PublicKey};
use stacks_common::util::{get_epoch_time_ms, get_epoch_time_secs, sleep_ms};
-use crate::{
- burnchains::bitcoin_regtest_controller::BitcoinRPCRequest,
- burnchains::bitcoin_regtest_controller::UTXO, config::EventKeyType,
- config::EventObserverConfig, config::InitialBalance, neon, operations::BurnchainOpSigner,
- syncctl::PoxSyncWatchdogComms, BitcoinRegtestController, BurnchainController, Config,
- ConfigFile, Keychain,
-};
-
-use crate::util::hash::{MerkleTree, Sha512Trunc256Sum};
-use crate::util::secp256k1::MessageSignature;
-
-use rand::Rng;
-
use super::bitcoin_regtest::BitcoinCoreController;
use super::{
make_contract_call, make_contract_publish, make_contract_publish_microblock_only,
make_microblock, make_stacks_transfer, make_stacks_transfer_mblock_only, to_addr, ADDR_4, SK_1,
SK_2,
};
-
-use crate::config::FeeEstimatorName;
-use crate::tests::SK_3;
-use clarity::vm::ast::stack_depth_checker::AST_CALL_STACK_DEPTH_BUFFER;
-use clarity::vm::ast::ASTRules;
-use clarity::vm::ClarityName;
-use clarity::vm::ContractName;
-use clarity::vm::MAX_CALL_STACK_DEPTH;
-use stacks::chainstate::burn::db::sortdb::SortitionDB;
-use stacks::chainstate::stacks::miner::{
- signal_mining_blocked, signal_mining_ready, TransactionErrorEvent, TransactionEvent,
- TransactionSuccessEvent,
-};
-use std::convert::TryFrom;
-
+use crate::burnchains::bitcoin_regtest_controller::{BitcoinRPCRequest, UTXO};
+use crate::config::{EventKeyType, EventObserverConfig, FeeEstimatorName, InitialBalance};
+use crate::operations::BurnchainOpSigner;
use crate::stacks_common::types::PrivateKey;
+use crate::syncctl::PoxSyncWatchdogComms;
+use crate::tests::SK_3;
+use crate::util::hash::{MerkleTree, Sha512Trunc256Sum};
+use crate::util::secp256k1::MessageSignature;
+use crate::{neon, BitcoinRegtestController, BurnchainController, Config, ConfigFile, Keychain};
fn inner_neon_integration_test_conf(seed: Option>) -> (Config, StacksAddress) {
let mut conf = super::new_test_conf();
@@ -202,9 +177,8 @@ pub mod test_observer {
use std::sync::Mutex;
use std::thread;
- use tokio;
- use warp;
use warp::Filter;
+ use {tokio, warp};
use crate::event_dispatcher::{MinedBlockEvent, MinedMicroblockEvent, StackerDBChunksEvent};
diff --git a/testnet/stacks-node/src/tests/signer.rs b/testnet/stacks-node/src/tests/signer.rs
index c99cbe0129..788474085b 100644
--- a/testnet/stacks-node/src/tests/signer.rs
+++ b/testnet/stacks-node/src/tests/signer.rs
@@ -2,33 +2,26 @@ use std::sync::mpsc::{channel, Receiver, Sender};
use std::time::Duration;
use std::{env, thread};
-use crate::{
- config::{Config as NeonConfig, EventKeyType, EventObserverConfig, InitialBalance},
- neon,
- tests::{
- bitcoin_regtest::BitcoinCoreController,
- make_contract_publish,
- neon_integrations::{
- neon_integration_test_conf, next_block_and_wait, submit_tx, wait_for_runloop,
- },
- to_addr,
- },
- BitcoinRegtestController, BurnchainController,
-};
use clarity::vm::types::QualifiedContractIdentifier;
use libsigner::{RunningSigner, Signer, StackerDBEventReceiver};
use stacks::chainstate::stacks::StacksPrivateKey;
use stacks_common::types::chainstate::StacksAddress;
-use stacks_signer::{
- config::Config as SignerConfig,
- runloop::RunLoopCommand,
- utils::{build_signer_config_tomls, build_stackerdb_contract},
-};
-use tracing_subscriber::{fmt, prelude::*, EnvFilter};
-use wsts::{
- state_machine::{coordinator::Coordinator as FrostCoordinator, OperationResult},
- v2,
+use stacks_signer::config::Config as SignerConfig;
+use stacks_signer::runloop::RunLoopCommand;
+use stacks_signer::utils::{build_signer_config_tomls, build_stackerdb_contract};
+use tracing_subscriber::prelude::*;
+use tracing_subscriber::{fmt, EnvFilter};
+use wsts::state_machine::coordinator::frost::Coordinator as FrostCoordinator;
+use wsts::state_machine::OperationResult;
+use wsts::v2;
+
+use crate::config::{Config as NeonConfig, EventKeyType, EventObserverConfig, InitialBalance};
+use crate::tests::bitcoin_regtest::BitcoinCoreController;
+use crate::tests::neon_integrations::{
+ neon_integration_test_conf, next_block_and_wait, submit_tx, wait_for_runloop,
};
+use crate::tests::{make_contract_publish, to_addr};
+use crate::{neon, BitcoinRegtestController, BurnchainController};
// Helper struct for holding the btc and stx neon nodes
#[allow(dead_code)]
@@ -171,7 +164,7 @@ fn test_stackerdb_dkg() {
.collect::>();
let signer_stacks_addresses = signer_stacks_private_keys
.iter()
- .map(|key| to_addr(key).into())
+ .map(to_addr)
.collect::>();
// Setup the neon node
diff --git a/testnet/stacks-node/src/tests/stackerdb.rs b/testnet/stacks-node/src/tests/stackerdb.rs
index 13371fd9dd..a38f98b767 100644
--- a/testnet/stacks-node/src/tests/stackerdb.rs
+++ b/testnet/stacks-node/src/tests/stackerdb.rs
@@ -14,39 +14,23 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
-use std::env;
-use std::thread;
-
-use super::bitcoin_regtest::BitcoinCoreController;
-use crate::{
- burnchains::BurnchainController,
- config::EventKeyType,
- config::EventObserverConfig,
- config::InitialBalance,
- neon,
- tests::{
- make_contract_publish,
- neon_integrations::{
- neon_integration_test_conf, next_block_and_wait, submit_tx, test_observer,
- wait_for_runloop,
- },
- to_addr,
- },
- BitcoinRegtestController,
-};
-
-use stacks::chainstate::stacks::StacksPrivateKey;
+use std::{env, thread};
use clarity::vm::types::QualifiedContractIdentifier;
-
+use stacks::chainstate::stacks::StacksPrivateKey;
use stacks::libstackerdb::{StackerDBChunkAckData, StackerDBChunkData};
-
use stacks_common::types::chainstate::StacksAddress;
use stacks_common::util::hash::Sha512Trunc256Sum;
+use {reqwest, serde_json};
-use serde_json;
-
-use reqwest;
+use super::bitcoin_regtest::BitcoinCoreController;
+use crate::burnchains::BurnchainController;
+use crate::config::{EventKeyType, EventObserverConfig, InitialBalance};
+use crate::tests::neon_integrations::{
+ neon_integration_test_conf, next_block_and_wait, submit_tx, test_observer, wait_for_runloop,
+};
+use crate::tests::{make_contract_publish, to_addr};
+use crate::{neon, BitcoinRegtestController};
fn post_stackerdb_chunk(
http_origin: &str,