diff --git a/Cargo.lock b/Cargo.lock index 13dc7d021..962707632 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -671,7 +671,7 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chainhook-sdk" version = "0.12.5" -source = "git+https://github.com/hirosystems/chainhook.git?branch=chore/update-clarinet-and-clarity#160fd65a66a679efa4cf19cbe33c685eebaa9c2d" +source = "git+https://github.com/hirosystems/chainhook.git#6e3f2a1097b11c14b92beef0faf275aee5814559" dependencies = [ "base58 0.2.0", "base64 0.21.7", @@ -683,7 +683,7 @@ dependencies = [ "futures", "fxhash", "hex 0.4.3", - "hiro-system-kit 0.3.1", + "hiro-system-kit 0.3.4", "hyper 0.14.27", "lazy_static", "miniscript", @@ -697,7 +697,7 @@ dependencies = [ "serde-hex", "serde_derive", "serde_json", - "stacks-rpc-client 2.3.1", + "stacks-codec 2.4.1 (git+https://github.com/hirosystems/clarinet.git?branch=feat/stacks-codec)", "threadpool", "tokio", ] @@ -705,7 +705,7 @@ dependencies = [ [[package]] name = "chainhook-types" version = "1.3.3" -source = "git+https://github.com/hirosystems/chainhook.git?branch=chore/update-clarinet-and-clarity#160fd65a66a679efa4cf19cbe33c685eebaa9c2d" +source = "git+https://github.com/hirosystems/chainhook.git#6e3f2a1097b11c14b92beef0faf275aee5814559" dependencies = [ "hex 0.4.3", "schemars", @@ -819,7 +819,7 @@ dependencies = [ "clarinet-files", "clarinet-utils", "clarity-lsp", - "clarity-repl 2.4.1", + "clarity-repl", "crossbeam-channel", "crossterm", "ctrlc", @@ -874,7 +874,7 @@ dependencies = [ "bitcoincore-rpc-json 0.16.0", "clarinet-files", "clarinet-utils", - "clarity-repl 2.4.1", + "clarity-repl", "colored 2.1.0", "libsecp256k1 0.7.1", "reqwest", @@ -882,7 +882,8 @@ dependencies = [ "serde_derive", "serde_json", "serde_yaml", - "stacks-rpc-client 2.4.1", + "stacks-codec 2.4.1", + "stacks-rpc-client", "tiny-hderive", ] @@ -894,7 +895,7 @@ dependencies = [ "bitcoin 0.29.2", "chainhook-types", "clarinet-utils", - "clarity-repl 2.4.1", + "clarity-repl", "js-sys", "libsecp256k1 0.7.1", "serde", @@ -914,7 +915,7 @@ version = "2.4.1" dependencies = [ "clarinet-deployments", "clarinet-files", - "clarity-repl 2.4.1", + "clarity-repl", "colored 2.1.0", "console_error_panic_hook", "gloo-utils", @@ -966,7 +967,7 @@ version = "1.0.0" dependencies = [ "clap", "clarinet-files", - "clarity-repl 2.4.1", + "clarity-repl", "serde", "serde_derive", "serde_json", @@ -978,7 +979,7 @@ name = "clarity-jupyter-kernel" version = "1.0.0" dependencies = [ "chrono", - "clarity-repl 2.4.1", + "clarity-repl", "colored 1.9.3", "dirs", "failure", @@ -1000,7 +1001,7 @@ version = "1.0.0" dependencies = [ "clarinet-deployments", "clarinet-files", - "clarity-repl 2.4.1", + "clarity-repl", "console_error_panic_hook", "js-sys", "lazy_static", @@ -1014,29 +1015,6 @@ dependencies = [ "web-sys", ] -[[package]] -name = "clarity-repl" -version = "2.3.1" -source = "git+https://github.com/hirosystems/clarinet.git#56acb9e4beebd58e05e7bf04e33499c7faacd11b" -dependencies = [ - "ansi_term", - "atty", - "chrono", - "clarity", - "getrandom 0.2.8", - "hiro-system-kit 0.1.0 (git+https://github.com/hirosystems/clarinet.git)", - "integer-sqrt", - "lazy_static", - "pox-locking", - "regex", - "reqwest", - "serde", - "serde_derive", - "serde_json", - "sha2 0.10.6", - "wsts", -] - [[package]] name = "clarity-repl" version = "2.4.1" @@ -1070,7 +1048,6 @@ dependencies = [ "tokio-util", "wasm-bindgen", "wasm-bindgen-futures", - "wsts", ] [[package]] @@ -2279,20 +2256,9 @@ dependencies = [ [[package]] name = "hiro-system-kit" -version = "0.1.0" -source = "git+https://github.com/hirosystems/clarinet.git#56acb9e4beebd58e05e7bf04e33499c7faacd11b" -dependencies = [ - "ansi_term", - "atty", - "lazy_static", - "tokio", -] - -[[package]] -name = "hiro-system-kit" -version = "0.3.1" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94a96596d2b33489f33f79b2df6f340dbbd2baba05a251715bb84661d33bf1c9" +checksum = "4d3bf5cf007a9973ef9b7dffe8d63fa5228e9bb1aa012e89da2b9f1e7119ce6e" dependencies = [ "ansi_term", "atty", @@ -2303,6 +2269,7 @@ dependencies = [ "slog-json", "slog-scope", "slog-term", + "time", "tokio", ] @@ -4968,6 +4935,25 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "stacks-codec" +version = "2.4.1" +dependencies = [ + "clarity", + "serde", + "wsts", +] + +[[package]] +name = "stacks-codec" +version = "2.4.1" +source = "git+https://github.com/hirosystems/clarinet.git?branch=feat/stacks-codec#f8bd0af8e387c3c5169a261f3257380397a8c0fb" +dependencies = [ + "clarity", + "serde", + "wsts", +] + [[package]] name = "stacks-common" version = "0.0.2" @@ -5033,7 +5019,7 @@ dependencies = [ "clarinet-deployments", "clarinet-files", "clarinet-utils", - "clarity-repl 2.4.1", + "clarity-repl", "crossbeam-channel", "crossterm", "ctrlc", @@ -5046,7 +5032,8 @@ dependencies = [ "serde_derive", "serde_json", "serde_yaml", - "stacks-rpc-client 2.4.1", + "stacks-codec 2.4.1", + "stacks-rpc-client", "stackslib", "tokio", "tracing", @@ -5054,28 +5041,10 @@ dependencies = [ "tracing-subscriber", ] -[[package]] -name = "stacks-rpc-client" -version = "2.3.1" -source = "git+https://github.com/hirosystems/clarinet.git#56acb9e4beebd58e05e7bf04e33499c7faacd11b" -dependencies = [ - "clarity-repl 2.3.1", - "hmac 0.12.1", - "libsecp256k1 0.7.1", - "pbkdf2", - "reqwest", - "serde", - "serde_derive", - "serde_json", - "sha2 0.10.6", - "tiny-hderive", -] - [[package]] name = "stacks-rpc-client" version = "2.4.1" dependencies = [ - "clarity-repl 2.4.1", "hmac 0.12.1", "libsecp256k1 0.7.1", "pbkdf2", @@ -5084,6 +5053,7 @@ dependencies = [ "serde_derive", "serde_json", "sha2 0.10.6", + "stacks-codec 2.4.1", "tiny-hderive", ] diff --git a/Cargo.toml b/Cargo.toml index 098185b39..49f4994b4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,6 +11,7 @@ members = [ "components/clarity-repl", "components/clarity-events", "components/hiro-system-kit", + "components/stacks-codec", "components/stacks-devnet-js", "components/stacks-network", "components/stacks-rpc-client", @@ -19,3 +20,7 @@ default-members = ["components/clarinet-cli"] # [patch.crates-io] # "clarity-vm" = { path = "../stacks-blockchain/clarity" } + +# [patch.'https://github.com/hirosystems/chainhook.git'] +# chainhook-sdk = {path = "../chainhook/components/chainhook-sdk" } +# chainhook-types = {path = "../chainhook/components/chainhook-types-rs" } diff --git a/components/clarinet-deployments/Cargo.toml b/components/clarinet-deployments/Cargo.toml index 83251a48c..0c88bd1c9 100644 --- a/components/clarinet-deployments/Cargo.toml +++ b/components/clarinet-deployments/Cargo.toml @@ -27,10 +27,11 @@ base64 = "0.21.3" tiny-hderive = { version = "0.3.0", optional = true } libsecp256k1 = { version = "0.7.0", optional = true } clarinet_utils = { package = "clarinet-utils", path = "../clarinet-utils", optional = true } +stacks-codec = { path = "../stacks-codec", optional = true } [features] default = ["cli"] -cli = ["clarity-repl/cli", "clarinet-files/cli", "onchain"] +cli = ["clarity-repl/cli", "clarinet-files/cli", "stacks-codec", "onchain"] wasm = ["clarity-repl/wasm", "clarinet-files/wasm"] onchain = [ "stacks-rpc-client", diff --git a/components/clarinet-deployments/src/onchain/mod.rs b/components/clarinet-deployments/src/onchain/mod.rs index a4f89b5e7..9cb9615e1 100644 --- a/components/clarinet-deployments/src/onchain/mod.rs +++ b/components/clarinet-deployments/src/onchain/mod.rs @@ -12,19 +12,19 @@ use clarity_repl::clarity::vm::types::{ }; use clarity_repl::clarity::vm::{ClarityName, Value}; use clarity_repl::clarity::{ClarityVersion, ContractName, EvaluationResult}; -use clarity_repl::codec::{ - SinglesigHashMode, SinglesigSpendingCondition, StacksString, StacksTransactionSigner, - TokenTransferMemo, TransactionAuth, TransactionContractCall, TransactionPayload, - TransactionPostConditionMode, TransactionPublicKeyEncoding, TransactionSmartContract, - TransactionSpendingCondition, TransactionVersion, -}; -use clarity_repl::codec::{StacksTransaction, TransactionAnchorMode}; use clarity_repl::repl::session::{ BOOT_MAINNET_ADDRESS, BOOT_TESTNET_ADDRESS, V1_BOOT_CONTRACTS, V2_BOOT_CONTRACTS, V3_BOOT_CONTRACTS, }; use clarity_repl::repl::{Session, SessionSettings}; use reqwest::Url; +use stacks_codec::codec::{ + SinglesigHashMode, SinglesigSpendingCondition, StacksString, StacksTransactionSigner, + TokenTransferMemo, TransactionAuth, TransactionContractCall, TransactionPayload, + TransactionPostConditionMode, TransactionPublicKeyEncoding, TransactionSmartContract, + TransactionSpendingCondition, TransactionVersion, +}; +use stacks_codec::codec::{StacksTransaction, TransactionAnchorMode}; use stacks_rpc_client::StacksRpc; use std::collections::{BTreeMap, HashSet, VecDeque}; use std::str::FromStr; diff --git a/components/clarinet-files/Cargo.toml b/components/clarinet-files/Cargo.toml index 57d9ab9d4..3bb115f6e 100644 --- a/components/clarinet-files/Cargo.toml +++ b/components/clarinet-files/Cargo.toml @@ -9,7 +9,7 @@ edition = "2021" serde = "1" serde_derive = "1" # chainhook-types = "1.2" -chainhook-types = { version = "1.2", git = "https://github.com/hirosystems/chainhook.git", branch="chore/update-clarinet-and-clarity" } +chainhook-types = { version = "1.2", git = "https://github.com/hirosystems/chainhook.git" } bip39 = { version = "1.0.1", default-features = false } libsecp256k1 = "0.7.0" toml = { version = "0.5.6", features = ["preserve_order"] } diff --git a/components/clarity-repl/Cargo.toml b/components/clarity-repl/Cargo.toml index a75cc9637..0c8d258b3 100644 --- a/components/clarity-repl/Cargo.toml +++ b/components/clarity-repl/Cargo.toml @@ -58,7 +58,6 @@ reqwest = { version = "0.11", default-features = false, features = [ "json", "rustls-tls", ] } -wsts = { version = "8.1.0", default-features = false, optional = true } # WASM wasm-bindgen = { version = "0.2.91", optional = true } @@ -87,16 +86,14 @@ cli = [ "clarity/log", "hiro_system_kit/tokio_helpers", "clar2wasm", - "pox-locking/default", - "wsts" + "pox-locking/default" ] sdk = [ "clarity/canonical", "clarity/developer-mode", "clarity/log", "hiro_system_kit/tokio_helpers", - "pox-locking/default", - "wsts" + "pox-locking/default" ] dap = [ "tokio", diff --git a/components/clarity-repl/src/bin.rs b/components/clarity-repl/src/bin.rs index f41826d00..7266a3047 100644 --- a/components/clarity-repl/src/bin.rs +++ b/components/clarity-repl/src/bin.rs @@ -20,9 +20,6 @@ extern crate prettytable; #[macro_use] extern crate hiro_system_kit; -#[macro_use] -mod macros; - pub mod analysis; pub mod frontend; pub mod repl; diff --git a/components/clarity-repl/src/lib.rs b/components/clarity-repl/src/lib.rs index f930a0a8d..ce7646a46 100644 --- a/components/clarity-repl/src/lib.rs +++ b/components/clarity-repl/src/lib.rs @@ -11,17 +11,7 @@ extern crate serde_derive; #[macro_use] extern crate hiro_system_kit; -#[macro_use] -mod macros; - pub mod analysis; -#[cfg(not(feature = "wasm"))] -pub mod codec; -pub mod repl; -pub mod utils; - -#[cfg(test)] -pub mod test_fixtures; pub mod clarity { #![allow(ambiguous_glob_reexports)] @@ -29,6 +19,11 @@ pub mod clarity { pub use ::clarity::vm::*; pub use ::clarity::*; } +pub mod repl; +pub mod utils; + +#[cfg(test)] +pub mod test_fixtures; #[cfg(feature = "cli")] pub mod frontend; diff --git a/components/stacks-codec/Cargo.toml b/components/stacks-codec/Cargo.toml new file mode 100644 index 000000000..a7711ccd6 --- /dev/null +++ b/components/stacks-codec/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "stacks-codec" +version = "2.4.1" +license = "GPL-3.0" +edition = "2021" + +[dependencies] +# clarity-vm = "2" +clarity = { git = "https://github.com/stacks-network/stacks-core.git", branch="feat/clarity-wasm-next", package = "clarity", default-features = false, features = ["canonical", "developer-mode", "log"] } +serde = { version = "1", features = ["derive"] } +wsts = { version = "8.1.0", default-features = false } diff --git a/components/clarity-repl/src/codec/mod.rs b/components/stacks-codec/src/codec.rs similarity index 100% rename from components/clarity-repl/src/codec/mod.rs rename to components/stacks-codec/src/codec.rs diff --git a/components/stacks-codec/src/lib.rs b/components/stacks-codec/src/lib.rs new file mode 100644 index 000000000..378114164 --- /dev/null +++ b/components/stacks-codec/src/lib.rs @@ -0,0 +1,11 @@ +pub mod codec; + +#[macro_use] +mod macros; + +pub mod clarity { + #![allow(ambiguous_glob_reexports)] + pub use ::clarity::types::*; + pub use ::clarity::vm::*; + pub use ::clarity::*; +} diff --git a/components/clarity-repl/src/macros.rs b/components/stacks-codec/src/macros.rs similarity index 100% rename from components/clarity-repl/src/macros.rs rename to components/stacks-codec/src/macros.rs diff --git a/components/stacks-network/Cargo.toml b/components/stacks-network/Cargo.toml index e487d9185..2049ae447 100644 --- a/components/stacks-network/Cargo.toml +++ b/components/stacks-network/Cargo.toml @@ -36,7 +36,7 @@ clap = { version = "4.4.8", features = ["derive"] } serde_yaml = "0.8.23" stackslib = { git = "https://github.com/stacks-network/stacks-core.git", branch="feat/clarity-wasm-next", package = "stackslib" } -chainhook-sdk = { default-features = true, git = "https://github.com/hirosystems/chainhook.git", branch="chore/update-clarinet-and-clarity" } +chainhook-sdk = { default-features = true, git = "https://github.com/hirosystems/chainhook.git" } # chainhook-sdk = { version = "=0.11", default-features = true } stacks-rpc-client = { path = "../stacks-rpc-client" } @@ -45,6 +45,7 @@ clarinet-deployments = { path = "../clarinet-deployments", features = ["cli"] } clarinet-utils = { path = "../clarinet-utils" } hiro-system-kit = { path = "../hiro-system-kit", features = ["log"] } clarity-repl = { path = "../clarity-repl", features = ["cli"] } +stacks-codec = { path = "../stacks-codec" } [lib] name = "stacks_network" diff --git a/components/stacks-network/src/chains_coordinator.rs b/components/stacks-network/src/chains_coordinator.rs index f6bf0f175..e4ea8a2f2 100644 --- a/components/stacks-network/src/chains_coordinator.rs +++ b/components/stacks-network/src/chains_coordinator.rs @@ -32,11 +32,11 @@ use clarity_repl::clarity::vm::types::{BuffData, SequenceData, TupleData}; use clarity_repl::clarity::vm::ClarityName; use clarity_repl::clarity::vm::Value as ClarityValue; use clarity_repl::clarity::PublicKey; -use clarity_repl::codec; use hiro_system_kit; use hiro_system_kit::slog; use hiro_system_kit::yellow; -use stacks_rpc_client::PoxInfo; +use stacks_codec::codec; +use stacks_rpc_client::rpc_client::PoxInfo; use stacks_rpc_client::StacksRpc; use stackslib::chainstate::stacks::address::PoxAddress; use stackslib::core::CHAIN_ID_TESTNET; @@ -227,6 +227,7 @@ pub async fn start_chains_coordinator( observer_command_rx, Some(observer_event_tx_moved), None, + None, ctx_moved, ); }); diff --git a/components/stacks-rpc-client/Cargo.toml b/components/stacks-rpc-client/Cargo.toml index faf56c39b..d430331ba 100644 --- a/components/stacks-rpc-client/Cargo.toml +++ b/components/stacks-rpc-client/Cargo.toml @@ -20,6 +20,4 @@ sha2 = "0.10.0" tiny-hderive = { version = "0.3.0" } libsecp256k1 = { version = "0.7.0" } -clarity_repl = { version = "2", package = "clarity-repl", path = "../clarity-repl", default-features = false, features = [ - "sdk", -] } +stacks-codec = { version = "2", package = "stacks-codec", path = "../stacks-codec" } diff --git a/components/stacks-rpc-client/src/crypto.rs b/components/stacks-rpc-client/src/crypto.rs index 48e9498d3..a8bac2068 100644 --- a/components/stacks-rpc-client/src/crypto.rs +++ b/components/stacks-rpc-client/src/crypto.rs @@ -4,18 +4,18 @@ use crate::clarity::codec::*; use crate::clarity::vm::types::{PrincipalData, QualifiedContractIdentifier, Value}; use crate::clarity::vm::{ClarityName, ClarityVersion, ContractName}; -use clarity_repl::clarity::address::{ - AddressHashMode, C32_ADDRESS_VERSION_MAINNET_SINGLESIG, C32_ADDRESS_VERSION_TESTNET_SINGLESIG, -}; -use clarity_repl::clarity::chainstate::StacksAddress; -use clarity_repl::clarity::codec::StacksMessageCodec; -use clarity_repl::clarity::util::secp256k1::{ - MessageSignature, Secp256k1PrivateKey, Secp256k1PublicKey, -}; use hmac::Hmac; use libsecp256k1::{PublicKey, SecretKey}; use pbkdf2::pbkdf2; use sha2::Sha512; +use stacks_codec::clarity::address::{ + AddressHashMode, C32_ADDRESS_VERSION_MAINNET_SINGLESIG, C32_ADDRESS_VERSION_TESTNET_SINGLESIG, +}; +use stacks_codec::clarity::chainstate::StacksAddress; +use stacks_codec::clarity::codec::StacksMessageCodec; +use stacks_codec::clarity::util::secp256k1::{ + MessageSignature, Secp256k1PrivateKey, Secp256k1PublicKey, +}; use tiny_hderive::bip32::ExtendedPrivKey; #[derive(Clone, Debug)] diff --git a/components/stacks-rpc-client/src/lib.rs b/components/stacks-rpc-client/src/lib.rs index d12eab4b4..fb4efe473 100644 --- a/components/stacks-rpc-client/src/lib.rs +++ b/components/stacks-rpc-client/src/lib.rs @@ -9,12 +9,12 @@ extern crate serde_derive; extern crate serde_json; pub mod clarity { - pub use clarity_repl::clarity::vm; - pub use clarity_repl::codec; + pub use stacks_codec::clarity::vm; + pub use stacks_codec::codec; } pub mod rpc_client; pub mod crypto; -pub use rpc_client::{PoxInfo, StacksRpc}; +pub use rpc_client::StacksRpc; diff --git a/components/stacks-rpc-client/src/rpc_client.rs b/components/stacks-rpc-client/src/rpc_client.rs index 1dd081d37..7ee0bba94 100644 --- a/components/stacks-rpc-client/src/rpc_client.rs +++ b/components/stacks-rpc-client/src/rpc_client.rs @@ -1,14 +1,13 @@ -use clarity_repl::clarity::codec::StacksMessageCodec; -use clarity_repl::clarity::util::hash::{bytes_to_hex, hex_bytes, to_hex}; -use clarity_repl::clarity::vm::types::Value; - -use reqwest::blocking::Client; +use std::fs::File; +use std::io::prelude::*; use std::io::Cursor; -use clarity_repl::codec::{StacksTransaction, TransactionPayload}; +use stacks_codec::clarity::codec::StacksMessageCodec; +use stacks_codec::clarity::util::hash::{bytes_to_hex, hex_bytes, to_hex}; +use stacks_codec::clarity::vm::types::Value; +use stacks_codec::codec::{StacksTransaction, TransactionPayload}; -use std::fs::File; -use std::io::prelude::*; +use reqwest::blocking::Client; #[derive(Debug)] pub enum RpcError { @@ -72,58 +71,6 @@ pub struct PoxInfo { pub next_cycle: NextPoxCycle, } -impl PoxInfo { - pub fn mainnet_default() -> PoxInfo { - PoxInfo { - contract_id: "SP000000000000000000002Q6VF78.pox-3".into(), - pox_activation_threshold_ustx: 0, - first_burnchain_block_height: 666050, - prepare_phase_block_length: 100, - reward_phase_block_length: 2000, - reward_slots: 4000, - total_liquid_supply_ustx: 1368787887756275, - ..Default::default() - } - } - - pub fn testnet_default() -> PoxInfo { - PoxInfo { - contract_id: "ST000000000000000000002AMW42H.pox-3".into(), - pox_activation_threshold_ustx: 0, - current_burnchain_block_height: 2000000, - first_burnchain_block_height: 2000000, - prepare_phase_block_length: 50, - reward_phase_block_length: 1000, - reward_slots: 2000, - total_liquid_supply_ustx: 41412139686144074, - ..Default::default() - } - } - - pub fn devnet_default() -> PoxInfo { - Self::default() - } -} - -impl Default for PoxInfo { - fn default() -> PoxInfo { - PoxInfo { - contract_id: "ST000000000000000000002AMW42H.pox".into(), - pox_activation_threshold_ustx: 0, - current_burnchain_block_height: 100, - first_burnchain_block_height: 100, - prepare_phase_block_length: 4, - reward_phase_block_length: 6, - reward_cycle_length: 10, - reward_slots: 10, - total_liquid_supply_ustx: 1000000000000000, - reward_cycle_id: 0, - current_cycle: CurrentPoxCycle::default(), - next_cycle: NextPoxCycle::default(), - } - } -} - #[derive(Deserialize, Debug, Clone, Default)] pub struct CurrentPoxCycle { pub id: u64,