Skip to content

Commit f8add43

Browse files
committed
Merge remote-tracking branch 'origin/master' into elements-22-fix-ci
2 parents 829c2de + cfc10a5 commit f8add43

File tree

8 files changed

+532
-10
lines changed

8 files changed

+532
-10
lines changed

ci/test/04_install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ DOCKER_EXEC df -h
8686

8787
if [ "$RUN_FUZZ_TESTS" = "true" ] || [ "$RUN_UNIT_TESTS" = "true" ] || [ "$RUN_UNIT_TESTS_SEQUENTIAL" = "true" ]; then
8888
if [ ! -d ${DIR_QA_ASSETS} ]; then
89-
DOCKER_EXEC git clone --depth=1 https://github.com/bitcoin-core/qa-assets ${DIR_QA_ASSETS}
89+
DOCKER_EXEC git clone --depth=1 https://github.com/ElementsProject/qa-assets ${DIR_QA_ASSETS}
9090
fi
9191

9292
export DIR_FUZZ_IN=${DIR_QA_ASSETS}/fuzz_seed_corpus/

doc/elements-confidential-transactions.md

Lines changed: 492 additions & 0 deletions
Large diffs are not rendered by default.

src/qt/bitcoinunits.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <QStringList>
88

99
#include <cassert>
10+
#include <util/system.h>
1011

1112
static constexpr auto MAX_DIGITS_BTC = 16;
1213

@@ -42,6 +43,19 @@ bool BitcoinUnits::valid(int unit)
4243

4344
QString BitcoinUnits::longName(int unit)
4445
{
46+
const std::string default_asset_name = gArgs.GetArg("-defaultpeggedassetname", "");
47+
if (default_asset_name != "") {
48+
std::string rv;
49+
switch(unit)
50+
{
51+
case BTC: rv=default_asset_name;break;
52+
case mBTC: rv=std::string("m-")+default_asset_name;break;
53+
case uBTC: rv=std::string("μ-")+default_asset_name;break;
54+
case SAT: rv=std::string("sat-")+default_asset_name;break;
55+
default: rv="???";break;
56+
}
57+
return QString::fromUtf8(rv.c_str());
58+
}
4559
switch(unit)
4660
{
4761
case BTC: return QString("L-BTC");
@@ -54,6 +68,9 @@ QString BitcoinUnits::longName(int unit)
5468

5569
QString BitcoinUnits::shortName(int unit)
5670
{
71+
if (gArgs.GetArg("-defaultpeggedassetname", "") != "") {
72+
return longName(unit);
73+
}
5774
switch(unit)
5875
{
5976
case uBTC: return QString::fromUtf8("L-bits");

src/rpc/blockchain.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,17 +154,17 @@ UniValue paramEntryToJSON(const DynaFedParamEntry& entry)
154154
}
155155

156156
// fields all params have
157-
result.pushKV("root", HexStr(entry.CalculateRoot()));
157+
result.pushKV("root", entry.CalculateRoot().GetHex());
158158
result.pushKV("signblockscript", HexStr(entry.m_signblockscript));
159159
result.pushKV("max_block_witness", (uint64_t)entry.m_signblock_witness_limit);
160160

161161
// add the extra root which is stored for compact and calculated for full
162162
if (entry.m_serialize_type == 1) {
163163
// compact
164-
result.pushKV("extra_root", HexStr(entry.m_elided_root));
164+
result.pushKV("extra_root", entry.m_elided_root.GetHex());
165165
} else if (entry.m_serialize_type == 2) {
166166
// full
167-
result.pushKV("extra_root", HexStr(entry.CalculateExtraRoot()));
167+
result.pushKV("extra_root", entry.CalculateExtraRoot().GetHex());
168168
}
169169

170170
// some extra fields only present on full params

src/test/script_tests.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1684,7 +1684,7 @@ static void AssetTest(const UniValue& test)
16841684
size_t idx = test["index"].get_int64();
16851685
unsigned int test_flags = ParseScriptFlags(test["flags"].get_str());
16861686
bool fin = test.exists("final") && test["final"].get_bool();
1687-
// ELEMENTS FIXME: update feature_taproot.py --dumptests to actually output these
1687+
// ELEMENTS: feature_taproot.py --dumptests outputs this field
16881688
uint256 hash_genesis_block = test.exists("hash_genesis_block") ? uint256S(test["hash_genesis_block"].get_str()) : uint256{};
16891689

16901690
if (test.exists("success")) {
@@ -1725,6 +1725,8 @@ BOOST_AUTO_TEST_CASE(script_assets_test)
17251725
{
17261726
// See src/test/fuzz/script_assets_test_minimizer.cpp for information on how to generate
17271727
// the script_assets_test.json file used by this test.
1728+
// ELEMENTS: qa-assets repo can be cloned here https://github.com/ElementsProject/qa-assets
1729+
// then set DIR_UNIT_TEST_DATA env var to /path/to/qa-assets/unit_test_data when running this test
17281730

17291731
const char* dir = std::getenv("DIR_UNIT_TEST_DATA");
17301732
BOOST_WARN_MESSAGE(dir != nullptr, "Variable DIR_UNIT_TEST_DATA unset, skipping script_assets_test");
@@ -1744,12 +1746,11 @@ BOOST_AUTO_TEST_CASE(script_assets_test)
17441746
BOOST_CHECK(tests.isArray());
17451747
BOOST_CHECK(tests.size() > 0);
17461748

1747-
/*
1748-
ELEMENTS: temporarily disabled until we implement the new Taproot sighash and upload new qa-assets
1749+
g_con_elementsmode = true;
17491750
for (size_t i = 0; i < tests.size(); i++) {
17501751
AssetTest(tests[i]);
17511752
}
1752-
*/
1753+
g_con_elementsmode = false;
17531754
file.close();
17541755
}
17551756

src/validation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1172,7 +1172,7 @@ PackageMempoolAcceptResult MemPoolAccept::AcceptMultipleTransactions(const std::
11721172
}
11731173

11741174
for (Workspace& ws : workspaces) {
1175-
PrecomputedTransactionData txdata;
1175+
PrecomputedTransactionData txdata(args.m_chainparams.HashGenesisBlock());
11761176
if (!PolicyScriptChecks(args, ws, txdata)) {
11771177
// Exit early to avoid doing pointless work. Update the failed tx result; the rest are unfinished.
11781178
package_state.Invalid(PackageValidationResult::PCKG_TX, "transaction failed");

test/functional/feature_dynafed.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
initial_extension = [initial_online+initial_online]
3030
new_extension = [initial_offline+initial_online]
3131

32+
initial_cpe_root = "3700bdb2975ff8e0dadaaba2b33857b0ca2610c950a92b1db725025e3647a8e1"
33+
3234
ERR_MP_INVALID_PEGOUT = "invalid-pegout-proof"
3335
ERR_MP_INVALID_PEGIN = "pegin-no-witness"
3436

@@ -48,16 +50,19 @@ def validate_no_vote_op_true(node, block, first_dynafed_active_block):
4850
assert_equal(dynamic_parameters["current"]["signblockscript"], WSH_OP_TRUE)
4951
if block_height % 10 == 0 or first_dynafed_active_block:
5052
assert_equal(dynamic_parameters["current"]["type"], "full")
53+
assert_equal(dynamic_parameters["current"]["root"], initial_cpe_root)
5154
assert_equal(dynamic_parameters["current"]["fedpegscript"], "51")
5255
assert_equal(dynamic_parameters["current"]["extension_space"], initial_extension)
5356
else:
5457
assert_equal(dynamic_parameters["current"]["type"], "compact")
58+
assert_equal(dynamic_parameters["current"]["root"], initial_cpe_root)
5559
assert not "fedpegscript" in dynamic_parameters["proposed"]
5660
assert not "extension_space" in dynamic_parameters["proposed"]
5761
assert_equal(dynamic_parameters["current"]["max_block_witness"], 74)
5862
# nothing was proposed, null fields make impossible to be valid blockheader
5963
# due to script rules requiring bool true on stack
6064
assert_equal(dynamic_parameters["proposed"]["type"], "null")
65+
assert not "root" in dynamic_parameters["proposed"]
6166
assert not "signblockscript" in dynamic_parameters["proposed"]
6267
assert not "max_block_witness" in dynamic_parameters["proposed"]
6368
assert not "fedpegscript" in dynamic_parameters["proposed"]
@@ -134,6 +139,9 @@ def test_dynafed_activation(self):
134139
self.sync_blocks(timeout=240)
135140
assert_equal(self.nodes[0].getblockchaininfo()["softforks"]["dynafed"]["bip9"]["status"], "active")
136141

142+
# Check the root hash
143+
assert_equal(self.nodes[0].getblockchaininfo()["current_params_root"], initial_cpe_root)
144+
137145
# Existing blocks should have null dynafed fields
138146
for block in blocks:
139147
assert "dynamic_parameters" not in self.nodes[0].getblock(block)

test/functional/feature_taproot.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
CTxOut,
2222
CTxOutValue,
2323
CTxOutWitness,
24+
ser_uint256,
2425
uint256_from_str,
2526
)
2627
from test_framework.script import (
@@ -1179,12 +1180,15 @@ def dump_json_test(tx, input_utxos, idx, success, failure):
11791180
# Determine flags to dump
11801181
flags = LEGACY_FLAGS if spender.comment.startswith("legacy/") or spender.comment.startswith("inactive/") else TAPROOT_FLAGS
11811182

1183+
hash_genesis_block = bytearray(ser_uint256(g_genesis_hash))
1184+
hash_genesis_block.reverse()
11821185
fields = [
11831186
("tx", tx.serialize().hex()),
11841187
("prevouts", [x.output.serialize().hex() for x in input_utxos]),
11851188
("index", idx),
11861189
("flags", flags),
1187-
("comment", spender.comment)
1190+
("comment", spender.comment),
1191+
("hash_genesis_block", hash_genesis_block.hex())
11881192
]
11891193

11901194
# The "final" field indicates that a spend should be always valid, even with more validation flags enabled

0 commit comments

Comments
 (0)