Skip to content

Commit 1339803

Browse files
committed
set Wno-error for simplicity keep warning but dont error on it
fuzz test fixes set -DPRODUCTION for simplicity in fuzz tests set UNDEBUG for simplicity in fuzz tests update wallet fuzz tests update test script fix msvc conversion issues more msvc vector conversion fixes and substitution of boost libs fix more hexstr calls fix hexstr calls in init.cpp default CMAKE_GENERATOR to Unix Makefiles more span fixes specify build bin directory fix executable locations fix fuzz tests for c11 and functional test fixes fix fuzz test executable path specify legacy wallet for elements functional tests remove assertion for static initialization order issue use elements fuzz corpus print debug log on failure use heap for blind and asset_blind test: avoid disk space warning for non-regtest feature_config_args.py incorrectly assumed that its testnet4 node would not log a disk space warning. 0683b8e increased m_assumed_blockchain_size on testnet4 from 1 to 11 GiB which triggers this bug on more systems, e.g. a RAM disk. Prevent the warning by setting -prune for these nodes. Fix the same issue in feature_signet.py Github-Pull: #32057 Rebased-From: 20fe41e
1 parent 17c1e0d commit 1339803

33 files changed

Lines changed: 119 additions & 102 deletions

.github/workflows/ci.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ jobs:
222222

223223
- name: Generate build system
224224
run: |
225-
cmake -B build --preset vs2022-static -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_INSTALLATION_ROOT\scripts\buildsystems\vcpkg.cmake" ${{ matrix.generate-options }}
225+
cmake -B build --preset vs2022-static -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_INSTALLATION_ROOT\scripts\buildsystems\vcpkg.cmake" -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE="${{ github.workspace }}/build/bin" ${{ matrix.generate-options }}
226226
227227
- name: Save vcpkg binary cache
228228
uses: actions/cache/save@v4
@@ -246,18 +246,18 @@ jobs:
246246
if: matrix.job-type == 'standard'
247247
working-directory: build
248248
env:
249-
BITCOIND: '${{ github.workspace }}\build\bin\Release\bitcoind.exe'
250-
BITCOINCLI: '${{ github.workspace }}\build\bin\Release\bitcoin-cli.exe'
251-
BITCOINUTIL: '${{ github.workspace }}\build\bin\Release\bitcoin-util.exe'
252-
BITCOINWALLET: '${{ github.workspace }}\build\bin\Release\bitcoin-wallet.exe'
249+
BITCOIND: '${{ github.workspace }}\build\bin\elementsd.exe'
250+
BITCOINCLI: '${{ github.workspace }}\build\bin\elements-cli.exe'
251+
BITCOINUTIL: '${{ github.workspace }}\build\bin\elements-util.exe'
252+
BITCOINWALLET: '${{ github.workspace }}\build\bin\elements-wallet.exe'
253253
TEST_RUNNER_EXTRA: ${{ github.event_name != 'pull_request' && '--extended' || '' }}
254254
shell: cmd
255255
run: py -3 test\functional\test_runner.py --jobs %NUMBER_OF_PROCESSORS% --ci --quiet --tmpdirprefix=%RUNNER_TEMP% --combinedlogslen=99999999 --timeout-factor=%TEST_RUNNER_TIMEOUT_FACTOR% %TEST_RUNNER_EXTRA%
256256

257257
- name: Clone corpora
258258
if: matrix.job-type == 'fuzz'
259259
run: |
260-
git clone --depth=1 https://github.com/bitcoin-core/qa-assets "$env:RUNNER_TEMP\qa-assets"
260+
git clone --depth=1 https://github.com/ElementsProject/qa-assets "$env:RUNNER_TEMP\qa-assets"
261261
Set-Location "$env:RUNNER_TEMP\qa-assets"
262262
Write-Host "Using qa-assets repo from commit ..."
263263
git log -1
@@ -266,7 +266,7 @@ jobs:
266266
if: matrix.job-type == 'fuzz'
267267
working-directory: build
268268
env:
269-
BITCOINFUZZ: '${{ github.workspace }}\build\bin\Release\fuzz.exe'
269+
BITCOINFUZZ: '${{ github.workspace }}\build\bin\fuzz.exe'
270270
shell: cmd
271271
run: |
272272
py -3 test\fuzz\test_runner.py --par %NUMBER_OF_PROCESSORS% --loglevel DEBUG %RUNNER_TEMP%\qa-assets\fuzz_corpora

ci/test/03_test_script.sh

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ fi
124124
# === CMake build (modern path used by the fork) ===
125125
if [ -n "$NO_DEPENDS" ]; then
126126
echo "Building with CMake (NO_DEPENDS=1)..."
127-
cmake -B build -S . -G "$CMAKE_GENERATOR" $BITCOIN_CONFIG_ALL
127+
cmake -B build -S . ${CMAKE_GENERATOR:+-G "$CMAKE_GENERATOR"} $BITCOIN_CONFIG_ALL
128128
else
129129
# depends path (still uses configure in some jobs)
130130
./autogen.sh
@@ -133,6 +133,21 @@ fi
133133

134134
cmake --build build --config Release --parallel "$MAKEJOBS"
135135

136+
if [ -n "$NO_DEPENDS" ]; then
137+
bash -c "${PRINT_CCACHE_STATISTICS}"
138+
139+
if [ "$RUN_UNIT_TESTS" = "true" ]; then
140+
DIR_UNIT_TEST_DATA="${DIR_UNIT_TEST_DATA}" CTEST_OUTPUT_ON_FAILURE=ON ctest --stop-on-failure "${MAKEJOBS}" --timeout $(( TEST_RUNNER_TIMEOUT_FACTOR * 60 ))
141+
fi
142+
143+
if [ "$RUN_FUNCTIONAL_TESTS" = "true" ]; then
144+
eval "TEST_RUNNER_EXTRA=($TEST_RUNNER_EXTRA)"
145+
test/functional/test_runner.py --ci "${MAKEJOBS}" --tmpdirprefix "${BASE_SCRATCH_DIR}"/test_runner/ --ansi --combinedlogslen=99999999 --timeout-factor="${TEST_RUNNER_TIMEOUT_FACTOR}" "${TEST_RUNNER_EXTRA[@]}" --quiet --failfast
146+
fi
147+
148+
exit 0
149+
fi
150+
136151
mkdir -p "${BASE_BUILD_DIR}"
137152
cd "${BASE_BUILD_DIR}"
138153

src/CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ target_include_directories(elementssimplicity
105105
target_compile_definitions(elementssimplicity PRIVATE PRODUCTION)
106106
# Simplicity requires assertions; remove NDEBUG that cmake adds for optimized builds.
107107
target_compile_options(elementssimplicity PRIVATE -UNDEBUG)
108+
target_compile_options(elementssimplicity PRIVATE
109+
$<$<CXX_COMPILER_ID:MSVC>:/std:c11>
110+
)
108111
target_link_libraries(elementssimplicity
109112
PRIVATE
110113
core_interface
@@ -113,8 +116,8 @@ target_link_libraries(elementssimplicity
113116
# macOS Apple Clang is stricter than Linux GCC on this vendored code
114117
if(APPLE)
115118
target_compile_options(elementssimplicity PRIVATE
116-
-Wno-conditional-uninitialized
117-
-Wno-implicit-fallthrough
119+
-Wno-error=conditional-uninitialized
120+
-Wno-error=implicit-fallthrough
118121
)
119122
endif()
120123

src/assetsdir.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
#include <tinyformat.h>
99
#include <util/strencodings.h>
1010

11-
#include <boost/algorithm/string/classification.hpp>
12-
#include <boost/algorithm/string/split.hpp>
13-
1411
void CAssetsDir::Set(const CAsset& asset, const AssetMetadata& metadata)
1512
{
1613
// No asset or label repetition
@@ -41,7 +38,11 @@ void CAssetsDir::InitFromStrings(const std::vector<std::string>& assetsToInit, c
4138
{
4239
for (std::string strToSplit : assetsToInit) {
4340
std::vector<std::string> vAssets;
44-
boost::split(vAssets, strToSplit, boost::is_any_of(":"));
41+
const auto pos = strToSplit.find(':');
42+
if (pos != std::string::npos) {
43+
vAssets.push_back(strToSplit.substr(0, pos));
44+
vAssets.push_back(strToSplit.substr(pos + 1));
45+
}
4546
if (vAssets.size() != 2) {
4647
throw std::runtime_error("-assetdir parameters malformed, expecting asset:label");
4748
}

src/blind.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <blind.h>
66
#include <chainparams.h>
77

8+
#include <array>
89
#include <hash.h>
910
#include <primitives/transaction.h>
1011
#include <primitives/confidential.h>
@@ -474,8 +475,8 @@ int BlindTransaction(std::vector<uint256 >& input_value_blinding_factors, const
474475
//Running total of newly blinded outputs
475476
static const unsigned char diff_zero[32] = {0};
476477
assert(num_to_blind <= 10000); // More than 10k outputs? Stop spamming.
477-
unsigned char blind[10000][32];
478-
unsigned char asset_blind[10000][32];
478+
std::vector<std::array<unsigned char, 32>> blind(num_to_blind);
479+
std::vector<std::array<unsigned char, 32>> asset_blind(num_to_blind);
479480
secp256k1_pedersen_commitment value_commit;
480481
secp256k1_generator asset_gen;
481482
CAsset asset;

src/common/signmessage.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ bool MessageSign(
6565
return false;
6666
}
6767

68-
signature = EncodeBase64(signature_bytes);
68+
signature = EncodeBase64(MakeByteSpan(signature_bytes));
6969

7070
return true;
7171
}

src/core_read.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ static bool DecodeTx(CMutableTransaction& tx, const std::vector<unsigned char>&
143143
// Try decoding with extended serialization support, and remember if the result successfully
144144
// consumes the entire input.
145145
if (try_witness) {
146-
DataStream ssData(tx_data);
146+
DataStream ssData(MakeByteSpan(tx_data));
147147
try {
148148
ssData >> TX_WITH_WITNESS(tx_extended);
149149
if (ssData.empty()) ok_extended = true;
@@ -161,7 +161,7 @@ static bool DecodeTx(CMutableTransaction& tx, const std::vector<unsigned char>&
161161

162162
// Try decoding with legacy serialization, and remember if the result successfully consumes the entire input.
163163
if (try_no_witness) {
164-
DataStream ssData(tx_data);
164+
DataStream ssData(MakeByteSpan(tx_data));
165165
try {
166166
ssData >> TX_NO_WITNESS(tx_legacy);
167167
if (ssData.empty()) ok_legacy = true;
@@ -208,7 +208,7 @@ bool DecodeHexBlockHeader(CBlockHeader& header, const std::string& hex_header)
208208
if (!IsHex(hex_header)) return false;
209209

210210
const std::vector<unsigned char> header_data{ParseHex(hex_header)};
211-
DataStream ser_header(header_data);
211+
DataStream ser_header(MakeByteSpan(header_data));
212212
try {
213213
ser_header >> TX_WITH_WITNESS(header);
214214
} catch (const std::exception&) {
@@ -223,7 +223,7 @@ bool DecodeHexBlk(CBlock& block, const std::string& strHexBlk)
223223
return false;
224224

225225
std::vector<unsigned char> blockData(ParseHex(strHexBlk));
226-
DataStream ssBlock(blockData);
226+
DataStream ssBlock(MakeByteSpan(blockData));
227227
try {
228228
ssBlock >> TX_WITH_WITNESS(block);
229229
}

src/core_write.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,14 @@ std::string FormatScript(const CScript& script)
8888
}
8989
}
9090
if (vch.size() > 0) {
91-
ret += strprintf("0x%x 0x%x ", HexStr(std::vector<uint8_t>(it2, it - vch.size())),
92-
HexStr(std::vector<uint8_t>(it - vch.size(), it)));
91+
ret += strprintf("0x%x 0x%x ", HexStr(MakeByteSpan(std::vector<uint8_t>(it2, it - vch.size()))),
92+
HexStr(MakeByteSpan(std::vector<uint8_t>(it - vch.size(), it))));
9393
} else {
94-
ret += strprintf("0x%x ", HexStr(std::vector<uint8_t>(it2, it)));
94+
ret += strprintf("0x%x ", HexStr(MakeByteSpan(std::vector<uint8_t>(it2, it))));
9595
}
9696
continue;
9797
}
98-
ret += strprintf("0x%x ", HexStr(std::vector<uint8_t>(it2, script.end())));
98+
ret += strprintf("0x%x ", HexStr(MakeByteSpan(std::vector<uint8_t>(it2, script.end()))));
9999
break;
100100
}
101101
return ret.substr(0, ret.empty() ? ret.npos : ret.size() - 1);
@@ -157,9 +157,9 @@ std::string ScriptToAsmStr(const CScript& script, const bool fAttemptSighashDeco
157157
vch.pop_back(); // remove the sighash type byte. it will be replaced by the decode.
158158
}
159159
}
160-
str += HexStr(vch) + strSigHashDecode;
160+
str += HexStr(MakeByteSpan(vch)) + strSigHashDecode;
161161
} else {
162-
str += HexStr(vch);
162+
str += HexStr(MakeByteSpan(vch));
163163
}
164164
}
165165
} else {
@@ -180,7 +180,7 @@ UniValue EncodeHexScriptWitness(const CScriptWitness& witness)
180180
{
181181
UniValue witness_hex(UniValue::VARR);
182182
for (const auto &item : witness.stack) {
183-
witness_hex.push_back(HexStr(item));
183+
witness_hex.push_back(HexStr(MakeByteSpan(item)));
184184
}
185185
return witness_hex;
186186
}
@@ -292,7 +292,7 @@ void TxToUniv(const CTransaction& tx, const uint256& block_hash, UniValue& entry
292292
if (!scriptWitness.IsNull()) {
293293
UniValue txinwitness(UniValue::VARR);
294294
for (const auto &item : scriptWitness.stack) {
295-
txinwitness.push_back(HexStr(item));
295+
txinwitness.push_back(HexStr(MakeByteSpan(item)));
296296
}
297297
in.pushKV("txinwitness", txinwitness);
298298
}
@@ -301,7 +301,7 @@ void TxToUniv(const CTransaction& tx, const uint256& block_hash, UniValue& entry
301301
if (tx.witness.vtxinwit.size() > i && !tx.witness.vtxinwit[i].m_pegin_witness.IsNull()) {
302302
UniValue pegin_witness(UniValue::VARR);
303303
for (const auto& item : tx.witness.vtxinwit[i].m_pegin_witness.stack) {
304-
pegin_witness.push_back(HexStr(item));
304+
pegin_witness.push_back(HexStr(MakeByteSpan(item)));
305305
}
306306
in.pushKV("pegin_witness", pegin_witness);
307307
}
@@ -330,12 +330,12 @@ void TxToUniv(const CTransaction& tx, const uint256& block_hash, UniValue& entry
330330
if (issuance.nAmount.IsExplicit()) {
331331
issue.pushKV("assetamount", ValueFromAmount(issuance.nAmount.GetAmount()));
332332
} else if (issuance.nAmount.IsCommitment()) {
333-
issue.pushKV("assetamountcommitment", HexStr(issuance.nAmount.vchCommitment));
333+
issue.pushKV("assetamountcommitment", HexStr(MakeByteSpan(issuance.nAmount.vchCommitment)));
334334
}
335335
if (issuance.nInflationKeys.IsExplicit()) {
336336
issue.pushKV("tokenamount", ValueFromAmount(issuance.nInflationKeys.GetAmount()));
337337
} else if (issuance.nInflationKeys.IsCommitment()) {
338-
issue.pushKV("tokenamountcommitment", HexStr(issuance.nInflationKeys.vchCommitment));
338+
issue.pushKV("tokenamountcommitment", HexStr(MakeByteSpan(issuance.nInflationKeys.vchCommitment)));
339339
}
340340
in.pushKV("issuance", issue);
341341
}
@@ -373,7 +373,7 @@ void TxToUniv(const CTransaction& tx, const uint256& block_hash, UniValue& entry
373373
}
374374

375375
if (ptxoutwit->vchSurjectionproof.size()) {
376-
out.pushKV("surjectionproof", HexStr(ptxoutwit->vchSurjectionproof));
376+
out.pushKV("surjectionproof", HexStr(MakeByteSpan(ptxoutwit->vchSurjectionproof)));
377377
}
378378
}
379379
out.pushKV("valuecommitment", txout.nValue.GetHex());

src/httprpc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ static bool multiUserAuthorized(std::string strUserPass)
123123

124124
CHMAC_SHA256(reinterpret_cast<const unsigned char*>(strSalt.data()), strSalt.size()).Write(reinterpret_cast<const unsigned char*>(strPass.data()), strPass.size()).Finalize(out);
125125
std::vector<unsigned char> hexvec(out, out+KEY_SIZE);
126-
std::string strHashFromPass = HexStr(hexvec);
126+
std::string strHashFromPass = HexStr(MakeByteSpan(hexvec));
127127

128128
if (TimingResistantEqual(strHashFromPass, strHash)) {
129129
return true;

src/i2p.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ void Session::CreateIfNotCreatedAlready()
438438
GenerateAndSavePrivateKey(*sock);
439439
}
440440

441-
const std::string& private_key_b64 = SwapBase64(EncodeBase64(m_private_key));
441+
const std::string& private_key_b64 = SwapBase64(EncodeBase64(MakeByteSpan(m_private_key)));
442442

443443
SendRequestAndGetReply(*sock,
444444
strprintf("SESSION CREATE STYLE=STREAM ID=%s DESTINATION=%s "

0 commit comments

Comments
 (0)