Skip to content

Conversation

kderme
Copy link
Contributor

@kderme kderme commented Aug 23, 2021

Fixes #507

With this pr db-sync supports node configuration like
"TestShelleyHardForkAtEpoch": 0

It also supports initial funds and staking in the Shelley Genesis

When the Shelley Genesis file has some important information, like initial distribution, pools and delegations, an artificial Shelley Genesis Block is inserted and artificial Txs, to attach all the information to it. The genesis blocks have some unique characteristics in the db:

  • Byron Genesis Block has null EpochNo and null PreviousId
  • Shelley Genesis Block has null EpochNo and non-null PreviousId

In most cases the Shelley Genesis Block will be the next block of the Byron Genesis block. This means the byron genesis block may have two next blocks.

The Shelley Genesis block is not inserted, if it lacks any important information (funds/staking). So this should not affect mainnet.

@kderme kderme requested a review from erikd as a code owner August 23, 2021 09:15
@kderme kderme force-pushed the kderme/fix-fork-at-0 branch 3 times, most recently from b0a9715 to 1f96fd8 Compare August 27, 2021 12:05
@savaki
Copy link

savaki commented Aug 31, 2021

Previously, if creating a new testnet via scripts/byron-to-alonzo/mkfiles.sh, cardano-db-sync would fail to start up. Once we switched to the branch, cardano-db-sync successful starts up and runs. However, if cardano-db-sync is shut down and then restarted, the following error appears:

cardano-db-sync-extended_1   | [db-sync-node:Info:6] [2021-08-30 20:18:44.52 UTC] NetworkMagic: 31415
cardano-db-sync-extended_1   | [db-sync-node:Info:6] [2021-08-30 20:18:44.53 UTC] Initial genesis distribution present and correct
cardano-db-sync-extended_1   | [db-sync-node:Info:6] [2021-08-30 20:18:44.53 UTC] Total genesis supply of Ada: 10020.000000
cardano-db-sync-extended_1   | [db-sync-node:Info:6] [2021-08-30 20:18:44.53 UTC] Validating Genesis distribution
cardano-db-sync-extended_1   | Error: Shelley.validateGenesisDistribution: Expected initial block to have 1 but got 2

@savaki
Copy link

savaki commented Aug 31, 2021

Seems like the issue lies here, https://github.com/input-output-hk/cardano-db-sync/blob/1f96fd8f010c7a117a3c622884abcdc550890735/cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Genesis.hs#L164

where expectedTxCount is off. Looking at the byron genesis file, I see:

  "nonAvvmBalances": {
    "5oP9ib6ym3XYb4bdW1gpkqYpzw939QGkd7xUAYemppCiBiMBQtY4jTfnboPBrZfWkh": "5010000000",
    "5oP9ib6ym3XbF24fvvwzCEhPynWgmMM9d9Z5tDvB7msP133Ria6m58umoomWAuByWr": "5010000000"
  },

so I would have expected 2 to be returned.

@kderme
Copy link
Contributor Author

kderme commented Aug 31, 2021

Previously, if creating a new testnet via scripts/byron-to-alonzo/mkfiles.sh, cardano-db-sync would fail to start up. Once we switched to the branch, cardano-db-sync successful starts up and runs. However, if cardano-db-sync is shut down and then restarted, the following error appears:

cardano-db-sync-extended_1   | [db-sync-node:Info:6] [2021-08-30 20:18:44.52 UTC] NetworkMagic: 31415
cardano-db-sync-extended_1   | [db-sync-node:Info:6] [2021-08-30 20:18:44.53 UTC] Initial genesis distribution present and correct
cardano-db-sync-extended_1   | [db-sync-node:Info:6] [2021-08-30 20:18:44.53 UTC] Total genesis supply of Ada: 10020.000000
cardano-db-sync-extended_1   | [db-sync-node:Info:6] [2021-08-30 20:18:44.53 UTC] Validating Genesis distribution
cardano-db-sync-extended_1   | Error: Shelley.validateGenesisDistribution: Expected initial block to have 1 but got 2

Thank you for pointing this out. There are indeed some remaining issues with this pr.

@erikd
Copy link
Contributor

erikd commented Sep 6, 2021

@kderme Is this going to be addressed:

There are indeed some remaining issues with this pr.

@kderme
Copy link
Contributor Author

kderme commented Sep 8, 2021

@savaki the error you get comes from the Shelley genesis and the nonAvvmBalances is from the Byron genesis file. Maybe there is a misconfiguration between the two when you restart db-sync?

@kderme kderme force-pushed the kderme/fix-fork-at-0 branch from 1f96fd8 to b20ce42 Compare September 9, 2021 20:53
@erikd
Copy link
Contributor

erikd commented Oct 1, 2021

Cherry picked the "Support networks that fork at 0" commit into #864 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

support transition from byron -> another era in epoch 0

3 participants