feature/1121 implement ucan validation (#1176)

- **refactor: remove unused auth components**
- **refactor: improve devbox configuration and deployment process**
- **refactor: improve devnet and testnet setup**
- **fix: update templ version to v0.2.778**
- **refactor: rename pkl/net.matrix to pkl/matrix.net**
- **refactor: migrate webapp components to nebula**
- **refactor: protobuf types**
- **chore: update dependencies for improved security and stability**
- **feat: implement landing page and vault gateway servers**
- **refactor: Migrate data models to new module structure and update
related files**
- **feature/1121-implement-ucan-validation**
- **refactor: Replace hardcoded constants with model types in attns.go**
- **feature/1121-implement-ucan-validation**
- **chore: add origin Host struct and update main function to handle
multiple hosts**
- **build: remove unused static files from dwn module**
- **build: remove unused static files from dwn module**
- **refactor: Move DWN models to common package**
- **refactor: move models to pkg/common**
- **refactor: move vault web app assets to embed module**
- **refactor: update session middleware import path**
- **chore: configure port labels and auto-forwarding behavior**
- **feat: enhance devcontainer configuration**
- **feat: Add UCAN middleware for Echo with flexible token validation**
- **feat: add JWT middleware for UCAN authentication**
- **refactor: update package URI and versioning in PklProject files**
- **fix: correct sonr.pkl import path**
- **refactor: move JWT related code to auth package**
- **feat: introduce vault configuration retrieval and management**
- **refactor: Move vault components to gateway module and update file
paths**
- **refactor: remove Dexie and SQLite database implementations**
- **feat: enhance frontend with PWA features and WASM integration**
- **feat: add Devbox features and streamline Dockerfile**
- **chore: update dependencies to include TigerBeetle**
- **chore(deps): update go version to 1.23**
- **feat: enhance devnet setup with PATH environment variable and
updated PWA manifest**
- **fix: upgrade tigerbeetle-go dependency and remove indirect
dependency**
- **feat: add PostgreSQL support to devnet and testnet deployments**
- **refactor: rename keyshare cookie to token cookie**
- **feat: upgrade Go version to 1.23.3 and update dependencies**
- **refactor: update devnet and testnet configurations**
- **feat: add IPFS configuration for devnet**
- **I'll help you update the ipfs.config.pkl to include all the peers
from the shell script. Here's the updated configuration:**
- **refactor: move mpc package to crypto directory**
- **feat: add BIP32 support for various cryptocurrencies**
- **feat: enhance ATN.pkl with additional capabilities**
- **refactor: simplify smart account and vault attenuation creation**
- **feat: add new capabilities to the Attenuation type**
- **refactor: Rename MPC files for clarity and consistency**
- **feat: add DIDKey support for cryptographic operations**
- **feat: add devnet and testnet deployment configurations**
- **fix: correct key derivation in bip32 package**
- **refactor: rename crypto/bip32 package to crypto/accaddr**
- **fix: remove duplicate indirect dependency**
- **refactor: move vault package to root directory**
- **refactor: update routes for gateway and vault**
- **refactor: remove obsolete web configuration file**
- **refactor: remove unused TigerBeetle imports and update host
configuration**
- **refactor: adjust styles directory path**
- **feat: add broadcastTx and simulateTx functions to gateway**
- **feat: add PinVault handler**
This commit is contained in:
Prad Nukala
2024-12-02 14:27:18 -05:00
committed by GitHub
parent 2a128af227
commit 31bcc21c35
535 changed files with 9357 additions and 10950 deletions
+8
View File
@@ -0,0 +1,8 @@
# Deployment
This directory contains the configuration files for deploying the Sonr blockchain.
## Contents
- `devnet`: Configuration for deploying the Sonr blockchain on the devnet (local development).
- `testnet`: Configuration for deploying the Sonr blockchain on the testnet (current prod setup)
+12
View File
@@ -0,0 +1,12 @@
# https://taskfile.dev
version: '3'
vars:
GREETING: Hello, World!
tasks:
default:
cmds:
- echo "{{.GREETING}}"
silent: true
+202
View File
@@ -0,0 +1,202 @@
import "https://pkl.sh/ipfs.net/0.0.1/Config.pkl"
API {
HTTPHeaders {
`Access-Control-Allow-Origin` = new { "*" }
}
}
Addresses {
API = "/ip4/127.0.0.1/tcp/5001"
Gateway = "/ip4/127.0.0.1/tcp/8080"
Swarm = new {
"/ip4/0.0.0.0/tcp/4001"
"/ip6/::/tcp/4001"
"/ip4/0.0.0.0/udp/4001/quic"
"/ip6/::/udp/4001/quic"
}
}
Bootstrap {
"/dnsaddr/bootstrap.libp2p.io/p2p/QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa"
"/dnsaddr/bootstrap.libp2p.io/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb"
"/dnsaddr/bootstrap.libp2p.io/p2p/QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt"
"/ip4/104.131.131.82/tcp/4001/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ"
"/ip4/104.131.131.82/udp/4001/quic/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ"
"/dnsaddr/bootstrap.libp2p.io/p2p/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN"
}
Datastore {
BloomFilterSize = 0
GCPeriod = "1h"
HashOnRead = false
StorageGCWatermark = 90
StorageMax = "10GB"
Spec = new {
mounts = new {
new {
prefix = "flatfs.datastore"
child = new {
path = "blocks"
shardFunc = "/repo/flatfs/shard/v1/next-to-last/2"
type = "flatfs"
sync = true
}
mountpoint = "/blocks"
type = "measure"
}
new {
prefix = "leveldb.datastore"
child = new {
compression = "none"
path = "datastore"
type = "levelds"
}
mountpoint = "/"
type = "measure"
}
}
type = "mount"
}
}
Discovery {
MDNS = new {
Enabled = true
}
}
Experimental {
StrategicProviding = false
UrlstoreEnabled = false
AcceleratedDHTClient = false
GraphsyncEnabled = false
FilestoreEnabled = false
Libp2pStreamMounting = false
P2pHttpProxy = false
}
Gateway {
HTTPHeaders = new {
`Access-Control-Allow-Headers` = new {
"X-Requested-With"
"Range"
"User-Agent"
}
`Access-Control-Allow-Methods` = new { "GET" }
`Access-Control-Allow-Origin` = new { "*" }
}
NoDNSLink = false
NoFetch = false
PublicGateways = null
RootRedirect = ""
Writable = false
}
Identity {
PrivKey = "CAESQP0FRhYf5Nvxg0wrbN+VTK7kWdgy+3AKoxU3vNH0K9FHVpXyx6/mHKyCaPjqI11YsHUW0B2ZODGROPafyS6IeWY="
PeerID = "12D3KooWFeMr1tHFs8WAF11rKDULJbmKg9rE5aVhYJU23oC7pqjB"
}
Ipns {
RecordLifetime = ""
RepublishPeriod = ""
ResolveCacheSize = 128
}
Migration {
Keep = ""
}
Mounts {
IPNS = "/ipns"
FuseAllowOther = false
IPFS = "/ipfs"
}
Peering {
Peers = new {
new {
Addrs = new { "/dnsaddr/node-1.ingress.cloudflare-ipfs.com" }
ID = "QmcFf2FH3CEgTNHeMRGhN7HNHU1EXAxoEk6EFuSyXCsvRE"
}
new {
Addrs = new { "/dnsaddr/node-2.ingress.cloudflare-ipfs.com" }
ID = "QmcFmLd5ySfk2WZuJ1mfSWLDjdmHZq7rSAua4GoeSQfs1z"
}
new {
Addrs = new { "/dnsaddr/node-3.ingress.cloudflare-ipfs.com" }
ID = "QmcfFmzSDVbwexQ9Au2pt5YEXHK5xajwgaU6PpkbLWerMa"
}
new {
Addrs = new { "/dnsaddr/node-4.ingress.cloudflare-ipfs.com" }
ID = "QmcfJeB3Js1FG7T8YaZATEiaHqNKVdQfybYYkbT1knUswx"
}
new {
Addrs = new { "/dnsaddr/node-5.ingress.cloudflare-ipfs.com" }
ID = "QmcfVvzK4tMdFmpJjEKDUoqRgP4W9FnmJoziYX5GXJJ8eZ"
}
new {
Addrs = new { "/dnsaddr/node-6.ingress.cloudflare-ipfs.com" }
ID = "QmcfZD3VKrUxyP9BbyUnZDpbqDnT7cQ4WjPP8TRLXaoE7G"
}
new {
Addrs = new { "/dnsaddr/node-7.ingress.cloudflare-ipfs.com" }
ID = "QmcfZP2LuW4jxviTeG8fi28qjnZScACb8PEgHAc17ZEri3"
}
new {
Addrs = new { "/dnsaddr/node-8.ingress.cloudflare-ipfs.com" }
ID = "QmcfgsJsMtx6qJb74akCw1M24X1zFwgGo11h1cuhwQjtJP"
}
new {
Addrs = new { "/dnsaddr/node-9.ingress.cloudflare-ipfs.com" }
ID = "Qmcfr2FC7pFzJbTSDfYaSy1J8Uuy8ccGLeLyqJCKJvTHMi"
}
new {
Addrs = new { "/dnsaddr/node-10.ingress.cloudflare-ipfs.com" }
ID = "QmcfR3V5YAtHBzxVACWCzXTt26SyEkxdwhGJ6875A8BuWx"
}
new {
Addrs = new { "/dnsaddr/node-11.ingress.cloudflare-ipfs.com" }
ID = "Qmcfuo1TM9uUiJp6dTbm915Rf1aTqm3a3dnmCdDQLHgvL5"
}
new {
Addrs = new { "/dnsaddr/node-12.ingress.cloudflare-ipfs.com" }
ID = "QmcfV2sg9zaq7UUHVCGuSvT2M2rnLBAPsiE79vVyK3Cuev"
}
}
}
Provider {
Strategy = ""
}
Pubsub {
Router = ""
DisableSigning = false
}
Reprovider {
Strategy = "all"
Interval = "12h"
}
Routing {
Methods = null
Routers = null
Type = "dht"
}
Swarm {
AddrFilters = null
ConnMgr = new {}
DisableBandwidthMetrics = false
DisableNatPortMap = false
RelayClient = new {}
ResourceMgr = new {}
Transports = new {
Multiplexers = new {}
Network = new {}
Security = new {}
}
}
+3
View File
@@ -0,0 +1,3 @@
amends "https://pkl.sh/sonr.chain/0.0.2/App.pkl"
+3
View File
@@ -0,0 +1,3 @@
amends "https://pkl.sh/sonr.chain/0.0.2/Genesis.pkl"
@@ -1,19 +1,22 @@
{
"$schema": "https://raw.githubusercontent.com/jetify-com/devbox/0.12.0/.schema/devbox.schema.json",
"packages": [
"go@1.22",
"go@1.23",
"bun@latest",
"ipfs@latest",
"skate@latest",
"air@latest",
"templ@latest"
"go-task@latest",
"templ@latest",
"tigerbeetle@latest"
],
"env": {
"GOPATH": "$HOME/go",
"CHAIN_ID": "sonr-testnet-1",
"PATH": "./build:$HOME/go/bin:$PATH",
"CHAIN_ID": "sonr-devnet-1",
"DENOM": "usnr",
"KEYRING": "test",
"MONIKER": "florence",
"MONIKER": "cupertino",
"BINARY": "sonrd",
"ACC0_NAME": "acc0",
"ACC1_NAME": "acc1",
@@ -23,12 +26,23 @@
"ACC1_MNEMONIC": "$(skate get ACC1_MNEMONIC)"
},
"shell": {
"init_hook": ["export ROOT=$(git rev-parse --show-toplevel)"],
"init_hook": [
"export ROOT=$(git rev-parse --show-toplevel)"
],
"scripts": {
"devnet": ["cd $ROOT", "make sh-testnet"],
"ipfs": ["cd $ROOT", "make setup-ipfs", "ipfs daemon"],
"air": ["cd $ROOT", "air"],
"gex": ["go install github.com/cosmos/gex@latest", "gex"]
"sonr": [
"cd $ROOT",
"make sh-testnet"
],
"ipfs": [
"cd $ROOT",
"make setup-ipfs",
"ipfs daemon"
],
"hway": [
"cd $ROOT",
"air"
]
}
}
}
@@ -97,51 +97,99 @@
}
}
},
"go@1.22": {
"last_modified": "2024-11-16T04:25:12Z",
"resolved": "github:NixOS/nixpkgs/34a626458d686f1b58139620a8b2793e9e123bba#go_1_22",
"go-task@latest": {
"last_modified": "2024-11-28T07:51:56Z",
"resolved": "github:NixOS/nixpkgs/226216574ada4c3ecefcbbec41f39ce4655f78ef#go-task",
"source": "devbox-search",
"version": "1.22.9",
"version": "3.40.0",
"systems": {
"aarch64-darwin": {
"outputs": [
{
"name": "out",
"path": "/nix/store/4nf51i4ah186y2jy3fad2fyvpa49qx6q-go-1.22.9",
"path": "/nix/store/ynnx5bghcar86a89026rdysvpf51b2li-go-task-3.40.0",
"default": true
}
],
"store_path": "/nix/store/4nf51i4ah186y2jy3fad2fyvpa49qx6q-go-1.22.9"
"store_path": "/nix/store/ynnx5bghcar86a89026rdysvpf51b2li-go-task-3.40.0"
},
"aarch64-linux": {
"outputs": [
{
"name": "out",
"path": "/nix/store/8w8vzwgp55yl8j1ljgm4wzdgjkvkv5v3-go-1.22.9",
"path": "/nix/store/2ga7yc7nn0k01n2w3wa6fjbp0i31r6d6-go-task-3.40.0",
"default": true
}
],
"store_path": "/nix/store/8w8vzwgp55yl8j1ljgm4wzdgjkvkv5v3-go-1.22.9"
"store_path": "/nix/store/2ga7yc7nn0k01n2w3wa6fjbp0i31r6d6-go-task-3.40.0"
},
"x86_64-darwin": {
"outputs": [
{
"name": "out",
"path": "/nix/store/vlih7j78ki05i8nvzdsxvws7a7ksq04m-go-1.22.9",
"path": "/nix/store/0fc73lrh98s9i7qjsxk8gjddxam5kv76-go-task-3.40.0",
"default": true
}
],
"store_path": "/nix/store/vlih7j78ki05i8nvzdsxvws7a7ksq04m-go-1.22.9"
"store_path": "/nix/store/0fc73lrh98s9i7qjsxk8gjddxam5kv76-go-task-3.40.0"
},
"x86_64-linux": {
"outputs": [
{
"name": "out",
"path": "/nix/store/frc5188kgv3ws0n999c7cy5vi2f8k4jp-go-1.22.9",
"path": "/nix/store/x5pbyv5p0yj3fl77j4bmgcj8s7jjcjwn-go-task-3.40.0",
"default": true
}
],
"store_path": "/nix/store/frc5188kgv3ws0n999c7cy5vi2f8k4jp-go-1.22.9"
"store_path": "/nix/store/x5pbyv5p0yj3fl77j4bmgcj8s7jjcjwn-go-task-3.40.0"
}
}
},
"go@1.23": {
"last_modified": "2024-11-16T04:25:12Z",
"resolved": "github:NixOS/nixpkgs/34a626458d686f1b58139620a8b2793e9e123bba#go",
"source": "devbox-search",
"version": "1.23.3",
"systems": {
"aarch64-darwin": {
"outputs": [
{
"name": "out",
"path": "/nix/store/qrj2wp6vzfpjfrrlcmr22818zg83fb73-go-1.23.3",
"default": true
}
],
"store_path": "/nix/store/qrj2wp6vzfpjfrrlcmr22818zg83fb73-go-1.23.3"
},
"aarch64-linux": {
"outputs": [
{
"name": "out",
"path": "/nix/store/dm66qyl19skrwcmk4rb9xcs64xc1d071-go-1.23.3",
"default": true
}
],
"store_path": "/nix/store/dm66qyl19skrwcmk4rb9xcs64xc1d071-go-1.23.3"
},
"x86_64-darwin": {
"outputs": [
{
"name": "out",
"path": "/nix/store/vkjn6njpz4gy5ma763vh8hh93bgjwycr-go-1.23.3",
"default": true
}
],
"store_path": "/nix/store/vkjn6njpz4gy5ma763vh8hh93bgjwycr-go-1.23.3"
},
"x86_64-linux": {
"outputs": [
{
"name": "out",
"path": "/nix/store/bavnchxi7v6xs077jxv7fl5rrqc3y87w-go-1.23.3",
"default": true
}
],
"store_path": "/nix/store/bavnchxi7v6xs077jxv7fl5rrqc3y87w-go-1.23.3"
}
}
},
@@ -246,6 +294,54 @@
"store_path": "/nix/store/sn5h79d36r86i6a8rm1k52c2ij1s32kx-templ-0.2.793"
}
}
},
"tigerbeetle@latest": {
"last_modified": "2024-11-16T04:25:12Z",
"resolved": "github:NixOS/nixpkgs/34a626458d686f1b58139620a8b2793e9e123bba#tigerbeetle",
"source": "devbox-search",
"version": "0.16.12",
"systems": {
"aarch64-darwin": {
"outputs": [
{
"name": "out",
"path": "/nix/store/mm3jzwf24p35afr55v7kl5a0h6962i6p-tigerbeetle-0.16.12",
"default": true
}
],
"store_path": "/nix/store/mm3jzwf24p35afr55v7kl5a0h6962i6p-tigerbeetle-0.16.12"
},
"aarch64-linux": {
"outputs": [
{
"name": "out",
"path": "/nix/store/4106973gg3crfxq0gwrgwn4hcx64mzyy-tigerbeetle-0.16.12",
"default": true
}
],
"store_path": "/nix/store/4106973gg3crfxq0gwrgwn4hcx64mzyy-tigerbeetle-0.16.12"
},
"x86_64-darwin": {
"outputs": [
{
"name": "out",
"path": "/nix/store/6lnwnr3mvdamm5lxjjqkaagw2pyqlq0a-tigerbeetle-0.16.12",
"default": true
}
],
"store_path": "/nix/store/6lnwnr3mvdamm5lxjjqkaagw2pyqlq0a-tigerbeetle-0.16.12"
},
"x86_64-linux": {
"outputs": [
{
"name": "out",
"path": "/nix/store/afrj2ph61xz0lh7f3d1g1d7v2rslbvny-tigerbeetle-0.16.12",
"default": true
}
],
"store_path": "/nix/store/afrj2ph61xz0lh7f3d1g1d7v2rslbvny-tigerbeetle-0.16.12"
}
}
}
}
}
@@ -2,7 +2,7 @@ version: "0.6"
processes:
ipfs:
namespace: testnet
namespace: devnet
command: "devbox run ipfs"
background: true
availability:
@@ -10,19 +10,20 @@ processes:
max_restarts: 0
sonr:
namespace: testnet
namespace: devnet
background: true
command: "devbox run devnet"
command: "devbox run sonr"
restart: never
max_restarts: 1
depends:
- ipfs
hway-air:
namespace: testnet
hway:
namespace: devnet
background: true
command: "devbox run air"
command: "devbox run hway"
restart: never
max_restarts: 1
depends:
- ipfs
- sonr
+85
View File
@@ -0,0 +1,85 @@
/*
This file defines the database schema for the PostgresQL ("psql") event sink
implementation in CometBFT. The operator must create a database and install
this schema before using the database to index events.
*/
-- The blocks table records metadata about each block.
-- The block record does not include its events or transactions (see tx_results).
CREATE TABLE blocks (
rowid BIGSERIAL PRIMARY KEY,
height BIGINT NOT NULL,
chain_id VARCHAR NOT NULL,
-- When this block header was logged into the sink, in UTC.
created_at TIMESTAMPTZ NOT NULL,
UNIQUE (height, chain_id)
);
-- Index blocks by height and chain, since we need to resolve block IDs when
-- indexing transaction records and transaction events.
CREATE INDEX idx_blocks_height_chain ON blocks(height, chain_id);
-- The tx_results table records metadata about transaction results. Note that
-- the events from a transaction are stored separately.
CREATE TABLE tx_results (
rowid BIGSERIAL PRIMARY KEY,
-- The block to which this transaction belongs.
block_id BIGINT NOT NULL REFERENCES blocks(rowid),
-- The sequential index of the transaction within the block.
index INTEGER NOT NULL,
-- When this result record was logged into the sink, in UTC.
created_at TIMESTAMPTZ NOT NULL,
-- The hex-encoded hash of the transaction.
tx_hash VARCHAR NOT NULL,
-- The protobuf wire encoding of the TxResult message.
tx_result BYTEA NOT NULL,
UNIQUE (block_id, index)
);
-- The events table records events. All events (both block and transaction) are
-- associated with a block ID; transaction events also have a transaction ID.
CREATE TABLE events (
rowid BIGSERIAL PRIMARY KEY,
-- The block and transaction this event belongs to.
-- If tx_id is NULL, this is a block event.
block_id BIGINT NOT NULL REFERENCES blocks(rowid),
tx_id BIGINT NULL REFERENCES tx_results(rowid),
-- The application-defined type label for the event.
type VARCHAR NOT NULL
);
-- The attributes table records event attributes.
CREATE TABLE attributes (
event_id BIGINT NOT NULL REFERENCES events(rowid),
key VARCHAR NOT NULL, -- bare key
composite_key VARCHAR NOT NULL, -- composed type.key
value VARCHAR NULL,
UNIQUE (event_id, key)
);
-- A joined view of events and their attributes. Events that do not have any
-- attributes are represented as a single row with empty key and value fields.
CREATE VIEW event_attributes AS
SELECT block_id, tx_id, type, key, composite_key, value
FROM events LEFT JOIN attributes ON (events.rowid = attributes.event_id);
-- A joined view of all block events (those having tx_id NULL).
CREATE VIEW block_events AS
SELECT blocks.rowid as block_id, height, chain_id, type, key, composite_key, value
FROM blocks JOIN event_attributes ON (blocks.rowid = event_attributes.block_id)
WHERE event_attributes.tx_id IS NULL;
-- A joined view of all transaction events.
CREATE VIEW tx_events AS
SELECT height, index, chain_id, type, key, composite_key, value, tx_results.created_at
FROM blocks JOIN tx_results ON (blocks.rowid = tx_results.block_id)
JOIN event_attributes ON (tx_results.rowid = event_attributes.tx_id)
WHERE event_attributes.tx_id IS NOT NULL;
+12
View File
@@ -0,0 +1,12 @@
# https://taskfile.dev
version: '3'
vars:
GREETING: Hello, World!
tasks:
default:
cmds:
- echo "{{.GREETING}}"
silent: true
+202
View File
@@ -0,0 +1,202 @@
import "https://pkl.sh/ipfs.net/0.0.1/Config.pkl"
API {
HTTPHeaders {
`Access-Control-Allow-Origin` = new { "*" }
}
}
Addresses {
API = "/ip4/127.0.0.1/tcp/5001"
Gateway = "/ip4/127.0.0.1/tcp/8080"
Swarm = new {
"/ip4/0.0.0.0/tcp/4001"
"/ip6/::/tcp/4001"
"/ip4/0.0.0.0/udp/4001/quic"
"/ip6/::/udp/4001/quic"
}
}
Bootstrap {
"/dnsaddr/bootstrap.libp2p.io/p2p/QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa"
"/dnsaddr/bootstrap.libp2p.io/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb"
"/dnsaddr/bootstrap.libp2p.io/p2p/QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt"
"/ip4/104.131.131.82/tcp/4001/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ"
"/ip4/104.131.131.82/udp/4001/quic/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ"
"/dnsaddr/bootstrap.libp2p.io/p2p/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN"
}
Datastore {
BloomFilterSize = 0
GCPeriod = "1h"
HashOnRead = false
StorageGCWatermark = 90
StorageMax = "10GB"
Spec = new {
mounts = new {
new {
prefix = "flatfs.datastore"
child = new {
path = "blocks"
shardFunc = "/repo/flatfs/shard/v1/next-to-last/2"
type = "flatfs"
sync = true
}
mountpoint = "/blocks"
type = "measure"
}
new {
prefix = "leveldb.datastore"
child = new {
compression = "none"
path = "datastore"
type = "levelds"
}
mountpoint = "/"
type = "measure"
}
}
type = "mount"
}
}
Discovery {
MDNS = new {
Enabled = true
}
}
Experimental {
StrategicProviding = false
UrlstoreEnabled = false
AcceleratedDHTClient = false
GraphsyncEnabled = false
FilestoreEnabled = false
Libp2pStreamMounting = false
P2pHttpProxy = false
}
Gateway {
HTTPHeaders = new {
`Access-Control-Allow-Headers` = new {
"X-Requested-With"
"Range"
"User-Agent"
}
`Access-Control-Allow-Methods` = new { "GET" }
`Access-Control-Allow-Origin` = new { "*" }
}
NoDNSLink = false
NoFetch = false
PublicGateways = null
RootRedirect = ""
Writable = false
}
Identity {
PrivKey = "CAESQP0FRhYf5Nvxg0wrbN+VTK7kWdgy+3AKoxU3vNH0K9FHVpXyx6/mHKyCaPjqI11YsHUW0B2ZODGROPafyS6IeWY="
PeerID = "12D3KooWFeMr1tHFs8WAF11rKDULJbmKg9rE5aVhYJU23oC7pqjB"
}
Ipns {
RecordLifetime = ""
RepublishPeriod = ""
ResolveCacheSize = 128
}
Migration {
Keep = ""
}
Mounts {
IPNS = "/ipns"
FuseAllowOther = false
IPFS = "/ipfs"
}
Peering {
Peers = new {
new {
Addrs = new { "/dnsaddr/node-1.ingress.cloudflare-ipfs.com" }
ID = "QmcFf2FH3CEgTNHeMRGhN7HNHU1EXAxoEk6EFuSyXCsvRE"
}
new {
Addrs = new { "/dnsaddr/node-2.ingress.cloudflare-ipfs.com" }
ID = "QmcFmLd5ySfk2WZuJ1mfSWLDjdmHZq7rSAua4GoeSQfs1z"
}
new {
Addrs = new { "/dnsaddr/node-3.ingress.cloudflare-ipfs.com" }
ID = "QmcfFmzSDVbwexQ9Au2pt5YEXHK5xajwgaU6PpkbLWerMa"
}
new {
Addrs = new { "/dnsaddr/node-4.ingress.cloudflare-ipfs.com" }
ID = "QmcfJeB3Js1FG7T8YaZATEiaHqNKVdQfybYYkbT1knUswx"
}
new {
Addrs = new { "/dnsaddr/node-5.ingress.cloudflare-ipfs.com" }
ID = "QmcfVvzK4tMdFmpJjEKDUoqRgP4W9FnmJoziYX5GXJJ8eZ"
}
new {
Addrs = new { "/dnsaddr/node-6.ingress.cloudflare-ipfs.com" }
ID = "QmcfZD3VKrUxyP9BbyUnZDpbqDnT7cQ4WjPP8TRLXaoE7G"
}
new {
Addrs = new { "/dnsaddr/node-7.ingress.cloudflare-ipfs.com" }
ID = "QmcfZP2LuW4jxviTeG8fi28qjnZScACb8PEgHAc17ZEri3"
}
new {
Addrs = new { "/dnsaddr/node-8.ingress.cloudflare-ipfs.com" }
ID = "QmcfgsJsMtx6qJb74akCw1M24X1zFwgGo11h1cuhwQjtJP"
}
new {
Addrs = new { "/dnsaddr/node-9.ingress.cloudflare-ipfs.com" }
ID = "Qmcfr2FC7pFzJbTSDfYaSy1J8Uuy8ccGLeLyqJCKJvTHMi"
}
new {
Addrs = new { "/dnsaddr/node-10.ingress.cloudflare-ipfs.com" }
ID = "QmcfR3V5YAtHBzxVACWCzXTt26SyEkxdwhGJ6875A8BuWx"
}
new {
Addrs = new { "/dnsaddr/node-11.ingress.cloudflare-ipfs.com" }
ID = "Qmcfuo1TM9uUiJp6dTbm915Rf1aTqm3a3dnmCdDQLHgvL5"
}
new {
Addrs = new { "/dnsaddr/node-12.ingress.cloudflare-ipfs.com" }
ID = "QmcfV2sg9zaq7UUHVCGuSvT2M2rnLBAPsiE79vVyK3Cuev"
}
}
}
Provider {
Strategy = ""
}
Pubsub {
Router = ""
DisableSigning = false
}
Reprovider {
Strategy = "all"
Interval = "12h"
}
Routing {
Methods = null
Routers = null
Type = "dht"
}
Swarm {
AddrFilters = null
ConnMgr = new {}
DisableBandwidthMetrics = false
DisableNatPortMap = false
RelayClient = new {}
ResourceMgr = new {}
Transports = new {
Multiplexers = new {}
Network = new {}
Security = new {}
}
}
+3
View File
@@ -0,0 +1,3 @@
amends "https://pkl.sh/sonr.chain/0.0.2/App.pkl"
+3
View File
@@ -0,0 +1,3 @@
amends "https://pkl.sh/sonr.chain/0.0.2/Genesis.pkl"
+27 -20
View File
@@ -1,12 +1,20 @@
{
"$schema": "https://raw.githubusercontent.com/jetify-com/devbox/0.12.0/.schema/devbox.schema.json",
"packages": [
"go@1.22",
"bun@latest",
"ipfs@latest",
"air@latest",
"templ@latest"
],
"packages": {
"go": "1.23",
"bun": "latest",
"ipfs": "latest",
"skate": "latest",
"cloudflared": "latest",
"go-task": "latest",
"tigerbeetle": "latest",
"matrix-synapse": {
"version": "latest",
"excluded_platforms": [
"aarch64-darwin"
]
}
},
"env": {
"GOPATH": "$HOME/go",
"PATH": "./build:$HOME/go/bin:$PATH",
@@ -21,22 +29,21 @@
"ACC1_ADDRESS": "idx1hj5fveer5cjtn4wd6wstzugjfdxzl0xpecp0nd",
"ACC0_MNEMONIC": "$(skate get ACC0_MNEMONIC)",
"ACC1_MNEMONIC": "$(skate get ACC1_MNEMONIC)",
"TUNNEL_TOKEN": "$(skate get CLOUDFLARE_TUNNEL_TOKEN)",
"TEMPL_EXPERIMENT": "rawgo",
"R2_CDN_BUCKET": "cdn",
"R2_PKL_BUCKET": "pkljar"
"TUNNEL_TOKEN": "$(skate get CLOUDFLARE_TUNNEL_TOKEN)"
},
"shell": {
"init_hook": ["export ROOT=$(git rev-parse --show-toplevel)"],
"init_hook": [
"export ROOT=$(git rev-parse --show-toplevel)"
],
"scripts": {
"start:testnet": ["make sh-testnet"],
"start:ipfs": ["sh scripts/setup_ipfs.sh"],
"start:air": ["air"],
"start:gex": ["go install github.com/cosmos/gex@latest", "gex"],
"gen:pkl": ["make gen-pkl"],
"gen:templ": ["make gen-templ"],
"buf-push": [
"cd ./proto && bunx buf dep update && bunx buf build && bunx buf push"
"sonr": [
"cd $ROOT",
"make sh-testnet"
],
"ipfs": [
"cd $ROOT",
"make setup-ipfs",
"ipfs daemon"
]
}
}
+289 -88
View File
@@ -1,54 +1,6 @@
{
"lockfile_version": "1",
"packages": {
"air@latest": {
"last_modified": "2024-11-16T04:25:12Z",
"resolved": "github:NixOS/nixpkgs/34a626458d686f1b58139620a8b2793e9e123bba#air",
"source": "devbox-search",
"version": "1.61.1",
"systems": {
"aarch64-darwin": {
"outputs": [
{
"name": "out",
"path": "/nix/store/0s90vbnmsyyixs0991md21pbrw8babfb-air-1.61.1",
"default": true
}
],
"store_path": "/nix/store/0s90vbnmsyyixs0991md21pbrw8babfb-air-1.61.1"
},
"aarch64-linux": {
"outputs": [
{
"name": "out",
"path": "/nix/store/8mpw2asxs297v26fxqy2y1bq438f344l-air-1.61.1",
"default": true
}
],
"store_path": "/nix/store/8mpw2asxs297v26fxqy2y1bq438f344l-air-1.61.1"
},
"x86_64-darwin": {
"outputs": [
{
"name": "out",
"path": "/nix/store/abminkf7ldqf9vm14xx5wvsrdx3wrvy6-air-1.61.1",
"default": true
}
],
"store_path": "/nix/store/abminkf7ldqf9vm14xx5wvsrdx3wrvy6-air-1.61.1"
},
"x86_64-linux": {
"outputs": [
{
"name": "out",
"path": "/nix/store/ajx8v5rbbvglncb97yybg3x9kn95gfrm-air-1.61.1",
"default": true
}
],
"store_path": "/nix/store/ajx8v5rbbvglncb97yybg3x9kn95gfrm-air-1.61.1"
}
}
},
"bun@latest": {
"last_modified": "2024-11-18T00:41:09Z",
"resolved": "github:NixOS/nixpkgs/5083ec887760adfe12af64830a66807423a859a7#bun",
@@ -97,51 +49,99 @@
}
}
},
"go@1.22": {
"last_modified": "2024-11-16T04:25:12Z",
"resolved": "github:NixOS/nixpkgs/34a626458d686f1b58139620a8b2793e9e123bba#go_1_22",
"cloudflared@latest": {
"last_modified": "2024-11-18T00:41:09Z",
"resolved": "github:NixOS/nixpkgs/5083ec887760adfe12af64830a66807423a859a7#cloudflared",
"source": "devbox-search",
"version": "1.22.9",
"version": "2024.11.0",
"systems": {
"aarch64-darwin": {
"outputs": [
{
"name": "out",
"path": "/nix/store/4nf51i4ah186y2jy3fad2fyvpa49qx6q-go-1.22.9",
"path": "/nix/store/95knk04xlh78swlk9a6kg524rfykzzmz-cloudflared-2024.11.0",
"default": true
}
],
"store_path": "/nix/store/4nf51i4ah186y2jy3fad2fyvpa49qx6q-go-1.22.9"
"store_path": "/nix/store/95knk04xlh78swlk9a6kg524rfykzzmz-cloudflared-2024.11.0"
},
"aarch64-linux": {
"outputs": [
{
"name": "out",
"path": "/nix/store/8w8vzwgp55yl8j1ljgm4wzdgjkvkv5v3-go-1.22.9",
"path": "/nix/store/2d6mh1pi99m19bc9m3phcsfgygbfpyig-cloudflared-2024.11.0",
"default": true
}
],
"store_path": "/nix/store/8w8vzwgp55yl8j1ljgm4wzdgjkvkv5v3-go-1.22.9"
"store_path": "/nix/store/2d6mh1pi99m19bc9m3phcsfgygbfpyig-cloudflared-2024.11.0"
},
"x86_64-darwin": {
"outputs": [
{
"name": "out",
"path": "/nix/store/vlih7j78ki05i8nvzdsxvws7a7ksq04m-go-1.22.9",
"path": "/nix/store/4dii539ldfv0f9n7xigfy19ivrg3ng2n-cloudflared-2024.11.0",
"default": true
}
],
"store_path": "/nix/store/vlih7j78ki05i8nvzdsxvws7a7ksq04m-go-1.22.9"
"store_path": "/nix/store/4dii539ldfv0f9n7xigfy19ivrg3ng2n-cloudflared-2024.11.0"
},
"x86_64-linux": {
"outputs": [
{
"name": "out",
"path": "/nix/store/frc5188kgv3ws0n999c7cy5vi2f8k4jp-go-1.22.9",
"path": "/nix/store/hlnabpfi58mpd16symqb7kp8xc2lf1pf-cloudflared-2024.11.0",
"default": true
}
],
"store_path": "/nix/store/frc5188kgv3ws0n999c7cy5vi2f8k4jp-go-1.22.9"
"store_path": "/nix/store/hlnabpfi58mpd16symqb7kp8xc2lf1pf-cloudflared-2024.11.0"
}
}
},
"go@1.23": {
"last_modified": "2024-11-16T04:25:12Z",
"resolved": "github:NixOS/nixpkgs/34a626458d686f1b58139620a8b2793e9e123bba#go",
"source": "devbox-search",
"version": "1.23.3",
"systems": {
"aarch64-darwin": {
"outputs": [
{
"name": "out",
"path": "/nix/store/qrj2wp6vzfpjfrrlcmr22818zg83fb73-go-1.23.3",
"default": true
}
],
"store_path": "/nix/store/qrj2wp6vzfpjfrrlcmr22818zg83fb73-go-1.23.3"
},
"aarch64-linux": {
"outputs": [
{
"name": "out",
"path": "/nix/store/dm66qyl19skrwcmk4rb9xcs64xc1d071-go-1.23.3",
"default": true
}
],
"store_path": "/nix/store/dm66qyl19skrwcmk4rb9xcs64xc1d071-go-1.23.3"
},
"x86_64-darwin": {
"outputs": [
{
"name": "out",
"path": "/nix/store/vkjn6njpz4gy5ma763vh8hh93bgjwycr-go-1.23.3",
"default": true
}
],
"store_path": "/nix/store/vkjn6njpz4gy5ma763vh8hh93bgjwycr-go-1.23.3"
},
"x86_64-linux": {
"outputs": [
{
"name": "out",
"path": "/nix/store/bavnchxi7v6xs077jxv7fl5rrqc3y87w-go-1.23.3",
"default": true
}
],
"store_path": "/nix/store/bavnchxi7v6xs077jxv7fl5rrqc3y87w-go-1.23.3"
}
}
},
@@ -151,51 +151,252 @@
"source": "devbox-search",
"version": "0.17.0"
},
"templ@latest": {
"last_modified": "2024-11-16T04:25:12Z",
"resolved": "github:NixOS/nixpkgs/34a626458d686f1b58139620a8b2793e9e123bba#templ",
"matrix-synapse@latest": {
"last_modified": "2024-11-18T00:41:09Z",
"resolved": "github:NixOS/nixpkgs/5083ec887760adfe12af64830a66807423a859a7#matrix-synapse",
"source": "devbox-search",
"version": "0.2.793",
"version": "1.119.0",
"systems": {
"aarch64-darwin": {
"outputs": [
{
"name": "out",
"path": "/nix/store/ivargvf76g71k5gk3iz4al52rsy28w38-templ-0.2.793",
"default": true
}
],
"store_path": "/nix/store/ivargvf76g71k5gk3iz4al52rsy28w38-templ-0.2.793"
},
"aarch64-linux": {
"outputs": [
{
"name": "out",
"path": "/nix/store/03654iddn006yx5j1lqq496hax60v8p5-templ-0.2.793",
"path": "/nix/store/dfgj6lgmxy18qd5v9z91376i0b1z06jx-matrix-synapse-wrapped-1.119.0",
"default": true
}
],
"store_path": "/nix/store/03654iddn006yx5j1lqq496hax60v8p5-templ-0.2.793"
},
"x86_64-darwin": {
"outputs": [
{
"name": "out",
"path": "/nix/store/blvd5wbd1ix6m745s4zx3b84kwzprshq-templ-0.2.793",
"default": true
}
],
"store_path": "/nix/store/blvd5wbd1ix6m745s4zx3b84kwzprshq-templ-0.2.793"
"store_path": "/nix/store/dfgj6lgmxy18qd5v9z91376i0b1z06jx-matrix-synapse-wrapped-1.119.0"
},
"x86_64-linux": {
"outputs": [
{
"name": "out",
"path": "/nix/store/sn5h79d36r86i6a8rm1k52c2ij1s32kx-templ-0.2.793",
"path": "/nix/store/570l35c4n3qdxaszrf6bz4rrrw87pkil-matrix-synapse-wrapped-1.119.0",
"default": true
}
],
"store_path": "/nix/store/sn5h79d36r86i6a8rm1k52c2ij1s32kx-templ-0.2.793"
"store_path": "/nix/store/570l35c4n3qdxaszrf6bz4rrrw87pkil-matrix-synapse-wrapped-1.119.0"
}
}
},
"postgresql@latest": {
"last_modified": "2024-11-22T01:27:12Z",
"plugin_version": "0.0.2",
"resolved": "github:NixOS/nixpkgs/8edf06bea5bcbee082df1b7369ff973b91618b8d#postgresql",
"source": "devbox-search",
"version": "16.4",
"systems": {
"aarch64-darwin": {
"outputs": [
{
"name": "out",
"path": "/nix/store/j6n9b877yhrnkp9z9p1gllxpnfvdrbrb-postgresql-16.4",
"default": true
},
{
"name": "man",
"path": "/nix/store/465icqyw6m38jxpx5yr1ri26ki0f96sz-postgresql-16.4-man",
"default": true
},
{
"name": "lib",
"path": "/nix/store/l9w6d22hrcrxkv005g2gbzhvk64vp4rm-postgresql-16.4-lib"
},
{
"name": "dev",
"path": "/nix/store/jvw9nsblsbh9m4n551sq7qnw82hhsv08-postgresql-16.4-dev"
},
{
"name": "doc",
"path": "/nix/store/fk1x8k1qsiaasp73qnzyrzw4ylaf1xy6-postgresql-16.4-doc"
}
],
"store_path": "/nix/store/j6n9b877yhrnkp9z9p1gllxpnfvdrbrb-postgresql-16.4"
},
"aarch64-linux": {
"outputs": [
{
"name": "out",
"path": "/nix/store/2ywn472iqfdiyw5w4frm63rn3nyrkgn1-postgresql-16.4",
"default": true
},
{
"name": "man",
"path": "/nix/store/650fqsb195p9x00jgqgzkisjwddbvgfd-postgresql-16.4-man",
"default": true
},
{
"name": "debug",
"path": "/nix/store/wm34pd2y04mjgvhanqw4ymmhds56l9da-postgresql-16.4-debug"
},
{
"name": "dev",
"path": "/nix/store/ai2ckvi44jdh9i5078gj5brdwsxk4ydm-postgresql-16.4-dev"
},
{
"name": "doc",
"path": "/nix/store/qys6z2y4iwr0f6ahpq9gcv9hb551w479-postgresql-16.4-doc"
},
{
"name": "lib",
"path": "/nix/store/pii1vyxbzggi7aqy7xglav8p52c0qfp2-postgresql-16.4-lib"
}
],
"store_path": "/nix/store/2ywn472iqfdiyw5w4frm63rn3nyrkgn1-postgresql-16.4"
},
"x86_64-darwin": {
"outputs": [
{
"name": "out",
"path": "/nix/store/5k1p2jjnsdcsvk8zpsqxlzhajh1x9ghq-postgresql-16.4",
"default": true
},
{
"name": "man",
"path": "/nix/store/p8b24icm7xiwlky1dggqcinn1ah92agl-postgresql-16.4-man",
"default": true
},
{
"name": "dev",
"path": "/nix/store/cvl9wdw387jk02bbhm1qvidzl18hayyr-postgresql-16.4-dev"
},
{
"name": "doc",
"path": "/nix/store/ysmwxhh3s2l1k2jkzxq0bv6vdzlgr14j-postgresql-16.4-doc"
},
{
"name": "lib",
"path": "/nix/store/4va0gp1c718dk1zyqs0il2gn7a81spr0-postgresql-16.4-lib"
}
],
"store_path": "/nix/store/5k1p2jjnsdcsvk8zpsqxlzhajh1x9ghq-postgresql-16.4"
},
"x86_64-linux": {
"outputs": [
{
"name": "out",
"path": "/nix/store/ypx0whdqvwbql73nija0zrm4z3rgcm9l-postgresql-16.4",
"default": true
},
{
"name": "man",
"path": "/nix/store/7x75jfmpc7x36863cf6kr61ikcz787ki-postgresql-16.4-man",
"default": true
},
{
"name": "doc",
"path": "/nix/store/4c7h8sg2i0jim6hzmzhjw5nn0zmx1xvd-postgresql-16.4-doc"
},
{
"name": "lib",
"path": "/nix/store/xd8ks7bs2p7gjgk8h98bfg8801swl9m0-postgresql-16.4-lib"
},
{
"name": "debug",
"path": "/nix/store/pxhd0wq2sbafamjmcp7f890qza76gwav-postgresql-16.4-debug"
},
{
"name": "dev",
"path": "/nix/store/20i6jma3fbm4sw060hdnrs311fw4aczj-postgresql-16.4-dev"
}
],
"store_path": "/nix/store/ypx0whdqvwbql73nija0zrm4z3rgcm9l-postgresql-16.4"
}
}
},
"skate@latest": {
"last_modified": "2024-11-16T04:25:12Z",
"resolved": "github:NixOS/nixpkgs/34a626458d686f1b58139620a8b2793e9e123bba#skate",
"source": "devbox-search",
"version": "1.0.0",
"systems": {
"aarch64-darwin": {
"outputs": [
{
"name": "out",
"path": "/nix/store/q6yhpyfbqiabyic6ymx5rp2db62bnbvr-skate-1.0.0",
"default": true
}
],
"store_path": "/nix/store/q6yhpyfbqiabyic6ymx5rp2db62bnbvr-skate-1.0.0"
},
"aarch64-linux": {
"outputs": [
{
"name": "out",
"path": "/nix/store/q55dbgvc4xwvr2g02dks6j2j699qni2k-skate-1.0.0",
"default": true
}
],
"store_path": "/nix/store/q55dbgvc4xwvr2g02dks6j2j699qni2k-skate-1.0.0"
},
"x86_64-darwin": {
"outputs": [
{
"name": "out",
"path": "/nix/store/s1hy525y8ciya3nrns9kryy3jlcw8igv-skate-1.0.0",
"default": true
}
],
"store_path": "/nix/store/s1hy525y8ciya3nrns9kryy3jlcw8igv-skate-1.0.0"
},
"x86_64-linux": {
"outputs": [
{
"name": "out",
"path": "/nix/store/8s03iazymz77nv6pjxpz7wair0m646wv-skate-1.0.0",
"default": true
}
],
"store_path": "/nix/store/8s03iazymz77nv6pjxpz7wair0m646wv-skate-1.0.0"
}
}
},
"tigerbeetle@latest": {
"last_modified": "2024-11-16T04:25:12Z",
"resolved": "github:NixOS/nixpkgs/34a626458d686f1b58139620a8b2793e9e123bba#tigerbeetle",
"source": "devbox-search",
"version": "0.16.12",
"systems": {
"aarch64-darwin": {
"outputs": [
{
"name": "out",
"path": "/nix/store/mm3jzwf24p35afr55v7kl5a0h6962i6p-tigerbeetle-0.16.12",
"default": true
}
],
"store_path": "/nix/store/mm3jzwf24p35afr55v7kl5a0h6962i6p-tigerbeetle-0.16.12"
},
"aarch64-linux": {
"outputs": [
{
"name": "out",
"path": "/nix/store/4106973gg3crfxq0gwrgwn4hcx64mzyy-tigerbeetle-0.16.12",
"default": true
}
],
"store_path": "/nix/store/4106973gg3crfxq0gwrgwn4hcx64mzyy-tigerbeetle-0.16.12"
},
"x86_64-darwin": {
"outputs": [
{
"name": "out",
"path": "/nix/store/6lnwnr3mvdamm5lxjjqkaagw2pyqlq0a-tigerbeetle-0.16.12",
"default": true
}
],
"store_path": "/nix/store/6lnwnr3mvdamm5lxjjqkaagw2pyqlq0a-tigerbeetle-0.16.12"
},
"x86_64-linux": {
"outputs": [
{
"name": "out",
"path": "/nix/store/afrj2ph61xz0lh7f3d1g1d7v2rslbvny-tigerbeetle-0.16.12",
"default": true
}
],
"store_path": "/nix/store/afrj2ph61xz0lh7f3d1g1d7v2rslbvny-tigerbeetle-0.16.12"
}
}
}
+12 -2
View File
@@ -3,7 +3,7 @@ version: "0.6"
processes:
ipfs:
namespace: testnet
command: "devbox run start:ipfs"
command: "devbox run ipfs"
background: true
availability:
restart: never
@@ -12,8 +12,18 @@ processes:
sonr:
namespace: testnet
background: true
command: "devbox run start:testnet"
command: "devbox run sonr"
restart: never
max_restarts: 1
depends:
- ipfs
hway:
namespace: testnet
background: true
command: "devbox run hway"
restart: never
max_restarts: 1
depends:
- ipfs
- sonr
+85
View File
@@ -0,0 +1,85 @@
/*
This file defines the database schema for the PostgresQL ("psql") event sink
implementation in CometBFT. The operator must create a database and install
this schema before using the database to index events.
*/
-- The blocks table records metadata about each block.
-- The block record does not include its events or transactions (see tx_results).
CREATE TABLE blocks (
rowid BIGSERIAL PRIMARY KEY,
height BIGINT NOT NULL,
chain_id VARCHAR NOT NULL,
-- When this block header was logged into the sink, in UTC.
created_at TIMESTAMPTZ NOT NULL,
UNIQUE (height, chain_id)
);
-- Index blocks by height and chain, since we need to resolve block IDs when
-- indexing transaction records and transaction events.
CREATE INDEX idx_blocks_height_chain ON blocks(height, chain_id);
-- The tx_results table records metadata about transaction results. Note that
-- the events from a transaction are stored separately.
CREATE TABLE tx_results (
rowid BIGSERIAL PRIMARY KEY,
-- The block to which this transaction belongs.
block_id BIGINT NOT NULL REFERENCES blocks(rowid),
-- The sequential index of the transaction within the block.
index INTEGER NOT NULL,
-- When this result record was logged into the sink, in UTC.
created_at TIMESTAMPTZ NOT NULL,
-- The hex-encoded hash of the transaction.
tx_hash VARCHAR NOT NULL,
-- The protobuf wire encoding of the TxResult message.
tx_result BYTEA NOT NULL,
UNIQUE (block_id, index)
);
-- The events table records events. All events (both block and transaction) are
-- associated with a block ID; transaction events also have a transaction ID.
CREATE TABLE events (
rowid BIGSERIAL PRIMARY KEY,
-- The block and transaction this event belongs to.
-- If tx_id is NULL, this is a block event.
block_id BIGINT NOT NULL REFERENCES blocks(rowid),
tx_id BIGINT NULL REFERENCES tx_results(rowid),
-- The application-defined type label for the event.
type VARCHAR NOT NULL
);
-- The attributes table records event attributes.
CREATE TABLE attributes (
event_id BIGINT NOT NULL REFERENCES events(rowid),
key VARCHAR NOT NULL, -- bare key
composite_key VARCHAR NOT NULL, -- composed type.key
value VARCHAR NULL,
UNIQUE (event_id, key)
);
-- A joined view of events and their attributes. Events that do not have any
-- attributes are represented as a single row with empty key and value fields.
CREATE VIEW event_attributes AS
SELECT block_id, tx_id, type, key, composite_key, value
FROM events LEFT JOIN attributes ON (events.rowid = attributes.event_id);
-- A joined view of all block events (those having tx_id NULL).
CREATE VIEW block_events AS
SELECT blocks.rowid as block_id, height, chain_id, type, key, composite_key, value
FROM blocks JOIN event_attributes ON (blocks.rowid = event_attributes.block_id)
WHERE event_attributes.tx_id IS NULL;
-- A joined view of all transaction events.
CREATE VIEW tx_events AS
SELECT height, index, chain_id, type, key, composite_key, value, tx_results.created_at
FROM blocks JOIN tx_results ON (blocks.rowid = tx_results.block_id)
JOIN event_attributes ON (tx_results.rowid = event_attributes.tx_id)
WHERE event_attributes.tx_id IS NOT NULL;