Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Electrum: stop spamming logs #1433

Merged
merged 3 commits into from
May 26, 2020
Merged

Electrum: stop spamming logs #1433

merged 3 commits into from
May 26, 2020

Conversation

sstone
Copy link
Member

@sstone sstone commented May 25, 2020

Connection errors that happen before a proper handshake (i.e exchange of "version" messages) has been completed are now logged as "debug". Errors that are not sent by our master Electrum server are also logged as debug.
This greatly reduces the amount of connection-related logs, especially on testnet, and users will still be able to tell if they have connection issues (tested with eclair-mobile and Phoenix).

The last commit updates our electrum checkpoints.

sstone added 3 commits May 22, 2020 12:24
…a proper handshake

We only care for errors that we received during or after the "handshake" (i.e. the exchange of "version" messages).
Other errors cause by dead/unresponsive servers... which are very common on testnet just add spams to the logs.
…ry servers

We care for errors with our master electrum servers.
@sstone sstone requested a review from dpad85 May 25, 2020 08:01
Copy link
Member

@t-bast t-bast left a comment

Choose a reason for hiding this comment

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

LGTM, how do we review/validate the updated checkpoints?

@sstone
Copy link
Member Author

sstone commented May 25, 2020

The checkpoints are imported from Electrum (we use the exact same format), these come from spesmilo/electrum@fc80f7a

They are block hashes and difficulty targets taken every 2016 blocks (which is the difficulty adjustment period). They can be checked manually:

  • there is one item every 2016 blocks
  • block height should be N*2016 - 1
  • the bits field of the next block should match the checkpoint's nexbits field (on mainnet only, checking this on testnet is a PITA)

For example the last item on our mainnet checkpoint is:

    [
        "00000000000000000006da92c61b6b63ea910be27cab5fd951137105314f2969",
        1740794600224838465872409004248364704712181251938713600
    ]

The corresponding block header is:

{
  "hash": "00000000000000000006da92c61b6b63ea910be27cab5fd951137105314f2969",
  "confirmations": 12754,
  "height": 618911,
  "version": 536870912,
  "versionHex": "20000000",
  "merkleroot": "617f1010c9e0b37173d76e2eb6e57b0e3479b5c192744639260f931c978ae7aa",
  "time": 1582619298,
  "mediantime": 1582615830,
  "nonce": 544318282,
  "bits": "17121ad4",
  "difficulty": 15546745765529.37,
  "chainwork": "00000000000000000000000000000000000000000d037486edebab30d3c6c0e0",
  "nTx": 2605,
  "previousblockhash": "00000000000000000005c645e873072ab04834ba30eedfb192af5347ff2ffd14",
  "nextblockhash": "00000000000000000003fa80fb38019a948f5eec1e6e285a8d1eaec21d197c5f"
}

And the next bits field can be computed as (with the scala console for example):

scala> fr.acinq.bitcoin.encodeCompact(new java.math.BigInteger("1740794600224838465872409004248364704712181251938713600")).toHexString
res0: String = 17122cbc

We can check that it matches the bits field of the block that comes just after our checkoint hash:

bitcoin-cli getblockheader `bitcoin-cli getblockhash 618912`
{
  "hash": "00000000000000000003fa80fb38019a948f5eec1e6e285a8d1eaec21d197c5f",
  "confirmations": 12754,
  "height": 618912,
  "version": 536879104,
  "versionHex": "20002000",
  "merkleroot": "1f320d5b00e7cae0187abafcab2a0babd8490b03b37c3f2f375151f6d6a18f2d",
  "time": 1582619322,
  "mediantime": 1582616324,
  "nonce": 1684026233,
  "bits": "17122cbc",
  "difficulty": 15486913440292.87,
  "chainwork": "00000000000000000000000000000000000000000d03829ccffaf764ff73fbe9",
  "nTx": 2587,
  "previousblockhash": "00000000000000000006da92c61b6b63ea910be27cab5fd951137105314f2969",
  "nextblockhash": "0000000000000000000afbc86127bb1784a799beebe56ecd51361b8c4c519a42"
}

@sstone sstone merged commit e0320da into master May 26, 2020
@sstone sstone deleted the electrum-stop-spamming-logs branch May 26, 2020 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants