Commit graph

3954 commits

Author SHA1 Message Date
Olaoluwa Osuntokun
447c95c9c2
Merge pull request #2122 from kcalvinalvin/2024-02-15-dont-rely-on-height-fetching
blockchain: don't rely on BlockHeightByHash for prune height calculations
2024-03-08 17:40:16 -08:00
Olaoluwa Osuntokun
a4f447006e
Merge pull request #2131 from kcalvinalvin/2024-03-05-fix-intermittent-addrmgr-bug
addrmgr: fix intermittent addrmanager_internal_test bug
2024-03-05 12:07:57 -06:00
Calvin Kim
f2caa8fadc blockchain: don't rely on BlockHeightByHash for prune height
calculations

Since BlockHeightByHash only returns the heights for blocks that are in
the main chain, when a block that is stale gets pruned, this will cause
an error in the block height lookup and cause an error in block
processing.

Look up the node directly from the index and if the node isn't found,
just skip that node. For utxoCache.lastFlushHash, if that isn't found,
just force a flush.
2024-03-06 02:15:39 +09:00
Calvin Kim
f9da3387f1 addrmgr: fix intermittent addrmanager_internal_test bug
Sometimes the tests in the addrmanager_internal_test will fail with:
"addrmanager_internal_test.go: expected to find 5 addresses, found 4"

This is because the generated address with randAddr() may not always
generate an address that's routable. If the address is not routable,
that address will not be added to the manager when calling AddAddress().

This bug is fixed by creating a new function routableRandAddr() that
always creates a routable random address.
2024-03-05 16:33:08 +09:00
Olaoluwa Osuntokun
1a2b599bf1
Merge pull request #2125 from yyforyongyu/add-gettxspendingprevout
Add `gettxspendingprevout` for `btcd` and fix version check
2024-03-01 15:04:20 -06:00
yyforyongyu
0d4ed16ed7
btcd: increase version number to 0.24.1 2024-02-28 16:40:11 +08:00
yyforyongyu
34721f02c1
rpcclient: replace ErrBitcoindVersion with ErrBackendVersion 2024-02-28 03:38:48 +08:00
yyforyongyu
4cf49bd72c
multi: turn BackendVersion into an interface
This commit adds a new interface, `BackendVersion`, to support checking
versions for multiple both btcd and bitcoind. Once neutrino version is
also pinned here, it should also be checked.
2024-02-27 23:04:47 +08:00
yyforyongyu
9e6070a707
rpcclient: start tracking btcd version 2024-02-27 23:04:46 +08:00
yyforyongyu
0d52a890f2
rpcclient: handle backend versioning in one file 2024-02-27 23:04:46 +08:00
yyforyongyu
a033b0d6e7
rpcclient+integration: add new method GetTxSpendingPrevOut 2024-02-27 23:04:46 +08:00
yyforyongyu
5f71df165e
rpcclient: track bitcoind version 24.0.0
We need this for `gettxspendingprevout`.
2024-02-27 22:58:33 +08:00
yyforyongyu
72bbdd55a6
rpcserver+mempool: implement gettxspendingprevout for btcd
This commit adds the RPC method `gettxspendingprevout` for btcd.
2024-02-27 22:58:33 +08:00
yyforyongyu
dd31767617
btcjson: add new command GetTxSpendingPrevOutCmd 2024-02-27 22:58:33 +08:00
Olaoluwa Osuntokun
9ea2eea99b
Merge pull request #2112 from devlzcode/expose-newfutureerror
feat: Expose newFutureError for developer friendliness
2024-02-26 16:20:30 -08:00
Olaoluwa Osuntokun
5b6d265dd9
Merge pull request #2108 from kcalvinalvin/2024-01-22-dont-update-mempool
netsync: don't update mempool/fee estimator unless we're synced up
2024-02-26 16:19:51 -08:00
Olaoluwa Osuntokun
d55c55a81f
Merge pull request #2119 from nikicat/nb/include-unsafe
Added 'include_unsafe' option to FundRawTransaction
2024-02-22 14:46:04 -08:00
Calvin Kim
a0c9e3b384 blockchain: add case for pruning stale blocks
Pruning stale blocks will make the block validation fail for the block
that the prune was triggered on as BlockHeightByHash will not return the
height for blocks that are not in the main chain.

We add a test case to ensure that the test fails in the above case.
2024-02-16 16:17:04 +09:00
Calvin Kim
8836219a02 blockchain: return error in db.View instead of t.Fatal
Calling t.Fatal inside db.View makes the test hang on failures.  Return
the error and call t.Fatal outside of db.View avoids this.
2024-02-16 16:17:04 +09:00
Nikolay Bryskin
069a0eca29
Added 'include_unsafe' option to FundRawTransaction 2024-02-05 14:55:17 +02:00
ly
c4b1448212
feat: Expose newFutureError for developer friendliness 2024-01-25 19:24:23 -08:00
Olaoluwa Osuntokun
13152b35e1
Merge pull request #2089 from kcalvinalvin/2024-01-03-add-last-flush-time-on-initconsistentstate
blockchain: set the lastflushtime when setting the lastflushhash
2024-01-23 20:25:55 -08:00
Olaoluwa Osuntokun
8e53942b98
Merge pull request #2107 from Halimao/refactor/make-help
refactor: add `make help` to display the usage for project Makefile
2024-01-23 20:14:29 -08:00
Halimao
2a55ff4884 refactor: add make help command that describes goals 2024-01-24 10:28:18 +08:00
Olaoluwa Osuntokun
62e6af035e
Merge pull request #2105 from yyforyongyu/fix-batch-mem-leak
rpcclient: make sure batch requests are GCed
2024-01-22 16:01:08 -08:00
Calvin Kim
c17cf800dc netsync: don't update mempool/fee estimator unless we're synced up
Noticed during ibd that there's a slight overhead for
handleBlockchainNotification on mempool/fee estimator updates. Since
there's no reason to be looking at this while we're not caught up,
return early and avoid the calls.
2024-01-22 13:35:55 +09:00
yyforyongyu
9cda0f7e95
wire: add Copy method to MsgBlock 2024-01-21 18:43:15 +08:00
yyforyongyu
e8a5a55379
rpcclient: make sure batch requests are GCed
This commit makes sure the batch requests are always GCed before sending
back the responses for them. In particular,
- `removeRequest` didn't remove the item from `batchList`, which is now
  fixed.
- `Send` didn't remove the request from `requestMap`, which is now fixed
  by using `removeRequest`.
2024-01-19 18:56:22 +08:00
Olaoluwa Osuntokun
17fdc5219b
Merge pull request #2053 from yyforyongyu/testmempoolaccept
support `testmempoolaccept` for both `bitcoind` and `btcd`
2024-01-16 12:06:49 -08:00
yyforyongyu
fbe65bfc01
gomod: run go mod tidy for all modules
Also add the `make tidy-module` copied from `lnd`.
2024-01-15 17:22:42 +08:00
yyforyongyu
8817ebdd39
integration: print logs to console 2024-01-15 17:22:42 +08:00
yyforyongyu
c104e72151
rpctest: add itest for testmempoolaccept 2024-01-15 17:22:41 +08:00
yyforyongyu
ef54c49df4
multi: map btcd mempool acceptance errors to bitcoind's testmempoolaccept
This commit creates a `RejectReasonMap` to map the errors returned from
`btcd` to bitcoind's `testmempoolaccept` so the `RejectReason` is
unified at the RPC level. To make sure the map keys are unique, the
error strings are modified in `btcd`.
2024-01-15 17:22:41 +08:00
yyforyongyu
6c9f7fe7b9
btcd: add new RPC method testmempoolaccept 2024-01-15 17:22:41 +08:00
yyforyongyu
4842b23247
mempool+rpcserver: add interface TxMempool
This commit adds a new interface `TxMempool` which defines how other
subsystems interact with `TxPool`.
2024-01-15 17:22:41 +08:00
yyforyongyu
c7e40280d5
rpcclient: support testmempoolaccept for bitcoind 2024-01-15 17:22:41 +08:00
yyforyongyu
889cdb4f66
multi: add more bitcoind versions to the BackendVersion
This commit adds bitcoind version 22.0 and 25.0 to our `BackendVersion`
set to handle the `testmempoolaccept` RPC calls. A unit test is added to
make sure the parser works as expected.
2024-01-15 17:22:40 +08:00
yyforyongyu
ca4261f028
btcjson: add TestMempoolAcceptCmd 2024-01-15 17:22:40 +08:00
yyforyongyu
2ad8026a38
mempool: add new method checkMempoolAcceptance
This commit breaks the `maybeAcceptTransaction` into two parts - the
first is reading the mempool to validate the transaction, and the
relevant logic has been moved into the new method
`checkMempoolAcceptance`. The second part is writing to the mempool, and
is kept in the method `maybeAcceptTransaction`.
2024-01-15 17:22:40 +08:00
yyforyongyu
44abf0a53c
gitignore: ignore vim files 2024-01-15 17:22:40 +08:00
Oliver Gugger
91cdf0d7fc
Merge pull request #2098 from vuittont60/master
Fix some typos
2024-01-09 12:52:07 +01:00
vuittont60
6ed54f3bf2
btcec: fix typo 2024-01-09 17:12:36 +08:00
vuittont60
7df46516b7
btcutil: fix typo 2024-01-09 17:12:23 +08:00
vuittont60
048a7ef40b
database: fix typo 2024-01-09 17:12:09 +08:00
vuittont60
7fdd92c3a0
docs: fix typo 2024-01-09 17:11:59 +08:00
Thabokani
a4df044cfd
Fix some typos (#2085)
* Dockerfile: fix typo

* blockchain: fix typos

* sample-btcd.conf: fix typos

* server: fix typos

* txscript: fix typos
2024-01-03 16:36:49 -05:00
Calvin Kim
e307ad122f blockchain: set the lastflushtime when setting the lastflushhash
On startup when the headers-first mode is off, when receiving the first
block, the periodic flush will trigger.  The lastflushtime wasn't set
which resulted in the flush being triggered on the first block on
restart.
2024-01-03 14:24:36 +09:00
Olaoluwa Osuntokun
b1b9420208
Merge pull request #2082 from btcsuite/btcd-24
build: create btcd v0.24 release branch
2023-12-30 16:52:37 -08:00
Olaoluwa Osuntokun
4ec8f016b9
rpcclient: fix race condition in doDisconnect
In this commit, we fix the following race condition:
```
==================
WARNING: DATA RACE
Write at 0x00c000216018 by goroutine 31:
  github.com/btcsuite/btcd/rpcclient.(*Client).wsReconnectHandler()
      /home/runner/work/btcd/btcd/rpcclient/infrastructure.go:736 +0x2aa
  github.com/btcsuite/btcd/rpcclient.New·dwrap·13()
      /home/runner/work/btcd/btcd/rpcclient/infrastructure.go:1496 +0x39

Previous read at 0x00c000216018 by goroutine 29:
  github.com/btcsuite/btcd/rpcclient.(*Client).doDisconnect()
      /home/runner/work/btcd/btcd/rpcclient/infrastructure.go:1079 +0x247
  github.com/btcsuite/btcd/rpcclient.(*Client).Disconnect()
      /home/runner/work/btcd/btcd/rpcclient/infrastructure.go:1111 +0x47
  github.com/btcsuite/btcd/rpcclient.(*Client).wsInHandler()
      /home/runner/work/btcd/btcd/rpcclient/infrastructure.go:491 +0x1eb
  github.com/btcsuite/btcd/rpcclient.(*Client).start·dwrap·11()
      /home/runner/work/btcd/btcd/rpcclient/infrastructure.go:1181 +0x39

Goroutine 31 (running) created at:
  github.com/btcsuite/btcd/rpcclient.New()
      /home/runner/work/btcd/btcd/rpcclient/infrastructure.go:1496 +0xd77
  github.com/btcsuite/btcd/rpcclient.makeClient()
      /home/runner/work/btcd/btcd/rpcclient/chain_test.go:268 +0x1f9
  github.com/btcsuite/btcd/rpcclient.TestClientConnectedToWSServerRunner.func2()
      /home/runner/work/btcd/btcd/rpcclient/chain_test.go:164 +0x47
  testing.tRunner()
      /opt/hostedtoolcache/go/1.17.5/x64/src/testing/testing.go:1259 +0x22f
  testing.(*T).Run·dwrap·21()
      /opt/hostedtoolcache/go/1.17.5/x64/src/testing/testing.go:1306 +0x47

Goroutine 29 (finished) created at:
  github.com/btcsuite/btcd/rpcclient.(*Client).start()
      /home/runner/work/btcd/btcd/rpcclient/infrastructure.go:1181 +0x2e4
  github.com/btcsuite/btcd/rpcclient.New()
      /home/runner/work/btcd/btcd/rpcclient/infrastructure.go:1493 +0xc51
  github.com/btcsuite/btcd/rpcclient.makeClient()
      /home/runner/work/btcd/btcd/rpcclient/chain_test.go:268 +0x1f9
  github.com/btcsuite/btcd/rpcclient.TestClientConnectedToWSServerRunner.func2()
      /home/runner/work/btcd/btcd/rpcclient/chain_test.go:164 +0x47
  testing.tRunner()
      /opt/hostedtoolcache/go/1.17.5/x64/src/testing/testing.go:1259 +0x22f
  testing.(*T).Run·dwrap·21()
      /opt/hostedtoolcache/go/1.17.5/x64/src/testing/testing.go:1306 +0x47
```

This arises as in `wsReconnectHandler`, the mutex isn't held while the
`conn` pointer is modified.
2023-12-30 16:43:07 -08:00
Olaoluwa Osuntokun
8d2ab63e36
build: bump version to btcd v0.24 2023-12-30 16:25:08 -08:00