Commit Graph

140 Commits

Author SHA1 Message Date
Chris Stewart
d46b4a6c91
Make logging to file async, remove neverBlock configuration so that we are guaranteed to capture logs (#4305) 2022-05-01 06:45:33 -05:00
rorp
48189d5c1d
Make CRUD.run and CRUD.runVec transactional (#4059)
* Make `CRUD.run` and `CRUD.runVec` transactional

* remove explicit `transactionally` calls
2022-02-07 17:42:48 -06:00
benthecarman
142612f034
Make newConfigOfType use Vector[Config] (#4039) 2022-02-04 06:14:16 -06: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
7ee1f0f406
Implement batching of database calls for our chain callback (#4003) 2022-01-23 07:39:10 -06:00
Chris Stewart
ee0d62c5b8
2022 01 14 DLCDataManagement refactor (#3982)
* WIP

* Finish refactor, get unit tests working

* Remove log
2022-01-18 08:12:27 -06:00
rorp
4b07629d56
Add getmediantimepast RPC call (#3921)
* Add `getmediantimepast` RPC call

* update docs

* respond to the PR comments
2021-12-22 16:15:30 -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
4f7b6422ea
2021 08 06 app config refacotr (#3498)
* Move AppConfig into app-commons, reduce classpath deps on keyManager,tor

* Move test ServerArgParserTest

* Fix compile error
2021-08-07 14:36:11 -05:00
Chris Stewart
639043227c
Add logs to make it more apparent that No Common Ancestors isn't necessarily bad (#3354)
* Add logs to make it more apparent that No Common Ancestors isn't necessarily a bad thing

* Switch No common ancestor log message to DEBUG
2021-06-30 09:58:43 -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
benthecarman
8432712dba
Fix sbt deprecation warnings (#3163) 2021-05-27 06:28:32 -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
benthecarman
07514e2348 Remove logging from core (#2810)
* Remove logging from core

* Remove slf4j from testkit core

* Remove logback from coretest
2021-03-21 19:11:55 -05:00
Aris
85087b0f70 Refactoring chain (#2662) 2021-02-13 14:10:40 -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
Chris Stewart
35d58e6429 Reduce number of rows selected by best filter header/best filter query (#2617)
* Reduce number of rows selected by best filter header/best filter query

* Remove benchmarking code

* use same queries for best height and best filter so we don't repeat ourselves

* join by blockhash

* Apply optimization to compact filter table

Co-authored-by: Ben Carman <benthecarman@live.com>
2021-02-03 11:37:36 -06:00
benthecarman
22e373e63d Fix bestblockhash rpc call (#2612) 2021-02-02 13:03:05 -06:00
benthecarman
03ca6f617e Optimize filter sync and fetching filter heights (#2568) 2021-01-30 14:56:47 -06:00
Chris Stewart
756bfc4427 2021 01 27 conectionpool (#2578)
* Give connection pool example config

* Get hikari logging working on postgres

* fix 2.12.x

* Bump metrics core to a supported version

* Add hikari-logging and hikari-logging-interval configuration options to turn off/on hikari and schedule how often logs appear

* Turn off hikari logging in the db-commons/reference.conf and add it to appserver/reference.conf

* default the logging to off in scala code

* Make sure connection pool is enabled in db-commons, add default database configuration to website

* Address code review, fix things that didn't need to be changed
2021-01-28 09:44:03 -06:00
benthecarman
29bde74cb8 Fix all DAOs to use safeDatabase (#2556) 2021-01-22 16:13:45 -06:00
benthecarman
e10e278aa4 Add walletinfo rpc (#2546)
* Add walletinfo rpc

* Move rootXpub to key manager obj

* Make configuration keys for getinfo the same as the ones in our configuration files

* Cleanup

Co-authored-by: Chris Stewart <stewart.chris1234@gmail.com>
2021-01-22 13:55:21 -06:00
benthecarman
0d07d558c4 Optimize node.start() and fetching filter & filter header heights (#2554)
* Make node.start() more async

* Add missing filter indexes

* Move queries to vals
2021-01-22 10:38:32 -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
98ace6f14e 2021 01 02 issue 2457 (#2461)
* WIP

* Get neutrino node with wallet 'receive information about received payments' working again

* Fix compile

* Remove initial sync logic from test case

* Remove sync logic in NeutrinoNodeWithWallet test cases

* Improve logging and rename a few things

* WIP2

* WIP3

* Get NeutrinoNodeWithWallet tests working

* Implement WalletSync, which allows you to sync a wallet from a arbitrary data source

* Get all tests passing again

* Use spv.appConfig in DataMessageHandlerTest rather than caching the config

* Modify cleanup to hopefully get CI passing

* Fix postgres tests by cleaning the table during the destroy phase of the test fixture. This is needed because the same postgres database is shared between tests in the same test suite

* Revert logback-test.xml

* Get sqlite/postgres tests passing pt 2

* syncHeight -> syncDescriptorOpt()

* Add case for genesis block hash in WalletSync

* Fix SpvNodeWithWallet test case to actually test spv functionality

* Remove nodeCallbacks parameters, callbacks should be registered on nodeAppConfig
2021-01-09 09:33:37 -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
Ben Carman
1225584526 Multi Wallet support (#2345)
* Multi Wallet support

* Fix Oracle tests

* Fix some CI errors

* Increase KeyManagerAppConfig code coverage

* Add test for multiple seeds in seed folder

* Move things in reference.conf files

* Lower key manager coverage requirement

* Fix postgres test issues

* Create DbAppConfig

* Add some docs, fix hardcoded postgres db name

* Clarify db vs schema

* Add character types

* Fix chaindb in conf

* Always copy default seed

* Remove need for driverName config
2020-12-16 17:27:56 -06:00
Chris Stewart
f586e25699 Get Scala 2.13.4 compiling (#2294)
* Get Scala 2.13.4 compiling

* Fix broken test case, in general use if() else() statements for Vectors rather than pattern match as I am unsure of how to correctly pattern match on Vector0,Vector1,...,Vector6()

* Bump CI to 2.13.4

* OVerride CurrencyUnit.equals() so that it works on Scala 2.13.4, not sure why there was a regression here between Scala versions 2.13.4/2.13.3

* Add explicit unit tests making sure bitcoin/satoshi currency units are equivalent
2020-11-28 07:36: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
ade2503702 2020 10 05 redo config (#2121)
* Use absolute paths for resolving configurations

Make log level OFF again

WIP: Move resolution of config into AppConfig.start(), things are totally broken

WIP: Make AppConfig.config private

Get all tests passing again but using absolute path in configuration

* Cherry-pick onto master

* Fix BitcoinSAppConfig configuration keys to use the full path

* Apply code review

* Fix log, move invariant for requiredConfirmations back into the lazy val

* Fix DlcOracleAppConfig to use absolute path
2020-10-05 18:00:30 -05:00
Chris Stewart
9b09b04230 Upgrade to scalac 2.13.3 (#2115) 2020-10-04 07:42:44 -05:00
Ben Carman
11e6b7d9eb Initial SigNet support (#2057) 2020-09-25 12:29:13 -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
857b33f31f Make ChainApi.getHeadersBetween() be inclusive on the 'from' parameter (#2009)
* Make ChainApi.getHeadersBetween() be inclusive on the 'from' parameter

* Use ben's suggestion of comparing hashes
2020-09-12 11:13:03 -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
rorp
c62be8b5f6 Update callbacks for LN support (#1938)
Update callbacks for LN support
2020-09-09 11:02:31 -07: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
8b76acd042 Move getBestFilterHeader() use the best chain by chainwork for determining the fitler header (#1964) 2020-09-02 19:41:52 -05:00
Ben Carman
f5fcab9580 Change maxBy and minBys to use maxByOption and minByOption (#1961)
* Change maxBy and minBys to use maxByOption and minByOption

* Fix compile issue
2020-09-02 16:03:57 -05:00
Chris Stewart
98236835a5 Rename ChainApi.nextHeaderBatchRange -> ChainApi.nextBlockHeaderBatchrnage (#1957) 2020-09-02 13:19:20 -05:00
Ben Carman
1670902e75 Fix max by for getBlockCount (#1951)
* Fix max by for getBlockCount

* Add helper func to package
2020-09-01 19:38:15 -05:00