Skip to content

Conversation

luke-jr
Copy link
Member

@luke-jr luke-jr commented Feb 17, 2020

Side effect: this results in the RPC showing unknown service bits as "UNKNOWN[n]" like the GUI.

Note that there is no common mask-to-vector<string> function because both GUI and RPC would need to iterate through it to convert to their desired target formats.

@hebasto
Copy link
Member

hebasto commented Feb 17, 2020

Concept ACK

1 similar comment
@Sjors
Copy link
Member

Sjors commented Feb 19, 2020

Concept ACK

…agToStr function

Side effect: this results in the RPC showing unknown service bits as "UNKNOWN[n]" like the GUI.

Note that there is no common mask-to-vector<string> function because both GUI and RPC would need to iterate through it to convert to their desired target formats.
@@ -199,3 +199,27 @@ const std::vector<std::string> &getAllNetMessageTypes()
{
return allNetMessageTypesVec;
}

std::string serviceFlagToStr(const uint64_t mask, const int bit)
Copy link
Member

Choose a reason for hiding this comment

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

Seems it would be enough to only pass in bit, or what am I missing?

Copy link
Member Author

Choose a reason for hiding this comment

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

This avoid recalculating mask

Copy link
Member

Choose a reason for hiding this comment

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

That's one bit shift 1ull << bit;. Given how rarely this function is called that seems like an over-optimization.

@jonasschnelli
Copy link
Contributor

jonasschnelli commented Feb 27, 2020

utACK cea91a1 c31bc5b

@DrahtBot
Copy link
Contributor

DrahtBot commented Mar 1, 2020

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

@vasild vasild left a comment

Choose a reason for hiding this comment

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

Approach ACK

Comment on lines -763 to +748
uint64_t check = 1LL << i;
uint64_t check = 1ull << i;
if (mask & check)
{
strList.append(serviceFlagToStr(check, i));
strList.append(QString::fromStdString(serviceFlagToStr(mask, i)));
Copy link
Contributor

Choose a reason for hiding this comment

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

Here we should pass check instead of mask? I did not test it but I think with the current patch formatServicesStr(NODE_NETWORK | NODE_WITNESS) will return a string like UNKNOWN[9] & UNKNOWN[9].

The arguments to serviceFlagToStr() are redundant (one can be derived from the other easily) which I think is confusing and could lead to slippages. I agree with @laanwj that just one of them should be passed.

@vasild
Copy link
Contributor

vasild commented May 29, 2020

#18165 (comment)

Now that this PR got merged I tested whether my concern above was legit. It was:

instead of

NETWORK & WITNESS

now I see

UNKNOWN[1033] & UNKNOWN[1033] & UNKNOWN[2^10]

@fanquake
Copy link
Member

@vasild Thanks for following up and testing, did you want to open a PR to fix this?

@jonasschnelli
Copy link
Contributor

@vasild. Oh. I missed that. Would be great if you can fix it via a new PR.

@vasild
Copy link
Contributor

vasild commented May 29, 2020

I am on it, hold on!

vasild added a commit to vasild/bitcoin that referenced this pull request May 29, 2020
Don't take two redundant arguments in `serviceFlagToStr()`.

Introduce `serviceFlagsToStr()` which takes a mask (with more than one
bit set) and returns a vector of strings.

As a side effect this fixes an issue introduced in
bitcoin#18165 due to which the GUI could
print something like `UNKNOWN[1033] & UNKNOWN[1033] & UNKNOWN[2^10]`
instead of `NETWORK & WITNESS`.
@vasild
Copy link
Contributor

vasild commented May 29, 2020

Here is a fix: #19106

Cheerz!

vasild added a commit to vasild/bitcoin that referenced this pull request May 29, 2020
Don't take two redundant arguments in `serviceFlagToStr()`.

As a side effect this fixes an issue introduced in
bitcoin#18165 due to which the GUI could
print something like `UNKNOWN[1033] & UNKNOWN[1033] & UNKNOWN[2^10]`
instead of `NETWORK & WITNESS`.
jonasschnelli added a commit that referenced this pull request May 29, 2020
189ae0c util: dedup code in callers of serviceFlagToStr() (Vasil Dimov)
fbacad1 util: simplify the interface of serviceFlagToStr() (Vasil Dimov)

Pull request description:

  Don't take two redundant arguments in `serviceFlagToStr()`.

  Introduce `serviceFlagsToStr()` which takes a mask (with more than one
  bit set) and returns a vector of strings.

  As a side effect this fixes an issue introduced in
  #18165 due to which the GUI could
  print something like `UNKNOWN[1033] & UNKNOWN[1033] & UNKNOWN[2^10]`
  instead of `NETWORK & WITNESS`.

ACKs for top commit:
  MarcoFalke:
    ACK 189ae0c
  jonasschnelli:
    Tested ACK 189ae0c

Tree-SHA512: 000c490f16ebbba04458c62ca4ce743abffd344d375d95f5bbd5008742012032787655db2874b168df0270743266261dccf1693761906567502dcbac902bda50
Stackout pushed a commit to Stackout/pexa-backport that referenced this pull request May 30, 2020
Don't take two redundant arguments in `serviceFlagToStr()`.

As a side effect this fixes an issue introduced in
bitcoin/bitcoin#18165 due to which the GUI could
print something like `UNKNOWN[1033] & UNKNOWN[1033] & UNKNOWN[2^10]`
instead of `NETWORK & WITNESS`.
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request May 31, 2020
…to a shared serviceFlagToStr function

c31bc5b Consolidate service flag bit-to-name conversion to a shared serviceFlagToStr function (Luke Dashjr)
cea91a1 Bugfix: GUI: Use unsigned long long type to avoid implicit conversion of MSB check (Luke Dashjr)

Pull request description:

  Side effect: this results in the RPC showing unknown service bits as "UNKNOWN[n]" like the GUI.

  Note that there is no common mask-to-`vector<string>` function because both GUI and RPC would need to iterate through it to convert to their desired target formats.

ACKs for top commit:
  jonasschnelli:
    utACK ~~cea91a1e40e12029140ebfba969ce3ef2965029c~~ c31bc5b

Tree-SHA512: 32c7ba8ac7ef2d4087f4f317447ae93a328ec9fb9ad81301df2fbaeeb21a3db7a503187a369552b05a9414251b7cf8e15bcde74c1ea2ef36591ea7ffb6721f60
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request May 31, 2020
Don't take two redundant arguments in `serviceFlagToStr()`.

As a side effect this fixes an issue introduced in
bitcoin#18165 due to which the GUI could
print something like `UNKNOWN[1033] & UNKNOWN[1033] & UNKNOWN[2^10]`
instead of `NETWORK & WITNESS`.
janus pushed a commit to janus/bitgesell that referenced this pull request Nov 15, 2020
Don't take two redundant arguments in `serviceFlagToStr()`.

As a side effect this fixes an issue introduced in
bitcoin/bitcoin#18165 due to which the GUI could
print something like `UNKNOWN[1033] & UNKNOWN[1033] & UNKNOWN[2^10]`
instead of `NETWORK & WITNESS`.
jasonbcox pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Nov 25, 2020
…agToStr function

Summary:
```
Side effect: this results in the RPC showing unknown service bits as
"UNKNOWN[n]" like the GUI.

Note that there is no common mask-to-vector<string> function because
both GUI and RPC would need to iterate through it to convert to their
desired target formats.
```

Backport of core [[bitcoin/bitcoin#18165 | PR18165]].

Depends on D8516.

Test Plan:
  ninja all check-all

  ./src/qt/bitcoin-qt -server
Check the service bits are displayed correctly in the peers window
  ./src/bitcoin-cli getnetworkinfo
Check the service bits are displayed correctly

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Subscribers: deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D8518
jasonbcox pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Nov 25, 2020
Summary:
```
Don't take two redundant arguments in `serviceFlagToStr()`.

As a side effect this fixes an issue introduced in
bitcoin/bitcoin#18165 due to which the GUI could
print something like `UNKNOWN[1033] & UNKNOWN[1033] & UNKNOWN[2^10]`
instead of `NETWORK & WITNESS`.

util: dedup code in callers of serviceFlagToStr()
```

Backport of core [[bitcoin/bitcoin#19106 | PR19106]].

Depends on D8518.

Test Plan:
  ninja all check-all

  ./src/qt/bitcoin-qt -server
Check the service bits display correctly

  ./src/bitcoin-cli getnetworkinfo
Check the service bits display correctly

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D8519
kwvg added a commit to kwvg/dash that referenced this pull request Aug 22, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Aug 22, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Sep 16, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Sep 18, 2021
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Sep 21, 2021
189ae0c util: dedup code in callers of serviceFlagToStr() (Vasil Dimov)
fbacad1 util: simplify the interface of serviceFlagToStr() (Vasil Dimov)

Pull request description:

  Don't take two redundant arguments in `serviceFlagToStr()`.

  Introduce `serviceFlagsToStr()` which takes a mask (with more than one
  bit set) and returns a vector of strings.

  As a side effect this fixes an issue introduced in
  bitcoin#18165 due to which the GUI could
  print something like `UNKNOWN[1033] & UNKNOWN[1033] & UNKNOWN[2^10]`
  instead of `NETWORK & WITNESS`.

ACKs for top commit:
  MarcoFalke:
    ACK 189ae0c
  jonasschnelli:
    Tested ACK 189ae0c

Tree-SHA512: 000c490f16ebbba04458c62ca4ce743abffd344d375d95f5bbd5008742012032787655db2874b168df0270743266261dccf1693761906567502dcbac902bda50
thelazier pushed a commit to thelazier/dash that referenced this pull request Sep 25, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Oct 12, 2021
kwvg pushed a commit to kwvg/dash that referenced this pull request Oct 12, 2021
189ae0c util: dedup code in callers of serviceFlagToStr() (Vasil Dimov)
fbacad1 util: simplify the interface of serviceFlagToStr() (Vasil Dimov)

Pull request description:

  Don't take two redundant arguments in `serviceFlagToStr()`.

  Introduce `serviceFlagsToStr()` which takes a mask (with more than one
  bit set) and returns a vector of strings.

  As a side effect this fixes an issue introduced in
  bitcoin#18165 due to which the GUI could
  print something like `UNKNOWN[1033] & UNKNOWN[1033] & UNKNOWN[2^10]`
  instead of `NETWORK & WITNESS`.

ACKs for top commit:
  MarcoFalke:
    ACK 189ae0c
  jonasschnelli:
    Tested ACK 189ae0c

Tree-SHA512: 000c490f16ebbba04458c62ca4ce743abffd344d375d95f5bbd5008742012032787655db2874b168df0270743266261dccf1693761906567502dcbac902bda50
gades pushed a commit to cosanta/cosanta-core that referenced this pull request May 30, 2022
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Aug 16, 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