iotaledger / iotaledger/wasp

InitChainByStateMetadataBytes called for already initialized chain

Open
#711 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Go
Stars
7
Forks
13
PR merge metrics
No merged PRs in 30d

Description

**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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.