Skip to content

Commit

Permalink
Merge branch 'upgrade9_test_1' into 'master'
Browse files Browse the repository at this point in the history
Upgrade9 (May 2023) - Everything plus fixups

Closes Bitcoin-ABC#445

See merge request bitcoin-cash-node/bitcoin-cash-node!1600
  • Loading branch information
ftrader committed Nov 24, 2022
2 parents 0085f58 + 9d8c67e commit 8b87f9b
Show file tree
Hide file tree
Showing 206 changed files with 22,236 additions and 2,177 deletions.
3 changes: 3 additions & 0 deletions cmake/modules/NSIS.template.in
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ Section -post SEC0001
CreateShortcut "$SMPROGRAMS\$StartMenuGroup\@CPACK_NSIS_DISPLAY_NAME@ (testnet).lnk" "$INSTDIR\${BITCOIN_GUI_NAME}" "-testnet" "$INSTDIR\${BITCOIN_GUI_NAME}" 1
CreateShortcut "$SMPROGRAMS\$StartMenuGroup\@CPACK_NSIS_DISPLAY_NAME@ (testnet4).lnk" "$INSTDIR\${BITCOIN_GUI_NAME}" "-testnet4" "$INSTDIR\${BITCOIN_GUI_NAME}" 1
CreateShortcut "$SMPROGRAMS\$StartMenuGroup\@CPACK_NSIS_DISPLAY_NAME@ (scalenet).lnk" "$INSTDIR\${BITCOIN_GUI_NAME}" "-scalenet" "$INSTDIR\${BITCOIN_GUI_NAME}" 1
CreateShortcut "$SMPROGRAMS\$StartMenuGroup\@CPACK_NSIS_DISPLAY_NAME@ (chipnet).lnk" "$INSTDIR\${BITCOIN_GUI_NAME}" "-chipnet" "$INSTDIR\${BITCOIN_GUI_NAME}" 1
CreateShortcut "$SMPROGRAMS\$StartMenuGroup\Uninstall $(^Name).lnk" $INSTDIR\uninstall.exe
!insertmacro MUI_STARTMENU_WRITE_END
WriteRegStr HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayName "$(^Name)"
Expand Down Expand Up @@ -143,10 +144,12 @@ Section -un.post UNSEC0001
Delete /REBOOTOK "$SMPROGRAMS\$StartMenuGroup\@CPACK_NSIS_DISPLAY_NAME@ (testnet).lnk"
Delete /REBOOTOK "$SMPROGRAMS\$StartMenuGroup\@CPACK_NSIS_DISPLAY_NAME@ (testnet4).lnk"
Delete /REBOOTOK "$SMPROGRAMS\$StartMenuGroup\@CPACK_NSIS_DISPLAY_NAME@ (scalenet).lnk"
Delete /REBOOTOK "$SMPROGRAMS\$StartMenuGroup\@CPACK_NSIS_DISPLAY_NAME@ (chipnet).lnk"
Delete /REBOOTOK "$SMSTARTUP\Bitcoin Cash Node.lnk"
Delete /REBOOTOK "$SMSTARTUP\Bitcoin Cash Node (testnet).lnk"
Delete /REBOOTOK "$SMSTARTUP\Bitcoin Cash Node (testnet4).lnk"
Delete /REBOOTOK "$SMSTARTUP\Bitcoin Cash Node (scalenet).lnk"
Delete /REBOOTOK "$SMSTARTUP\Bitcoin Cash Node (chipnet).lnk"
Delete /REBOOTOK "$SMSTARTUP\Bitcoin Cash Node (regtest).lnk"
Delete /REBOOTOK "$INSTDIR\uninstall.exe"
Delete /REBOOTOK "$INSTDIR\debug.log"
Expand Down
2 changes: 2 additions & 0 deletions contrib/devtools/chainparams/chainparams_chipnet.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
00000000f053c918cf174ebcdc0b886e2315f3f0337a8ce0fcc42eb4ce403fe5
0000000000000000000000000000000000000000000000000161bec9fb1873fa
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
chainparams_test.txt
chainparams_testnet4.txt
chainparams_scalenet.txt
chainparams_chipnet.txt
These files must consist of lines in the format
Expand Down Expand Up @@ -67,14 +68,18 @@ def main():
// Scalenet re-organizes above height 10,000 - use block 9,999 hash here.
const BlockHash SCALENET_DEFAULT_ASSUME_VALID = BlockHash::fromHex("{}");
const uint256 SCALENET_MINIMUM_CHAIN_WORK = uint256S("{}");
const BlockHash CHIPNET_DEFAULT_ASSUME_VALID = BlockHash::fromHex("{}");
const uint256 CHIPNET_MINIMUM_CHAIN_WORK = uint256S("{}");
}} // namespace ChainParamsConstants\
'''.format(
# 'generated' is split out so this file is not identified as generated.
"generated",
*process_constants(indir, 'chainparams_main.txt'),
*process_constants(indir, 'chainparams_test.txt'),
*process_constants(indir, 'chainparams_testnet4.txt'),
*process_constants(indir, 'chainparams_scalenet.txt'))
*process_constants(indir, 'chainparams_scalenet.txt'),
*process_constants(indir, 'chainparams_chipnet.txt'))
)


Expand Down
3 changes: 3 additions & 0 deletions contrib/devtools/chainparams/make_chainparams.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class Chain(Enum):
TestNet = "TESTNET"
TestNet4 = "TESTNET4"
ScaleNet = "SCALENET"
ChipNet = "CHIPNET"


def get_chainparams(rpc_caller, block):
Expand All @@ -31,6 +32,8 @@ def get_chainparams(rpc_caller, block):
chain = Chain.TestNet4
elif chaininfo['chain'] == 'scale':
chain = Chain.ScaleNet
elif chaininfo['chain'] == 'chip':
chain = Chain.ChipNet
# Comment-out the below to actually update chain params for scalenet
sys.exit("ScaleNet chainparams should not be updated. See BCHN issue "
"#293. If you really wish to proceed anyway, then please "
Expand Down
7 changes: 7 additions & 0 deletions contrib/seeds/generate-seeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
nodes_testnet3.txt
nodes_testnet4.txt
nodes_scalenet.txt
nodes_chipnet.txt
These files must consist of lines in the format
Expand All @@ -36,6 +37,9 @@
static SeedSpec6 pnSeed6_scalenet[]={
...
}
static SeedSpec6 pnSeed6_chipnet[]={
...
}
These should be pasted into `src/chainparamsseeds.h`.
'''
Expand Down Expand Up @@ -153,6 +157,9 @@ def main():
g.write('\n')
with open(os.path.join(indir, 'nodes_scalenet.txt'), 'r', encoding="utf8") as f:
process_nodes(g, f, 'pnSeed6_scalenet', 38333)
with open(os.path.join(indir, 'nodes_chipnet.txt'), 'r', encoding="utf8") as f:
process_nodes(g, f, 'pnSeed6_chipnet', 48333)
g.write('\n')
g.write('#endif // BITCOIN_CHAINPARAMSSEEDS_H\n')


Expand Down
11 changes: 11 additions & 0 deletions contrib/seeds/nodes_chipnet.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
66.29.152.199:48333
149.28.32.202:48333
23.92.24.29:48333
139.162.181.217:48333
109.74.196.81:48333
172.105.0.240:48333
139.162.99.221:48333
96.126.111.144:48333
192.46.220.139:48333
136.49.183.215:48333
72.66.71.69:48333
35 changes: 33 additions & 2 deletions doc/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,46 @@ TODO

## Added functionality

TODO
P2SH-32 (pay-to-scripthash 32) support has been added and consensus rules for this
feature will activate on May 15, 2023.

## Deprecated functionality

TODO

## Modified functionality

TODO
#### Two error messages have changed:

- If the node receives a transaction that spends an UTXO with a locking script >10,000 bytes, the node now generates
the error message `bad-txns-input-scriptpubkey-unspendable`. Previously it would generate the message
`mandatory-script-verify-flag-failed (Script is too big)`

- Similarly, if the node receives a transaction that spends an `OP_RETURN` output, the node now generates the error
message `bad-txns-input-scriptpubkey-unspendable`. Previously it would generate the message
`mandatory-script-verify-flag-failed (OP_RETURN was encountered)`

The reason for this change is that sometimes an oversized locking script ended up "looking like" an `OP_RETURN` anyway
when read from the UTXO database and so the previous behavior was inconsistent because it depended on whether the output
being spent was consuming an output still in memory or coming from the UTXO db. Thus, it was possible to receive the
`OP_RETURN`-related error message when actually attempting to spend an output with an oversized locking script. As
such, the two ambiguous cases have been collapsed down into 1 consistent error message.

This error message change does mean that the node will now push a different BIP61 string to its peers when it receives
an invalid transaction that triggers these error conditions. However, no known nodes actually pay much attention to the
exact format of the error message that they receive when a transaction is rejected by a peer, so this change should
be relatively benign.

#### P2SH-32 addresses are now supported by RPC

Certain RPC methods that take an `address` parameter (such as `sendtoaddress`) will now
also correctly parse P2SH-32 addresses and thus will allow composing of transactions and
sending of funds to P2SH-32 addresses, even before the May 15, 2023 upgrade date. Note that
on mainnet such transactions will remain non-standard and cannot be relayed until P2SH-32
activates on May 15, 2023. For reference, P2SH-32 addresses are longer than regular P2SH
addresses, for example: `bitcoincash:pwqwzrf7z06m7nn58tkdjyxqfewanlhyrpxysack85xvf3mt0rv02l9dxc5uf`
is a P2SH-32 address.


## Removed functionality

Expand Down
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@ target_link_libraries(script common)
add_library(bitcoinconsensus
arith_uint256.cpp
hash.cpp
primitives/token.cpp
primitives/transaction.cpp
pubkey.cpp
uint256.cpp
Expand Down Expand Up @@ -524,6 +525,7 @@ add_library(server
checkpoints.cpp
config.cpp
consensus/activation.cpp
consensus/tokens.cpp
consensus/tx_verify.cpp
consensus/tx_check.cpp
dsproof/dsproof.cpp
Expand Down
6 changes: 3 additions & 3 deletions src/amount.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ struct Amount {
explicit constexpr Amount(int64_t _amount) : amount(_amount) {}

public:
constexpr Amount() : amount(0) {}
constexpr Amount(const Amount &other) : amount(other.amount) {}
constexpr Amount() noexcept : amount(0) {}
constexpr Amount(const Amount &other) noexcept : amount(other.amount) {}

/**
* Assignement operator.
*/
constexpr Amount &operator=(const Amount &other) {
constexpr Amount &operator=(const Amount &other) noexcept {
amount = other.amount;
return *this;
}
Expand Down
4 changes: 1 addition & 3 deletions src/bench/block_assemble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ static void AssembleBlock(benchmark::State &state) {
const Config &config = GetConfig();

const CScript redeemScript = CScript() << OP_DROP << OP_TRUE;
const CScript SCRIPT_PUB =
CScript() << OP_HASH160 << ToByteVector(CScriptID(redeemScript))
<< OP_EQUAL;
const CScript SCRIPT_PUB = GetScriptForDestination(ScriptID(redeemScript, false /* p2sh_32 = false */));

const CScript scriptSig = CScript() << std::vector<uint8_t>(100, 0xff)
<< ToByteVector(redeemScript);
Expand Down
6 changes: 2 additions & 4 deletions src/bench/chained_tx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <miner.h>
#include <primitives/transaction.h>
#include <script/script.h>
#include <script/standard.h>
#include <test/setup_common.h>
#include <test/util.h>
#include <txmempool.h>
Expand All @@ -25,10 +26,7 @@
static const CScript REDEEM_SCRIPT = CScript()
<< OP_DROP << OP_TRUE;

static const CScript SCRIPT_PUB_KEY = CScript()
<< OP_HASH160
<< ToByteVector(CScriptID(REDEEM_SCRIPT))
<< OP_EQUAL;
static const CScript SCRIPT_PUB_KEY = GetScriptForDestination(ScriptID(REDEEM_SCRIPT, false /* p2sh_20 */));

static const CScript SCRIPT_SIG = CScript()
<< std::vector<uint8_t>(100, 0xff)
Expand Down
2 changes: 1 addition & 1 deletion src/bench/checkqueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ static void CCheckQueue_RealData32MB(bool cacheSigs, benchmark::State &state) {
UnlimitedSigChecks highLimitPerTx, highLimitPerBlock;
for (const auto & tx : block.vtx) {
if (tx->IsCoinBase()) continue;
const PrecomputedTransactionData txdata(*tx);
std::vector<CScriptCheck> vChecksThisTx;
const auto contexts = ScriptExecutionContext::createForAllInputs(*tx, coinsCache);
assert(contexts.size() == tx->vin.size());
const PrecomputedTransactionData txdata(contexts.at(0));
for (size_t i = 0; i < tx->vin.size(); ++i) {
vChecksThisTx.emplace_back(contexts[i], MANDATORY_SCRIPT_VERIFY_FLAGS,
cacheSigs /* whether to store results in cache */,
Expand Down
9 changes: 5 additions & 4 deletions src/bench/dsproof.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,14 @@ static void DoubleSpendProofCreate(benchmark::State &state) {
for (auto & txin : tx.vin) {
const Coin coin(CTxOut{1 * COIN, GetScriptForDestination(privKey.GetPubKey().GetID())}, 123, false);

SignatureData sigdata = DataFromTransaction(tx, i, coin.GetTxOut());
// no "real" script execution context is necessary for dsproofs (P2PKH only)
const ScriptExecutionContext limited_context{unsigned(i), coin.GetTxOut(), tx};

auto const context = std::nullopt; // no script execution context is necessary for dsproofs (P2PKH only)
SignatureData sigdata = DataFromTransaction(limited_context, STANDARD_SCRIPT_VERIFY_FLAGS);

ProduceSignature(keyStore,
MutableTransactionSignatureCreator(&tx, i, coin.GetTxOut().nValue, sigHashType),
coin.GetTxOut().scriptPubKey, sigdata, context);
TransactionSignatureCreator(limited_context, sigHashType),
coin.GetTxOut().scriptPubKey, sigdata, STANDARD_SCRIPT_VERIFY_FLAGS);
UpdateInput(txin, sigdata);
++i;
if (i == tx.vin.size() && !commonTxOut)
Expand Down
6 changes: 2 additions & 4 deletions src/bench/removeforblock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <miner.h>
#include <primitives/transaction.h>
#include <script/script.h>
#include <script/standard.h>
#include <test/setup_common.h>
#include <test/util.h>
#include <txmempool.h>
Expand All @@ -26,10 +27,7 @@
static const CScript REDEEM_SCRIPT = CScript()
<< OP_DROP << OP_TRUE;

static const CScript SCRIPT_PUB_KEY = CScript()
<< OP_HASH160
<< ToByteVector(CScriptID(REDEEM_SCRIPT))
<< OP_EQUAL;
static const CScript SCRIPT_PUB_KEY = GetScriptForDestination(ScriptID(REDEEM_SCRIPT, false /* p2sh_20 */));

static const CScript SCRIPT_SIG = CScript()
<< std::vector<uint8_t>(100, 0xff)
Expand Down
22 changes: 10 additions & 12 deletions src/bench/verify_script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ static void VerifyNestedIfScript(benchmark::State &state) {
auto stack_copy = stack;
ScriptExecutionMetrics metrics = {};
ScriptError error;
auto const null_context = std::nullopt;
bool ret = EvalScript(stack_copy, script, 0, BaseSignatureChecker(), metrics, null_context, &error);
bool ret = EvalScript(stack_copy, script, 0, BaseSignatureChecker(), metrics, &error);
assert(ret);
}
}
Expand Down Expand Up @@ -81,13 +80,8 @@ static void VerifyBlockScripts(bool reallyCheckSigs,
std::vector<PrecomputedTransactionData> txdataVec;
if (reallyCheckSigs) {
txdataVec.reserve(block.vtx.size());
for (const auto &tx : block.vtx) {
if (tx->IsCoinBase()) continue;
txdataVec.emplace_back(*tx);
}
}


const auto &coins = coinsCache; // get a const reference to be safe
std::vector<const Coin *> coinsVec; // coins being spent laid out in block input order
std::vector<std::vector<ScriptExecutionContext>> contexts; // script execution contexts for each tx
Expand All @@ -100,15 +94,18 @@ static void VerifyBlockScripts(bool reallyCheckSigs,
assert(!coin.IsSpent());
coinsVec.push_back(&coin);
}
if (reallyCheckSigs && !contexts.back().empty()) {
txdataVec.emplace_back(contexts.back().at(0));
}
}

struct FakeSignaureChecker final : BaseSignatureChecker {
struct FakeSignaureChecker final : ContextOptSignatureChecker {
bool VerifySignature(const std::vector<uint8_t> &, const CPubKey &, const uint256 &) const override { return true; }
bool CheckSig(const std::vector<uint8_t> &, const std::vector<uint8_t> &, const CScript &, uint32_t) const override { return true; }
bool CheckLockTime(const CScriptNum &) const override { return true; }
bool CheckSequence(const CScriptNum &) const override { return true; }
using ContextOptSignatureChecker::ContextOptSignatureChecker;
};
const FakeSignaureChecker fakeChecker;

while (state.KeepRunning()) {
size_t okct = 0;
Expand All @@ -125,10 +122,11 @@ static void VerifyBlockScripts(bool reallyCheckSigs,
if (reallyCheckSigs) {
assert(txdataVecIdx < txdataVec.size());
const auto &txdata = txdataVec[txdataVecIdx];
const TransactionSignatureChecker checker(tx.get(), inputNum, coin.GetTxOut().nValue, txdata);
ok = VerifyScript(inp.scriptSig, coin.GetTxOut().scriptPubKey, flags, checker, context, &serror);
const TransactionSignatureChecker checker(context, txdata);
ok = VerifyScript(inp.scriptSig, coin.GetTxOut().scriptPubKey, flags, checker, &serror);
} else {
ok = VerifyScript(inp.scriptSig, coin.GetTxOut().scriptPubKey, flags, fakeChecker, context, &serror);
ok = VerifyScript(inp.scriptSig, coin.GetTxOut().scriptPubKey, flags, FakeSignaureChecker(context),
&serror);
}
if (!ok) {
throw std::runtime_error(
Expand Down
4 changes: 3 additions & 1 deletion src/bitcoin-cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ static void SetupCliArgs() {
const auto testnetBaseParams = CreateBaseChainParams(CBaseChainParams::TESTNET);
const auto testnet4BaseParams = CreateBaseChainParams(CBaseChainParams::TESTNET4);
const auto scalenetBaseParams = CreateBaseChainParams(CBaseChainParams::SCALENET);
const auto chipnetBaseParams = CreateBaseChainParams(CBaseChainParams::CHIPNET);
const auto regtestBaseParams = CreateBaseChainParams(CBaseChainParams::REGTEST);

gArgs.AddArg("-version", "Print version and exit", ArgsManager::ALLOW_ANY,
Expand Down Expand Up @@ -76,11 +77,12 @@ static void SetupCliArgs() {
ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
gArgs.AddArg("-rpcport=<port>",
strprintf("Connect to JSON-RPC on <port> (default: %u, "
"testnet: %u, testnet4: %u, scalenet: %u, regtest: %u)",
"testnet: %u, testnet4: %u, scalenet: %u, chipnet: %u, regtest: %u)",
defaultBaseParams->RPCPort(),
testnetBaseParams->RPCPort(),
testnet4BaseParams->RPCPort(),
scalenetBaseParams->RPCPort(),
chipnetBaseParams->RPCPort(),
regtestBaseParams->RPCPort()),
ArgsManager::ALLOW_ANY | ArgsManager::NETWORK_ONLY, OptionsCategory::OPTIONS);
gArgs.AddArg("-rpcwait", "Wait for RPC server to start", ArgsManager::ALLOW_ANY,
Expand Down
Loading

0 comments on commit 8b87f9b

Please sign in to comment.