Git Product home page Git Product logo

relay_counter's Introduction

relay_counter

A simple tool that counts relays during a time period

Prerequisite

Requires a full node of Pocket Core RC-0.6.2 or higher

How To Use

  1. Ensure golang 1.13+ environment is properly installed
  2. Sync (RC-0.6.2) Pocket Core Instance (ensure completely synced)
  3. go get github.com/pokt-network/relay_counter
  4. cd /src/github.com/pokt-network/relay_counter
  5. Edit configuration file (See details below)
  6. go run ./...
  7. check /src/github.com/pokt-network/relay_counter/result for the result file

Config File

Found in /config/config.json

{
  "timeline": {
    "start": -4,
    "end": -1, // can be 0 for latest
    "unit": "days" // blocks, sessions, min, weeks, hours
  },
  "endpoint": "http://localhost:8081/v1",
  "http_retry": 3, // if rpc not responsive
  "params": {
    "blocks_per_session": 4, // needed for sessions
    "approx_block_time_in_min": 15
  }
}

TL;DR how it works

With a simple config file, relay_counter uses binary search to find the nearest blocks to the start/end, then tallies up the relays using valid claims and proofs transactions.

You can pass arguments like a different config file path or a results file path. Also you can override on the fly with arguments any of the parameters that exists into the config.json.

go run ./... -config=test/config.json -results test/result.json -endpoint=https://some.node.com/v1

In any case you can use -h to see all the available options.

Config.json | CLI args

Config File Option CLI Arg Description Options/Default
- -config config file path config/config.json
- -results results file path result/.json
selector -selector Use this to point which method will you use to select block timeline, byBlock
timeline.start -timelineStart used only when selector=timeline
timeline.end -timelineEnd used only when selector=timeline
timeline.unit -timelineUnit used only when selector=timeline block[s],session[s],minute[s],hour[s],day[s],week[s]
byBlock.start -startBlock used only when selector=byBlock
byBlock.end -endBlock used only when selector=byBlock
endpoint -endpoint endpoint must be pocket-core version endpoint
http_retry -httpRetry how much retries will be done in case some endpoint fail
params.block_per_session -blocksPerSession
parms.approx_block_time_in_min -blockTimeInMin approximate time before next block height been generated

relay_counter's People

Contributors

andrewnguyen22 avatar benvangithub avatar jorgecuesta avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

relay_counter's Issues

Command line arguments

  • Can you please provide command line args to override config params for the timeline? I will invoke this tool periodically, and changing config file programmatically each time is less than ideal. Doable, of course. But ugly.
  • Can you please make the output name configurable via command line? Current way of auto-creating filenames is not very programmer friendly.

Add support byBlock with start and end been equals

I want to be able to know the relays for an specific block height, so now because it is reusing the timeline idea, start is X and end should be X+1, but when X is the latest block height this throw errors so is not usuable.

JSON Result Names Are Error Prone Because So Similar

type NodeReport struct {
	Service              []ServiceReport  `json:"serviced"`
	TotalRelays          int64            `json:"total_relays"`
	ServiceReportByChain map[string]int64 `json:"service_by_chain"`
}

type AppReport struct {
	ServicedBy            []ServiceReport  `json:"serviced_by"`
	TotalRelays           int64            `json:"total_relays"`
	ServicedReportByChain map[string]int64 `json:"serviced_by_chain"`
}

Make them the same to allow for easy parsing

please include minHeight and maxHeight values in report header

After playing with it a bit.. I kinda think that it really needs to accept absolute block numbers in addition to relative to current block time periods. as well as printing same in the report file.

I would find it much easier to run batches and keep them organized by month or week or whatever if the header info contained min and max height.
Thank you.

Failing at step 3 - go 1.16 Pocket 6.3.6

Do I need to run a downgraded version? or Am I doing something else wrong?

$ go get github.com/pokt-network/relay_counter

github.com/pokt-network/pocket-core/types

go/pkg/mod/github.com/pokt-network/[email protected]/types/config.go:130:20: c.TendermintConfig.LevelDBOptions undefined (type config.Config has no field or method LevelDBOptions)
go/pkg/mod/github.com/pokt-network/[email protected]/types/config.go:130:38: undefined: config.DefaultLevelDBOpts
go/pkg/mod/github.com/pokt-network/[email protected]/types/config.go:173:3: t.LevelDBOptions undefined (type *config.Config has no field or method LevelDBOptions)
go/pkg/mod/github.com/pokt-network/[email protected]/types/config.go:173:21: undefined: config.DefaultLevelDBOpts
go/pkg/mod/github.com/pokt-network/[email protected]/types/context.go:271:3: unknown field 'NumTxs' in struct literal of type "github.com/tendermint/tendermint/abci/types".Header
go/pkg/mod/github.com/pokt-network/[email protected]/types/context.go:272:3: unknown field 'TotalTxs' in struct literal of type "github.com/tendermint/tendermint/abci/types".Header
go/pkg/mod/github.com/pokt-network/[email protected]/types/indexer.go:192:81: undefined: query.Page
go/pkg/mod/github.com/pokt-network/[email protected]/types/indexer.go:200:81: undefined: query.Page
go/pkg/mod/github.com/pokt-network/[email protected]/types/indexer.go:208:84: undefined: query.Page
go/pkg/mod/github.com/pokt-network/[email protected]/types/indexer.go:216:69: undefined: query.Page
go/pkg/mod/github.com/pokt-network/[email protected]/types/context.go:272:3: too many errors

Error when using the default config file

I am receiving this error on healthy nodes, completely up to speed with current block height and with bunch of relays and rewards.

This error doesn't happen if I use blocks as timeline unit vs. days. Perhaps a bug in binary search logic?

go run ./ ...
2021/02/23 04:03:48 Attempting to read Config file:
2021/02/23 04:03:48 Config File Processed:
2021/02/23 04:03:48 {{-4 -1 days} http://localhost:8082/v1 3 {15 4}}
2021/02/23 04:03:48 Testing Pocket Endpoint
2021/02/23 04:03:48 Converting Timeline To Block Heights
2021/02/23 04:03:48 Getting the latest height
2021/02/23 04:03:48 Getting the latest block
2021/02/23 04:03:48 Latest height is 19243 and latest time is: 2021-02-23 03:41:33.185792419 +0000 UTC
2021/02/23 04:03:48 Timeline unit is days
2021/02/23 04:03:48 Calclating the approximate start and end times
2021/02/23 04:03:48 Target start: 2021-02-19 03:41:33.185792419 +0000 UTC
Target End: 2021-02-22 03:41:33.185792419 +0000 UTC
2021/02/23 04:03:48 Begin Closest Height Operations
2021/02/23 04:03:48 Performing a binary search for the closest height to the target time: 2021-02-19 03:41:33.185792419 +0000 UTC
2021/02/23 04:03:48 min:  0 max 19243 try height 18859 closest height 18859
2021/02/23 04:03:48 min:  18859 max 19243 try height 19051 closest height 18859
2021/02/23 04:03:48 RPC failure for block by height: Unregistered interface types.Evidence
Trying to retry. Retry count is: 0/3
2021/02/23 04:03:53 min:  18859 max 19243 try height 19051 closest height 18859
2021/02/23 04:03:54 RPC failure for block by height: Unregistered interface types.Evidence
Trying to retry. Retry count is: 1/3
2021/02/23 04:03:59 min:  18859 max 19243 try height 19051 closest height 18859
2021/02/23 04:03:59 RPC failure for block by height: Unregistered interface types.Evidence
Trying to retry. Retry count is: 2/3
2021/02/23 04:04:04 min:  18859 max 19243 try height 19051 closest height 18859
2021/02/23 04:04:04 After 3 retries, unable to get block for height: 19051, with error: Unregistered interface types.Evidence
exit status 1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.