Skip to content

node uptime wrong #34326

Closed
Closed

Description

@embetrix

Is there an existing issue for this?

  • I have searched the existing issues

Current behaviour

System is freshly booted but bitcoind show wrong uptime:

root@raspberrypi5-c8-bf-64:~# bitcoin-cli -conf=/etc/bitcoin/bitcoin.conf uptime
20120688

My real uptime:

root@raspberrypi5-c8-bf-64:~# uptime 
 15:53:22 up 10 min,  0 user,  load average: 0.61, 0.56, 0.31

version:

root@raspberrypi5-c8-bf-64:~# bitcoind --version
Bitcoin Core daemon version v30.2.0 bitcoind
Copyright (C) 2009-2026 The Bitcoin Core developers

Please contribute if you find Bitcoin Core useful. Visit
<https://bitcoincore.org/> for further information about the software.
The source code is available from <https://github.com/bitcoin/bitcoin>.

This is experimental software.
Distributed under the MIT software license, see the accompanying file COPYING
or <https://opensource.org/license/MIT>

bitcoin conf file:

root@raspberrypi5-c8-bf-64:~# cat /etc/bitcoin/bitcoin.conf 
#############################################################
# Bitcoin configuration file
#############################################################
pid=/run/bitcoin/bitcoind.pid
nodebuglogfile=1
datadir=/var/bitcoin
loglevel=info
proxy=127.0.0.1:9050
signer=/usr/bin/hwi

# Settings for signet Network
signet=1

[signet]
walletdir=/var/wallets
listen=1
bind=127.0.0.1
port=38333

# RPC Settings
rpcuser=satobox
rpcport=38332
rpcbind=127.0.0.1
rpcallowip=127.0.0.1
rpcauth=satobox:3381456077fa06cabce053c62a368693$263f4f1cbdc1b4b25233385b931807508f5d8bd59d2c46dc418e4ea2b23dfd09
rpccookiefile=/run/bitcoin/cookie
rpccookieperms=group
server=1
deprecatedrpc=warnings

Expected behaviour

should show correct uptime

Steps to reproduce

just build new bitcoin core and test with commands above

Relevant log output

No response

How did you obtain Bitcoin Core

Compiled from source

What version of Bitcoin Core are you using?

v30.2

Operating system and version

linux

Machine specifications

raspberrypi5

Activity

  1. pinheadmz commented on Jan 17, 2026

    @pinheadmz
    Member

    Just to be sure... is the clock on your system correct?

  2. embetrix commented on Jan 17, 2026

    @embetrix
    Author

    @pinheadmz correct the rpi5 does not have an RTC backed up with a battery so if bitcoind start before the NTP is synchronized the bitcoin-cli uptime shows incorrect uptime

  3. pinheadmz commented on Jan 17, 2026

    @pinheadmz
    Member

    What happens if the clock is correct when you start Bitcoin and still correct when you make the RPC?

  4. l0rinc commented on Jan 17, 2026

    @l0rinc
    Contributor

    I was able to reproduce the reported behavior on an RPi5 by simulating a large clock correction using regtest setmocktime (and also via explicit timedatectl set-ntp false)

    $ cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release && ninja -C build bitcoind bitcoin-cli -j$(nproc)
    # ...
    $ DATA_DIR=$(mktemp -d)
    $ ./build/bin/bitcoind -regtest -datadir="$DATA_DIR" -connect=0 -daemon
    Bitcoin Core starting
    $ ./build/bin/bitcoin-cli -regtest -datadir="$DATA_DIR" -rpcwait uptime
    1
    $ ./build/bin/bitcoin-cli -regtest -datadir="$DATA_DIR" setmocktime $(( $(date +%s) + 20000000 ))
    $ ./build/bin/bitcoin-cli -regtest -datadir="$DATA_DIR" uptime
    20000001
    $ ./build/bin/bitcoin-cli -regtest -datadir="$DATA_DIR" stop
    Bitcoin Core stopping

    I will push a fix for this to use a std::chrono::steady_clock instead.

  5. l0rinc commented on Jan 17, 2026

    @l0rinc
    Contributor

    Thanks for the report, fixed it in #34328 - if you can, please try it out locally to confirm

  6. added a commit that references this issue on Jan 27, 2026
  7. pinheadmz commented on Jan 27, 2026

    @pinheadmz
    Member

    Was this closed by #34328 ?

  8. l0rinc commented on Jan 27, 2026

    @l0rinc
    Contributor

    yes, please close the issue.

  9. dergoegge commented on Jan 29, 2026

    @dergoegge
    Member

    @embetrix out of curiosity what is your usecase for the uptime RPC? Any reason you prefer it over querying your OS for the uptime of the bitcoind process?

  10. embetrix commented on Jan 29, 2026

    @embetrix
    Author

    @dergoegge : I started a project recently : https://github.com/embetrix/satobox it implement a full node built completely from sources (including OS and all packages).
    It runs actually on RPI5 but not exclusivly.
    I have hw wallet management system using Specter-Desktop and it showed previously wrong uptime when bitcoin was started before NTP sync.
    I mitigated that by adding systemd requirement on NTP : https://github.com/embetrix/satobox/blob/scarthgap/meta-satobox/recipes-bitcoin/bitcoin/bitcoin/bitcoind.service.in#L3
    but the fix proposed by @l0rinc is cleaner and I can remove this dependency with future bitcoin core releases to have a quicker start of the node.

  11. added a commit that references this issue on Jun 28, 2026
  12. added a commit that references this issue on Jun 30, 2026
  13. added a commit that references this issue on Aug 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions