Code Monkey home page Code Monkey logo

cardano-leader-logs's Introduction

cardano-leader-logs

In a community effort, led by Andrew Westberg [BCSH], we implemented a way to retrieve stakepool slot leader logs.

This is a nodejs + python implementation which was tested on Ubuntu 20.04.

Note: this method only works for current epoch block assignments. Calculating next epochs assignments based on next epoch's nonce is not supported.

Japanese README: https://github.com/btbf/cardano-leader-logs (outdated)

Installation

Ubuntu 20.04

Node.js

curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt-get update
sudo apt-get install -y nodejs

export NODE_PATH=/usr/lib/node_modules/

Python

sudo apt-get update
sudo apt-get install -y software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get install -y python3.9
sudo apt-get install -y python3-pip

python3 --version
pip3 --version

pip3 install pytz

Libsodium

git clone https://github.com/input-output-hk/libsodium
cd libsodium
git checkout 66f017f1
./autogen.sh
./configure
make
sudo make install

cardano-node

The node does not need to run as a block producer as long as it has access to the correct vrf.skey.

Configuration file - slotLeaderLogsConfig.json

Add your poolId, the path to your pool vrf.skey, and paths for both node genesis files (Shelley and Byron). Make sure to have the node stats available as seen below (or put your own port). The path to the cardano-cli could be a cardano-cli or ./cardano-cli depending on how you installed the CLI previously.

{
  "poolId":           "<YOUR_POOL_ID>",
  "vrfSkey":          "vrf.skey", // path to pool's VRF signing key

  "genesisShelley":   "../files/genesis.json", // path to Shelley genesis file
  "genesisByron":     "../files/byron-genesis.json", // path to Byron genesis file

  "libsodiumBinary":  "/usr/local/lib/libsodium.so", // path to Libsodium executable
  "cardanoCLI":       "cardano-cli", // path to cardano-cli executable
  "nodeStatsURL":     "http://127.0.0.1:12798/metrics", // location for node stats (from the node's `config.json`)

  "timeZone":         "Europe/London" // timezone to be used to display the block schedule in
}

Retrieving the epoch nonce

To manually retrieve the epoch nonce (required for block schedule calculation):

cardano-cli query protocol-state --mainnet | jq -r .csTickn.ticknStateEpochNonce.contents

0022cfa563a5328c4fb5c8017121329e964c26ade5d167b1bd9b2ec967772b60

Running

  1. Through the provided runLeaderLogs.sh: By default, this script will look for the slotLeaderLogsConfig.json in the same directory -> this can be edited inside the script to specify another location for the config file:
SLOTLEADER_CONFIG="slotLeaderLogsConfig.json" # path to configuration file
./runLeaderLogs.sh

...

      Calculating leader slots...

expected blocks with d == 0.00: xy
assigned blocks with d == 0.00: xyz

[
  { index: 1, slot: 6354, date: '2021-06-25 00:30:45' }
  ...
]
  1. Manually, by running:
node cardanoLeaderLogs.js path/to/slotLeaderLogsConfig.json epochNonceHash

Thanks

Thanks to Andrew Westberg [BCSH], Papacarp [LOVE] and others who contributed.

This repository was created by Marcel Baumberg [TITAN] and is now maintained by Damjan Ostrelic [EDEN].

cardano-leader-logs's People

Contributors

dostrelith678 avatar marcelklammer avatar mokhfn avatar adade-pool avatar lunarpool avatar

Watchers

James Cloos avatar

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.