Skip to content

InitChainByStateMetadataBytes called for already initialized chain #711

@chriscandless

Description

@chriscandless

Description
handleStateAnchor has special case for stateAchor.GetStateIndex() == 0. It assumes chain initialization is in progress, so it calls InitChainByStateMetadataBytes. But what is chain was already initialized, but just no other block was produced yet? We get double initialization.

Although it sounds like not an issue, it becomes (a minor) one in combination with a fact, that L1 parameters change after time. On alphanet L1 parameters change pretty often. That means, that if we deploy chain localy, then restart node after 5 minutes we will get an error Ignoring InitialAO.

We need to review if there is a way to add some additional condition in addition to stateAchor.GetStateIndex() == 0 to check not only state index, but also the fact, that chain was already initialized. Sounda potentially simple, but need to be guided by @kape1395 , because I'm not sure how that change would influence consensus.

To Reproduce

  1. Remove waspdb beforehand
  2. Start wasp: wasp -c config.json
  3. Get some funds: wasp-cli wallet request-funds
  4. Log in: wasp auth login (wasp:wasp)
  5. Deploy chain: wasp-cli chain deploy --chain=testchain
  6. Restart wasp
  7. See InitChainByStateMetadataBytes is called again, because if stateAchor.GetStateIndex() == 0 case in handleStateAnchor is still valid

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions