Giter Site home page Giter Site logo

trchopan / scheduled-blocks Goto Github PK

View Code? Open in Web Editor NEW
7.0 2.0 0.0 64 KB

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

Haskell 100.00%
cardano schedule blocks stakepool-operator

scheduled-blocks's Introduction

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.

scheduled-blocks's People

Contributors

trchopan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  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.