MinaProtocol / mina

Mina is a cryptocurrency protocol with a constant size blockchain, improving scaling while maintaining decentralization and security.
https://minaprotocol.com
Apache License 2.0
1.99k stars 527 forks source link

epoch ledger snapshot assertion failure #6956

Open deepthiskumar opened 3 years ago

deepthiskumar commented 3 years ago

This assertion

          (*These are computed using different values but are supposed to be equal*)
          assert (
            Coda_base.Frozen_ledger_hash.equal snapshot_ledger_hash
              epoch_data.ledger.hash ) ;

in proof_of_stake.ml fails when computing next_producer_timing in the following condition: In an empty coda config directory: After initializing the frontier with the genesis state, node hears about a new root that's in epoch 1, syncs its local state to according to the new root, tries to compute the next producer timing based on the genesis state + updated local sync before the frontier is updated with the new root. This fails because the next_epoch_ledger in the local state is different from the next epoch ledger in the genesis block.

I think we can fix this by checking if the consensus state and the local state are in different epochs and don't try to look for a winning slot until they are in the same epoch? A proper fix would be to stop block production until the node is synced. Commenting the assertion for 4.1 (perhaps this is the local state sync race condition we were seeing in the past?)

deepthiskumar commented 3 years ago

This also means that we evaluate vrf using epoch 0 staking ledger first in epoch 1 (if the above race condition is not hit) and show next Next block will be produced in based on that. When bootstrap is completed, we evaluated again based on the correct ledger. Explains why some users have been seeing this value change