Giter Club home page Giter Club logo

lisk-pool3's Introduction

Lisk pool distribution software (v3)

Test

Redistribution software for Lisk delegate on mainnet (and testnet) after the migration to Lisk3.

Use at your own risk, software provided as-is

Configuration

Fork this repo; edit config.json and modify the first lines with your settings:

{
	"apiEndpoint": "https://mainnet-service.lisktools.eu/api/v2/",   		// Node uri
	"network": "mainnet",									    // Or testnet
	"interactive": true,                                        // Ask for confirmation
	"delegateName": "dakk",                                     // Delegate name      
	"sharingPercentage": 15,                                    // % of sharing
	"minPayout": 0.1,                                           // Minimum payout
	"blackList": [],                                            // Addresses to skip
	"poolState": "poollogs.json",                               // Where to save pool state
	"paymentsFile": "payments.sh",                              // Where to save payments commands
	"includeSelfStake": false,                                  // True if we want to include selfstake in distribution calculations
	"multiSignature": false,				    // True if you're using a multisig account
	"fromAddress": ""					    // Address from where to make the payments. Remove if the payments will be made from the delegate's address
}

Dependencies

  • python3
  • requests python module (pip3 install requests)
  • a synced lisk node

Run

python liskpool3.py

If you want to update pending balances without paying, use --only-update option

Troubleshooting

Missing genesis_block.json error

If you get this message when you run the payments.sh file:

Error: ENOENT: no such file or directory, open 
'/home/lisk/lisk-core/config/mainnet/genesis_block.json'
Error: Missing 1 required arg:
transaction  The transaction to be signed encoded as hex string

You can fix it by copying the file /home/lisk/.lisk/lisk-core/config/mainnet/genesis_block.json to /home/lisk/lisk-core/config/mainnet/ directory

Frontend

The software has a tiny frontend written in angular. In order to create and update it:

npm install -g @angular/cli
cd pool-frontend
npm install

And update with:

bash update_frontend.sh [base_directory]

Where base directory is the base directory of the frontend (leave blank if it stays in the toplevel).

License

MIT License

Copyright (c) 2021 Davide Gessa

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

lisk-pool3's People

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

lisk-pool3's Issues

error when executing payments.sh

I'm getting the following:

parse error: Invalid numeric literal at line 2, column 0
› Error: Missing 1 required arg:
› transaction A transaction to be sent to the node encoded as hex string
› See more help with --help

root cause:

the problem is with the portion "| jq .transaction -r" at code lines similar to this one ( non-multisig and multisig ):

cmds.append('TXC=lisk-core transaction:create 2 0 %s --offline --network %s --network-identifier %s --nonce=\echo $NONCE --passphrase="echo $PASSPHRASE" --asset='{"data": "%s payouts", "amount":%s,"recipientAddress":"%s"}' | jq .transaction -r'

I remove that portion of code everything works ok

the --only-update option is not taking effect

after executing "python3 liskpool3.py --only-update" the following happens:

  • poollogs.json does not reflect pending payments, they are all 0, although the accumulated reward for voters is added to the history as rewards paid.
  • payments.sh file is created, why is created if the execution was only for updating pendings ?

Rewards paid history is not being updated with proper amount

steps to reproduce:

  1. execute python3 liskpool3.py --only-update
  2. execute update_frontend.sh and browse to stats page
  3. execute python3 liskpool3.py
  4. execute bash payments.sh
  5. execute update_frontend.sh and browse to stats page

The latest paid amount result to be the same as previous in history

Unit tests with mock data

  • getVotesPercentages
  • addressToBinary
  • getForgedSinceLastPayout
  • calculateRewards
  • payPendings
  • paymentCommandForLiskCore

Use forger plugin as a source of rewards/voters data

Not sure if this something you want to implement, but since the official lisk-service has issues you could use the forger plugin built in to lisk-core. It provides always accurate data since it collects the data from local lisk-core node. You can read about it here: https://lisk.com/documentation/lisk-sdk/references/lisk-framework/forger-plugin.html#actions

The communication with the plugin is through WS. It has two actions that returns everything you want. The aggregated votes and rewards.

forger:getVoters
forger:getForgingInfo

The user would have to run his lisk-core with --enable-forger-plugin parameter.
It's not a feature request :) Just something for you to consider.

Iterate over votes_received endpoint

Currently the script only fetches a single page for the retrieving the votes for a delegate. This is problematic when there are more than 100 voters for an account.

The tool should iterate over all necessary pages to correctly fetch all votes received.

Script doesn't calculate rewards properly after executing it multiple times

lisk@ubuntu:~/lisk-pool3$ python3 liskpool3.py --min-payout 10000000000
8 produced blocks since last payout, 7.00000000 lsk to pay
Delegate przemer got 6.93137254 lsk of reward
Saved to poollogs.json
Nothing to pay. Exiting...

lisk@ubuntu:~/lisk-pool3$ python3 liskpool3.py --min-payout 10000000000
-7 produced blocks since last payout, -6.00000000 lsk to pay
Delegate przemer got -5.94117647 lsk of reward
Saved to poollogs.json
Nothing to pay. Exiting...

lisk@ubuntu:~/lisk-pool3$ python3 liskpool3.py --min-payout 10000000000
7 produced blocks since last payout, 6.00000000 lsk to pay
Delegate przemer got 5.94117647 lsk of reward
Saved to poollogs.json
Nothing to pay. Exiting...

lisk@ubuntu:~/lisk-pool3$ python3 liskpool3.py --min-payout 10000000000
0 produced blocks since last payout, 0.00000000 lsk to pay
Delegate przemer got 0.00000000 lsk of reward
Saved to poollogs.json
Nothing to pay. Exiting...

Add a parameter to establish a vote cap within distribution

some pool owners would be interested in offering a vote cap to benefit to attract vote from smaller accounts.

e.g.: vote cap is set to 200k, then if somebody votes with 300k it only counts 200k weight for the distribution calculation.

note: I'm not clear how but we also need factor the delegate vote capacity, what is fair distribution when vote from community exceeded the vote capacity ?

Error while trying to send payments

I'm getting multiple errors when trying to send payments. I can fix some, but not all. However, I feel something else must be wrong if no one else is having these issues, so I feel I'm looking in the wrong spot for the issue. These are the errors I get:

~/lisk-pool3-main$ bash payments.sh

Write passphrase:
*******
Write second passphrase:
*******
payments.sh: line 9: Sending: command not found
payments.sh: line 11: --mandatory-keys="14d554573013e49a6bf8b6041677426067b84633de624ed1db9d9ee5214a5379": command not found
 ›   Error: Missing 1 required arg:
 ›   transaction  The transaction to be signed encoded as hex string
 ›   See more help with --help
payments.sh: line 11: {"transaction":"08021000180520c09a0c2a2090ad9bfed339af2d6b4b3b7f7cdf25d927b255f9f25dbbc892ee9ca57ef67807322908ebae95a40b12142f02c7e2f406e95269bf538285fc66e0ed08494f1a0b6d7276207061796f7574733a403a72fae81a82bca699fe4a220cf47bb6f5b896d2e417c84ca3bd94b72f86c7b441ec4535dc6dee55492e62f538acdf0702403386a936db2a6c53091365d8490b"}: command not found
payments.sh: line 12: --mandatory-keys="14d554573013e49a6bf8b6041677426067b84633de624ed1db9d9ee5214a5379": command not found
 ›   Error: Missing 1 required arg:
 ›   transaction  The transaction to be signed encoded as hex string
 ›   See more help with --help
payments.sh: line 12: {"transaction":"08021000180520c09a0c2a2090ad9bfed339af2d6b4b3b7f7cdf25d927b255f9f25dbbc892ee9ca57ef67807322908ebae95a40b12142f02c7e2f406e95269bf538285fc66e0ed08494f1a0b6d7276207061796f7574733a403a72fae81a82bca699fe4a220cf47bb6f5b896d2e417c84ca3bd94b72f86c7b441ec4535dc6dee55492e62f538acdf0702403386a936db2a6c53091365d8490b"}: command not found
{"transaction":"08021000180520c09a0c2a2090ad9bfed339af2d6b4b3b7f7cdf25d927b255f9f25dbbc892ee9ca57ef67807322908ebae95a40b12142f02c7e2f406e95269bf538285fc66e0ed08494f1a0b6d7276207061796f7574733a403a72fae81a82bca699fe4a220cf47bb6f5b896d2e417c84ca3bd94b72f86c7b441ec4535dc6dee55492e62f538acdf0702403386a936db2a6c53091365d8490b"}
 ›   Error: Transaction signatures does not match required number of signatures: '2' for transaction with id 'd415befaea2dd48f732182313f0ed2644cfd7d665e9e5f0404df10b61d958fee'
payments.sh: line 17: Sending: command not found
...

Attached is the payments.sh file:
payments.txt

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.