Skip to content

Instantly share code, notes, and snippets.

@delta1
Created April 4, 2023 08:14
Show Gist options
  • Save delta1/32a8fc5e0e33c0aab657d2970e233a75 to your computer and use it in GitHub Desktop.
Save delta1/32a8fc5e0e33c0aab657d2970e233a75 to your computer and use it in GitHub Desktop.
elements merging notes

merge notes for elements 24

please comment with

  • bitcoin PR / merged-master commit hash
  • notes about conflicts/resolution or things to keep track of
@jamesdorfman
Copy link

jamesdorfman commented Jul 11, 2023

delta1/elements@e3ab195

for Bitcoin PR bitcoin/bitcoin#22019

In src/wallet/spend.cpp
I think this variable that we kept should really be removed

-<<<<<<< HEAD
     CAmountMap mapValueFromPresetInputs;
-||||||| 09e60df115
-    CAmount nValueFromPresetInputs = 0;
-=======
->>>>>>> c840ab0231bc29057172179f005001c9ab299554

It doesn't appear to be used anywhere.

Update: fixed in jamesdorfman/elements@6a42ca5.

Additionally, in the following two asserts, let's note what upstream bitcoin notes the error at, in case someone is able to fix it in the future.

diff --git a/test/functional/rpc_psbt.py b/test/functional/rpc_psbt.py
index 72979b9a88..f556e776e7 100755
--- a/test/functional/rpc_psbt.py
+++ b/test/functional/rpc_psbt.py
@@ -1134,7 +1134,8 @@ class PSBTTest(BitcoinTestFramework):
         ext_utxo = self.nodes[0].listunspent(addresses=[addr])[0]
 
         # An external input without solving data should result in an error
-        assert_raises_rpc_error(-4, "Missing solving data for estimating transaction size", self.nodes[1].walletcreatefundedpsbt, [ext_utxo], [{self.nodes[0].getnewaddress(): 10 + ext_utxo['amount']}], 0, {'add_inputs': True})
+        # ELEMENTS: minor FIXME error is different since SelectCoins no longer has the error out
+        assert_raises_rpc_error(-4, "Insufficient funds", self.nodes[1].walletcreatefundedpsbt, [ext_utxo], [{self.nodes[0].getnewaddress(): 10 + ext_utxo['amount']}], 0, {'add_inputs': True})
 
         # But funding should work when the solving data is provided
         psbt = self.nodes[1].walletcreatefundedpsbt([ext_utxo], [{self.nodes[0].getnewaddress(): 15}], 0, {'add_inputs': True, "solving_data": {"pubkeys": [addr_info['pubkey']], "scripts": [addr_info["embedded"]["scriptPubKey"]]}})
diff --git a/test/functional/wallet_send.py b/test/functional/wallet_send.py
index 9ad0f015e4..97720b47a1 100755
--- a/test/functional/wallet_send.py
+++ b/test/functional/wallet_send.py
@@ -508,7 +508,8 @@ class WalletSendTest(BitcoinTestFramework):
         ext_utxo = ext_fund.listunspent(addresses=[addr])[0]
 
         # An external input without solving data should result in an error
-        self.test_send(from_wallet=ext_wallet, to_wallet=self.nodes[0], amount=15, inputs=[ext_utxo], add_inputs=True, psbt=True, include_watching=True, expect_error=(-4, "Missing solving data for estimating transaction size"))
+        # ELEMENTS: minor FIXME error is different since SelectCoins no longer has the error out
+        self.test_send(from_wallet=ext_wallet, to_wallet=self.nodes[0], amount=15, inputs=[ext_utxo], add_inputs=True, psbt=True, include_watching=True, expect_error=(-4, "Insufficient funds"))

Update: the first FIXME comment was removed during a subsequent merge, the second FIXME comment was updated in jamesdorfman/elements@b6f5c2d.

@jamesdorfman
Copy link

jamesdorfman commented Jul 12, 2023

delta1/elements@fa3c0f4

for Bitcoin PR bitcoin/bitcoin#23789

The # With no arguments passed, expect fee of 141 satoshis. comment from upstream should not have been removed:

+++ b/test/functional/rpc_fundrawtransaction.py
@@ -827,39 +827,10 @@ class RawTransactionsTest(BitcoinTestFramework):
         for param, zero_value in product(["fee_rate", "feeRate"], [0, 0.000, 0.00000000, "0", "0.000", "0.00000000"]):
             assert_equal(self.nodes[3].fundrawtransaction(rawtx, {param: zero_value})["fee"], 0)
 
-<<<<<<< HEAD
-        if self.options.descriptors:
-            # With no arguments passed, expect fee of 153 satoshis as descriptor wallets now have a taproot output.
-            assert_approx(node.fundrawtransaction(rawtx)["fee"], vexp=0.00001386, vspan=0.00000001)
-            # Expect fee to be 10,000x higher when an explicit fee rate 10,000x greater is specified.
-            result = node.fundrawtransaction(rawtx, {"fee_rate": 1000}) # ELEMENTS: reduce by 10x
-            assert_approx(result["fee"], vexp=0.01386, vspan=0.0001)
-        else:
-            # With no arguments passed, expect fee of 141 satoshis as legacy wallets only support up to segwit v0.
         assert_approx(node.fundrawtransaction(rawtx)["fee"], vexp=0.00001374, vspan=0.00000001)
         # Expect fee to be 10,000x higher when an explicit fee rate 10,000x greater is specified.
         result = node.fundrawtransaction(rawtx, {"fee_rate": 1000}) # ELEMENTS: reduce by 10x
         assert_approx(result["fee"], vexp=0.01374, vspan=0.0001)
-||||||| 9ac064d245
-        if self.options.descriptors:
-            # With no arguments passed, expect fee of 153 satoshis as descriptor wallets now have a taproot output.
-            assert_approx(node.fundrawtransaction(rawtx)["fee"], vexp=0.00000153, vspan=0.00000001)
-            # Expect fee to be 10,000x higher when an explicit fee rate 10,000x greater is specified.
-            result = node.fundrawtransaction(rawtx, {"fee_rate": 10000})
-            assert_approx(result["fee"], vexp=0.0153, vspan=0.0001)
-        else:
-            # With no arguments passed, expect fee of 141 satoshis as legacy wallets only support up to segwit v0.
-            assert_approx(node.fundrawtransaction(rawtx)["fee"], vexp=0.00000141, vspan=0.00000001)
-            # Expect fee to be 10,000x higher when an explicit fee rate 10,000x greater is specified.
-            result = node.fundrawtransaction(rawtx, {"fee_rate": 10000})
-            assert_approx(result["fee"], vexp=0.0141, vspan=0.0001)
-=======
-        # With no arguments passed, expect fee of 141 satoshis.
-        assert_approx(node.fundrawtransaction(rawtx)["fee"], vexp=0.00000141, vspan=0.00000001)
-        # Expect fee to be 10,000x higher when an explicit fee rate 10,000x greater is specified.
-        result = node.fundrawtransaction(rawtx, {"fee_rate": 10000})
-        assert_approx(result["fee"], vexp=0.0141, vspan=0.0001)
->>>>>>> 3ac38058ce0e80a9f4276bfa82951decdb237e9a

Update: fixed in jamesdorfman/elements@8b21677.

@jamesdorfman
Copy link

jamesdorfman commented Jul 12, 2023

delta1/elements@8886cea

for Bitcoin PR bitcoin-core/gui#459

TODO: sync with @delta1 on this -- what does taproot look like in elements? Do we merge each PR as-is, or did we make changes to taproot for elements. What were these changes?

Update: main difference is that elements sighashes require the genesis block. See https://github.com/ElementsProject/elements/blob/master/doc/taproot-sighash.mediawiki for more info.

@jamesdorfman
Copy link

jamesdorfman commented Jul 13, 2023

delta1/elements@42605e2

for Bitcoin PR bitcoin/bitcoin#23866

I think the upstream deletion of self.setup_clean_chain = True should also have been removed from Elements:

diff --git a/test/functional/rpc_scantxoutset.py b/test/functional/rpc_scantxoutset.py
index 0142a89050..ffc814c02b 100755
--- a/test/functional/rpc_scantxoutset.py
+++ b/test/functional/rpc_scantxoutset.py
@@ -22,14 +22,9 @@ def descriptors(out):
 class ScantxoutsetTest(BitcoinTestFramework):
     def set_test_params(self):
         self.num_nodes = 1
-<<<<<<< HEAD
         self.setup_clean_chain = True
         # ELEMENTS: use bitcoin regtest prefixes to avoid having to rewrite the entire test
         self.extra_args = [["-pubkeyprefix=111", "-scriptprefix=196", "-secretprefix=239", "-extpubkeyprefix=043587CF", "-extprvkeyprefix=04358394", "-bech32_hrp=bcrt"]]
-||||||| a213bd63ca
-        self.setup_clean_chain = True
-=======
->>>>>>> d3582f2d3bfebb32316aa3974f6f27db20a610f5

Update: the functional test fails if I remove this line, let's keep it in.

@jamesdorfman
Copy link

delta1/elements@5c8aae9

for Bitcoin PR bitcoin/bitcoin#23909

If the dmg generation fails in CI / testing, it might be because we removed the libicns and imagemagick dependencies, which were not removed in upstream (because they did not exist):

diff --git a/doc/build-osx.md b/doc/build-osx.md
index 0dbd37afc5..bf20a0dd52 100644
--- a/doc/build-osx.md
+++ b/doc/build-osx.md
@@ -218,18 +218,6 @@ This command depends on a couple of python packages, so it is required that you
 Ensuring that `python` is installed, you can install the deploy dependencies by running the following commands in your terminal:
 
 ``` bash
-<<<<<<< HEAD
-brew install librsvg libicns imagemagick
-```
-
-``` bash
-||||||| 1aabbf33d7
-brew install librsvg
-```
-
-``` bash
-=======
->>>>>>> 3e5dd94c423bedfa8b70a1e00df632a22dbd4574
 pip3 install ds_store mac_alias

@jamesdorfman
Copy link

jamesdorfman commented Jul 14, 2023

delta1/elements@7878ba4

for Bitcoin PR bitcoin/bitcoin#23497

These two lines can be removed:

diff --git a/src/wallet/coinselection.h b/src/wallet/coinselection.h
index aeea1e550b..816c9872e9 100644
--- a/src/wallet/coinselection.h
+++ b/src/wallet/coinselection.h
@@ -15,6 +15,9 @@
 
 #include <optional>
 
+// class CWallet;
+// class uint256;
+

Update: removed in jamesdorfman/elements@ed9beba.

@jamesdorfman
Copy link

jamesdorfman commented Jul 14, 2023

delta1/elements@7d759da

for Bitcoin PR bitcoin/bitcoin#23201

The following assert was commented out without any notes. Let's add a note that this was just for Elements, and note it in this gist as well.

diff --git a/test/functional/rpc_fundrawtransaction.py b/test/functional/rpc_fundrawtransaction.py

-        assert_fee_amount(funded_tx4["fee"], tx4_vsize, Decimal(0.0001))
+        # assert_fee_amount(funded_tx4["fee"], tx4_vsize, Decimal(0.0001))

Same with the following assert in this file:

diff --git a/test/functional/wallet_send.py b/test/functional/wallet_send.py

-        assert_fee_amount(testres["fees"]["base"], testres["vsize"], Decimal(0.0001))
+        # assert_fee_amount(testres["fees"]["base"], testres["vsize"], Decimal(0.0001))

Update: I understand why these are commented out -- fees are very different between bitcoin and elements. I added comments to the ends of both of these assertion lines, in jamesdorfman/elements@dca9352.

@jamesdorfman
Copy link

jamesdorfman commented Jul 14, 2023

delta1/elements@c53eb39

for Bitcoin PR bitcoin/bitcoin#24035

Upstream removed the extra fee but we didn't. Should we?

diff --git a/test/functional/mempool_accept.py b/test/functional/mempool_accept.py
index 6113deae1c..fdc23b507f 100755
--- a/test/functional/mempool_accept.py
+++ b/test/functional/mempool_accept.py

         tx = tx_from_hex(raw_tx_0)
-<<<<<<< HEAD
         tx.vout[0].nValue.setToAmount(tx.vout[0].nValue.getAmount() - int(4 * fee * COIN))  # Set more fee
         tx.vout[1].nValue.setToAmount(tx.vout[1].nValue.getAmount() + int(4 * fee * COIN))
-        # skip re-signing the tx
-||||||| 767ee2e3a1
-        tx.vout[0].nValue -= int(4 * fee * COIN)  # Set more fee
-        # skip re-signing the tx
-=======
-        tx.vout[0].nValue -= int(4 * fee * COIN)  # Set more fee
->>>>>>> 807169e10b4a18324356ed6ee4d69587b96a7c70

Update: no we can't. The test fails without this extra fee, with the following error:

AssertionError: not([{'txid': 'e2b2d9feda958b9a0d74e0f13069c4bb5beacf69f0a82ca69eedaf13fb89416a', 'allowed': False, 'reject-reason': 'txn-mempool-conflict'}] == [{'txid': 'e2b2d9feda958b9a0d74e0f13069c4bb5beacf69f0a82ca69eedaf13fb89416a', 'allowed': False, 'reject-reason': 'txn-already-in-mempool'}])

@jamesdorfman
Copy link

jamesdorfman commented Jul 17, 2023

delta1/elements@5931d7d

for Bitcoin PR bitcoin/bitcoin#23508

Check this out -- this PR removed the following lines:

diff --git a/test/functional/rpc_blockchain.py b/test/functional/rpc_blockchain.py
index 3ef94e1f25..19c2387b66 100755
--- a/test/functional/rpc_blockchain.py
+++ b/test/functional/rpc_blockchain.py
@@ -160,25 +160,6 @@ class BlockchainTest(BitcoinTestFramework):
         self.start_node(0, extra_args=[
             '-stopatheight=207',
             '-prune=550',
-<<<<<<< HEAD
-            '-testactivationheight=bip34@2',
-            '-testactivationheight=dersig@3',
-            '-testactivationheight=cltv@4',
-            '-testactivationheight=csv@5',
-            '-testactivationheight=segwit@6',
-            # ELEMENTS
-            "-con_bip34height=2",
-            "-con_bip66height=3",
-            "-con_bip65height=4",
-            "-con_csv_deploy_start=5",
-||||||| a4f7c41271
-            '-testactivationheight=bip34@2',
-            '-testactivationheight=dersig@3',
-            '-testactivationheight=cltv@4',
-            '-testactivationheight=csv@5',
-            '-testactivationheight=segwit@6',
-=======
->>>>>>> d4e92d843650b0480b86d15ce46ed02b6fd9b5be

We treated it like a deletion. However, they were actually moved (I found this in the original PR), lower in that same file test/functional/rpc_blockchain.py:

 def _test_getdeploymentinfo(self):
        # Note: continues past -stopatheight height, so must be invoked
        # after _test_stopatheight

        self.log.info("Test getdeploymentinfo")
        self.stop_node(0)
        self.start_node(0, extra_args=[
            '-testactivationheight=bip34@2',
            '-testactivationheight=dersig@3',
            '-testactivationheight=cltv@4',
            '-testactivationheight=csv@5',
            '-testactivationheight=segwit@6',
        ])

So, we need to add

# ELEMENTS
"-con_bip34height=2",
"-con_bip66height=3",
"-con_bip65height=4",
"-con_csv_deploy_start=5",

there as well.

Update: upon further review of the commit, these arguments were already correctly added during the commit. I think the 4-way diff Wass just being strange. This is not actually an issue.

@jamesdorfman
Copy link

jamesdorfman commented Jul 20, 2023

delta1/elements@eef2269

for Bitcoin PR bitcoin/bitcoin#24343

TODO: revisit failing test (I will do it when I'm done going through everything)

Update: fixed in jamesdorfman/elements@2ab19eb

@jamesdorfman
Copy link

jamesdorfman commented Jul 20, 2023

delta1/elements@51fbed1

for Bitcoin PR bitcoin/bitcoin#24409

Not specifically related to this commit, but we need to update the PACKAGE_NAME variable in file build_msvc/bitcoin_config.h.ini.
It's currently set to

/* Define to the full name of this package. */
#define PACKAGE_NAME "Bitcoin Core"

Update: fixed in jamesdorfman/elements@c37b88c

@jamesdorfman
Copy link

delta1/elements@055d634

for Bitcoin PR bitcoin/bitcoin#24451

Confirm with @delta1 -- your commit message says All conflicts in the locale translation files were resolved by taking the upstream version of the files.. I want to confirm that by upstream, you mean bitcoin. If that is the case, then I agree with this solution.

@delta1
Copy link
Author

delta1 commented Jul 20, 2023

delta1/elements@055d634

for Bitcoin PR bitcoin/bitcoin#24451

Confirm with @delta1 -- your commit message says All conflicts in the locale translation files were resolved by taking the upstream version of the files.. I want to confirm that by upstream, you mean bitcoin. If that is the case, then I agree with this solution.

@jamesdorfman yes exactly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment