Skip to content

Conversation

maflcko
Copy link
Member

@maflcko maflcko commented May 13, 2021

To clarify that a call to this only changes the random state and nothing else.

@DrahtBot
Copy link
Contributor

DrahtBot commented May 13, 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.

Copy link
Contributor

@promag promag left a comment

Choose a reason for hiding this comment

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

ACK fa8e3f7.

Built locally, also tried to avoid mutable members, but all things considered, this approach seems preferable.

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 fa8e3f7

@maflcko maflcko force-pushed the 2105-addrmanConstSelect branch from fa8e3f7 to fa84581 Compare May 22, 2021 07:38
@maflcko
Copy link
Member Author

maflcko commented May 22, 2021

Rebased

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.

re-ACK fa84581 🦉
Checked that changes since my last ACK are only rebase-related via git range-diff fa8e3f78...fa845812

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.

re-re-ACK fa49ab3

Checked that changes since my last re-ACK are only rebase-related (caused by 5cd7f8a and 8caf60d) via git range-diff fa845812...fa49ab3

maflcko pushed a commit that referenced this pull request Jun 13, 2021
…only once

faf7623 fuzz: Call const member functions in addrman fuzz test only once (MarcoFalke)

Pull request description:

  Logically based on #21940

  Currently the fuzz test may spend a long time generating random numbers:

  ![Screenshot from 2021-05-13 12-14-09](https://user-images.githubusercontent.com/6399679/118112238-06ecd880-b3e5-11eb-8013-6e0c20e6159f.png)

  Fix that by calling const member functions only once.

  Hopefully fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=34224

ACKs for top commit:
  practicalswift:
    cr ACK faf7623: touches only `src/test/fuzz/addrman.cpp`

Tree-SHA512: 0fe9e0111eb1706fc39bd2f90d4b87a771882bada54c01e96d8e79c2afca2f1081139d5ab680285a81835cc5142e74ada422a181db34b01904975d1e167e64c2
@maflcko
Copy link
Member Author

maflcko commented Jun 14, 2021

Rebased and added one commit

@maflcko maflcko force-pushed the 2105-addrmanConstSelect branch from fa49ab3 to fa35236 Compare June 14, 2021 07:25
@maflcko maflcko force-pushed the 2105-addrmanConstSelect branch from fa35236 to faecfad Compare June 14, 2021 15:59
@maflcko maflcko force-pushed the 2105-addrmanConstSelect branch from faecfad to fa47bdd Compare July 19, 2021 19:39
Copy link
Contributor

@lsilva01 lsilva01 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 and Tested ACK fa47bdd on Ubuntu 20.04.

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.

re-ACK fa47bdd

Checked again that changes since my last re-ACK are only rebase-related via git range-diff fa49ab3...fa47bddd (plus the fuzzing related extra commit)

@fanquake fanquake requested a review from jnewbery July 20, 2021 02:56
@maflcko maflcko force-pushed the 2105-addrmanConstSelect branch from fa47bdd to fab755b Compare July 21, 2021 14:02
@maflcko
Copy link
Member Author

maflcko commented Jul 21, 2021

Force pushed to add comment

@maflcko maflcko changed the title refactor: Mark CAddrMan::Select const refactor: Mark CAddrMan::Select and GetAddr const Jul 21, 2021
@maflcko
Copy link
Member Author

maflcko commented Jul 21, 2021

Can GetAddr() also be made const?

It already is. (Adjusted title)

@sipa
Copy link
Member

sipa commented Jul 22, 2021

Concept ACK. Perhaps this deserves a comment in addrman.h though, to state that even const member functions cannot be used without synchronization?

@maflcko maflcko force-pushed the 2105-addrmanConstSelect branch from a04e835 to 5555a1d Compare July 22, 2021 18:39
@maflcko
Copy link
Member Author

maflcko commented Jul 22, 2021

Added a lock annotation to the mutable member, which can be "read" by compilers and developers

MarcoFalke added 2 commits July 23, 2021 11:31
Leaving it as-is would be annoying because some editor fix-up the
spacing when opening a file or editing it.
@maflcko maflcko force-pushed the 2105-addrmanConstSelect branch from 5555a1d to fae108c Compare July 23, 2021 09:31
@jnewbery
Copy link
Contributor

Code review ACK fae108c

@maflcko
Copy link
Member Author

maflcko commented Jul 29, 2021

@promag or @theStack interested in donating a re-ACK?

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.

re-ACK fae108c 🍦

Checked via git range-diff fa47bddd...fae108ce that there were only minor changes (comment on vRandom, as suggested by jnewbery) and rebase on master since my last ACK

@maflcko maflcko merged commit 2f60d9f into bitcoin:master Aug 2, 2021
@maflcko maflcko deleted the 2105-addrmanConstSelect branch August 2, 2021 10:15
@jonatack
Copy link
Member

jonatack commented Aug 2, 2021

Did any of the reviewers test this change with DEBUG_ADDRMAN defined? It blows up for me.

addrman.cpp:467:15: error: out-of-line definition of 'Check_' does not match any declaration in 'CAddrMan'
int CAddrMan::Check_()
              ^~~~~~
./addrman.h:746:9: note: member declaration does not match because it is const qualified
    int Check_() const EXCLUSIVE_LOCKS_REQUIRED(cs);
        ^              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

@maflcko
Copy link
Member Author

maflcko commented Aug 2, 2021

@jonatack Good catch. I didn't test this with the CPP flag set and CI doesn't either.

Luckily the code will be always compiled after #20233, so shouldn't happen again after that pull is merged.

@jnewbery
Copy link
Contributor

jnewbery commented Aug 2, 2021

Thanks @jonatack. I'm currently rebasing #20233 and will include a fix for this issue in that PR.

@jonatack
Copy link
Member

jonatack commented Aug 2, 2021

Thanks @jonatack. I'm currently rebasing #20233 and will include a fix for this issue in that PR.

Thanks!

@maflcko
Copy link
Member Author

maflcko commented Aug 2, 2021

I created a fix in #22601 , because I didn't see the comment here.

@jonatack
Copy link
Member

jonatack commented Aug 2, 2021

Thanks, in the meantime will cherry-pick this commit locally.

@theStack
Copy link
Contributor

theStack commented Aug 2, 2021

Did any of the reviewers test this change with DEBUG_ADDRMAN defined? It blows up for me.

Oops, no, I didn't :( thanks for catching this.

Would it make sense to have a CI instance with DEBUG_ADDRMAN defined or is that overambitious? 🤔

@jnewbery
Copy link
Contributor

jnewbery commented Aug 2, 2021

@theStack please see #20233 which removes the DEBUG_ADDRMAN build option and makes consistency checks a runtime option.

sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Aug 4, 2021
fae108c Fix incorrect whitespace in addrman (MarcoFalke)
fa32024 Add missing GUARDED_BY to CAddrMan::insecure_rand (MarcoFalke)
fab755b fuzz: Actually use const addrman (MarcoFalke)
fae0c79 refactor: Mark CAddrMan::GetAddr const (MarcoFalke)
fa02934 refactor: Mark CAddrMan::Select const (MarcoFalke)

Pull request description:

  To clarify that a call to this only changes the random state and nothing else.

ACKs for top commit:
  jnewbery:
    Code review ACK fae108c
  theStack:
    re-ACK fae108c 🍦

Tree-SHA512: 3ffb211d4715cc3daeb3bfcdb3fcc6b108ca96df5fa565510436fac0e8da86c93b30c9c4aad0563e27d84f615fcd729481072009a4e2360c8b3d40787ab6506a
@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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants