hirosystems / chainhook

Extract transactions from Stacks and Bitcoin and build event driven re-org resistant indexers and databases.
GNU General Public License v3.0
144 stars 57 forks source link

Updating Documentation #248

Closed a-straus closed 1 year ago

a-straus commented 1 year ago

Will be updating this as I go:

  1. chainhook config new --testnet generates the following config for mainnet named Chainhook.toml, not Testnet.toml:
    
    [storage]
    driver = "redis"
    redis_uri = "redis://localhost:6379/"
    cache_path = "cache"

[chainhooks] max_stacks_registrations = 500 max_bitcoin_registrations = 500

[network] mode = "mainnet" bitcoind_rpc_url = "http://localhost:8332" bitcoind_rpc_username = "devnet" bitcoind_rpc_password = "devnet" stacks_node_rpc_url = "http://localhost:20443"

[[event_source]] tsv_file_url = "https://archive.hiro.so/mainnet/stacks-blockchain-api/mainnet-stacks-blockchain-api-latest.gz"


2. If you enter command `chainhook predicates new hello-ordinals.json --bitcoin` if outputs the following predicate:

{ "chain": "bitcoin", "uuid": "3020128f-7fe5-43e8-8160-0722beb143da", "name": "Hello world", "version": 1, "networks": { "mainnet": { "start_block": 0, "end_block": 100, "if_this": { "scope": "ordinals_protocol", "operation": "inscription_feed" }, "then_that": { "file_append": { "path": "ordinals.txt" } } } } }

Which I would argue doesn't really help a user learn anything.  The documentation that follows is generalized predicate documentation that does not reference the `hello-ordinals.json` generated predicate.

My suggestion would be to have two different generated predicates: the first could be for --bitcoin and generate a basic predicate for mainnet that includes something like looking for a specific tx or txs from a specific address.  Then in the testnet section of the documentation have a different `chainhook predicates new hello-ordinals.json --testnet` which would look like this:

{ "chain": "bitcoin", "uuid": "602975ef-b1ed-49c7-8ab8-a0633a57a133", "name": "Hello world", "version": 1, "networks": { "testnet": { "start_block": 2413343, "end_block": 2453343 "if_this": { "scope": "ordinals_protocol", "operation": "inscription_feed" }, "then_that": { "file_append": { "path": "ordinals.txt" } } } } }


This will at least see some ordinal transactions rather than none because it starts at the first ordinal block and continues for 40,000 blocks.  Values can be changed accordingly

3. 
`chainhook predicates scan ./path/to/predicate.json --testnet`
I don't think that it's actually generating the following config:

[storage] driver = "memory"

[chainhooks] max_stacks_registrations = 500 max_bitcoin_registrations = 500

[network] mode = "testnet" bitcoind_rpc_url = "http://0.0.0.0:18332" bitcoind_rpc_username = "testnet" bitcoind_rpc_password = "testnet" stacks_node_rpc_url = "http://0.0.0.0:20443"


Because when I try to connect to the bitcoin rpc node i'm getting an incorrect password error.
Nor does this appear to work with `chainhook service start --testnet`

4. There's no mention of Redis anywhere, even though if you run `chainhook config new --testnet` you'll get a config that includes Redis.
When it comes to running the server I'd suggest adding a note about docker and the following docker command:
`docker run --name chainhook-redis -p 6379:6379 -d redis`
Very easy and sets it up

5.
To get chainhook service to stream blocks from bitcoind from @lgalabru:
You'll need to enable zmq in bitcoind - can be done by adding the line:
`zmqpubhashblock=tcp://0.0.0.0:18543`

to your bitcoind conf file. 
Then you'll also have to add the following line in the [network] node of you Chainhook.toml:
`bitcoind_zmq_url = "tcp://localhost:18543"`
with that, you'll want to start chainhook as a service, with the command:
`$ chainhook service start --start-http-api --config-path=./path/to/config.toml`
or 
`$ chainhook service start --predicate-path=./path/to/predicate-1.json --config-path=./path/to/config.toml`

if you already know that you will be working with a fixed set of predicates
zhangsj commented 1 year ago

what is mean about the event_source? and it is not any port open after start with --start-http-api

lgalabru commented 1 year ago

@LakshmiLavanyaKasturi Were you able to address these feedbacks in the latest version of the documentation?

lgalabru commented 1 year ago

Addressed in the latest version of the documentation!