Commit Graph

80 Commits

Author SHA1 Message Date
Chris Stewart
86463231d6
2022 08 18 Add configuration to only emit websocket events when IBD is done (#4627)
* Implement isinitialblockdownload flag in databaes

* Change to IsInitialBlockDownload to be less confusing

* Fix missing refactors, add ChainApi.isIBD()

* Implement logic for ChainApi.isIBD(), add configuration flag to toggle whether to emit websocket events while IBD is ongoing or not, add isinitialblockdownload field to getinfo endpoint

* Remove confusing ChainApi.isIBD() that didn't accurately account for the case where IBD wasn't set in the database

* Fix bug around emitting the websocket events

* Add some documentation
2022-08-22 10:09:00 -05:00
Chris Stewart
5c9092889b
Add abillity to clear callbacks (#4512)
Fix missing clearCallbacks()

Add some tests

Remove uncessary code from test
2022-07-17 09:10:57 -05:00
rorp
e90e372e54
Add sync JSON field to the getinfo endpoint output (#4452)
* Add `sync` JSON field to the `getinfo` endpoint output

* improve test coverage

* update docs

* rename sync flag

* WebSocket notifications

* fix unit tests

* fix unit tests

* increase test timout
2022-07-12 14:41:43 -05:00
Chris Stewart
e802254a20
2022 01 24 rm appconfig varargs (#4011)
* Get things compiling

* Get tests passing

* Fix docs
2022-01-25 07:25:05 -06:00
Chris Stewart
52dcf51e82
Automatically download binaries if they are used in test suite (#4005)
* Remove download binary scripts from CI, try to make binary downloads contingent on tests being run in a project

* Cleanup docs to remove unecessary downloadBitcoind
2022-01-23 17:43:30 -06:00
Chris Stewart
7ee1f0f406
Implement batching of database calls for our chain callback (#4003) 2022-01-23 07:39:10 -06:00
rorp
fa45c74c36
Improve filter header verification (#3566)
* Improve filter header verification

* unit test
2021-08-18 06:57:01 -05:00
Chris Stewart
7ba7f8b9ba
Try to add block generate to address in fixture setup to get around compact filter sync edge case (#3231)
* Try to add block generate to address in fixture setup to get around the case where block headers & filter headers are synced but compact filters are not

* Push to github to force re-run of CI 2

* Add ChainApi.getBestFilter(), use it in sync to determine if filter headers & filters are in sync

* Push to github to force re-run of CI 3

* Simplify getBestFilter, add unit test

* Add more comments, clean up some code
2021-06-08 12:47:28 -05:00
Chris Stewart
a2911f31ed
Fix race condition with BitcoindChainHandlerViaZmqTest (#2990)
Turn off logging again

Try to move things around even more to make sure zmq is started

Turn logging level down to ERROR to hopefully get some meaningful output

Adjust both valdiation & ChainHandler to be ERROR level logging

switch zmqpubrawblock to be the port we know is free

Reduce logging to WARN

Bump bitcoind max retries to 120

Fix rebase

Revert logging

Remove some noisy logs

Restore logs to trace level

Add explicit tag
2021-05-01 13:11:13 -05:00
Chris Stewart
a27d4acd9f Get FilterSync test working with cached bitcoind in chainTest project (#2952)
* Get FilterSync test working with cached bitcoind in chainTest project

* Small refactor to be DRY

* Fix docs

* Refactor ChainSyncTest to use 1 cached bitcoind, as a by product add ChainWithBitcoindNewestCachedUnitTest

* Remove unecessary mixin trait

* Fix missing ChainWithBitcoindNewestCachedUnitTest.afterAll()

* Reduce thread pool size for akka's internal dispatcher in unit tests from 2 -> 1. Same with the blocking dispatcher

* Add comment
2021-04-26 07:41:30 -05:00
Chris Stewart
16538980e3 Fix missing super.stop() to shutdown DbAppConfig db connection pool (#2943)
* Fix missing super.stop() to shutdown DbAppConfig db connection pool inside of all DbAppConfig subclasses that override stop()

* Fix import

* Remove implicit modifier to NodeUnitTest.getFreshConfig(), make sure we are shutting down chainAppConfig inside NodeUnitTest

* Remove chainTest subclasses implementing ActorSystem, make sure we do correct cleanup in ChainUnitTest

* Decouple CachedChainAppConfig & CachedAppConfig. When using only one sub module in the CachedAppConfig, teardown may fail as the other modules might not be started such as using chainAppConfig in chainTest, BitcoinSAppConfig.stop() requires us to call nodAppConfig.stop() first, which isn't started.

* Push to github to force re-run of CI 4
2021-04-23 08:21:56 -05:00
Chris Stewart
1959495cec Add testkit-core module (#2726)
* Refactor AsyncUtil to just use an execution context rather than an actor system

* Create testkit-core, start moving data structures over to testkit-core

* WIP, getting rid of the hard dependency on BitcoinSAsyncTest and akka

* Rework test traits to not be dependnent on akka, move BaseAsyncTest into testkitCore, add a test trait that just uses the default scala executionContext

* Get everything compiling

* Move logback-test.xml to testkit-core so it applies to coreTest,cryptoTest as well

* Cleanup rebase issues

* Fix Deps.scala

* Address ben's code review

* Segregate jvm settings and compiler settings

* Filter out -Xfatal-warning for scalajs for now since there is a ton of errors

* Move maintainer settings into CommonSettings.settings
2021-03-02 07:05:21 -06:00
Aris
f8694eb097 Fix/typos (#2633)
* Fix typos

* Collection minor fixes

Removes redundant .headOption on options
Replaces .exists(_ == ???) with .contains(???)
Replaces option == None with option.isEmpty
2021-02-07 15:00:25 -06:00
Chris Stewart
8f958bf5d9 Update scalafmt (#2619) 2021-02-03 16:37:12 -06:00
benthecarman
03ca6f617e Optimize filter sync and fetching filter heights (#2568) 2021-01-30 14:56:47 -06:00
Chris Stewart
2048cc0bbb Make ChainApi.processHeaders() return a failed future in the case we … (#2436)
* Rename NodeUnitTest.confg -> NodeUnitTest.getFreshConfig()

* Rename CachedBitcoinSAppConfig.config -> CachedBitcoinSAppConfig.cachedConfig

* Make CachedChainAppConfig extend CachedBitcoinSAppConfig

* Make ChainApi.processHeaders() return a failed future in the case we have no valid headers

* Run scalafmt

* Fix test case to check if promise is completed yet

* WIP: Get something working that isn't network specific

Start putting things back in place

Add comment

Revert logback file

Remove BitcoinSLogger object

* Fix unused import

* Get rid of annoying diff

* Fix spacing nit
2021-01-12 06:11:19 -06:00
Chris Stewart
51e9796b39 2021 01 11 issue 2493 (#2503)
* Rename NodeUnitTest.confg -> NodeUnitTest.getFreshConfig()

* Rename CachedBitcoinSAppConfig.config -> CachedBitcoinSAppConfig.cachedConfig

* Make CachedChainAppConfig extend CachedBitcoinSAppConfig

* use cached configs in both wallet/chain project as well taking ben's suggestion to fix those
2021-01-11 16:45:10 -06:00
Chris Stewart
b2560c4606 Rework BlockHeaderDAO.chainTips into two methods: BlockHeaderDAO.{get… (#2443)
* Rework BlockHeaderDAO.chainTips into two methods: BlockHeaderDAO.{getBestChainTips,getForkedChainTips}. getForkedChainTips is needed for reorg situations in the case a block header is received that builds off a stale tip

* Deduplicate BlockHeaderDAO.getBlockchains() that are subchains for the best chains
2021-01-01 09:04:29 -06:00
Chris Stewart
936d4e4911 Remove BlockHeader.getBlockchainsFrom(), rework type signature for Bl… (#2431)
* Remove BlockHeader.getBlockchainsFrom(), rework type signature for BlockHeader.getBlockchainFrom() to return Future[Option[Blockchain]]

* fix nits
2020-12-26 07:17:38 -06:00
Chris Stewart
d204056ad8 2020 12 19 enable test compileropts (#2400)
* Fix bug where test compiler opts were not enabled

* Fix all exsting compiler warnings in test project

* Add scalaCollectionCompat dependency to bitcoindRpcTest so we can use @nowarn annotation on scala 2.12
2020-12-20 07:09:07 -06:00
Chris Stewart
66ec96b1f5 2020 11 13 issue 2258 (#2260)
* Introduce ChainHandlerCached which behaves like the old ChainHandler. Now Chainhandler.getBestBlockHeader() will read headers from the database

* Remove ChainHandler.blockchains field, now it's only available in ChainHandlerCached

* De-futurify ChainHandler.fromDatabase()

* Adjust logging

* Patch test case

* Use BlockHeaderDAO.chainTips when getting best header rather thean BlockHeaderDAO.getBlockchains(). Implement a helper method ChainHandler.toChainHandlerCached()

* Fix chain.md,wallet.md

* Make ChainHandler.getBestBlockHeader() consider time of header if chainwork is the same. Make test cases less strict on what header is the best header when both chainwork and time are the same on the eader

* Only execute callbacks on headers that are going to be created in the database, not all headers passed into ChainHandler.processHeadersWithChains()

* Turn up log level again

* Small optimizations, check if we have seen a header before before processing it in ChainHandler.processHeadersWithChains(). Fix FilterSyncMarker.toString(). Use ChainHandlerCached in Node

* Remove ChainHandlerCached in appServer, re-add it in Node.scala
2020-11-17 06:19:07 -06:00
Chris Stewart
581d46c2c8 2020 11 02 cleanup (#2233)
* Cleanup a bunch of imports in test

* Use @nowarn annotation for testing things that are deprecated

* Fix base58 test

* Cleanup crypto-test

* Use scala collection compat dependency to get access to the @nowarn annotation on scala 2.12.x

* Rework more scala 2.13.x compile failures in chain-test and key-manager-test

* Optimize imports for entire project

* Fix nits
2020-11-03 11:07:04 -06:00
Chris Stewart
9b09b04230 Upgrade to scalac 2.13.3 (#2115) 2020-10-04 07:42:44 -05:00
Ben Carman
1e3aee55c3 Merge pull request #2019
* Refactor logging to only use grizzled slf4j

* Fix docs

* test travis config change
2020-09-19 14:09:12 -05:00
Ben Carman
ae6bab857f Increase chain test code coverage even more (#2028) 2020-09-17 16:25:08 -05:00
Ben Carman
16599010c7 Increase chain code coverage (#2023) 2020-09-16 16:24:25 -05:00
Chris Stewart
841230e35c Handle the case where our block headers are synced already (#2021) 2020-09-16 11:45:57 -05:00
Chris Stewart
76b9577181 Introduce 'FilterSyncMarker' to ChainApi, make it clearier what exact… (#2003)
* Introduce 'FilterSyncMarker' to ChainApi, make it clearier what exactly the (Int,DoubleSha256Digest) tuple is returned from ChainApi.nextBlockHeaderRange()

* Fix doc

* Add scaladoc to FilterSyncMarker

* Rebase onto master, fix conflicts to use FilterSyncMarker
2020-09-11 13:48:40 -05:00
Chris Stewart
2980e3fc01 Resolve issues with reorgs and syncing filters (#1969)
* Pull over test cases, WIP

* Rework ChainHandler.nextBlockHeaderRange() to use hashes rather than heights to very integrity of header chain, add test case

* Modify test case to make sure we are generating the 'heaviest chain work' header as first in the tuple that is used in reorg test cases

* Refactor to helper method called 'findNextHeader()' to make things simpler

* Add scaladoc to ChainHandler.findNextHeader()

* WIP

* Fix bugs in ChainApi.nextBlockHeaderRange(), now return (startHeight,stopHash) rather than (stopHeight,stopHash)

* Get chain handler tests passing, remove genesis filter header/fitler from default chain project fixture, make it a specialized one to have genesis filter header/filter in the database. Use that specialized fixture in ChainHandlerTest for now

* FilterSync work without having the genesis filter and filter header inserted into the database

* fix bug in DataMessageHandler where we were using sendNextGetCompactFilterHeadersCommand rather than using peerMsgSender.sendGetCompactFilterHeadersMessage

* Refactor ChainHandler.findNextHeader() to centralize where chains are fetched

* Address ben's code review
2020-09-11 12:41:25 -05:00
Chris Stewart
4149271b77 Segregate mainnet chainhandler tests and regtest chainhandler tests (#1988) 2020-09-09 09:50:24 -05:00
Ben Carman
4c0437e352 Optimize findClosestToTime (#1959)
* Optimize findClosestToTime

* Fix Test

* Rename function, change execption type
2020-09-08 09:23:41 -05:00
Chris Stewart
98236835a5 Rename ChainApi.nextHeaderBatchRange -> ChainApi.nextBlockHeaderBatchrnage (#1957) 2020-09-02 13:19:20 -05:00
Chris Stewart
170242812c Fix maxBy() exception in the case of empty Blockchain in ChainHandler… (#1934)
* Fix maxBy() exception in the case of empty Blockchain in ChainHandler.bestFilterHeaderSearch()

* Add another unit test to CompactFilterHeaderDAO for coverage
2020-08-29 15:29:09 -05:00
Chris Stewart
d3af9c2ccb Implement getBestFilterHeader based on a number of block headers that… (#1926)
* Implement getBestFilterHeader based on a number of block headers that can be passed in as a parameter. These headers can be used to indicate what your current best chain is

* Bring back compiler opts

* Fix compiler error for maxByOption as it isn't in the 2.12 std library

* Implement a context free best filter headers search. The basic strategy is to look at headers in the _future_ of our current best filter header

* Fix bug in sql query were we were doing max chainWork too early on block headers, we needed to filter out headers in our set and _then_ we get the max chain work

* Add more unit tests
2020-08-29 08:13:38 -05:00
Chris Stewart
3ab280a12b Remove AppConfig.initialize() in favor of AppConfig.start() (#1907)
* Remove AppConfig.initialize() in favor of AppConfig.start()

* Fix docs
2020-08-26 16:24:38 -05:00
rorp
23685f124e Add an ability to one Postgres database for all sub-projects (#1897)
* Add an ability to one Postgres database for all sub-projects
2020-08-26 12:20:18 -07:00
Ben Carman
f468fff7ea Move ChainApi to core (#1888)
* Move Chain Db Reps to core

* Move ChainApi to Core
2020-08-25 07:08:42 -05:00
Chris Stewart
3e8e9b0e85 2020 08 22 chaintest cleanup (#1877)
* Clean up code for BroadcastDAO test

* Extend StartStopAsync with BitcoinSAppConfig, create 'CachedAppConfig' test trait, clean up P2PClientTest

* Make MerkleBuffersTest use CachedAppConfig

* Start cleaning up after ourselves in the chainTest test suite

* Cancel background runnable for generating blocks after test case, add nodeAppConfig.stop() to tests in NodeAppConfigTest

* Stop mainnet nodeAppConfig in test as per ben's code review

* Refactor ChainUnitTest.withChainFixture() to use makeDependentFixture()

* Call .stop() for appConfig's spun up in ChainAppConfigTest

* Less parallelization on destruction of chainAppConfig

* Revert parallelExecution/fork jvm in CommonSettings
2020-08-24 11:20:02 -05:00
Chris Stewart
32f03bdf0b 2020 08 21 clean broadcast dao (#1875)
* Clean up code for BroadcastDAO test

* Extend StartStopAsync with BitcoinSAppConfig, create 'CachedAppConfig' test trait, clean up P2PClientTest

* Make MerkleBuffersTest use CachedAppConfig

* Start cleaning up after ourselves in the chainTest test suite

* Cancel background runnable for generating blocks after test case, add nodeAppConfig.stop() to tests in NodeAppConfigTest

* Stop mainnet nodeAppConfig in test as per ben's code review
2020-08-24 11:19:41 -05:00
rorp
b5a40035ce Refactor wallet DB (#1798)
* Refactor wallet DB

* fix create(), update() and upsert()

* remove accout foreign key

* fix wallet fixtures

* update Postgres schema

* update SQLite schema

* fix AddressHandlingTest

* fix SQLITE_BUSY exception in TransactionProcessing

* fix RescanHandlingTest

* revert NeutrinoNodeTest

* fix SpendingInfoDAOTest

* fix SQLITE_BUSY exceptions

* fix DbManagementTest

* fix "Task rejected" Slick exceptions in Postgres mode

* responded to the PR comments
2020-08-18 13:43:12 -05:00
Ben Carman
f7b9c5722f Use database to calculate number of confirmations (#1789)
* Use database to calculate number of confirmations

* Check block is in best chain

* Use db

* Optimize getNumberOfConfirmations

* Fix compile issue for older versions

* Add better logging messages

* More logs

* Update confs sequentially
2020-08-16 16:15:13 -05:00
Chris Stewart
380adb5cdb Batch and execute headers for chain work calculation test case, this … (#1837) 2020-08-15 14:05:01 -05:00
Chris Stewart
c9f78a2a40 2020 08 14 issue 1829 (#1833)
* Fix O(n^2) behavior in BaseBlockchain.connectWalkBackwards, cache BlockHeader.hash after the first time it is called

* Revert a few files
2020-08-15 07:31:50 -05:00
Chris Stewart
48e3cb8e14 Attempt to batch checking of headers in chainTest to avoid reject exe… (#1826)
* Attempt to batch checking of headers in chainTest to avoid reject execution exceptions in the scala slick database queue

* Fix 2.12 compile issue
2020-08-15 07:23:26 -05:00
Ben Carman
48a7f6f86e Remove default false for useLogbackConf (#1816)
* Remove default false for useLogbackConf

* Fix docs

* Set logging level to WARN for tests
2020-08-14 08:53:07 -05:00
Ben Carman
c3dc52ce90 Send GetHeadersMessage using all of our cached headers to prevent reorgs from stalling node (#1758)
* Send GetHeadersMessage using all of our cached headers to prevent reorgs from stalling node

* Add test, improve logging

* Start with correct chains

* Simplify error, change back to createAll
2020-08-10 13:04:12 -05:00
Ben Carman
cad6fbeaaf Fix getBlockchainsBetweenHeights (#1710)
* Fix getBlockchainsBetweenHeights

* Fix getBlockchainsBetweenHeights

* Fix compile issue for older version

* Improve test

* Optimizations
2020-07-29 16:36:22 -05:00
Ben Carman
b2b9ca7eec Create getBlockchainsBetweenHeights for BlockHeaderDAO (#1703)
* Create getBlockchainsBetweenHeights for BlockHeaderDAO

* Use reconstructFromHeaders instead
2020-07-27 13:14:29 -05:00
Ben Carman
20214ea821 Fix length of BigIntMapper (#1651)
* Fix length of BigIntMapper

* Fix for max value uint256
2020-07-09 14:44:55 -05:00
Scala Steward
97a4886c6e Update scalafmt-core to 2.6.0 (#1579)
* Update scalafmt-core to 2.6.0

* Upgrade scalafmt, fix all formatting errors

* Scalafmt on 2.12

* fix test

* More fixes

Co-authored-by: Ben Carman <benthecarman@live.com>
2020-06-19 10:38:12 -05:00