From fe0990bdbaf5c41816923447d4296733c4520a05 Mon Sep 17 00:00:00 2001 From: Igor Markin Date: Tue, 7 Feb 2023 13:50:36 +0400 Subject: [PATCH 01/19] fix(dashmate): missing rawblock zmq message in core config (#770) --- packages/dashmate/templates/core/dash.conf.dot | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/dashmate/templates/core/dash.conf.dot b/packages/dashmate/templates/core/dash.conf.dot index 4f2f5eb7be9..bf3dd65a115 100644 --- a/packages/dashmate/templates/core/dash.conf.dot +++ b/packages/dashmate/templates/core/dash.conf.dot @@ -37,6 +37,7 @@ spentindex=1 # ZeroMQ notifications zmqpubrawtx=tcp://0.0.0.0:29998 zmqpubrawtxlock=tcp://0.0.0.0:29998 +zmqpubrawblock=tcp://0.0.0.0:29998 zmqpubhashblock=tcp://0.0.0.0:29998 zmqpubrawchainlocksig=tcp://0.0.0.0:29998 zmqpubrawchainlock=tcp://0.0.0.0:29998 From 28517672354ff451896eaade0744ecdff1284399 Mon Sep 17 00:00:00 2001 From: Mikhail Pshenichnikov Date: Mon, 20 Feb 2023 14:22:46 +0400 Subject: [PATCH 02/19] fix(dashmate): undefined wallet for dash-cli (#786) --- packages/dashmate/templates/core/dash.conf.dot | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/dashmate/templates/core/dash.conf.dot b/packages/dashmate/templates/core/dash.conf.dot index bf3dd65a115..3bc0af78e87 100644 --- a/packages/dashmate/templates/core/dash.conf.dot +++ b/packages/dashmate/templates/core/dash.conf.dot @@ -10,6 +10,7 @@ debug={{=it.core.debug }} server=1 rpcuser={{=it.core.rpc.user}} rpcpassword={{=it.core.rpc.password}} +rpcwallet=main rpcallowip=127.0.0.1 rpcallowip=172.16.0.0/12 From ba2223216131cd6b67b0ff9348ec5b2c7f15802c Mon Sep 17 00:00:00 2001 From: Lukasz Klimek <842586+lklimek@users.noreply.github.com> Date: Fri, 17 Mar 2023 18:55:32 +0100 Subject: [PATCH 03/19] feat: support .env config files in rs-drive-abci --- Cargo.lock | 144 +++++++++++++++++- packages/rs-drive-abci/.env.example | 7 +- packages/rs-drive-abci/Cargo.toml | 4 + packages/rs-drive-abci/src/abci/config.rs | 119 +++++++++++++++ packages/rs-drive-abci/src/abci/error.rs | 2 + packages/rs-drive-abci/src/abci/messages.rs | 6 +- packages/rs-drive-abci/src/abci/mod.rs | 6 +- .../src/abci/{app.rs => server.rs} | 59 ++++--- packages/rs-drive-abci/src/config.rs | 107 +++++++++++-- packages/rs-drive-abci/src/error/mod.rs | 9 +- packages/rs-drive-abci/src/main.rs | 68 +++++++++ packages/rs-drive-abci/src/platform.rs | 2 +- packages/rs-drive-nodejs/src/lib.rs | 9 +- packages/rs-drive/src/drive/config.rs | 6 +- 14 files changed, 496 insertions(+), 52 deletions(-) create mode 100644 packages/rs-drive-abci/src/abci/config.rs rename packages/rs-drive-abci/src/abci/{app.rs => server.rs} (56%) create mode 100644 packages/rs-drive-abci/src/main.rs diff --git a/Cargo.lock b/Cargo.lock index 22183ff4241..043f4edd7c6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -523,6 +523,43 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "clap" +version = "4.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3d7ae14b20b94cb02149ed21a86c423859cbe18dc7ed69845cace50e52b40a5" +dependencies = [ + "bitflags", + "clap_derive", + "clap_lex", + "is-terminal", + "once_cell", + "strsim", + "termcolor", +] + +[[package]] +name = "clap_derive" +version = "4.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44bec8e5c9d09e439c4335b1af0abaab56dcf3b94999a936e1bb47b9134288f0" +dependencies = [ + "heck 0.4.1", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "350b9cf31731f9957399229e9b2adc51eeabdfbe9d71d9a0552275fd12710d09" +dependencies = [ + "os_str_bytes", +] + [[package]] name = "codespan-reporting" version = "0.11.1" @@ -593,7 +630,7 @@ checksum = "b01d6de93b2b6c65e17c634a26653a29d107b3c98c607c765bf38d041531cd8f" dependencies = [ "atty", "cast", - "clap", + "clap 2.34.0", "criterion-plot", "csv", "itertools", @@ -909,6 +946,12 @@ dependencies = [ "subtle", ] +[[package]] +name = "dotenvy" +version = "0.15.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03d8c417d7a8cb362e0c37e5d815f5eb7c37f79ff93707329d5a194e42e54ca0" + [[package]] name = "downcast" version = "0.11.0" @@ -1009,10 +1052,13 @@ dependencies = [ "bytes", "chrono", "ciborium", + "clap 4.1.8", "dashcore", "dashcore-rpc", + "dotenvy", "dpp", "drive", + "envy", "flex-error", "hex", "itertools", @@ -1023,6 +1069,7 @@ dependencies = [ "rust_decimal_macros", "serde", "serde_json", + "serde_with", "structopt", "tempfile", "tenderdash-abci", @@ -1101,6 +1148,36 @@ dependencies = [ "termcolor", ] +[[package]] +name = "envy" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f47e0157f2cb54f5ae1bd371b30a2ae4311e1c028f575cd4e81de7353215965" +dependencies = [ + "serde", +] + +[[package]] +name = "errno" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" +dependencies = [ + "errno-dragonfly", + "libc", + "winapi", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", + "libc", +] + [[package]] name = "error-chain" version = "0.12.4" @@ -1443,6 +1520,12 @@ dependencies = [ "libc", ] +[[package]] +name = "hermit-abi" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" + [[package]] name = "hex" version = "0.4.3" @@ -1550,6 +1633,28 @@ dependencies = [ "serde", ] +[[package]] +name = "io-lifetimes" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfa919a82ea574332e2de6e74b4c36e74d41982b335080fa59d4ef31be20fdf3" +dependencies = [ + "libc", + "windows-sys 0.45.0", +] + +[[package]] +name = "is-terminal" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21b6b32576413a8e69b90e952e4a026476040d81017b80445deda5f2d3921857" +dependencies = [ + "hermit-abi 0.3.1", + "io-lifetimes", + "rustix", + "windows-sys 0.45.0", +] + [[package]] name = "iso8601" version = "0.4.2" @@ -1746,6 +1851,12 @@ dependencies = [ "cc", ] +[[package]] +name = "linux-raw-sys" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" + [[package]] name = "lock_api" version = "0.4.9" @@ -2180,6 +2291,12 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" +[[package]] +name = "os_str_bytes" +version = "6.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee" + [[package]] name = "output_vt100" version = "0.1.3" @@ -2671,6 +2788,20 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" +[[package]] +name = "rustix" +version = "0.36.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd5c6ff11fecd55b40746d1995a02f2eb375bf8c00d192d521ee09f42bef37bc" +dependencies = [ + "bitflags", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys", + "windows-sys 0.45.0", +] + [[package]] name = "rustversion" version = "1.0.11" @@ -2848,9 +2979,9 @@ dependencies = [ [[package]] name = "serde_with" -version = "2.2.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30d904179146de381af4c93d3af6ca4984b3152db687dacb9c3c35e86f39809c" +checksum = "85456ffac572dc8826334164f2fb6fb40a7c766aebe195a2a21ee69ee2885ecf" dependencies = [ "base64 0.13.1", "chrono", @@ -2864,9 +2995,9 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "2.2.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1966009f3c05f095697c537312f5415d1e3ed31ce0a56942bac4c771c5c335e" +checksum = "7cbcd6104f8a4ab6af7f6be2a0da6be86b9de3c401f6e86bb856ab2af739232f" dependencies = [ "darling", "proc-macro2", @@ -3001,7 +3132,7 @@ version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c6b5c64445ba8094a6ab0c3cd2ad323e07171012d9c98b0b15651daf1787a10" dependencies = [ - "clap", + "clap 2.34.0", "lazy_static", "structopt-derive", ] @@ -3126,6 +3257,7 @@ dependencies = [ "thiserror", "tracing", "tracing-subscriber", + "url", ] [[package]] diff --git a/packages/rs-drive-abci/.env.example b/packages/rs-drive-abci/.env.example index c0afd31ff42..1a83904b959 100644 --- a/packages/rs-drive-abci/.env.example +++ b/packages/rs-drive-abci/.env.example @@ -1,6 +1,5 @@ # ABCI host and port to listen -ABCI_HOST=0.0.0.0 -ABCI_PORT=26658 +ABCI_BIND_ADDRESS="tcp://0.0.0.0:26658" DB_PATH=./db @@ -29,7 +28,7 @@ INITIAL_CORE_CHAINLOCKED_HEIGHT= # https://github.com/dashevo/dashcore-lib/blob/286c33a9d29d33f05d874c47a9b33764a0be0cf1/lib/constants/index.js#L42-L57 VALIDATOR_SET_LLMQ_TYPE=100 - +VALIDATOR_SET_QUORUM_ROTATION_BLOCK_COUNT=1024 # DPNS Contract DPNS_MASTER_PUBLIC_KEY= @@ -69,3 +68,5 @@ LOG_STATE_REPOSITORY=false NODE_ENV=production TENDERDASH_P2P_PORT=26656 + +QUORUM_SIZE=5 diff --git a/packages/rs-drive-abci/Cargo.toml b/packages/rs-drive-abci/Cargo.toml index 39512dcbb29..0dd105ca521 100644 --- a/packages/rs-drive-abci/Cargo.toml +++ b/packages/rs-drive-abci/Cargo.toml @@ -16,6 +16,7 @@ ciborium = { git = "https://github.com/qrayven/ciborium", branch = "feat-ser-nul chrono = "0.4.20" serde = { version = "1.0.152", features = ["derive"] } serde_json = { version = "1.0", features = ["preserve_order"] } +serde_with = { version = "2.3.1", features = ["hex"], default-features = false } drive = { path = "../rs-drive", features = ["fixtures-and-mocks"] } thiserror = "1.0.30" rand = "0.8.5" @@ -41,6 +42,9 @@ tracing = { version = "0.1.37", default-features = false } flex-error = { version = "0.4.4", default-features = false } structopt = { version = "0.3.26", optional = true, default-features = false } tracing-subscriber = { version = "0.3.16", optional = true, default-features = false } +clap = { version = "4.1.8", features = ["derive"] } +envy = { version = "0.4.2" } +dotenvy = { version = "0.15.6" } #tenderdash-abci = { git="https://github.com/dashpay/rs-tenderdash-abci" } tenderdash-abci = { path = "/home/lklimek/git/lklimek/tenderdash-abci-rs/abci" } diff --git a/packages/rs-drive-abci/src/abci/config.rs b/packages/rs-drive-abci/src/abci/config.rs new file mode 100644 index 00000000000..e8851d2cc05 --- /dev/null +++ b/packages/rs-drive-abci/src/abci/config.rs @@ -0,0 +1,119 @@ +//! Configuration of ABCI Application server + +use crate::config::FromEnv; + +use serde::{Deserialize, Serialize}; +use serde_with::serde_as; + +use super::messages::{RequiredIdentityPublicKeysSet, SystemIdentityPublicKeys}; + +/// AbciAppConfig stores configuration of the ABCI Application. +#[allow(dead_code)] +#[derive(Clone, Debug, Serialize, Deserialize, Default)] +pub struct AbciConfig { + /// Address to listen on + /// + /// Address should be an URL with scheme `tcp://` or `unix://`, for example: + /// - `tcp://127.0.0.1:1234` + /// - `unix:///var/run/abci.sock` + #[serde(rename = "abci_bind_address")] + pub bind_address: String, + /// Public keys used for system identity + /// + #[serde(flatten)] + pub keys: ContractKeys, +} + +impl FromEnv for AbciConfig {} + +#[serde_as] +#[derive(Clone, Debug, Serialize, Deserialize, Default)] + +/// Various keys +pub struct ContractKeys { + // dpns contract + /// hex-encoded + #[serde_as(as = "serde_with::hex::Hex")] + dpns_master_public_key: Vec, + /// hex-encoded + #[serde_as(as = "serde_with::hex::Hex")] + dpns_second_public_key: Vec, + + // dashpay contract + /// hex-encoded + #[serde_as(as = "serde_with::hex::Hex")] + dashpay_master_public_key: Vec, + /// hex-encoded + #[serde_as(as = "serde_with::hex::Hex")] + dashpay_second_public_key: Vec, + + // feature flags contract + /// hex-encoded + #[serde_as(as = "serde_with::hex::Hex")] + feature_flags_master_public_key: Vec, + /// hex-encoded + #[serde_as(as = "serde_with::hex::Hex")] + feature_flags_second_public_key: Vec, + + // masternode reward shares contract + /// hex-encoded + #[serde_as(as = "serde_with::hex::Hex")] + masternode_reward_shares_master_public_key: Vec, + /// hex-encoded + #[serde_as(as = "serde_with::hex::Hex")] + masternode_reward_shares_second_public_key: Vec, + + // withdrawals contract + /// hex-encoded + #[serde_as(as = "serde_with::hex::Hex")] + withdrawals_master_public_key: Vec, + /// hex-encoded + #[serde_as(as = "serde_with::hex::Hex")] + withdrawals_second_public_key: Vec, +} + +impl From for SystemIdentityPublicKeys { + fn from(keys: ContractKeys) -> Self { + Self { + masternode_reward_shares_contract_owner: RequiredIdentityPublicKeysSet { + master: keys.masternode_reward_shares_master_public_key, + high: keys.masternode_reward_shares_second_public_key, + }, + feature_flags_contract_owner: RequiredIdentityPublicKeysSet { + master: keys.feature_flags_master_public_key, + high: keys.feature_flags_second_public_key, + }, + dpns_contract_owner: RequiredIdentityPublicKeysSet { + master: keys.dpns_master_public_key, + high: keys.dpns_second_public_key, + }, + withdrawals_contract_owner: RequiredIdentityPublicKeysSet { + master: keys.withdrawals_master_public_key, + high: keys.withdrawals_second_public_key, + }, + dashpay_contract_owner: RequiredIdentityPublicKeysSet { + master: keys.dashpay_master_public_key, + high: keys.dashpay_second_public_key, + }, + } + } +} + +#[cfg(test)] +mod tests { + use std::env; + + use super::FromEnv; + + #[test] + fn test_config_from_env() { + let envfile = format!("{}/.env.example", env!("CARGO_MANIFEST_DIR")); + let envfile = std::path::PathBuf::from(envfile); + dbg!(&envfile); + + dotenvy::from_path(envfile.as_path()).expect("cannot load .env file"); + + let config = super::AbciConfig::from_env().unwrap(); + dbg!(config.keys.dashpay_master_public_key); + } +} diff --git a/packages/rs-drive-abci/src/abci/error.rs b/packages/rs-drive-abci/src/abci/error.rs index db700e75ff3..fc17fcedaca 100644 --- a/packages/rs-drive-abci/src/abci/error.rs +++ b/packages/rs-drive-abci/src/abci/error.rs @@ -1,7 +1,9 @@ use tenderdash_abci::Error as TenderdashError; +/// Error returned within ABCI server #[derive(Debug, thiserror::Error)] pub enum Error { + /// Error returned by tenderdash-abci library #[error("tenderdash: {0}")] Tenderdash(#[from] TenderdashError), } diff --git a/packages/rs-drive-abci/src/abci/messages.rs b/packages/rs-drive-abci/src/abci/messages.rs index 84d835490de..f7832aab883 100644 --- a/packages/rs-drive-abci/src/abci/messages.rs +++ b/packages/rs-drive-abci/src/abci/messages.rs @@ -55,7 +55,7 @@ pub struct InitChainRequest { } /// System identity public keys -#[derive(Serialize, Deserialize, Clone)] +#[derive(Serialize, Deserialize, Clone, Debug)] #[serde(rename_all = "camelCase")] pub struct SystemIdentityPublicKeys { /// Required public key set for masternode reward shares contract owner identity @@ -70,8 +70,10 @@ pub struct SystemIdentityPublicKeys { pub dashpay_contract_owner: RequiredIdentityPublicKeysSet, } +// impl Default for SystemIdentityPublicKeys {} + /// Required public key set for an identity -#[derive(Serialize, Deserialize, Clone)] +#[derive(Serialize, Deserialize, Clone, Debug)] #[serde(rename_all = "camelCase")] pub struct RequiredIdentityPublicKeysSet { /// Authentication key with master security level diff --git a/packages/rs-drive-abci/src/abci/mod.rs b/packages/rs-drive-abci/src/abci/mod.rs index 1aaf5d76ad6..c08f48db41a 100644 --- a/packages/rs-drive-abci/src/abci/mod.rs +++ b/packages/rs-drive-abci/src/abci/mod.rs @@ -1,3 +1,7 @@ -pub mod app; +pub mod config; +mod error; pub mod handlers; pub mod messages; +pub mod server; + +pub use error::Error; diff --git a/packages/rs-drive-abci/src/abci/app.rs b/packages/rs-drive-abci/src/abci/server.rs similarity index 56% rename from packages/rs-drive-abci/src/abci/app.rs rename to packages/rs-drive-abci/src/abci/server.rs index 72783538b9d..ddac7acc890 100644 --- a/packages/rs-drive-abci/src/abci/app.rs +++ b/packages/rs-drive-abci/src/abci/server.rs @@ -1,34 +1,48 @@ //! This module implements ABCI application server. //! -use super::messages::SystemIdentityPublicKeys; -use crate::{error::Error, platform::Platform}; +use super::config::AbciConfig; +use crate::{config::PlatformConfig, error::Error, platform::Platform}; use dpp::identity::TimestampMillis; use drive::query::TransactionArg; use std::sync::MutexGuard; -use tenderdash_abci::{proto::abci as proto, start_server, BindAddress, Server}; - -/// AbciAppConfig stores configuration of the ABCI Application. -#[allow(dead_code)] -pub struct AbciAppConfig { - bind_address: BindAddress, - system_identity_public_keys: SystemIdentityPublicKeys, -} - +use tenderdash_abci::proto::abci as proto; /// AbciApp is an implementation of ABCI Application, as defined by Tenderdash. /// /// AbciApp implements logic that should be triggered when Tenderdash performs various operations, like /// creating new proposal or finalizing new block. -pub struct AbciApp<'a> { +pub struct AbciApplication<'a> { platform: std::sync::Mutex<&'a Platform>, transaction: TransactionArg<'a, 'a>, - config: &'a AbciAppConfig, - // TODO: read from configuation? + config: AbciConfig, } -impl<'a> AbciApp<'a> { +/// Start ABCI server and process incoming connections. +/// +/// Should never return. +pub fn start(config: &PlatformConfig) -> Result<(), Error> { + let bind_address = config.abci.bind_address.clone(); + let abci_config = config.abci.clone(); + + let platform: Platform = + Platform::open(config.data_dir.to_owned(), Some(config.to_owned())).unwrap(); + + let abci = AbciApplication::new(abci_config, &platform)?; + + let server = + tenderdash_abci::start_server(&bind_address, abci).map_err(|e| super::Error::from(e))?; + + loop { + match server.handle_connection() { + Ok(_) => (), + Err(e) => tracing::error!("tenderdash connection terminated: {:?}", e), + } + } +} + +impl<'a> AbciApplication<'a> { /// Create new ABCI app - pub fn new(config: &'a AbciAppConfig, platform: &'a Platform) -> Result, Error> { - let app = AbciApp { + pub fn new(config: AbciConfig, platform: &'a Platform) -> Result, Error> { + let app = AbciApplication { platform: std::sync::Mutex::new(platform), transaction: None, config, @@ -37,11 +51,6 @@ impl<'a> AbciApp<'a> { Ok(app) } - /// Create ABCI Server for this application - pub fn bind(self) -> Result, tenderdash_abci::Error> { - start_server(&self.config.bind_address, self) - } - fn platform(&self) -> MutexGuard<&'a Platform> { self.platform.lock().unwrap() } @@ -51,7 +60,7 @@ impl<'a> AbciApp<'a> { } } -impl<'a> tenderdash_abci::Application for AbciApp<'a> { +impl<'a> tenderdash_abci::Application for AbciApplication<'a> { fn init_chain(&self, request: proto::RequestInitChain) -> proto::ResponseInitChain { let platform = self.platform(); let transaction = self.transaction(); @@ -61,11 +70,11 @@ impl<'a> tenderdash_abci::Application for AbciApp<'a> { genesis_time.nanos as u32, ) .unwrap(); - let keys = self.config.system_identity_public_keys.to_owned(); + platform .create_genesis_state( genesis_time.timestamp_millis() as TimestampMillis, - keys, + self.config.keys.clone().into(), transaction, ) .expect("create genesis state"); diff --git a/packages/rs-drive-abci/src/config.rs b/packages/rs-drive-abci/src/config.rs index 541d6f92b34..55f4d555df8 100644 --- a/packages/rs-drive-abci/src/config.rs +++ b/packages/rs-drive-abci/src/config.rs @@ -26,38 +26,82 @@ // IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +use std::path::PathBuf; + use drive::drive::config::DriveConfig; +use serde::{de::DeserializeOwned, Deserialize, Serialize}; + +use crate::{abci::config::AbciConfig, error::Error}; /// Configuration for Dash Core RPC client -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Serialize, Deserialize)] pub struct CoreRpcConfig { - /// Core RPC client url - pub url: String, + /// Core RPC client hostname or IP address + #[serde(rename = "core_json_rpc_host")] + pub host: String, + + // FIXME: fix error Configuration(Custom("invalid type: string \"9998\", expected i16")) and change port to i16 + /// Core RPC client port number + #[serde(rename = "core_json_rpc_port")] + pub port: String, /// Core RPC client username + #[serde(rename = "core_json_rpc_username")] pub username: String, /// Core RPC client password + #[serde(rename = "core_json_rpc_password")] pub password: String, } +impl CoreRpcConfig { + /// Return core address in the `host:port` format. + pub fn url(&self) -> String { + return format!("{}:{}", self.host, self.port); + } +} + /// Configuration for Dash Core related things -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Serialize, Deserialize)] pub struct CoreConfig { /// Core RPC config + #[serde(flatten)] pub rpc: CoreRpcConfig, } -/// Platform configuration -#[derive(Clone, Debug)] +/// Configurtion of Dash Platform. +/// +/// All fields in this struct can be configured using environment variables. +/// These variables can also be defined in `.env` file in the current directory +/// or its parents. You can also provide path to the .env file as a command-line argument. +/// +/// Environment variables should be renamed to `SCREAMING_SNAKE_CASE`. +/// For example, to define [`verify_sum_trees`], you should set VERIFY_SUM_TREES +/// environment variable: +/// +/// `` +/// export VERIFY_SUM_TREES=true +/// `` +/// +/// [`verify_sum_trees`]: PlatformConfig::verify_sum_trees +#[derive(Clone, Debug, Serialize, Deserialize)] +// NOTE: in renames, we use lower_snake_case, because uppercase does not work; see +// https://github.com/softprops/envy/issues/61 and https://github.com/softprops/envy/pull/69 pub struct PlatformConfig { /// Drive configuration + #[serde(flatten)] pub drive: Option, /// Dash Core config + #[serde(flatten)] pub core: CoreConfig, - /// Should we verify sum trees? Useful to set as no for tests + /// ABCI Application Server config + #[serde(flatten)] + pub abci: AbciConfig, + + /// Should we verify sum trees? Useful to set as `false` for tests + #[serde(default = "PlatformConfig::default_verify_sum_trees")] pub verify_sum_trees: bool, /// The default quorum size @@ -65,22 +109,67 @@ pub struct PlatformConfig { /// How often should quorums change? pub validator_set_quorum_rotation_block_count: u64, + + /// Path to data storage + pub data_dir: PathBuf, } +impl PlatformConfig { + // #[allow(unused)] + fn default_verify_sum_trees() -> bool { + true + } +} +/// create new object using values from environment variables +pub trait FromEnv { + /// create new object using values from environment variables + fn from_env() -> Result + where + Self: Sized + DeserializeOwned, + { + envy::from_env::().map_err(|e| Error::from(e)) + } +} + +impl FromEnv for PlatformConfig {} + impl Default for PlatformConfig { fn default() -> Self { Self { verify_sum_trees: true, - quorum_size: 100, + quorum_size: 0, validator_set_quorum_rotation_block_count: 15, drive: Default::default(), + abci: Default::default(), core: CoreConfig { rpc: CoreRpcConfig { - url: "127.0.0.1".to_owned(), + host: "127.0.0.1".to_owned(), + port: "0".to_owned(), username: "".to_owned(), password: "".to_owned(), }, }, + data_dir: PathBuf::from("/var/lib/dash-platform/data"), } } } + +#[cfg(test)] +mod tests { + use std::env; + + use super::FromEnv; + + #[test] + fn test_config_from_env() { + let envfile = format!("{}/.env.example", env!("CARGO_MANIFEST_DIR")); + let envfile = std::path::PathBuf::from(envfile); + dbg!(&envfile); + + dotenvy::from_path(envfile.as_path()).expect("cannot load .env file"); + assert_eq!("5", env::var("QUORUM_SIZE").unwrap()); + + let config = super::PlatformConfig::from_env().unwrap(); + assert_eq!(config.verify_sum_trees, true); + } +} diff --git a/packages/rs-drive-abci/src/error/mod.rs b/packages/rs-drive-abci/src/error/mod.rs index 483c54bf4dc..ac6b8a1198c 100644 --- a/packages/rs-drive-abci/src/error/mod.rs +++ b/packages/rs-drive-abci/src/error/mod.rs @@ -1,8 +1,9 @@ +use crate::abci::Error as AbciError; use crate::error::execution::ExecutionError; use crate::error::serialization::SerializationError; use drive::dpp::ProtocolError; use drive::error::Error as DriveError; - +use tracing::error; /// Execution errors module pub mod execution; @@ -12,6 +13,9 @@ pub mod serialization; /// Errors #[derive(Debug, thiserror::Error)] pub enum Error { + /// ABCI Server Error + #[error("abci: {0}")] + Abci(#[from] AbciError), /// Drive Error #[error("storage: {0}")] Drive(#[from] DriveError), @@ -24,4 +28,7 @@ pub enum Error { /// Serialization Error #[error("serialization: {0}")] Serialization(#[from] SerializationError), + /// Configuration Error + #[error("configuration: {0}")] + Configuration(#[from] envy::Error), } diff --git a/packages/rs-drive-abci/src/main.rs b/packages/rs-drive-abci/src/main.rs new file mode 100644 index 00000000000..fc6230d906e --- /dev/null +++ b/packages/rs-drive-abci/src/main.rs @@ -0,0 +1,68 @@ +use std::{panic, path::PathBuf}; + +use clap::{Parser, Subcommand}; +use drive_abci::config::{FromEnv, PlatformConfig}; + +#[derive(Debug, Parser)] +#[command( author, version, about, long_about = None)] +struct Cli { + #[command(subcommand)] + command: Commands, + /// Path to the config (.env) file. + #[arg(short, long, value_hint = clap::ValueHint::FilePath) ] + config: Option, +} + +#[derive(Debug, Subcommand)] +enum Commands { + /// Start server in foreground + #[command()] + Start {}, + /// Dump configuration + /// + /// WARNING: output can contain sensitive data! + #[command()] + Config {}, +} + +// #[derive(Debug, Args)] +// #[command(args_conflicts_with_subcommands = true)] +// struct StartArgs { +// /// Path to data directory (GroveDB) +// /// +// /// Path to the data directory, containing transactions database. +// #[arg(short, long, value_hint = clap::ValueHint::DirPath) ] +// data: std::path::PathBuf, +// } + +pub fn main() { + let cli = Cli::parse(); + let config = load_config(&cli.config); + + match cli.command { + Commands::Start {} => drive_abci::abci::server::start(&config).unwrap(), + Commands::Config {} => dump_config(&config), + } +} + +fn dump_config(config: &PlatformConfig) { + let serialized = + serde_json::to_string_pretty(config).expect("failed to generate configuration"); + + println!("{}", serialized); +} + +fn load_config(config: &Option) -> PlatformConfig { + match config { + Some(path) => { + if let Err(e) = dotenvy::from_path(path) { + panic!("cannot load config file {:?}: {}", path, e); + } + } + None => { + dotenvy::dotenv().expect("cannot load .env file"); + } + }; + + PlatformConfig::from_env().expect("cannot parse configuration file") +} diff --git a/packages/rs-drive-abci/src/platform.rs b/packages/rs-drive-abci/src/platform.rs index da4a29fea67..c9bfaa22754 100644 --- a/packages/rs-drive-abci/src/platform.rs +++ b/packages/rs-drive-abci/src/platform.rs @@ -79,7 +79,7 @@ impl Platform { let core_rpc: Box = Box::new( DefaultCoreRPC::open( - config.core.rpc.url.as_str(), + config.core.rpc.url().as_str(), config.core.rpc.username.clone(), config.core.rpc.password.clone(), ) diff --git a/packages/rs-drive-nodejs/src/lib.rs b/packages/rs-drive-nodejs/src/lib.rs index 07bc33ef6b0..415b94d87ea 100644 --- a/packages/rs-drive-nodejs/src/lib.rs +++ b/packages/rs-drive-nodejs/src/lib.rs @@ -115,10 +115,15 @@ impl PlatformWrapper { data_contracts_block_cache_size, ..Default::default() }; - + //core_addr: Vec<&str> + let core_addr: Vec<&str> = core_rpc_url.split(':').collect(); + let core_host = core_addr.first().unwrap(); + let core_port = core_addr.get(1).unwrap(); let core_config = CoreConfig { rpc: CoreRpcConfig { - url: core_rpc_url, + host: core_host.to_string(), + port: core_port.to_string(), + username: core_rpc_username, password: core_rpc_password, }, diff --git a/packages/rs-drive/src/drive/config.rs b/packages/rs-drive/src/drive/config.rs index 455d4deadd5..cdfef031902 100644 --- a/packages/rs-drive/src/drive/config.rs +++ b/packages/rs-drive/src/drive/config.rs @@ -30,6 +30,8 @@ //! Drive Configuration File //! +use serde::{Deserialize, Serialize}; + use crate::drive::config::DriveEncoding::DriveCbor; /// Boolean if GroveDB batching is enabled by default @@ -41,7 +43,7 @@ pub const DEFAULT_GROVE_HAS_RAW_ENABLED: bool = true; /// Default maximum number of contracts in cache pub const DEFAULT_DATA_CONTRACTS_CACHE_SIZE: u64 = 500; -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Serialize, Deserialize)] /// Encoding for Drive pub enum DriveEncoding { /// Drive CBOR @@ -50,7 +52,7 @@ pub enum DriveEncoding { DriveProtobuf, } -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Serialize, Deserialize)] /// Drive configuration struct pub struct DriveConfig { /// Boolean if batching is enabled From 35c2636977c349a9056e89d4ab5de5f77e8a8b86 Mon Sep 17 00:00:00 2001 From: Lukasz Klimek <842586+lklimek@users.noreply.github.com> Date: Mon, 20 Mar 2023 10:34:36 +0100 Subject: [PATCH 04/19] chore(rs-drive-abci): cli verbosity + initchain (WIP) --- Cargo.lock | 26 +++++++++++++++-- packages/rs-drive-abci/.env.example | 2 +- packages/rs-drive-abci/Cargo.toml | 9 +++++- packages/rs-drive-abci/src/abci/server.rs | 11 +++++++- packages/rs-drive-abci/src/config.rs | 4 +-- packages/rs-drive-abci/src/main.rs | 34 +++++++++++++++++++++-- 6 files changed, 77 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 043f4edd7c6..151f4ffe496 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1892,6 +1892,15 @@ dependencies = [ "serde_json", ] +[[package]] +name = "matchers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" +dependencies = [ + "regex-automata", +] + [[package]] name = "maybe-uninit" version = "2.0.0" @@ -2689,6 +2698,15 @@ dependencies = [ "regex-syntax", ] +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +dependencies = [ + "regex-syntax", +] + [[package]] name = "regex-syntax" version = "0.6.28" @@ -3249,7 +3267,7 @@ dependencies = [ [[package]] name = "tenderdash-abci" -version = "0.11.0-dev.1" +version = "0.12.0-dev.1" dependencies = [ "bytes", "prost", @@ -3262,7 +3280,7 @@ dependencies = [ [[package]] name = "tenderdash-proto" -version = "0.11.0-dev.4" +version = "0.12.0-dev.1" dependencies = [ "bytes", "flex-error", @@ -3498,8 +3516,12 @@ version = "0.3.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a6176eae26dd70d0c919749377897b54a9276bd7061339665dd68777926b5a70" dependencies = [ + "matchers", + "once_cell", + "regex", "sharded-slab", "thread_local", + "tracing", "tracing-core", ] diff --git a/packages/rs-drive-abci/.env.example b/packages/rs-drive-abci/.env.example index 1a83904b959..7201ba24b74 100644 --- a/packages/rs-drive-abci/.env.example +++ b/packages/rs-drive-abci/.env.example @@ -1,7 +1,7 @@ # ABCI host and port to listen ABCI_BIND_ADDRESS="tcp://0.0.0.0:26658" -DB_PATH=./db +DB_PATH=/tmp/db # GroveDB database file GROVEDB_LATEST_FILE=${DB_PATH}/latest_state diff --git a/packages/rs-drive-abci/Cargo.toml b/packages/rs-drive-abci/Cargo.toml index 0dd105ca521..dcfc4dd19c9 100644 --- a/packages/rs-drive-abci/Cargo.toml +++ b/packages/rs-drive-abci/Cargo.toml @@ -11,6 +11,7 @@ license = "MIT" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + [dependencies] ciborium = { git = "https://github.com/qrayven/ciborium", branch = "feat-ser-null-as-undefined" } chrono = "0.4.20" @@ -41,7 +42,9 @@ prost = { version = "0.11.6", default-features = false } tracing = { version = "0.1.37", default-features = false } flex-error = { version = "0.4.4", default-features = false } structopt = { version = "0.3.26", optional = true, default-features = false } -tracing-subscriber = { version = "0.3.16", optional = true, default-features = false } +tracing-subscriber = { version = "0.3.16", default-features = false, features = [ + "env-filter", +] } clap = { version = "4.1.8", features = ["derive"] } envy = { version = "0.4.2" } dotenvy = { version = "0.15.6" } @@ -54,3 +57,7 @@ itertools = { version = "0.10.5" } [features] default = ["fixtures-and-mocks"] fixtures-and-mocks = ["mockall"] + +[[bin]] +name = "rs-drive-abci" +path = "src/main.rs" diff --git a/packages/rs-drive-abci/src/abci/server.rs b/packages/rs-drive-abci/src/abci/server.rs index ddac7acc890..e3e0d114dca 100644 --- a/packages/rs-drive-abci/src/abci/server.rs +++ b/packages/rs-drive-abci/src/abci/server.rs @@ -24,7 +24,7 @@ pub fn start(config: &PlatformConfig) -> Result<(), Error> { let abci_config = config.abci.clone(); let platform: Platform = - Platform::open(config.data_dir.to_owned(), Some(config.to_owned())).unwrap(); + Platform::open(config.db_path.to_owned(), Some(config.to_owned())).unwrap(); let abci = AbciApplication::new(abci_config, &platform)?; @@ -61,6 +61,15 @@ impl<'a> AbciApplication<'a> { } impl<'a> tenderdash_abci::Application for AbciApplication<'a> { + fn info(&self, request: proto::RequestInfo) -> proto::ResponseInfo { + tracing::info!("tenderdash info: {:?}", request); + proto::ResponseInfo { + app_version: 1, + version: env!("CARGO_PKG_VERSION").to_string(), + ..Default::default() + } + } + fn init_chain(&self, request: proto::RequestInitChain) -> proto::ResponseInitChain { let platform = self.platform(); let transaction = self.transaction(); diff --git a/packages/rs-drive-abci/src/config.rs b/packages/rs-drive-abci/src/config.rs index 55f4d555df8..31140047f94 100644 --- a/packages/rs-drive-abci/src/config.rs +++ b/packages/rs-drive-abci/src/config.rs @@ -111,7 +111,7 @@ pub struct PlatformConfig { pub validator_set_quorum_rotation_block_count: u64, /// Path to data storage - pub data_dir: PathBuf, + pub db_path: PathBuf, } impl PlatformConfig { @@ -149,7 +149,7 @@ impl Default for PlatformConfig { password: "".to_owned(), }, }, - data_dir: PathBuf::from("/var/lib/dash-platform/data"), + db_path: PathBuf::from("/var/lib/dash-platform/data"), } } } diff --git a/packages/rs-drive-abci/src/main.rs b/packages/rs-drive-abci/src/main.rs index fc6230d906e..cd7b1c5c999 100644 --- a/packages/rs-drive-abci/src/main.rs +++ b/packages/rs-drive-abci/src/main.rs @@ -1,7 +1,7 @@ -use std::{panic, path::PathBuf}; - use clap::{Parser, Subcommand}; use drive_abci::config::{FromEnv, PlatformConfig}; +use std::{panic, path::PathBuf}; +use tracing_subscriber::prelude::*; #[derive(Debug, Parser)] #[command( author, version, about, long_about = None)] @@ -11,6 +11,14 @@ struct Cli { /// Path to the config (.env) file. #[arg(short, long, value_hint = clap::ValueHint::FilePath) ] config: Option, + /// Enable verbose logging. Use multiple times for even more logs. + /// + /// This overrides any settings defined in RUST_LOG. + /// For more about RUST_LOG, see: + /// https://rust-lang-nursery.github.io/rust-cookbook/development_tools/debugging/config_log.html + /// + #[arg(short, long, action = clap::ArgAction::Count)] + verbose: u8, } #[derive(Debug, Subcommand)] @@ -39,6 +47,8 @@ pub fn main() { let cli = Cli::parse(); let config = load_config(&cli.config); + set_verbosity(&cli); + match cli.command { Commands::Start {} => drive_abci::abci::server::start(&config).unwrap(), Commands::Config {} => dump_config(&config), @@ -66,3 +76,23 @@ fn load_config(config: &Option) -> PlatformConfig { PlatformConfig::from_env().expect("cannot parse configuration file") } + +fn set_verbosity(cli: &Cli) { + use tracing_subscriber::*; + + let env_filter = match cli.verbose { + 0 => EnvFilter::builder() + .with_default_directive( + "error,tenderdash_abci=warn,drive_abci=warn" + .parse() + .unwrap(), + ) + .from_env_lossy(), + 1 => EnvFilter::new("error,tenderdash_abci=info,drive_abci=info"), + 2 => EnvFilter::new("info,tenderdash_abci=debug,drive_abci=debug"), + 3 => EnvFilter::new("debug,tenderdash_abci=debug,drive_abci=debug"), + _ => panic!("max verbosity level is 3"), + }; + + registry().with(fmt::layer()).with(env_filter).init(); +} From 80da548598ee7b284df1aca78ebd254ff2bb870f Mon Sep 17 00:00:00 2001 From: Lukasz Klimek <842586+lklimek@users.noreply.github.com> Date: Mon, 20 Mar 2023 13:17:05 +0100 Subject: [PATCH 05/19] chore(abci): check version on abci info() call --- Cargo.lock | 7 +- packages/rs-drive-abci/Cargo.toml | 18 ++--- packages/rs-drive-abci/src/abci/error.rs | 5 +- packages/rs-drive-abci/src/abci/mod.rs | 1 + packages/rs-drive-abci/src/abci/server.rs | 86 +++++++++++++++++++++++ packages/rs-drive-abci/src/main.rs | 4 ++ 6 files changed, 107 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 151f4ffe496..e93a42109bb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -420,7 +420,7 @@ checksum = "4acbb09d9ee8e23699b9634375c72795d095bf268439da88562cf9b501f181fa" dependencies = [ "camino", "cargo-platform", - "semver 1.0.16", + "semver 1.0.17", "serde", "serde_json", ] @@ -1067,6 +1067,7 @@ dependencies = [ "rand", "rust_decimal", "rust_decimal_macros", + "semver 1.0.17", "serde", "serde_json", "serde_with", @@ -2900,9 +2901,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.16" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58bc9567378fc7690d6b2addae4e60ac2eeea07becb2c64b9f218b53865cba2a" +checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" dependencies = [ "serde", ] diff --git a/packages/rs-drive-abci/Cargo.toml b/packages/rs-drive-abci/Cargo.toml index dcfc4dd19c9..d877e7b3abd 100644 --- a/packages/rs-drive-abci/Cargo.toml +++ b/packages/rs-drive-abci/Cargo.toml @@ -42,22 +42,24 @@ prost = { version = "0.11.6", default-features = false } tracing = { version = "0.1.37", default-features = false } flex-error = { version = "0.4.4", default-features = false } structopt = { version = "0.3.26", optional = true, default-features = false } +clap = { version = "4.1.8", optional = true, features = ["derive"] } +envy = { version = "0.4.2" } +dotenvy = { version = "0.15.6", optional = true } tracing-subscriber = { version = "0.3.16", default-features = false, features = [ "env-filter", -] } -clap = { version = "4.1.8", features = ["derive"] } -envy = { version = "0.4.2" } -dotenvy = { version = "0.15.6" } -#tenderdash-abci = { git="https://github.com/dashpay/rs-tenderdash-abci" } -tenderdash-abci = { path = "/home/lklimek/git/lklimek/tenderdash-abci-rs/abci" } +], optional = true } +semver = { version = "1.0.17", optional = true } +#tenderdash-abci = { git="https://github.com/dashpay/rs-tenderdash-abci" , optional = true } +tenderdash-abci = { path = "/home/lklimek/git/lklimek/tenderdash-abci-rs/abci", optional = true } [dev-dependencies] itertools = { version = "0.10.5" } [features] -default = ["fixtures-and-mocks"] +default = ["fixtures-and-mocks", "server"] fixtures-and-mocks = ["mockall"] - +server = ["tenderdash-abci", "clap", "dotenvy", "tracing-subscriber", "semver"] [[bin]] name = "rs-drive-abci" path = "src/main.rs" +required-features = ["server"] diff --git a/packages/rs-drive-abci/src/abci/error.rs b/packages/rs-drive-abci/src/abci/error.rs index fc17fcedaca..8b16d4cc84a 100644 --- a/packages/rs-drive-abci/src/abci/error.rs +++ b/packages/rs-drive-abci/src/abci/error.rs @@ -1,9 +1,8 @@ -use tenderdash_abci::Error as TenderdashError; - /// Error returned within ABCI server #[derive(Debug, thiserror::Error)] pub enum Error { /// Error returned by tenderdash-abci library + #[cfg(feature = "server")] #[error("tenderdash: {0}")] - Tenderdash(#[from] TenderdashError), + Tenderdash(#[from] tenderdash_abci::Error), } diff --git a/packages/rs-drive-abci/src/abci/mod.rs b/packages/rs-drive-abci/src/abci/mod.rs index c08f48db41a..7a5663eca0d 100644 --- a/packages/rs-drive-abci/src/abci/mod.rs +++ b/packages/rs-drive-abci/src/abci/mod.rs @@ -2,6 +2,7 @@ pub mod config; mod error; pub mod handlers; pub mod messages; +#[cfg(feature = "server")] pub mod server; pub use error::Error; diff --git a/packages/rs-drive-abci/src/abci/server.rs b/packages/rs-drive-abci/src/abci/server.rs index e3e0d114dca..8d5882a352d 100644 --- a/packages/rs-drive-abci/src/abci/server.rs +++ b/packages/rs-drive-abci/src/abci/server.rs @@ -6,6 +6,7 @@ use dpp::identity::TimestampMillis; use drive::query::TransactionArg; use std::sync::MutexGuard; use tenderdash_abci::proto::abci as proto; +use tracing::debug; /// AbciApp is an implementation of ABCI Application, as defined by Tenderdash. /// /// AbciApp implements logic that should be triggered when Tenderdash performs various operations, like @@ -63,6 +64,15 @@ impl<'a> AbciApplication<'a> { impl<'a> tenderdash_abci::Application for AbciApplication<'a> { fn info(&self, request: proto::RequestInfo) -> proto::ResponseInfo { tracing::info!("tenderdash info: {:?}", request); + + if !check_version(&request.abci_version, tenderdash_abci::proto::ABCI_VERSION) { + panic!( + "SemVer mismatch: Tenderdash requires ABCI version {}, our version is {}", + request.version, + tenderdash_abci::proto::ABCI_VERSION + ); + } + proto::ResponseInfo { app_version: 1, version: env!("CARGO_PKG_VERSION").to_string(), @@ -93,3 +103,79 @@ impl<'a> tenderdash_abci::Application for AbciApplication<'a> { } } } +/// Check if ABCI version required by Tenderdash matches our protobuf version. +/// +/// Match is determined based on Semantic Versioning rules, as defined for '^' operator. +fn check_version(tenderdash_abci_requirement: &str, our_abci_version: &str) -> bool { + let our_version = + semver::Version::parse(our_abci_version).expect("cannot parse version of protobuf library"); + + let requirement = String::from("^") + tenderdash_abci_requirement; + let td_version = semver::VersionReq::parse(requirement.as_str()) + .expect("cannot parse version of tenderdash server"); + + debug!( + "ABCI version check: required: {}, our: {}", + requirement, our_version + ); + + td_version.matches(&our_version) +} + +#[cfg(test)] +mod tests { + use crate::abci::server::check_version; + + #[test] + fn test_versions() { + #[derive(Debug)] + struct TestCase<'a> { + our_version: &'a str, + td_version: &'a str, + expect: bool, + } + + let test_cases = vec![ + TestCase { + td_version: "0.1.2-dev.1", + our_version: "0.1.0", + expect: false, + }, + TestCase { + td_version: "0.1.0", + our_version: "0.1.0", + expect: true, + }, + TestCase { + td_version: "0.1.0", + our_version: "0.1.2", + expect: true, + }, + TestCase { + td_version: "0.1.0-dev.1", + our_version: "0.1.0-dev.1", + expect: true, + }, + TestCase { + td_version: "0.1.0-dev.1", + our_version: "0.1.0-dev.2", + expect: true, + }, + TestCase { + td_version: "0.1.0", + our_version: "0.1.0-dev.1", + expect: false, + }, + TestCase { + td_version: "0.1.0-dev.1", + our_version: "0.1.0-dev.1", + expect: true, + }, + ]; + + for tc in test_cases { + dbg!(&tc); + assert_eq!(check_version(tc.td_version, tc.our_version,), tc.expect); + } + } +} diff --git a/packages/rs-drive-abci/src/main.rs b/packages/rs-drive-abci/src/main.rs index cd7b1c5c999..eb16756787d 100644 --- a/packages/rs-drive-abci/src/main.rs +++ b/packages/rs-drive-abci/src/main.rs @@ -1,8 +1,12 @@ +//! Main server process for RS-Drive-ABCI +//! +//! RS-Drive-ABCI server starts a single-threaded server and listens to connections from Tenderdash. use clap::{Parser, Subcommand}; use drive_abci::config::{FromEnv, PlatformConfig}; use std::{panic, path::PathBuf}; use tracing_subscriber::prelude::*; +/// Main command container for ABCI Server #[derive(Debug, Parser)] #[command( author, version, about, long_about = None)] struct Cli { From 5fb661265eb50be131eb30fcbf9f242cd07417e6 Mon Sep 17 00:00:00 2001 From: Lukasz Klimek <842586+lklimek@users.noreply.github.com> Date: Mon, 20 Mar 2023 14:33:05 +0100 Subject: [PATCH 06/19] chore(rs-drive-abci): improve log formatting on console --- Cargo.lock | 18 ++++++++++++++++++ packages/rs-drive-abci/Cargo.toml | 14 ++++++++++++-- packages/rs-drive-abci/src/abci/server.rs | 6 +++++- packages/rs-drive-abci/src/main.rs | 12 ++++++++++-- 4 files changed, 45 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e93a42109bb..33da8559a12 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1047,6 +1047,7 @@ dependencies = [ name = "drive-abci" version = "0.1.0" dependencies = [ + "atty", "base64 0.13.1", "bs58", "bytes", @@ -2103,6 +2104,16 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be" +[[package]] +name = "nu-ansi-term" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" +dependencies = [ + "overload", + "winapi", +] + [[package]] name = "num" version = "0.2.1" @@ -2316,6 +2327,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "overload" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" + [[package]] name = "pairing" version = "0.22.0" @@ -3518,6 +3535,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a6176eae26dd70d0c919749377897b54a9276bd7061339665dd68777926b5a70" dependencies = [ "matchers", + "nu-ansi-term", "once_cell", "regex", "sharded-slab", diff --git a/packages/rs-drive-abci/Cargo.toml b/packages/rs-drive-abci/Cargo.toml index d877e7b3abd..6ce1724ae5a 100644 --- a/packages/rs-drive-abci/Cargo.toml +++ b/packages/rs-drive-abci/Cargo.toml @@ -47,8 +47,10 @@ envy = { version = "0.4.2" } dotenvy = { version = "0.15.6", optional = true } tracing-subscriber = { version = "0.3.16", default-features = false, features = [ "env-filter", + "ansi", ], optional = true } semver = { version = "1.0.17", optional = true } +atty = { version = "0.2.14", optional = true } #tenderdash-abci = { git="https://github.com/dashpay/rs-tenderdash-abci" , optional = true } tenderdash-abci = { path = "/home/lklimek/git/lklimek/tenderdash-abci-rs/abci", optional = true } @@ -58,8 +60,16 @@ itertools = { version = "0.10.5" } [features] default = ["fixtures-and-mocks", "server"] fixtures-and-mocks = ["mockall"] -server = ["tenderdash-abci", "clap", "dotenvy", "tracing-subscriber", "semver"] +server = [ + "tenderdash-abci", + "clap", + "dotenvy", + "tracing-subscriber", + "semver", + "atty", +] + [[bin]] -name = "rs-drive-abci" +name = "drive-abci" path = "src/main.rs" required-features = ["server"] diff --git a/packages/rs-drive-abci/src/abci/server.rs b/packages/rs-drive-abci/src/abci/server.rs index 8d5882a352d..5a321be2014 100644 --- a/packages/rs-drive-abci/src/abci/server.rs +++ b/packages/rs-drive-abci/src/abci/server.rs @@ -33,9 +33,13 @@ pub fn start(config: &PlatformConfig) -> Result<(), Error> { tenderdash_abci::start_server(&bind_address, abci).map_err(|e| super::Error::from(e))?; loop { - match server.handle_connection() { + tracing::info!("waiting for new connection"); + let result = std::panic::catch_unwind(|| match server.handle_connection() { Ok(_) => (), Err(e) => tracing::error!("tenderdash connection terminated: {:?}", e), + }); + if let Err(_e) = result { + tracing::error!("panic: connection terminated"); } } } diff --git a/packages/rs-drive-abci/src/main.rs b/packages/rs-drive-abci/src/main.rs index eb16756787d..7524f17a3ed 100644 --- a/packages/rs-drive-abci/src/main.rs +++ b/packages/rs-drive-abci/src/main.rs @@ -3,7 +3,7 @@ //! RS-Drive-ABCI server starts a single-threaded server and listens to connections from Tenderdash. use clap::{Parser, Subcommand}; use drive_abci::config::{FromEnv, PlatformConfig}; -use std::{panic, path::PathBuf}; +use std::path::PathBuf; use tracing_subscriber::prelude::*; /// Main command container for ABCI Server @@ -52,6 +52,7 @@ pub fn main() { let config = load_config(&cli.config); set_verbosity(&cli); + install_panic_hook(); match cli.command { Commands::Start {} => drive_abci::abci::server::start(&config).unwrap(), @@ -98,5 +99,12 @@ fn set_verbosity(cli: &Cli) { _ => panic!("max verbosity level is 3"), }; - registry().with(fmt::layer()).with(env_filter).init(); + let layer = fmt::layer().with_ansi(atty::is(atty::Stream::Stdout)); + + registry().with(layer).with(env_filter).init(); +} + +/// Install panic hook to ensure that all panic logs are correctly formatted +fn install_panic_hook() { + std::panic::set_hook(Box::new(|info| tracing::error!("panic: {:?}", info))); } From ccf6d6311a159e8af7db220f6583ca96c4171102 Mon Sep 17 00:00:00 2001 From: Lukasz Klimek <842586+lklimek@users.noreply.github.com> Date: Tue, 21 Mar 2023 10:44:06 +0100 Subject: [PATCH 07/19] feat!(abci): prototype prepare_proposal --- Cargo.lock | 5 +- packages/rs-drive-abci/.env.example | 37 ++----- packages/rs-drive-abci/src/abci/config.rs | 10 ++ packages/rs-drive-abci/src/abci/error.rs | 3 + packages/rs-drive-abci/src/abci/handlers.rs | 2 + packages/rs-drive-abci/src/abci/mod.rs | 5 +- packages/rs-drive-abci/src/abci/proposal.rs | 117 ++++++++++++++++++++ packages/rs-drive-abci/src/abci/server.rs | 28 +++-- packages/rs-drive-abci/src/block.rs | 20 +++- packages/rs-drive-abci/src/main.rs | 17 ++- 10 files changed, 203 insertions(+), 41 deletions(-) create mode 100644 packages/rs-drive-abci/src/abci/proposal.rs diff --git a/Cargo.lock b/Cargo.lock index 33da8559a12..e78ce58ea2f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -463,9 +463,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.23" +version = "0.4.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f" +checksum = "4e3c5919066adf22df73762e50cffcde3a758f2a848b113b586d1f86728b673b" dependencies = [ "iana-time-zone", "js-sys", @@ -3301,6 +3301,7 @@ name = "tenderdash-proto" version = "0.12.0-dev.1" dependencies = [ "bytes", + "chrono", "flex-error", "num-derive", "num-traits", diff --git a/packages/rs-drive-abci/.env.example b/packages/rs-drive-abci/.env.example index 7201ba24b74..60d90389b1c 100644 --- a/packages/rs-drive-abci/.env.example +++ b/packages/rs-drive-abci/.env.example @@ -1,5 +1,5 @@ # ABCI host and port to listen -ABCI_BIND_ADDRESS="tcp://0.0.0.0:26658" +ABCI_BIND_ADDRESS="tcp://0.0.0.0:6658" DB_PATH=/tmp/db @@ -24,48 +24,35 @@ CORE_ZMQ_CONNECTION_RETRIES=16 NETWORK=testnet -INITIAL_CORE_CHAINLOCKED_HEIGHT= +INITIAL_CORE_CHAINLOCKED_HEIGHT=1243 # https://github.com/dashevo/dashcore-lib/blob/286c33a9d29d33f05d874c47a9b33764a0be0cf1/lib/constants/index.js#L42-L57 VALIDATOR_SET_LLMQ_TYPE=100 VALIDATOR_SET_QUORUM_ROTATION_BLOCK_COUNT=1024 # DPNS Contract -DPNS_MASTER_PUBLIC_KEY= -DPNS_SECOND_PUBLIC_KEY= +DPNS_MASTER_PUBLIC_KEY=02649a81b760e8635dd3a4fad8911388ed09d7c1680558a890180d4edc8bcece7e +DPNS_SECOND_PUBLIC_KEY=03f5ea3ab4bf594c28997eb8f83873532275ac2edd36e586b137ed42d15d510948 # Dashpay Contract -DASHPAY_MASTER_PUBLIC_KEY= -DASHPAY_SECOND_PUBLIC_KEY= +DASHPAY_MASTER_PUBLIC_KEY=022d6d70c9d24d03904713db17fb74c9201801ba0e3aed0f5d91e89df388e94aa6 +DASHPAY_SECOND_PUBLIC_KEY=028c0a26c87b2e7f1aebbbeace9e687d774e037f5b50a6905b5f6fa24495b502cd # Feature flags contract -FEATURE_FLAGS_MASTER_PUBLIC_KEY= -FEATURE_FLAGS_SECOND_PUBLIC_KEY= +FEATURE_FLAGS_MASTER_PUBLIC_KEY=034ee04c509083ecd09e76fa53e0b5331b39120c19607cd04c4f167707dbb42302 +FEATURE_FLAGS_SECOND_PUBLIC_KEY=03c755ae1b79dbcc79020aad3ccdfcb142fc6e74f1afc220fca1e275a87aa12cf8 # Masternode reward shares contract -MASTERNODE_REWARD_SHARES_MASTER_PUBLIC_KEY= -MASTERNODE_REWARD_SHARES_SECOND_PUBLIC_KEY= +MASTERNODE_REWARD_SHARES_MASTER_PUBLIC_KEY=02099cc210c7b6c7f566099046ddc92615342db326184940bf3811026ea328c85e +MASTERNODE_REWARD_SHARES_SECOND_PUBLIC_KEY=02bf55f97f189895da29824781053140ee66b2bf47760246504fbe502985096af5 # Withdrawals contract -WITHDRAWALS_MASTER_PUBLIC_KEY= -WITHDRAWALS_SECOND_PUBLIC_KEY= - -# logging -LOG_STDOUT_LEVEL=info - -LOG_PRETTY_FILE_LEVEL=silent -LOG_PRETTY_FILE_PATH=/tmp/drive-pretty.log - -LOG_JSON_FILE_LEVEL=silent -LOG_JSON_FILE_PATH=/tmp/drive-json.log - -LOG_STATE_REPOSITORY=false - -NODE_ENV=production +WITHDRAWALS_MASTER_PUBLIC_KEY=027057cdf58628635ef7b75e6b6c90dd996a16929cd68130e16b9328d429e5e03a +WITHDRAWALS_SECOND_PUBLIC_KEY=022084d827fea4823a69aa7c8d3e02fe780eaa0ef1e5e9841af395ba7e40465ab6 TENDERDASH_P2P_PORT=26656 diff --git a/packages/rs-drive-abci/src/abci/config.rs b/packages/rs-drive-abci/src/abci/config.rs index e8851d2cc05..3a6d28be643 100644 --- a/packages/rs-drive-abci/src/abci/config.rs +++ b/packages/rs-drive-abci/src/abci/config.rs @@ -22,6 +22,16 @@ pub struct AbciConfig { /// #[serde(flatten)] pub keys: ContractKeys, + + /// Height of genesis block; defaults to 1 + #[serde(default = "AbciConfig::default_genesis_height")] + pub genesis_height: i64, +} + +impl AbciConfig { + fn default_genesis_height() -> i64 { + 1 + } } impl FromEnv for AbciConfig {} diff --git a/packages/rs-drive-abci/src/abci/error.rs b/packages/rs-drive-abci/src/abci/error.rs index 8b16d4cc84a..7ac01649a27 100644 --- a/packages/rs-drive-abci/src/abci/error.rs +++ b/packages/rs-drive-abci/src/abci/error.rs @@ -1,6 +1,9 @@ /// Error returned within ABCI server #[derive(Debug, thiserror::Error)] pub enum Error { + /// Invalid system state + #[error("invalid state: {0}")] + InvalidState(String), /// Error returned by tenderdash-abci library #[cfg(feature = "server")] #[error("tenderdash: {0}")] diff --git a/packages/rs-drive-abci/src/abci/handlers.rs b/packages/rs-drive-abci/src/abci/handlers.rs index 73d957d64ab..a14c0f3519a 100644 --- a/packages/rs-drive-abci/src/abci/handlers.rs +++ b/packages/rs-drive-abci/src/abci/handlers.rs @@ -47,6 +47,7 @@ use crate::platform::Platform; /// A trait for handling the Tenderdash ABCI (Application Blockchain Interface). pub trait TenderdashAbci { /// Called with JS drive on init chain + #[deprecated = "use abci::server module"] fn init_chain( &self, request: InitChainRequest, @@ -54,6 +55,7 @@ pub trait TenderdashAbci { ) -> Result; /// Called with JS Drive on block begin + #[deprecated = "replaced with abci::serverAbciApplication::prepare_proposal()"] fn block_begin( &self, request: BlockBeginRequest, diff --git a/packages/rs-drive-abci/src/abci/mod.rs b/packages/rs-drive-abci/src/abci/mod.rs index 7a5663eca0d..33406ea166d 100644 --- a/packages/rs-drive-abci/src/abci/mod.rs +++ b/packages/rs-drive-abci/src/abci/mod.rs @@ -2,7 +2,10 @@ pub mod config; mod error; pub mod handlers; pub mod messages; +mod proposal; #[cfg(feature = "server")] -pub mod server; +mod server; +#[cfg(feature = "server")] +pub use server::start; pub use error::Error; diff --git a/packages/rs-drive-abci/src/abci/proposal.rs b/packages/rs-drive-abci/src/abci/proposal.rs new file mode 100644 index 00000000000..bc71289116e --- /dev/null +++ b/packages/rs-drive-abci/src/abci/proposal.rs @@ -0,0 +1,117 @@ +// TODO: replace `handlers.rs` with this file + +use crate::{ + block::{BlockExecutionContext, BlockStateInfo}, + error::{execution::ExecutionError, Error}, + execution::fee_pools::epoch::EpochInfo, + platform::Platform, +}; + +use dpp::util::vec::vec_to_array; +use drive::query::TransactionArg; +use tenderdash_abci::proto::{ + abci::{self as proto, ExecTxResult}, + serializers::timestamp::ToMilis, +}; + +pub trait Proposal { + fn prepare_proposal( + &self, + request: proto::RequestPrepareProposal, + transaction: TransactionArg, + ) -> Result; +} +impl Proposal for Platform { + fn prepare_proposal( + &self, + request: proto::RequestPrepareProposal, + transaction: TransactionArg, + ) -> Result { + let genesis_time_ms = if request.height == self.config.abci.genesis_height { + let block_time_ms = request.time.clone().unwrap().to_milis(); + self.drive.set_genesis_time(block_time_ms); + block_time_ms + } else { + //todo: lazy load genesis time + self.drive + .get_genesis_time(transaction) + .map_err(Error::Drive)? + .ok_or(Error::Execution(ExecutionError::DriveIncoherence( + "the genesis time must be set", + ))) + .unwrap() + }; + + // Update versions + let proposed_app_version = request.proposed_app_version; + + self.drive + .update_validator_proposed_app_version( + vec_to_array(&request.proposer_pro_tx_hash).expect("invalid proposer protxhash"), + proposed_app_version as u32, + transaction, + ) + .unwrap(); + + // Init block execution context + let block_info = BlockStateInfo::from_prepare_proposal_request(&request); + + let epoch_info = EpochInfo::from_genesis_time_and_block_info(genesis_time_ms, &block_info)?; + + // FIXME: we need to calculate total hpms based on masternode list (or remove hpmn_count if not needed) + let total_hpmns = self.config.quorum_size as u32; + let block_execution_context = BlockExecutionContext { + block_info, + epoch_info: epoch_info.clone(), + hpmn_count: total_hpmns, + }; + + // If last synced Core block height is not set instead of scanning + // number of blocks for asset unlock transactions scan only one + // on Core chain locked height by setting last_synced_core_height to the same value + // FIXME: re-enable and implement + // let last_synced_core_height = if request.last_synced_core_height == 0 { + // block_execution_context.block_info.core_chain_locked_height + // } else { + // request.last_synced_core_height + // }; + let last_synced_core_height = block_execution_context.block_info.core_chain_locked_height; + + self.block_execution_context + .replace(Some(block_execution_context)); + + self.update_broadcasted_withdrawal_transaction_statuses( + last_synced_core_height, + transaction, + )?; + + // TODO: restore withdrawal transactions logic + // let unsigned_withdrawal_transaction_bytes = self + // .fetch_and_prepare_unsigned_withdrawal_transactions( + // vec_to_array(&request.quorum_hash).expect("invalid quorum hash"), + // transaction, + // )?; + + let mut tx_results = ::prost::alloc::vec::Vec::::new(); + for tx in request.txs { + tx_results.push(mock_exec_tx(tx)) // TODO: execute transactions in a proper way + } + // TODO: implement all fields, including tx processing; for now, just leaving bare minimum + let response = proto::ResponsePrepareProposal { + app_hash: vec![0, 32], // TODO: implement + tx_results, + ..Default::default() + }; + + Ok(response) + } +} + +/// Return tx result that just copies tx to data field +fn mock_exec_tx(tx: Vec) -> ExecTxResult { + ExecTxResult { + code: 0, + data: tx.clone(), + ..Default::default() + } +} diff --git a/packages/rs-drive-abci/src/abci/server.rs b/packages/rs-drive-abci/src/abci/server.rs index 5a321be2014..e7b31867865 100644 --- a/packages/rs-drive-abci/src/abci/server.rs +++ b/packages/rs-drive-abci/src/abci/server.rs @@ -1,11 +1,11 @@ //! This module implements ABCI application server. //! use super::config::AbciConfig; -use crate::{config::PlatformConfig, error::Error, platform::Platform}; +use crate::{abci::proposal::Proposal, config::PlatformConfig, error::Error, platform::Platform}; use dpp::identity::TimestampMillis; use drive::query::TransactionArg; use std::sync::MutexGuard; -use tenderdash_abci::proto::abci as proto; +use tenderdash_abci::proto::{abci as proto, serializers::timestamp::ToMilis}; use tracing::debug; /// AbciApp is an implementation of ABCI Application, as defined by Tenderdash. /// @@ -87,16 +87,15 @@ impl<'a> tenderdash_abci::Application for AbciApplication<'a> { fn init_chain(&self, request: proto::RequestInitChain) -> proto::ResponseInitChain { let platform = self.platform(); let transaction = self.transaction(); - let genesis_time = request.time.expect("init chain REQUIRES genesis time"); - let genesis_time = chrono::NaiveDateTime::from_timestamp_opt( - genesis_time.seconds, - genesis_time.nanos as u32, - ) - .unwrap(); + + let genesis_time = request + .time + .expect("init chain REQUIRES genesis time") + .to_milis(); platform .create_genesis_state( - genesis_time.timestamp_millis() as TimestampMillis, + genesis_time as TimestampMillis, self.config.keys.clone().into(), transaction, ) @@ -106,6 +105,17 @@ impl<'a> tenderdash_abci::Application for AbciApplication<'a> { ..Default::default() } } + + fn prepare_proposal( + &self, + request: proto::RequestPrepareProposal, + ) -> proto::ResponsePrepareProposal { + let platform = self.platform(); + let transaction = self.transaction(); + platform + .prepare_proposal(request, transaction) + .expect("failed to prepare proposal") + } } /// Check if ABCI version required by Tenderdash matches our protobuf version. /// diff --git a/packages/rs-drive-abci/src/block.rs b/packages/rs-drive-abci/src/block.rs index 92b5ca09888..bf3f22a35ea 100644 --- a/packages/rs-drive-abci/src/block.rs +++ b/packages/rs-drive-abci/src/block.rs @@ -27,6 +27,10 @@ // DEALINGS IN THE SOFTWARE. // +use dpp::util::vec::vec_to_array; +use tenderdash_abci::proto::abci as proto; +use tenderdash_abci::proto::serializers::timestamp::ToMilis; + use crate::abci::messages::BlockBeginRequest; use crate::execution::fee_pools::epoch::EpochInfo; @@ -46,6 +50,7 @@ pub struct BlockStateInfo { impl BlockStateInfo { /// Given a `BlockBeginRequest` return `BlockInfo` + #[deprecated = "use from_prepare_proposal_request and from_process_proposal_request"] pub fn from_block_begin_request(block_begin_request: &BlockBeginRequest) -> BlockStateInfo { BlockStateInfo { block_height: block_begin_request.block_height, @@ -55,8 +60,21 @@ impl BlockStateInfo { core_chain_locked_height: block_begin_request.core_chain_locked_height, } } + /// Generate block state info based on Prepare Proposal request + pub fn from_prepare_proposal_request( + request: &proto::RequestPrepareProposal, + ) -> BlockStateInfo { + BlockStateInfo { + block_height: request.height as u64, + block_time_ms: request.time.clone().unwrap().to_milis(), + previous_block_time_ms: None, // TODO: implement properly + //>::into() + proposer_pro_tx_hash: vec_to_array(&request.proposer_pro_tx_hash) + .expect("invalid proposer protxhash"), + core_chain_locked_height: request.core_chain_locked_height, + } + } } - /// Block execution context pub struct BlockExecutionContext { /// Block info diff --git a/packages/rs-drive-abci/src/main.rs b/packages/rs-drive-abci/src/main.rs index 7524f17a3ed..b87bfdf2da3 100644 --- a/packages/rs-drive-abci/src/main.rs +++ b/packages/rs-drive-abci/src/main.rs @@ -17,7 +17,16 @@ struct Cli { config: Option, /// Enable verbose logging. Use multiple times for even more logs. /// - /// This overrides any settings defined in RUST_LOG. + /// Repeat `v` multiple times to increase log verbosity: + /// + /// - none - `warn` unless overriden by RUST_LOG variable + /// - `-v` - `info` from Drive, `error` from libraries + /// - `-vv` - `debug` from Drive, `info` from libraries + /// - `-vvv` - `debug` from all components + /// - `-vvvv` - `trace` from Drive, `debug` from libraries + /// - `-vvvvv` - `trace` from all components + /// + /// Note: This overrides any settings defined in RUST_LOG. /// For more about RUST_LOG, see: /// https://rust-lang-nursery.github.io/rust-cookbook/development_tools/debugging/config_log.html /// @@ -55,7 +64,7 @@ pub fn main() { install_panic_hook(); match cli.command { - Commands::Start {} => drive_abci::abci::server::start(&config).unwrap(), + Commands::Start {} => drive_abci::abci::start(&config).unwrap(), Commands::Config {} => dump_config(&config), } } @@ -96,7 +105,9 @@ fn set_verbosity(cli: &Cli) { 1 => EnvFilter::new("error,tenderdash_abci=info,drive_abci=info"), 2 => EnvFilter::new("info,tenderdash_abci=debug,drive_abci=debug"), 3 => EnvFilter::new("debug,tenderdash_abci=debug,drive_abci=debug"), - _ => panic!("max verbosity level is 3"), + 4 => EnvFilter::new("debug,tenderdash_abci=trace,drive_abci=trace"), + 5 => EnvFilter::new("trace"), + _ => panic!("max verbosity level is 5"), }; let layer = fmt::layer().with_ansi(atty::is(atty::Stream::Stdout)); From 4baaabe491dbdd9eec7e236da5a7ce2b5686ade4 Mon Sep 17 00:00:00 2001 From: Lukasz Klimek <842586+lklimek@users.noreply.github.com> Date: Wed, 22 Mar 2023 11:07:27 +0100 Subject: [PATCH 08/19] build(rs-drive-abci)!: Dockerfile updated --- packages/rs-drive-abci/Dockerfile | 219 ++++++++++++++++++++---------- 1 file changed, 149 insertions(+), 70 deletions(-) diff --git a/packages/rs-drive-abci/Dockerfile b/packages/rs-drive-abci/Dockerfile index 621b673e8eb..1ce1904db95 100644 --- a/packages/rs-drive-abci/Dockerfile +++ b/packages/rs-drive-abci/Dockerfile @@ -1,82 +1,161 @@ -# syntax = docker/dockerfile:1.3 -FROM node:16-alpine3.16 as builder +# syntax = docker/dockerfile:1.5 -ARG CARGO_BUILD_PROFILE=debug -ENV CARGO_BUILD_PROFILE ${CARGO_BUILD_PROFILE} - -RUN apk update && \ - apk --no-cache upgrade && \ - apk add --no-cache git \ - openssh-client \ - linux-headers \ - python3 \ - alpine-sdk \ - cmake \ - zeromq-dev \ - ca-certificates \ - gcc \ - clang \ - libc-dev \ - binutils \ - bash - -# Install Rust -ENV RUSTUP_HOME=/usr/local/rustup \ - CARGO_HOME=/usr/local/cargo \ - PATH=/usr/local/cargo/bin:$PATH \ - RUST_VERSION=stable - -RUN set -eux; \ - apkArch="$(apk --print-arch)"; \ - case "$apkArch" in \ - x86_64) rustArch='x86_64-unknown-linux-musl'; rustupSha256='bdf022eb7cba403d0285bb62cbc47211f610caec24589a72af70e1e900663be9' ;; \ - aarch64) rustArch='aarch64-unknown-linux-musl'; rustupSha256='89ce657fe41e83186f5a6cdca4e0fd40edab4fd41b0f9161ac6241d49fbdbbbe' ;; \ - *) echo >&2 "unsupported architecture: $apkArch"; exit 1 ;; \ - esac; \ - url="https://static.rust-lang.org/rustup/archive/1.24.3/${rustArch}/rustup-init"; \ - wget "$url"; \ - echo "${rustupSha256} *rustup-init" | sha256sum -c -; \ - chmod +x rustup-init; \ - ./rustup-init -y --no-modify-path --profile minimal --default-toolchain $RUST_VERSION --default-host ${rustArch}; \ - rm rustup-init; \ - chmod -R a+w $RUSTUP_HOME $CARGO_HOME; \ - rustup --version; \ - cargo --version; \ - rustc --version; - -WORKDIR /platform - -# Copy yarn and Cargo files -COPY .cargo /platform/.cargo -COPY .pnp.* Cargo.toml Cargo.lock rust-toolchain.toml ./ - -# Copy only necessary packages from monorepo -COPY packages/rs-dpp packages/rs-dpp -COPY packages/rs-drive packages/rs-drive -COPY packages/rs-drive-abci packages/rs-drive-abci -COPY packages/rs-platform-value packages/rs-platform-value -COPY packages/rs-drive-nodejs packages/rs-drive-nodejs -COPY packages/dapi-grpc packages/dapi-grpc -COPY packages/dashpay-contract packages/dashpay-contract -COPY packages/dpns-contract packages/dpns-contract -COPY packages/feature-flags-contract packages/feature-flags-contract -COPY packages/masternode-reward-shares-contract packages/masternode-reward-shares-contract -COPY packages/withdrawals-contract packages/withdrawals-contract -COPY packages/data-contracts packages/data-contracts +# Docker image for rs-drive-abci +# +# This image is divided into 3 stages, for better layer caching: +# - deps - includes all dependencies and some libraries +# - build - actual build process +# - release - final image +# +# We use Debian as base, because Alpine causes segmentation fault in git2 rust crate. + +# +# DEPS: INSTALL AND CACHE DEPENDENCIES +# +FROM rust:bullseye as deps LABEL maintainer="Dash Developers " LABEL description="Drive ABCI Rust" +RUN --mount=type=cache,sharing=locked,target=/var/lib/apt/lists \ + --mount=type=cache,sharing=locked,target=/var/cache/apt \ + rm -f /etc/apt/apt.conf.d/docker-clean \ + && apt-get update \ + && apt-get install --yes \ + build-essential \ + libclang-dev \ + libssl-dev \ + protobuf-compiler \ + git \ + wget \ + unzip \ + bash + +SHELL ["/bin/bash", "-c"] + +# +# Install sccache - build cache for Rust +# +ARG SCCACHE_URL="https://github.com/mozilla/sccache/releases/download/v0.4.0/sccache-v0.4.0-x86_64-unknown-linux-musl.tar.gz" +RUN wget -q -O /tmp/sccache.tar.gz ${SCCACHE_URL} \ + && mkdir -p /tmp/sccache \ + && tar -z -C /tmp/sccache -xf /tmp/sccache.tar.gz \ + && cp /tmp/sccache/sccache*/sccache /usr/bin/sccache \ + && rm -r /tmp/sccache.tar.gz /tmp/sccache + +# +# Update Rust runtime +# +ARG CARGO_BUILD_PROFILE=debug +RUN rustup install stable + +# +# Fetch build dependencies +# +WORKDIR /usr/src/platform-fetch + +# We copy just .toml files and create some dummy files to avoid copying over full source. +# If we copy everything, docker layered caching will invalidate the cache when any file changes. +# But we only care about files with dependencies. + +# COPY Cargo.lock Cargo.toml . +# COPY packages/rs-dpp/Cargo.toml packages/rs-dpp/Cargo.toml +# COPY packages/wasm-dpp/Cargo.toml packages/wasm-dpp/Cargo.toml +# COPY packages/rs-drive/Cargo.toml packages/rs-drive/Cargo.toml +# COPY packages/rs-drive/Cargo.toml packages/rs-drive/Cargo.toml +# COPY packages/rs-platform-value/Cargo.toml packages/rs-platform-value/Cargo.toml +# COPY packages/rs-drive-abci/Cargo.toml packages/rs-drive-abci/Cargo.toml +# COPY packages/rs-drive-nodejs/Cargo.toml packages/rs-drive-nodejs/Cargo.toml +# COPY packages/dashpay-contract/Cargo.toml packages/dashpay-contract/Cargo.toml +# COPY packages/withdrawals-contract/Cargo.toml packages/withdrawals-contract/Cargo.toml +# COPY packages/masternode-reward-shares-contract/Cargo.toml packages/masternode-reward-shares-contract/Cargo.toml +# COPY packages/feature-flags-contract/Cargo.toml packages/feature-flags-contract/Cargo.toml +# COPY packages/dpns-contract/Cargo.toml packages/dpns-contract/Cargo.toml +# COPY packages/data-contracts/Cargo.toml packages/data-contracts/Cargo.toml +# # We need to add some dummy files, so that `cargo fetch` will not complain. +# RUN for d in packages/*; do \ +# mkdir -p ${d}/src && touch --date="2000-01-01" ${d}/src/lib.rs ;\ +# done +# RUN mkdir -p packages/rs-drive/benches && touch --date="2000-01-01" packages/rs-drive/benches/benchmarks.rs + +# +# Fetch all dependencies +# +# RUN cargo fetch --verbose + +# +# EXECUTE BUILD +# +FROM deps as build + +WORKDIR /usr/src/platform + +COPY . . + +WORKDIR /usr/src/platform + + +# Set RUSTC_WRAPPER=/usr/bin/sccache to enable `sccache` caching. +ARG RUSTC_WRAPPER=/usr/bin/sccache +# Set SCCACHE_DIR to location of sccache on disk +# ARG SCCACHE_DIR +# Set SCCACHE_MEMCACHED to use local memcache daemon +# ARG SCCACHE_MEMCACHED +# Set args below to use Github Actions cache; see https://github.com/mozilla/sccache/blob/main/docs/GHA.md +ARG SCCACHE_GHA_ENABLED +ARG ACTIONS_CACHE_URL +ARG ACTIONS_RUNTIME_TOKEN + +# Disable incremental buildings, not supported by sccache +ARG CARGO_INCREMENTAL=false + +# Run the build, with extensive caching. +# See https://doc.rust-lang.org/cargo/guide/cargo-home.html#caching-the-cargo-home-in-ci +# --mount=type=cache,sharing=private,target=/usr/src/platform/target \ +RUN --mount=type=cache,sharing=shared,target=/root/.cache/sccache \ + --mount=type=cache,sharing=shared,target=${CARGO_HOME}/.crates.toml \ + --mount=type=cache,sharing=shared,target=${CARGO_HOME}/.crates2.json \ + --mount=type=cache,sharing=shared,target=${CARGO_HOME}/registry/index \ + --mount=type=cache,sharing=shared,target=${CARGO_HOME}/registry/cache \ + --mount=type=cache,sharing=shared,target=${CARGO_HOME}/git/db \ + cargo build -p drive-abci \ + && cp /usr/src/platform/target/${CARGO_BUILD_PROFILE}/drive-abci /usr/src/platform/drive-abci + +# +# FINAL IMAGE +# +FROM debian:bullseye-slim AS release + +VOLUME /var/lib/platform + +ENV DB_PATH=/var/lib/platform/rs-drive-abci/db +ENV RUST_LOG="info,tenderdash_abci=debug,drive_abci=debug" + # Install ZMQ shared library -RUN apk update && apk add --no-cache zeromq-dev +# zeromq-dev +# RUN apt-get update && apt-get install --yes libzmq5 && apt-get clean -WORKDIR /platform +# +# Install binaries and data +# +WORKDIR /var/lib/platform -COPY --from=builder /platform /platform +COPY --from=build /usr/src/platform/drive-abci /usr/bin/drive-abci +COPY --from=build /usr/src/platform/packages/rs-drive-abci/.env.example /var/lib/platform/rs-drive-abci/.env -# Remove Rust sources -RUN rm -rf packages/rs-drive packages/rs-drive-abci packages/rs-dpp packages/rs-platform-value +# +# Create new non-root user +# +ARG USERNAME=platform +ARG USER_UID=1000 +ARG USER_GID=$USER_UID +RUN groupadd --gid $USER_GID $USERNAME \ + && useradd --uid $USER_UID --gid $USER_GID --home /var/lib/platform/rs-drive-abci --create-home $USERNAME \ + && chown -R $USER_UID:$USER_GID /var/lib/platform/rs-drive-abci -RUN cp /platform/packages/rs-drive-abci/.env.example /platform/packages/rs-drive-abci/.env +USER $USERNAME +WORKDIR /var/lib/platform/rs-drive-abci +ENTRYPOINT ["/usr/bin/drive-abci"] +CMD ["start"] EXPOSE 26658 From 133d55872315cc43985eed313e8b17f2d0318f2d Mon Sep 17 00:00:00 2001 From: Lukasz Klimek <842586+lklimek@users.noreply.github.com> Date: Wed, 22 Mar 2023 11:08:33 +0100 Subject: [PATCH 09/19] chore(rs-drive-abci): deps and cfg support updated --- Cargo.lock | 2 ++ packages/rs-drive-abci/Cargo.toml | 4 ++-- packages/rs-drive-abci/src/main.rs | 9 ++++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e78ce58ea2f..860a010e63c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3286,6 +3286,7 @@ dependencies = [ [[package]] name = "tenderdash-abci" version = "0.12.0-dev.1" +source = "git+https://github.com/dashpay/rs-tenderdash-abci?branch=proto-timestamp-milis#627d9607b9dec9d5b4182f877229a15e6568cbdd" dependencies = [ "bytes", "prost", @@ -3299,6 +3300,7 @@ dependencies = [ [[package]] name = "tenderdash-proto" version = "0.12.0-dev.1" +source = "git+https://github.com/dashpay/rs-tenderdash-abci?branch=proto-timestamp-milis#627d9607b9dec9d5b4182f877229a15e6568cbdd" dependencies = [ "bytes", "chrono", diff --git a/packages/rs-drive-abci/Cargo.toml b/packages/rs-drive-abci/Cargo.toml index 6ce1724ae5a..60856cfba19 100644 --- a/packages/rs-drive-abci/Cargo.toml +++ b/packages/rs-drive-abci/Cargo.toml @@ -51,8 +51,8 @@ tracing-subscriber = { version = "0.3.16", default-features = false, features = ], optional = true } semver = { version = "1.0.17", optional = true } atty = { version = "0.2.14", optional = true } -#tenderdash-abci = { git="https://github.com/dashpay/rs-tenderdash-abci" , optional = true } -tenderdash-abci = { path = "/home/lklimek/git/lklimek/tenderdash-abci-rs/abci", optional = true } +tenderdash-abci = { git = "https://github.com/dashpay/rs-tenderdash-abci", branch = "proto-timestamp-milis", optional = true } +#tenderdash-abci = { path = "/home/lklimek/git/lklimek/tenderdash-abci-rs/abci", optional = true } [dev-dependencies] itertools = { version = "0.10.5" } diff --git a/packages/rs-drive-abci/src/main.rs b/packages/rs-drive-abci/src/main.rs index b87bfdf2da3..059ceffe2bc 100644 --- a/packages/rs-drive-abci/src/main.rs +++ b/packages/rs-drive-abci/src/main.rs @@ -4,6 +4,7 @@ use clap::{Parser, Subcommand}; use drive_abci::config::{FromEnv, PlatformConfig}; use std::path::PathBuf; +use tracing::warn; use tracing_subscriber::prelude::*; /// Main command container for ABCI Server @@ -84,7 +85,13 @@ fn load_config(config: &Option) -> PlatformConfig { } } None => { - dotenvy::dotenv().expect("cannot load .env file"); + if let Err(e) = dotenvy::dotenv() { + if e.not_found() { + warn!("cannot find any matching .env file"); + } else { + panic!("cannot load config file: {}", e); + } + } } }; From d1276691ca8aed5a01d826d93213b9733a3dbc3c Mon Sep 17 00:00:00 2001 From: Lukasz Klimek <842586+lklimek@users.noreply.github.com> Date: Wed, 22 Mar 2023 11:45:31 +0100 Subject: [PATCH 10/19] chore(rs-drive-abci): minor changes in comments etc --- packages/rs-drive-abci/Cargo.toml | 1 + packages/rs-drive-abci/Dockerfile | 33 -------------------------- packages/rs-drive-abci/src/main.rs | 38 +++++++++++++----------------- 3 files changed, 17 insertions(+), 55 deletions(-) diff --git a/packages/rs-drive-abci/Cargo.toml b/packages/rs-drive-abci/Cargo.toml index 60856cfba19..b9e4b198566 100644 --- a/packages/rs-drive-abci/Cargo.toml +++ b/packages/rs-drive-abci/Cargo.toml @@ -5,6 +5,7 @@ authors = [ "Samuel Westrich ", "Ivan Shumkov ", "Djavid Gabibiyan ", + "Lukasz Klimek ", ] edition = "2021" license = "MIT" diff --git a/packages/rs-drive-abci/Dockerfile b/packages/rs-drive-abci/Dockerfile index 1ce1904db95..6b7b50b3a0c 100644 --- a/packages/rs-drive-abci/Dockerfile +++ b/packages/rs-drive-abci/Dockerfile @@ -54,35 +54,6 @@ RUN rustup install stable # WORKDIR /usr/src/platform-fetch -# We copy just .toml files and create some dummy files to avoid copying over full source. -# If we copy everything, docker layered caching will invalidate the cache when any file changes. -# But we only care about files with dependencies. - -# COPY Cargo.lock Cargo.toml . -# COPY packages/rs-dpp/Cargo.toml packages/rs-dpp/Cargo.toml -# COPY packages/wasm-dpp/Cargo.toml packages/wasm-dpp/Cargo.toml -# COPY packages/rs-drive/Cargo.toml packages/rs-drive/Cargo.toml -# COPY packages/rs-drive/Cargo.toml packages/rs-drive/Cargo.toml -# COPY packages/rs-platform-value/Cargo.toml packages/rs-platform-value/Cargo.toml -# COPY packages/rs-drive-abci/Cargo.toml packages/rs-drive-abci/Cargo.toml -# COPY packages/rs-drive-nodejs/Cargo.toml packages/rs-drive-nodejs/Cargo.toml -# COPY packages/dashpay-contract/Cargo.toml packages/dashpay-contract/Cargo.toml -# COPY packages/withdrawals-contract/Cargo.toml packages/withdrawals-contract/Cargo.toml -# COPY packages/masternode-reward-shares-contract/Cargo.toml packages/masternode-reward-shares-contract/Cargo.toml -# COPY packages/feature-flags-contract/Cargo.toml packages/feature-flags-contract/Cargo.toml -# COPY packages/dpns-contract/Cargo.toml packages/dpns-contract/Cargo.toml -# COPY packages/data-contracts/Cargo.toml packages/data-contracts/Cargo.toml -# # We need to add some dummy files, so that `cargo fetch` will not complain. -# RUN for d in packages/*; do \ -# mkdir -p ${d}/src && touch --date="2000-01-01" ${d}/src/lib.rs ;\ -# done -# RUN mkdir -p packages/rs-drive/benches && touch --date="2000-01-01" packages/rs-drive/benches/benchmarks.rs - -# -# Fetch all dependencies -# -# RUN cargo fetch --verbose - # # EXECUTE BUILD # @@ -131,10 +102,6 @@ VOLUME /var/lib/platform ENV DB_PATH=/var/lib/platform/rs-drive-abci/db ENV RUST_LOG="info,tenderdash_abci=debug,drive_abci=debug" -# Install ZMQ shared library -# zeromq-dev -# RUN apt-get update && apt-get install --yes libzmq5 && apt-get clean - # # Install binaries and data # diff --git a/packages/rs-drive-abci/src/main.rs b/packages/rs-drive-abci/src/main.rs index 059ceffe2bc..f91a384f3c8 100644 --- a/packages/rs-drive-abci/src/main.rs +++ b/packages/rs-drive-abci/src/main.rs @@ -7,9 +7,15 @@ use std::path::PathBuf; use tracing::warn; use tracing_subscriber::prelude::*; -/// Main command container for ABCI Server +// struct aaa {} + +/// Server that accepts connections from Tenderdash, and +/// executes Dash Platform logic as part of the ABCI++ protocol. +/// +/// Server configuration is based on environment variables that can be +/// set in the environment or saved in .env file. #[derive(Debug, Parser)] -#[command( author, version, about, long_about = None)] +#[command(author, version)] struct Cli { #[command(subcommand)] command: Commands, @@ -20,16 +26,14 @@ struct Cli { /// /// Repeat `v` multiple times to increase log verbosity: /// - /// - none - `warn` unless overriden by RUST_LOG variable - /// - `-v` - `info` from Drive, `error` from libraries - /// - `-vv` - `debug` from Drive, `info` from libraries - /// - `-vvv` - `debug` from all components - /// - `-vvvv` - `trace` from Drive, `debug` from libraries - /// - `-vvvvv` - `trace` from all components + /// * none - `warn` unless overriden by RUST_LOG variable{n} + /// * `-v` - `info` from Drive, `error` from libraries{n} + /// * `-vv` - `debug` from Drive, `info` from libraries{n} + /// * `-vvv` - `debug` from all components{n} + /// * `-vvvv` - `trace` from Drive, `debug` from libraries{n} + /// * `-vvvvv` - `trace` from all components{n} /// - /// Note: This overrides any settings defined in RUST_LOG. - /// For more about RUST_LOG, see: - /// https://rust-lang-nursery.github.io/rust-cookbook/development_tools/debugging/config_log.html + /// Note: Using `-v` overrides any settings defined in RUST_LOG. /// #[arg(short, long, action = clap::ArgAction::Count)] verbose: u8, @@ -37,7 +41,7 @@ struct Cli { #[derive(Debug, Subcommand)] enum Commands { - /// Start server in foreground + /// Start server in foreground. #[command()] Start {}, /// Dump configuration @@ -47,16 +51,6 @@ enum Commands { Config {}, } -// #[derive(Debug, Args)] -// #[command(args_conflicts_with_subcommands = true)] -// struct StartArgs { -// /// Path to data directory (GroveDB) -// /// -// /// Path to the data directory, containing transactions database. -// #[arg(short, long, value_hint = clap::ValueHint::DirPath) ] -// data: std::path::PathBuf, -// } - pub fn main() { let cli = Cli::parse(); let config = load_config(&cli.config); From 9e10dcff573757f8926db358c8532dea42961e06 Mon Sep 17 00:00:00 2001 From: Lukasz Klimek <842586+lklimek@users.noreply.github.com> Date: Wed, 22 Mar 2023 13:36:59 +0100 Subject: [PATCH 11/19] chore(rs-drive-abci): improve logging --- Cargo.lock | 143 +++++++++++++++++++- packages/rs-drive-abci/.env.example | 2 +- packages/rs-drive-abci/Cargo.toml | 2 +- packages/rs-drive-abci/src/abci/proposal.rs | 7 +- packages/rs-drive-abci/src/abci/server.rs | 44 ++++-- packages/rs-drive-abci/src/main.rs | 2 +- 6 files changed, 182 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 860a010e63c..bc1ad7fb0b7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1248,6 +1248,12 @@ dependencies = [ "subtle", ] +[[package]] +name = "fixedbitset" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" + [[package]] name = "flex-error" version = "0.4.4" @@ -1427,6 +1433,21 @@ version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "221996f774192f0f718773def8201c4ae31f02616a54ccfc2d358bb0e5cefdec" +[[package]] +name = "git2" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf7f68c2995f392c49fffb4f95ae2c873297830eb25c6bc4c114ce8f4562acc" +dependencies = [ + "bitflags", + "libc", + "libgit2-sys", + "log", + "openssl-probe", + "openssl-sys", + "url", +] + [[package]] name = "glob" version = "0.3.1" @@ -1798,6 +1819,20 @@ version = "0.2.139" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" +[[package]] +name = "libgit2-sys" +version = "0.14.2+1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f3d95f6b51075fe9810a7ae22c7095f12b98005ab364d8544797a825ce946a4" +dependencies = [ + "cc", + "libc", + "libssh2-sys", + "libz-sys", + "openssl-sys", + "pkg-config", +] + [[package]] name = "libloading" version = "0.6.7" @@ -1833,6 +1868,20 @@ dependencies = [ "zstd-sys", ] +[[package]] +name = "libssh2-sys" +version = "0.2.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b094a36eb4b8b8c8a7b4b8ae43b2944502be3e59cd87687595cf6b0a71b3f4ca" +dependencies = [ + "cc", + "libc", + "libz-sys", + "openssl-sys", + "pkg-config", + "vcpkg", +] + [[package]] name = "libz-sys" version = "1.1.8" @@ -1840,6 +1889,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9702761c3935f8cc2f101793272e202c72b99da8f4224a19ddcf1279a6450bbf" dependencies = [ "cc", + "libc", "pkg-config", "vcpkg", ] @@ -2032,6 +2082,12 @@ dependencies = [ "uuid 1.3.0", ] +[[package]] +name = "multimap" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a" + [[package]] name = "neon" version = "0.10.1" @@ -2312,6 +2368,25 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + +[[package]] +name = "openssl-sys" +version = "0.9.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a95792af3c4e0153c3914df2261bedd30a98476f94dc892b67dfe1d89d433a04" +dependencies = [ + "autocfg", + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "os_str_bytes" version = "6.4.1" @@ -2383,6 +2458,16 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" +[[package]] +name = "petgraph" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dd7d28ee937e54fe3080c91faa1c3a46c06de6252988a7f4592ba2310ef22a4" +dependencies = [ + "fixedbitset", + "indexmap", +] + [[package]] name = "pin-project-lite" version = "0.2.9" @@ -2489,6 +2574,16 @@ dependencies = [ "yansi", ] +[[package]] +name = "prettyplease" +version = "0.1.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c8646e95016a7a6c4adea95bafa8a16baab64b583356217f2c85db4a39d9a86" +dependencies = [ + "proc-macro2", + "syn", +] + [[package]] name = "proc-macro-crate" version = "0.1.5" @@ -2551,6 +2646,28 @@ dependencies = [ "prost-derive", ] +[[package]] +name = "prost-build" +version = "0.11.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c828f93f5ca4826f97fedcbd3f9a536c16b12cff3dbbb4a007f932bbad95b12" +dependencies = [ + "bytes", + "heck 0.4.1", + "itertools", + "lazy_static", + "log", + "multimap", + "petgraph", + "prettyplease", + "prost", + "prost-types", + "regex", + "syn", + "tempfile", + "which", +] + [[package]] name = "prost-derive" version = "0.11.8" @@ -3286,7 +3403,6 @@ dependencies = [ [[package]] name = "tenderdash-abci" version = "0.12.0-dev.1" -source = "git+https://github.com/dashpay/rs-tenderdash-abci?branch=proto-timestamp-milis#627d9607b9dec9d5b4182f877229a15e6568cbdd" dependencies = [ "bytes", "prost", @@ -3300,7 +3416,6 @@ dependencies = [ [[package]] name = "tenderdash-proto" version = "0.12.0-dev.1" -source = "git+https://github.com/dashpay/rs-tenderdash-abci?branch=proto-timestamp-milis#627d9607b9dec9d5b4182f877229a15e6568cbdd" dependencies = [ "bytes", "chrono", @@ -3312,9 +3427,22 @@ dependencies = [ "serde", "serde_bytes", "subtle-encoding", + "tenderdash-proto-compiler", "time 0.3.17", ] +[[package]] +name = "tenderdash-proto-compiler" +version = "0.1.0" +dependencies = [ + "git2", + "prost-build", + "regex", + "subtle-encoding", + "tempfile", + "walkdir", +] + [[package]] name = "termcolor" version = "1.2.0" @@ -3793,6 +3921,17 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "which" +version = "4.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2441c784c52b289a054b7201fc93253e288f094e2f4be9058343127c4226a269" +dependencies = [ + "either", + "libc", + "once_cell", +] + [[package]] name = "winapi" version = "0.3.9" diff --git a/packages/rs-drive-abci/.env.example b/packages/rs-drive-abci/.env.example index 60d90389b1c..a044839b74b 100644 --- a/packages/rs-drive-abci/.env.example +++ b/packages/rs-drive-abci/.env.example @@ -1,5 +1,5 @@ # ABCI host and port to listen -ABCI_BIND_ADDRESS="tcp://0.0.0.0:6658" +ABCI_BIND_ADDRESS="tcp://0.0.0.0:26658" DB_PATH=/tmp/db diff --git a/packages/rs-drive-abci/Cargo.toml b/packages/rs-drive-abci/Cargo.toml index b9e4b198566..931e471d90f 100644 --- a/packages/rs-drive-abci/Cargo.toml +++ b/packages/rs-drive-abci/Cargo.toml @@ -40,7 +40,7 @@ rust_decimal_macros = "1.25.0" mockall = { version = "0.11", optional = true } bytes = { version = "1.4.0", default-features = false } prost = { version = "0.11.6", default-features = false } -tracing = { version = "0.1.37", default-features = false } +tracing = { version = "0.1.37", default-features = false, features = [] } flex-error = { version = "0.4.4", default-features = false } structopt = { version = "0.3.26", optional = true, default-features = false } clap = { version = "4.1.8", optional = true, features = ["derive"] } diff --git a/packages/rs-drive-abci/src/abci/proposal.rs b/packages/rs-drive-abci/src/abci/proposal.rs index bc71289116e..b40704a6144 100644 --- a/packages/rs-drive-abci/src/abci/proposal.rs +++ b/packages/rs-drive-abci/src/abci/proposal.rs @@ -17,14 +17,15 @@ use tenderdash_abci::proto::{ pub trait Proposal { fn prepare_proposal( &self, - request: proto::RequestPrepareProposal, + request: &proto::RequestPrepareProposal, transaction: TransactionArg, ) -> Result; } + impl Proposal for Platform { fn prepare_proposal( &self, - request: proto::RequestPrepareProposal, + request: &proto::RequestPrepareProposal, transaction: TransactionArg, ) -> Result { let genesis_time_ms = if request.height == self.config.abci.genesis_height { @@ -93,7 +94,7 @@ impl Proposal for Platform { // )?; let mut tx_results = ::prost::alloc::vec::Vec::::new(); - for tx in request.txs { + for tx in request.txs.clone() { tx_results.push(mock_exec_tx(tx)) // TODO: execute transactions in a proper way } // TODO: implement all fields, including tx processing; for now, just leaving bare minimum diff --git a/packages/rs-drive-abci/src/abci/server.rs b/packages/rs-drive-abci/src/abci/server.rs index e7b31867865..6050ce7d7cd 100644 --- a/packages/rs-drive-abci/src/abci/server.rs +++ b/packages/rs-drive-abci/src/abci/server.rs @@ -4,7 +4,7 @@ use super::config::AbciConfig; use crate::{abci::proposal::Proposal, config::PlatformConfig, error::Error, platform::Platform}; use dpp::identity::TimestampMillis; use drive::query::TransactionArg; -use std::sync::MutexGuard; +use std::{fmt::Debug, sync::MutexGuard}; use tenderdash_abci::proto::{abci as proto, serializers::timestamp::ToMilis}; use tracing::debug; /// AbciApp is an implementation of ABCI Application, as defined by Tenderdash. @@ -65,10 +65,14 @@ impl<'a> AbciApplication<'a> { } } +impl<'a> Debug for AbciApplication<'a> { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "AbciApp") + } +} + impl<'a> tenderdash_abci::Application for AbciApplication<'a> { fn info(&self, request: proto::RequestInfo) -> proto::ResponseInfo { - tracing::info!("tenderdash info: {:?}", request); - if !check_version(&request.abci_version, tenderdash_abci::proto::ABCI_VERSION) { panic!( "SemVer mismatch: Tenderdash requires ABCI version {}, our version is {}", @@ -77,11 +81,20 @@ impl<'a> tenderdash_abci::Application for AbciApplication<'a> { ); } - proto::ResponseInfo { + let response = proto::ResponseInfo { app_version: 1, version: env!("CARGO_PKG_VERSION").to_string(), ..Default::default() - } + }; + + tracing::info!( + method = "info", + method = "info", + ?request, + ?response, + "info received" + ); + response } fn init_chain(&self, request: proto::RequestInitChain) -> proto::ResponseInitChain { @@ -90,6 +103,7 @@ impl<'a> tenderdash_abci::Application for AbciApplication<'a> { let genesis_time = request .time + .clone() .expect("init chain REQUIRES genesis time") .to_milis(); @@ -101,9 +115,12 @@ impl<'a> tenderdash_abci::Application for AbciApplication<'a> { ) .expect("create genesis state"); - proto::ResponseInitChain { + let response = proto::ResponseInitChain { ..Default::default() - } + }; + + tracing::info!(method = "init_chain", "init chain executed"); + response } fn prepare_proposal( @@ -112,9 +129,16 @@ impl<'a> tenderdash_abci::Application for AbciApplication<'a> { ) -> proto::ResponsePrepareProposal { let platform = self.platform(); let transaction = self.transaction(); - platform - .prepare_proposal(request, transaction) - .expect("failed to prepare proposal") + let response = platform + .prepare_proposal(&request, transaction) + .expect("failed to prepare proposal"); + + tracing::info!( + method = "prepare_proposal", + height = request.height, + "prepare proposal executed", + ); + response } } /// Check if ABCI version required by Tenderdash matches our protobuf version. diff --git a/packages/rs-drive-abci/src/main.rs b/packages/rs-drive-abci/src/main.rs index f91a384f3c8..aa89c4aaac8 100644 --- a/packages/rs-drive-abci/src/main.rs +++ b/packages/rs-drive-abci/src/main.rs @@ -118,5 +118,5 @@ fn set_verbosity(cli: &Cli) { /// Install panic hook to ensure that all panic logs are correctly formatted fn install_panic_hook() { - std::panic::set_hook(Box::new(|info| tracing::error!("panic: {:?}", info))); + std::panic::set_hook(Box::new(|info| tracing::error!(panic=%info, "panic"))); } From 07de599436bf3eb5cd45263c1f312ac9f7904017 Mon Sep 17 00:00:00 2001 From: Lukasz Klimek <842586+lklimek@users.noreply.github.com> Date: Wed, 22 Mar 2023 15:04:58 +0100 Subject: [PATCH 12/19] build(rs-drive-abci): update tenderdash-proto branch name --- packages/rs-drive-abci/Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/rs-drive-abci/Cargo.toml b/packages/rs-drive-abci/Cargo.toml index 931e471d90f..487e32747d8 100644 --- a/packages/rs-drive-abci/Cargo.toml +++ b/packages/rs-drive-abci/Cargo.toml @@ -52,8 +52,8 @@ tracing-subscriber = { version = "0.3.16", default-features = false, features = ], optional = true } semver = { version = "1.0.17", optional = true } atty = { version = "0.2.14", optional = true } -tenderdash-abci = { git = "https://github.com/dashpay/rs-tenderdash-abci", branch = "proto-timestamp-milis", optional = true } -#tenderdash-abci = { path = "/home/lklimek/git/lklimek/tenderdash-abci-rs/abci", optional = true } +tenderdash-abci = { git = "https://github.com/dashpay/rs-tenderdash-abci", branch = "dev", optional = true } +# tenderdash-abci = { path = "/home/lklimek/git/lklimek/tenderdash-abci-rs/abci", optional = true } [dev-dependencies] itertools = { version = "0.10.5" } From 324c192e988c0ee3d961306f6bb04de1f28a4a46 Mon Sep 17 00:00:00 2001 From: Lukasz Klimek <842586+lklimek@users.noreply.github.com> Date: Wed, 22 Mar 2023 16:09:47 +0100 Subject: [PATCH 13/19] chore(rs-drive-abci): code cleanup --- Cargo.lock | 3 + packages/rs-drive-abci/Dockerfile | 17 +--- packages/rs-drive-abci/src/abci/config.rs | 19 ++-- packages/rs-drive-abci/src/abci/handlers.rs | 4 +- packages/rs-drive-abci/src/abci/mod.rs | 14 ++- packages/rs-drive-abci/src/abci/server.rs | 104 ++++++-------------- packages/rs-drive-abci/src/config.rs | 2 +- 7 files changed, 65 insertions(+), 98 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bc1ad7fb0b7..d16abb3249b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3403,6 +3403,7 @@ dependencies = [ [[package]] name = "tenderdash-abci" version = "0.12.0-dev.1" +source = "git+https://github.com/dashpay/rs-tenderdash-abci?branch=dev#8e37174a26c59ca9ba385c6c6547905e3eb582bd" dependencies = [ "bytes", "prost", @@ -3416,6 +3417,7 @@ dependencies = [ [[package]] name = "tenderdash-proto" version = "0.12.0-dev.1" +source = "git+https://github.com/dashpay/rs-tenderdash-abci?branch=dev#8e37174a26c59ca9ba385c6c6547905e3eb582bd" dependencies = [ "bytes", "chrono", @@ -3434,6 +3436,7 @@ dependencies = [ [[package]] name = "tenderdash-proto-compiler" version = "0.1.0" +source = "git+https://github.com/dashpay/rs-tenderdash-abci?branch=dev#8e37174a26c59ca9ba385c6c6547905e3eb582bd" dependencies = [ "git2", "prost-build", diff --git a/packages/rs-drive-abci/Dockerfile b/packages/rs-drive-abci/Dockerfile index 6b7b50b3a0c..607a46e82ce 100644 --- a/packages/rs-drive-abci/Dockerfile +++ b/packages/rs-drive-abci/Dockerfile @@ -49,11 +49,6 @@ RUN wget -q -O /tmp/sccache.tar.gz ${SCCACHE_URL} \ ARG CARGO_BUILD_PROFILE=debug RUN rustup install stable -# -# Fetch build dependencies -# -WORKDIR /usr/src/platform-fetch - # # EXECUTE BUILD # @@ -63,20 +58,16 @@ WORKDIR /usr/src/platform COPY . . -WORKDIR /usr/src/platform - +# +# Configure sccache +# # Set RUSTC_WRAPPER=/usr/bin/sccache to enable `sccache` caching. ARG RUSTC_WRAPPER=/usr/bin/sccache -# Set SCCACHE_DIR to location of sccache on disk -# ARG SCCACHE_DIR -# Set SCCACHE_MEMCACHED to use local memcache daemon -# ARG SCCACHE_MEMCACHED # Set args below to use Github Actions cache; see https://github.com/mozilla/sccache/blob/main/docs/GHA.md ARG SCCACHE_GHA_ENABLED ARG ACTIONS_CACHE_URL ARG ACTIONS_RUNTIME_TOKEN - # Disable incremental buildings, not supported by sccache ARG CARGO_INCREMENTAL=false @@ -100,7 +91,6 @@ FROM debian:bullseye-slim AS release VOLUME /var/lib/platform ENV DB_PATH=/var/lib/platform/rs-drive-abci/db -ENV RUST_LOG="info,tenderdash_abci=debug,drive_abci=debug" # # Install binaries and data @@ -121,6 +111,7 @@ RUN groupadd --gid $USER_GID $USERNAME \ && chown -R $USER_UID:$USER_GID /var/lib/platform/rs-drive-abci USER $USERNAME + WORKDIR /var/lib/platform/rs-drive-abci ENTRYPOINT ["/usr/bin/drive-abci"] CMD ["start"] diff --git a/packages/rs-drive-abci/src/abci/config.rs b/packages/rs-drive-abci/src/abci/config.rs index 3a6d28be643..3add7f23a8b 100644 --- a/packages/rs-drive-abci/src/abci/config.rs +++ b/packages/rs-drive-abci/src/abci/config.rs @@ -18,10 +18,10 @@ pub struct AbciConfig { /// - `unix:///var/run/abci.sock` #[serde(rename = "abci_bind_address")] pub bind_address: String, + /// Public keys used for system identity - /// #[serde(flatten)] - pub keys: ContractKeys, + pub keys: Keys, /// Height of genesis block; defaults to 1 #[serde(default = "AbciConfig::default_genesis_height")] @@ -39,8 +39,12 @@ impl FromEnv for AbciConfig {} #[serde_as] #[derive(Clone, Debug, Serialize, Deserialize, Default)] -/// Various keys -pub struct ContractKeys { +/// Struct to easily load from environment keys used by the Platform. +/// +/// Once loaded, Keys can be easily converted to [SystemIdentityPublicKeys] +/// +/// [SystemIdentityPublicKeys]: super::messages::SystemIdentityPublicKeys +pub struct Keys { // dpns contract /// hex-encoded #[serde_as(as = "serde_with::hex::Hex")] @@ -82,8 +86,8 @@ pub struct ContractKeys { withdrawals_second_public_key: Vec, } -impl From for SystemIdentityPublicKeys { - fn from(keys: ContractKeys) -> Self { +impl From for SystemIdentityPublicKeys { + fn from(keys: Keys) -> Self { Self { masternode_reward_shares_contract_owner: RequiredIdentityPublicKeysSet { master: keys.masternode_reward_shares_master_public_key, @@ -123,7 +127,6 @@ mod tests { dotenvy::from_path(envfile.as_path()).expect("cannot load .env file"); - let config = super::AbciConfig::from_env().unwrap(); - dbg!(config.keys.dashpay_master_public_key); + let _config = super::AbciConfig::from_env().unwrap(); } } diff --git a/packages/rs-drive-abci/src/abci/handlers.rs b/packages/rs-drive-abci/src/abci/handlers.rs index a14c0f3519a..e08371cc5fd 100644 --- a/packages/rs-drive-abci/src/abci/handlers.rs +++ b/packages/rs-drive-abci/src/abci/handlers.rs @@ -55,7 +55,7 @@ pub trait TenderdashAbci { ) -> Result; /// Called with JS Drive on block begin - #[deprecated = "replaced with abci::serverAbciApplication::prepare_proposal()"] + #[deprecated = "use abci::server mod, prepare_proposal or process_proposal"] fn block_begin( &self, request: BlockBeginRequest, @@ -63,6 +63,7 @@ pub trait TenderdashAbci { ) -> Result; /// Called with JS Drive on block end + #[deprecated = "use abci::server finalize_block"] fn block_end( &self, request: BlockEndRequest, @@ -70,6 +71,7 @@ pub trait TenderdashAbci { ) -> Result; /// Called with JS Drive after the current block db transaction is committed + #[deprecated = "use abci::server finalize_block"] fn after_finalize_block( &self, request: AfterFinalizeBlockRequest, diff --git a/packages/rs-drive-abci/src/abci/mod.rs b/packages/rs-drive-abci/src/abci/mod.rs index 33406ea166d..412925a832e 100644 --- a/packages/rs-drive-abci/src/abci/mod.rs +++ b/packages/rs-drive-abci/src/abci/mod.rs @@ -1,11 +1,19 @@ -pub mod config; mod error; + +// old code - handlers and messages +#[deprecated = "logic moved to [server] and [proposal] mod"] pub mod handlers; +#[deprecated = "use tenderdash-proto crate whenever possible"] pub mod messages; + +// new code - config, +#[cfg(feature = "server")] +pub mod config; +#[cfg(feature = "server")] mod proposal; #[cfg(feature = "server")] mod server; -#[cfg(feature = "server")] -pub use server::start; pub use error::Error; +#[cfg(feature = "server")] +pub use server::start; diff --git a/packages/rs-drive-abci/src/abci/server.rs b/packages/rs-drive-abci/src/abci/server.rs index 6050ce7d7cd..fba7d4a8808 100644 --- a/packages/rs-drive-abci/src/abci/server.rs +++ b/packages/rs-drive-abci/src/abci/server.rs @@ -56,10 +56,13 @@ impl<'a> AbciApplication<'a> { Ok(app) } + /// Return locked Platform object fn platform(&self) -> MutexGuard<&'a Platform> { self.platform.lock().unwrap() } + /// Return current transaction. + /// TODO: implement fn transaction(&self) -> TransactionArg { self.transaction } @@ -67,7 +70,7 @@ impl<'a> AbciApplication<'a> { impl<'a> Debug for AbciApplication<'a> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "AbciApp") + write!(f, "") } } @@ -87,13 +90,7 @@ impl<'a> tenderdash_abci::Application for AbciApplication<'a> { ..Default::default() }; - tracing::info!( - method = "info", - method = "info", - ?request, - ?response, - "info received" - ); + tracing::info!(method = "info", ?request, ?response, "info executed"); response } @@ -104,15 +101,11 @@ impl<'a> tenderdash_abci::Application for AbciApplication<'a> { let genesis_time = request .time .clone() - .expect("init chain REQUIRES genesis time") - .to_milis(); + .expect("genesis time is required") + .to_milis() as TimestampMillis; platform - .create_genesis_state( - genesis_time as TimestampMillis, - self.config.keys.clone().into(), - transaction, - ) + .create_genesis_state(genesis_time, self.config.keys.clone().into(), transaction) .expect("create genesis state"); let response = proto::ResponseInitChain { @@ -141,21 +134,19 @@ impl<'a> tenderdash_abci::Application for AbciApplication<'a> { response } } + /// Check if ABCI version required by Tenderdash matches our protobuf version. /// /// Match is determined based on Semantic Versioning rules, as defined for '^' operator. fn check_version(tenderdash_abci_requirement: &str, our_abci_version: &str) -> bool { let our_version = - semver::Version::parse(our_abci_version).expect("cannot parse version of protobuf library"); + semver::Version::parse(our_abci_version).expect("cannot parse protobuf library version"); - let requirement = String::from("^") + tenderdash_abci_requirement; - let td_version = semver::VersionReq::parse(requirement.as_str()) - .expect("cannot parse version of tenderdash server"); + let require = String::from("^") + tenderdash_abci_requirement; + let td_version = + semver::VersionReq::parse(require.as_str()).expect("cannot parse tenderdash version"); - debug!( - "ABCI version check: required: {}, our: {}", - requirement, our_version - ); + debug!("ABCI version: required: {}, our: {}", require, our_version); td_version.matches(&our_version) } @@ -164,56 +155,25 @@ fn check_version(tenderdash_abci_requirement: &str, our_abci_version: &str) -> b mod tests { use crate::abci::server::check_version; - #[test] - fn test_versions() { - #[derive(Debug)] - struct TestCase<'a> { - our_version: &'a str, - td_version: &'a str, - expect: bool, + /// test_versions! {} (td_version, our_version, expected); } + macro_rules! test_versions { + ($($name:ident: $value:expr,)*) => { + $( + #[test] + fn $name() { + let (td, our, expect) = $value; + assert_eq!(check_version(td, our),expect); + } + )* } + } - let test_cases = vec![ - TestCase { - td_version: "0.1.2-dev.1", - our_version: "0.1.0", - expect: false, - }, - TestCase { - td_version: "0.1.0", - our_version: "0.1.0", - expect: true, - }, - TestCase { - td_version: "0.1.0", - our_version: "0.1.2", - expect: true, - }, - TestCase { - td_version: "0.1.0-dev.1", - our_version: "0.1.0-dev.1", - expect: true, - }, - TestCase { - td_version: "0.1.0-dev.1", - our_version: "0.1.0-dev.2", - expect: true, - }, - TestCase { - td_version: "0.1.0", - our_version: "0.1.0-dev.1", - expect: false, - }, - TestCase { - td_version: "0.1.0-dev.1", - our_version: "0.1.0-dev.1", - expect: true, - }, - ]; - - for tc in test_cases { - dbg!(&tc); - assert_eq!(check_version(tc.td_version, tc.our_version,), tc.expect); - } + test_versions! { + test_versions_td_newer: ("0.1.2-dev.1", "0.1.0", false), + test_versions_equal: ("0.1.0","0.1.0",true), + test_versions_td_older: ("0.1.0","0.1.2",true), + test_versions_equal_dev: ("0.1.0-dev.1","0.1.0-dev.1",true), + test_versions_our_newer_dev: ("0.1.0-dev.1", "0.1.0-dev.2",true), + test_versions_our_dev:("0.1.0","0.1.0-dev.1",false), } } diff --git a/packages/rs-drive-abci/src/config.rs b/packages/rs-drive-abci/src/config.rs index 31140047f94..f2f32540669 100644 --- a/packages/rs-drive-abci/src/config.rs +++ b/packages/rs-drive-abci/src/config.rs @@ -137,7 +137,7 @@ impl Default for PlatformConfig { fn default() -> Self { Self { verify_sum_trees: true, - quorum_size: 0, + quorum_size: 100, validator_set_quorum_rotation_block_count: 15, drive: Default::default(), abci: Default::default(), From 29a21ab7981395885224886abbac6ee64131574e Mon Sep 17 00:00:00 2001 From: Lukasz Klimek <842586+lklimek@users.noreply.github.com> Date: Thu, 23 Mar 2023 10:55:03 +0100 Subject: [PATCH 14/19] chore(rs-drive-abci): fix error on missing config var --- Cargo.lock | 6 +++--- packages/rs-drive-abci/Cargo.toml | 2 +- packages/rs-drive-abci/src/main.rs | 21 +++++++++++++++++---- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d16abb3249b..6562ebb89a3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3403,7 +3403,7 @@ dependencies = [ [[package]] name = "tenderdash-abci" version = "0.12.0-dev.1" -source = "git+https://github.com/dashpay/rs-tenderdash-abci?branch=dev#8e37174a26c59ca9ba385c6c6547905e3eb582bd" +source = "git+https://github.com/dashpay/rs-tenderdash-abci?branch=master#656e6ba8640e9bb046e4e7f1898f7e4e9a063e33" dependencies = [ "bytes", "prost", @@ -3417,7 +3417,7 @@ dependencies = [ [[package]] name = "tenderdash-proto" version = "0.12.0-dev.1" -source = "git+https://github.com/dashpay/rs-tenderdash-abci?branch=dev#8e37174a26c59ca9ba385c6c6547905e3eb582bd" +source = "git+https://github.com/dashpay/rs-tenderdash-abci?branch=master#656e6ba8640e9bb046e4e7f1898f7e4e9a063e33" dependencies = [ "bytes", "chrono", @@ -3436,7 +3436,7 @@ dependencies = [ [[package]] name = "tenderdash-proto-compiler" version = "0.1.0" -source = "git+https://github.com/dashpay/rs-tenderdash-abci?branch=dev#8e37174a26c59ca9ba385c6c6547905e3eb582bd" +source = "git+https://github.com/dashpay/rs-tenderdash-abci?branch=master#656e6ba8640e9bb046e4e7f1898f7e4e9a063e33" dependencies = [ "git2", "prost-build", diff --git a/packages/rs-drive-abci/Cargo.toml b/packages/rs-drive-abci/Cargo.toml index 487e32747d8..9c3cd44e618 100644 --- a/packages/rs-drive-abci/Cargo.toml +++ b/packages/rs-drive-abci/Cargo.toml @@ -52,7 +52,7 @@ tracing-subscriber = { version = "0.3.16", default-features = false, features = ], optional = true } semver = { version = "1.0.17", optional = true } atty = { version = "0.2.14", optional = true } -tenderdash-abci = { git = "https://github.com/dashpay/rs-tenderdash-abci", branch = "dev", optional = true } +tenderdash-abci = { git = "https://github.com/dashpay/rs-tenderdash-abci", branch = "master", optional = true } # tenderdash-abci = { path = "/home/lklimek/git/lklimek/tenderdash-abci-rs/abci", optional = true } [dev-dependencies] diff --git a/packages/rs-drive-abci/src/main.rs b/packages/rs-drive-abci/src/main.rs index aa89c4aaac8..4ba2c7bbee8 100644 --- a/packages/rs-drive-abci/src/main.rs +++ b/packages/rs-drive-abci/src/main.rs @@ -56,6 +56,7 @@ pub fn main() { let config = load_config(&cli.config); set_verbosity(&cli); + install_panic_hook(); match cli.command { @@ -71,8 +72,8 @@ fn dump_config(config: &PlatformConfig) { println!("{}", serialized); } -fn load_config(config: &Option) -> PlatformConfig { - match config { +fn load_config(path: &Option) -> PlatformConfig { + match path { Some(path) => { if let Err(e) = dotenvy::from_path(path) { panic!("cannot load config file {:?}: {}", path, e); @@ -89,7 +90,17 @@ fn load_config(config: &Option) -> PlatformConfig { } }; - PlatformConfig::from_env().expect("cannot parse configuration file") + let config = PlatformConfig::from_env(); + if let Err(ref e) = config { + if let drive_abci::error::Error::Configuration(src) = e { + if let envy::Error::MissingValue(e2) = src { + panic!("missing configuration option: {}", e2.to_uppercase()); + }; + panic!("cannot parse configuration file: {}", e); + } + }; + + config.expect("cannot parse configuration file") } fn set_verbosity(cli: &Cli) { @@ -116,7 +127,9 @@ fn set_verbosity(cli: &Cli) { registry().with(layer).with(env_filter).init(); } -/// Install panic hook to ensure that all panic logs are correctly formatted +/// Install panic hook to ensure that all panic logs are correctly formatted. +/// +/// Depends on [set_verbosity()]. fn install_panic_hook() { std::panic::set_hook(Box::new(|info| tracing::error!(panic=%info, "panic"))); } From 00ee409bbcf817440904f495642e9fcdf4308c9f Mon Sep 17 00:00:00 2001 From: Lukasz Klimek <842586+lklimek@users.noreply.github.com> Date: Fri, 24 Mar 2023 09:31:32 +0100 Subject: [PATCH 15/19] chore(rs-drive-abci): apply peer review feedback --- packages/rs-drive-abci/src/abci/config.rs | 1 - packages/rs-drive-abci/src/abci/error.rs | 6 +++- packages/rs-drive-abci/src/abci/mod.rs | 4 +-- packages/rs-drive-abci/src/abci/proposal.rs | 23 ++++++++------- packages/rs-drive-abci/src/abci/server.rs | 19 ++++++------- packages/rs-drive-abci/src/config.rs | 1 - packages/rs-drive-abci/src/error/mod.rs | 2 +- packages/rs-drive-abci/src/main.rs | 31 ++++++++------------- packages/rs-drive-nodejs/src/lib.rs | 6 ++-- 9 files changed, 45 insertions(+), 48 deletions(-) diff --git a/packages/rs-drive-abci/src/abci/config.rs b/packages/rs-drive-abci/src/abci/config.rs index 3add7f23a8b..430cd6c1f29 100644 --- a/packages/rs-drive-abci/src/abci/config.rs +++ b/packages/rs-drive-abci/src/abci/config.rs @@ -123,7 +123,6 @@ mod tests { fn test_config_from_env() { let envfile = format!("{}/.env.example", env!("CARGO_MANIFEST_DIR")); let envfile = std::path::PathBuf::from(envfile); - dbg!(&envfile); dotenvy::from_path(envfile.as_path()).expect("cannot load .env file"); diff --git a/packages/rs-drive-abci/src/abci/error.rs b/packages/rs-drive-abci/src/abci/error.rs index 7ac01649a27..6c291869b26 100644 --- a/packages/rs-drive-abci/src/abci/error.rs +++ b/packages/rs-drive-abci/src/abci/error.rs @@ -1,9 +1,13 @@ /// Error returned within ABCI server #[derive(Debug, thiserror::Error)] -pub enum Error { +pub enum AbciError { /// Invalid system state #[error("invalid state: {0}")] InvalidState(String), + + /// Bad request received from Tenderdash + #[error("bad request received from Tenderdash: {0}")] + BadRequest(String), /// Error returned by tenderdash-abci library #[cfg(feature = "server")] #[error("tenderdash: {0}")] diff --git a/packages/rs-drive-abci/src/abci/mod.rs b/packages/rs-drive-abci/src/abci/mod.rs index 412925a832e..a144c50118b 100644 --- a/packages/rs-drive-abci/src/abci/mod.rs +++ b/packages/rs-drive-abci/src/abci/mod.rs @@ -6,7 +6,7 @@ pub mod handlers; #[deprecated = "use tenderdash-proto crate whenever possible"] pub mod messages; -// new code - config, +// new code - config, #[cfg(feature = "server")] pub mod config; #[cfg(feature = "server")] @@ -14,6 +14,6 @@ mod proposal; #[cfg(feature = "server")] mod server; -pub use error::Error; +pub use error::AbciError; #[cfg(feature = "server")] pub use server::start; diff --git a/packages/rs-drive-abci/src/abci/proposal.rs b/packages/rs-drive-abci/src/abci/proposal.rs index b40704a6144..ff223d98099 100644 --- a/packages/rs-drive-abci/src/abci/proposal.rs +++ b/packages/rs-drive-abci/src/abci/proposal.rs @@ -14,6 +14,8 @@ use tenderdash_abci::proto::{ serializers::timestamp::ToMilis, }; +use super::AbciError; + pub trait Proposal { fn prepare_proposal( &self, @@ -29,7 +31,11 @@ impl Proposal for Platform { transaction: TransactionArg, ) -> Result { let genesis_time_ms = if request.height == self.config.abci.genesis_height { - let block_time_ms = request.time.clone().unwrap().to_milis(); + let block_time_ms = request + .time + .clone() + .ok_or(AbciError::BadRequest(String::from("missing proposal time")))? + .to_milis(); self.drive.set_genesis_time(block_time_ms); block_time_ms } else { @@ -39,20 +45,17 @@ impl Proposal for Platform { .map_err(Error::Drive)? .ok_or(Error::Execution(ExecutionError::DriveIncoherence( "the genesis time must be set", - ))) - .unwrap() + )))? }; // Update versions let proposed_app_version = request.proposed_app_version; - self.drive - .update_validator_proposed_app_version( - vec_to_array(&request.proposer_pro_tx_hash).expect("invalid proposer protxhash"), - proposed_app_version as u32, - transaction, - ) - .unwrap(); + self.drive.update_validator_proposed_app_version( + vec_to_array(&request.proposer_pro_tx_hash).expect("invalid proposer protxhash"), + proposed_app_version as u32, + transaction, + )?; // Init block execution context let block_info = BlockStateInfo::from_prepare_proposal_request(&request); diff --git a/packages/rs-drive-abci/src/abci/server.rs b/packages/rs-drive-abci/src/abci/server.rs index fba7d4a8808..b8fd27a3c34 100644 --- a/packages/rs-drive-abci/src/abci/server.rs +++ b/packages/rs-drive-abci/src/abci/server.rs @@ -24,13 +24,12 @@ pub fn start(config: &PlatformConfig) -> Result<(), Error> { let bind_address = config.abci.bind_address.clone(); let abci_config = config.abci.clone(); - let platform: Platform = - Platform::open(config.db_path.to_owned(), Some(config.to_owned())).unwrap(); + let platform: Platform = Platform::open(&config.db_path, Some(config.clone()))?; let abci = AbciApplication::new(abci_config, &platform)?; - let server = - tenderdash_abci::start_server(&bind_address, abci).map_err(|e| super::Error::from(e))?; + let server = tenderdash_abci::start_server(&bind_address, abci) + .map_err(|e| super::AbciError::from(e))?; loop { tracing::info!("waiting for new connection"); @@ -58,7 +57,9 @@ impl<'a> AbciApplication<'a> { /// Return locked Platform object fn platform(&self) -> MutexGuard<&'a Platform> { - self.platform.lock().unwrap() + self.platform + .lock() + .expect("cannot acquire lock on platform") } /// Return current transaction. @@ -97,12 +98,8 @@ impl<'a> tenderdash_abci::Application for AbciApplication<'a> { fn init_chain(&self, request: proto::RequestInitChain) -> proto::ResponseInitChain { let platform = self.platform(); let transaction = self.transaction(); - - let genesis_time = request - .time - .clone() - .expect("genesis time is required") - .to_milis() as TimestampMillis; + let genesis_time = + request.time.expect("genesis time is required").to_milis() as TimestampMillis; platform .create_genesis_state(genesis_time, self.config.keys.clone().into(), transaction) diff --git a/packages/rs-drive-abci/src/config.rs b/packages/rs-drive-abci/src/config.rs index f2f32540669..e5cbbb3c9ae 100644 --- a/packages/rs-drive-abci/src/config.rs +++ b/packages/rs-drive-abci/src/config.rs @@ -164,7 +164,6 @@ mod tests { fn test_config_from_env() { let envfile = format!("{}/.env.example", env!("CARGO_MANIFEST_DIR")); let envfile = std::path::PathBuf::from(envfile); - dbg!(&envfile); dotenvy::from_path(envfile.as_path()).expect("cannot load .env file"); assert_eq!("5", env::var("QUORUM_SIZE").unwrap()); diff --git a/packages/rs-drive-abci/src/error/mod.rs b/packages/rs-drive-abci/src/error/mod.rs index ac6b8a1198c..3b9abf02dbb 100644 --- a/packages/rs-drive-abci/src/error/mod.rs +++ b/packages/rs-drive-abci/src/error/mod.rs @@ -1,4 +1,4 @@ -use crate::abci::Error as AbciError; +use crate::abci::AbciError; use crate::error::execution::ExecutionError; use crate::error::serialization::SerializationError; use drive::dpp::ProtocolError; diff --git a/packages/rs-drive-abci/src/main.rs b/packages/rs-drive-abci/src/main.rs index 4ba2c7bbee8..7d6bfeef3ff 100644 --- a/packages/rs-drive-abci/src/main.rs +++ b/packages/rs-drive-abci/src/main.rs @@ -73,31 +73,24 @@ fn dump_config(config: &PlatformConfig) { } fn load_config(path: &Option) -> PlatformConfig { - match path { - Some(path) => { - if let Err(e) = dotenvy::from_path(path) { - panic!("cannot load config file {:?}: {}", path, e); - } + if let Some(path) = path { + if let Err(e) = dotenvy::from_path(path) { + panic!("cannot load config file {:?}: {}", path, e); } - None => { - if let Err(e) = dotenvy::dotenv() { - if e.not_found() { - warn!("cannot find any matching .env file"); - } else { - panic!("cannot load config file: {}", e); - } - } + } else if let Err(e) = dotenvy::dotenv() { + if e.not_found() { + warn!("cannot find any matching .env file"); + } else { + panic!("cannot load config file: {}", e); } - }; + } let config = PlatformConfig::from_env(); if let Err(ref e) = config { - if let drive_abci::error::Error::Configuration(src) = e { - if let envy::Error::MissingValue(e2) = src { - panic!("missing configuration option: {}", e2.to_uppercase()); - }; - panic!("cannot parse configuration file: {}", e); + if let drive_abci::error::Error::Configuration(envy::Error::MissingValue(field)) = e { + panic!("missing configuration option: {}", field.to_uppercase()); } + panic!("cannot parse configuration file: {}", e); }; config.expect("cannot parse configuration file") diff --git a/packages/rs-drive-nodejs/src/lib.rs b/packages/rs-drive-nodejs/src/lib.rs index 415b94d87ea..31abef54eb0 100644 --- a/packages/rs-drive-nodejs/src/lib.rs +++ b/packages/rs-drive-nodejs/src/lib.rs @@ -117,8 +117,10 @@ impl PlatformWrapper { }; //core_addr: Vec<&str> let core_addr: Vec<&str> = core_rpc_url.split(':').collect(); - let core_host = core_addr.first().unwrap(); - let core_port = core_addr.get(1).unwrap(); + let core_host = core_addr.first().expect("missing core address"); + let core_port = core_addr + .get(1) + .expect("missing port number in core address"); let core_config = CoreConfig { rpc: CoreRpcConfig { host: core_host.to_string(), From 75a088b1157aafd80ecce2a37704d81d006104a9 Mon Sep 17 00:00:00 2001 From: Lukasz Klimek <842586+lklimek@users.noreply.github.com> Date: Fri, 24 Mar 2023 10:59:29 +0100 Subject: [PATCH 16/19] chore(rs-drive-abci): use AsRef instead of clone in prepare_proposal time --- packages/rs-drive-abci/src/abci/proposal.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/rs-drive-abci/src/abci/proposal.rs b/packages/rs-drive-abci/src/abci/proposal.rs index ff223d98099..b363aabd523 100644 --- a/packages/rs-drive-abci/src/abci/proposal.rs +++ b/packages/rs-drive-abci/src/abci/proposal.rs @@ -33,7 +33,7 @@ impl Proposal for Platform { let genesis_time_ms = if request.height == self.config.abci.genesis_height { let block_time_ms = request .time - .clone() + .as_ref() .ok_or(AbciError::BadRequest(String::from("missing proposal time")))? .to_milis(); self.drive.set_genesis_time(block_time_ms); From fdb488328fb5e54c567b89d832e9391a9f5c9b90 Mon Sep 17 00:00:00 2001 From: Lukasz Klimek <842586+lklimek@users.noreply.github.com> Date: Fri, 24 Mar 2023 12:46:14 +0100 Subject: [PATCH 17/19] chore(rs-drive-abci): Application handlers can return ResponseException --- packages/rs-drive-abci/src/abci/mod.rs | 4 +- packages/rs-drive-abci/src/abci/proposal.rs | 23 +++--- packages/rs-drive-abci/src/abci/server.rs | 90 +++++++-------------- packages/rs-drive-abci/src/error/mod.rs | 10 +++ 4 files changed, 52 insertions(+), 75 deletions(-) diff --git a/packages/rs-drive-abci/src/abci/mod.rs b/packages/rs-drive-abci/src/abci/mod.rs index a144c50118b..d70cdd43104 100644 --- a/packages/rs-drive-abci/src/abci/mod.rs +++ b/packages/rs-drive-abci/src/abci/mod.rs @@ -1,9 +1,9 @@ mod error; // old code - handlers and messages -#[deprecated = "logic moved to [server] and [proposal] mod"] +// #[deprecated = "logic moved to [server] and [proposal] mod"] pub mod handlers; -#[deprecated = "use tenderdash-proto crate whenever possible"] +// #[deprecated = "use tenderdash-proto crate whenever possible"] pub mod messages; // new code - config, diff --git a/packages/rs-drive-abci/src/abci/proposal.rs b/packages/rs-drive-abci/src/abci/proposal.rs index b363aabd523..6864ccdff9e 100644 --- a/packages/rs-drive-abci/src/abci/proposal.rs +++ b/packages/rs-drive-abci/src/abci/proposal.rs @@ -10,7 +10,7 @@ use crate::{ use dpp::util::vec::vec_to_array; use drive::query::TransactionArg; use tenderdash_abci::proto::{ - abci::{self as proto, ExecTxResult}, + abci::{self as proto, ExecTxResult, ResponseException}, serializers::timestamp::ToMilis, }; @@ -21,7 +21,7 @@ pub trait Proposal { &self, request: &proto::RequestPrepareProposal, transaction: TransactionArg, - ) -> Result; + ) -> Result; } impl Proposal for Platform { @@ -29,12 +29,12 @@ impl Proposal for Platform { &self, request: &proto::RequestPrepareProposal, transaction: TransactionArg, - ) -> Result { + ) -> Result { let genesis_time_ms = if request.height == self.config.abci.genesis_height { let block_time_ms = request .time .as_ref() - .ok_or(AbciError::BadRequest(String::from("missing proposal time")))? + .ok_or("missing proposal time")? .to_milis(); self.drive.set_genesis_time(block_time_ms); block_time_ms @@ -51,11 +51,14 @@ impl Proposal for Platform { // Update versions let proposed_app_version = request.proposed_app_version; - self.drive.update_validator_proposed_app_version( - vec_to_array(&request.proposer_pro_tx_hash).expect("invalid proposer protxhash"), - proposed_app_version as u32, - transaction, - )?; + self.drive + .update_validator_proposed_app_version( + vec_to_array(&request.proposer_pro_tx_hash) + .map_err(|e| format!("invalid proposer protxhash: {}", e))?, + proposed_app_version as u32, + transaction, + ) + .map_err(|e| format!("cannot update proposed app version: {}", e))?; // Init block execution context let block_info = BlockStateInfo::from_prepare_proposal_request(&request); @@ -102,7 +105,7 @@ impl Proposal for Platform { } // TODO: implement all fields, including tx processing; for now, just leaving bare minimum let response = proto::ResponsePrepareProposal { - app_hash: vec![0, 32], // TODO: implement + app_hash: vec![0; 32], // TODO: implement tx_results, ..Default::default() }; diff --git a/packages/rs-drive-abci/src/abci/server.rs b/packages/rs-drive-abci/src/abci/server.rs index b8fd27a3c34..a842ed4a06c 100644 --- a/packages/rs-drive-abci/src/abci/server.rs +++ b/packages/rs-drive-abci/src/abci/server.rs @@ -5,8 +5,10 @@ use crate::{abci::proposal::Proposal, config::PlatformConfig, error::Error, plat use dpp::identity::TimestampMillis; use drive::query::TransactionArg; use std::{fmt::Debug, sync::MutexGuard}; -use tenderdash_abci::proto::{abci as proto, serializers::timestamp::ToMilis}; -use tracing::debug; +use tenderdash_abci::proto::{ + abci::{self as proto, ResponseException}, + serializers::timestamp::ToMilis, +}; /// AbciApp is an implementation of ABCI Application, as defined by Tenderdash. /// /// AbciApp implements logic that should be triggered when Tenderdash performs various operations, like @@ -76,13 +78,13 @@ impl<'a> Debug for AbciApplication<'a> { } impl<'a> tenderdash_abci::Application for AbciApplication<'a> { - fn info(&self, request: proto::RequestInfo) -> proto::ResponseInfo { - if !check_version(&request.abci_version, tenderdash_abci::proto::ABCI_VERSION) { - panic!( - "SemVer mismatch: Tenderdash requires ABCI version {}, our version is {}", + fn info(&self, request: proto::RequestInfo) -> Result { + if !tenderdash_abci::check_version(&request.abci_version) { + return Err(ResponseException::from(format!( + "tenderdash requires ABCI version {}, our version is {}", request.version, tenderdash_abci::proto::ABCI_VERSION - ); + ))); } let response = proto::ResponseInfo { @@ -92,85 +94,47 @@ impl<'a> tenderdash_abci::Application for AbciApplication<'a> { }; tracing::info!(method = "info", ?request, ?response, "info executed"); - response + Ok(response) } - fn init_chain(&self, request: proto::RequestInitChain) -> proto::ResponseInitChain { + fn init_chain( + &self, + request: proto::RequestInitChain, + ) -> Result { let platform = self.platform(); let transaction = self.transaction(); - let genesis_time = - request.time.expect("genesis time is required").to_milis() as TimestampMillis; + let genesis_time = request + .time + .ok_or("genesis time is required in init chain")? + .to_milis() as TimestampMillis; - platform - .create_genesis_state(genesis_time, self.config.keys.clone().into(), transaction) - .expect("create genesis state"); + platform.create_genesis_state( + genesis_time, + self.config.keys.clone().into(), + transaction, + )?; let response = proto::ResponseInitChain { ..Default::default() }; tracing::info!(method = "init_chain", "init chain executed"); - response + Ok(response) } fn prepare_proposal( &self, request: proto::RequestPrepareProposal, - ) -> proto::ResponsePrepareProposal { + ) -> Result { let platform = self.platform(); let transaction = self.transaction(); - let response = platform - .prepare_proposal(&request, transaction) - .expect("failed to prepare proposal"); + let response = platform.prepare_proposal(&request, transaction)?; tracing::info!( method = "prepare_proposal", height = request.height, "prepare proposal executed", ); - response - } -} - -/// Check if ABCI version required by Tenderdash matches our protobuf version. -/// -/// Match is determined based on Semantic Versioning rules, as defined for '^' operator. -fn check_version(tenderdash_abci_requirement: &str, our_abci_version: &str) -> bool { - let our_version = - semver::Version::parse(our_abci_version).expect("cannot parse protobuf library version"); - - let require = String::from("^") + tenderdash_abci_requirement; - let td_version = - semver::VersionReq::parse(require.as_str()).expect("cannot parse tenderdash version"); - - debug!("ABCI version: required: {}, our: {}", require, our_version); - - td_version.matches(&our_version) -} - -#[cfg(test)] -mod tests { - use crate::abci::server::check_version; - - /// test_versions! {} (td_version, our_version, expected); } - macro_rules! test_versions { - ($($name:ident: $value:expr,)*) => { - $( - #[test] - fn $name() { - let (td, our, expect) = $value; - assert_eq!(check_version(td, our),expect); - } - )* - } - } - - test_versions! { - test_versions_td_newer: ("0.1.2-dev.1", "0.1.0", false), - test_versions_equal: ("0.1.0","0.1.0",true), - test_versions_td_older: ("0.1.0","0.1.2",true), - test_versions_equal_dev: ("0.1.0-dev.1","0.1.0-dev.1",true), - test_versions_our_newer_dev: ("0.1.0-dev.1", "0.1.0-dev.2",true), - test_versions_our_dev:("0.1.0","0.1.0-dev.1",false), + Ok(response) } } diff --git a/packages/rs-drive-abci/src/error/mod.rs b/packages/rs-drive-abci/src/error/mod.rs index 3b9abf02dbb..085baf5e899 100644 --- a/packages/rs-drive-abci/src/error/mod.rs +++ b/packages/rs-drive-abci/src/error/mod.rs @@ -3,7 +3,9 @@ use crate::error::execution::ExecutionError; use crate::error::serialization::SerializationError; use drive::dpp::ProtocolError; use drive::error::Error as DriveError; +use tenderdash_abci::proto::abci::ResponseException; use tracing::error; + /// Execution errors module pub mod execution; @@ -32,3 +34,11 @@ pub enum Error { #[error("configuration: {0}")] Configuration(#[from] envy::Error), } + +impl From for ResponseException { + fn from(value: Error) -> Self { + Self { + error: value.to_string(), + } + } +} From 25c312e380fb86c9ddef6b2094b7118a061476be Mon Sep 17 00:00:00 2001 From: Lukasz Klimek <842586+lklimek@users.noreply.github.com> Date: Fri, 24 Mar 2023 13:26:27 +0100 Subject: [PATCH 18/19] build(rs-drive-abci): remove unused semver dependency --- Cargo.lock | 599 ++++++++++++++++-------------- packages/rs-drive-abci/Cargo.toml | 10 +- 2 files changed, 323 insertions(+), 286 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6562ebb89a3..8af0251ccb0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -60,15 +60,15 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.69" +version = "1.0.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "224afbd727c3d6e4b90103ece64b8d1b67fbb1973b1046c2281eed3f3803f800" +checksum = "7de8ce5e0f9f8d88245311066a578d72b7af3e7088f32783804676302df237e4" [[package]] name = "arrayref" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" +checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" [[package]] name = "arrayvec" @@ -78,13 +78,13 @@ checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" [[package]] name = "async-trait" -version = "0.1.64" +version = "0.1.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cd7fce9ba8c3c042128ce72d8b2ddbf3a05747efb67ea0313c635e10bda47a2" +checksum = "86ea188f25f0255d8f92797797c97ebf5631fa88178beb1a46fdf5622c9a00e4" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.8", ] [[package]] @@ -169,7 +169,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn", + "syn 1.0.109", ] [[package]] @@ -245,9 +245,9 @@ dependencies = [ [[package]] name = "block-buffer" -version = "0.10.3" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" dependencies = [ "generic-array", ] @@ -286,9 +286,9 @@ dependencies = [ [[package]] name = "borsh" -version = "0.10.1" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3ef05d137e34b7ac51dbec170ee523a9b728cff71385796771d259771d592f8" +checksum = "4114279215a005bc675e386011e594e1d9b800918cea18fcadadcce864a2046b" dependencies = [ "borsh-derive", "hashbrown 0.13.2", @@ -296,37 +296,37 @@ dependencies = [ [[package]] name = "borsh-derive" -version = "0.10.1" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "190b1188f062217531748807129459c8c14641b648e887e39681a433db7fc939" +checksum = "0754613691538d51f329cce9af41d7b7ca150bc973056f1156611489475f54f7" dependencies = [ "borsh-derive-internal", "borsh-schema-derive-internal", "proc-macro-crate 0.1.5", "proc-macro2", - "syn", + "syn 1.0.109", ] [[package]] name = "borsh-derive-internal" -version = "0.10.1" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0fcf747a3e4eb47869441664df09d0eb88dcc9a85d499860efb82c2cfe6affc" +checksum = "afb438156919598d2c7bad7e1c0adf3d26ed3840dbc010db1a882a65583ca2fb" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] name = "borsh-schema-derive-internal" -version = "0.10.1" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f671d085f791c5fd3331c843ded45454b034b6188bf0f78ed28e7fd66a8b3f69" +checksum = "634205cc43f74a1b9046ef87c4540ebda95696ec0f315024860cad7c5b0f5ccd" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -343,23 +343,24 @@ checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" [[package]] name = "bytecheck" -version = "0.6.9" +version = "0.6.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d11cac2c12b5adc6570dad2ee1b87eff4955dac476fe12d81e5fdd352e52406f" +checksum = "13fe11640a23eb24562225322cd3e452b93a3d4091d62fab69c70542fcd17d1f" dependencies = [ "bytecheck_derive", "ptr_meta", + "simdutf8", ] [[package]] name = "bytecheck_derive" -version = "0.6.9" +version = "0.6.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13e576ebe98e605500b3c8041bb888e966653577172df6dd97398714eb30b9bf" +checksum = "e31225543cb46f81a7e224762764f4a6a0f097b1db0b175f69e8065efaa42de5" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -396,9 +397,9 @@ dependencies = [ [[package]] name = "camino" -version = "1.1.2" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c77df041dc383319cc661b428b6961a005db4d6808d5e12536931b1ca9556055" +checksum = "c530edf18f37068ac2d977409ed5cd50d53d73bc653c7647b48eb78976ac9ae2" dependencies = [ "serde", ] @@ -503,9 +504,9 @@ dependencies = [ [[package]] name = "clang-sys" -version = "1.4.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa2e27ae6ab525c3d369ded447057bca5438d86dc3a68f6faafb8269ba82ebf3" +checksum = "77ed9a53e5d4d9c573ae844bfac6872b159cb1d1585a83b29e7a64b7eef7332a" dependencies = [ "glob", "libc", @@ -525,9 +526,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.1.8" +version = "4.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3d7ae14b20b94cb02149ed21a86c423859cbe18dc7ed69845cace50e52b40a5" +checksum = "3c911b090850d79fc64fe9ea01e28e465f65e821e08813ced95bced72f7a8a9b" dependencies = [ "bitflags", "clap_derive", @@ -540,22 +541,21 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.1.8" +version = "4.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44bec8e5c9d09e439c4335b1af0abaab56dcf3b94999a936e1bb47b9134288f0" +checksum = "9a932373bab67b984c790ddf2c9ca295d8e3af3b7ef92de5a5bacdccdee4b09b" dependencies = [ "heck 0.4.1", - "proc-macro-error", "proc-macro2", "quote", - "syn", + "syn 2.0.8", ] [[package]] name = "clap_lex" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "350b9cf31731f9957399229e9b2adc51eeabdfbe9d71d9a0552275fd12710d09" +checksum = "033f6b7a4acb1f358c742aaca805c939ee73b4c6209ae4318ec7aca81c42e646" dependencies = [ "os_str_bytes", ] @@ -593,9 +593,15 @@ dependencies = [ [[package]] name = "constant_time_eq" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3ad85c1f65dc7b37604eb0e89748faf0b9653065f2a8ef69f96a687ec1e9279" +checksum = "13418e745008f7349ec7e449155f419a61b92b58a99cc3616942b926825ec76b" + +[[package]] +name = "convert_case" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" [[package]] name = "core-foundation-sys" @@ -660,23 +666,23 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.6" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2dd04ddaf88237dc3b8d8f9a3c1004b506b54b3313403944054d23c0870c521" +checksum = "cf2b3e8478797446514c91ef04bafcb59faba183e621ad488df88983cc14128c" dependencies = [ "cfg-if 1.0.0", - "crossbeam-utils 0.8.14", + "crossbeam-utils 0.8.15", ] [[package]] name = "crossbeam-deque" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "715e8152b692bba2d374b53d4875445368fdf21a94751410af607a5ac677d1fc" +checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" dependencies = [ "cfg-if 1.0.0", - "crossbeam-epoch 0.9.13", - "crossbeam-utils 0.8.14", + "crossbeam-epoch 0.9.14", + "crossbeam-utils 0.8.15", ] [[package]] @@ -696,14 +702,14 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.13" +version = "0.9.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01a9af1f4c2ef74bb8aa1f7e19706bc72d03598c8a570bb5de72243c7a9d9d5a" +checksum = "46bd5f3f85273295a9d14aedfb86f6aadbff6d8f5295c4a9edb08e819dcf5695" dependencies = [ "autocfg", "cfg-if 1.0.0", - "crossbeam-utils 0.8.14", - "memoffset 0.7.1", + "crossbeam-utils 0.8.15", + "memoffset 0.8.0", "scopeguard", ] @@ -720,9 +726,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.14" +version = "0.8.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb766fa798726286dbbb842f174001dab8abc7b627a1dd86e0b7222a95d929f" +checksum = "3c063cd8cc95f5c377ed0d4b49a4b21f632396ff690e8470c29b3359b346984b" dependencies = [ "cfg-if 1.0.0", ] @@ -749,9 +755,9 @@ dependencies = [ [[package]] name = "csv" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af91f40b7355f82b0a891f50e70399475945bb0b0da4f1700ce60761c9d3e359" +checksum = "0b015497079b9a9d69c02ad25de6c0a6edef051ea6360a327d0bd05802ef64ad" dependencies = [ "csv-core", "itoa", @@ -775,14 +781,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d2301688392eb071b0bf1a37be05c469d3cc4dbbd95df672fe28ab021e6a096" dependencies = [ "quote", - "syn", + "syn 1.0.109", ] [[package]] name = "cxx" -version = "1.0.90" +version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90d59d9acd2a682b4e40605a242f6670eaa58c5957471cbf85e8aa6a0b97a5e8" +checksum = "a9c00419335c41018365ddf7e4d5f1c12ee3659ddcf3e01974650ba1de73d038" dependencies = [ "cc", "cxxbridge-flags", @@ -792,9 +798,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.90" +version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebfa40bda659dd5c864e65f4c9a2b0aff19bea56b017b9b77c73d3766a453a38" +checksum = "fb8307ad413a98fff033c8545ecf133e3257747b3bae935e7602aab8aa92d4ca" dependencies = [ "cc", "codespan-reporting", @@ -802,31 +808,31 @@ dependencies = [ "proc-macro2", "quote", "scratch", - "syn", + "syn 2.0.8", ] [[package]] name = "cxxbridge-flags" -version = "1.0.90" +version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "457ce6757c5c70dc6ecdbda6925b958aae7f959bda7d8fb9bde889e34a09dc03" +checksum = "edc52e2eb08915cb12596d29d55f0b5384f00d697a646dbd269b6ecb0fbd9d31" [[package]] name = "cxxbridge-macro" -version = "1.0.90" +version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebf883b7aacd7b2aeb2a7b338648ee19f57c140d4ee8e52c68979c6b2f7f2263" +checksum = "631569015d0d8d54e6c241733f944042623ab6df7bc3be7466874b05fcdb1c5f" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.8", ] [[package]] name = "darling" -version = "0.14.3" +version = "0.14.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0808e1bd8671fb44a113a14e13497557533369847788fa2ae912b6ebfce9fa8" +checksum = "7b750cb3417fd1b327431a470f388520309479ab0bf5e323505daf0290cd3850" dependencies = [ "darling_core", "darling_macro", @@ -834,27 +840,27 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.14.3" +version = "0.14.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "001d80444f28e193f30c2f293455da62dcf9a6b29918a4253152ae2b1de592cb" +checksum = "109c1ca6e6b7f82cc233a97004ea8ed7ca123a9af07a8230878fcfda9b158bf0" dependencies = [ "fnv", "ident_case", "proc-macro2", "quote", "strsim", - "syn", + "syn 1.0.109", ] [[package]] name = "darling_macro" -version = "0.14.3" +version = "0.14.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b36230598a2d5de7ec1c6f51f72d8a99a9208daff41de2084d06e3fd3ea56685" +checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e" dependencies = [ "darling_core", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -914,6 +920,19 @@ dependencies = [ "withdrawals-contract", ] +[[package]] +name = "derive_more" +version = "0.99.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" +dependencies = [ + "convert_case", + "proc-macro2", + "quote", + "rustc_version", + "syn 1.0.109", +] + [[package]] name = "diff" version = "0.1.13" @@ -941,16 +960,16 @@ version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" dependencies = [ - "block-buffer 0.10.3", + "block-buffer 0.10.4", "crypto-common", "subtle", ] [[package]] name = "dotenvy" -version = "0.15.6" +version = "0.15.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03d8c417d7a8cb362e0c37e5d815f5eb7c37f79ff93707329d5a194e42e54ca0" +checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" [[package]] name = "downcast" @@ -1053,7 +1072,7 @@ dependencies = [ "bytes", "chrono", "ciborium", - "clap 4.1.8", + "clap 4.1.13", "dashcore", "dashcore-rpc", "dotenvy", @@ -1068,7 +1087,6 @@ dependencies = [ "rand", "rust_decimal", "rust_decimal_macros", - "semver 1.0.17", "serde", "serde_json", "serde_with", @@ -1108,7 +1126,7 @@ checksum = "06a91d774f4b861acaa791bc6165e66d72d3a5d1aa85fc8c0956f5580f863161" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1119,9 +1137,9 @@ checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" [[package]] name = "enum-map" -version = "2.4.2" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50c25992259941eb7e57b936157961b217a4fc8597829ddef0596d6c3cd86e1a" +checksum = "988f0d17a0fa38291e5f41f71ea8d46a5d5497b9054d5a759fae2cbb819f2356" dependencies = [ "enum-map-derive", ] @@ -1134,7 +1152,7 @@ checksum = "2a4da76b3b6116d758c7ba93f7ec6a35d2e2cf24feda76c6e38a375f4d5c59f2" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1207,7 +1225,7 @@ checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", "synstructure", ] @@ -1317,9 +1335,9 @@ checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "futures" -version = "0.3.26" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13e2792b0ff0340399d58445b88fd9770e3489eff258a4cbc1523418f12abf84" +checksum = "531ac96c6ff5fd7c62263c5e3c67a603af4fcaee2e1a0ae5565ba3a11e69e549" dependencies = [ "futures-channel", "futures-core", @@ -1332,9 +1350,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.26" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e5317663a9089767a1ec00a487df42e0ca174b61b4483213ac24448e4664df5" +checksum = "164713a5a0dcc3e7b4b1ed7d3b433cabc18025386f9339346e8daf15963cf7ac" dependencies = [ "futures-core", "futures-sink", @@ -1342,15 +1360,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.26" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec90ff4d0fe1f57d600049061dc6bb68ed03c7d2fbd697274c41805dcb3f8608" +checksum = "86d7a0c1aa76363dac491de0ee99faf6941128376f1cf96f07db7603b7de69dd" [[package]] name = "futures-executor" -version = "0.3.26" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8de0a35a6ab97ec8869e32a2473f4b1324459e14c29275d14b10cb1fd19b50e" +checksum = "1997dd9df74cdac935c76252744c1ed5794fac083242ea4fe77ef3ed60ba0f83" dependencies = [ "futures-core", "futures-task", @@ -1359,38 +1377,38 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.26" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfb8371b6fb2aeb2d280374607aeabfc99d95c72edfe51692e42d3d7f0d08531" +checksum = "89d422fa3cbe3b40dca574ab087abb5bc98258ea57eea3fd6f1fa7162c778b91" [[package]] name = "futures-macro" -version = "0.3.26" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95a73af87da33b5acf53acfebdc339fe592ecf5357ac7c0a7734ab9d8c876a70" +checksum = "3eb14ed937631bd8b8b8977f2c198443447a8355b6e3ca599f38c975e5a963b6" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] name = "futures-sink" -version = "0.3.26" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f310820bb3e8cfd46c80db4d7fb8353e15dfff853a127158425f31e0be6c8364" +checksum = "ec93083a4aecafb2a80a885c9de1f0ccae9dbd32c2bb54b0c3a65690e0b8d2f2" [[package]] name = "futures-task" -version = "0.3.26" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcf79a1bf610b10f42aea489289c5a2c478a786509693b80cd39c44ccd936366" +checksum = "fd65540d33b37b16542a0438c12e6aeead10d4ac5d05bd3f805b8f35ab592879" [[package]] name = "futures-util" -version = "0.3.26" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c1d6de3acfef38d2be4b1f543f553131788603495be83da675e180c8d6b7bd1" +checksum = "3ef6b17e481503ec85211fed8f39d1970f128935ca1f814cd32ac4a6842e84ab" dependencies = [ "futures-channel", "futures-core", @@ -1429,9 +1447,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.27.1" +version = "0.27.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "221996f774192f0f718773def8201c4ae31f02616a54ccfc2d358bb0e5cefdec" +checksum = "ad0a93d233ebf96623465aad4046a8d3aa4da22d4f4beba5388838c8a434bbb4" [[package]] name = "git2" @@ -1583,16 +1601,16 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "iana-time-zone" -version = "0.1.53" +version = "0.1.54" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64c122667b287044802d6ce17ee2ddf13207ed924c712de9a66a5814d5b64765" +checksum = "0c17cc76786e99f8d2f055c11159e7f0091c42474dcc3189fbab96072e873e6d" dependencies = [ "android_system_properties", "core-foundation-sys", "iana-time-zone-haiku", "js-sys", "wasm-bindgen", - "winapi", + "windows", ] [[package]] @@ -1658,19 +1676,20 @@ dependencies = [ [[package]] name = "io-lifetimes" -version = "1.0.6" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfa919a82ea574332e2de6e74b4c36e74d41982b335080fa59d4ef31be20fdf3" +checksum = "09270fd4fa1111bc614ed2246c7ef56239a3063d5be0d1ec3b589c505d400aeb" dependencies = [ + "hermit-abi 0.3.1", "libc", "windows-sys 0.45.0", ] [[package]] name = "is-terminal" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21b6b32576413a8e69b90e952e4a026476040d81017b80445deda5f2d3921857" +checksum = "8687c819457e979cc940d09cb16e42a1bf70aa6b60a549de6d3a62a0ee90c69e" dependencies = [ "hermit-abi 0.3.1", "io-lifetimes", @@ -1698,9 +1717,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.5" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440" +checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" [[package]] name = "jemalloc-sys" @@ -1725,9 +1744,9 @@ dependencies = [ [[package]] name = "jobserver" -version = "0.1.25" +version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "068b1ee6743e4d11fb9c6a1e6064b3693a1b600e7f5f5988047d98b3dc9fb90b" +checksum = "936cfd212a0155903bcbc060e316fb6cc7cbf2e1907329391ebadc1fe0ce77c2" dependencies = [ "libc", ] @@ -1796,7 +1815,7 @@ dependencies = [ "regex", "serde", "serde_json", - "time 0.3.17", + "time 0.3.20", "url", "uuid 0.8.2", ] @@ -1815,9 +1834,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.139" +version = "0.2.140" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" +checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c" [[package]] name = "libgit2-sys" @@ -1976,9 +1995,9 @@ dependencies = [ [[package]] name = "memoffset" -version = "0.7.1" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" +checksum = "d61c719bcfbcf5d62b3a09efa6088de8c54bc0bfcd3ea7ae39fcc186108b8de1" dependencies = [ "autocfg", ] @@ -2002,7 +2021,7 @@ dependencies = [ "rand", "storage", "thiserror", - "time 0.3.17", + "time 0.3.20", "visualize", ] @@ -2057,7 +2076,7 @@ dependencies = [ "cfg-if 1.0.0", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -2068,7 +2087,7 @@ checksum = "975fa04238144061e7f8df9746b2e9cd93ef85881da5548d842a7c6a4b614415" dependencies = [ "crossbeam-channel", "crossbeam-epoch 0.8.2", - "crossbeam-utils 0.8.14", + "crossbeam-utils 0.8.15", "num_cpus", "once_cell", "parking_lot", @@ -2114,7 +2133,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b7288eac8b54af7913c60e0eb0e2a7683020dffa342ab3fd15e28f035ba897cf" dependencies = [ "quote", - "syn", + "syn 1.0.109", "syn-mid", ] @@ -2145,15 +2164,6 @@ dependencies = [ "minimal-lexical", ] -[[package]] -name = "nom8" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae01545c9c7fc4486ab7debaf2aad7003ac19431791868fb2e8066df97fad2f8" -dependencies = [ - "memchr", -] - [[package]] name = "normalize-line-endings" version = "0.3.0" @@ -2253,7 +2263,7 @@ checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -2322,23 +2332,23 @@ dependencies = [ [[package]] name = "num_enum" -version = "0.5.9" +version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d829733185c1ca374f17e52b762f24f535ec625d2cc1f070e34c8a9068f341b" +checksum = "1f646caf906c20226733ed5b1374287eb97e3c2a5c227ce668c1f2ce20ae57c9" dependencies = [ "num_enum_derive", ] [[package]] name = "num_enum_derive" -version = "0.5.9" +version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2be1598bf1c313dcdd12092e3f1920f463462525a21b7b4e11b4168353d0123e" +checksum = "dcbff9bc912032c62bf65ef1d5aea88983b420f4f839db1e9b0c281a25c9c799" dependencies = [ - "proc-macro-crate 1.3.0", + "proc-macro-crate 1.3.1", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -2352,9 +2362,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.17.0" +version = "1.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" +checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" [[package]] name = "oorandom" @@ -2376,9 +2386,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.82" +version = "0.9.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a95792af3c4e0153c3914df2261bedd30a98476f94dc892b67dfe1d89d433a04" +checksum = "666416d899cf077260dac8698d60a60b435a46d57e82acb1be3d0dad87284e5b" dependencies = [ "autocfg", "cc", @@ -2389,9 +2399,9 @@ dependencies = [ [[package]] name = "os_str_bytes" -version = "6.4.1" +version = "6.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee" +checksum = "ceedf44fb00f2d1984b0bc98102627ce622e083e49a5bacdb3e514fa4238e267" [[package]] name = "output_vt100" @@ -2548,15 +2558,15 @@ dependencies = [ [[package]] name = "predicates-core" -version = "1.0.5" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72f883590242d3c6fc5bf50299011695fa6590c2c70eac95ee1bdb9a733ad1a2" +checksum = "b794032607612e7abeb4db69adb4e33590fa6cf1149e95fd7cb00e634b92f174" [[package]] name = "predicates-tree" -version = "1.0.7" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54ff541861505aabf6ea722d2131ee980b8276e10a1297b94e896dd8b621850d" +checksum = "368ba315fb8c5052ab692e68a0eefec6ec57b23a36959c14496f0b0df2c0cecf" dependencies = [ "predicates-core", "termtree", @@ -2581,7 +2591,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c8646e95016a7a6c4adea95bafa8a16baab64b583356217f2c85db4a39d9a86" dependencies = [ "proc-macro2", - "syn", + "syn 1.0.109", ] [[package]] @@ -2595,9 +2605,9 @@ dependencies = [ [[package]] name = "proc-macro-crate" -version = "1.3.0" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66618389e4ec1c7afe67d51a9bf34ff9236480f8d51e7489b7d5ab0303c13f34" +checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" dependencies = [ "once_cell", "toml_edit", @@ -2612,7 +2622,7 @@ dependencies = [ "proc-macro-error-attr", "proc-macro2", "quote", - "syn", + "syn 1.0.109", "version_check", ] @@ -2629,9 +2639,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.51" +version = "1.0.53" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d727cae5b39d21da60fa540906919ad737832fe0b1c165da3a34d6548c849d6" +checksum = "ba466839c78239c09faf015484e5cc04860f88242cff4d03eb038f04b4699b73" dependencies = [ "unicode-ident", ] @@ -2663,7 +2673,7 @@ dependencies = [ "prost", "prost-types", "regex", - "syn", + "syn 1.0.109", "tempfile", "which", ] @@ -2678,7 +2688,7 @@ dependencies = [ "itertools", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -2707,7 +2717,7 @@ checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -2727,7 +2737,7 @@ version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b7e31331286705f455e56cca62e0e717158474ff02b7936c1fa596d983f4ae27" dependencies = [ - "crossbeam-utils 0.8.14", + "crossbeam-utils 0.8.15", "libc", "mach", "once_cell", @@ -2739,9 +2749,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.23" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" +checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" dependencies = [ "proc-macro2", ] @@ -2784,18 +2794,18 @@ dependencies = [ [[package]] name = "raw-cpuid" -version = "10.6.1" +version = "10.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c307f7aacdbab3f0adee67d52739a1d71112cc068d6fab169ddeb18e48877fad" +checksum = "6c297679cb867470fa8c9f67dbba74a78d78e3e98d7cf2b08d6d71540f797332" dependencies = [ "bitflags", ] [[package]] name = "rayon" -version = "1.6.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6db3a213adf02b3bcfd2d3846bb41cb22857d131789e01df434fb7e7bc0759b7" +checksum = "1d2df5196e37bcc87abebc0053e20787d73847bb33134a69841207dd0a47f03b" dependencies = [ "either", "rayon-core", @@ -2803,13 +2813,13 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.10.2" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "356a0625f1954f730c0201cdab48611198dc6ce21f4acff55089b5a78e6e835b" +checksum = "4b8f95bd6966f5c87776639160a66bd8ab9895d9d4ab01ddba9fc60661aebe8d" dependencies = [ "crossbeam-channel", "crossbeam-deque", - "crossbeam-utils 0.8.14", + "crossbeam-utils 0.8.15", "num_cpus", ] @@ -2824,9 +2834,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.7.1" +version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733" +checksum = "cce168fea28d3e05f158bda4576cf0c844d5045bc2cc3620fa0292ed5bb5814c" dependencies = [ "aho-corasick", "memchr", @@ -2844,18 +2854,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.28" +version = "0.6.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" - -[[package]] -name = "remove_dir_all" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" -dependencies = [ - "winapi", -] +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "rend" @@ -2888,7 +2889,7 @@ checksum = "ff26ed6c7c4dfc2aa9480b86a60e3c7233543a270a680e10758a507c5a4ce476" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -2903,9 +2904,9 @@ dependencies = [ [[package]] name = "rust_decimal" -version = "1.28.1" +version = "1.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e13cf35f7140155d02ba4ec3294373d513a3c7baa8364c162b030e33c61520a8" +checksum = "2b1b21b8760b0ef8ae5b43d40913ff711a2053cb7ff892a34facff7a6365375a" dependencies = [ "arrayvec", "borsh", @@ -2921,9 +2922,9 @@ dependencies = [ [[package]] name = "rust_decimal_macros" -version = "1.28.1" +version = "1.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f79c1532c5088b44236d74c7dd9d80a1c57a433e02694fced7b5a670dc562ce5" +checksum = "7f4709403426683ccd5e1ef02b24a2468fe87f8df8a2a792743bb369d7656efa" dependencies = [ "quote", "rust_decimal", @@ -2931,9 +2932,9 @@ dependencies = [ [[package]] name = "rustc-demangle" -version = "0.1.21" +version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" +checksum = "d4a36c42d1873f9a77c53bde094f9664d9891bc604a45b4798fd2c389ed12e5b" [[package]] name = "rustc-hash" @@ -2941,11 +2942,20 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" +[[package]] +name = "rustc_version" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver 1.0.17", +] + [[package]] name = "rustix" -version = "0.36.9" +version = "0.36.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd5c6ff11fecd55b40746d1995a02f2eb375bf8c00d192d521ee09f42bef37bc" +checksum = "db4165c9963ab29e422d6c26fbc1d37f15bace6b2810221f9d925023480fcf0e" dependencies = [ "bitflags", "errno", @@ -2957,15 +2967,15 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.11" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5583e89e108996506031660fe09baa5011b9dd0341b89029313006d1fb508d70" +checksum = "4f3208ce4d8448b3f3e7d168a73f5e0c43a61e32930de3bceeccedb388b6bf06" [[package]] name = "ryu" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde" +checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" [[package]] name = "same-file" @@ -2978,9 +2988,9 @@ dependencies = [ [[package]] name = "scheduled-thread-pool" -version = "0.2.6" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "977a7519bff143a44f842fd07e80ad1329295bd71686457f18e496736f4bf9bf" +checksum = "3cbc66816425a074528352f5789333ecff06ca41b36b0b0efdfbb29edc391a19" dependencies = [ "parking_lot", ] @@ -2993,9 +3003,9 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "scratch" -version = "1.0.3" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddccb15bcce173023b3fedd9436f882a0739b8dfb45e4f6b6002bee5929f61b2" +checksum = "1792db035ce95be60c3f8853017b3999209281c24e2ba5bc8e59bf97a0c590c1" [[package]] name = "seahash" @@ -3050,9 +3060,9 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.152" +version = "1.0.158" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb" +checksum = "771d4d9c4163ee138805e12c710dd365e4f44be8be0503cb1bb9eb989425d9c9" dependencies = [ "serde_derive", ] @@ -3098,20 +3108,20 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.152" +version = "1.0.158" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e" +checksum = "e801c1712f48475582b7696ac71e0ca34ebb30e09338425384269d9717c62cad" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.8", ] [[package]] name = "serde_json" -version = "1.0.93" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cad406b69c91885b5107daf2c29572f6c8cdb3c66826821e286c533490c0bc76" +checksum = "1c533a59c9d8a93a09c6ab31f0fd5e5f4dd1b8fc9434804029839884765d04ea" dependencies = [ "indexmap", "itoa", @@ -3121,13 +3131,13 @@ dependencies = [ [[package]] name = "serde_repr" -version = "0.1.10" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a5ec9fa74a20ebbe5d9ac23dac1fc96ba0ecfe9f50f2843b52e537b10fbcb4e" +checksum = "bcec881020c684085e55a25f7fd888954d56609ef363479dc5a1305eb0d40cab" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.8", ] [[package]] @@ -3143,7 +3153,7 @@ dependencies = [ "serde", "serde_json", "serde_with_macros", - "time 0.3.17", + "time 0.3.20", ] [[package]] @@ -3155,7 +3165,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -3206,6 +3216,12 @@ dependencies = [ "libc", ] +[[package]] +name = "simdutf8" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a" + [[package]] name = "skeptic" version = "0.13.7" @@ -3223,9 +3239,9 @@ dependencies = [ [[package]] name = "slab" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef" +checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" dependencies = [ "autocfg", ] @@ -3238,9 +3254,9 @@ checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" [[package]] name = "socket2" -version = "0.4.7" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02e2d2db9033d13a1567121ddd7a095ee144db4e1ca1b1bda3419bc0da294ebd" +checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" dependencies = [ "libc", "winapi", @@ -3300,7 +3316,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -3322,7 +3338,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn", + "syn 1.0.109", ] [[package]] @@ -3342,9 +3358,20 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.107" +version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcc02725fd69ab9f26eab07fad303e2497fad6fb9eba4f96c4d1687bdf704ad9" dependencies = [ "proc-macro2", "quote", @@ -3359,7 +3386,7 @@ checksum = "baa8e7560a164edb1621a55d18a0c59abf49d360f47aa7b821061dd7eea7fac9" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -3370,7 +3397,7 @@ checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", "unicode-xid", ] @@ -3388,25 +3415,25 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tempfile" -version = "3.3.0" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" +checksum = "af18f7ae1acd354b992402e9ec5864359d693cd8a79dcbef59f76891701c1e95" dependencies = [ "cfg-if 1.0.0", "fastrand", - "libc", "redox_syscall", - "remove_dir_all", - "winapi", + "rustix", + "windows-sys 0.42.0", ] [[package]] name = "tenderdash-abci" version = "0.12.0-dev.1" -source = "git+https://github.com/dashpay/rs-tenderdash-abci?branch=master#656e6ba8640e9bb046e4e7f1898f7e4e9a063e33" +source = "git+https://github.com/dashpay/rs-tenderdash-abci?branch=master#b7ca26bfb5c8076ccac9bf90519215a343636075" dependencies = [ "bytes", "prost", + "semver 1.0.17", "tenderdash-proto", "thiserror", "tracing", @@ -3417,10 +3444,11 @@ dependencies = [ [[package]] name = "tenderdash-proto" version = "0.12.0-dev.1" -source = "git+https://github.com/dashpay/rs-tenderdash-abci?branch=master#656e6ba8640e9bb046e4e7f1898f7e4e9a063e33" +source = "git+https://github.com/dashpay/rs-tenderdash-abci?branch=master#b7ca26bfb5c8076ccac9bf90519215a343636075" dependencies = [ "bytes", "chrono", + "derive_more", "flex-error", "num-derive", "num-traits", @@ -3430,13 +3458,13 @@ dependencies = [ "serde_bytes", "subtle-encoding", "tenderdash-proto-compiler", - "time 0.3.17", + "time 0.3.20", ] [[package]] name = "tenderdash-proto-compiler" version = "0.1.0" -source = "git+https://github.com/dashpay/rs-tenderdash-abci?branch=master#656e6ba8640e9bb046e4e7f1898f7e4e9a063e33" +source = "git+https://github.com/dashpay/rs-tenderdash-abci?branch=master#b7ca26bfb5c8076ccac9bf90519215a343636075" dependencies = [ "git2", "prost-build", @@ -3457,9 +3485,9 @@ dependencies = [ [[package]] name = "termtree" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95059e91184749cb66be6dc994f67f182b6d897cb3df74a5bf66b5e709295fd8" +checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" [[package]] name = "test-case" @@ -3480,7 +3508,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -3494,22 +3522,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.39" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5ab016db510546d856297882807df8da66a16fb8c4101cb8b30054b0d5b2d9c" +checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.39" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5420d42e90af0c38c3290abcca25b9b3bdf379fc9f55c528f53a269d9c9a267e" +checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.8", ] [[package]] @@ -3535,9 +3563,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.17" +version = "0.3.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a561bf4617eebd33bca6434b988f39ed798e527f51a1e797d0ee4f61c0a38376" +checksum = "cd0cbfecb4d19b5ea75bb31ad904eb5b9fa13f21079c3b92017ebdf4999a5890" dependencies = [ "itoa", "serde", @@ -3553,9 +3581,9 @@ checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd" [[package]] name = "time-macros" -version = "0.2.6" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d967f99f534ca7e495c575c62638eebc2898a8c84c119b89e250477bc4ba16b2" +checksum = "fd80a657e71da814b8e5d60d3374fc6d35045062245d80224748ae522dd76f36" dependencies = [ "time-core", ] @@ -3587,9 +3615,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.25.0" +version = "1.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8e00990ebabbe4c14c08aca901caed183ecd5c09562a12c824bb53d3c3fd3af" +checksum = "03201d01c3c27a29c8a5cee5b55a93ddae1ccf6f08f65365c2c918f8c1b76f64" dependencies = [ "autocfg", "bytes", @@ -3602,7 +3630,7 @@ dependencies = [ "signal-hook-registry", "socket2", "tokio-macros", - "windows-sys 0.42.0", + "windows-sys 0.45.0", ] [[package]] @@ -3613,7 +3641,7 @@ checksum = "d266c00fde287f55d3f1c3e96c500c362a2b8c695076ec180f27918820bc6df8" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -3627,19 +3655,19 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.5.1" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4553f467ac8e3d374bc9a177a26801e5d0f9b211aa1673fb137a403afd1c9cf5" +checksum = "3ab8ed2edee10b50132aed5f331333428b011c99402b5a534154ed15746f9622" [[package]] name = "toml_edit" -version = "0.18.1" +version = "0.19.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56c59d8dd7d0dcbc6428bf7aa2f0e823e26e43b3c9aca15bbc9475d23e5fa12b" +checksum = "239410c8609e8125456927e6707163a3b1fdb40561e4b803bc041f466ccfdc13" dependencies = [ "indexmap", - "nom8", "toml_datetime", + "winnow", ] [[package]] @@ -3710,15 +3738,15 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.10" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54675592c1dbefd78cbd98db9bacd89886e1ca50692a0692baefffdeb92dd58" +checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" [[package]] name = "unicode-ident" -version = "1.0.6" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" +checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" [[package]] name = "unicode-normalization" @@ -3808,12 +3836,11 @@ dependencies = [ [[package]] name = "walkdir" -version = "2.3.2" +version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" +checksum = "36df944cda56c7d8d8b7496af378e6b16de9284591917d307c9b4d313c44e698" dependencies = [ "same-file", - "winapi", "winapi-util", ] @@ -3850,7 +3877,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn", + "syn 1.0.109", "wasm-bindgen-shared", ] @@ -3884,7 +3911,7 @@ checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -3966,6 +3993,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdacb41e6a96a052c6cb63a144f24900236121c6f63f4f8219fef5977ecb0c25" +dependencies = [ + "windows-targets", +] + [[package]] name = "windows-sys" version = "0.42.0" @@ -3992,9 +4028,9 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", @@ -4007,45 +4043,54 @@ dependencies = [ [[package]] name = "windows_aarch64_gnullvm" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" [[package]] name = "windows_aarch64_msvc" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" [[package]] name = "windows_i686_gnu" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" [[package]] name = "windows_i686_msvc" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" [[package]] name = "windows_x86_64_gnu" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" [[package]] name = "windows_x86_64_gnullvm" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" [[package]] name = "windows_x86_64_msvc" -version = "0.42.1" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" + +[[package]] +name = "winnow" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" +checksum = "deac0939bd6e4f24ab5919fbf751c97a8cfc8543bb083a305ed5c0c10bb241d1" +dependencies = [ + "memchr", +] [[package]] name = "withdrawals-contract" diff --git a/packages/rs-drive-abci/Cargo.toml b/packages/rs-drive-abci/Cargo.toml index 9c3cd44e618..d49514ab18a 100644 --- a/packages/rs-drive-abci/Cargo.toml +++ b/packages/rs-drive-abci/Cargo.toml @@ -50,7 +50,6 @@ tracing-subscriber = { version = "0.3.16", default-features = false, features = "env-filter", "ansi", ], optional = true } -semver = { version = "1.0.17", optional = true } atty = { version = "0.2.14", optional = true } tenderdash-abci = { git = "https://github.com/dashpay/rs-tenderdash-abci", branch = "master", optional = true } # tenderdash-abci = { path = "/home/lklimek/git/lklimek/tenderdash-abci-rs/abci", optional = true } @@ -61,14 +60,7 @@ itertools = { version = "0.10.5" } [features] default = ["fixtures-and-mocks", "server"] fixtures-and-mocks = ["mockall"] -server = [ - "tenderdash-abci", - "clap", - "dotenvy", - "tracing-subscriber", - "semver", - "atty", -] +server = ["tenderdash-abci", "clap", "dotenvy", "tracing-subscriber", "atty"] [[bin]] name = "drive-abci" From d678e1957df34f6257e571228297bbc37d2b7ac1 Mon Sep 17 00:00:00 2001 From: Lukasz Klimek <842586+lklimek@users.noreply.github.com> Date: Fri, 24 Mar 2023 13:28:24 +0100 Subject: [PATCH 19/19] build(rs-drive-abci): update cargo.lock --- Cargo.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8af0251ccb0..a592316d770 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3429,7 +3429,7 @@ dependencies = [ [[package]] name = "tenderdash-abci" version = "0.12.0-dev.1" -source = "git+https://github.com/dashpay/rs-tenderdash-abci?branch=master#b7ca26bfb5c8076ccac9bf90519215a343636075" +source = "git+https://github.com/dashpay/rs-tenderdash-abci?branch=master#20ff131666e9cdc080e9ab2c70e1da2e8cef91e1" dependencies = [ "bytes", "prost", @@ -3444,7 +3444,7 @@ dependencies = [ [[package]] name = "tenderdash-proto" version = "0.12.0-dev.1" -source = "git+https://github.com/dashpay/rs-tenderdash-abci?branch=master#b7ca26bfb5c8076ccac9bf90519215a343636075" +source = "git+https://github.com/dashpay/rs-tenderdash-abci?branch=master#20ff131666e9cdc080e9ab2c70e1da2e8cef91e1" dependencies = [ "bytes", "chrono", @@ -3464,7 +3464,7 @@ dependencies = [ [[package]] name = "tenderdash-proto-compiler" version = "0.1.0" -source = "git+https://github.com/dashpay/rs-tenderdash-abci?branch=master#b7ca26bfb5c8076ccac9bf90519215a343636075" +source = "git+https://github.com/dashpay/rs-tenderdash-abci?branch=master#20ff131666e9cdc080e9ab2c70e1da2e8cef91e1" dependencies = [ "git2", "prost-build",