Skip to content
This repository has been archived by the owner on Nov 30, 2021. It is now read-only.

evm: balance and nonce invariants #661

Merged
merged 4 commits into from
Dec 15, 2020
Merged

evm: balance and nonce invariants #661

merged 4 commits into from
Dec 15, 2020

Conversation

fedekunze
Copy link
Contributor

@fedekunze fedekunze commented Dec 14, 2020

closes #314

@fedekunze fedekunze added the x/evm EVM module issues label Dec 14, 2020
@@ -37,17 +36,11 @@ func InitGenesis(ctx sdk.Context, k Keeper, accountKeeper types.AccountKeeper, d
}

evmBalance := acc.GetCoins().AmountOf(evmDenom)
if !evmBalance.Equal(account.Balance) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved this check to the invariant

@fedekunze fedekunze marked this pull request as ready for review December 14, 2020 20:09
@fedekunze fedekunze requested a review from noot as a code owner December 14, 2020 20:09

k.SetBalance(ctx, address, account.Balance.BigInt())
k.SetNonce(ctx, address, acc.GetSequence())
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this setter was missing

@araskachoi
Copy link
Contributor

Looks like the command is not working as intended though:

steps to reproduce:

  1. I used the init script (./init.sh) to start ethermintd
  2. I start the rest-server as well
  3. I run ethermintd export

Output:

ERROR: couldn't create db: Error initializing DB: resource temporarily unavailable

There are no relevant error messages that come out in the ethermintd and ethermintcli logs

@summerpro
Copy link
Contributor

closes #314

Why can this pr close issue314?

@fedekunze
Copy link
Contributor Author

Why can this pr close issue314?

Because the invariant check that is run on every block ensures the accounting is correct (see the function on files). For this, you have to run a node in the invariant mode

@fedekunze
Copy link
Contributor Author

Looks like the command is not working as intended though:

@araskachoi this PR is not related with the app export logic you mentioned. Although I just checked it on my own and it worked all right 👍 :

  1. run init.sh
  2. stop the daemon
  3. ethermintd export --for-zero-height --log_level="*:error" --height=3 > ~/genesis.json

Copy link
Contributor

@araskachoi araskachoi left a comment

Choose a reason for hiding this comment

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

looks good, left a couple of questions

@fedekunze fedekunze merged commit a1386ee into development Dec 15, 2020
@fedekunze fedekunze deleted the evm-invariants branch December 15, 2020 18:43
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ensure balance accounting is correct when sending multiple transfers with MsgSend
3 participants