Skip to content

Conversation

@laanwj
Copy link
Member

@laanwj laanwj commented Jun 5, 2020

A straightforward and hopefully uncontroversial refactor to improve consistency.

  • Move the decision whether to translate an individual error message to where it is defined. This simplifies call sites: no more InitError(Untranslated(SomeFunction(...))).

  • Make all functions in util/error.h consistently return a bilingual_str. We've decided to use this as error message type so let's roll with it.

This has no functional changes: no messages are changed, no new translation messages are defined.

Also make a function static that can be static.

@practicalswift
Copy link
Contributor

Concept ACK

@DrahtBot
Copy link
Contributor

DrahtBot commented Jun 5, 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.

@hebasto
Copy link
Member

hebasto commented Jun 5, 2020

Concept ACK.

Copy link
Member

@jonatack jonatack left a comment

Choose a reason for hiding this comment

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

ACK f40dddfde231550e76043011d4211ca2fb17143d

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 f40dddfde231550e76043011d4211ca2fb17143d, tested on Linux Mint 19.3 (x86_64).

Copy link
Member

Choose a reason for hiding this comment

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

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.

ACK. This should also fix the failing tests when running the net permission tests in the gui

@jonatack
Copy link
Member

jonatack commented Jun 5, 2020

Probably unrelated or a bad build, but with two different debug builds on this branch and not on master, I'm seeing seeing this shortly after launching the GUI. Testing further with rebase on master.

Assertion failed: detected inconsistent lock order at sync.cpp:128, details in debug log.
Aborted
debug log

2020-06-05T14:38:04Z Bitcoin Core version v0.20.99.0-f40dddfde2-dirty (debug build)
2020-06-05T14:38:04Z Qt 5.11.3 (dynamic), plugin=xcb (dynamic)
2020-06-05T14:38:04Z System: PureOS, x86_64-little_endian-lp64
2020-06-05T14:38:04Z Screen: HDMI-1 3840x1600, pixel ratio=1.0
2020-06-05T14:38:04Z Screen: eDP-1 1920x1080, pixel ratio=1.0
2020-06-05T14:38:04Z Assuming ancestors of block 0000000000000000000f2adce67e49b0b6bdeb9de8b7c3d7e93b21e7fc1e819d have valid signatures.
2020-06-05T14:38:04Z Setting nMinimumChainWork=00000000000000000000000000000000000000000e1ab5ec9348e9f4b8eb8154
2020-06-05T14:38:04Z Using the 'sse4(1way),sse41(4way),avx2(8way)' SHA256 implementation
2020-06-05T14:38:04Z Using RdSeed as additional entropy source
2020-06-05T14:38:04Z Using RdRand as an additional entropy source
2020-06-05T14:38:04Z Default data directory /home/jon/.bitcoin
2020-06-05T14:38:04Z Using data directory /home/jon/.bitcoin
2020-06-05T14:38:04Z Config file: /home/jon/.bitcoin/bitcoin.conf
2020-06-05T14:38:04Z Config file arg: addresstype="bech32"
2020-06-05T14:38:04Z Config file arg: avoidpartialspends="1"
2020-06-05T14:38:04Z Config file arg: blocksonly="0"
2020-06-05T14:38:04Z Config file arg: dbcache="10240"
2020-06-05T14:38:04Z Config file arg: logips="1"
2020-06-05T14:38:04Z Config file arg: maxconnections="512"
2020-06-05T14:38:04Z Config file arg: maxmempool="1000"
2020-06-05T14:38:04Z Config file arg: maxuploadtarget="0"
2020-06-05T14:38:04Z Config file arg: par="0"
2020-06-05T14:38:04Z Config file arg: persistmempool="1"
2020-06-05T14:38:04Z Config file arg: rpcpassword=****
2020-06-05T14:38:04Z Config file arg: rpcuser=****
2020-06-05T14:38:04Z Config file arg: server="1"
2020-06-05T14:38:04Z Config file arg: txconfirmtarget="10"
2020-06-05T14:38:04Z Config file arg: txindex="1"
2020-06-05T14:38:04Z Config file arg: walletbroadcast="1"

...

2020-06-05T14:38:30Z opencon thread start
2020-06-05T14:38:30Z msghand thread start
2020-06-05T14:38:31Z GUI: Platform customization: "other"
2020-06-05T14:38:31Z New outbound peer connected: version: 70015, blocks=633204, peer=0, peeraddr=[2a01:4f8:1c17:7ac6::1]:8333 (full-relay)
2020-06-05T14:38:32Z New outbound peer connected: version: 70015, blocks=633204, peer=1, peeraddr=136.32.20.188:8333 (full-relay)
2020-06-05T14:38:32Z Imported mempool transactions from disk: 1447 succeeded, 0 failed, 0 expired, 0 already there, 0 waiting for initial broadcast
2020-06-05T14:38:36Z UpdateTip: new best=0000000000000000000280a397cbe44cbfb9469f098922dbec3ebb7b01546968 height=633198 version=0x20000000 log2_work=92.005832 tx=536190097 date='2020-06-05T13:50:17Z' progress=0.999982 cache=2.0MiB(15058txo) warning='64 des 100 derniers blocs ont une version inattendue'
2020-06-05T14:38:36Z POTENTIAL DEADLOCK DETECTED
2020-06-05T14:38:36Z Previous lock order was:
2020-06-05T14:38:36Z  m_cs_chainstate validation.cpp:2868 (in thread msghand)
2020-06-05T14:38:36Z  (1) cs_main validation.cpp:2883 (in thread msghand)
2020-06-05T14:38:36Z  ::mempool.cs validation.cpp:2883 (in thread msghand)
2020-06-05T14:38:36Z  (2) clientmodel->m_cached_tip_mutex qt/clientmodel.cpp:255 (in thread msghand)
2020-06-05T14:38:36Z Current lock order is:
2020-06-05T14:38:36Z  (2) m_cached_tip_mutex qt/clientmodel.cpp:119 (in thread main)
2020-06-05T14:38:36Z  (1) ::cs_main interfaces/node.cpp:200 (in thread main)
2020-06-05T14:39:32Z P2P peers available. Skipped DNS seeding.
2020-06-05T14:39:32Z dnsseed thread exit
2020-06-05T14:39:38Z New outbound peer connected: version: 70015, blocks=633204, peer=10, peeraddr=138.229.205.237:8333 (full-relay)
2020-06-05T14:39:56Z UpdateTip: new best=0000000000000000000280a397cbe44cbfb9469f098922dbec3ebb7b01546968 height=633198 version=0x20000000 log2_work=92.005832 tx=536190097 date='2020-06-05T13:50:17Z' progress=0.999982 cache=2.1MiB(15165txo) warning='64 des 100 derniers blocs ont une version inattendue'
2020-06-05T14:39:56Z POTENTIAL DEADLOCK DETECTED
2020-06-05T14:39:56Z Previous lock order was:
2020-06-05T14:39:56Z  m_cs_chainstate validation.cpp:2868 (in thread msghand)
2020-06-05T14:39:56Z  (1) cs_main validation.cpp:2883 (in thread msghand)
2020-06-05T14:39:56Z  ::mempool.cs validation.cpp:2883 (in thread msghand)
2020-06-05T14:39:56Z  (2) clientmodel->m_cached_tip_mutex qt/clientmodel.cpp:255 (in thread msghand)
2020-06-05T14:39:56Z Current lock order is:
2020-06-05T14:39:56Z  (2) m_cached_tip_mutex qt/clientmodel.cpp:119 (in thread main)
2020-06-05T14:39:56Z  (1) ::cs_main interfaces/node.cpp:200 (in thread main)
2020-06-05T14:41:51Z net thread start
2020-06-05T14:41:51Z opencon thread start
2020-06-05T14:41:51Z msghand thread start
2020-06-05T14:41:51Z GUI: Platform customization: "other"
2020-06-05T14:41:52Z New outbound peer connected: version: 70015, blocks=633204, peer=0, peeraddr=173.249.2.209:8333 (full-relay)
2020-06-05T14:41:52Z Imported mempool transactions from disk: 1447 succeeded, 0 failed, 0 expired, 0 already there, 0 waiting for initial broadcast
2020-06-05T14:41:58Z UpdateTip: new best=0000000000000000000280a397cbe44cbfb9469f098922dbec3ebb7b01546968 height=633198 version=0x20000000 log2_work=92.005832 tx=536190097 date='2020-06-05T13:50:17Z' progress=0.999981 cache=2.0MiB(15058txo) warning='64 des 100 derniers blocs ont une version inattendue'
2020-06-05T14:41:58Z POTENTIAL DEADLOCK DETECTED
2020-06-05T14:41:58Z Previous lock order was:
2020-06-05T14:41:58Z  m_cs_chainstate validation.cpp:2868 (in thread msghand)
2020-06-05T14:41:58Z  (1) cs_main validation.cpp:2883 (in thread msghand)
2020-06-05T14:41:58Z  ::mempool.cs validation.cpp:2883 (in thread msghand)
2020-06-05T14:41:58Z  (2) clientmodel->m_cached_tip_mutex qt/clientmodel.cpp:255 (in thread msghand)
2020-06-05T14:41:58Z Current lock order is:
2020-06-05T14:41:58Z  (2) m_cached_tip_mutex qt/clientmodel.cpp:119 (in thread main)
2020-06-05T14:41:58Z  (1) ::cs_main interfaces/node.cpp:200 (in thread main)

@maflcko
Copy link
Member

maflcko commented Jun 5, 2020

@jonatack This issue has been fixed on master

@jonatack
Copy link
Member

jonatack commented Jun 5, 2020

Thanks, suspected as much. I just verified with a build of this branch rebased on master that the issue is gone.

laanwj added 3 commits June 9, 2020 15:39
- Move the decision whether to translate an error message to where it is
  defined. This simplifies call sites: no more `InitError(Untranslated(...))`.

- Make all functions in `util/error.h` consistently return a
  `bilingual_str`. We've decided to use this as error message type so
  let's roll with it.

This has no functional changes: no messages are changed, no new
translation messages are defined.
It's only used inside `net_permissions.cpp`.
Make it consistent with `Chain::initError`.
@laanwj laanwj force-pushed the 2020_06_bilingual_str branch from f40dddf to 6fe9890 Compare June 9, 2020 13:40
@laanwj
Copy link
Member Author

laanwj commented Jun 9, 2020

  • Rebased
  • Use anonymous namespace instead of static
  • Fuzzing tests should compile again

@maflcko
Copy link
Member

maflcko commented Jun 9, 2020

Tested before:

LC_ALL=de_DE.UTF-8 QT_QPA_PLATFORM=xcb BITCOIND=bitcoin-qt ./test/functional/p2p_permissions.py --tracerpc
...
AssertionError: [node 1] Expected message "Invalid P2P permission" does not partially match stderr:
"Error: Ungültige P2P Genehmigung: 'oopsie'"

Tested after:

# same test
...
2020-06-09T14:57:47.148000Z TestFramework (INFO): Tests successful

ACK 6fe9890 🔣

Show signature and timestamp

Signature:

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

ACK 6fe989054f0ad9308e8a25f7123d9e5dd67f1164 🔣
-----BEGIN PGP SIGNATURE-----

iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
pUigZgv/aQzZaHqcIzdNovyxkfR+qQOTJCXkEDUY+kITIOyKIwc970A+qvldJRhW
7fUT7TUM4zl8GglIT9QVUPLTtLSWl75iNFphGkqBEQcXFcUApqrSP5iWITDzEqAr
WqdUkTxtCdyxdw8GpBW8cFrRPdvIE2HmLfHDMtdvjRa3pkajy6u15l9xOm6jvMeT
4icO1axpuwnCPfLMOckzTQVhxUtJ1QR4gsl49PjidRqK7BGx1iiEHSgSkfUIBTma
hQrVrzPtEkHQhkNUADSzRLofKjkRH83QBEezulKOyaZUnNWQa7UFjxSTWo6dUmG1
cdKFUJ9nFTcGi2K5PuBYx/El05MkNlJ5XsJ5yB1irukHjdZ/d8AkVoC5mB0i1bhn
UGtM0KWvAIOZOiOmmBewgUlR6kbVIjwFhDOmUiJX/w9GIkheM1c8A90APOZVK0d5
mOfCJwlQ5q8Q5JcRyibcqgpCfAkpdJmJJhB+xHET+w0SkzkoQ7r7bsXUVjj29GaF
MhL92C/x
=2qDJ
-----END PGP SIGNATURE-----

Timestamp of file with hash 71e8aa88cba09cc7b0e920f846122ece50689e066e9939b354e8102915106d61 -

@hebasto
Copy link
Member

hebasto commented Jun 9, 2020

@MarcoFalke

Tested before:

LC_ALL=de_DE.UTF-8 QT_QPA_PLATFORM=xcb BITCOIND=bitcoin-qt ./test/functional/p2p_permissions.py --tracerpc
...
AssertionError: [node 1] Expected message "Invalid P2P permission" does not partially match stderr:
"Error: Ungültige P2P Genehmigung: 'oopsie'"

Tested after:

# same test
...
2020-06-09T14:57:47.148000Z TestFramework (INFO): Tests successful

Trying to reproduce your tests, and got:

AssertionError: [node 1] Unable to connect to bitcoind after 60s

What am I doing wrong?

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 6fe9890, tested on Linux Mint 19.3 (x86_64).
Also verified that it compiles successfully with the --enable-fuzz option.

@maflcko
Copy link
Member

maflcko commented Jun 9, 2020

What am I doing wrong?

You'll need to manually close the GUI dialogs. The python test framework can't do that for you (yet).

@maflcko maflcko merged commit f8364df into bitcoin:master Jun 9, 2020
fanquake added a commit to fanquake/bitcoin that referenced this pull request Jun 10, 2020
After bitcoin#19176, building the gui on Bionic is failing with:

```bash
  CXX      qt/qt_libbitcoinqt_a-guiutil.o
qt/bitcoin.cpp: In function 'int GuiMain(int, char**)':
qt/bitcoin.cpp:460:35: error: 'Untranslated' was not declared in this scope
node->initError(strprintf(Untranslated("Error parsing command line arguments: %s\n"), error));
```

The merge commit also failed to compile with the same error:
https://travis-ci.org/github/bitcoin/bitcoin/jobs/696627543
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Jun 10, 2020
6fe9890 refactor: Change Node::initError to take bilingual_str (Wladimir J. van der Laan)
425e7cb refactor: Put`TryParsePermissionFlags` in anonymous namespace (Wladimir J. van der Laan)
77b79fa refactor: Error message bilingual_str consistency (Wladimir J. van der Laan)

Pull request description:

  A straightforward and hopefully uncontroversial refactor to improve consistency.

  - Move the decision whether to translate an individual error message to where it is defined. This simplifies call sites: no more `InitError(Untranslated(SomeFunction(...)))`.

  - Make all functions in `util/error.h` consistently return a   `bilingual_str`. We've decided to use this as error message type so let's roll with it.

  This has no functional changes: no messages are changed, no new translation messages are defined.

  Also make a function static that can be static.

ACKs for top commit:
  MarcoFalke:
    ACK 6fe9890 🔣
  hebasto:
    ACK 6fe9890, tested on Linux Mint 19.3 (x86_64).

Tree-SHA512: 1dd123ef285c4b50bbc429b2f11c9a63aaa669a84955a0a9b8134e9dc141bc38f863f798e8982ac68bbe83170e1067a87d1a87fe7f791928b7914e10bbc2ef8d
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Jun 10, 2020
fanquake added a commit that referenced this pull request Jun 10, 2020
948f113 gui: add missing translation.h include to fix build (fanquake)

Pull request description:

  After #19176, building the gui on Bionic is failing with:

  ```bash
    CXX      qt/qt_libbitcoinqt_a-guiutil.o
  qt/bitcoin.cpp: In function 'int GuiMain(int, char**)':
  qt/bitcoin.cpp:460:35: error: 'Untranslated' was not declared in this scope
             node->initError(strprintf(Untranslated("Error parsing command line arguments: %s\n"), error));
  ```

  The merge commit also failed to compile with the same error:
  https://travis-ci.org/github/bitcoin/bitcoin/jobs/696627543

ACKs for top commit:
  hebasto:
    ACK 948f113, tested on Linux Mint 19.3 (x86_64): it fixes compiling error with the `--disable-wallet` configure option.

Tree-SHA512: db0197b110b3a7d05af2ceb29fbe9eeb6521d28f53b6267aa6d07a975886adb5c6485af79506ab6c66ed101e32292feeaff3707cdbc11432e5b97400953d5631
@Sjors Sjors mentioned this pull request Jun 10, 2020
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Jun 10, 2020
After bitcoin#19176, building the gui on Bionic is failing with:

```bash
  CXX      qt/qt_libbitcoinqt_a-guiutil.o
qt/bitcoin.cpp: In function 'int GuiMain(int, char**)':
qt/bitcoin.cpp:460:35: error: 'Untranslated' was not declared in this scope
node->initError(strprintf(Untranslated("Error parsing command line arguments: %s\n"), error));
```

The merge commit also failed to compile with the same error:
https://travis-ci.org/github/bitcoin/bitcoin/jobs/696627543
stackman27 pushed a commit to stackman27/bitcoin that referenced this pull request Jul 4, 2020
After bitcoin#19176, building the gui on Bionic is failing with:

```bash
  CXX      qt/qt_libbitcoinqt_a-guiutil.o
qt/bitcoin.cpp: In function 'int GuiMain(int, char**)':
qt/bitcoin.cpp:460:35: error: 'Untranslated' was not declared in this scope
node->initError(strprintf(Untranslated("Error parsing command line arguments: %s\n"), error));
```

The merge commit also failed to compile with the same error:
https://travis-ci.org/github/bitcoin/bitcoin/jobs/696627543
Fabcien pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Dec 14, 2020
Summary:
```
A straightforward and hopefully uncontroversial refactor to improve
consistency.

    Move the decision whether to translate an individual error message
to where it is defined. This simplifies call sites: no more
InitError(Untranslated(SomeFunction(...))).

    Make all functions in util/error.h consistently return a
bilingual_str. We've decided to use this as error message type so let's
roll with it.

This has no functional changes: no messages are changed, no new
translation messages are defined.

Also make a function static that can be static.
```

Backport of core [[bitcoin/bitcoin#19176 | PR19176]].
The change to `kitchen_sink.cpp` is not ported since this file hasn't
been ported yet, but the compiler will make the change obvious when
needed.

Depends on D8650.

Test Plan:
  ninja all check-all
  ninja bitcoin-fuzzers

Reviewers: #bitcoin_abc, PiRK

Reviewed By: #bitcoin_abc, PiRK

Differential Revision: https://reviews.bitcoinabc.org/D8651
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Feb 15, 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.

6 participants