trchopan / scheduled-blocks

Use the Epoch Nonce seeds and compare with the Pool sigma derived VRF key of the Pool to calculate the block assignment schedule.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

scheduled-blocks

Use the Epoch Nonce seeds and compare with the Pool sigma derived VRF key of the Pool to calculate the block assignment schedule.

No cardano-node Required, data is taken from blockfrost.io and armada-alliance.com.

This is a rewritten in Haskell of the ScheduledBlocks in Python.

Commands

history

Get the scheduled block in past epoch (current epoch included)

Example

$ scheduled-blocks history --epoch 321 \
    --blockFrostApi $BLOCKFROST_API \
    --poolId $POOL_ID \
    --vrfSkey ~/vrf.skey

Checking current network epoch...done
Checking Pool Sigma from Pool History...done
Checking epoch parameters...done
Checking epoch info for active stake...done
Checking network genenis...done
Nonce: 97be25ab0a46a6537faaf32f882de17611c897f32c7eeef12f53a176b225e461
Active Slot Coefficient: 0.050
Epoch Length: 432000
Slot Length: 1
First Slot of Epoch: 53308800
Last Slot of Epoch: 53740800
Active Stake (epoch 321): 23,537,719,498,083,358
Pool Active Stake: 916,392,141,238
Pool Sigma: 0.000038933
Slot 53309568 block assigned. Time 2022-02-15 04:57:39 +0700

Working [==================>......]  74%

next

Get the scheduled block for the next epoch by query the nonce from armada-aliance.

Note: Next nonce is announce 1.5 days before the end of current epoch.

persistReport

Perform the epoch schedule calculation for all epoch starting from --fromEpoch flag to current epoch.

With each iteration save the block schedule into file in output directory, under file name <epoch>.json name.

Example

$ scheduled-blocks persistReport --output ./block-schedules/ --fromEpoch 321 --blockFrostApi $BLOCKFROST_API --poolId $POOL_ID --vrfSkey ~/vrf.skey
Checking current network epoch...done
./block-schedules/321.json file not exist
================================================================================
Checking current network epoch...done
Checking Pool Sigma from Pool History...done
Checking epoch parameters...done
Checking epoch info for active stake...done
Checking network genenis...done
Checking first Shelly block...done
Epoch: 321
Nonce: 97be25ab0a46a6537faaf32f882de17611c897f32c7eeef12f53a176b225e461
Active Slot Coefficient: 0.050
Epoch Length: 432000
Slot Length: 1
First Slot of Epoch: 53308800
Last Slot of Epoch: 53740800
Active Stake (epoch 321): 23,537,719,498,083,358
Pool Active Stake: 916,392,141,238
Pool Sigma: 0.000038933
Slot 53309568 block assigned. Time 2022-02-15 04:57:39 +0700

Slot 53719603 block assigned. Time 2022-02-19 22:51:34 +0700

CPU time:  69.54s
already check epoch 322
[]

already check epoch 323
[
    {
        "slot": 54456018,
        "time": "2022-02-28T04:25:09Z"
    }
]

Build

libsodium

This tool depends on libsodium for the calculation of the crypto vrf seed bytes.

Install by source: https://github.com/input-output-hk/libsodium

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

GHC

Recommend to use GHCup https://www.haskell.org/ghcup/

Use ghcup tui to select:

  • ghc 8.10.7
  • cabal 3.6.0.0

Build

cabal build

# If cabal cannot find the correct lib path for libsodium, it can be provided by
# cabal build --extra-lib-dirs=/usr/local/lib

WIP

I’m trying to implement concurrency code for the slot leader calculation. At the moment, speed not yet change much as I’m still learning Haskell and the implementation may not correct.

If you like to try out the concurrency code. It can be run using RTS flag: +RTS -N4 where 4 is the number of available cores.

Tags

cardano blockchain, block schedule, epoch, blockfrost, armada-alliance

License

MIT

Copyright (c) 2022-, Quang Tran.

About

Use the Epoch Nonce seeds and compare with the Pool sigma derived VRF key of the Pool to calculate the block assignment schedule.


Languages

Language:Haskell 100.0%