Skip to content

Commit

Permalink
refactor!: store inscription data in postgres instead of sqlite (#375)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
rafaelcr authored Jan 4, 2025
1 parent 30e8f7a commit 4afb201
Show file tree
Hide file tree
Showing 107 changed files with 8,157 additions and 11,679 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ jobs:
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Setup integration environment
run: |
sudo ufw disable
docker compose -f ../../dockerfiles/docker-compose.dev.postgres.yml up -d
docker compose -f ../../dockerfiles/docker-compose.dev.postgres.yml logs -t -f --no-color &> docker-compose-logs.txt &
- name: Update Rust
run: |
rustup update
Expand All @@ -59,6 +65,14 @@ jobs:
token: ${{ secrets.CODECOV_TOKEN }}
slug: hirosystems/ordhook

- name: Print integration environment logs
run: cat docker-compose-logs.txt
if: failure()

- name: Teardown integration environment
run: docker compose -f ../../dockerfiles/docker-compose.dev.postgres.yml down -v -t 0
if: always()

build-publish:
runs-on: ubuntu-latest
needs: test
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ components/chainhook-types-js/dist
*.tar.gz
*.zip
*.rdb
Ordhook.toml
/Ordhook.toml

cache/
./tests
Expand Down
65 changes: 65 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "lldb",
"request": "launch",
"name": "Debug unit tests in library 'chainhook-postgres'",
"cargo": {
"args": ["test", "--no-run", "--lib", "--package=chainhook-postgres"],
"filter": {
"name": "chainhook-postgres",
"kind": "lib"
}
},
"args": [],
"cwd": "${workspaceFolder}"
},
{
"type": "lldb",
"request": "launch",
"name": "run: ordhook service",
"cargo": {
"args": ["build", "--bin=ordhook", "--package=ordhook-cli"],
"filter": {
"name": "ordhook",
"kind": "bin"
}
},
"args": [
"service",
"start",
"--config-path=${workspaceFolder}/.vscode/ordhook.toml",
],
"cwd": "${workspaceFolder}"
},
{
"type": "lldb",
"request": "launch",
"name": "Debug unit tests in executable 'ordhook'",
"cargo": {
"args": ["test", "--no-run", "--bin=ordhook", "--package=ordhook-cli"],
"filter": {
"name": "ordhook",
"kind": "bin"
}
},
"args": [],
"cwd": "${workspaceFolder}"
},
{
"type": "lldb",
"request": "launch",
"name": "Debug unit tests in library 'ordhook'",
"cargo": {
"args": ["test", "--no-run", "--lib", "--package=ordhook"],
"filter": {
"name": "ordhook",
"kind": "lib"
}
},
"args": [],
"cwd": "${workspaceFolder}"
}
]
}
46 changes: 46 additions & 0 deletions .vscode/ordhook.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
[storage]
working_dir = "tmp"
observers_working_dir = "tmp"

[ordinals_db]
database = "ordinals"
host = "localhost"
port = 5432
username = "postgres"
password = "postgres"

[brc20_db]
database = "brc20"
host = "localhost"
port = 5432
username = "postgres"
password = "postgres"

# The Http Api allows you to register / deregister
# dynamically predicates.
# Disable by default.
#
# [http_api]
# http_port = 20456

[network]
mode = "mainnet"
bitcoind_rpc_url = "http://localhost:8332"
bitcoind_rpc_username = "rafaelcr"
bitcoind_rpc_password = "developer"
bitcoind_zmq_url = "tcp://0.0.0.0:18543"

[resources]
ulimit = 2048
cpu_core_available = 6
memory_available = 16
bitcoind_rpc_threads = 2
bitcoind_rpc_timeout = 15
expected_observers_count = 1

[logs]
ordinals_internals = true
chainhook_internals = true

[meta_protocols]
brc20 = true
Loading

0 comments on commit 4afb201

Please sign in to comment.