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

feat: summary peer availability tracing #127

Merged
merged 8 commits into from Aug 1, 2020

Conversation

m-schmoock
Copy link
Member

@m-schmoock m-schmoock commented Jul 20, 2020

Adds:

  • peer availability tracing, to show the node operator which peers are reliable.
  • 72hr exponential smoothing window

Fixes:

  • fix broken fiat price API by switching to public (and reliable) bitstamp ticker API.
  • fix PriceThread actually perform a loop instead of fetching price only one time

@m-schmoock m-schmoock requested a review from cdecker July 20, 2020 15:00
@codecov
Copy link

codecov bot commented Jul 20, 2020

Codecov Report

Merging #127 into master will increase coverage by 0.54%.
The diff coverage is 96.96%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #127      +/-   ##
==========================================
+ Coverage   57.32%   57.87%   +0.54%     
==========================================
  Files          22       23       +1     
  Lines        2580     2611      +31     
==========================================
+ Hits         1479     1511      +32     
+ Misses       1101     1100       -1     
Impacted Files Coverage Δ
summary/summary.py 87.05% <95.65%> (+1.52%) ⬆️
summary/summary_avail.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ded4f6b...fab43a0. Read the comment docs.

@m-schmoock m-schmoock force-pushed the feat/summary_availability branch 2 times, most recently from 41ebcf7 to fd2fd0e Compare July 20, 2020 17:24
@m-schmoock m-schmoock changed the title feat: summary availability 24hr window feat: summary availability Jul 21, 2020
Copy link
Collaborator

@niftynei niftynei left a comment

Choose a reason for hiding this comment

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

lgtm. codecov is complaining that the total test coverage has gone a bit :)

summary/summary.py Outdated Show resolved Hide resolved
summary/summary.py Outdated Show resolved Hide resolved
summary/summary.py Outdated Show resolved Hide resolved
summary/summary.py Outdated Show resolved Hide resolved
summary/summary.py Outdated Show resolved Hide resolved
@m-schmoock
Copy link
Member Author

I think I can also rearrange code to make the calculation tetstable so codecov is more happy with me

@m-schmoock m-schmoock changed the title feat: summary availability feat: summary peer availability tracing Jul 23, 2020
@m-schmoock m-schmoock force-pushed the feat/summary_availability branch 5 times, most recently from 5add9c5 to dae4835 Compare July 24, 2020 23:18
@m-schmoock
Copy link
Member Author

m-schmoock commented Jul 24, 2020

Okay, I fixed the code coverage, even though it was just related to seemingly not profiling unittest thread itself.
By adding a test with a low summary-availability-interval value we get the PeerThread to execute quick enough, and this thread is audited by codecov.

@cdecker : maybe we can reconfigure codecov also tracing the actual unittest threads instead of only the plugin threads within the daemon?

@m-schmoock m-schmoock requested a review from niftynei July 25, 2020 16:35
plugin.add_option(
'summary-availability-interval',
300,
'How often in seconds the availability should be calculated. Causes RPC and CPU.'
Copy link
Collaborator

Choose a reason for hiding this comment

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

The meaning of Causes RPC and CPU isn't totally clear to me. May be clearer as "uses" or "causes usage"?

Copy link
Member Author

Choose a reason for hiding this comment

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

If your okay, I simply removed that silly addition. I thought it would be useful to tell the user that this is just local RPC and doesn't consume much resources or network stuff. But it doesn't add anything particular interesting.

Solved, rebased an force-pushed.

summary/summary.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@niftynei niftynei left a comment

Choose a reason for hiding this comment

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

lgtm!

summary/test_summary.py Outdated Show resolved Hide resolved
summary/summary.py Show resolved Hide resolved
Copy link
Contributor

@cdecker cdecker left a comment

Choose a reason for hiding this comment

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

Excellent addition, I look forward to knowing which peers of mine are lazy and should be disconnected :-)

I went through with a fine-toothed comb, and added a couple of nits, nothing serious, so feel free to ignore them, just thought that since I'm this later to review I should at least put in that much effort.

ACK 2a0d272

summary/summary.py Outdated Show resolved Hide resolved
summary/summary.py Outdated Show resolved Hide resolved
summary/summary.py Outdated Show resolved Hide resolved
summary/summary.py Outdated Show resolved Hide resolved
@@ -2,7 +2,7 @@
from pyln.client import Plugin, Millisatoshi
from packaging import version
from collections import namedtuple
from datetime import datetime
from summary_avail import *
Copy link
Contributor

Choose a reason for hiding this comment

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

If you're concerned that the path might not be unique you can explicitly import a local module by using the following:

from .availability import *

This saves you from having to prefix everything. Alternatively you could also have the executable in the top-level and create a summary package containing all the sub-modules.

Copy link
Member Author

Choose a reason for hiding this comment

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

Wont do, since plugin API or autoreload plugin gets me this:

    from .availability import *
ImportError: attempted relative import with no known parent package

@cdecker
Copy link
Contributor

cdecker commented Aug 1, 2020

Regarding codecov, I'm really tempted to just remove it. It hasn't produced anything actionable, and has been outright misleading in some cases (some plugins flip-flopping despite not being touched...)

It might just be our setup, with tests running as unit-tests and also collecting coverage when run as plugins.

1. bitcoinaverage does not supply public prices since a while now:
>  Unauthenticated requests are not allowed. Take out a new plan or start
>   a free trial at https://pro.bitcoinaverage.com"
This commit fixes this by porting to bitstamp public ticker API.

2. This commit fixes the missing thread loop, so the price is
   actually updated after a while.

3. This commit fixes an unchecked attribute access that crashed during
   my tests.
this applies a 72hr exponential smoothed sliding window to
the online/offline availability state of a peer.
using level error caused the testframework to fail on non-essential
price or availability thread log messages.

likely caused by the test runner not being able to query the bitstamp
API.
extracts the availability calculations to own testable module
@cdecker cdecker merged commit acf670b into lightningd:master Aug 1, 2020
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.

None yet

3 participants