hirosystems / ordinals-api

Bitcoin Ordinals API
Apache License 2.0
201 stars 61 forks source link

Attempt to run a testnet endpoint with fully synced `bitcoind` and `ordhook` #291

Closed chunteng-web3 closed 9 months ago

chunteng-web3 commented 10 months ago

Hi there! I have been working on setting up a complete ordinals-api endpoint with a fully synced bitcoind and ordhook on testnet. Here are my configurations:

bitcoin.conf

# Bitcoin Core Configuration

server=1
rpcport=8332
rpcallowip=127.0.0.1
rest=1
txindex=1
listen=1
discover=0
# dns=0
# dnsseed=0
listenonion=0
rpcserialversion=1
disablewallet=0
fallbackfee=0.00001
rpcthreads=8
blocksonly=1
dbcache=4096
testnet=1

[test]
rpcuser=testnet
rpcpassword=testnet
rpcport=8332
rpcallowip=127.0.0.1
rpcbind=0.0.0.0

# Start zeromq
zmqpubhashblock=tcp://0.0.0.0:18543

Ordhook.toml

[storage]
working_dir = "ordhook"

# The Http Api allows you to register / deregister
# dynamically predicates.
# Disable by default.
#
[http_api]
http_port = 20456
database_uri = "redis://localhost:6379/"

[network]
mode = "testnet"
bitcoind_rpc_url = "http://127.0.0.1:8332"
bitcoind_rpc_username = "testnet"
bitcoind_rpc_password = "testnet"
# Bitcoin block events can be received by Chainhook
# either through a Bitcoin node's ZeroMQ interface,
# or through the Stacks node. Zmq is being
# used by default:
bitcoind_zmq_url = "tcp://127.0.0.1:18543"
# but stacks can also be used:
# stacks_node_rpc_url = "http://0.0.0.0:20443"

[limits]
max_number_of_bitcoin_predicates = 100
max_number_of_concurrent_bitcoin_scans = 100
max_number_of_processing_threads = 16
bitcoin_concurrent_http_requests_max = 16
max_caching_memory_size_mb = 32000

# Disable the following section if the state
# must be built locally
#[bootstrap]
#download_url = "https://archive.hiro.so/mainnet/ordhook/mainnet-ordhook-sqlite-latest"

[logs]
ordinals_internals = true
chainhook_internals = true

and .env forordinals-api

# See src/env.ts for environment variable documentation.
PGUSER=postgres
PGPASSWORD=PASSWORD-HIDDEN
PGDATABASE=testnet
PGHOST=localhost
CHAINHOOK_NODE_AUTH_TOKEN=
CHAINHOOK_AUTO_PREDICATE_REGISTRATION=false

At the moment, I've met two issues:

  1. Although I can properly scan inscriptions by either transaction ID or blocks, but the inscription number is very different from what https://testnet.unisat.io/ has provided. For example, with ordhook scan inscription b25dfaeea88930616332bc97b9bde3bbfcfbe62e35e763a07cc4706a2be1ed17i0 --testnet, it shows
    Inscription b25dfaeea88930616332bc97b9bde3bbfcfbe62e35e763a07cc4706a2be1ed17i0 revealed at block #2572012 (inscription_number 839153, ordinal_number 1510383666160705)`

while on https://testnet.unisat.io/inscription/b25dfaeea88930616332bc97b9bde3bbfcfbe62e35e763a07cc4706a2be1ed17i0 the inscription number is #736652. I don't know if this is concerning but it should be fine if we use Hiro's ordinals-api exclusively.

  1. Running npm start in the ordinals-api (and .env mentioned above) returns the following after I tried curl http://localhost:3000/ordinals/v1/inscriptions:
    
    > @hirosystems/ordinals-api@1.0.0 start
    > node dist/src/index.js

{"level":"info","time":"2024-01-10T14:31:25.987Z","pid":2406848,"hostname":"IP-HIDDEN","name":"api","msg":"Initializing in default run mode..."} {"level":"info","time":"2024-01-10T14:31:26.042Z","pid":2406848,"hostname":"IP-HIDDEN","name":"api","msg":"Initializing background services..."} {"level":"info","time":"2024-01-10T14:31:26.506Z","pid":2406848,"hostname":"IP-HIDDEN","name":"chainhook-client","msg":"ChainhookEventObserver does not have predicates to register"} {"level":"info","time":"2024-01-10T14:31:26.509Z","pid":2406848,"hostname":"IP-HIDDEN","name":"chainhook-client","msg":"Server listening at http://0.0.0.0:3099"} {"level":"info","time":"2024-01-10T14:31:26.529Z","pid":2406848,"hostname":"IP-HIDDEN","name":"api","msg":"Server listening at http://0.0.0.0:3001"} {"level":"info","time":"2024-01-10T14:31:26.757Z","pid":2406848,"hostname":"IP-HIDDEN","name":"api","msg":"Server listening at http://0.0.0.0:3000"} {"level":"info","time":"2024-01-10T14:31:26.760Z","pid":2406848,"hostname":"IP-HIDDEN","name":"api","msg":"Server listening at http://0.0.0.0:9153"} {"level":"info","time":"2024-01-10T14:31:26.529Z","pid":2406848,"hostname":"IP-HIDDEN","name":"api","msg":"Initializing API service..."} {"level":"info","time":"2024-01-10T14:31:26.760Z","pid":2406848,"hostname":"IP-HIDDEN","name":"api","msg":"App initialized"} {"level":"info","time":"2024-01-10T14:32:01.567Z","pid":2406848,"hostname":"IP-HIDDEN","name":"api","reqId":"req-1","req":{"method":"GET","url":"/ordinals/v1/inscriptions","hostname":"localhost:3000","remoteAddress":"127.0.0.1","remotePort":32858},"msg":"incoming request"} {"level":"info","time":"2024-01-10T14:32:01.599Z","pid":2406848,"hostname":"IP-HIDDEN","name":"api","reqId":"req-1","res":{"statusCode":200},"responseTime":29.878253996372223,"msg":"request completed"}


However, the return results are:

{"limit":20,"offset":0,"total":0,"results":[]}



As you can see, the request was processed but the data was not retrieved properly though `ordhook scan` can return data as expected (though with a questionable inscription number).

Any ideas on how I can eventually obtain the results for inscription on testnet? Thank you!
rafaelcr commented 9 months ago

Hi @chunteng-web3 with regards to the API, can you set CHAINHOOK_AUTO_PREDICATE_REGISTRATION to true so it registers the predicate into Ordhook? Otherwise the API will not receive inscriptions from it and won't be able to display them on endpoint responses. Make sure to configure all your node info correctly in the API's .env, too, so they can communicate with each other.

smcclellan commented 9 months ago

Closing for now -- please reopen if the issue persists after trying the above.

endangurura commented 7 months ago

I have the same issue -- running on mainnet and CHAINHOOK_AUTO_PREDICATE_REGISTRATION=true / ORDHOOK_AUTO_PREDICATE_REGISTRATION=true (v3.1.0-beta.1)