Page MenuHomePhabricator

Merge #14885: rpc: Assert named arguments are unique in RPCHelpMan
ClosedPublic

Authored by nakihito on Mar 27 2020, 00:22.

Details

Summary

e09a5875ca rpc: Assert named arguments are unique in RPCHelpMan (João Barbosa)

Pull request description:

Prevents an obvious mistake.

Tree-SHA512: 32c24a1934b17ab6f0d5cd31bdf0388e93ee5156ccc1b4f78eb9fd7f1d4b27a4b978b594ff11812bc9f20987c9fc36bf4497ddaedf18cf6bcbea19c050571334

Backport of Core PR14885

Depends on D5746

Test Plan
ninja
./bitcoind
mkdir internalerror
./bitcoin-cli help > RPCs
./getrpchelps.sh RPCs internalerror
grep -rnI Internal\ error internalerror

The grep command's output should be empty.

Script:

Change the name of an argument for an RPC to be the same as another
i.e. waitforblock in rpc/blockchain.cpp from

{"blockhash", RPCArg::Type::STR_HEX, /* opt */ false,

to

 {"timeout", RPCArg::Type::STR_HEX, /* opt */ false,
ninja
./bitcoind
./bitcoin-cli help waitforblock

Confirm bitcoind does not crash and that bitcoin-cli outputs the following error:

Internal bug detected: 'named_args.insert(arg.m_name).second'
You may report this issue here: https://github.com/Bitcoin-ABC/bitcoin-abc/issues

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Owners added a reviewer: Restricted Owners Package.Mar 27 2020, 00:22

[Bot Message]
One or more PR numbers were detected in the summary.
Links to those PRs have been inserted into the summary for reference.

Fabien requested changes to this revision.Mar 27 2020, 13:25
Fabien added a subscriber: Fabien.
Fabien added inline comments.
src/rpc/util.cpp
124 ↗(On Diff #17236)

From the developer notes:

- Assertions should not have side-effects

  - *Rationale*: Even though the source code is set to refuse to compile
    with assertions disabled, having side-effects in assertions is unexpected and
    makes the code harder to understand

If assert is compiled out the insertion is lost.

This revision now requires changes to proceed.Mar 27 2020, 13:25

Going to have to go through some dependencies to remove the assert.

Rebased of D5746 to remove assert.

nakihito edited the test plan for this revision. (Show Details)
nakihito edited the summary of this revision. (Show Details)
deadalnix requested changes to this revision.Apr 17 2020, 00:33
deadalnix added a subscriber: deadalnix.
deadalnix added inline comments.
src/rpc/util.cpp
292 ↗(On Diff #18873)

Why not an assert as in the original PR?

This revision now requires changes to proceed.Apr 17 2020, 00:33
nakihito added inline comments.
src/rpc/util.cpp
292 ↗(On Diff #18873)

https://reviews.bitcoinabc.org/D5586?id=17236#inline-34624

From the developer notes:

  • Assertions should not have side-effects
    • *Rationale*: Even though the source code is set to refuse to compile with assertions disabled, having side-effects in assertions is unexpected and makes the code harder to understand

If assert is compiled out the insertion is lost.

Fabien added inline comments.
src/rpc/util.cpp
292 ↗(On Diff #18873)

Oh I was just asking for splitting the insertion and the assert in 2 lines, but thanks for the backports.

This revision is now accepted and ready to land.Apr 20 2020, 08:54