Commit graph

1043 commits

Author SHA1 Message Date
Andrew Poelstra
01766fafdf Merge c93e123dc7 into merged_master (Bitcoin PR bitcoin/bitcoin#22308) 2021-07-28 12:52:10 +00:00
Andrew Poelstra
2a28a2f2d1 Merge 672870ab7b into merged_master (Bitcoin PR bitcoin/bitcoin#22201) 2021-07-28 04:50:06 +00:00
Andrew Poelstra
8e462c9a98 Merge 74013641e0 into merged_master (Bitcoin PR bitcoin/bitcoin#22089) 2021-07-28 03:33:26 +00:00
Andrew Poelstra
cfa325712a Merge e172ea8804 into merged_master (Bitcoin PR bitcoin/bitcoin#22210) 2021-07-27 22:06:32 +00:00
Andrew Poelstra
be04e946b9 Merge 964d91b193 into merged_master (Bitcoin PR bitcoin/bitcoin#22130) 2021-07-25 15:24:50 +00:00
Andrew Poelstra
fcc12d7e2a Merge 3c393ef9e1 into merged_master (Bitcoin PR bitcoin/bitcoin#22149) 2021-07-23 00:28:01 +00:00
Andrew Poelstra
f806c13661 Merge 260b1d74fe into merged_master (Bitcoin PR bitcoin/bitcoin#22092) 2021-07-22 18:31:32 +00:00
Andrew Poelstra
f46e4fdf55 Merge 7e83e74e7f into merged_master (Bitcoin PR bitcoin/bitcoin#21178) 2021-07-20 12:32:17 +00:00
Andrew Poelstra
01b1d5f844 Merge c5ee0cc11a into merged_master (Bitcoin PR bitcoin/bitcoin#21989) 2021-07-19 13:07:08 +00:00
Andrew Poelstra
ec674d3ecb Merge d7a6bba949 into merged_master (Bitcoin PR bitcoin/bitcoin#22103) 2021-07-19 06:12:28 +00:00
Andrew Poelstra
ff5c2de782 Merge 0a909073dc into merged_master (Bitcoin PR bitcoin/bitcoin#22048) 2021-07-12 21:04:54 +00:00
Andrew Poelstra
11548bb33c Merge 778b920179 into merged_master (Bitcoin PR bitcoin/bitcoin#21945) 2021-07-12 12:52:18 +00:00
Andrew Poelstra
7447a3b352 Merge d8ae29ec8f into merged_master (Bitcoin PR bitcoin/bitcoin#21900) 2021-07-08 18:04:18 +00:00
Andrew Poelstra
ab1e80eb09 Merge 779aaa7f03 into merged_master (Bitcoin PR bitcoin/bitcoin#21754)
What a pain in the ass. This changes the `feature_cltv` functional test
to use the `MiniWallet`, an internal Pythonic wallet that produces
"signatures" consisting of several OP_NOPs in a row, so that this test
can be used when the wallet is disabled.

This means that the functions in feature_cltv which add a CLTV check and
change the locktime/sequence number no longer need to re-sign when they
change the txid, so they don't...HOWEVER, our Elements-specific
`feature_block_v4` test calls these functions with a real transaction
and depended on the re-signing behavior.

After several attempts at min-effort min-diff fixes I landed on this,
which simply sets the locktime at transaction creation and avoids having
to re-sign at all.

Also, I had to change the number of NOPs in the fake wallet code to make
a vsize assertion pass, presumably because of differences in Bitcoin/Elements
transaction serialization.
2021-07-06 13:53:02 +00:00
Andrew Poelstra
c4182106af Merge 2b45cf0bcd into merged_master (Bitcoin PR bitcoin/bitcoin#19521)
This is part of the "UTXO Set Statistics" project in Core, which aims
to make things like "checking coin supply" faster. This stuff, and
related things in coinstats.cpp, have always been broken for Elements
in the sense that we consider only explicit outputs and we ignore
assets (so everything just gets added together to get a meaningless
total). It probably wouldn't be too hard to restrict this to only
consider policyAsset, but it's out of scope for a rebase IMO.

Also, I think this situation is fine .. I don't understand the motivation
for this or why Core is merging this when they refuse to merge an address
index .. but I guess we'll see if there are users who care about this data
and who care about it being meaningful on Elements.

Also, apologies for the big diff -- there were some mechanical changes
to deal with CT amounts, but most of the changes related to the difference
in how fees are accounted for. While I'm not thrilled with this PR, its
functional test is really good! So I think what I eventually came up with
is internally consistent.
2021-07-04 19:51:38 +00:00
Andrew Poelstra
4485d3c785 Merge 40310f5e8c into merged_master (Bitcoin PR bitcoin/bitcoin#21792) 2021-07-03 22:18:16 +00:00
Andrew Poelstra
6b565b9878 Merge fb66dbe786 into merged_master (Bitcoin PR bitcoin/bitcoin#21762) 2021-07-03 13:46:53 +00:00
Andrew Poelstra
a02abbc35a Merge 7f37a1d560 into merged_master (Bitcoin PR bitcoin/bitcoin#21785) 2021-07-03 08:56:11 +00:00
Andrew Poelstra
b945a1dacf Merge a1f0b8b62e into merged_master (Bitcoin PR #21634) 2021-06-30 12:41:09 +00:00
Andrew Poelstra
d39d57c704 Merge 1c7be9ab90 into merged_master (Bitcoin PR #20286)
I hate this PR.
2021-06-28 21:30:17 +00:00
Andrew Poelstra
d976552b1c Merge 9b48b3ac42 into merged_master (Bitcoin PR #21390)
Diff reduction :) again just had to replace some fixed hashes
2021-06-28 15:54:24 +00:00
Andrew Poelstra
c1cf0e6fa4 Merge ed49203daa into merged_master (Bitcoin PR #21357) 2021-06-28 13:58:19 +00:00
Andrew Poelstra
d44ce3a73f Merge 8ec881d3b6 into merged_master (Bitcoin PR #20861) 2021-06-27 19:12:42 +00:00
Andrew Poelstra
90f1f6650b Merge fbf5d16238 into merged_master (Bitcoin PR #21246) 2021-06-26 01:58:32 +00:00
Andrew Poelstra
ac89deaff7 Merge c0e44ee8e4 into merged_master (Bitcoin PR #21254) 2021-06-25 15:52:53 +00:00
Andrew Poelstra
e99a9c186a Merge 2059d32edb into merged_master (Bitcoin PR #21200) 2021-06-25 13:13:25 +00:00
Andrew Poelstra
578ee6183f Merge a9335e4f12 into merged_master (Bitcoin PR #16546)
There are a few layers of bullshit to this PR.

First, there is the fact that it adds a functional test gated on a new
config flag which is disabled by default, so it actually adds broken
code with no tests, waiting to ruin your day 520 PRs later when #21935
enables the broken test.

Second, the test appears to be superficially nonsensical because it
generates two transactions from different wallets and tries to compare
them for byte-for-byte equality, which doesn't make sense (at least)
because change outputs are randomly located...so something fishy is
going on.

Of course, in Elements the transactions are *not* equal half the time
because the outputs are permuted, which may have let me quickly figure
out the issue, except...

Third, there is a red herring of a bug where the two transactions have
slightly different feerates. This turns out to be caused by
CWallet::CalculateMaximumSignedTxSize using differently sized dummy
transactions depending on whether watchonly outputs are included (this
fact is conveniently disguised by #17211 slightly changing this logic;
this is an unmerged PR in Core that Elements has a backport of an old
version of). And the two wallets have different watchonly settings.

A sub-red-herring is the fact that this bug results in a discrepancy
of 0.25 vbytes, so it does not appear in Core but does appear in
Elements (there is a 3/16 probability that we should be so unlucky...
we are).

But this is all irrelevant, because...

Fourth, this test is actually super bullshit. The way it works is by
constructing a PSBT legitimately, saving this to disk, then re-"signs"
using the external signer interface by using a mock signer that
COMPLETELY REPLACES THE TRANSACTION UNDER CONSTRUCTION. So it doesn't
matter what the fee output looks like and it doesn't matter what the
order of the outputs. Core does not detect this malfeasance and
neither does Elements. For some reason, Core has a functional test
that explicitly checks that you can do this even though it is insane
and it is hard to think of non-malicious reasons to do it.

Fifth, while Elements fails to detect that its external signer is
actually changing the transaction out from under it, it DOES assume
that this won't happen. In CWallet::SignPSBT it blithely un-replaces
the transaction, which undermines the functional test.

Sixth, the original PR where this test was introduced has comments
locked, so anyone who spent six hours reverse-engineering this idiotic
broken test, and is still feeling charitable enough to discuss it with
the Core developors, can go pound sand.

Anyway, just disabled the broken test and move on with our lives.
2021-07-27 00:19:01 +00:00
Andrew Poelstra
37c94c9100 Merge b805dbb0b9 into merged_master (Bitcoin PR #19809) 2021-06-24 13:52:54 +00:00
Andrew Poelstra
2cec742519 Merge 860f916803 into merged_master (Bitcoin PR #20524) 2021-06-24 13:40:22 +00:00
Andrew Poelstra
1c42ada28c Merge 69f7f50aa5 into merged_master (Bitcoin PR #20993) 2021-06-24 00:14:00 +00:00
Andrew Poelstra
59b1a731c8 Merge 8d6994f93d into merged_master (Bitcoin PR #21100) 2021-06-23 13:41:16 +00:00
MarcoFalke
fa27baa9c8
Revert "test: Add temporary logging to debug #20975"
This reverts commit faa94961d6.
2021-06-22 10:04:06 +02:00
MarcoFalke
672870ab7b
Merge bitcoin/bitcoin#22201: test: Fix TestShell to allow running in Jupyter Notebook
168b6c317c add dummy file param to fix jupyter (Josiah Baker)

Pull request description:

  this fixes argparse to use `parse_known_args`. previously, if an unknown argument was passed, argparse would fail with an `unrecognized arguments: %s` error.

  ## why
  the documentation mentions being able to run `TestShell` in a REPL interpreter or a jupyter notebook. when i tried to run inside a jupyter notebook, i got the following error:

  ![image](https://user-images.githubusercontent.com/7444140/121382910-57554880-c947-11eb-94f2-49da8679528c.png)

  this was due to the notebook passing the filename of the notebook as an argument. this is a known problem with notebooks and argparse, documented here: https://stackoverflow.com/questions/48796169/how-to-fix-ipykernel-launcher-py-error-unrecognized-arguments-in-jupyter

  ## testing
  to test, make sure you have jupyter notebooks installed. you can do this by running:
  ```
  pip install notebook
  ```
  or following instructions from [here](https://jupyterlab.readthedocs.io/en/stable/getting_started/installation.html).

  once installed, start a notebook (`jupyter notebook`), launch a python3 kernel and run the following snippet:

  ```python
  import sys

  # make sure this is the path for your system
  sys.path.insert(0, "/path/to/bitcoin/test/functional")
  from test_framework.test_shell import TestShell

  test = TestShell().setup(num_nodes=2, setup_clean_chain=True)
  ```

  you should see the following output, without errors:
  ![image](https://user-images.githubusercontent.com/7444140/121383301-a307f200-c947-11eb-83b6-6c50b2cada25.png)

  if you are unfamiliar with notebooks, here is a short guide on using them: https://jupyter.readthedocs.io/en/latest/running.html

ACKs for top commit:
  MarcoFalke:
    review ACK 168b6c317c
  jamesob:
    crACK https://github.com/bitcoin/bitcoin/pull/22201/commits/168b6c317ca054c1287c36be532964e861f44266
  practicalswift:
    cr ACK 168b6c317c

Tree-SHA512: 4fee1563bf64a1cf9009934182412446cde03badf2f19553b78ad2cb3ceb0e5e085a5db41ed440473494ac047f04641311ecbba3948761c6553d0ca4b54937b4
2021-06-22 08:11:16 +02:00
Josiah Baker
168b6c317c add dummy file param to fix jupyter
testshell in jupyter was failing due to an extra arg.
this adds a dummy -f param, which allows TestShell to
be used in a command line or jupyter environment
2021-06-21 17:12:16 +02:00
Andrew Poelstra
50a0a6246b Merge d48f9e8ebb into merged_master (Bitcoin PR #21124) 2021-06-21 14:32:43 +00:00
MarcoFalke
74013641e0
Merge bitcoin/bitcoin#22089: test: MiniWallet: fix fee calculation for P2PK and check tx vsize
d6d2ab9845 test: MiniWallet: fix fee calculation for P2PK and check tx vsize (Sebastian Falbesoner)
ce024b1c0e test: MiniWallet: force P2PK signature to have fixed size (71 bytes) (Sebastian Falbesoner)

Pull request description:

  This PR is a follow-up to #21945. It aims to both fix the fee calculation for P2PK mode transactions and enable its vsize check. Currently, the latter assumes a fixed tx length, which is fine for anyone-can-spend txs but doesn't apply to P2PK output spends due to varying DER signature size; the vsize check is therefore disabled for P2PK mode on master branch.

  Creating one million DER signatures with MiniWallet shows the following distribution of sizes (smart people with better math skills probably could deduce the ratios without trying, but hey):

  | DER signature size [bytes]  | #occurences (ratio) |
  | ------------- | ------------- |
  | 71  | 498893 (49.89%) |
  | 70 | 497244 (49.72%) |
  | 69 | 3837 (0.38%) |
  | 68 | 22 (0.0022%) |

  Note that even smaller signatures are possible (for smaller R and S values with leading zero bytes), it's just that the probability decreases exponentially.     Instead of choosing a large vsize check range and hoping that smaller signatures are never created (potentially leading to flaky tests), the proposed solution is ~~to limit the signature size to the two most common sizes 71 and 70 (>99.6% probability) and then accordingly only check for two vsize values; the value to be used for fee calculation is a decimal right between the two possible sizes (167.5 vbytes) and for the vsize check it's rounded down/up integer values are used.~~ to simply grind the signature to a fixed size of 71 bytes (49.89% probability, i.e. on average each call to `sign_tx()`, on average two ECC signing operations are needed).

  ~~The idea of grinding signatures to a fixed size (similar to https://github.com/bitcoin/bitcoin/pull/13666 which grinds to low-R values) would be counter-productive, as the signature creation in the test suite is quite expensive and this would significantly slow down tests that calculate hundreds of signatures (like e.g. feature_csv_activation.py).~~

  For more about transaction sizes on different input/output types, see the following interesting article: https://medium.com/coinmonks/on-bitcoin-transaction-sizes-97e31bc9d816

ACKs for top commit:
  MarcoFalke:
    Concept ACK d6d2ab9845

Tree-SHA512: 011c70ee0e4adf9ba12902e4b6c411db9ae96bdd8bc810bf1d67713367998e28ea328394503371fc1f5087a819547ddaea56c073b28db893ae1c0031d7927f32
2021-06-21 16:11:13 +02:00
Andrew Poelstra
323f9bf6cd Merge b401b09355 into merged_master (Bitcoin PR #21107) 2021-06-21 08:23:27 +00:00
Andrew Poelstra
bcd5f2207c Merge a6b1bf6439 into merged_master (Bitcoin PR #20267) 2021-06-21 02:52:43 +00:00
Andrew Poelstra
81622629c1 Merge 384e090f93 into merged_master (Bitcoin PR #19509) 2021-06-20 20:00:04 +00:00
Andrew Poelstra
4fc9d12dc4 Merge 4c55f92c76 into merged_master (Bitcoin PR #20954) 2021-06-20 02:12:30 +00:00
MarcoFalke
e172ea8804
Merge bitcoin/bitcoin#22210: test: Use MiniWallet in test_no_inherited_signaling RBF test
fa7d71f270 test: Run pep-8 on touched test (MarcoFalke)
fab7e99c2a test: Use MiniWallet in test_no_inherited_signaling RBF test (MarcoFalke)
fab871f649 test: Remove unused generate() from test (MarcoFalke)
faff3f35b7 test: Add txin.sequence option to MiniWallet (MarcoFalke)

Pull request description:

  This comes with nice benefits:
  * Less code and complexity
  * Test can be run without wallet compiled in

  Also add some additional checks for `getmempoolentry` (#22209) and other cleanups 🎨

ACKs for top commit:
  mjdietzx:
    Tested ACK fa7d71f270 thanks for the explanations, nicely done
  theStack:
    ACK fa7d71f270 🍷

Tree-SHA512: 0e9b8fe985779d8d7034d256deed627125bb374b6ae2972c461b3a220739a51061c6147ad69339bee16282f82716c7f3f8a7a89c693ceb1e47ea50709272332a
2021-06-19 08:47:52 +02:00
Andrew Poelstra
a9ab76769e Merge 11cbd4bb54 into merged_master (Bitcoin PR #17556)
This PR eliminates "strange regtest=0 behavior" in a test which had forced
us to disable the test for Elements. Can re-enable now :)

I also removed the `chain_in_args` parameter to `TestNode`, which Steven added
in https://github.com/ElementsProject/elements/pull/533 (which itself replaces
unconditionally adding chain={} on the command-line, which was added in #458).
These were added in the 0.17 rebase to deal with the job of starting bitcoind,
which then did not support the `chain=` command-line arg as well as elementsd,
which back then required this command-line arg.

This was causing some issues with the "check -acceptnonstdtxn doesn't work on
mainnet" test because it would add -chain=elementsregtest to the command-line
of a daemon that was supposed to be connecting to mainnet/liquidv1. It is
possible to override this behavior, but since 0.20+ versions of elementsd and
bitcoind have essentially the same support for chain= options, it seemed
cleaner to just eliminate the diff.
2021-06-18 14:40:09 +00:00
Andrew Poelstra
6e0871df92 Merge 32e59fc371 into merged_master (Bitcoin PR #20916) 2021-06-17 23:00:15 +00:00
Andrew Poelstra
89f673c0bd Merge 6af013792f into merged_master (Bitcoin PR #19315)
This uses a regtest-only RPC which checks that the chain is literally
"regtest". Since regtest is disabled in Elements (we use elementsregtest)
I weakened the check for this to just check that the chain name has
"regtest" somewhere in it. Hopefully this isn't too magical.
2021-06-17 17:31:47 +00:00
Andrew Poelstra
c3a8653b11 Merge 9c0b76c709 into merged_master (Bitcoin PR #20876) 2021-06-17 15:30:21 +00:00
Andrew Poelstra
c5a022192f Merge d7e2401c62 into merged_master (Bitcoin PR #18077) 2021-06-17 01:59:15 +00:00
Andrew Poelstra
6afa119596 Merge b6a71b80d2 into merged_master (Bitcoin PR #19055) 2021-06-16 22:36:48 +00:00
Andrew Poelstra
617905a928 Merge 34322b7f5c into merged_master (Bitcoin PR #20842) 2021-06-16 18:28:04 +00:00
Andrew Poelstra
27930edc9c Merge 4a540683ec into merged_master (Bitcoin PR #20813) 2021-06-16 14:11:07 +00:00
Andrew Poelstra
691fc96215 Merge 0e1b57b4bb into merged_master (Bitcoin PR #20763) 2021-06-16 03:40:29 +00:00