Re-creating Your Stake Pool's Block Schedule

Figuring out your stake pool’s block schedule is a great tool for planning maintenance. Thanks to

@amw7

and other contributors from the community, we now have a tool to figure out your block schedule! This video shows you how to create it for your pool.

3 Likes

I keep getting this error:

node cardanoLeaderLogs.js slotLeaderLogsConfig.json fa2cd68857d74b32d704c86ac94ad40c2d7b5d7143ace3ea4e1fa798794059c0
             process args: [
  '/usr/bin/node',
  '/home/ubuntu/relay/cardano-leader-logs/cardanoLeaderLogs.js',
  'slotLeaderLogsConfig.json',
  'fa2cd68857d74b32d704c86ac94ad40c2d7b5d7143ace3ea4e1fa798794059c0'
]
     replaying last epoch: false
                  Network: --mainnet
     Loading ledger state: null
Error: Command failed: cardano-cli shelley query ledger-state --cardano-mode --mainnet > /home/ubuntu/relay/cardano-leader-logs/ledgerstate.json
/bin/sh: 1: cardano-cli: not found

    at ChildProcess.exithandler (child_process.js:308:12)
    at ChildProcess.emit (events.js:315:20)
    at maybeClose (internal/child_process.js:1048:16)
    at Socket.<anonymous> (internal/child_process.js:439:11)
    at Socket.emit (events.js:315:20)
    at Pipe.<anonymous> (net.js:673:12) {
  killed: false,
  code: 127,
  signal: null,
  cmd: 'cardano-cli shelley query ledger-state --cardano-mode --mainnet > /home/ubuntu/relay/cardano-leader-logs/ledgerstate.json '
}
(node:1196) UnhandledPromiseRejectionWarning: SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at loadLedgerState (/home/ubuntu/relay/cardano-leader-logs/cardanoLeaderLogs.js:58:15)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async calculateLeaderLogs (/home/ubuntu/relay/cardano-leader-logs/cardanoLeaderLogs.js:98:14)
    at async main (/home/ubuntu/relay/cardano-leader-logs/cardanoLeaderLogs.js:140:3)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:1196) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:1196) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Any idea where I goofed?

cardano-cli binary is not in your PATH:

/bin/sh: 1: cardano-cli: not found

try adding:

if [ -d "$HOME/.cabal/bin" ] ; then
    PATH="$HOME/.cabal/bin:$PATH"
fi

to your .profile file and run source .profile then try running again. The .profile should be in your user’s home directory - although it might be named differently for different distributions (this is for Ubuntu 20.04).

That did it.

You the man!

ps. How does this work? Is the slot leader ‘lottery’ determined at the time of the snapshot and not done in real-time?

Since the HFC this now fails for me with:

{ Error: Command failed: cardano-cli shelley query ledger-state --cardano-mode --mainnet > /home/adam/cardano/cardano-leader-logs/ledgerstate.json 
WARNING: The "shelley" subcommand is now deprecated and will be removed in the future. Please use the top-level commands instead.
Shelley command failed: query ledger-state  Error: A query from a certain era was applied to a ledger from a different era: EraMismatch {ledgerEraName = "Allegra", otherEraName = "Shelley"}

Digging into the error, the root issue seems to be querying the ledger-state:

cardano-cli query ledger-state --cardano-mode --mainnet
Shelley command failed: query ledger-state  Error: A query from a certain era was applied to a ledger from a different era: EraMismatch {ledgerEraName = "Allegra", otherEraName = "Shelley"}

There doesn’t seem to be any docs that I can find around querying the ledger state since the Allegra HFC event.

1 Like

@lungaretta, hi!

Perhaps try to specify the era with an extra option - - allegra-era?

Cheers A

3 Likes

@lungaretta, yep, this is the solution. I’ve put up a PR on the repo for the fix.

1 Like

Do you have a link for me to see? The original repo from MarcelKlammer looks like it’s been removed…?

Hi @Dostrelith,

Thanks for your input and pr. I have an open topic about the Shelley subcommand in the Operators group. I don’t wish to hijack this thread, would you care to also comment there? I have a number of questions in relation to this change.

I figured it out now. As well as the two additions of --allegra-era in cardanoLeaderLogs.js, the structure of the ledgerstate.json has also changed which was causing parsing errors for me. So in ledgerUtils.js file all four references to ledger.esSnapshots need to be changed to ledger.nesEs.esSnapshots.

Yep, that came with cnode 1.24.2. The PR for that was merge so you could do a git pull for it, but manually changing it works too as well of course :slight_smile:

Seems like the original repo was removed :pensive:

You can achieve similar results by using cncli (or using the archived repo from (@Dostrelith)
The following commands will only work if you have cncli installed and have the sync service enabled (Guild Operators)

Download the current Ledger state (should be quick)

cardano-cli query ledger-state --cardano-mode --mainnet --allegra-era > /tmp/ledger-state.json

Then you can use the following command to see if you have any slots assigned to you in the next epoch

cd $CNODE_HOME/guild-db/cncli

cncli leaderlog --pool-id [POOL_ID] --pool-vrf-skey $CNODE_HOME/priv/pool/[POOL_NAME]/vrf.skey --byron-genesis $CNODE_HOME/files/byron-genesis.json --shelley-genesis $CNODE_HOME/files/genesis.json --ledger-state /tmp/ledger-state.json --ledger-set next

You can also pass other ledger values to see different epoch information:

–ledger-set next = will get info from the next epoch
–ledger-set current = will get info from the current epoch
–ledger-set previous = will get into from the previous epoch

The output will look like this

{
  "status": "ok", 
  "epoch": 237,
  "epochNonce": "ac0e65bc72164256d1349245073a52cafeb9bcd313c6bfbcac6d2c62d6437085",
  "epochSlots": 1,
  "epochSlotsIdeal": 0.11,    
  "maxPerformance": 909.09,
  "poolId": "[POOL_ID]",
  "sigma": 7.421986221128383e-6,
  "activeStake": 151318101569,
  "totalActiveStake": 20387817635424648,
  "d": 0.32,
  "f": 0.05,
  "assignedSlots": [
    { 
      "no": 1, 
      "slot": 17225411,
      "slotInEpoch": 206110,
      "at": "2020-12-22T11:01:58-08:00"
    } 
  ]
}

If you see nothing in “assignedSlots”, then you don’t have any slots assigned :frowning:

You should be able to view the next Block schedule once the Epoch is around 70% completed (or 1.5 days before the epoch ends)

2 Likes

Yep, I should have posted an update here. I re-created the repo and am maintaining it - updated installation instructions and set up stream-JSON in the code to handle ledger getting too large to read normally from a file yesterday.

npm -i stream-json before running the latest code!

1 Like

As you seem to be quite into the this topic… Maybe you can tell me if it is possible to make cardano-cli dump previous ledger states. Say from 10 epochs ago? That would be great, but I could not find anything about this. Maybe I was usind the wrong terms for searching the web… :slight_smile: