Commit graph

99 commits

Author SHA1 Message Date
Andrew Poelstra
4268df69bc Merge 828bb776d2 into merged_master (Bitcoin PR #20750) 2021-06-24 17:22:15 +00:00
Andrew Poelstra
f250da483b Merge 8e1913ae02 into merged_master (Bitcoin PR #21062) 2021-06-22 22:39:50 +00:00
Andrew Poelstra
1670bdfa0b ci: fix benchmarks, fuzztests and unit tests
Includes a memory leak in the checkqueue unit test (but not in
the actual code). WE really need to switch our checkqueue to use
std::unique_pointer rather than bare pointers. But this would be
invasive enough that I want to do it in a followup PR.

Also pretty-much disable the validation_flush_cache unit test.
This is a stupid and irritating test which tries to unit-test
exact memory usage of std containers. It already has at least
one "remove wrong assumptions" update upstream and after many
tries I was unable to change all the magic numbers in a way
that'd consistently pass CI for Elements.

Also adds a couple ubsan suppressions about perfectly-legitimate
conversions of integer types.
2021-03-26 17:33:05 +00:00
Andrew Poelstra
22cf380984 Merge a993a7c675 into merged_master (Elements PR #960)
Several conflicts in the C++ code related to the new `flags` parameter
to `CheckSignature` and the corresponding function being renamed upstream
to `CheckSignatureECDSA`.

Several conflicts in the test harness as Steven sorta pulled the new
upstream ECKey module into the Python code, and the actual upstream
code was slightly different. Also needed to update the feature_taproot
code to always use the non-RANGEPROOF sighash since dynafed is not
enabled in the Taproot test.

Also had to pull the `set_wif` method out of `ECKey` and inline it because
otherwise it triggers a "circular inclusion" error between script.py (which
would pull in `base58_to_bytes` from address.py) and address.py (which now
pulls in some taproot EC related stuff from script.py).

Noticed that #960 does not test the "sighash rangeproof flag set but no
witnesses" case.
2021-03-25 23:46:21 +00:00
Steven Roose
691040a63d
Add SIGHASH_RANGEPROOF support 2021-02-22 15:19:09 +00:00
Carl Dong
3704433c4f scripted-diff: Invoke ::AcceptToMemoryPool with chainstate
-BEGIN VERIFY SCRIPT-
find_regex='\bAcceptToMemoryPool\(' \
    && git grep -l -E "$find_regex" -- src \
        | grep -v '^src/validation\.\(cpp\|h\)$' \
        | xargs sed -i -E 's@'"$find_regex"'@\0::ChainstateActive(), @g'
-END VERIFY SCRIPT-
2021-02-18 14:49:06 -05:00
gzhao408
f82baf0762 [refactor] return MempoolAcceptResult
This creates a cleaner interface with ATMP, allows us to make results const,
and makes accessing values that don't make sense (e.g. fee when tx is
invalid) an error.
2021-02-09 07:01:52 -08:00
Andrew Poelstra
ab283556b0 Merge db88db4727 into merged_master (Bitcoin PR #19339)
Changes API for AcceptToMemoryPool to no longer check maximum fee; we remove
this check from interfaces::CChain::testPeginClaimAcceptance. This is fine,
the check never should have been there (this method's job is to notice double
claim attempts and provide a more helpful message to the user; other mempool
failures should be caught later in the `claimrawpegin` logic when we call
`pwallet->commitTransaction` which actually subits to the mempool). It was
only checking fees because the API made it easier to do so than to not.
2020-11-30 15:50:18 +00:00
Andrew Poelstra
3ca887d480 Merge d052f5e6b7 into merged_master (Bitcoin PR #16841) 2020-11-27 21:29:55 +00:00
Andrew Poelstra
b75123826a Merge a998c5185b into merged_master (Bitcoin PR #18675) 2020-11-26 01:08:24 +00:00
Andrew Poelstra
fd37b7c5d6 Merge 54f812d9d2 into merged_master (Bitcoin PR #18673) 2020-11-26 01:08:23 +00:00
Andrew Poelstra
77cefac5f9 Merge 2755b2b109 into merged_master (Bitcoin PR #18010) 2020-11-14 16:52:12 +00:00
Andrew Poelstra
7c53615bb6 Merge af05bd9e1e into merged_master (Bitcoin PR #17891) 2020-11-14 16:52:07 +00:00
Andrew Poelstra
c4e2622681 Merge 3f8dbcd655 into merged_master (Bitcoin PR #16658) 2020-11-14 16:52:03 +00:00
Andrew Poelstra
fcc3e6c04c Merge ae6943620a into merged_master (Bitcoin PR #17407) 2020-11-09 23:10:14 +00:00
Andrew Poelstra
056b9bb06d Merge 46fc4d1a24 into merged_master (Bitcoin PR #17384) 2020-11-09 23:10:08 +00:00
Andrew Poelstra
bde84fefc4 Merge 3c40bc6726 into merged_master (Bitcoin PR #15921) 2020-11-09 21:20:48 +00:00
Andrew Poelstra
5115dbbf41 Merge 6519be6054 into merged_master (Bitcoin PR #13868) 2020-11-09 21:20:20 +00:00
Andrew Poelstra
028f2d94d1 Merge 85883a9f8e into merged_master (Bitcoin PR #16443) 2020-11-09 21:20:14 +00:00
Andrew Poelstra
a50b652932 Merge 735d6b57e7 into merged_master (Bitcoin PR #16227) 2020-11-09 03:58:21 +00:00
Andrew Poelstra
9274da2dfc Merge 7400135b79 into merged_master (Bitcoin PR #16278) 2020-11-09 03:58:17 +00:00
Andrew Poelstra
68d9951825 Merge d0f81a96d9 into merged_master (Bitcoin PR #16129) 2020-11-06 15:20:13 +00:00
Andrew Poelstra
f6f2aefae3 Merge 40c66bb3d1 into merged_master (Bitcoin PR #15855) 2020-10-29 16:50:16 +00:00
Andrew Poelstra
c91184f6c2 Merge b2a6b02161 into merged_master (Bitcoin PR #15948) 2020-10-29 02:36:55 +00:00
Andrew Poelstra
161bcd2ae8 Merge 78295e97b8 into merged_master (Bitcoin PR #15788) 2020-10-28 16:43:03 +00:00
John Newbery
b048b275d9 [validation] Remove absurdfee from accepttomempool
Mempool behavior should not be user-specific.
Checking that txfee is acceptable should be
the responsibility of the wallet or client, not
the mempool.
2020-10-05 04:55:01 -07:00
MeshCollider
b887060d06 Replace usage of GetScriptForWitness with GetScriptForDestination 2020-08-14 08:44:42 +12:00
MarcoFalke
a998c5185b
Merge #18675: tests: Don't initialize PrecomputedTransactionData in txvalidationcache tests
3718ae2ef8 [tests] Don't initialize PrecomputedTransactionData in txvalidationcache tests (John Newbery)

Pull request description:

  PrecomputedTransactionData is initialized inside CheckInputScripts(). No need to pre-initialize it before calling into CheckInputScripts().

  Normally, I wouldn't bother, but we're making changes to `PrecomputedTransactionData` in #17977 which would break these tests without removing these constructions. Might as well get these changes out of the way here.

ACKs for top commit:
  robot-visions:
    ACK 3718ae2ef8
  sipa:
    utACK 3718ae2ef8

Tree-SHA512: bc9c095035a7072a2a91941df38cdbb969e817264efbaa6dcb88cc3ab132d9264aa0751fa588d1a5e45f37b4d2bb1903cda078765f0bbcc87d9cc47cbec5356a
2020-04-19 06:18:21 -04:00
John Newbery
3718ae2ef8 [tests] Don't initialize PrecomputedTransactionData in txvalidationcache tests
PrecomputedTransactionData is initialized inside CheckInputScripts(). No need
to pre-initialize it before calling into CheckInputScripts().
2020-04-16 15:20:57 -04:00
MarcoFalke
fac5c37300
scripted-diff: Sort test includes
-BEGIN VERIFY SCRIPT-
 # Mark all lines with #includes
 sed -i --regexp-extended -e 's/(#include <.*>)/\1 /g' $(git grep -l '#include' ./src/bench/ ./src/test ./src/wallet/test/)
 # Sort all marked lines
 git diff -U0 | ./contrib/devtools/clang-format-diff.py -p1 -i -v
-END VERIFY SCRIPT-
2020-04-16 13:32:36 -04:00
Sebastian Falbesoner
b3c4d9bac6 test: rename test suite name "tx_validationcache_tests" to match filename
Quoting src/test/README.md, 'Adding test cases':
    "The file naming convention is `<source_filename>_tests.cpp`
     and such files should wrap their tests in a test suite
     called `<source_filename>_tests`."

Currently the unit test source file txvalidationcache_tests.cpp contains a unit
test suite with the name tx_validationcache_tests, which is fixed by this commit.
The following shell script shows that this is the only mismatch and for all other
unit test source files the test suite names are correct:

 #!/bin/bash
 shopt -s globstar
 for test_full_filename in **/*_tests.cpp; do
     test_name_file=`basename $test_full_filename .cpp`
     test_name_suite=`sed -n "s/^.*TEST_SUITE(\(.*_tests\).*$/\1/p" $test_full_filename`
     if [ $test_name_file != $test_name_suite ]; then
         echo "TestFilename: $test_name_file != TestSuitname: $test_name_suite"
     fi
 done
2020-01-27 22:44:02 +01:00
MarcoFalke
e09c701e01 scripted-diff: Bump copyright of files changed in 2020
-BEGIN VERIFY SCRIPT-
./contrib/devtools/copyright_header.py update ./
-END VERIFY SCRIPT-
2020-01-15 02:18:00 +07:00
MarcoFalke
3f8dbcd655
Merge #16658: validation: Rename CheckInputs to CheckInputScripts
3bd8db80d8 [validation] fix comments in CheckInputScripts() (John Newbery)
6f6465cefc scripted-diff: [validation] Rename CheckInputs to CheckInputScripts (John Newbery)

Pull request description:

  CheckInputs() used to check no double spends, scripts & sigs and amounts. Since
  832e074, the double spend and amount checks
  have been moved to CheckTxInputs(), and CheckInputs() now just validates
  input scripts. Rename the function to CheckInputScripts().

  Also fix incorrect comments.

ACKs for top commit:
  MarcoFalke:
    re-ACK 3bd8db80d8, did the rebase myself, checked the scripted diff 👡
  promag:
    ACK 3bd8db80d8 :trollface:

Tree-SHA512: 7b3f8597d210492798fb784ee8ea47ea6377519111190161c7cc34a967509013f4337304f52e9bedc97b7710de7b0ff8880e08cd7f867754567f82e7b02c794c
2020-01-02 11:09:00 -05:00
MarcoFalke
fa538813b1
scripted-diff: Replace ::mempool with m_node.mempool in tests
-BEGIN VERIFY SCRIPT-
 # tx pool member access (mempool followed by dot)
 sed --regexp-extended -i -e 's/(::)?\<mempool\>\.([a-zA-Z])/m_node.mempool->\2/g' $(git grep -l mempool ./src/test)
 # plain global (mempool not preceeded by dot, but followed by comma)
 sed --regexp-extended -i -e 's/([^\.])(::)?\<mempool\>,/\1*m_node.mempool,/g'     $(git grep -l mempool ./src/test)
-END VERIFY SCRIPT-
2019-11-15 13:40:14 -05:00
MarcoFalke
8888ad02e2
test: Replace recursive lock with locking annotations
Also, use m_node.mempool instead of the global
2019-11-15 13:40:08 -05:00
John Newbery
6f6465cefc scripted-diff: [validation] Rename CheckInputs to CheckInputScripts
CheckInputs() used to check no double spends, scripts & sigs and amounts. Since
832e0744cb, the double spend and amount checks
have been moved to CheckTxInputs(), and CheckInputs() now just validates
input scripts. Rename the function to CheckInputScripts().

-BEGIN VERIFY SCRIPT-
sed -i -E -e 's/CheckInputs\b/CheckInputScripts/g' $(git grep -l CheckInputs | grep -v doc/)
-END VERIFY SCRIPT-
2019-11-07 13:50:58 -05:00
MarcoFalke
faec28252c
scripted-diff: test: Move setup_common to test library
-BEGIN VERIFY SCRIPT-
 # Move files
 for f in $(git ls-files src/test/lib/); do git mv $f src/test/util/; done
 git mv src/test/setup_common.cpp                     src/test/util/
 git mv src/test/setup_common.h                       src/test/util/
 # Replace Windows paths
 sed -i -e 's|\\setup_common|\\util\\setup_common|g' $(git grep -l '\\setup_common')
 sed -i -e 's|src\\test\\lib\\|src\\test\\util\\|g'  build_msvc/test_bitcoin/test_bitcoin.vcxproj
 # Everything else
 sed -i -e 's|/setup_common|/util/setup_common|g'    $(git grep -l 'setup_common')
 sed -i -e 's|test/lib/|test/util/|g'                $(git grep -l 'test/lib/')
 # Fix include guard
 sed -i -e 's|BITCOIN_TEST_SETUP_COMMON_H|BITCOIN_TEST_UTIL_SETUP_COMMON_H|g' ./src/test/util/setup_common.h
 sed -i -e 's|BITCOIN_TEST_LIB_|BITCOIN_TEST_UTIL_|g'                     $(git grep -l 'BITCOIN_TEST_LIB_')
-END VERIFY SCRIPT-
2019-11-06 11:56:41 -05:00
John Newbery
3004d5a12d [validation] Remove fMissingInputs from AcceptToMemoryPool()
Handle this failure in the same way as all other failures: call Invalid()
with the reasons for the failure.
2019-10-29 15:46:45 -04:00
John Newbery
a27a2957ed [validation] Add CValidationState subclasses
Split CValidationState into TxValidationState and BlockValidationState
to store validation results for transactions and blocks respectively.
2019-10-29 15:46:45 -04:00
Matt Corallo
9b92538ade
Remove unused fScriptChecks parameter from CheckInputs
fScriptChecks = false just short-circuits the entire function, so
passing it in is entirely useless.
2019-08-26 16:27:58 -07:00
James O'Beirne
fae6ab6aed refactor: pcoinsTip -> CChainState::CoinsTip()
This aliasing makes subsequent commits easier to review; eventually CoinsTip()
will return the CCoinsViewCache managed by CChainState.
2019-08-06 13:13:06 -04:00
Andrew Chow
37a79a4fcc Move various SigningProviders to signingprovider.{cpp,h}
Moves all of the various SigningProviders out of sign.{cpp,h} and
keystore.{cpp,h}. As such, keystore.{cpp,h} is also removed.

Includes and the Makefile are updated to reflect this. Includes were largely
changed using:
git grep -l "keystore.h" | xargs sed -i -e 's;keystore.h;script/signingprovider.h;g'
2019-07-09 16:20:18 -04:00
Andrew Chow
d9becff4e1 scripted-diff: rename CBasicKeyStore to FillableSigningProvider
-BEGIN VERIFY SCRIPT-
git grep -l "CBasicKeyStore" | xargs sed -i -e 's/CBasicKeyStore/FillableSigningProvider/g'
-END VERIFY SCRIPT-
2019-07-09 16:20:18 -04:00
practicalswift
9a841696c1 tests: Reduce compilation time and unneccessary recompiles by removing unused includes in tests 2019-06-26 20:37:48 +02:00
practicalswift
eca9767673 Make reasoning about dependencies easier by not including unused dependencies 2019-06-02 17:15:23 +02:00
Steven Roose
52f6f6905b
WIP: Fix compilation after merge 2019-05-20 16:22:05 +01:00
Steven Roose
f4889a5253
UPSTREAM MERGE BROKEN: Merge upstream commit '519b0bc5dc' into master 2019-05-17 16:17:09 +01:00
MarcoFalke
fa3c651143
[refactor] interfaces: Add missing LockAnnotation for cs_main 2019-05-13 14:46:01 -04:00
Wladimir J. van der Laan
de5af41e35
Merge #15452: Replace CScriptID and CKeyID in CTxDestination with dedicated types
78e407ad0c GetKeyBirthTimes should return key ids, not destinations (Gregory Sanders)
70946e7fee Replace CScriptID and CKeyID in CTxDestination with dedicated types (Gregory Sanders)

Pull request description:

  The current usage seems to be an overloading of meanings. `CScriptID` is used in the wallet as a lookup key, as well as a destination, and `CKeyID` likewise. Instead, have all destinations be dedicated types.

  New types:
  `CScriptID`->`ScriptHash`
  `CKeyID`->`PKHash`

ACKs for commit 78e407:
  ryanofsky:
    utACK 78e407ad0c. Only changes are removing extra CScriptID()s and fixing the test case.
  Sjors:
    utACK 78e407a
  meshcollider:
    utACK https://github.com/bitcoin/bitcoin/pull/15452/commits/78e407ad0c26190a22de1bc8ed900164a44a36c3

Tree-SHA512: 437f59fc3afb83a40540da3351507aef5aed44e3a7f15b01ddad6226854edeee762ff0b0ef336fe3654c4cd99a205cef175211de8b639abe1130c8a6313337b9
2019-05-09 18:54:43 +02:00
James O'Beirne
631940aab2 scripted-diff: replace chainActive -> ::ChainActive()
Though at the moment ChainActive() simply references `g_chainstate.m_chain`,
doing this change now clears the way for multiple chainstate usage and allows
us to script the diff.

-BEGIN VERIFY SCRIPT-
git grep -l "chainActive" | grep -E '(h|cpp)$' | xargs sed -i '/chainActive =/b; /extern CChain& chainActive/b; s/\(::\)\{0,1\}chainActive/::ChainActive()/g'
-END VERIFY SCRIPT-
2019-05-03 15:02:54 -04:00