Skip to content

Conversation

ryanofsky
Copy link
Contributor

This bug doesn't have any effects currently because it only affects
external signer RPCs which aren't currently using the wallet context,
but it does cause an appveyor failure in a upcoming PR:

https://ci.appveyor.com/project/DrahtBot/bitcoin/builds/38512882

This bug is subtle and could have been avoided if JSONRPCRequest didn't
have constructors that were so loose with type checking. Suggested
change
#21366 (comment)
eliminates these and would be a good followup for a future PR.

This PR just implements the simplest possible fix.

This bug doesn't have any effects currently because it only affects
external signer RPCs which aren't currently using the wallet context,
but it does cause an appveyor failure in a upcoming PR:

https://ci.appveyor.com/project/DrahtBot/bitcoin/builds/38512882

This bug is subtle and could have been avoided if JSONRPCRequest didn't
have constructors that were so loose with type checking.  Suggested
change
bitcoin#21366 (comment)
eliminates these and would be a good followup for a future PR.
ryanofsky added a commit to ryanofsky/bitcoin that referenced this pull request Apr 2, 2021
This just makes an additional simplification after bitcoin#21366 replaced
util::Ref with std::any. It was originally suggested
bitcoin#21366 (comment) but
delayed for a followup. It would have prevented usage bug
bitcoin#21572.
@maflcko maflcko requested a review from theStack April 2, 2021 17:51
@DrahtBot DrahtBot added the Wallet label Apr 2, 2021
Copy link
Contributor

@theStack theStack left a comment

Choose a reason for hiding this comment

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

Code-review ACK 937fd4a

This bug is subtle and could have been avoided if JSONRPCRequest didn't
have constructors that were so loose with type checking.

Though I fully support the follow-up PR (actually I also planned to open it with your suggested changes in #21366 (comment)) , I don't think the removal of the ctors alone prevents bugs like this. Nothing stops you from setting the
JSONRPCRequest member variable "context" to "m_context" instead of "&m_context" and you have exactly the same problem...

@DrahtBot
Copy link
Contributor

DrahtBot commented Apr 3, 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:

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.

ryanofsky added a commit to ryanofsky/bitcoin that referenced this pull request Apr 3, 2021
This just makes an additional simplification after bitcoin#21366 replaced
util::Ref with std::any. It was originally suggested
bitcoin#21366 (comment) but
delayed for a followup. It would have prevented usage bug
bitcoin#21572.
@ryanofsky
Copy link
Contributor Author

Nothing stops you from setting the
JSONRPCRequest member variable "context" to "m_context" instead of "&m_context" and you have exactly the same problem...

It's true the new code in #21574 doesn't stop you from writing request.context = whatever where whatever could be any type. But that's just how std::any works. The reason I think #21574 would prevent this type of bug is just that it switches to clearly assigning an rpc request context, instead of passing an context argument to an intermediate function which could be accepting any type or value. Also the change would have required an update to the #ifdef ENABLE_EXTERNAL_SIGNER code block that was overlooked in the original PR because the old code still compiled even after it was no longer correct.

Any case, thanks for reviewing this bugfix and feel free to post any concerns about #21574 in the thread there if there are problems with that cleanup or ways to improve it.

Copy link
Contributor

@meshcollider meshcollider left a comment

Choose a reason for hiding this comment

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

Code review ACK 937fd4a

Thanks for the fix!

@maflcko maflcko merged commit aa69471 into bitcoin:master Apr 7, 2021
ryanofsky added a commit to ryanofsky/bitcoin that referenced this pull request Apr 7, 2021
This just makes an additional simplification after bitcoin#21366 replaced
util::Ref with std::any. It was originally suggested
bitcoin#21366 (comment) but
delayed for a followup. It would have prevented usage bug
bitcoin#21572.
ryanofsky added a commit to ryanofsky/bitcoin that referenced this pull request Apr 7, 2021
This just makes an additional simplification after bitcoin#21366 replaced
util::Ref with std::any. It was originally suggested
bitcoin#21366 (comment) but
delayed for a followup. It would have prevented usage bug
bitcoin#21572.
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Apr 7, 2021
…1366

937fd4a Fix wrong wallet RPC context set after bitcoin#21366 (Russell Yanofsky)

Pull request description:

  This bug doesn't have any effects currently because it only affects
  external signer RPCs which aren't currently using the wallet context,
  but it does cause an appveyor failure in a upcoming PR:

  https://ci.appveyor.com/project/DrahtBot/bitcoin/builds/38512882

  This bug is subtle and could have been avoided if JSONRPCRequest didn't
  have constructors that were so loose with type checking.  Suggested
  change
  bitcoin#21366 (comment)
  eliminates these and would be a good followup for a future PR.

  This PR just implements the simplest possible fix.

ACKs for top commit:
  theStack:
    Code-review ACK 937fd4a
  meshcollider:
    Code review ACK 937fd4a

Tree-SHA512: 53e6265ed6c7abb47d2b3e77d1604edfeb993c3a2440f0c19679cfeb23516965e6707ff486196a0acfbeff21c79a9a08b5cd33bae9a232d33d0134bca1bd0ff3
maflcko pushed a commit to bitcoin-core/gui that referenced this pull request Apr 8, 2021
9044522 Drop JSONRPCRequest constructors after #21366 (Russell Yanofsky)

Pull request description:

  This just makes an additional simplification after #21366 replaced
  util::Ref with std::any. It was originally suggested
  bitcoin/bitcoin#21366 (comment) but
  delayed for a followup. It would have prevented usage bug
  bitcoin/bitcoin#21572.

ACKs for top commit:
  promag:
    ACK 9044522, fixed conflict in src/wallet/interfaces.cpp.

Tree-SHA512: e909411b8f75013620b94e1a609296befb832fdcb574cd2e6689bfe3c636b03cd4ac1ccb2b32b532daf0f2131bb043464024966310fffc7e3cad77713d4bd0ef
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Apr 8, 2021
…1366

9044522 Drop JSONRPCRequest constructors after bitcoin#21366 (Russell Yanofsky)

Pull request description:

  This just makes an additional simplification after bitcoin#21366 replaced
  util::Ref with std::any. It was originally suggested
  bitcoin#21366 (comment) but
  delayed for a followup. It would have prevented usage bug
  bitcoin#21572.

ACKs for top commit:
  promag:
    ACK 9044522, fixed conflict in src/wallet/interfaces.cpp.

Tree-SHA512: e909411b8f75013620b94e1a609296befb832fdcb574cd2e6689bfe3c636b03cd4ac1ccb2b32b532daf0f2131bb043464024966310fffc7e3cad77713d4bd0ef
ryanofsky added a commit to ryanofsky/bitcoin that referenced this pull request Apr 8, 2021
This just makes an additional simplification after bitcoin#21366 replaced
util::Ref with std::any. It was originally suggested
bitcoin#21366 (comment) but
delayed for a followup. It would have prevented usage bug
bitcoin#21572.
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Aug 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants