Skip to content

Commit 4afb201

Browse files
authored
refactor!: store inscription data in postgres instead of sqlite (#375)
* chore: new pg lib * chore: migrations and connection code * brc20 migrations * connection opts * fixed columns * vscode configs * transaction utils * chain tip integration * more progress * progress * models * brc20 progress * progress * more * utils * models and isnerts * some more inserts * ordering support * remove extra code * organize * deadpool * chain tip * counts * optimize transfers table * optimize reinscriptions * transfers in same block * drop blocks structure * brc20 counts * token minted supplies * brc20 insert chunks * brc20 tweaks * tweaks * rollback progress * restore tests * fix brc20 tests * cache tests * brc20 db tests * pg docker compose * fix: pg path * fix: dockerfile * test: inscr write * test: rollbacks * fix: token minted supply rollback * fix: ordinals rollback * chore: upgrade rust * fix: share rocksdb conn across threads * chore: search path support * chore: logs cleanup * chore: re-enable seq cursor tests * fix: wire up rollbacks * fix: brc20 decimal conversion * fix: recursion parsing * fix: remove 0x from binary content * fix: inscription content fixed for real this time * fix: remove null bytes before inserting * chore: delete http api * fix: new pg methods * fix: all tests * chore: add pool size config, remove http config * style: comments
1 parent 30e8f7a commit 4afb201

File tree

107 files changed

+8157
-11679
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+8157
-11679
lines changed

.github/workflows/ci.yaml

+14
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ jobs:
4444
target/
4545
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
4646

47+
- name: Setup integration environment
48+
run: |
49+
sudo ufw disable
50+
docker compose -f ../../dockerfiles/docker-compose.dev.postgres.yml up -d
51+
docker compose -f ../../dockerfiles/docker-compose.dev.postgres.yml logs -t -f --no-color &> docker-compose-logs.txt &
52+
4753
- name: Update Rust
4854
run: |
4955
rustup update
@@ -59,6 +65,14 @@ jobs:
5965
token: ${{ secrets.CODECOV_TOKEN }}
6066
slug: hirosystems/ordhook
6167

68+
- name: Print integration environment logs
69+
run: cat docker-compose-logs.txt
70+
if: failure()
71+
72+
- name: Teardown integration environment
73+
run: docker compose -f ../../dockerfiles/docker-compose.dev.postgres.yml down -v -t 0
74+
if: always()
75+
6276
build-publish:
6377
runs-on: ubuntu-latest
6478
needs: test

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ components/chainhook-types-js/dist
1818
*.tar.gz
1919
*.zip
2020
*.rdb
21-
Ordhook.toml
21+
/Ordhook.toml
2222

2323
cache/
2424
./tests

.vscode/launch.json

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"type": "lldb",
6+
"request": "launch",
7+
"name": "Debug unit tests in library 'chainhook-postgres'",
8+
"cargo": {
9+
"args": ["test", "--no-run", "--lib", "--package=chainhook-postgres"],
10+
"filter": {
11+
"name": "chainhook-postgres",
12+
"kind": "lib"
13+
}
14+
},
15+
"args": [],
16+
"cwd": "${workspaceFolder}"
17+
},
18+
{
19+
"type": "lldb",
20+
"request": "launch",
21+
"name": "run: ordhook service",
22+
"cargo": {
23+
"args": ["build", "--bin=ordhook", "--package=ordhook-cli"],
24+
"filter": {
25+
"name": "ordhook",
26+
"kind": "bin"
27+
}
28+
},
29+
"args": [
30+
"service",
31+
"start",
32+
"--config-path=${workspaceFolder}/.vscode/ordhook.toml",
33+
],
34+
"cwd": "${workspaceFolder}"
35+
},
36+
{
37+
"type": "lldb",
38+
"request": "launch",
39+
"name": "Debug unit tests in executable 'ordhook'",
40+
"cargo": {
41+
"args": ["test", "--no-run", "--bin=ordhook", "--package=ordhook-cli"],
42+
"filter": {
43+
"name": "ordhook",
44+
"kind": "bin"
45+
}
46+
},
47+
"args": [],
48+
"cwd": "${workspaceFolder}"
49+
},
50+
{
51+
"type": "lldb",
52+
"request": "launch",
53+
"name": "Debug unit tests in library 'ordhook'",
54+
"cargo": {
55+
"args": ["test", "--no-run", "--lib", "--package=ordhook"],
56+
"filter": {
57+
"name": "ordhook",
58+
"kind": "lib"
59+
}
60+
},
61+
"args": [],
62+
"cwd": "${workspaceFolder}"
63+
}
64+
]
65+
}

.vscode/ordhook.toml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
[storage]
2+
working_dir = "tmp"
3+
observers_working_dir = "tmp"
4+
5+
[ordinals_db]
6+
database = "ordinals"
7+
host = "localhost"
8+
port = 5432
9+
username = "postgres"
10+
password = "postgres"
11+
12+
[brc20_db]
13+
database = "brc20"
14+
host = "localhost"
15+
port = 5432
16+
username = "postgres"
17+
password = "postgres"
18+
19+
# The Http Api allows you to register / deregister
20+
# dynamically predicates.
21+
# Disable by default.
22+
#
23+
# [http_api]
24+
# http_port = 20456
25+
26+
[network]
27+
mode = "mainnet"
28+
bitcoind_rpc_url = "http://localhost:8332"
29+
bitcoind_rpc_username = "rafaelcr"
30+
bitcoind_rpc_password = "developer"
31+
bitcoind_zmq_url = "tcp://0.0.0.0:18543"
32+
33+
[resources]
34+
ulimit = 2048
35+
cpu_core_available = 6
36+
memory_available = 16
37+
bitcoind_rpc_threads = 2
38+
bitcoind_rpc_timeout = 15
39+
expected_observers_count = 1
40+
41+
[logs]
42+
ordinals_internals = true
43+
chainhook_internals = true
44+
45+
[meta_protocols]
46+
brc20 = true

0 commit comments

Comments
 (0)