mirror of
https://github.com/sonr-io/sonr.git
synced 2026-08-02 17:31:39 +00:00
Fix/hway db driver (#1198)
* fix/hway-db-driver * fix/hway-db-driver * chore(scripts): add tx indexer and psql connection to test * fix(scripts): make testnet setup more robust and configurable
This commit is contained in:
@@ -1,202 +0,0 @@
|
||||
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 {}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,76 @@
|
||||
amends "https://pkl.sh/sonr.chain/0.0.2/App.pkl"
|
||||
import "package://pkg.pkl-lang.org/pkl-pantry/pkl.toml@1.0.0#/toml.pkl"
|
||||
|
||||
`minimum-gas-prices` = "0usnr"
|
||||
`query-gas-limit` = "0"
|
||||
pruning = "default"
|
||||
`pruning-keep-recent` = "0"
|
||||
`pruning-interval` = "0"
|
||||
`halt-height` = 0
|
||||
`halt-time` = 0
|
||||
`min-retain-blocks` = 0
|
||||
`inter-block-cache` = true
|
||||
`index-events` = new Listing {}
|
||||
`iavl-cache-size` = 781250
|
||||
`iavl-disable-fastnode` = false
|
||||
`app-db-backend` = ""
|
||||
|
||||
telemetry = new {
|
||||
`service-name` = ""
|
||||
enabled = true
|
||||
`enable-hostname` = true
|
||||
`enable-hostname-label` = false
|
||||
`enable-service-label` = false
|
||||
`prometheus-retention-time` = 60
|
||||
`global-labels` = new Listing {
|
||||
new Listing {
|
||||
"chain_id"
|
||||
"sonr-testnet-1"
|
||||
}
|
||||
}
|
||||
`metrics-sink` = ""
|
||||
`statsd-addr` = ""
|
||||
`datadog-hostname` = ""
|
||||
}
|
||||
|
||||
api = new {
|
||||
enable = true
|
||||
swagger = false
|
||||
address = "tcp://0.0.0.0:1317"
|
||||
`max-open-connections` = 1000
|
||||
`rpc-read-timeout` = 10
|
||||
`rpc-write-timeout` = 0
|
||||
`rpc-max-body-bytes` = 1000000
|
||||
`enabled-unsafe-cors` = false
|
||||
}
|
||||
|
||||
grpc = new {
|
||||
enable = true
|
||||
address = "0.0.0.0:9090"
|
||||
`max-recv-msg-size` = "10485760"
|
||||
`max-send-msg-size` = "2147483647"
|
||||
}
|
||||
|
||||
`grpc-web` = new {
|
||||
enable = true
|
||||
}
|
||||
|
||||
`state-sync` = new {
|
||||
`snapshot-interval` = 0
|
||||
`snapshot-keep-recent` = 2
|
||||
}
|
||||
|
||||
streaming = new {
|
||||
abci = new {
|
||||
keys = new Listing {}
|
||||
plugin = ""
|
||||
`stop-node-on-err` = true
|
||||
}
|
||||
}
|
||||
|
||||
mempool = new {
|
||||
`max-txs` = 5000
|
||||
}
|
||||
|
||||
output {
|
||||
renderer = new toml.Renderer {}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,143 @@
|
||||
amends "https://pkl.sh/sonr.chain/0.0.2/Genesis.pkl"
|
||||
import "package://pkg.pkl-lang.org/pkl-pantry/pkl.toml@1.0.0#/toml.pkl"
|
||||
|
||||
version = "0.38.12"
|
||||
|
||||
proxy_app = "tcp://127.0.0.1:26658"
|
||||
moniker = read("env:MONIKER") ?? "florence"
|
||||
db_backend = "goleveldb"
|
||||
db_dir = "data"
|
||||
log_level = "info"
|
||||
log_format = "plain"
|
||||
|
||||
genesis_file = "config/genesis.json"
|
||||
priv_validator_key_file = "config/priv_validator_key.json"
|
||||
priv_validator_state_file = "data/priv_validator_state.json"
|
||||
priv_validator_laddr = ""
|
||||
node_key_file = "config/node_key.json"
|
||||
abci = "socket"
|
||||
filter_peers = false
|
||||
|
||||
rpc = new {
|
||||
laddr = "tcp://0.0.0.0:26657"
|
||||
cors_allowed_origins = new Listing {}
|
||||
cors_allowed_methods = new Listing {
|
||||
"HEAD"
|
||||
"GET"
|
||||
"POST"
|
||||
}
|
||||
cors_allowed_headers = new Listing {
|
||||
"Origin"
|
||||
"Accept"
|
||||
"Content-Type"
|
||||
"X-Requested-With"
|
||||
"X-Server-Time"
|
||||
}
|
||||
grpc_laddr = ""
|
||||
grpc_max_open_connections = 900
|
||||
unsafe = false
|
||||
max_open_connections = 900
|
||||
max_subscription_clients = 100
|
||||
max_subscriptions_per_client = 5
|
||||
experimental_subscription_buffer_size = 200
|
||||
experimental_websocket_write_buffer_size = 200
|
||||
experimental_close_on_slow_client = false
|
||||
timeout_broadcast_tx_commit = "10s"
|
||||
max_request_batch_size = 10
|
||||
max_body_bytes = 1000000
|
||||
max_header_bytes = 1048576
|
||||
tls_cert_file = ""
|
||||
tls_key_file = ""
|
||||
pprof_laddr = "localhost:6060"
|
||||
}
|
||||
|
||||
p2p = new {
|
||||
laddr = "tcp://0.0.0.0:26656"
|
||||
external_address = ""
|
||||
seeds = ""
|
||||
persistent_peers = ""
|
||||
addr_book_file = "config/addrbook.json"
|
||||
addr_book_strict = true
|
||||
max_num_inbound_peers = 40
|
||||
max_num_outbound_peers = 10
|
||||
unconditional_peer_ids = ""
|
||||
persistent_peers_max_dial_period = "0s"
|
||||
flush_throttle_timeout = "100ms"
|
||||
max_packet_msg_payload_size = 1024
|
||||
send_rate = 5120000
|
||||
recv_rate = 5120000
|
||||
pex = true
|
||||
seed_mode = false
|
||||
private_peer_ids = ""
|
||||
allow_duplicate_ip = false
|
||||
handshake_timeout = "20s"
|
||||
dial_timeout = "3s"
|
||||
}
|
||||
|
||||
mempool = new {
|
||||
type = "flood"
|
||||
recheck = true
|
||||
recheck_timeout = "1s"
|
||||
broadcast = true
|
||||
wal_dir = ""
|
||||
size = 5000
|
||||
max_txs_bytes = 1073741824
|
||||
cache_size = 10000
|
||||
`keep-invalid-txs-in-cache` = false
|
||||
max_tx_bytes = 1048576
|
||||
max_batch_bytes = 0
|
||||
experimental_max_gossip_connections_to_persistent_peers = 0
|
||||
experimental_max_gossip_connections_to_non_persistent_peers = 0
|
||||
}
|
||||
|
||||
statesync = new {
|
||||
enable = false
|
||||
rpc_servers = ""
|
||||
trust_height = 0
|
||||
trust_hash = ""
|
||||
trust_period = "168h0m0s"
|
||||
discovery_time = "15s"
|
||||
temp_dir = ""
|
||||
chunk_request_timeout = "10s"
|
||||
chunk_fetchers = "4"
|
||||
}
|
||||
|
||||
blocksync = new {
|
||||
version = "v0"
|
||||
}
|
||||
|
||||
consensus = new {
|
||||
wal_file = "data/cs.wal/wal"
|
||||
timeout_propose = "3s"
|
||||
timeout_propose_delta = "500ms"
|
||||
timeout_prevote = "1s"
|
||||
timeout_prevote_delta = "500ms"
|
||||
timeout_precommit = "1s"
|
||||
timeout_precommit_delta = "500ms"
|
||||
timeout_commit = "5000ms"
|
||||
double_sign_check_height = 0
|
||||
skip_timeout_commit = false
|
||||
create_empty_blocks = true
|
||||
create_empty_blocks_interval = "0s"
|
||||
peer_gossip_sleep_duration = "100ms"
|
||||
peer_query_maj23_sleep_duration = "2s"
|
||||
}
|
||||
|
||||
storage = new {
|
||||
discard_abci_responses = false
|
||||
}
|
||||
|
||||
tx_index = new {
|
||||
indexer = read("env:TX_INDEX_INDEXER") ?? "kv"
|
||||
`psql-conn` = read("env:TX_INDEX_PSQL_CONN") ?? ""
|
||||
}
|
||||
|
||||
instrumentation = new {
|
||||
prometheus = false
|
||||
prometheus_listen_addr = ":26660"
|
||||
max_open_connections = 3
|
||||
namespace = "cometbft"
|
||||
}
|
||||
|
||||
output {
|
||||
renderer = new toml.Renderer {}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,11 @@ version: "0.6"
|
||||
|
||||
processes:
|
||||
sonr:
|
||||
namespace: devnet
|
||||
command: "make sh-testnet"
|
||||
namespace: testnet
|
||||
command: "make dop-testnet"
|
||||
|
||||
hway:
|
||||
namespace: devnet
|
||||
namespace: testnet
|
||||
command: "./build/hway"
|
||||
depends:
|
||||
- sonr
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
-- Connect to a different database first (postgres) since we can't drop a database while connected to it
|
||||
\c postgres;
|
||||
|
||||
-- Terminate all connections to the databases
|
||||
SELECT pg_terminate_backend(pid)
|
||||
FROM pg_stat_activity
|
||||
WHERE datname IN ('chainindex', 'highway', 'matrixhs')
|
||||
AND pid <> pg_backend_pid();
|
||||
|
||||
-- Drop the databases if they exist
|
||||
DROP DATABASE IF EXISTS chainindex;
|
||||
DROP DATABASE IF EXISTS highway;
|
||||
DROP DATABASE IF EXISTS matrixhs;
|
||||
|
||||
-- Drop the users if they exist
|
||||
DROP USER IF EXISTS chainindex_user;
|
||||
DROP USER IF EXISTS highway_user;
|
||||
DROP USER IF EXISTS matrixhs_user;
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
-- Switch to postgres database first
|
||||
\c postgres;
|
||||
|
||||
-- Terminate existing connections
|
||||
SELECT pg_terminate_backend(pid)
|
||||
FROM pg_stat_activity
|
||||
WHERE datname = 'chainindex'
|
||||
AND pid <> pg_backend_pid();
|
||||
|
||||
-- Drop and recreate database and user
|
||||
DROP DATABASE IF EXISTS chainindex;
|
||||
DROP USER IF EXISTS chainindex_user;
|
||||
|
||||
CREATE USER chainindex_user WITH PASSWORD 'chainindex_password123';
|
||||
CREATE DATABASE chainindex;
|
||||
|
||||
-- Connect to the new database
|
||||
\c chainindex;
|
||||
|
||||
-- Create the blocks table
|
||||
CREATE TABLE blocks (
|
||||
rowid BIGSERIAL PRIMARY KEY,
|
||||
height BIGINT NOT NULL,
|
||||
chain_id VARCHAR NOT NULL,
|
||||
created_at TIMESTAMPTZ NOT NULL,
|
||||
UNIQUE (height, chain_id)
|
||||
);
|
||||
|
||||
CREATE INDEX idx_blocks_height_chain ON blocks(height, chain_id);
|
||||
|
||||
CREATE TABLE tx_results (
|
||||
rowid BIGSERIAL PRIMARY KEY,
|
||||
block_id BIGINT NOT NULL REFERENCES blocks(rowid),
|
||||
index INTEGER NOT NULL,
|
||||
created_at TIMESTAMPTZ NOT NULL,
|
||||
tx_hash VARCHAR NOT NULL,
|
||||
tx_result BYTEA NOT NULL,
|
||||
UNIQUE (block_id, index)
|
||||
);
|
||||
|
||||
CREATE TABLE events (
|
||||
rowid BIGSERIAL PRIMARY KEY,
|
||||
block_id BIGINT NOT NULL REFERENCES blocks(rowid),
|
||||
tx_id BIGINT NULL REFERENCES tx_results(rowid),
|
||||
type VARCHAR NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE attributes (
|
||||
event_id BIGINT NOT NULL REFERENCES events(rowid),
|
||||
key VARCHAR NOT NULL,
|
||||
composite_key VARCHAR NOT NULL,
|
||||
value VARCHAR NULL,
|
||||
UNIQUE (event_id, key)
|
||||
);
|
||||
|
||||
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);
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
-- Grant all necessary privileges
|
||||
GRANT ALL PRIVILEGES ON DATABASE chainindex TO chainindex_user;
|
||||
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO chainindex_user;
|
||||
GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO chainindex_user;
|
||||
GRANT ALL PRIVILEGES ON ALL FUNCTIONS IN SCHEMA public TO chainindex_user;
|
||||
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL PRIVILEGES ON TABLES TO chainindex_user;
|
||||
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL PRIVILEGES ON SEQUENCES TO chainindex_user;
|
||||
|
||||
Reference in New Issue
Block a user