Skip to content

Massive refactoring to use local JSONRPC interface. - #31

Open
ke6jjj wants to merge 4 commits into
tedder:mainfrom
ke6jjj:jsc/no-docker
Open

Massive refactoring to use local JSONRPC interface.#31
ke6jjj wants to merge 4 commits into
tedder:mainfrom
ke6jjj:jsc/no-docker

Conversation

@ke6jjj

@ke6jjj ke6jjj commented Jul 19, 2021

Copy link
Copy Markdown

Use the new JSONRPC interface to the validator/miner when retrieving stats, removing
the need to scrape the CLI output and removing the need to query the Helium blockchain
API.

ke6jjj added 3 commits July 18, 2021 17:10
Remove all CLI-based scraping code and use JSON/RPC to interact
with the validator programmatically, instead. Also remove all
queries to the Helium API; they can be satisfied locally and
likely more accurately.
Clean up the mechanism used for passing parameters to JSONRPC functions.
Do it the Python way, using keyword arguments. Then unpack them into a JSON
dictionary at the appropriate time.

Also, for the time being, don't ask the validator to enumerate all validators
recorded in the ledger. This is an expensive operation and doesn't help
much in the long run. Instead, ask for this validator's stats, only.
Comment thread miner_exporter.py
UPDATE_PERIOD = int(os.environ.get('UPDATE_PERIOD', 30))
VALIDATOR_CONTAINER_NAME = os.environ.get('VALIDATOR_CONTAINER_NAME', 'validator')
# for testnet, https://testnet-api.helium.wtf/v1
API_BASE_URL = os.environ.get('API_BASE_URL', 'https://api.helium.io/v1')

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Should this also be deleted since the public API is no longer used?

Comment thread miner_exporter.py

if __name__ == '__main__':
prometheus_client.start_http_server(9825) # 9-VAL on your phone
miner = MinerJSONRPC('http://localhost:4467/')

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Does localhost work for docker? I thought someone determined when JSONRPC came out that docker won't pick up that endpoint. Or did this PR fix this issues? helium/miner#884

@anthonyra

Copy link
Copy Markdown

I also tried to spin this up on one of validators to test it out. I'm able to get the service running and active while the miner is stopped however once I start the miner the service crashes with the following status.

● validator_exporter.service - Validator statistics for Prometheus
     Loaded: loaded (/etc/systemd/system/validator_exporter.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Sun 2021-07-25 16:28:09 UTC; 6s ago
    Process: 43513 ExecStart=/home/helium/validator_exporter/run (code=exited, status=1/FAILURE)
   Main PID: 43513 (code=exited, status=1/FAILURE)

Jul 25 16:28:09 ip-10-0-1-161 systemd[1]: validator_exporter.service: Scheduled restart job, restart counter is at 5.
Jul 25 16:28:09 ip-10-0-1-161 systemd[1]: Stopped Validator statistics for Prometheus.
Jul 25 16:28:09 ip-10-0-1-161 systemd[1]: validator_exporter.service: Start request repeated too quickly.
Jul 25 16:28:09 ip-10-0-1-161 systemd[1]: validator_exporter.service: Failed with result 'exit-code'.
Jul 25 16:28:09 ip-10-0-1-161 systemd[1]: Failed to start Validator statistics for Prometheus.

I'm building from source but the validator is running in a directory /validator/miner I'm wondering if that would cause issues? I'd love to help and get this rolled out though!

@ke6jjj

ke6jjj commented Jul 25, 2021

Copy link
Copy Markdown
Author

This code depends on a change to the hbbft perf call that still isn't merged. That's likely what is crashing.

@anthonyra

Copy link
Copy Markdown

Ahh well fair enough, I thought maybe I messed up the install... I'm super excited to see this in action though!

@anthonyra

Copy link
Copy Markdown

I thought I heard through the grape vine that hbbft_perf is now supported via JSONRPC.. do you think this will work now?

@ke6jjj

ke6jjj commented Aug 23, 2021

Copy link
Copy Markdown
Author

It could be! Let's see if they actually merged my PR.

@ke6jjj

ke6jjj commented Aug 23, 2021

Copy link
Copy Markdown
Author

Nope. PR is still open =( helium/miner#936

Comment thread miner_exporter.py
log.error("in consensus fetch failure")

this_validator = None
try:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

With release 1.2.2 the PR you were waiting on has been merged! After spinning this up the following error continues to occur "validator fetch failure" so maybe the address filter isn't working on ledger validators?

@anthonyra

Copy link
Copy Markdown

@ke6jjj Hey, sorry to bother again. It appears that there's some missing information from the scrapper it could be related to the error I noted above. But my python is absolutely terrible and my understanding of the JSONRPC is even less... It appears that it's not able to get the ledger details for the validator..

Screen Shot 2021-09-07 at 12 12 18 PM

Let me know if I can help at all besides annoying you with this issues...

@ke6jjj

ke6jjj commented Sep 7, 2021

Copy link
Copy Markdown
Author

No problem! I'll have to take a look and see how things have diverged. I haven't been running this branch recently.

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