cardano-community / guild-operators

Artifacts and scripts created by Guild operators
https://cardano-community.github.io/guild-operators
MIT License
353 stars 179 forks source link

[feature] - blocklog.db - full stakepool history load into epochdata table #1781

Closed asnakep closed 4 months ago

asnakep commented 4 months ago

Hello CNTools Team,

I would like to propose the integration in cncli.sh of a process I wrote to perform a full load of epochdata table in blocklog db.

The scenario is this: An operator runs a stakepool for months or years without using cntools/cncli and makes blocks during this period. At some point, the operator starts using cntools/cncli, and when cncli initializes, all block schedules from the first pool block until the last are entered into the blocklog table in blocklog.db.

Meanwhile, the epochdata table is updated at every slot leader check, so you only have data in epochdata from when you started using CNTools, not from before.

The script checks all previous epochs where your pool got at least one block based on the query "SELECT DISTINCT epoch FROM blocklog."

It also takes into account the current epoch and the next epoch if it's found in the blocklog table.

Depending of the pool history it can take some minutes or a lot of hours. It took 2 hours and 20 minutes to process 136 epochs.

It could be an optional part of cncli.sh init (with force option too).

It has been tested several times and failed only once during the first hours of new epoch, and the reason could be because pool_stake_snapshot Koios point was not available or because values in it were rotating from Mark to Set.

I attach the script.

Thank you, cheers, Manuel

cncli_fulload_epochdata_table.sh.txt

rdlrt commented 4 months ago

Thanks for raising this, I agree with the outcome - but I feel this should be part of cncli.sh wrapper itself. In case you'd like to submit a PR for the same (if not - would likely fall into four uture priority list 🙂 )

asnakep commented 4 months ago

Thanks Priyank, yes it should be inside cncli.sh, I initially specified this "I would like to propose the integration in cncli.sh...."

I open the PR

Cheers, Manuel

asnakep commented 4 months ago

Hi Priyank,

I forgot to ask it, no pb I can do it but, do want cncli.sh with my code integrated for PR?

Thank you Manuel

rdlrt commented 4 months ago

Yip - would be good to add the old epoch additions to validate function

asnakep commented 4 months ago

Cool, I took note of that thank you Manuel