Skip to content

Conversation

ryanofsky
Copy link
Contributor

@ryanofsky ryanofsky commented Sep 15, 2021

This is meant to improve readability of code and remove guesswork needed to determine argument types and migrate to typed arguments (#22978) by having distinctly named GetArg GetArgs GetBoolArg and GetIntArg methods.


This commit was originally part of #22766 and had some review discussion there. But it was wisely suggested to be split off to make that PR smaller.

@DrahtBot
Copy link
Contributor

DrahtBot commented Sep 15, 2021

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #23095 (refactor: Use C++17 std::clamp by hebasto)
  • #23061 (Fix (inverse) meaning of -persistmempool by MarcoFalke)
  • #22950 ([p2p] Pimpl AddrMan to abstract implementation details by amitiuttarwar)
  • #22674 (validation: mempool validation and submission for packages of 1 child + parents by glozow)
  • #22290 (Package Mempool Submission with Package Fee-Bumping by glozow)
  • #21726 (Improve Indices on pruned nodes via prune blockers by fjahr)
  • #21527 (net_processing: lock clean up by ajtowns)
  • #20196 (net: fix GetListenPort() to derive the proper port by vasild)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@maflcko
Copy link
Member

maflcko commented Sep 22, 2021

Inspected the binary to check that only the right calls (with second argument long) are replaced. IIUC the patch should be correct if it compiles, because GetArg was only used for types that don't convert into each other (strings and integers).

git diff --word-diff-regex=. -U0 -- /tmp/{old,new}/d_objdump
diff --git a/tmp/old/d_objdump b/tmp/new/d_objdump
index 6bd4ff20d4..1a2f13bc07 100644
--- a/tmp/old/d_objdump
+++ b/tmp/new/d_objdump
@@ -19346 +19346 @@ Disassembly of section .text:
   3d495:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -31578 +31578 @@ Disassembly of section .text:
   4d31d:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -31881 +31881 @@ Disassembly of section .text:
   4d9e8:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -32610 +32610 @@ Disassembly of section .text:
   4ead3:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -32635 +32635 @@ Disassembly of section .text:
   4eb70:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -32732 +32732 @@ Disassembly of section .text:
   4edc9:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -32858 +32858 @@ Disassembly of section .text:
   4f0ce:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -32879 +32879 @@ Disassembly of section .text:
   4f14c:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -33268 +33268 @@ Disassembly of section .text:
   4fad3:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -33343 +33343 @@ Disassembly of section .text:
   4fca1:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -33359 +33359 @@ Disassembly of section .text:
   4fd08:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -33415 +33415 @@ Disassembly of section .text:
   4fe58:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -33443 +33443 @@ Disassembly of section .text:
   4ff03:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -33895 +33895 @@ Disassembly of section .text:
   509ac:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -36937 +36937 @@ Disassembly of section .text:
   54106:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -37772 +37772 @@ Disassembly of section .text:
   553a7:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -37909 +37909 @@ Disassembly of section .text:
   55686:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -39117 +39117 @@ Disassembly of section .text:
   56fec:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -39219 +39219 @@ Disassembly of section .text:
   571d6:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -40946 +40946 @@ Disassembly of section .text:
   597cc:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -41106 +41106 @@ Disassembly of section .text:
   59b40:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -41118 +41118 @@ Disassembly of section .text:
   59b90:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -43828 +43828 @@ Disassembly of section .text:
   5d4e2:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -43855 +43855 @@ Disassembly of section .text:
   5d58f:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -43940 +43940 @@ Disassembly of section .text:
   5d758:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -69277 +69277 @@ Disassembly of section .text:
   77720:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -69457 +69457 @@ Disassembly of section .text:
   77a03:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -70352 +70352 @@ Disassembly of section .text:
   78880:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -71732 +71732 @@ Disassembly of section .text:
   7a12c:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -97948 +97948 @@ Disassembly of section .text:
   97257:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -97977 +97977 @@ Disassembly of section .text:
   972da:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -138273 +138273 @@ Disassembly of section .text:
   c20bd:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -155265 +155265 @@ Disassembly of section .text:
   d6a5a:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -169911 +169911 @@ Disassembly of section .text:
   e6eea:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -229830 +229830 @@ Disassembly of section .text:
  123600:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -229855 +229855 @@ Disassembly of section .text:
  123677:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -229947 +229947 @@ Disassembly of section .text:
  12383c:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -229971 +229971 @@ Disassembly of section .text:
  1238d1:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -229996 +229996 @@ Disassembly of section .text:
  12396e:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -230022 +230022 @@ Disassembly of section .text:
  123a0f:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -230302 +230302 @@ Disassembly of section .text:
  123e93:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -325034 +325034 @@ Disassembly of section .text:
  182109:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -385583 +385583 @@ Disassembly of section .text:
  1cfd9b:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -556782 +556782 @@ Disassembly of section .text:
  29fc3a:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -564683 +564683 @@ Disassembly of section .text:
  2a71a3:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -573015 +573015 @@ Disassembly of section .text:
  2af871:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -593321 +593321 @@ Disassembly of section .text:
  2c4f9c:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -593337 +593337 @@ Disassembly of section .text:
  2c5007:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -637996 +637996 @@ Disassembly of section .text:
  2f1cb7:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -638009 +638009 @@ Disassembly of section .text:
  2f1d06:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -639214 +639214 @@ Disassembly of section .text:
  2f346d:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -639227 +639227 @@ Disassembly of section .text:
  2f34d1:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -643073 +643073 @@ Disassembly of section .text:
  2f7dbc:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -643098 +643098 @@ Disassembly of section .text:
  2f7e33:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -643124 +643124 @@ Disassembly of section .text:
  2f7eb6:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -643149 +643149 @@ Disassembly of section .text:
  2f7f2e:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -645647 +645647 @@ Disassembly of section .text:
  2fa8b7:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -652571 +652571 @@ Disassembly of section .text:
  302cf5:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -652776 +652776 @@ Disassembly of section .text:
  3030a3:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -660428 +660428 @@ Disassembly of section .text:
  30bf6d:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -671358 +671358 @@ Disassembly of section .text:
  317b1f:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -671453 +671453 @@ Disassembly of section .text:
  317cb7:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -683716 +683716 @@ Disassembly of section .text:
  325c04:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -687507 +687507 @@ Disassembly of section .text:
  32a9c3:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -722831 +722831 @@ Disassembly of section .text:
  34e94c:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -774728 +774728 @@ Disassembly of section .text:
  384581:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -774756 +774756 @@ Disassembly of section .text:
  384613:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -775515 +775515 @@ Disassembly of section .text:
  385752:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -778167 +778167 @@ Disassembly of section .text:
  38890b:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -816776 +816776 @@ Disassembly of section .text:
  3b1039:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -817168 +817168 @@ Disassembly of section .text:
  3b174f:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -1018869 +1018869 @@ Disassembly of section .text:
  49fc24:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -1027664 +1027664 @@ Disassembly of section .text:
  4a8c38:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -1031786 +1031786 @@ Disassembly of section .text:
  4acef0:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -1078195 +1078195 @@ Disassembly of section .text:
  4ded92:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -1175949 +1175949 @@ Disassembly of section .text:
  54387c:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -1232047 +1232047 @@ Disassembly of section .text:
  5867bf:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -1241981 +1241981 @@ Disassembly of section .text:
  59097e:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>
@@ -1422701 +1422701 @@ Disassembly of section .text:
0000000000647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>:
@@ -1422714 +1422714 @@ Disassembly of section .text:
  64773d:	je     64779f <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const+0x8f>
@@ -1422716 +1422716 @@ Disassembly of section .text:
  647742:	jne    64777d <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const+0x6d>
@@ -1422721 +1422721 @@ Disassembly of section .text:
  647757:	je     64775d <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const+0x4d>
@@ -1422723 +1422723 @@ Disassembly of section .text:
  64775b:	jmp    64779f <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const+0x8f>
@@ -1422726 +1422726 @@ Disassembly of section .text:
  647763:	jne    64777d <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const+0x6d>
@@ -1422731 +1422731 @@ Disassembly of section .text:
  647778:	je     6477c0 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const+0xb0>
@@ -1422734 +1422734 @@ Disassembly of section .text:
  647780:	jne    64778c <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const+0x7c>
@@ -1422737 +1422737 @@ Disassembly of section .text:
  64778a:	jmp    64779c <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const+0x8c>
@@ -1422747 +1422747 @@ Disassembly of section .text:
  6477b5:	jne    6477c7 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const+0xb7>
@@ -1422753 +1422753 @@ Disassembly of section .text:
  6477c5:	jmp    64779f <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const+0x8f>
@@ -1469343 +1469343 @@ Disassembly of section .text:
  675206:	callq  647710 <ArgsManager::Get{+Int+}Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long) const>

@maflcko
Copy link
Member

maflcko commented Sep 22, 2021

review ACK 5b47496 💜

Show signature and timestamp

Signature:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

review ACK 5b4749680485bfc32b1ed453bce5015f8a087189 💜
-----BEGIN PGP SIGNATURE-----

iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
pUgy/gv+KxAwgYwxopQXdUWnvHNEXwVR+3pwrRDki3U1WA7vP3X2rYWKYvVrr02c
YpR4361XtL9C/SAJbfCeHnKA9gEwmTgZophCx8jRJi1+SyzgSkAYqzlLfV7J8mxC
53khFqgLzxlQ4QdPCDdYyQZXJYPRIwnrN+2TWkCoDqCwYSf+9Nml9ZZxwdv6uGE0
fMxMg3Jes5z5N9kNe3SFIUb6BSVe0oMJRH/ZSgWJbEiQ51ECzALAKrygtTvXD3TE
o8aOD+CdRU53cm7605Z7TD3tZt2KdYeHuv8u8xnt7z/L/HwJuk6nCyZbw+xDCPJx
ws2nDYclKoqWm+5dNIDQcrPKHA/rSBzMK1Qx/NDwejVZt4FZcMmWU8NUeb5rQ4tl
uhAZKNOgLDNuJLozgh4gjBjPChsAcPG8iN9hWQvVWbiKvoN3eYulp/JA0JrVW2b8
XptnTG2WjolKPN484SpA0vamCWx+4IGUbVIA8d3dhjpiG2sZwv+AUicaq2+LCMzE
y+U8Sdd4
=ENki
-----END PGP SIGNATURE-----

Timestamp of file with hash 4f858a3b99bca7b8ec087959266bafe189cdb41593a9ae56bcea40bae04969f5 -

src/init.cpp Outdated
@@ -217,7 +217,7 @@ void Shutdown(NodeContext& node)
node.banman.reset();
node.addrman.reset();

if (node.mempool && node.mempool->IsLoaded() && node.args->GetArg("-persistmempool", DEFAULT_PERSIST_MEMPOOL)) {
if (node.mempool && node.mempool->IsLoaded() && node.args->GetIntArg("-persistmempool", DEFAULT_PERSIST_MEMPOOL)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MarcoFalke's #23061 changes this to GetBoolArg. Given the ACK there, I assume that is the more correct change? If that is going to be backported then it can be merged first and this PR rebased on top.

Copy link
Contributor

@kiminuo kiminuo Sep 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I would expect so too as DEFAULT_PERSIST_MEMPOOL is a boolean constant.)

@LarryRuane
Copy link
Contributor

LarryRuane commented Sep 23, 2021

ACK 5b47496
I verified that all remaining calls to GetArg() have a string as the second argument (although I guess I didn't need to, any of those would not have compiled), and ran the unit (boost) tests.

Copy link
Contributor

@kiminuo kiminuo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK 5b47496

Went line by line and the patch looks correct to me. https://github.com/bitcoin/bitcoin/pull/22976/files#r714600644 seems good to address though.

@@ -1217,7 +1217,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
if (!ignores_incoming_txs) node.fee_estimator = std::make_unique<CBlockPolicyEstimator>();

assert(!node.mempool);
int check_ratio = std::min<int>(std::max<int>(args.GetArg("-checkmempool", chainparams.DefaultConsistencyChecks() ? 1 : 0), 0), 1000000);
int check_ratio = std::min<int>(std::max<int>(args.GetIntArg("-checkmempool", chainparams.DefaultConsistencyChecks() ? 1 : 0), 0), 1000000);
Copy link
Contributor

@kiminuo kiminuo Sep 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Not for this PR but looking at the line I would expect std::clamp here)

edit: Addressed by #23095

@@ -1263,7 +1263,7 @@ void InitScriptExecutionCache() {
g_scriptExecutionCacheHasher.Write(nonce.begin(), 32);
// nMaxCacheSize is unsigned. If -maxsigcachesize is set to zero,
// setup_bytes creates the minimum possible cache (2 elements).
size_t nMaxCacheSize = std::min(std::max((int64_t)0, gArgs.GetArg("-maxsigcachesize", DEFAULT_MAX_SIG_CACHE_SIZE) / 2), MAX_MAX_SIG_CACHE_SIZE) * ((size_t) 1 << 20);
size_t nMaxCacheSize = std::min(std::max((int64_t)0, gArgs.GetIntArg("-maxsigcachesize", DEFAULT_MAX_SIG_CACHE_SIZE) / 2), MAX_MAX_SIG_CACHE_SIZE) * ((size_t) 1 << 20);
Copy link
Contributor

@kiminuo kiminuo Sep 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Not for this PR but looking at the line I would expect std::clamp here)

edit: Addressed by #23095

@@ -2517,7 +2517,7 @@ bool CChainState::ActivateBestChain(BlockValidationState& state, std::shared_ptr

CBlockIndex *pindexMostWork = nullptr;
CBlockIndex *pindexNewTip = nullptr;
int nStopAtHeight = gArgs.GetArg("-stopatheight", DEFAULT_STOPATHEIGHT);
int nStopAtHeight = gArgs.GetIntArg("-stopatheight", DEFAULT_STOPATHEIGHT);
Copy link
Contributor

@kiminuo kiminuo Sep 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not for this PR but isn't it better to cast it explicitely here? It's very easy to think that GetIntArg returns int and not int64_t.

@ryanofsky
Copy link
Contributor Author

Rebased 5b47496 -> 89b96f9 (pr/intarg.1 -> pr/intarg.2, compare) due to conflict with #22818

@hebasto
Copy link
Member

hebasto commented Sep 25, 2021

Concept ACK.

Copy link
Member

@hebasto hebasto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggesting script change:

@@ -7,5 +7,5 @@
 with compile time checking.
 
 -BEGIN VERIFY SCRIPT-
-git grep -l GetArg | xargs sed -i 's/GetArg(\([^)]*\( [0-9]\+\|-1\|port\|BaseParams().RPCPort()\|Params().GetDefaultPort()\|_TIMEOUT\|Height\|_WORKQUEUE\|_THREADS\|_MEMPOOL\|_CONNECTIONS\|LIMIT\|SigOp\|Bytes\|_SIZE\|_VERSION\|_AGE\|_CHECKS\|Checks() ? 1 : 0\|_BANTIME\|Cache\|BLOCKS\|LEVEL\|Weight\|Version\|BUFFER\|TARGET\|WEIGHT\|TXN\|TRANSACTIONS\|ADJUSTMENT\|i64\|Size\|nDefault\|_EXPIRY\|HEIGHT\|SIZE\|SNDHWM\|_TIME_MS\)\))/GetIntArg(\1)/g'
+git grep -l GetArg | xargs sed -i 's/GetArg(\([^)]*\( [0-9]\+\|-1\|port\|BaseParams().RPCPort()\|Params().GetDefaultPort()\|_TIMEOUT\|Height\|_WORKQUEUE\|_THREADS\|_CONNECTIONS\|LIMIT\|SigOp\|Bytes\|_VERSION\|_AGE\|_CHECKS\|Checks() ? 1 : 0\|_BANTIME\|Cache\|BLOCKS\|LEVEL\|Weight\|Version\|BUFFER\|TARGET\|WEIGHT\|TXN\|TRANSACTIONS\|ADJUSTMENT\|i64\|Size\|nDefault\|_EXPIRY\|HEIGHT\|SIZE\|SNDHWM\|_TIME_MS\)\))/GetIntArg(\1)/g'
 -END VERIFY SCRIPT-

Improve readability of code, simplify future scripted diff cleanup PRs, and be
more consistent with naming for GetBoolArg.

This will also be useful for replacing runtime settings type checking
with compile time checking.

-BEGIN VERIFY SCRIPT-
git grep -l GetArg | xargs sed -i 's/GetArg(\([^)]*\( [0-9]\+\|-1\|port\|BaseParams().RPCPort()\|Params().GetDefaultPort()\|_TIMEOUT\|Height\|_WORKQUEUE\|_THREADS\|_CONNECTIONS\|LIMIT\|SigOp\|Bytes\|_VERSION\|_AGE\|_CHECKS\|Checks() ? 1 : 0\|_BANTIME\|Cache\|BLOCKS\|LEVEL\|Weight\|Version\|BUFFER\|TARGET\|WEIGHT\|TXN\|TRANSACTIONS\|ADJUSTMENT\|i64\|Size\|nDefault\|_EXPIRY\|HEIGHT\|SIZE\|SNDHWM\|_TIME_MS\)\))/GetIntArg(\1)/g'
-END VERIFY SCRIPT-

Co-authored-by: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>
@ryanofsky
Copy link
Contributor Author

Rebased 89b96f9 -> 93b9800 (pr/intarg.2 -> pr/intarg.3, compare) due to conflict with #23061. Thanks @hebasto for simplifying the scripted diff after that PR!

Copy link
Member

@hebasto hebasto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 93b9800.

Copy link
Member

@maflcko maflcko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re-ACK 93b9800 📨

Show signature and timestamp

Signature:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

re-ACK 93b9800fec588fc0c258e754405db1e9f89cfb81 📨
-----BEGIN PGP SIGNATURE-----

iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
pUhsoQv+NLfJRdSCRTCqPhR9Dep3iK1duj4XvvoYRP89eikIjevfNPM3bRCXEm0Q
rgyEaxfo5QdvbOZU9gwLjCFUbYGrkNAD1m66LRBf71Bqk+5FJ+wZHDo6cd/RpRxZ
Ijv73U9D1L/bI33ftzVc8yrRCLzU7oYuxgSwX9/OxJqmm1GfdQ4TsJ3xwtX9aBz9
etqr5pX+iTPNfGPMKbKci6qGCkUys8ANt7XoNV8O92cczq9IPlQrau0YJ81Mulaw
jwWn48I3P1gMHx4y9MoWl1xH+0ddoBnGI4PyVwKECUBPac//jZspAkp5PtF3oF8l
4/ejTHzDeA84oanUoAEq3jMbv0dleBxdQkVDB4fs7+JhIxCgW5H7IjSgtlU3G07r
POmz9Y6N/5JG1c22T9tPn385M5pCda2LTfXawusRPuLzCtcrvOC1JnfU/MbKfkvX
zPfVFe8Vt/2W9VKGnOjvkTtQCgwLMOHEc9OjTSOSBL+GoffQrBUwN8KOUVRewCtX
PYZLdVyl
=6CRv
-----END PGP SIGNATURE-----

Timestamp of file with hash 6a0788037cf2c7d2a33005e2ca5b19d4e0ecf44890a2d5133d708fd3c90446a9 -

@maflcko maflcko merged commit 825f4a6 into bitcoin:master Sep 27, 2021
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Sep 27, 2021
Fabcien pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Sep 12, 2022
Summary:
This is a backport of [[bitcoin/bitcoin#22976 | core#22976]]
Depends on D11944

Test Plan: `ninja all check-all`

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D11947
@bitcoin bitcoin locked and limited conversation to collaborators Oct 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants