diem: [Bug] Minting - Doubles the specified amount

🐛 Bug

I mint a new account with X libra, query balance on the account displays 2X libra.

To reproduce

I am able to reproduce the defect by running the following:

  1. account create
  2. account mint <account index> 10
  3. query balance <account index>

Example 1

libra% account create
>> Creating/retrieving next account from wallet
Created/retrieved account #6 address 6bd8942403ffae99ac6fd34ac075cae6e57614c30cf9467ba40f7e21cd17f497
libra% query balance 6
Balance is: 0.000000
libra% account mint 6 10
>> Minting coins
Mint request submitted
libra% query balance 6
Balance is: 20.000000

Example 2

libra% account list
No user accounts
libra% account create
>> Creating/retrieving next account from wallet
Created/retrieved account #0 address 529abf1ed8bea7541c385fd17cd81f67a789a0c66c177a36b0897bffe8edbcf7
libra% account create
>> Creating/retrieving next account from wallet
Created/retrieved account #1 address 8cb4a947bf12184d9080f8b3c3f0972f9a50bb6fb6b3f35a5d32bf9eefce3bea
libra% account mint 0 10
>> Minting coins
Mint request submitted
libra% account list
User account index: 0, address: 529abf1ed8bea7541c385fd17cd81f67a789a0c66c177a36b0897bffe8edbcf7, sequence number: 0, status: Local
User account index: 1, address: 8cb4a947bf12184d9080f8b3c3f0972f9a50bb6fb6b3f35a5d32bf9eefce3bea, sequence number: 0, status: Local
libra% account mint 1 10
>> Minting coins
Mint request submitted
libra% query balance 1
Balance is: 10.000000
libra% query balance 0
Balance is: 20.000000
libra% query balance 1
Balance is: 10.000000
libra% query balance 0
Balance is: 20.000000

Example 3

libra% account mint 7 100
>> Minting coins
Mint request submitted
libra% query balance 7
Balance is: 200.000000
libra% account create
>> Creating/retrieving next account from wallet
Created/retrieved account #8 address 1470739fe093c2e156b48defaf0e6f5f0eec889c441443011abcec60c3c8ccf0
libra% query balance
Invalid number of arguments for balance query
libra% query balance 8
Balance is: 0.000000
libra% account mint 8 17
>> Minting coins
Mint request submitted
libra% query balance 8
Balance is: 34.000000

Expected Behavior

After minting an account with X libra, querying the balance should display X libra.

System information

  • master branch, commit 78988282f76cb028a7b246c9f54c7342628cd13e
  • rustc 1.35.0 (3c235d560 2019-05-20)
  • OSX 10.14.1 (18B75)

Additional context

This is the first time I have run libra and connected to the testnet.

I built the project and ran the client using the following commands:

./scripts/dev_setup.sh
cargo build
./scripts/cli/start_cli_testnet.sh

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 21 (9 by maintainers)

Most upvoted comments

I am unable to reproduce:

Creating/retrieving next account from wallet Created/retrieved account #0 address 39c21531b5b43ec7d301ec8e0730a06442ae7f04fbc33c3c78e024d78ef628e3 libra% q b 0 Balance is: 0.000000 libra% a m 0 10 Minting coins Mint request submitted libra% q b 0 Balance is: 10.000000

One potential issue is that accounts aren’t created “fresh” if you have previously run the client. Since we use a mnuemonic file to seed the account creation, you’ll get the same set of accounts in the same order the next time you run the client - meaning that if you created an account and then minted some coins to it, then quit the client. Then you start the client again and create an account again, the balance for that account will be the same as what you previously minted because it’s actually the same account. Can you try removing client.mnemonic from scripts/cli and then attempt this again?

Hi @irmac,

I think @kphfb got to the point.

We are using deterministic derivation, but unless you write the newest state of your wallet via the below command, your client will lose all the information on the old accounts once you pkill it.

a w <Name of backup file>

What I think you did:

  1. You started up the client for the first time. This created a brand new mnemonic from a random seed generated using EntropyRng() and stored it at client.mnemonic.
  2. You created a new account via account create
  3. You minted X libra on that account via mint 0 <X>
  4. You pkilled the client
  5. You started up the client, which now did not create a new mnemonic since it found the client.mnemonic in the root level directory. This file does not contain information about the accounts you already created in step 1.
  6. You (re-)created a new account via account create. This is the same account you created earlier. You did not write your wallet state to file, so the wallet was instantiated as an empty wallet, even though you already created an account in the prior steps.
  7. You minted X libra on that account via mint 0 <X>
  8. You observed 2X libra minted on that account

As @kphfb explained: If you purge your mnemonic file before you start up the client the second time, then you will generate a fresh seed for generating private keys deterministically and this particular behavior will not be reproducible AFAIK.

Please let me know if I misunderstood anything.

@irmac

Now I see what you’re talking about. Ok, let me look into it!