Skip to content

Commit

Permalink
Merge #6297: backport: merge bitcoin#23156, #23213, #23227, #23223, #…
Browse files Browse the repository at this point in the history
…23564, #23538, #23437, #23630, #23465, #23738, #17631, #22875 (auxiliary backports: part 18)

5aceee3 merge bitcoin#22875: Fix Racy ParseOpCode function initialization (Kittywhiskers Van Gogh)
427d07f merge bitcoin#17631: Expose block filters over REST (Kittywhiskers Van Gogh)
d60f15e merge bitcoin#23738: improve logging of ChainstateManager snapshot persistance (Kittywhiskers Van Gogh)
8725734 merge bitcoin#23465: Remove CTxMemPool params from ATMP (Kittywhiskers Van Gogh)
d2cbdc4 merge bitcoin#23630: Remove GetSpendHeight (Kittywhiskers Van Gogh)
8bdab4d merge bitcoin#23437: AcceptToMemoryPool (Kittywhiskers Van Gogh)
1f4e8a0 merge bitcoin#23538: Remove strtol in torcontrol (Kittywhiskers Van Gogh)
2318d9f merge bitcoin#23564: don't use deprecated brew package names (Kittywhiskers Van Gogh)
3b7a739 merge bitcoin#23223: Disable lock contention logging in checkqueue_tests (Kittywhiskers Van Gogh)
b383609 merge bitcoin#23227: Avoid treating integer overflow as OP_0 (Kittywhiskers Van Gogh)
0188d32 merge bitcoin#23213: Return error when header count is not integral (Kittywhiskers Van Gogh)
eb9e208 merge bitcoin#23156: Remove unused ParsePrechecks and ParseDouble (Kittywhiskers Van Gogh)
18fff7e rpc: switch to taking an integer for `rate` in `quorum dkgsimerror` (Kittywhiskers Van Gogh)

Pull request description:

  ## Additional Information

  * Dependent on dashpay/dash#6288

  * Dependent on dashpay/dash#6296

  ## Breaking changes

  - `quorum dkgsimerror` will no longer accept a decimal value between 0 and 1 for the `rate` argument, it will now expect an integer between 0 to 100.

  ## Checklist

  - [x] I have performed a self-review of my own code
  - [x] I have commented my code, particularly in hard-to-understand areas **(note: N/A)**
  - [x] I have added or updated relevant unit/integration/functional/e2e tests
  - [x] I have made corresponding changes to the documentation
  - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_

ACKs for top commit:
  PastaPastaPasta:
    utACK 5aceee3
  UdjinM6:
    utACK 5aceee3
  knst:
    utACK 5aceee3

Tree-SHA512: 8fc34b05a74f2ddbe84b2a7a54772e49941042c89bc74d71d33711e658754a3d086af11fb2437d2bb72ede0c611adc57b82193783e7b6f10fbd4ebab2a7fa7cb
  • Loading branch information
PastaPastaPasta committed Oct 8, 2024
2 parents f93c763 + 5aceee3 commit 6157e67
Show file tree
Hide file tree
Showing 23 changed files with 438 additions and 230 deletions.
2 changes: 1 addition & 1 deletion .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ task:
task:
name: 'macOS 11 native [gui] [no depends]'
brew_install_script:
- brew install boost libevent berkeley-db4 qt@5 miniupnpc ccache zeromq qrencode sqlite libtool automake pkg-config gnu-getopt
- brew install boost libevent berkeley-db@4 qt@5 miniupnpc ccache zeromq qrencode sqlite libtool automake pkg-config gnu-getopt
<< : *GLOBAL_TASK_TEMPLATE
macos_instance:
# Use latest image, but hardcode version to avoid silent upgrades (and breaks)
Expand Down
8 changes: 4 additions & 4 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -746,8 +746,8 @@ case $host in
dnl It's safe to add these paths even if the functionality is disabled by
dnl the user (--without-wallet or --without-gui for example).

if test "x$use_bdb" != xno && $BREW list --versions berkeley-db4 >/dev/null && test "x$BDB_CFLAGS" = "x" && test "x$BDB_LIBS" = "x"; then
bdb_prefix=$($BREW --prefix berkeley-db4 2>/dev/null)
if test "x$use_bdb" != xno && $BREW list --versions berkeley-db@4 >/dev/null && test "x$BDB_CFLAGS" = "x" && test "x$BDB_LIBS" = "x"; then
bdb_prefix=$($BREW --prefix berkeley-db@4 2>/dev/null)
dnl This must precede the call to BITCOIN_FIND_BDB48 below.
BDB_CFLAGS="-I$bdb_prefix/include"
BDB_LIBS="-L$bdb_prefix/lib -ldb_cxx-4.8"
Expand All @@ -757,8 +757,8 @@ case $host in
export PKG_CONFIG_PATH="$($BREW --prefix sqlite3 2>/dev/null)/lib/pkgconfig:$PKG_CONFIG_PATH"
fi

if $BREW list --versions qt5 >/dev/null; then
export PKG_CONFIG_PATH="$($BREW --prefix qt5 2>/dev/null)/lib/pkgconfig:$PKG_CONFIG_PATH"
if $BREW list --versions qt@5 >/dev/null; then
export PKG_CONFIG_PATH="$($BREW --prefix qt@5 2>/dev/null)/lib/pkgconfig:$PKG_CONFIG_PATH"
fi

gmp_prefix=$($BREW --prefix gmp 2>/dev/null)
Expand Down
14 changes: 14 additions & 0 deletions doc/REST-interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,20 @@ With the /notxdetails/ option JSON response will only contain the transaction ha
Given a block hash: returns <COUNT> amount of blockheaders in upward direction.
Returns empty if the block doesn't exist or it isn't in the active chain.

#### Blockfilter Headers
`GET /rest/blockfilterheaders/<FILTERTYPE>/<COUNT>/<BLOCK-HASH>.<bin|hex|json>`

Given a block hash: returns <COUNT> amount of blockfilter headers in upward
direction for the filter type <FILTERTYPE>.
Returns empty if the block doesn't exist or it isn't in the active chain.

#### Blockfilters
`GET /rest/blockfilter/<FILTERTYPE>/<BLOCK-HASH>.<bin|hex|json>`

Given a block hash: returns the block filter of the given block of type
<FILTERTYPE>.
Responds with 404 if the block doesn't exist.

#### Blockhash by height
`GET /rest/blockhashbyheight/<HEIGHT>.<bin|hex|json>`

Expand Down
5 changes: 5 additions & 0 deletions doc/release-notes-6297.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
RPC changes
-----------

- `quorum dkgsimerror` will no longer accept a decimal value between 0 and 1 for the `rate` argument, it will now
expect an integer between 0 to 100.
74 changes: 38 additions & 36 deletions src/core_read.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,32 +19,43 @@
#include <string>

namespace {

opcodetype ParseOpCode(const std::string& s)
class OpCodeParser
{
static std::map<std::string, opcodetype> mapOpNames;
private:
std::map<std::string, opcodetype> mapOpNames;

if (mapOpNames.empty())
public:
OpCodeParser()
{
for (unsigned int op = 0; op <= MAX_OPCODE; op++)
{
for (unsigned int op = 0; op <= MAX_OPCODE; ++op) {
// Allow OP_RESERVED to get into mapOpNames
if (op < OP_NOP && op != OP_RESERVED)
if (op < OP_NOP && op != OP_RESERVED) {
continue;
}

std::string strName = GetOpName(static_cast<opcodetype>(op));
if (strName == "OP_UNKNOWN")
if (strName == "OP_UNKNOWN") {
continue;
}
mapOpNames[strName] = static_cast<opcodetype>(op);
// Convenience: OP_ADD and just ADD are both recognized:
if (strName.compare(0, 3, "OP_") == 0) { // strName starts with "OP_"
if (strName.compare(0, 3, "OP_") == 0) { // strName starts with "OP_"
mapOpNames[strName.substr(3)] = static_cast<opcodetype>(op);
}
}
}
auto it = mapOpNames.find(s);
if (it == mapOpNames.end()) throw std::runtime_error("script parse error: unknown opcode");
return it->second;
opcodetype Parse(const std::string& s) const
{
auto it = mapOpNames.find(s);
if (it == mapOpNames.end()) throw std::runtime_error("script parse error: unknown opcode");
return it->second;
}
};

opcodetype ParseOpCode(const std::string& s)
{
static const OpCodeParser ocp;
return ocp.Parse(s);
}

} // namespace
Expand All @@ -56,44 +67,35 @@ CScript ParseScript(const std::string& s)

std::vector<std::string> words = SplitString(s, " \t\n");

for (std::vector<std::string>::const_iterator w = words.begin(); w != words.end(); ++w)
{
if (w->empty())
{
for (const std::string& w : words) {
if (w.empty()) {
// Empty string, ignore. (SplitString doesn't combine multiple separators)
}
else if (std::all_of(w->begin(), w->end(), ::IsDigit) ||
(w->front() == '-' && w->size() > 1 && std::all_of(w->begin()+1, w->end(), ::IsDigit)))
} else if (std::all_of(w.begin(), w.end(), ::IsDigit) ||
(w.front() == '-' && w.size() > 1 && std::all_of(w.begin() + 1, w.end(), ::IsDigit)))
{
// Number
int64_t n = LocaleIndependentAtoi<int64_t>(*w);
const auto num{ToIntegral<int64_t>(w)};

//limit the range of numbers ParseScript accepts in decimal
//since numbers outside -0xFFFFFFFF...0xFFFFFFFF are illegal in scripts
if (n > int64_t{0xffffffff} || n < -1 * int64_t{0xffffffff}) {
// limit the range of numbers ParseScript accepts in decimal
// since numbers outside -0xFFFFFFFF...0xFFFFFFFF are illegal in scripts
if (!num.has_value() || num > int64_t{0xffffffff} || num < -1 * int64_t{0xffffffff}) {
throw std::runtime_error("script parse error: decimal numeric value only allowed in the "
"range -0xFFFFFFFF...0xFFFFFFFF");
}

result << n;
}
else if (w->substr(0,2) == "0x" && w->size() > 2 && IsHex(std::string(w->begin()+2, w->end())))
{
result << num.value();
} else if (w.substr(0, 2) == "0x" && w.size() > 2 && IsHex(std::string(w.begin() + 2, w.end()))) {
// Raw hex data, inserted NOT pushed onto stack:
std::vector<unsigned char> raw = ParseHex(std::string(w->begin()+2, w->end()));
std::vector<unsigned char> raw = ParseHex(std::string(w.begin() + 2, w.end()));
result.insert(result.end(), raw.begin(), raw.end());
}
else if (w->size() >= 2 && w->front() == '\'' && w->back() == '\'')
{
} else if (w.size() >= 2 && w.front() == '\'' && w.back() == '\'') {
// Single-quoted string, pushed as data. NOTE: this is poor-man's
// parsing, spaces/tabs/newlines in single-quoted strings won't work.
std::vector<unsigned char> value(w->begin()+1, w->end()-1);
std::vector<unsigned char> value(w.begin() + 1, w.end() - 1);
result << value;
}
else
{
} else {
// opcode, e.g. OP_ADD or ADD:
result << ParseOpCode(*w);
result << ParseOpCode(w);
}
}

Expand Down
7 changes: 0 additions & 7 deletions src/node/blockstorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,6 @@ class BlockManager

//! Check whether the block associated with this index entry is pruned or not.
bool IsBlockPruned(const CBlockIndex* pblockindex) EXCLUSIVE_LOCKS_REQUIRED(::cs_main);

/**
* Return the spend height, which is one more than the inputs.GetBestBlock().
* While checking, GetBestBlock() refers to the parent block. (protected by cs_main)
* This is also true for mempool checks.
*/
int GetSpendHeight(const CCoinsViewCache& inputs) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
};

void CleanupBlockRevFiles();
Expand Down
Loading

0 comments on commit 6157e67

Please sign in to comment.