-
Notifications
You must be signed in to change notification settings - Fork 1.2k
backport: Merge bitcoin#30170, 30026, 30017, 29961, 29904, 29910, 29849, 29865 #7257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
21efd26
86f25a8
4c48c1a
26fae74
45cee73
e951363
05f1dd9
63328b0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| // Copyright (c) 2024-present The Bitcoin Core developers | ||
| // Distributed under the MIT software license, see the accompanying | ||
| // file COPYING or https://opensource.org/license/mit/. | ||
|
|
||
| #include <common/url.h> | ||
|
|
||
| #include <string> | ||
|
|
||
| #include <boost/test/unit_test.hpp> | ||
|
|
||
| BOOST_AUTO_TEST_SUITE(common_url_tests) | ||
|
|
||
| // These test vectors were ported from test/regress.c in the libevent library | ||
| // which used to be a dependency of the UrlDecode function. | ||
|
|
||
| BOOST_AUTO_TEST_CASE(encode_decode_test) { | ||
| BOOST_CHECK_EQUAL(UrlDecode("Hello"), "Hello"); | ||
| BOOST_CHECK_EQUAL(UrlDecode("99"), "99"); | ||
| BOOST_CHECK_EQUAL(UrlDecode(""), ""); | ||
| BOOST_CHECK_EQUAL(UrlDecode("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123456789-.~_"), | ||
| "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123456789-.~_"); | ||
| BOOST_CHECK_EQUAL(UrlDecode("%20"), " "); | ||
| BOOST_CHECK_EQUAL(UrlDecode("%FF%F0%E0"), "\xff\xf0\xe0"); | ||
| BOOST_CHECK_EQUAL(UrlDecode("%01%19"), "\x01\x19"); | ||
| BOOST_CHECK_EQUAL(UrlDecode("http%3A%2F%2Fwww.ietf.org%2Frfc%2Frfc3986.txt"), | ||
| "http://www.ietf.org/rfc/rfc3986.txt"); | ||
| BOOST_CHECK_EQUAL(UrlDecode("1%2B2%3D3"), "1+2=3"); | ||
| } | ||
|
|
||
| BOOST_AUTO_TEST_CASE(decode_malformed_test) { | ||
| BOOST_CHECK_EQUAL(UrlDecode("%%xhello th+ere \xff"), "%%xhello th+ere \xff"); | ||
|
|
||
| BOOST_CHECK_EQUAL(UrlDecode("%"), "%"); | ||
| BOOST_CHECK_EQUAL(UrlDecode("%%"), "%%"); | ||
| BOOST_CHECK_EQUAL(UrlDecode("%%%"), "%%%"); | ||
| BOOST_CHECK_EQUAL(UrlDecode("%%%%"), "%%%%"); | ||
|
|
||
| BOOST_CHECK_EQUAL(UrlDecode("+"), "+"); | ||
| BOOST_CHECK_EQUAL(UrlDecode("++"), "++"); | ||
|
|
||
| BOOST_CHECK_EQUAL(UrlDecode("?"), "?"); | ||
| BOOST_CHECK_EQUAL(UrlDecode("??"), "??"); | ||
|
|
||
| BOOST_CHECK_EQUAL(UrlDecode("%G1"), "%G1"); | ||
| BOOST_CHECK_EQUAL(UrlDecode("%2"), "%2"); | ||
| BOOST_CHECK_EQUAL(UrlDecode("%ZX"), "%ZX"); | ||
|
|
||
| BOOST_CHECK_EQUAL(UrlDecode("valid%20string%G1"), "valid string%G1"); | ||
| BOOST_CHECK_EQUAL(UrlDecode("%20invalid%ZX"), " invalid%ZX"); | ||
| BOOST_CHECK_EQUAL(UrlDecode("%20%G1%ZX"), " %G1%ZX"); | ||
|
|
||
| BOOST_CHECK_EQUAL(UrlDecode("%1 "), "%1 "); | ||
| BOOST_CHECK_EQUAL(UrlDecode("% 9"), "% 9"); | ||
| BOOST_CHECK_EQUAL(UrlDecode(" %Z "), " %Z "); | ||
| BOOST_CHECK_EQUAL(UrlDecode(" % X"), " % X"); | ||
|
|
||
| BOOST_CHECK_EQUAL(UrlDecode("%-1"), "%-1"); | ||
| BOOST_CHECK_EQUAL(UrlDecode("%1-"), "%1-"); | ||
| } | ||
|
|
||
| BOOST_AUTO_TEST_CASE(decode_lowercase_hex_test) { | ||
| BOOST_CHECK_EQUAL(UrlDecode("%f0%a0%b0"), "\xf0\xa0\xb0"); | ||
| } | ||
|
|
||
| BOOST_AUTO_TEST_CASE(decode_internal_nulls_test) { | ||
| std::string result1{"\0\0x\0\0", 5}; | ||
| BOOST_CHECK_EQUAL(UrlDecode("%00%00x%00%00"), result1); | ||
| std::string result2{"abc\0\0", 5}; | ||
| BOOST_CHECK_EQUAL(UrlDecode("abc%00%00"), result2); | ||
| } | ||
|
|
||
| BOOST_AUTO_TEST_SUITE_END() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,13 +8,14 @@ | |
| #include <logging.h> | ||
| #include <policy/policy.h> | ||
| #include <stats/client.h> | ||
| #include <util/time.h> | ||
|
|
||
| #include <cassert> | ||
|
|
||
| /** Expiration time for orphan transactions in seconds */ | ||
| static constexpr int64_t ORPHAN_TX_EXPIRE_TIME = 20 * 60; | ||
| /** Minimum time between orphan transactions expire time checks in seconds */ | ||
| static constexpr int64_t ORPHAN_TX_EXPIRE_INTERVAL = 5 * 60; | ||
| /** Expiration time for orphan transactions */ | ||
| static constexpr auto ORPHAN_TX_EXPIRE_TIME{20min}; | ||
| /** Minimum time between orphan transactions expire time checks */ | ||
| static constexpr auto ORPHAN_TX_EXPIRE_INTERVAL{5min}; | ||
|
|
||
|
|
||
| bool TxOrphanage::AddTx(const CTransactionRef& tx, NodeId peer) | ||
|
|
@@ -39,7 +40,7 @@ bool TxOrphanage::AddTx(const CTransactionRef& tx, NodeId peer) | |
| return false; | ||
| } | ||
|
|
||
| auto ret = m_orphans.emplace(hash, OrphanTx{tx, peer, GetTime() + ORPHAN_TX_EXPIRE_TIME, m_orphan_list.size(), sz}); | ||
| auto ret = m_orphans.emplace(hash, OrphanTx{tx, peer, Now<NodeSeconds>() + ORPHAN_TX_EXPIRE_TIME, m_orphan_list.size(), sz}); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔴 Blocking: Missing prerequisites for bitcoin#30170: bitcoin#28364, bitcoin#29031, bitcoin#30000 New cumulative finding. Upstream bitcoin#30170 was applied on a newer TxOrphanage baseline: its pre-PR state indexed m_orphans by Wtxid, erased by Wtxid, had a TXPACKAGES elapsed-time removal log, and used LimitOrphans(unsigned int max_orphans, FastRandomContext& rng). Those upstream baseline pieces trace to bitcoin#28364, bitcoin#29031, and bitcoin#30000. Dash current head adapts the time-type conversion onto the older txid-keyed orphanage with internal RNG creation and no elapsed-time TXPACKAGES removal log. The adaptation appears clean for the narrow NodeSeconds conversion, so this is not blocking, but under the origin-based prerequisite rule the upstream dependency chain for the claimed bitcoin#30170 backport is incomplete. Policy gate (backport-prereq-restore): For full upstream backport PRs, a missing prerequisite is blocking unless the finding is explicitly allowlisted (e.g. source: ['codex-backport-reviewer'] |
||
| assert(ret.second); | ||
| m_orphan_list.push_back(ret.first); | ||
| for (const CTxIn& txin : tx->vin) { | ||
|
|
@@ -121,12 +122,12 @@ void TxOrphanage::LimitOrphans(unsigned int max_orphans_size) | |
| LOCK(m_mutex); | ||
|
|
||
| unsigned int nEvicted = 0; | ||
| static int64_t nNextSweep; | ||
| int64_t nNow = GetTime(); | ||
| static NodeSeconds nNextSweep; | ||
| auto nNow{Now<NodeSeconds>()}; | ||
| if (nNextSweep <= nNow) { | ||
| // Sweep out expired orphan pool entries: | ||
| int nErased = 0; | ||
| int64_t nMinExpTime = nNow + ORPHAN_TX_EXPIRE_TIME - ORPHAN_TX_EXPIRE_INTERVAL; | ||
| auto nMinExpTime = nNow + ORPHAN_TX_EXPIRE_TIME - ORPHAN_TX_EXPIRE_INTERVAL; | ||
| std::map<uint256, OrphanTx>::iterator iter = m_orphans.begin(); | ||
| while (iter != m_orphans.end()) | ||
| { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider to do bitcoin#29967 to addition for bitcoin#29904