> For the complete documentation index, see [llms.txt](https://doc.love2stake.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.love2stake.com/stake-pool-operator-tools/leader-log-scripts.md).

# Leader Log Scripts

{% hint style="info" %}
Leader Log scripts were developed by [papacarp ](https://t.me/pooltool)from [pooltool.io](https://pooltool.io/).  For full details of the scripts see [pooltool.io public](https://github.com/papacarp/pooltool.io) github
{% endhint %}

The scripts allow stake pool owners to check when their pool is scheduled for the slot leadership.  The steps below cover the following.

* [ ] **Installation** - *Updating and Installing required packages*
* [ ] **Download Scripts** *- Download of the scripts*
* [ ] **Executing scripts** *-* *Create Cardano ledger and run scripts* &#x20;

{% hint style="info" %}
All steps are required to be run on your Block Producer node
{% endhint %}

## Installation

Below guide is for **Ubuntu 20.04**.

Update and add ppa package:

```
sudo apt-get update
sudo apt-get install -y software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
```

Update, install python and pip:

```
sudo apt-get update
sudo apt-get install -y python3.9
sudo apt-get install -y python3-pip
```

Check version of the scripts:

```
python3 --version
pip3 --version
```

{% hint style="info" %}
Python output `Python 3.8.5`

PIP output `pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8)`
{% endhint %}

Install python package pytz:

```
pip3 install pytz
```

## Download scripts

Download `getSigma.py` and `leaderLogs.py`scripts from github:

{% hint style="info" %}
Example uses $NODE\_HOME as the location of the Cardano node folder
{% endhint %}

```
cd $NODE_HOME
wget https://raw.githubusercontent.com/papacarp/pooltool.io/master/leaderLogs/getSigma.py
wget https://raw.githubusercontent.com/papacarp/pooltool.io/master/leaderLogs/leaderLogs.py
```

## Executing scripts

Create Cardano ledger state:

```
cardano-cli query ledger-state --mainnet --allegra-era --out-file ledger-state.json
```

{% hint style="info" %}
This may take a minute and create `ledger-state.json inside your $NODE_HOME`
{% endhint %}

Using your Pool ID and `ledger-state.json` execute getSigma script:

{% hint style="info" %}
If you do not know your pool id you can find this in any of the staking pool sites (adapools.org, pooltool.io or cardanoscan.io).  Example below from pooltool.io&#x20;
{% endhint %}

![](/files/-MJrizD6EF6LCwsdJdim)

```
python3 getSigma.py \
--pool-id a930baffeb4ab6d3e93b39a70f1d6b5f5f922baad9e4f618da285b05 \
--ledger ledger-state.json
```

{% hint style="info" %}
This will output your Sigma value for the next steps

`building active stake`&#x20;

`Sigma: 6.970276119270975e-05`
{% endhint %}

Run `leaderLogs.py` with following parameters.&#x20;

{% hint style="info" %}
Below summary of arguments for full details see the [pooltool.io github](https://github.com/papacarp/pooltool.io/tree/master/leaderLogs).  Some of these are optional arguments but included in the example as these are what I use.

* **--vrf-skey** path to the pool vrf.skey file.
* **--sigma** value from the previous command
* **--pool-id** stake pool id
* **--epoch** the epoch your running this for.  In this case 223
* **--epoch-nonce** epoch 223 nonce (different value of each epoch).  This can be found [here](/stake-pool-operator-tools/leader-log-scripts/epoch-nonce.md).&#x20;
* **-bft** show potential blocks you would have had if Cardano was full decentralised.
* **--tz** set the timezone of your location.  Run command below to see list of timezones&#x20;

  ```
  timedatectl list-timezones 
  ```

{% endhint %}

Execute leaderLogs.py:&#x20;

```
python3 leaderLogs.py \
--vrf-skey vrf.skey \
--sigma 6.970276119270975e-05 \
--pool-id a930baffeb4ab6d3e93b39a70f1d6b5f5f922baad9e4f618da285b05 \
--epoch 223 \
--epoch-nonce fa2cd68857d74b32d704c86ac94ad40c2d7b5d7143ace3ea4e1fa798794059c0 \
-bft \
--tz Europe/London
```

If are scheduled for slot leadership then you should see output similar to this:&#x20;

```
Checking leadership log for Epoch 223 [ d Param: 0.58 ]
2020-10-14 20:19:53 ==> Leader for 164102, Cumulative epoch blocks: 1
2020-10-14 20:19:53 ==> Leader for slot 164102, Cumulative epoch blocks: 1
2020-10-15 08:39:00 ==> Leader for 208449, Cumulative epoch blocks: 2
2020-10-15 08:39:00 ==> Leader for slot 208449, Cumulative epoch blocks: 2
2020-10-17 10:46:55 ==> Stolen by BFT for 388924, Cumulative stolen blocks due to d param: 1
2020-10-17 10:46:55 ==> Leader for slot 388924, Cumulative epoch blocks: 2
2020-10-17 21:01:49 ==> Stolen by BFT for 425818, Cumulative stolen blocks due to d param: 2
2020-10-17 21:01:49 ==> Leader for slot 425818, Cumulative epoch blocks: 2
```

{% hint style="danger" %}
**Security:** It is responsibility of the operator to protect and secure the stake pool.  Consider  what you share with others.  [The Basics](https://forum.cardano.org/t/back-to-basics-security-measures-every-cardano-stake-pool-operators-should-know-and-implement/38166)  &#x20;
{% endhint %}

{% hint style="info" %}
**Support:** If you find the contents useful, then please consider supporting by either delegating your ADA to ticker **Love2** or sending ADA to the following address - `addr1qy2jswg2xfca87h79050dzgj0yup69u9gpclwn9jl2g5tlfvaj6kvenchu5gwxlfhffysxsnekq6kh4z7yq758w2x3gq7xc7sn`
{% endhint %}
