-
Notifications
You must be signed in to change notification settings - Fork 1.2k
backport: Merge bitcoin#28523, 26638, 28976, 27822, 28671 #7358
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
a5264f9
c34e457
3c47eb7
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 |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ | |
| #include <rpc/server.h> | ||
|
|
||
| #include <addrman.h> | ||
| #include <addrman_impl.h> | ||
| #include <banman.h> | ||
| #include <chainparams.h> | ||
| #include <clientversion.h> | ||
|
|
@@ -1174,6 +1175,74 @@ static RPCHelpMan getaddrmaninfo() | |
| }; | ||
| } | ||
|
|
||
| UniValue AddrmanEntryToJSON(const AddrInfo& info) | ||
| { | ||
| UniValue ret(UniValue::VOBJ); | ||
| ret.pushKV("address", info.ToStringAddr()); | ||
| ret.pushKV("port", info.GetPort()); | ||
| ret.pushKV("services", (uint64_t)info.nServices); | ||
| ret.pushKV("time", int64_t{TicksSinceEpoch<std::chrono::seconds>(info.nTime)}); | ||
| ret.pushKV("network", GetNetworkName(info.GetNetClass())); | ||
| ret.pushKV("source", info.source.ToStringAddr()); | ||
| ret.pushKV("source_network", GetNetworkName(info.source.GetNetClass())); | ||
| return ret; | ||
| } | ||
|
|
||
| UniValue AddrmanTableToJSON(const std::vector<std::pair<AddrInfo, AddressPosition>>& tableInfos) | ||
| { | ||
| UniValue table(UniValue::VOBJ); | ||
| for (const auto& e : tableInfos) { | ||
| AddrInfo info = e.first; | ||
| AddressPosition location = e.second; | ||
| std::ostringstream key; | ||
| key << location.bucket << "/" << location.position; | ||
| // Address manager tables have unique entries so there is no advantage | ||
| // in using UniValue::pushKV, which checks if the key already exists | ||
| // in O(N). UniValue::pushKVEnd is used instead which currently is O(1). | ||
| table.pushKVEnd(key.str(), AddrmanEntryToJSON(info)); | ||
|
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: Commit ordering: 28523 uses pushKVEnd before 27822 introduces it (bisect hazard) Within this PR the commits are ordered a5264f9 (Merge bitcoin#28523) → c34e457 (Merge bitcoin#27822) → 3c47eb7 (Merge bitcoin#28671). bitcoin#28523's new Policy gate (backport-prereq-restore): For full upstream backport PRs, a missing prerequisite is blocking unless the finding is explicitly allowlisted (e.g. source: ['claude-backport-reviewer'] 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 prerequisite before cherry-pick: bitcoin#27822 Dash commit a5264f9, the bitcoin#28523 backport, adds a call to table.pushKVEnd(...). In upstream, bitcoin#28523's parent already had UniValue::pushKVEnd because bitcoin#27822 was merged earlier. In Dash, a5264f9^ still declares only UniValue::__pushKV, and pushKVEnd is introduced later by c34e457. This means the dependency chain is present only in the final head, not at the cherry-pick point; the 28523 commit itself is unbuildable. The same commit also adds a test using time.time() before Dash adds the import in the later 28671 adaptation. 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'] |
||
| } | ||
| return table; | ||
| } | ||
|
|
||
| static RPCHelpMan getrawaddrman() | ||
| { | ||
| return RPCHelpMan{"getrawaddrman", | ||
| "EXPERIMENTAL warning: this call may be changed in future releases.\n" | ||
| "\nReturns information on all address manager entries for the new and tried tables.\n", | ||
| {}, | ||
| RPCResult{ | ||
| RPCResult::Type::OBJ_DYN, "", "", { | ||
| {RPCResult::Type::OBJ_DYN, "table", "buckets with addresses in the address manager table ( new, tried )", { | ||
| {RPCResult::Type::OBJ, "bucket/position", "the location in the address manager table (<bucket>/<position>)", { | ||
| {RPCResult::Type::STR, "address", "The address of the node"}, | ||
| {RPCResult::Type::NUM, "port", "The port number of the node"}, | ||
| {RPCResult::Type::STR, "network", "The network (" + Join(GetNetworkNames(), ", ") + ") of the address"}, | ||
| {RPCResult::Type::NUM, "services", "The services offered by the node"}, | ||
| {RPCResult::Type::NUM_TIME, "time", "The " + UNIX_EPOCH_TIME + " when the node was last seen"}, | ||
| {RPCResult::Type::STR, "source", "The address that relayed the address to us"}, | ||
| {RPCResult::Type::STR, "source_network", "The network (" + Join(GetNetworkNames(), ", ") + ") of the source address"}, | ||
| }} | ||
| }} | ||
| } | ||
| }, | ||
| RPCExamples{ | ||
| HelpExampleCli("getrawaddrman", "") | ||
| + HelpExampleRpc("getrawaddrman", "") | ||
| }, | ||
| [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { | ||
| NodeContext& node = EnsureAnyNodeContext(request.context); | ||
| if (!node.addrman) { | ||
| throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Address manager functionality missing or disabled"); | ||
| } | ||
|
|
||
| UniValue ret(UniValue::VOBJ); | ||
| ret.pushKV("new", AddrmanTableToJSON(node.addrman->GetEntries(false))); | ||
| ret.pushKV("tried", AddrmanTableToJSON(node.addrman->GetEntries(true))); | ||
| return ret; | ||
| }, | ||
| }; | ||
| } | ||
|
|
||
| void RegisterNetRPCCommands(CRPCTable &t) | ||
| { | ||
| static const CRPCCommand commands[]{ | ||
|
|
@@ -1196,6 +1265,7 @@ void RegisterNetRPCCommands(CRPCTable &t) | |
| {"hidden", &sendmsgtopeer}, | ||
| {"hidden", &setmnthreadactive}, | ||
| {"hidden", &getaddrmaninfo}, | ||
| {"hidden", &getrawaddrman}, | ||
| }; | ||
| for (const auto& c : commands) { | ||
| t.appendCommand(c.name, &c); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -87,7 +87,7 @@ class UniValue { | |
| template <class It> | ||
| void push_backV(It first, It last); | ||
|
|
||
| void __pushKV(std::string key, UniValue val); | ||
| void pushKVEnd(std::string key, UniValue val); | ||
|
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. Do not modify vendored UniValue sources without an explicit exception. Line 90 introduces an API rename inside As per coding guidelines: 🤖 Prompt for AI AgentsSource: Coding guidelines |
||
| void pushKV(std::string key, UniValue val); | ||
| void pushKVs(UniValue obj); | ||
|
|
||
|
|
||
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.
🟡 Suggestion: Reorder cherry-picks: bitcoin#28523 uses pushKVEnd before bitcoin#27822 introduces it (bisect hazard)
The series orders the merges as a5264f9 (bitcoin#28523) → c34e457 (bitcoin#27822) → 3c47eb7 (bitcoin#28671). bitcoin#28523's new
AddrmanTableToJSONcallstable.pushKVEnd(...)(src/rpc/net.cpp:1202), butUniValue::pushKVEndis introduced only by bitcoin#27822, which is the next commit in this PR.Verified:
git show a5264f984a:src/univalue/include/univalue.hstill declares only__pushKV, notpushKVEnd. Commit a5264f9 therefore does not compile in isolation, breakinggit bisectacross these two commits. The final HEAD is fine because 27822 is applied.Upstream chronological order is bitcoin#27822 (2023-06-21) → bitcoin#28523 (2023-10-03). Please reorder the cherry-picks to match upstream so every intermediate commit builds. (If you also restore bitcoin#26638/bitcoin#28976 per the other finding, this is a good opportunity to fix the order while re-pushing.)
source: ['claude', 'codex']