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

fix: update SignerMessage deserializing #663

Merged
merged 13 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .vscode/chainhook.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
[storage]
working_dir = "cache"

# The HTTP API allows you to register / deregister
# predicates dynamically.
# This is disabled by default.
#
[http_api]
http_port = 20456
database_uri = "redis://localhost:6379/"

[network]
mode = "testnet"
bitcoind_rpc_url = "http://localhost:18443"
bitcoind_rpc_username = "btc"
bitcoind_rpc_password = "btc"

# Chainhook must be able to receive Bitcoin block events.
# These events can originate from either a Stacks node or a Bitcoin node's ZeroMQ interface.

# By default, the service is set to receive Bitcoin block events from the Stacks node:
stacks_node_rpc_url = "http://localhost:20443"
stacks_events_ingestion_port = 20455

# However, events can also be received directly from a Bitcoin node.
# To achieve this, comment out the `stacks_node_rpc_url` line and uncomment the following line:
# bitcoind_zmq_url = "tcp://0.0.0.0:18543"

[limits]
max_number_of_bitcoin_predicates = 100
max_number_of_concurrent_bitcoin_scans = 100
max_number_of_stacks_predicates = 10
max_number_of_concurrent_stacks_scans = 10
max_number_of_processing_threads = 16
max_number_of_networking_threads = 16
max_caching_memory_size_mb = 32000

# The TSV file is required for downloading historical data for your predicates.
# If this is not a requirement, you can comment out the `tsv_file_url` line.
# [[event_source]]
# tsv_file_url = "https://archive.hiro.so/regtest/stacks-blockchain-api/regtest-stacks-blockchain-api-latest"

# Enables a server that provides metrics that can be scraped by Prometheus.
# This is disabled by default.
# [monitoring]
# prometheus_monitoring_port = 20457
24 changes: 24 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,30 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "lldb",
"request": "launch",
"name": "Debug executable 'chainhook'",
"cargo": {
"args": [
"build",
"--bin=chainhook",
"--package=chainhook"
],
"filter": {
"name": "chainhook",
"kind": "bin"
}
},
"args": [
"service",
"start",
"--config-path=${workspaceFolder}/.vscode/chainhook.toml",
],
"cwd": "${workspaceFolder}",
"preLaunchTask": "redis:start",
"postDebugTask": "redis:stop"
},
{
"type": "lldb",
"request": "launch",
Expand Down
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ default-members = ["components/chainhook-cli", "components/chainhook-sdk"]
resolver = "2"

[patch.crates-io]
stacks-codec = { git = "https://github.com/hirosystems/clarinet.git", rev = "b0683675115562d719ed4b5245f620e0990030a0" }
stacks-codec = { git = "https://github.com/hirosystems/clarinet.git", rev = "fcebfb5a986ded32d5a450c34f8e5e5f2da97de4" }
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ pub fn create_stacks_new_block(
tenure_height: Some(1122),
signer_bitvec: Some("000800000001ff".to_owned()),
signer_signature: Some(vec!["1234".to_owned(), "2345".to_owned()]),
signer_signature_hash: None,
cycle_number: Some(1),
reward_set: Some(RewardSet {
pox_ustx_threshold: "50000".to_owned(),
Expand Down
10 changes: 7 additions & 3 deletions components/chainhook-sdk/src/chainhooks/stacks/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,7 @@ pub fn evaluate_stacks_predicate_on_block<'a>(
pub fn evaluate_stacks_predicate_on_non_consensus_events<'a>(
events: &'a Vec<StacksNonConsensusEventData>,
chainhook: &'a StacksChainhookInstance,
_ctx: &Context,
ctx: &Context,
) -> (
Vec<&'a StacksNonConsensusEventData>,
BTreeMap<&'a str, &'a BlockIdentifier>,
Expand All @@ -873,7 +873,11 @@ pub fn evaluate_stacks_predicate_on_non_consensus_events<'a>(
| StacksPredicate::NftEvent(_)
| StacksPredicate::StxEvent(_)
| StacksPredicate::PrintEvent(_)
| StacksPredicate::Txid(_) => unreachable!(),
| StacksPredicate::Txid(_) => {
ctx.try_log(|logger| {
slog::error!(logger, "Invalid predicate for non-consensus events: {:?}", chainhook.predicate)
});
zone117x marked this conversation as resolved.
Show resolved Hide resolved
},
};
}
(occurrences, expired_predicates)
Expand Down Expand Up @@ -1107,7 +1111,7 @@ fn serialize_stacks_non_consensus_event(
};
json!({
"payload": payload,
"received_at": event.received_at_ms,
"received_at_ms": event.received_at_ms,
"received_at_block": event.received_at_block,
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"cycle_number": null,
"reward_set": null,
"signer_bitvec": null,
"signer_signature": null
"signer_signature": null,
"signer_public_keys": null
},
"parent_block_identifier": {
"hash": "0x",
Expand Down Expand Up @@ -108,7 +109,8 @@
"cycle_number": null,
"reward_set": null,
"signer_bitvec": null,
"signer_signature": null
"signer_signature": null,
"signer_public_keys": null
},
"parent_block_identifier": {
"hash": "0x",
Expand Down Expand Up @@ -195,7 +197,8 @@
"cycle_number": null,
"reward_set": null,
"signer_bitvec": null,
"signer_signature": null
"signer_signature": null,
"signer_public_keys": null
},
"parent_block_identifier": {
"hash": "0x",
Expand Down Expand Up @@ -283,7 +286,8 @@
"cycle_number": null,
"reward_set": null,
"signer_bitvec": null,
"signer_signature": null
"signer_signature": null,
"signer_public_keys": null
},
"parent_block_identifier": {
"hash": "0x",
Expand Down Expand Up @@ -370,7 +374,8 @@
"cycle_number": null,
"reward_set": null,
"signer_bitvec": null,
"signer_signature": null
"signer_signature": null,
"signer_public_keys": null
},
"parent_block_identifier": {
"hash": "0x",
Expand Down Expand Up @@ -459,7 +464,8 @@
"cycle_number": null,
"reward_set": null,
"signer_bitvec": null,
"signer_signature": null
"signer_signature": null,
"signer_public_keys": null
},
"parent_block_identifier": {
"hash": "0x",
Expand Down Expand Up @@ -547,7 +553,8 @@
"cycle_number": null,
"reward_set": null,
"signer_bitvec": null,
"signer_signature": null
"signer_signature": null,
"signer_public_keys": null
},
"parent_block_identifier": {
"hash": "0x",
Expand Down Expand Up @@ -635,7 +642,8 @@
"cycle_number": null,
"reward_set": null,
"signer_bitvec": null,
"signer_signature": null
"signer_signature": null,
"signer_public_keys": null
},
"parent_block_identifier": {
"hash": "0x",
Expand Down Expand Up @@ -724,7 +732,8 @@
"cycle_number": null,
"reward_set": null,
"signer_bitvec": null,
"signer_signature": null
"signer_signature": null,
"signer_public_keys": null
},
"parent_block_identifier": {
"hash": "0x",
Expand Down Expand Up @@ -812,7 +821,8 @@
"cycle_number": null,
"reward_set": null,
"signer_bitvec": null,
"signer_signature": null
"signer_signature": null,
"signer_public_keys": null
},
"parent_block_identifier": {
"hash": "0x",
Expand Down Expand Up @@ -900,7 +910,8 @@
"cycle_number": null,
"reward_set": null,
"signer_bitvec": null,
"signer_signature": null
"signer_signature": null,
"signer_public_keys": null
},
"parent_block_identifier": {
"hash": "0x",
Expand Down Expand Up @@ -988,7 +999,8 @@
"cycle_number": null,
"reward_set": null,
"signer_bitvec": null,
"signer_signature": null
"signer_signature": null,
"signer_public_keys": null
},
"parent_block_identifier": {
"hash": "0x",
Expand Down Expand Up @@ -1076,7 +1088,8 @@
"cycle_number": null,
"reward_set": null,
"signer_bitvec": null,
"signer_signature": null
"signer_signature": null,
"signer_public_keys": null
},
"parent_block_identifier": {
"hash": "0x",
Expand Down Expand Up @@ -1174,7 +1187,8 @@
"cycle_number": null,
"reward_set": null,
"signer_bitvec": null,
"signer_signature": null
"signer_signature": null,
"signer_public_keys": null
},
"parent_block_identifier": {
"hash": "0x",
Expand Down
Loading
Loading