Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix MPT branch node strip after deletion #2034

Merged
merged 3 commits into from
Jul 6, 2021
Merged

Fix MPT branch node strip after deletion #2034

merged 3 commits into from
Jul 6, 2021

Conversation

fyrchik
Copy link
Contributor

@fyrchik fyrchik commented Jul 2, 2021

If the only child left is hash node, we need to retrieve it from storage.

Another commit fixes only state dump.

After the restore node seems (waited for a couple of minutes) to be adding state roots without errors.

@@ -173,11 +173,12 @@ func (c *nep17TokenNative) updateAccBalance(ic *interop.Context, acc util.Uint16
return errors.New("insufficient funds")
}
si = state.StorageItem{}
} else if amount.Sign() == 0 && requiredBalance != nil {
} else if amount.Sign() <= 0 && requiredBalance != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it's better to put back si after receiving an error from incBalance? Otherwise we're unwrapping/comparing the balance twice.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about this though?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, forgot to push.

@@ -173,11 +173,12 @@ func (c *nep17TokenNative) updateAccBalance(ic *interop.Context, acc util.Uint16
return errors.New("insufficient funds")
}
si = state.StorageItem{}
} else if amount.Sign() == 0 && requiredBalance != nil {
} else if amount.Sign() <= 0 && requiredBalance != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it's better to put back si after receiving an error from incBalance? Otherwise we're unwrapping/comparing the balance twice.

pkg/core/native/native_nep17.go Show resolved Hide resolved
pkg/core/mpt/batch.go Show resolved Hide resolved
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
If the child left is a hash node, we should retrieve it from store.

Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
@roman-khimov roman-khimov merged commit ae8f4eb into master Jul 6, 2021
@roman-khimov roman-khimov deleted the fix-state branch July 6, 2021 11:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants