From 4e6af47a71f683d60b3068d0e0178f7d8db20ab5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Le=CC=81o=20Haf?= Date: Thu, 22 Aug 2024 21:48:08 +0200 Subject: [PATCH 1/2] full policy customisation --- .github/workflows/buildService.yml | 4 +- assets/compat/bitcoin.conf.template | 56 ++++++-- scripts/services/getConfig.ts | 199 +++++++++++++++++++++++----- 3 files changed, 213 insertions(+), 46 deletions(-) diff --git a/.github/workflows/buildService.yml b/.github/workflows/buildService.yml index 6c7db34..cf6b9f8 100644 --- a/.github/workflows/buildService.yml +++ b/.github/workflows/buildService.yml @@ -4,10 +4,10 @@ on: workflow_dispatch: pull_request: paths-ignore: ['*.md'] - branches: ['main', 'master', 'knots', 'knots-for-community'] + branches: ['main', 'master', 'knots', 'knots-for-community', 'new-config'] push: paths-ignore: ['*.md'] - branches: ['main', 'master', 'knots', 'knots-for-community'] + branches: ['main', 'master', 'knots', 'knots-for-community', 'new-config'] jobs: BuildPackage: diff --git a/assets/compat/bitcoin.conf.template b/assets/compat/bitcoin.conf.template index 8df05da..0e21c21 100644 --- a/assets/compat/bitcoin.conf.template +++ b/assets/compat/bitcoin.conf.template @@ -121,36 +121,36 @@ txindex=1 }} ## DATACARRIER -{{#IF datacarrier +{{#IF blkconstr.datacarrier datacarrier=1 }} -{{#IF !datacarrier +{{#IF !blkconstr.datacarrier datacarrier=0 }} -datacarriersize={{datacarriersize}} +datacarriersize={{blkconstr.datacarriersize}} ## PERMITBAREMULTISIG -{{#IF permitbaremultisig +{{#IF blkconstr.permitbaremultisig permitbaremultisig=1 }} -{{#IF !permitbaremultisig +{{#IF !blkconstr.permitbaremultisig permitbaremultisig=0 }} ## REJECTPARASITES -{{#IF rejectparasites +{{#IF blkconstr.rejectparasites rejectparasites=1 }} -{{#IF !rejectparasites +{{#IF !blkconstr.rejectparasites rejectparasites=0 }} ## REJECTTOKENS -{{#IF rejecttokens +{{#IF blkconstr.rejecttokens rejecttokens=1 }} -{{#IF !rejecttokens +{{#IF !blkconstr.rejecttokens rejecttokens=0 }} @@ -166,3 +166,41 @@ blockfilterindex=basic {{#IF advanced.blockfilters.peerblockfilters peerblockfilters=1 }} + +## BLKCONSTR + +minrelaytxfee={{blkconstr.minrelaytxfee}} + +bytespersigop={{blkconstr.bytespersigop}} + +bytespersigopstrict={{blkconstr.bytespersigopstrict}} + +limitancestorcount={{blkconstr.limitancestorcount}} + +limitancestorsize={{blkconstr.limitancestorsize}} + +limitdescendantcount={{blkconstr.limitdescendantcount}} + +limitdescendantsize={{blkconstr.limitdescendantsize}} + +maxscriptsize={{blkconstr.maxscriptsize}} + +datacarriercost={{blkconstr.datacarriercost}} + +dustrelayfee={{blkconstr.dustrelayfee}} + +## BAREPUBKEY +{{#IF blkconstr.permitbarepubkey +permitbarepubkey=1 +}} +{{#IF !blkconstr.permitbarepubkey +permitbarepubkey=0 +}} + +## ACCEPTNONSTDDATACARRIER +{{#IF blkconstr.acceptnonstddatacarrier +acceptnonstddatacarrier=1 +}} +{{#IF !blkconstr.acceptnonstddatacarrier +acceptnonstddatacarrier=0 +}} \ No newline at end of file diff --git a/scripts/services/getConfig.ts b/scripts/services/getConfig.ts index bd7e9fb..f89ce9a 100644 --- a/scripts/services/getConfig.ts +++ b/scripts/services/getConfig.ts @@ -22,6 +22,170 @@ export const getConfig: T.ExpectedExports.getConfig = async (effects) => { target: "tor-address", interface: "rpc", }, + blkconstr: { + type: "object", + name: "Template Construction", + description: "Options about standard policies and mining block templates", + spec: { + datacarrier: { + type: "boolean", + name: "Datacarrier", + description: "Relay and mine data carrier transactions", + default: true, + }, + datacarriersize: { + type: "number", + nullable: false, + name: "Datacarrier Size", + description: + "Maximum size of arbitrary data to relay and mine", + range: "[0,10000]", + integral: true, + units: "bytes", + default: 42, + }, + permitbaremultisig: { + type: "boolean", + name: "Permit Bare Multisig", + description: "Relay non-P2SH multisig", + default: false, + }, + rejectparasites: { + type: "boolean", + name: "Reject Parasites", + description: "Reject parasite transactions", + default: true, + }, + rejecttokens: { + type: "boolean", + name: "Reject Tokens", + description: "Reject tokens transactions (runes)", + default: false, + }, + minrelaytxfee: { + type: "number", + nullable: false, + name: "Min Transaction Relay Fee", + description: + "Fee rates (in BTC/kB) smaller than this are considered zero fee for relaying, mining and transaction creation", + range: "[0,21000000]", + integral: true, + units: "BTC/kvB", + default: 1000, + }, + bytespersigop: { + type: "number", + nullable: false, + name: "Bytes Per Sigop", + description: + "Equivalent bytes per sigop in transactions for relay and mining", + range: "[0,*)", + integral: true, + units: "bytes", + default: 20, + }, + bytespersigopstrict: { + type: "number", + nullable: false, + name: "Bytes Per Sigop Strict", + description: + "Minimum bytes per sigop in transactions we relay and mine", + range: "[0,*)", + integral: true, + units: "bytes", + default: 20, + }, + limitancestorcount: { + type: "number", + nullable: false, + name: "Max Ancestor Count", + description: + "Do not accept transactions if number of in-mempool ancestors is or more", + range: "[0,*)", + integral: true, + units: undefined, + default: 25, + }, + limitancestorsize: { + type: "number", + nullable: false, + name: "Max Ancestor Size", + description: + "Do not accept transactions whose size with all in-mempool ancestors exceeds kilobytes", + range: "[0,*)", + integral: true, + units: "kB", + default: 101, + }, + limitdescendantcount: { + type: "number", + nullable: false, + name: "Max descendants count", + description: + "Do not accept transactions if any ancestor would have or more in-mempool descendants", + range: "[0,*)", + integral: true, + units: undefined, + default: 25, + }, + limitdescendantsize: { + type: "number", + nullable: false, + name: "Max descendants size", + description: + "Do not accept transactions if any ancestor would have more than kilobytes of in-mempool descendants", + range: "[0,*)", + integral: true, + units: "kB", + default: 101, + }, + permitbarepubkey: { + type: "boolean", + name: "Permit Bare Pubkey", + description: "Relay legacy pubkey outputs", + default: false, + }, + maxscriptsize: { + type: "number", + nullable: false, + name: "Max Script Size", + description: + "Maximum size of scripts we relay and mine, in bytes", + range: "[0,*)", + integral: true, + units: "Bytes", + default: 1650, + }, + datacarriercost: { + type: "number", + nullable: false, + name: "Datacarrier cost", + description: + "Treat extra data in transactions as at least N vbytes per actual byte", + range: "[0,*)", + integral: true, + units: undefined, + default: 1, + }, + acceptnonstddatacarrier: { + type: "boolean", + name: "Accept non standard datacarrier", + description: "Relay and mine non-OP_RETURN datacarrier injection", + default: false, + }, + dustrelayfee: { + type: "number", + nullable: false, + name: "Dust Relay Fee", + description: + "Fee rate (in BTC/kvB) used to define dust, the value of an output such that it will cost more than its value in fees at this fee rate to spend it.", + range: "[0,*)", + integral: true, + units: "BTC/kvB", + default: 3000, + }, + } + }, rpc: { type: "object", name: "RPC Settings", @@ -124,41 +288,6 @@ export const getConfig: T.ExpectedExports.getConfig = async (effects) => { description: "Enable the ZeroMQ interface", default: true, }, - datacarrier: { - type: "boolean", - name: "Datacarrier", - description: "Relay and mine data carrier transactions", - default: true, - }, - datacarriersize: { - type: "number", - nullable: false, - name: "Datacarrier size", - description: - "Maximum size of arbitrary data to relay and mine.", - range: "[0,10000]", - integral: true, - units: "bytes", - default: 42, - }, - permitbaremultisig: { - type: "boolean", - name: "Permitbaremultisig", - description: "Relay non-P2SH multisig", - default: false, - }, - rejectparasites: { - type: "boolean", - name: "Reject Parasites", - description: "Reject parasites transactions", - default: true, - }, - rejecttokens: { - type: "boolean", - name: "Reject Tokens", - description: "Reject tokens transactions (runes)", - default: false, - }, txindex: { type: "boolean", name: "Transaction Index", From e461179472ff542d1c8158f8367b0e71eb0a0894 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Le=CC=81o=20Haf?= Date: Tue, 27 Aug 2024 20:26:42 +0200 Subject: [PATCH 2/2] add `testnet` support --- assets/compat/bitcoin.conf.template | 10 ++++++++++ scripts/services/getConfig.ts | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/assets/compat/bitcoin.conf.template b/assets/compat/bitcoin.conf.template index 0e21c21..98ab9a3 100644 --- a/assets/compat/bitcoin.conf.template +++ b/assets/compat/bitcoin.conf.template @@ -5,14 +5,18 @@ ## RPC {{#IF rpc.enable {{#IF advanced.pruning.mode = "automatic" +{{#IF !advanced.testnet rpcbind=127.0.0.1:18332 rpcallowip=127.0.0.1/32 }} +}} {{#IF advanced.pruning.mode != "automatic" +{{#IF !advanced.testnet rpcbind=0.0.0.0:8332 rpcallowip=0.0.0.0/0 }} }} +}} rpcuser={{rpc.username}} rpcpassword={{rpc.password}} {{#FOREACH rpc.advanced.auth @@ -41,8 +45,10 @@ mempoolexpiry={{advanced.mempool.mempoolexpiry}} ## PEERS {{#IF advanced.peers.listen listen=1 +{{#IF !advanced.testnet bind=0.0.0.0:8333 }} +}} {{#IF !advanced.peers.listen listen=0 }} @@ -203,4 +209,8 @@ acceptnonstddatacarrier=1 }} {{#IF !blkconstr.acceptnonstddatacarrier acceptnonstddatacarrier=0 +}} + +{{#IF advanced.testnet +testnet=1 }} \ No newline at end of file diff --git a/scripts/services/getConfig.ts b/scripts/services/getConfig.ts index f89ce9a..3be9ac0 100644 --- a/scripts/services/getConfig.ts +++ b/scripts/services/getConfig.ts @@ -518,6 +518,12 @@ export const getConfig: T.ExpectedExports.getConfig = async (effects) => { }, }, }, + testnet: { + type: "boolean", + name: "Testnet (EXPERIMENTAL)", + description: "Use testnet instead of mainnet", + default: false, + }, }, }, })(effects);