Commit graph

25168 commits

Author SHA1 Message Date
Pablo Greco
45fc81bfcc Merge commit '06b72ec82c' into elem-23.3.0rc3 2025-02-09 07:19:00 -08:00
Cory Fields
cad37df99f upnp: add compatibility for miniupnpc 2.2.8
See: c0a50ce33e

The return value of 2 now indicates:
"A valid connected IGD has been found but its IP address is reserved (non routable)"

We continue to ignore any return value other than 1.

(cherry picked from commit 8acdf66540)
2025-02-07 13:25:48 -08:00
Andrew Poelstra
ff6482fc29
fuzz: add SelectParams to rbf.cpp
We cannot fuzz RBF (or do anything mempool-related, really) without
chainparams. This has been true since 2019 at least. I suspect this fuzz
test has never really been run.
2025-02-06 21:31:47 +00:00
Andrew Poelstra
a3b7e71a3d
transaction: refuse to deserialize TxOuts with null values
In Bitcoin Core the notion of a "null" amount (and therefore a "null"
txout) is one which cannot be serialized or deserialized. In Core this
is implemented using a value of -1.

In Elements we use the CT notion of "nullness" which is that the flag on
the confidential value is 0. See d53479c9ff
which implemented this. This is reasonable, but because we don't have
checks on deserialization, we can deserialize objects that cannot be
reserialized.

In particular, in coins.h, we deserialize a coin by deserializing its
txout. When reserializing we assert that !out.IsNull(). This assertion
is hit by the `coins_deserialize` fuzztest.

There are a few potential fixes here:

* Remove the assertion from coins.h, which is there to catch logic bugs
  in Core, on the assumption that if they have no bugs then we don't
  either. This seems like a bad idea.
* Change "nullness" for amounts to be an encoding of -1, like in Core.
  This seems dangerous because we call `GetAmount` all over the place,
  and if this could return the -1 amount, this will likely blow
  something up. Probably this is safe for the same reason it is in Core
  -- that is, we never create null txouts except as sentinel values. But
  do you wanna bet that this is true now? That it'll always be true?
* Same as above, but assert that the amount is not null. This is safer
  than just blindly hoping that no overflows will occur but still not
  obviously safe.
* Refuse to deserialize null CT objects. This is impossible because we
  use null nonce values in txouts.
* Refuse to deserialize null CT values. Similarly, this is impossible
  because we use null values in null asset issuances, which are legal.
* Refused to deserialize CTxOuts with null values or assets.

We are going with the latter solution, because it is narrowly scoped,
does not increase the "crash surface" (we throw an exception, and we
already throw exceptions for other kinds of invalid serializations),
and is very unlikely to cause bugs (null values are invalid on the
network anyway; this is the first check in VerifyAmounts) (so are null
assets for that matter, which we maybe also should refuse to
deserialize).
2025-02-06 21:31:47 +00:00
Russell O'Connor
31d94775b3 Update to latest Simplicity
The main difference is that there is now explicit simplicity deallocation functions to go with the allocation functions in the API.
There are some minor changes to error message text.
The deserialization code is now automatically generated.
The are some other minor internal changes.
2025-02-04 12:14:25 -05:00
Russell O'Connor
7fc546656d Merge commit '3b60583dd2' into simplicity 2025-01-31 11:44:47 -05:00
Andrew Poelstra
b1b4e6d5c9 Sanitize libsimplicity
Without this patch, the --with-sanitizers config flag has no effect on
the copy of libsimplicity in Elements Core. This means that we aren't
running asan or tsan when we intend to, and also means that when fuzzing
we aren't instrumenting the Simplicity binary.

The result is extremely bad fuzz coverage and missed bugs.

ubsan suppression for simplicity sha256.c

ubsan detects when a left shift would overflow an integer type. This is
not UB (it would be if you tried to shift more than the type's width in
one shot) but "may be unintentional" and is therefore detected.

Add a whitelist to the giant list of whitelists.
2025-01-31 11:43:23 -05:00
Andrew Poelstra
1c871c8c20 interpreter: fix use-after-free in Simplicity init code
We have the code fragment `txTo.GetHash().begin()`, which takes a
transaction, computes its txid as a uint256, and then saves a pointer to
the internal data of the uint256.

However, in C++, expressions of the form a.b().c() lead to the return
value of `b` being dropped immediately after the call to `c`. This is
fine if `c` is something like `GetHex` which returns a new independently
allocated object with no pointers to its input. It is not fine for
`begin` which returns a pointer into the return value of `GetHash`.

So this fragment returns a dangling pointer, which is later used by the
Simplicity interpreter, leading to UB.

In practice this code appeared to work, possibly because the stack
layout was such that it actually did work ok. Or possibly because we
don't test with enough fidelity to tell that Simplicity's view of the
txid of a transaction was mangled.
2025-01-31 11:39:07 -05:00
Pablo Greco
1191d76821 Merge branch 'master' into elem-23.3.0-rc2 2025-01-23 05:47:52 -08:00
Byron Hambly
e7f32aac75
unblindconfidentialpair: update moneyrange check with asset 2025-01-17 13:09:11 +02:00
Byron Hambly
8dabb73663
moneyrange: check asset type 2025-01-17 13:09:10 +02:00
Byron Hambly
a3e0ce2e8c
amountfromvalue: add arg to check moneyrange 2025-01-17 13:09:10 +02:00
Pablo Greco
cd306bf8d3 Continue receiving data for the current messages, even when we select to send 2025-01-03 06:50:18 -08:00
Jeff Frontz
835c250465
Merge pull request #1380 from psgreco/elem-23.3.0-rc1
Prepare 23.3.0 rc1
2024-12-19 09:28:23 -05:00
Pablo Greco
867bfe30f9 Merge branch 'master' into elem-23.3.0-rc1 2024-12-17 08:34:38 -08:00
Pablo Greco
f138566ad3 Wallet: avoid scanning after the last known block 2024-12-17 05:35:31 -08:00
Pablo Greco
5de39247e6 Update help text for "acceptdiscountct" 2024-11-18 05:00:12 -08:00
Pablo Greco
22cc8dfe34 Accept by default discountct in liquidv1 2024-11-18 05:00:12 -08:00
Pablo Greco
cfd77df7b0 Merge branch 'master' into elem-23.3.0-rc1 2024-11-18 04:29:09 -08:00
Pablo Greco
e213060a12 Merge branch 'master-nochainstate' into elem-23.3.0-rc1 2024-11-18 04:28:02 -08:00
Pablo Greco
7398cfae87 Use LBTC instead of L-BTC in QT 2024-11-04 05:54:22 -08:00
Pablo Greco
96a0957d9d Revert "link: add simplicity to bitcoin-chainstate binary"
This reverts commit 2f2f3aac1e.
2024-10-08 08:27:25 -07:00
Andrew Poelstra
57ab101352
simplicity: copy activation threshold/period from taproot
Copy the parameters for mainnet because they seem to have worked fine
for Taproot and are therefore a good starting point for Simplicity.
Copy them for regtest so that we can also copy the functional test for
activation, without needing to change a whole bunch of numbers.
2024-10-08 14:41:40 +00:00
Andrew Poelstra
2532c4a6c4
rpc: add simplicity to getdeploymentinfo 2024-10-08 14:41:39 +00:00
Andrew Poelstra
3621e7adc0
liquid testnet: enable simplicity at all times
This will effectively activate Simplicity as soon as the sole Liquid
Testnet signer is updated.
2024-10-08 14:41:39 +00:00
Andrew Poelstra
850b82095c
disable simplicity on regtest
We want to test Simplicity activation using evbparams.
2024-10-08 14:41:39 +00:00
Andrew Poelstra
2f2f3aac1e
link: add simplicity to bitcoin-chainstate binary 2024-10-08 13:03:02 +00:00
Christian Lewe
508836028e Asset tests: Check script error
Compare the expected script error, parsed from JSON, with the actual
error that VerifyScript returns. If the JSON does not include an
expected error, then skip this check.
2024-10-07 14:39:10 -04:00
Russell O'Connor
4ca2411795 Asset tests: Parse Elements script errors
Take the existing function to parse script errors and extend it to parse
Elements errors. SCRIPT_ERR_ERROR_COUNT is not included because it is a
pseudo error.
2024-10-07 14:39:10 -04:00
Russell O'Connor
bcd508f409 Add Simplicity Deployment structure 2024-10-07 14:39:10 -04:00
Russell O'Connor
1698454c2a Add Simplicity verification
Unactivated.
2024-10-07 14:39:09 -04:00
Russell O'Connor
96fb8f5d15 Store hash_genesis_block in PrecomputedTransactionData.
This will be used by Simplicity.
2024-10-07 14:39:09 -04:00
Russell O'Connor
28553fdf67 Add Simplicity to the build system. 2024-10-07 14:39:09 -04:00
Russell O'Connor
8760cdd7be Merge commit 'f502c24196' as 'src/simplicity' 2024-10-07 14:38:29 -04:00
Russell O'Connor
52b92b8213 Cherry-pick <https://github.com/bitcoin/bitcoin/pull/27122>
Simplicity needs this fix.
2024-10-07 14:38:13 -04:00
Pablo Greco
00ddf91c31 Merge branch 'master' into elem-23.2.4-rc1 2024-09-25 09:37:34 -07:00
Byron Hambly
09c5068ab1
discount: fix weight calculation
Thanks to Jon Griffiths for picking up that the amount and nonce discount
should be multiplied by the witness scaling factor as they form part of
the base transaction.
2024-09-25 15:18:38 +02:00
Byron Hambly
d0f714638a
feat: add discountweight to TxToUniv 2024-09-20 14:39:13 +02:00
Pablo Greco
49549ab42b Merge branch 'master' into elem-23.2.3-rc2 2024-09-09 09:44:04 -07:00
Byron Hambly
f107021869
fix: discountct package mining 2024-09-09 12:03:33 +02:00
Pablo Greco
6ef35aca7b Merge branch 'master' into elem-23.2.3-rc1 2024-08-23 08:16:31 -07:00
Pablo Greco
5c04f7d9a0 Accept discount-ct by default in liquidtestnet 2024-08-19 08:29:18 -07:00
James Dorfman
639715df61
Merge pull request #1356 from delta1/discountct-blockmintxfee
fix: use discountvsize in miner if discount enabled
2024-08-19 11:27:01 -04:00
Byron Hambly
b0d6cde2d0
fix: use discountvsize in miner if discount enabled 2024-08-16 12:35:04 +02:00
Byron Hambly
c1bc7caff5
fix: size estimation for pegin transactions 2024-08-14 15:41:29 +02:00
Pablo Greco
b032722e30 Merge branch 'master' into elements-23.2.2-final 2024-07-24 06:28:07 -07:00
Byron Hambly
fdf3d1eab1
discount: update init doc for acceptdiscountct 2024-07-24 09:35:03 +02:00
Byron Hambly
47d6c34382
discount: fix override for creatediscountct 2024-07-24 09:34:16 +02:00
jhfrontz
9853992fd2 Ensure that arm-macos environments have sufficient QT thread stack 2024-07-17 17:32:24 -04:00
James Dorfman
c5e8a2be77
Merge pull request #1337 from ElementsProject/master
elements-23.x: merge master to prep release
2024-06-14 11:14:47 -04:00