Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BIP-325: Signet [consensus] #18267

Merged
merged 10 commits into from
Sep 21, 2020
Merged

Conversation

kallewoof
Copy link
Contributor

@kallewoof kallewoof commented Mar 5, 2020

This PR is a part of BIP-325 (https://github.com/bitcoin/bips/blob/master/bip-0325.mediawiki), and is a sub-PR of #16411.

  • Signet consensus (this)
  • Signet RPC tools (pending)
  • Signet utility scripts (contrib/signet) (pending)

@DrahtBot
Copy link
Contributor

DrahtBot commented Mar 5, 2020

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@practicalswift
Copy link
Contributor

Concept ACK

@kallewoof
Copy link
Contributor Author

I have no idea why feature_pruning is failing in that one test in Travis. It works on my mac and linux machines.

@jonatack
Copy link
Member

I have no idea why feature_pruning is failing in that one test in Travis. It works on my mac and linux machines.

I think the CI job failure Method not found (wallet method is disabled because no wallet is loaded) (-32601) is from #15454 merged yesterday.

@jonatack
Copy link
Member

jonatack commented Sep 18, 2020

re-ACK 8258c4c per git diff dbeea65 8258c4c, only change since last review is updated -signet* config option naming.

Updated config options and help:

((HEAD detached from origin/pr/18267))$ ./src/bitcoind -signet -help | grep -A2 signet
  -signet
       Use the signet chain. Note that the network is defined by the
       -signetchallenge parameter

  -signetchallenge
       Blocks must satisfy the given script to be considered valid (only for
       signet networks; defaults to the global default signet test
       network challenge)

  -signetseednode
       Specify a seed node for the signet network, in the hostname[:port]
       format, e.g. sig.net:1234 (may be used multiple times to specify
       multiple seed nodes; defaults to the global default signet test
       network seed node(s))
some manual CLI testing

$ ./src/bitcoin-cli -datadir=src/signet -netinfo 4
Bitcoin Core v0.20.99.0-178345497c - 70016/Satoshi:0.20.99/

Peer connections sorted by direction and min ping
<-> relay   net mping   ping send recv  txn  blk uptime id address                      version
out  full onion   477    477   40   40         5      6  0 vpytsykcl4w4dr2x.onion:38333 70016/Satoshi:0.20.99/
                   ms     ms  sec  sec  min  min    min

        ipv4    ipv6   onion   total  block-relay
in         0       0       0       0       0
out        0       0       1       1       0
total      0       0       1       1       0

Local addresses
nhvodudwrn5pka7l.onion                    port 38333     score      4
ugv7httwbjaayfuj.onion                    port 38333     score      4

$ ./src/bitcoin-cli -datadir=src/signet -getinfo
{
  "version": 209900,
  "blocks": 3747,
  "headers": 3747,
  "verificationprogress": 1,
  "timeoffset": 0,
  "connections": {
    "in": 0,
    "out": 1,
    "total": 1
  },
  "proxy": "127.0.0.1:9050",
  "difficulty": 0.003293189602495658,
  "chain": "signet",
  "keypoolsize": 1000,
  "paytxfee": 0.00000000,
  "balance": 9.49818000,
  "relayfee": 0.00001000,
  "warnings": "This is a pre-release test build - use at your own risk - do not use for mining or merchant applications"
}

$ ./src/bitcoin-cli -datadir=src/signet getwalletinfo
{
  "walletname": "",
  "walletversion": 169900,
  "balance": 9.49818000,
  "unconfirmed_balance": 0.00000000,
  "immature_balance": 0.00000000,
  "txcount": 10,
  "keypoololdest": 1599664406,
  "keypoolsize": 1000,
  "hdseedid": "xxx",
  "keypoolsize_hd_internal": 1000,
  "paytxfee": 0.00000000,
  "private_keys_enabled": true,
  "avoid_reuse": false,
  "scanning": false,
  "descriptors": false
}

some manual GUI testing

Screenshot from 2020-09-18 11-37-42

@fjahr
Copy link
Contributor

fjahr commented Sep 18, 2020

re-ACK 8258c4c

The only change was the renaming of the -signet* args.

Copy link

@dr-orlovsky dr-orlovsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like bech32 HRP is not updated

base58Prefixes[EXT_PUBLIC_KEY] = {0x04, 0x35, 0x87, 0xCF};
base58Prefixes[EXT_SECRET_KEY] = {0x04, 0x35, 0x83, 0x94};

bech32_hrp = "tb";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we do use "tb" instead of "sb" here?

In c-lightning PR we had "sb" here: https://github.com/ElementsProject/lightning/pull/2816/files#diff-53092192708008b1de0d997128c58d37R54

And BIP-325 and BIP-173 are being silent in this regard: not even a PR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

People thinks that the test networks should use the same prefixes so it was changed to match testnet.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, probably we have another thing to update in c-lightning then, additionally to new nonce.

Also, noticed that BIP-235 still has outdated nonce info

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Filed bitcoin/bips#1000 to update the bip for the genesis block. FWIW, #12314 has related discussion about reusing testnet addresses in regtest.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing that out, @dr-orlovsky -- I thought I had already updated the BIP but I had apparently forgotten to actually make it into a pull request.

@kallewoof
Copy link
Contributor Author

Travis now passes after wallet PR fix. Please re-review.

@DrahtBot DrahtBot mentioned this pull request Sep 19, 2020
Copy link
Member

@maflcko maflcko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approach ACK 8258c4c 🌵

Show signature and timestamp

Signature:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Approach ACK 8258c4c007 🌵
-----BEGIN PGP SIGNATURE-----

iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
pUhgkAv9HshmtvJ5n8HJ+i7B/2ZZCH5k4QsVC7dOG62A9TJf25LL1vSbmQLMNcmr
rYihCi+Hl9gtMLj4ond8EgYrXTRLxcwwaiJIBrnpb/5dJnIH5W65HG3rFN6fBzSg
Sf+DmYi990uJUcB9/TSmofpAff4ufc5+1alnXaDDAeo9fMcDgjs79sWy28eGClw3
nP5JSU8iJd8u6dQsKmqUmjvP/BTSA+biz3Uz9Q0WLxeYFuX1p3rryo6IfBTZx7iB
/aQFJgukOjaQSVDOlKUfVGkAX3EBA5tcNhPU4eQ6sJORKQhopuHvq1JrunWJ7lSz
hjiIDw2vI6mEcC7N2zfVCXZu5OV84EWA5GYK4uC44j5dulPbwIEPEMbhSXAi1TLO
lY1Lve7ot5/YVGW2TqVa5JhJxv6CdH7Drj8QPQQ00YwUknlUQjiXtT/sB/W6VEZP
/4wB9KdOaO+d/e8xq+K5WaGnk7dDiuOXwiSKyKXyxbve9mSIXSxwgBNM6pf6GUvt
dS9yZ6ox
=IKXe
-----END PGP SIGNATURE-----

Timestamp of file with hash 46dca4399a20a8d06fcc6a4bb3621364ceb7aa953eaaeec52880e8248a1abbbd -

src/signet.cpp Show resolved Hide resolved
src/test/fuzz/signet.cpp Show resolved Hide resolved
test/functional/feature_signet.py Show resolved Hide resolved
test/functional/feature_signet.py Show resolved Hide resolved
@laanwj
Copy link
Member

laanwj commented Sep 21, 2020

ACK 8258c4c

@laanwj laanwj merged commit 8c5f681 into bitcoin:master Sep 21, 2020
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Sep 22, 2020
8258c4c test: some sanity checks for consensus logic (Anthony Towns)
e47ad37 test: basic signet tests (Karl-Johan Alm)
4c189ab test: add small signet fuzzer (practicalswift)
ec9b25d test: signet network selection tests (Karl-Johan Alm)
3efe298 signet: hard-coded parameters for Signet Global Network VI (2020-09-07) (Karl-Johan Alm)
c7898bc qt: update QT to support signet network (Karl-Johan Alm)
a8de47a consensus: add signet validation (Karl-Johan Alm)
e8990f1 add signet chain and accompanying parameters (Karl-Johan Alm)
404682b add signet basic support (signet.cpp) (Karl-Johan Alm)
a2147d7 validation: move GetWitnessCommitmentIndex to consensus/validation (Karl-Johan Alm)

Pull request description:

  This PR is a part of BIP-325 (https://github.com/bitcoin/bips/blob/master/bip-0325.mediawiki), and is a sub-PR of bitcoin#16411.

  * Signet consensus (this)
  * Signet RPC tools (pending)
  * Signet utility scripts (contrib/signet) (pending)

ACKs for top commit:
  jonatack:
    re-ACK 8258c4c per `git diff dbeea65 8258c4c`, only change since last review is updated `-signet*` config option naming.
  fjahr:
    re-ACK 8258c4c
  laanwj:
    ACK 8258c4c
  MarcoFalke:
    Approach ACK 8258c4c 🌵

Tree-SHA512: 5d158add96755910837feafa8214e13695b769a6aec3a2da753cf672618bef377fac43b0f4b772a87b25dd9f0c1c9b29f2789785d7a7d47a155cdcf48f7c975d
bin = ParseHex("512103ad5e0edad18cb1f0fc0d28a3d4f1f3e445640337489abb10404f2d1e086be430210359ef5021964fe22d6f8e05b2463c9540ce96883fe3b278760f048f5189f2e6c452ae");
vSeeds.emplace_back("178.128.221.177");
vSeeds.emplace_back("2a01:7c8:d005:390::5");
vSeeds.emplace_back("ntv3mtqw5wt63red.onion:38333");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit weird that this shows up as "Loading addresses from DNS seed", but that's out of scope for this PR.

maflcko pushed a commit that referenced this pull request Sep 23, 2020
facaf9e doc: Document signet BIP (MarcoFalke)
faf0a26 doc: Update comments for new chain settings (-signet and -chain=signet) (MarcoFalke)
fae0548 fuzz: Remove needless guard (MarcoFalke)
77771a0 refactor: Remove SignetTxs::m_valid and use optional instead (MarcoFalke)
fa2ad5d test: Run signet test even when wallet was not compiled (MarcoFalke)

Pull request description:

  Some doc and test fixups for #18267

ACKs for top commit:
  ajtowns:
    ACK facaf9e -- code review only
  dr-orlovsky:
    Reviewed & ACK facaf9e
  kallewoof:
    Code review ACK facaf9e

Tree-SHA512: 8085027c488d84bb4bddccba78bd2d4c5af0d8e2644ee72265f1f30fa8c83f61a961d9da2c796f2940e69682291cbee7b1028b6a6ce123ad9134c0ebbf4723b0
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Sep 23, 2020
facaf9e doc: Document signet BIP (MarcoFalke)
faf0a26 doc: Update comments for new chain settings (-signet and -chain=signet) (MarcoFalke)
fae0548 fuzz: Remove needless guard (MarcoFalke)
77771a0 refactor: Remove SignetTxs::m_valid and use optional instead (MarcoFalke)
fa2ad5d test: Run signet test even when wallet was not compiled (MarcoFalke)

Pull request description:

  Some doc and test fixups for bitcoin#18267

ACKs for top commit:
  ajtowns:
    ACK facaf9e -- code review only
  dr-orlovsky:
    Reviewed & ACK bitcoin@facaf9e
  kallewoof:
    Code review ACK facaf9e

Tree-SHA512: 8085027c488d84bb4bddccba78bd2d4c5af0d8e2644ee72265f1f30fa8c83f61a961d9da2c796f2940e69682291cbee7b1028b6a6ce123ad9134c0ebbf4723b0
domob1812 added a commit to domob1812/namecoin-core that referenced this pull request Sep 28, 2020
Signet from bitcoin/bitcoin#18267 has been added,
but not fully adjusted yet (e.g. the default challenge is not yet changed).
Also the feature_signet.py regtest fails (and is thus skipped) because
the pregenerated blocks have a bad version for auxpow and would need to
be regenerated when enabling signet for Namecoin.
guggero added a commit to guggero/btcd that referenced this pull request Feb 14, 2021
This commit adds all necessary chain parameters for connecting to the
public signet network.
Reference: bitcoin/bitcoin#18267
guggero added a commit to guggero/btcd that referenced this pull request Feb 17, 2021
This commit adds all necessary chain parameters for connecting to the
public signet network.
Reference: bitcoin/bitcoin#18267
guggero added a commit to guggero/btcd that referenced this pull request Mar 10, 2021
This commit adds all necessary chain parameters for connecting to the
public signet network.
Reference: bitcoin/bitcoin#18267
guggero added a commit to guggero/btcd that referenced this pull request Mar 15, 2021
This commit adds all necessary chain parameters for connecting to the
public signet network.
Reference: bitcoin/bitcoin#18267
guggero added a commit to guggero/btcd that referenced this pull request Apr 22, 2021
This commit adds all necessary chain parameters for connecting to the
public signet network.
Reference: bitcoin/bitcoin#18267
marni pushed a commit to decfi/btcd that referenced this pull request Oct 5, 2021
* Improve error message about non-active segwit on simnet

I started playing with simnet and was confronted with error message:

```
[ERR] FNDG: Unable to broadcast funding tx for ChannelPoint(<point>:0):
-22: TX rejected: transaction <tx> has witness data, but segwit isn't active yet
```

I wasn't aware of the activation period so I got quite puzzled.
Google helped. But I think the message could mention likely cause.

Newly it optionally prints something like:

```
(The threshold for segwit activation is 300 blocks on simnet, current best height is 113)
```

* btcctl: add regtest mode to btcctl

* build: replace travis-ci with github actions.

test go 1.14
use golangci-lint

* build: update deps

* build: clean linter warnings

* btcjson: change getblock default verbosity to 1

This change makes btcd's getblock command match bitcoind's. Previously
the default verbosity was 0, which caused errors when using the
rpcclient library to connect to a bitcoind node - getblock would
unmarshall incorrectly since it didn't expect a verbosity=1 result when
it did not specify verbosity.

* rpcclient: send legacy GetBlock request for backwards compatibility

Without this, users of this library wouldn't be able to issue GetBlock
requests to nodes which haven't updated to support the latest request
format, namely the use of a single `int` parameter to denote verbosity
instead of two `bool`s.

* rpcclient: Add cookie auth

Based on Hugo Landau's cookie auth implementation for Namecoin's ncdns.

Fixes btcsuite#1054

* rpcclient: Refactor cookie caching

* rpcclient: Try user+pass auth before cookie auth

* rpcclient: Read first line of cookie instead of trimming space

* rpcclient: serialize nil inputs to empty list

* Improve chain state init efficiency

Remove unnecessary slice of all block indexes and
remove DB iteration over all block indexes that
used to determined the size of the slice.

* Add blockchain.NewUtxoEntry() to directly create entries for UtxoViewpoint

The current methods to add to a UtxoViewpoint don't allow for a situation where
we have only UTXO data but not a whole transaction.  This commit allows
contstruction of a UtxoEntry without requiring a full MsgTx.

AddTxOut() and AddTxOuts() both require a whole transaction, including the inputs,
which are only used in order to calculate the txid.  In some situations, such as
with use of the utreexo accumulator, we only have the utxo data but not the
transaction which created it.

For reference, utreexo's initial usage of the blockchain.NewUtxoEntry() function is at
https://github.com/mit-dci/utreexo/pull/135/files#diff-3f7b8f9991ea957f1f4ad9f5a95415f0R96

* Add getchaintxstats JSON-RPC client command

* Add fundrawtransaction RPC call

* Add getbalances RPC client command

* rpcclient: Add GetTransactionWatchOnly method

* peer: knownInventory, sentNonces - use generic lru

While here, also rename and generalize limitMap and apply to
other maps which need to be bounded.

* btcec: Avoid panic in fieldVal.SetByteSlice for large inputs

The implementation has been adapted from the dcrec module in dcrd. The
bug was initially fixed in decred/dcrd@3d9cda1 while transitioning to a
constant time algorithm. A large set of test vectors were subsequently
added in decred/dcrd@8c6b52d.

The function signature has been preserved for backwards compatibility.
This means that returning whether the value has overflowed, and the
corresponding test vectors have not been backported.

This fixes btcsuite#1170 and closes a previous attempt to fix the bug in btcsuite#1178.

* config+service_windows: add flag to disable win service

To run integration tests with btcd on Windows in non-interactive
environments (such as the Travis build with Windows machines), we
need to make sure we can still spawn a child process instead of only a
windows background service.

* updated docs for getblock-verbosity fixes

* Update json_rpc_api.md

Corrections suggested by @onyb btcsuite#1608 (comment)

* netsync: handle notfound messages from peers

backport from decred/dcrd#2253

When a peer sends a notfound message, remove the hash from requested
map.  Also increase notfound ban score and return early if it
disconnects the peer.

* release: update release script path

* release: remove old scripts and update process doc

- remove prep_release.sh and notes.sample
- update license in release.sh
- add notes for maintainers on the release process
- mention CHANGES file modifications

* Update CHANGES file for 0.21.0 release

Also updated changes for 0.20.1, and added a small note about changes
since 0.12.0.

* btcd: bump version to v0.21.0-beta

* blockchain: remove unknown block version warning

* Add rpclient implementation of getdescriptorinfo RPC

* peer: prevent last block height going backwards

This modifies the UpdateLastBlockHeight function to ensure the new
height is after the existing height before updating it in order to
prevent it from going backwards so it properly matches the intent of the
function which is to report the latest known block height for the peer.

Without this change, the value will properly start out at the latest
known block height reported by the peer during version negotiation,
however, it will be set to lower values when syncing from the peer due
to requesting old blocks and blindly updating the height.

It also adds a test to ensure proper functionality.

This is a backport of decred/dcrd#1747

* Fix monetary unit

* rpcserver: add parity with bitcoind for validateaddress

Updated the rpcserver handler for validateaddress JSON-RPC command to
have parity with the bitcoind 0.20.0 interface.

The new fields included are - isscript, iswitness, witness_version, and
witness_program. The scriptPubKey field has been left out since it
requires wallet access.

This update has no impact on the rpcclient.ValidateAddress method,
which uses the btcjson.ValidateAddressWalletResult type for modelling
the response from bitcoind.

* Add getblockfilter JSON-RPC client command

Add type for second getblockfilter param

* Implement signmessagewithprivkey JSON-RPC command

Reuse the Bitcoin message signature header const
also in verifymessage.

* rpcclient: Implement importmulti JSON-RPC client command

* Add Dockerfile to build and run btcd on Docker.

* btcd: fix conversion of int to string failing in Go 1.15

* btcjson,wire: fix invalid use of string(x) to convert byte value

* Major rework on documentation to make it compatible to readthedocs.org

* Added symlink to index.md for github readme preview.

* btcd+netsync: support witness tx and block in notfound msg

* btcec: set curve name in CurveParams

Set curve name(secp256k1) in KoblitzCurve.CurveParams

Fixes btcsuite#1564

* btcec: add a comment indicating where curve name taken from

Related with btcsuite#1565

* rpcclient: support listtransactions RPC with watchonly argument

Co-authored-by: Gert-Jaap Glasbergen <gertjaap@decoscrypto.com>

* blockchain: Remove unnecessary tx hash

* btcjson: update ListTransactionsResult for Bitcoin 0.20.0

This only adds new fields as optional, in order to make this change
backwards compatible with older versions of Bitcoin Core.

* chaincfg: Add RegisterHDKeyID func to populate HD key ID pairs

Currently, the only way to register HD version bytes is by initializing
chaincfg.Params struct, and registering it during package init.
RegisterHDKeyID provides a way to populate custom HD version bytes,
without having to create new chaincfg.Params instances. This is useful
for library packages who want to use non-standard version bytes for
serializing extended keys, such as the ones documented in SLIP-0132.

This function is complementary to HDPrivateKeyToPublicKeyID, which is
used to lookup previously registered key IDs.

* Nullable optional JSON-RPC parameters

Fix command marshalling dropping params following params with nil value.

btcsuite#1591 Allow specifying null parameter value from command line.

* GitHub Actions: Enable Go Race detector and code coverage

This modifies the goclean.sh script to run tests with the
race detector enabled. It also enables code coverage, and
uploads the results to coveralls.io.

Running tests with -race and -cover flags was disabled in
6487ba1 and 6788df7 respectively, due to some limits on
time/goroutines being hit on Travis CI. Since we have
migrated to GitHub Actions, it is desirable to bring them
back.

* rpc: Add getnodeaddresses JSON-RPC support

Add NodeAddresses function to rpcserverConnManager
interface for fetching known node addresses.

* btcjson,rpcclient: add support for PSBT commands to rpcclient

* Added ListSinceBlockMinConfWatchOnly method.

* wire: add proper types for flag field and improve docs

Summary of changes:

- Add a new const TxFlagMarker to indicate the flag prefix byte.
- Add a new TxFlag type to enumerate the flags supported by the
  tx parser.

  This allows us to avoid hardcoded magics, and will make it easier
  to support new flags in future.
- Improve code comments.

Closes btcsuite#1598.

* removed unnecessary GOMAXPROCS function calls

* rpcclient: add deriveaddresses RPC command

* ci: add go 1.15 to tests

* sample-btcd.conf: fix typo

* btcjson: add test for null params in searchrawtransactions

Closes PR btcsuite#1476.

* GetBlockTemplate RPC client implementation (btcsuite#1629)

* GetBlockTemplate RPC client implementation

* Txid added to the getblocktemplate result

* Omitempty for TxID and improved comment for GetBlockTemplate 'rules' field

* rpcclient: implement getaddressinfo command

Fields such as label, and labelspurpose are not included, since they
are deprecated, and will be removed in Bitcoin Core 0.21.

* Fix link to using bootstrap.dat

* rpcclient: implement getwalletinfo command

* rpcserver: add txid to getblocktemplate response

* rpc: add signrawtransactionwithwallet interface

Adds interface for issuing a signrawtransactionwithwallet command.
Note that this does not add functionality for the btcd rpc server
itself, it simply assumes that the RPC client has this ability and gives
an API for interacting with the RPC client.

rpc: add signrawtransactionwithwallet interface

* rpcclient: implement gettxoutsetinfo command

* Unmarshal hashes/second as float in GetMiningInfoResult

* rpcclient: add more wallet commands

Implement backupwallet, dumpwallet, loadwallet and unloadwallet.

* btcjson: add new JSON-RPC errors and document them

* rpcclient: implement createwallet with functional options

* rpcclient: fix documentation typos

* integration: allow setting custom btcd exe path

To allow using a custom btcd executable, we allow specifying a path to a
file. If the path is empty, the harness will fall back to compiling one
from scratch.

* integration: allow overwriting address generator

* integration: allow specifying connection behavior

* integration/rpctest: randomizes port in rpctest.New to reduce collisions

* btcjson+rpcserverhelp: restore bitcoind compatibility

The PR btcsuite#1594 introduced a change that made the order of parameters
relevant, if one of them is nil. This makes it harder to be backward
compatible with the same JSON message if an existing parameter in
bitcoind was re-purposed to have a different meaning.

* simplify s[:] to s where s is a slice

Found using https://go-critic.github.io/overview#unslice-ref

* rpcclient: add ExtraHeaders in ConnConfig

* Add support for receiving sendaddrv2 message from a peer

* fixed broken link

* Add support for arm32v7 in Dockerfile

* Fixes btcsuite#1653

* btcjson: Update fields in GetBlockChainInfoResult

Update the fields of GetBlockChainInfoResult to reflect the current state of
the RPC returned by other full-node implementations.

 * InitialBlockDownload - Node is in Initial Block Download mode if True.
 * SizeOnDisk - The estimated size of the block and undo files on disk.

* txscript: add benchmark for IsUnspendable

 - create benchmarks to measure allocations
 - add test for benchmark input
 - create a low alloc parseScriptTemplate
 - refactor parsing logic for a single opcode

* txscript/hashcache_test: always add inputs during getTxn

TestHashCacheAddContainsHashes flakes fairly regularly when rebasing
PR btcsuite#1684 with:
    txid <txid> wasn't inserted into cache but was found.

With probabilty 1/10^2 there will be no inputs on the transaction. This
reduces the entropy in the txid, and I belive is the primary cause of
the flake.

* txscript/hashcache_test: call rand.Seed once in init

This resolves the more fundamental flake in the unit tests noted in the
prior commit.

Because multiple unit tests call rand.Seed in parallel, it's possible
they can be executed with the same unix timestamp (in seconds). If the
second call happens between generating the hash cache and checking that
the cache doesn't contain a random txn, the random transaction is in
fact a duplicate of one generated earlier since the RNG state was reset.

To remedy, we initialize rand.Seed once in the init function.

* btcec: validate R and S signature components in RecoverCompact

* Add Batch JSON-RPC support (rpc client & server)

* Fix error message returned by EstimateFee

When you provide an argument to EstimateFee(numblocks uint32) that exceeds the estimateFeeDepth (which is set to 25), you get an error message that says "can only estimate fees for up to 100 blocks from now".  The variable used in the if condition and the variable used for creating the error message should be the same.

* docs: update shields

* rpcserver: Fix Error message returned by processRequest

When processRequest can't find a rpc command, standardCmdResult returns
a `btcjson.ErrRPCMethodNotFound` but it gets ignored and a
`btcjson.ErrRPCInvalidRequest` is returned instead.

This makes processRequest return the right error message.

* peer: allow external testing of peer.Peer

The previous use of allowSelfConns prevented this, as users aren't able
to invoke peer.TstAllowSelfConns themselves due to being part of a test
file, which aren't exported at the library level, leading to a
"disconnecting peer connected to self" error upon establishing a mock
connection between two peers. By including the option at the config
level instead (false by default, prevents connections to self) we enable
users of the peer library to properly test the behavior of the peer.Peer
struct externally.

* addrmgr: Use RLock/RUnlock when possible

* build: update btcutil dependency

* rpcclient: fix documentation typo

* btcjson: Updated TxRawResult.Version from int32 to uint32

* wire+chaincfg: add signet params

This commit adds all necessary chain parameters for connecting to the
public signet network.
Reference: bitcoin/bitcoin#18267

* config+params: add signet config option

This commit adds the --signet command line flag (or signet config
option) for starting btcd in signet mode.

* rpcserver: add taproot deployment to getblockchaininfo

* btcctl: add signet param

This commit adds the --signet command line flag to the btcctl utility.

* mining: extract witness commitment add into method

* rpctest: add witness commitment when calling CreateBlock

If we tried to include transactions having witnesses, the block would be
invalid since the witness commitment was not added.

* Don't reference the readme that we don't produce

* chaincfg: fix deployment bit numbers

On signet all previous soft forks and also taproot are always activated,
meaning the version is always 0x20000000 for all blocks. To make sure
they activate properly in `btcd` we therefore need to use the correct
bit to mask the version.
This means that on any custom signet there would need to be 2016 blocks
mined before SegWit or Taproot can be used.

* mempool: add additional test case for inherited RBF replacement

In this commit, we add an additional test case for inherited RBF
replacement. This test case asserts that if a parent is marked as being
replaceable, but the child isn't, then the child can still be replaced
as according to BIP 125 it shoudl _inhreit_ the replaceability of its
parent.

The addition of this test case was prompted by the recently discovered
Bitcoin Core "CVE" [1]. It turns out that bitcoind doesn't properly
implement BIP 125. Namely it fails to allow a child to "inherit"
replaceability if its parent is also replaceable. Our implementation
makes this trait rather explicit due to its recursive implementation.
Kudos to the original implementer @wpaulino for getting this correct.

[1]: https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2021-May/018893.html.

* Update CHANGES file for 0.22.0 release

* btcd: bump version to v0.22.0-beta

* Update release date for v0.22.0-beta in CHANGES file

* remove duplicate command

Co-authored-by: Antonin Hildebrand <antonin@hildebrand.cz>
Co-authored-by: Dan Cline <kidscline01@gmail.com>
Co-authored-by: David Hill <dhill@mindcry.org>
Co-authored-by: Henry <henry.wfisher@gmail.com>
Co-authored-by: Wilmer Paulino <wilmer.paulino@gmail.com>
Co-authored-by: Olaoluwa Osuntokun <laolu32@gmail.com>
Co-authored-by: JeremyRand <jeremyrand@airmail.cc>
Co-authored-by: Torkel Rogstad <torkel@rogstad.io>
Co-authored-by: Mikael Lindlof <mikuz.dev@gmail.com>
Co-authored-by: adiabat <rx@awsomnet.org>
Co-authored-by: Federico Bond <federicobond@gmail.com>
Co-authored-by: Anirudha Bose <anirudha.bose@ledger.fr>
Co-authored-by: Javed Khan <tuxcanfly@gmail.com>
Co-authored-by: Anirudha Bose <anirudha.bose@alumni.cern>
Co-authored-by: Oliver Gugger <gugger@gmail.com>
Co-authored-by: qqjettkgjzhxmwj <37233887+JettScythe@users.noreply.github.com>
Co-authored-by: Dan Cline <dan@dancline.net>
Co-authored-by: John C. Vernaleo <jcv@netpurgatory.com>
Co-authored-by: wakiyamap <wakiyamap@gmail.com>
Co-authored-by: Christian Lehmann <info@legacycode.org>
Co-authored-by: yyforyongyu <yy2452@columbia.edu>
Co-authored-by: Hanjun Kim <hallazzang@gmail.com>
Co-authored-by: Gert-Jaap Glasbergen <gertjaap@decoscrypto.com>
Co-authored-by: Calvin Kim <calvin@kcalvinalvin.info>
Co-authored-by: Andrew Tugarinov <nalcheg@gmail.com>
Co-authored-by: ipriver <g1ran1q@gmail.com>
Co-authored-by: Jake Sylvestre <jakesyl@gmail.com>
Co-authored-by: Tristyn <tristynstimpson@gmail.com>
Co-authored-by: Elliott Minns <elliott.minns@me.com>
Co-authored-by: Friedger Müffke <friedger@gmail.com>
Co-authored-by: David Mazary <dmaz@vt.edu>
Co-authored-by: Armando Ochoa <armando.o.j@gmail.com>
Co-authored-by: Liran Sharir <lsharir@paxos.com>
Co-authored-by: Iskander Sharipov <quasilyte@gmail.com>
Co-authored-by: 10gic <2391796+10gic@users.noreply.github.com>
Co-authored-by: Yaacov Akiba Slama <ya@slamail.org>
Co-authored-by: ebiiim <mail@ebiiim.com>
Co-authored-by: Victor Lavaud <victor.lavaud@gmail.com>
Co-authored-by: Vinayak Borkar <vinayakb@gmail.com>
Co-authored-by: Steven Kreuzer <skreuzer@FreeBSD.org>
Co-authored-by: Conner Fromknecht <conner@lightning.engineering>
Co-authored-by: Appelberg-s <Appelberg-s@users.noreply.github.com>
Co-authored-by: Gustavo Chain <gchain@pm.me>
Co-authored-by: Aurèle Oulès <aurele@oules.com>
Co-authored-by: Johan T. Halseth <johanth@gmail.com>
roylee17 pushed a commit to lbryio/lbcd that referenced this pull request Oct 20, 2021
This commit adds all necessary chain parameters for connecting to the
public signet network.
Reference: bitcoin/bitcoin#18267
kcalvinalvin pushed a commit to kcalvinalvin/btcd that referenced this pull request Nov 17, 2021
This commit adds all necessary chain parameters for connecting to the
public signet network.
Reference: bitcoin/bitcoin#18267
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Feb 15, 2022
@kallewoof kallewoof deleted the 2003-signet-consensus branch May 16, 2022 05:59
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.