diff --git a/assets/utils/check-synced.sh b/assets/utils/check-synced.sh index a884790..a71a58d 100644 --- a/assets/utils/check-synced.sh +++ b/assets/utils/check-synced.sh @@ -4,16 +4,10 @@ set -e sleep 15 -b_type=$(yq e '.bitcoind.type' /root/start9/config.yaml) -if [ "$b_type" = "internal" ]; then - b_host="bitcoind.embassy" - b_username=$(yq e '.bitcoind.user' /root/start9/config.yaml) - b_password=$(yq e '.bitcoind.password' /root/start9/config.yaml) -else - b_host="btc-rpc-proxy.embassy" - b_username=$(yq e '.bitcoind.user' /root/start9/config.yaml) - b_password=$(yq e '.bitcoind.password' /root/start9/config.yaml) -fi +b_host="bitcoind.embassy" +b_username=$(yq e '.bitcoin-user' /root/start9/config.yaml) +b_password=$(yq e '.bitcoin-password' /root/start9/config.yaml) + TXINDEX_CHECK=$(curl -sS --user $b_username:$b_password --data-binary '{"jsonrpc": "1.0", "id": "sync-hck", "method": "getindexinfo", "params": ["txindex"]}' -H 'content-type: text/plain;' $b_host:8332 | sed -n 's/.*\("synced":\).*/1/p') TXINDEX_SYNC=$(curl -sS --user $b_username:$b_password --data-binary '{"jsonrpc": "1.0", "id": "sync-hck", "method": "getindexinfo", "params": ["txindex"]}' -H 'content-type: text/plain;' $b_host:8332 | sed -n 's/.*\("synced":true\).*/1/p') IBD_STATE=$(curl -sS --user $b_username:$b_password --data-binary '{"jsonrpc": "1.0", "id": "sync-hck", "method": "getblockchaininfo", "params": []}' -H 'content-type: text/plain;' $b_host:8332 | sed -n 's/.*\("initialblockdownload":false\).*/1/p') diff --git a/docker_entrypoint.sh b/docker_entrypoint.sh index 82d6000..17df17a 100755 --- a/docker_entrypoint.sh +++ b/docker_entrypoint.sh @@ -27,19 +27,13 @@ cat /backend/nginx.conf > /etc/nginx/nginx.conf # BACKEND SETUP -# read bitcoin proxy creds from start9 config +# read bitcoin creds from start9 config HOST_IP=$(ip -4 route list match 0/0 | awk '{print $3}') bitcoind_type=$(yq e '.bitcoind.type' /root/start9/config.yaml) bitcoind_user=$(yq e '.bitcoind.user' /root/start9/config.yaml) bitcoind_pass=$(yq e '.bitcoind.password' /root/start9/config.yaml) +bitcoind_host="bitcoind.embassy" -if [ "$bitcoind_type" = "internal-proxy" ]; then - bitcoind_host="btc-rpc-proxy.embassy" - echo "Running on Bitcoin Proxy..." -else - bitcoind_host="bitcoind.embassy" - echo "Running on Bitcoin Core..." -fi sed -i "s/CORE_RPC_HOST:=127.0.0.1/CORE_RPC_HOST:=$bitcoind_host/" start.sh sed -i "s/CORE_RPC_USERNAME:=mempool/CORE_RPC_USERNAME:=$bitcoind_user/" start.sh sed -i "s/CORE_RPC_PASSWORD:=mempool/CORE_RPC_PASSWORD:=$bitcoind_pass/" start.sh diff --git a/instructions.md b/instructions.md index 178adea..ec5f14c 100644 --- a/instructions.md +++ b/instructions.md @@ -1,6 +1,7 @@ # Mempool.space Mempool is an open-source explorer developed for the Bitcoin community, focusing on the emerging transaction fee market to help our transition into a multi-layer ecosystem. + ## Configuration Mempool on the Start9 Server requires a fully synced archival Bitcoin Core node to function. diff --git a/manifest.yaml b/manifest.yaml index 4ed45b5..a294ad1 100644 --- a/manifest.yaml +++ b/manifest.yaml @@ -1,9 +1,9 @@ id: mempool title: Mempool -version: 2.5.0.1 +version: 2.5.0.2 release-notes: | - * Update Mempool to v2.5.0 [Release Notes](https://github.com/mempool/mempool/releases/tag/v2.5.0) - * Note: After upgrading the blocks database table will be cleared and reindexed + * Removes deprecated optional dependency of BTC RPC Proxy + * Uses Bitcoin Core as direct dependency license: AGPL wrapper-repo: "https://github.com/Start9Labs/mempool-wrapper" upstream-repo: "https://github.com/mempool/mempool" @@ -65,27 +65,15 @@ properties: type: script dependencies: bitcoind: - version: ">=0.21.1.2 <26.0.0" + version: ">=0.21.1.2 <27.0.0" requirement: - type: "opt-out" - how: Can alternatively configure proxy or bitcoin core node. + type: "required" description: Used to subscribe to new block events from a full archival node config: check: type: script auto-configure: type: script - btc-rpc-proxy: - version: ">=0.3.2.5 <0.4.0" - requirement: - type: "opt-in" - how: Can alternatively configure proxy or bitcoin core node. - description: Used for RPC permissioning. - config: - check: - type: script - auto-configure: - type: script electrs: version: ">=0.9.6 <0.10.0" requirement: diff --git a/scripts/services/dependencies.ts b/scripts/services/dependencies.ts index 13f8b65..eee79fb 100644 --- a/scripts/services/dependencies.ts +++ b/scripts/services/dependencies.ts @@ -1,6 +1,6 @@ import { matches, types as T } from "../deps.ts"; -const { shape, arrayOf, string, boolean } = matches; +const { shape, string, boolean } = matches; const matchBitcoindConfig = shape({ advanced: shape({ @@ -14,110 +14,6 @@ const matchBitcoindConfig = shape({ txindex: boolean, }); -const matchProxyConfig = shape({ - users: arrayOf( - shape( - { - name: string, - "allowed-calls": arrayOf(string), - password: string, - }, - ), - ), -}); -type ProxyChecks = typeof matchProxyConfig._TYPE; - -function times(fn: (i: number) => T, amount: number): T[] { - const answer = new Array(amount); - for (let i = 0; i < amount; i++) { - answer[i] = fn(i); - } - return answer; -} - -function randomItemString(input: string) { - return input[Math.floor(Math.random() * input.length)]; -} - -const serviceName = "mempool"; -const fullChars = - "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; -type Check = { - currentError(config: T.Config): string | void; - fix(config: T.Config): T.Config; -}; - -const proxyChecks: Array = [ - { - currentError(config) { - if (!matchProxyConfig.test(config)) { - return "Config is not the correct shape"; - } - if (config.users.some((x) => x.name === serviceName)) { - return; - } - return `Must have an RPC user named "${serviceName}"`; - }, - fix(config) { - if (!matchProxyConfig.test(config)) { - throw new Error("Config is not the correct shape"); - } - config.users.push({ - name: serviceName, - "allowed-calls": [], - password: times(() => randomItemString(fullChars), 22).join(""), - }); - return config; - }, - }, - ...[ - "echo", - "getindexinfo", - "getblockcount", - "getchaintips", - "getmempoolinfo", - "getblockchaininfo", - "getblockhash", - "getblock", - "getblockheader", - "getmempoolentry", - "getrawtransaction", - "decoderawtransaction", - "getrawmempool", - "gettxout", - "validateaddress", - "getblockstats", - "getnetworkhashps", - "getdifficulty", - ].map( - (operator): Check => ({ - currentError(config) { - if (!matchProxyConfig.test(config)) { - return "Config is not the correct shape"; - } - if ( - config.users.find((x) => x.name === serviceName)?.["allowed-calls"] - ?.some((x) => x === operator) ?? false - ) { - return; - } - return `RPC user "mempool" must have "${operator}" enabled`; - }, - fix(config) { - if (!matchProxyConfig.test(config)) { - throw new Error("Config is not the correct shape"); - } - const found = config.users.find((x) => x.name === serviceName); - if (!found) { - throw new Error("Users for mempool should exist"); - } - found["allowed-calls"] = [...(found["allowed-calls"] ?? []), operator]; - return config; - }, - }), - ), -]; - export const dependencies: T.ExpectedExports.dependencies = { bitcoind: { // deno-lint-ignore require-await @@ -133,7 +29,7 @@ export const dependencies: T.ExpectedExports.dependencies = { if (config.advanced.pruning.mode == "enabled") { return { error: - "Pruning must be disabled to use Bitcoin Core directly. To use with a pruned node, set Bitcoin Core to Bitcoin Proxy instead.", + "Pruning must be disabled to use Bitcoin Core.", }; } return { result: null }; @@ -147,30 +43,5 @@ export const dependencies: T.ExpectedExports.dependencies = { config.advanced.pruning.mode = "disabled"; return { result: config }; }, - }, - "btc-rpc-proxy": { - // deno-lint-ignore require-await - async check(effects, configInput) { - effects.info("check btc-rpc-proxy"); - for (const checker of proxyChecks) { - const error = checker.currentError(configInput); - if (error) { - effects.error(`throwing error: ${error}`); - return { error }; - } - } - return { result: null }; - }, - // deno-lint-ignore require-await - async autoConfigure(effects, configInput) { - effects.info("autoconfigure btc-rpc-proxy"); - for (const checker of proxyChecks) { - const error = checker.currentError(configInput); - if (error) { - configInput = checker.fix(configInput); - } - } - return { result: configInput }; - }, - }, + } }; diff --git a/scripts/services/getConfig.ts b/scripts/services/getConfig.ts index 60c3e21..ed6589a 100644 --- a/scripts/services/getConfig.ts +++ b/scripts/services/getConfig.ts @@ -10,78 +10,25 @@ export const getConfig: T.ExpectedExports.getConfig = compat.getConfig({ "target": "tor-address", "interface": "main", }, - "bitcoind": { - "type": "union", - "name": "Bitcoin Core", - "description": - "The Bitcoin Core node to connect to", - "tag": { - "id": "type", - "name": "Type", - "variant-names": { - "internal": "Bitcoin Core", - "internal-proxy": "Bitcoin Proxy", - }, - "description": - "The Bitcoin Core node to connect to", - }, - "default": "internal", - "variants": { - "internal": { - "user": { - "type": "pointer", - "name": "RPC Username", - "description": "The username for Bitcoin Core's RPC interface", - "subtype": "package", - "package-id": "bitcoind", - "target": "config", - "multi": false, - "selector": "$.rpc.username", - }, - "password": { - "type": "pointer", - "name": "RPC Password", - "description": "The password for Bitcoin Core's RPC interface", - "subtype": "package", - "package-id": "bitcoind", - "target": "config", - "multi": false, - "selector": "$.rpc.password", - }, - }, - "internal-proxy": { - "user": { - "type": "pointer", - "name": "RPC Username", - "description": "The username for the RPC user allocated to electrs", - "subtype": "package", - "package-id": "btc-rpc-proxy", - "target": "config", - "multi": false, - "selector": '$.users[?(@.name == "mempool")].name', - }, - "password": { - "type": "pointer", - "name": "RPC Password", - "description": "The password for the RPC user allocated to electrs", - "subtype": "package", - "package-id": "btc-rpc-proxy", - "target": "config", - "multi": false, - "selector": '$.users[?(@.name == "mempool")].password', - }, - "txindex": { - "name": "Transaction Indexer", - "description": "The Transaction Indexer for Bitcoin Core", - "type": "pointer", - "subtype": "package", - "package-id": "bitcoind", - "target": "config", - "multi": false, - "selector": "$.txindex", - }, - }, + "bitcoin-user": { + "type": "pointer", + "name": "RPC Username", + "description": "The username for Bitcoin Core's RPC interface", + "subtype": "package", + "package-id": "bitcoind", + "target": "config", + "multi": false, + "selector": "$.rpc.username", }, + "bitcoin-password": { + "type": "pointer", + "name": "RPC Password", + "description": "The password for Bitcoin Core's RPC interface", + "subtype": "package", + "package-id": "bitcoind", + "target": "config", + "multi": false, + "selector": "$.rpc.password", }, "lightning": { "type": "union", diff --git a/scripts/services/migrations.ts b/scripts/services/migrations.ts index 5db36b4..c1b3883 100644 --- a/scripts/services/migrations.ts +++ b/scripts/services/migrations.ts @@ -28,7 +28,6 @@ export const migration: T.ExpectedExports.migration = async (effects, version) = return result } - return { result: { configured: true } } } \ No newline at end of file diff --git a/scripts/services/setConfig.ts b/scripts/services/setConfig.ts index b80a45b..d76903b 100644 --- a/scripts/services/setConfig.ts +++ b/scripts/services/setConfig.ts @@ -16,17 +16,13 @@ export const setConfig: T.ExpectedExports.setConfig = async ( ] ? { electrs: ["synced"] } : {}; - const dependsOnBitcoind: { [key: string]: string[] } = newConfig?.txindex - ? { bitcoind: [] } - : {}; - // add two const depsLnd and depsCln for the new lightning type string in getConfig + // add two const depsLnd and depsCln for the new lightning type string in getConfig const depsLnd: { [key: string]: string[] } = newConfig?.lightning?.type === "lnd" ? {lnd: []} : {}; const depsCln: { [key: string]: string[] } = newConfig?.lightning?.type === "cln" ? {"c-lightning": []} : {}; return compat.setConfig(effects, newConfig, { ...dependsOnElectrs, - ...dependsOnBitcoind, ...depsLnd, ...depsCln, });