Skip to content

Simplified version of Block Clock - #212

Closed
shaavan wants to merge 7 commits into
bitcoin-core:mainfrom
shaavan:221216-the_block_clock_simplified
Closed

shaavan wants to merge 7 commits into
bitcoin-core:mainfrom
shaavan:221216-the_block_clock_simplified

Conversation

@shaavan

@shaavan shaavan commented Dec 16, 2022

Copy link
Copy Markdown
Contributor

This PR is the simplified version of #148. And removes commits in #127 to allow easier upstream commit merges.

Functional changes from the original version:

  1. The PeersIndicator has been replaced with plain rectangles to keep the UI intact.
  2. The conns property representing if the number of connections is greater than 0, has been set to always positive. With this change, the "connecting" page, though implemented, becomes inaccessible through the UI.

- This method would allow to get the blocktime value of the block at
  the given height.
- This file allowing using of Chain interfaces to get information about
  the blockchain.
- This class declares and defines the function that will be used in
  for the Block Clock.
1. Added a new Q_PROPERTY to track the remaining time till the IBD
   completioni.
2. Added two signals to later connect to the chainmodel class function.
3. Added new member variable, m_pause, which will keep track of if the
   block clock is in paused state or not, and will accordingly
disconnect or reconnect the user to network.
- Also made appropriate connections with the nodemodel signals
- This property will later be used for the BlockClock.qml file
- The BlockClock.qml files provides the control for BlockClock and
  determines how the elements would be displayed.
- The BlockClockComponent.qml file uses the aforementioned control to
  display the value, and determines what will be displayed.
@johnny9

johnny9 commented Dec 17, 2022 •

Copy link
Copy Markdown
Collaborator

On Ubuntu 22.04.1 LTS, I had to install apt install qml-module-qtgraphicaleffects for the application to load otherwise I receive the error

QQmlApplicationEngine failed to load component
qrc:/qml/pages/main.qml:53:13: Type NodeRunner unavailable
qrc:/qml/pages/node/NodeRunner.qml:24:9: Type BlockClockComponent unavailable
qrc:/qml/components/BlockClockComponent.qml:6:1: Type BlockClock unavailable
qrc:/qml/controls/BlockClock.qml:4:1: module "QtGraphicalEffects" is not installed

Might want to extend the README for the qml directory to include that module.

@johnny9

johnny9 commented Dec 17, 2022 •

Copy link
Copy Markdown
Collaborator

It looks great. Tested pause/resume as well as a sync on signet and here's what I got.

Screenshot_2022-12-16_22-18-31 Screenshot_2022-12-16_22-19-02 Screenshot_2022-12-16_22-25-01 Screenshot_2022-12-16_22-26-42 Screenshot_2022-12-16_22-28-51

@johnny9 johnny9 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Some QML errors appear during runtime. tail -f debug.log | grep GUI to watch for issues when running bitcoin-qt.

Comment thread src/qml/chainmodel.h
interfaces::Chain& m_chain;
};

#endif // BITCOIN_QML_CHAINMODEL_H No newline at end of file

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

"No newline at end of file"


Component.onCompleted: nodeModel.startNodeInitializionThread();

BlockClockComponent{}

@johnny9 johnny9 Dec 17, 2022 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

GUI: qrc:/qml/pages/node/NodeRunner.qml:24:9: QML BlockClockComponent: Detected anchors on an item that is managed by a layout. This is undefined behavior; use Layout.alignment instead.

Should be able to remove the ColumnLayout containing the BlockClockComponent and just define the BlockClockComponent as the content to this Page. When you do this, also remove the anchors.fill: parent and spacing: 0 in this file.

else {
var del = 0.0025
// Paint Block time points
for (var i=1; i<parent.blockList.length - 1; i++) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The following error appears when going into the paused state.

2022-12-17T03:50:17Z GUI: qrc:/qml/controls/BlockClock.qml:96: TypeError: Value is undefined and could not be converted to an object

@johnny9 johnny9 Dec 17, 2022 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Also a small style thing, put spaces before and after operators so its easier to read.

ringProgress: blockList[0]
header: Math.floor(nodeModel.blockTipHeight / 1000) + "," + nodeModel.blockTipHeight % 1000
subText: "Blocktime"
blockList: chainModel.timeRatioList

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

QML error appears when shutting down.

2022-12-17T03:52:37Z Shutdown: In progress...
2022-12-17T03:52:37Z torcontrol thread exit
2022-12-17T03:52:37Z addcon thread exit
2022-12-17T03:52:37Z msghand thread exit
2022-12-17T03:52:37Z net thread exit
2022-12-17T03:52:39Z opencon thread exit
2022-12-17T03:52:39Z DumpAnchors: Flush 0 outbound block-relay-only peer addresses to anchors.dat started
2022-12-17T03:52:39Z DumpAnchors: Flush 0 outbound block-relay-only peer addresses to anchors.dat completed (0.01s)
2022-12-17T03:52:39Z scheduler thread exit
2022-12-17T03:52:39Z Writing 0 unbroadcast transactions to disk.
2022-12-17T03:52:39Z Dumped mempool: 3.7e-06s to copy, 0.00448635s to dump
2022-12-17T03:52:39Z Shutdown: done
2022-12-17T03:52:39Z GUI: qrc:/qml/components/BlockClockComponent.qml:34: TypeError: Cannot read property 'timeRatioList' of null

Comment thread src/qml/chainmodel.cpp
m_time_ratio_list.erase(m_time_ratio_list.begin() + 1, m_time_ratio_list.end());
}
m_time_ratio_list[0] = currentTimeRatio;
} No newline at end of file

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

"No new line at end of file"

@shaavan

shaavan commented Dec 18, 2022

Copy link
Copy Markdown
Contributor Author

Moved the changes of this PR to #148 to preserve comment history for the block_clock and prevent the splitting of discussion between two PRs.

@johnny9, I shall be addressing your comments here and in #148. Thanks for your cooperation.

@shaavan shaavan closed this Dec 18, 2022
hebasto pushed a commit to hebasto/gui-qml that referenced this pull request Nov 22, 2026
…nunix platform support and fix race conditions

d5f7524 doc: Bump minimum required Cap'n Proto version to 0.9.2 (Ryan Ofsky)
4898199 build: suppress -Wc++23-lambda-attributes in warn_interface (Ryan Ofsky)
270f5db Squashed 'src/ipc/libmultiprocess/' changes from e8de5c7b68e..acded1aafae (Ryan Ofsky)

Pull request description:

  The changes can be verified by running `test/lint/git-subtree-check.sh src/ipc/libmultiprocess` as described in [developer notes](https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md#subtrees) and [lint instructions](https://github.com/bitcoin/bitcoin/tree/master/test/lint#git-subtree-checksh).

  Changes since last subtree update (#35720):

  - Adds support for nonunix platforms, making API changes that are not backwards compatible ([bitcoin-core#274](bitcoin-core/libmultiprocess#274)). Follow-ups add a `CurrentThread()` accessor matching compatibility code in [bitcoin/bitcoin#35084](bitcoin/bitcoin#35084) ([bitcoin-core#323](bitcoin-core/libmultiprocess#323)) and remove code for Cap'n Proto versions before 0.9 ([bitcoin-core#331](bitcoin-core/libmultiprocess#331)).
  - Fixes a data race between IPC calls running on worker threads and disconnects, found by Antithesis ([bitcoin-core#349](bitcoin-core/libmultiprocess#349)).
  - Fixes a use-after-free when a socket disconnects before `ConnectStream` connects, and leaks and hangs when a client `construct()` call throws ([bitcoin-core#298](bitcoin-core/libmultiprocess#298)).
  - Fixes a race where file descriptors from `SpawnProcess` could leak into processes forked at the same time by other threads, by clearing `FD_CLOEXEC` in the child after forking ([bitcoin-core#311](bitcoin-core/libmultiprocess#311)).
  - Makes `SpawnProcess` report `exec` failures back to the parent and throw, reaping the child ([bitcoin-core#312](bitcoin-core/libmultiprocess#312)).
  - Adds support for `std::chrono::time_point` fields ([bitcoin-core#303](bitcoin-core/libmultiprocess#303)) and for serializing lists of interface objects that need to be moved from ([bitcoin-core#304](bitcoin-core/libmultiprocess#304)), both needed by [bitcoin/bitcoin#10102](bitcoin/bitcoin#10102).
  - Accepts container fields and parameters with any comparator, hash, and allocator types, like Bitcoin Core's `GCSFilter::ElementSet`, needed by [bitcoin/bitcoin#29409](bitcoin/bitcoin#29409) ([bitcoin-core#379](bitcoin-core/libmultiprocess#379)).
  - Finds the `capnp` tool in vcpkg and Windows builds, needed by [bitcoin/bitcoin#32387](bitcoin/bitcoin#32387) ([bitcoin-core#317](bitcoin-core/libmultiprocess#317)).
  - Adds a `destroy_connection` option to `ServeStream` and `ConnectStream`, lets `ServeStream` take ownership of the init object and return the new server and its connection, and adds an `EventLoop::incomingConnections()` accessor, simplifying test setup in both repositories and needed by [bitcoin/bitcoin#35932](bitcoin/bitcoin#35932) ([bitcoin-core#365](bitcoin-core/libmultiprocess#365)).
  - Replaces `EventLoop::post()` with `sync()` taking a `kj::FunctionParam`, avoiding a heap allocation per call ([bitcoin-core#347](bitcoin-core/libmultiprocess#347)).
  - Names threads spawned by the event loop so they can be told apart in tools and logs ([bitcoin-core#324](bitcoin-core/libmultiprocess#324)).
  - Fixes warnings that Bitcoin Core enables or plans to enable: adds `[[noreturn]]` attributes for `-Wmissing-noreturn` ([bitcoin-core#339](bitcoin-core/libmultiprocess#339), for [bitcoin/bitcoin#35911](bitcoin/bitcoin#35911)), and fixes `-Wunused` ([bitcoin-core#362](bitcoin-core/libmultiprocess#362), for [bitcoin/bitcoin#36167](bitcoin/bitcoin#36167)), `-Wunused-const-variable` and `-Wundef` ([bitcoin-core#370](bitcoin-core/libmultiprocess#370)), and `-Wmissing-prototypes` ([bitcoin-core#386](bitcoin-core/libmultiprocess#386), for [bitcoin/bitcoin#36743](bitcoin/bitcoin#36743)) warnings.
  - Fails at compile time with a suggested workaround when Cap'n Proto misdetects exception support (`KJ_NO_EXCEPTIONS`), as happens on NetBSD ([bitcoin-core#364](bitcoin-core/libmultiprocess#364)).
  - Build improvements: fixes stale generated code when the `mpgen` binary changes ([bitcoin-core#316](bitcoin-core/libmultiprocess#316)), fixes `mpgen` link order for static Cap'n Proto builds ([bitcoin-core#367](bitcoin-core/libmultiprocess#367)), links `mpgen` against `kj-async` instead of `capnp-rpc` ([bitcoin-core#327](bitcoin-core/libmultiprocess#327)), shows Cap'n Proto `find_package` diagnostics ([bitcoin-core#325](bitcoin-core/libmultiprocess#325)), installs `type-unordered-set.h` and `version.h` ([bitcoin-core#350](bitcoin-core/libmultiprocess#350)), and shows include-what-you-use errors instead of failing silently ([bitcoin-core#371](bitcoin-core/libmultiprocess#371)).
  - Test, CI, documentation, and minor code improvements: fix for a startup race in the example program ([bitcoin-core#315](bitcoin-core/libmultiprocess#315)), new test for immediate client disconnects in `ListenConnections` ([bitcoin-core#310](bitcoin-core/libmultiprocess#310)), `ReadList` return value check ([bitcoin-core#338](bitcoin-core/libmultiprocess#338)), connect test race fix ([bitcoin-core#343](bitcoin-core/libmultiprocess#343)) and cleanups ([bitcoin-core#344](bitcoin-core/libmultiprocess#344)), `std::ranges::copy` follow-ups ([bitcoin-core#307](bitcoin-core/libmultiprocess#307)), trailing whitespace removal ([bitcoin-core#345](bitcoin-core/libmultiprocess#345)), Cap'n Proto version documentation fix ([bitcoin-core#357](bitcoin-core/libmultiprocess#357)), clang-tidy updates ([bitcoin-core#358](bitcoin-core/libmultiprocess#358), [bitcoin-core#360](bitcoin-core/libmultiprocess#360), [bitcoin-core#380](bitcoin-core/libmultiprocess#380), [bitcoin-core#389](bitcoin-core/libmultiprocess#389)), new CI job testing newer cmake and Cap'n Proto versions ([bitcoin-core#212](bitcoin-core/libmultiprocess#212), [bitcoin-core#359](bitcoin-core/libmultiprocess#359)), CI coverage for the minimum supported g++ ([bitcoin-core#330](bitcoin-core/libmultiprocess#330), [bitcoin-core#366](bitcoin-core/libmultiprocess#366)), new CI warnings ([bitcoin-core#332](bitcoin-core/libmultiprocess#332), [bitcoin-core#341](bitcoin-core/libmultiprocess#341)), CI parallelism ([bitcoin-core#334](bitcoin-core/libmultiprocess#334), [bitcoin-core#356](bitcoin-core/libmultiprocess#356)), CI diagnostics ([bitcoin-core#351](bitcoin-core/libmultiprocess#351), [bitcoin-core#352](bitcoin-core/libmultiprocess#352)), Nix and LLVM updates ([bitcoin-core#296](bitcoin-core/libmultiprocess#296), [bitcoin-core#363](bitcoin-core/libmultiprocess#363)), NetBSD and OpenBSD CI fixes ([bitcoin-core#321](bitcoin-core/libmultiprocess#321), [bitcoin-core#340](bitcoin-core/libmultiprocess#340), [bitcoin-core#381](bitcoin-core/libmultiprocess#381)), building Cap'n Proto with GCC in the 32-bit CI job to avoid an ABI mismatch ([bitcoin-core#383](bitcoin-core/libmultiprocess#383)), and GitHub Actions updates ([bitcoin-core#387](bitcoin-core/libmultiprocess#387)).

  The second commit suppresses the clang `-Wc++23-lambda-attributes` warning, which the new `[[noreturn]]` lambda attribute in `mp/proxy-types.h` triggers in C++20 builds. Since #31507 the Windows build uses clang-cl, so the same flag covers it.

  The third commit updates the minimum Cap'n Proto version in `doc/dependencies.md` to 0.9.2 (1.0 with Clang). This update raises libmultiprocess's own minimum from 0.7 to 0.9 (bitcoin-core/libmultiprocess#331), and libmultiprocess rejects 0.9.0 and 0.9.1 for CVE-2022-46149 and, with Clang 16 or newer, every version before 1.0.

ACKs for top commit:
  fanquake:
    ACK d5f7524
  willcl-ark:
    ACK d5f7524

Tree-SHA512: 4064944f4d8bb6c1665ddc7d5fae838492235d7dfdafab88b19b687ff6892460a3f450b90a145b287866330c569b862d748c941a70c65abc7f273ef13e490fd7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants