Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update clarinet and clarity-vm #475

Merged
merged 11 commits into from
Mar 27, 2024
Merged
1,574 changes: 1,263 additions & 311 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions components/chainhook-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ rand = "0.8.5"
chainhook-sdk = { version = "0.12.1", default-features = false, features = [
"zeromq",
], path = "../chainhook-sdk" }
hiro-system-kit = "0.3.2"
# clarinet-files = { path = "../../../clarinet/components/clarinet-files" }
hiro-system-kit = "0.3.1"
# hiro-system-kit = { path = "../../../clarinet/components/hiro-system-kit" }
clap = { version = "3.2.23", features = ["derive"], optional = true }
clap_generate = { version = "3.0.3", optional = true }
Expand Down Expand Up @@ -52,7 +51,6 @@ features = ["lz4", "snappy"]
[dev-dependencies]
criterion = "0.3"
redis = "0.21.5"
clarity-vm = "=2.1.1"
hex = "0.4.3"
test-case = "3.1.0"
serial_test = "2.0.0"
Expand Down
6 changes: 3 additions & 3 deletions components/chainhook-sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ serde = { version = "1", features = ["rc"] }
serde_json = { version = "1", features = ["arbitrary_precision"] }
serde-hex = "0.1.0"
serde_derive = "1"
stacks-rpc-client = "2"
hiro-system-kit = { version = "0.3.2", optional = true }
stacks-rpc-client = { version = "2", git = "https://github.com/hirosystems/clarinet.git" }
hiro-system-kit = { version = "0.3.1", optional = true }
# stacks-rpc-client = { version = "1", path = "../../../clarinet/components/stacks-rpc-client" }
# hiro-system-kit = { version = "0.1.0", path = "../../../clarinet/components/hiro-system-kit" }
chainhook-types = { version = "1.3.3", path = "../chainhook-types-rs" }
Expand Down Expand Up @@ -50,4 +50,4 @@ test-case = "3.1.0"
default = ["hiro-system-kit/log"]
zeromq = ["zmq"]
debug = ["hiro-system-kit/debug"]
release = ["hiro-system-kit/release_debug", "hiro-system-kit/full_log_level_prefix"]
release = ["hiro-system-kit/release"]
2 changes: 1 addition & 1 deletion components/chainhook-sdk/src/chainhooks/stacks/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use hiro_system_kit::slog;
use regex::Regex;
use reqwest::{Client, Method};
use serde_json::Value as JsonValue;
use stacks_rpc_client::clarity::stacks_common::codec::StacksMessageCodec;
use stacks_rpc_client::clarity::codec::StacksMessageCodec;
use stacks_rpc_client::clarity::vm::types::{CharType, SequenceData, Value as ClarityValue};
use std::collections::{BTreeMap, HashMap};
use std::io::Cursor;
Expand Down
14 changes: 10 additions & 4 deletions components/chainhook-sdk/src/indexer/stacks/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ use chainhook_types::*;
use hiro_system_kit::slog;
use rocket::serde::json::Value as JsonValue;
use rocket::serde::Deserialize;
use stacks_rpc_client::clarity::codec::StacksMessageCodec;
use stacks_rpc_client::clarity::codec::{StacksTransaction, TransactionAuth, TransactionPayload};
use stacks_rpc_client::clarity::stacks_common::codec::StacksMessageCodec;
use stacks_rpc_client::clarity::vm::types::{SequenceData, Value as ClarityValue};
use std::collections::{BTreeMap, HashMap, HashSet};
use std::convert::TryInto;
Expand Down Expand Up @@ -332,7 +332,7 @@ pub fn standardize_stacks_block(
.into();
let current_len = u64::saturating_sub(
block.burn_block_height,
1 + chain_ctx.pox_info.first_burnchain_block_height,
1 + (chain_ctx.pox_info.first_burnchain_block_height as u64),
);
let pox_cycle_id: u32 = (current_len / pox_cycle_length).try_into().unwrap_or(0);
let mut events: HashMap<&String, Vec<&NewEvent>> = HashMap::new();
Expand Down Expand Up @@ -818,10 +818,16 @@ pub fn get_tx_description(
StacksTransactionKind::ContractDeployment(data),
)
}
TransactionPayload::Coinbase(_, _) => {
TransactionPayload::Coinbase(_, _, _) => {
(format!("coinbase"), StacksTransactionKind::Coinbase)
}
_ => (format!("other"), StacksTransactionKind::Unsupported),
TransactionPayload::TenureChange(_) => (
format!("tenure change"),
StacksTransactionKind::TenureChange,
),
TransactionPayload::PoisonMicroblock(_, _) => {
unimplemented!()
}
};
Ok((description, tx_type, fee, nonce, sender, sponsor))
}
Expand Down
2 changes: 1 addition & 1 deletion components/chainhook-sdk/src/observer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ pub async fn start_stacks_event_observer(

let ingestion_config = Config {
port: ingestion_port,
workers: 3,
workers: 1,
address: IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)),
keep_alive: 5,
temp_dir: std::env::temp_dir().into(),
Expand Down
18 changes: 9 additions & 9 deletions components/chainhook-types-js/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ export interface StacksTransactionMetadata {
* @memberof StacksTransactionMetadata
*/
position: AnchorBlockPosition | MicroBlockPosition;
/**
/**
* @type {string}
* @memberof StacksTransactionMetadata
*/
Expand All @@ -335,18 +335,18 @@ export interface StacksTransactionMetadata {
* @export
* @interface MicroBlockPosition
*/
export interface MicroBlockPosition {
micro_block_identifier: BlockIdentifier,
index: number
export interface MicroBlockPosition {
micro_block_identifier: BlockIdentifier;
index: number;
}

/**
* AnchorBlockPosition
* @export
* @interface AnchorBlockPosition
*/
export interface AnchorBlockPosition {
index: number
export interface AnchorBlockPosition {
index: number;
}

export interface StacksTransactionReceipt {
Expand Down Expand Up @@ -428,11 +428,13 @@ export interface StacksTransactionExecutionCost {
runtime: number;
}

// todo: tenure change
export enum StacksTransactionKind {
ContractCall = "ContractCall",
ContractDeployment = "ContractDeployment",
NativeTokenTransfer = "NativeTokenTransfer",
Coinbase = "Coinbase",
TenureChange = "TenureChange",
Other = "Other",
}

Expand Down Expand Up @@ -1061,9 +1063,7 @@ export function checkBitcoinProof(
blockHash: string,
merkleProof: string[],
index: number
): boolean {

}
): boolean {}

// I'll add some documentation, but this is a "standard" bitcoin proof, so it goes as follow:
// So for instance, you'll receive something like this:
Expand Down
1 change: 1 addition & 0 deletions components/chainhook-types-rs/src/rosetta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ pub enum StacksTransactionKind {
ContractDeployment(StacksContractDeploymentData),
NativeTokenTransfer,
Coinbase,
TenureChange,
BitcoinOp(BitcoinOpData),
Unsupported,
}
Expand Down
6 changes: 6 additions & 0 deletions components/client/typescript/src/schemas/stacks/tx_kind.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ export const StacksTransactionCoinbaseKindSchema = Type.Object({
});
export type StacksTransactionCoinbaseKind = Static<typeof StacksTransactionCoinbaseKindSchema>;

export const StacksTransactionTenureChangeKindSchema = Type.Object({
type: Type.Literal('TenureChange'),
});
export type StacksTransactionTenureChangeKind = Static<typeof StacksTransactionTenureChangeKindSchema>;

export const StacksTransactionNativeTokenTransferKindSchema = Type.Object({
type: Type.Literal('NativeTokenTransfer'),
});
Expand Down Expand Up @@ -70,6 +75,7 @@ export type StacksTransactionUnsupportedKind = Static<

export const StacksTransactionKindSchema = Type.Union([
StacksTransactionCoinbaseKindSchema,
StacksTransactionTenureChangeKindSchema,
StacksTransactionContractCallKindSchema,
StacksTransactionContractDeploymentKindSchema,
StacksTransactionNativeTokenTransferKindSchema,
Expand Down
4 changes: 2 additions & 2 deletions dockerfiles/components/chainhook-node.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ WORKDIR /src

RUN apt update && apt install -y ca-certificates pkg-config libssl-dev libclang-11-dev

RUN rustup update 1.70.0 && rustup default 1.70.0
RUN rustup update 1.73.0 && rustup default 1.73.0

COPY ./Cargo.* /src/

Expand All @@ -30,4 +30,4 @@ COPY --from=build /out/ /bin/

WORKDIR /workspace

ENTRYPOINT ["chainhook"]
ENTRYPOINT ["chainhook"]
Loading