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

Negative Balance #1384

Closed
stakeada opened this issue Dec 17, 2019 · 3 comments
Closed

Negative Balance #1384

stakeada opened this issue Dec 17, 2019 · 3 comments
Labels
A-explorer Area: Explorer API and backend

Comments

@stakeada
Copy link

stakeada commented Dec 17, 2019

Describe the bug

I've set up a stake pool and now I have negative balance.

Mandatory Information

  1. jcli 0.8.2 (heads/v0.8.2-fe327f9a, release, linux [x86_64]) - [rustc 1.38.0 (625451e37 2019-09-23)]
  2. jormungandr 0.8.2 (heads/v0.8.2-fe327f9a, release, linux [x86_64]) - [rustc 1.38.0 (625451e37 2019-09-23)]"

To Reproduce
Steps to reproduce the behavior:

  1. Fund my wallet:
# export PLEDGE_AMOUNT=500700000
# cardano-wallet transaction create $SHELLEY_ID --payment $PLEDGE_AMOUNT@addr1skyy52dhd2nls9sxdg0vtt8dguvacalgcxzhuax9r7y8fslnre702ux9k87
  1. Create stake pool as is normally the case:
# jcli key generate --type=Curve25519_2HashDH > vrf.prv
# jcli key to-public < vrf.prv > vrf.pub
# jcli key generate --type=SumEd25519_12 > kes.prv
# jcli key to-public < kes.prv > kes.pub
# export TAX_LIMIT=1000000
# export TAX_RATIO="1/20"
# export TAX_FIXED=0
# jcli certificate new stake-pool-registration --tax-fixed $TAX_FIXED --tax-ratio $TAX_RATIO --kes-key $(cat kes.pub) --vrf-key $(cat vrf.pub) --owner $(cat owner.pub) --start-validity 0 --management-threshold 1 > stake-pool-registration.cert
# export FEE_CONSTANT=200000
# export FEE_COEFFICIENT=100000
# export FEE_POOL_REGISTRATION=500000000
# export FEE_STAKE_DELEGATION=400000
# export GENESIS_HASH=8e4d2a343f3dcf9330ad9035b3e8d168e6728904262f2c434a4f8f934ec7b676
# jcli transaction new | \
>   jcli transaction add-account $(cat owner.addr) $PLEDGE_AMOUNT  | \
>   jcli transaction add-certificate $(cat stake-pool-registration.cert) | \
>   jcli transaction finalize $(cat owner.addr) \
>     --fee-constant $FEE_CONSTANT \
>     --fee-coefficient $FEE_COEFFICIENT \
>     --fee-pool-registration $FEE_POOL_REGISTRATION \
>   > transaction.tmp
# jcli transaction make-witness \
>   $(jcli transaction data-for-witness < transaction.tmp) \
>   --genesis-block-hash $GENESIS_HASH \
>   --type account \
>   --account-spending-counter 0 \
>   owner.witness \
>   owner.prv
# jcli transaction add-witness owner.witness < transaction.tmp \
>   | jcli transaction seal \
>   | jcli transaction auth -k owner.prv \
>   | jcli transaction to-message \
>   > transaction.bin
  1. The ShelleyExplorer is showing negative balance

Expected behavior
No negative balance. I've only registered the stakepool once, which is why the fee should be subtracted only once. Not sure what happened, but it appears it was subtracted twice.

Also how can balance be negative anyway?

@rinor
Copy link
Contributor

rinor commented Dec 17, 2019

Also how can balance be negative anyway?

It isn't.

The problem is in the explorer.
If you check your balance from the ledger:
jcli rest v0 account get addr1skyy52dhd2nls9sxdg0vtt8dguvacalgcxzhuax9r7y8fslnre702ux9k87 --host "http://127.0.0.1:8001/api" --output-format json

{
  "counter": 1,
  "delegation": {
    "pools": []
  },
  "last_rewards": {
    "epoch": 0,
    "reward": 0
  },
  "value": 300000
}

your balance is exactly 300000 Lovelace or 0.3 ADA.

In this block is included our first transaction that funded addr1skyy52dhd2nls9sxdg0vtt8dguvacalgcxzhuax9r7y8fslnre702ux9k87 with 500.700000 ADA.

In this block is included your second transaction (pool registration) that costed you (in FEES) 500.400000 ADA leaving you with balance of 0.300000 ADA.

To be sure lets inspect some data from the second block since there are not much transactions in that block.

jcli rest v0 block 9f78ee62f43990f7d8a32da9721154aa1a4d92983d8deb2ce594ff338ecd38fc get --host "http://127.0.0.1:8001/api" | jcli debug block

Block {
    header: Header {
        version: 2,
        content_size: 382,
        date: BlockDate {
            epoch: 2,slot_id: 1784,
        },
        height: ChainLength(
            8694,
        ),
        content_hash: [
            117,140,42,56,152,238,132,71,242,226,225,2,16,131,108,7,244,234,119,47,239,36,52,143,255,39,255,213,44,244,112,152,
        ],
        parent_hash: [
            102,117,72,114,159,14,206,86,73,254,200,81,95,241,162,82,64,173,168,229,116,246,146,101,238,172,178,104,112,42,190,173,
        ],
        pool-id: [
            5,102,51,137,80,76,214,73,253,214,207,196,6,195,24,114,195,35,153,174,103,33,100,34,69,247,105,70,229,91,177,254,
        ],
        vrf-proof: [
            216,33,96,129,100,45,214,87,56,232,48,219,67,27,124,144,213,98,199,215,229,21,47,227,235,227,192,61,154,92,23,120,226,196,216,247,165,50,254,125,113,246,139,157,171,153,161,101,208,98,237,71,61,29,137,30,254,133,51,84,136,41,68,4,225,76,137,68,231,74,6,23,100,233,172,113,89,190,138,145,34,60,249,93,135,7,18,11,23,168,178,182,186,75,6,3,
        ],
        kes-sig: [
            0,0,0,0,106,94,198,50,96,178,6,4,74,220,188,108,114,154,203,184,87,196,145,132,16,20,21,29,180,81,137,92,116,114,83,156,73,63,103,140,188,87,78,55,221,11,223,191,101,33,6,159,11,254,137,74,174,162,233,132,119,18,65,63,9,143,181,15,192,6,174,25,155,88,141,15,96,40,197,203,201,123,194,165,133,163,170,22,26,182,218,32,128,239,57,240,108,81,97,29,167,27,232,114,103,49,9,166,11,118,135,30,78,30,129,134,104,160,43,43,15,11,57,253,13,54,3,111,49,59,205,12,89,65,103,95,15,40,49,12,196,119,116,40,4,217,51,32,154,246,93,53,248,36,142,60,49,43,39,148,131,139,211,191,172,32,3,202,224,65,39,245,111,81,41,71,240,100,174,6,69,40,230,190,30,140,93,148,26,112,194,76,98,128,113,53,97,1,38,248,107,37,144,30,32,46,197,74,109,250,235,61,188,129,237,255,107,99,253,85,248,9,247,97,1,192,132,183,213,47,173,137,69,205,220,107,136,48,15,91,42,105,184,188,199,30,147,90,27,241,232,171,46,252,230,122,131,26,124,65,177,10,29,90,36,159,214,36,209,214,41,5,14,216,70,83,54,232,218,137,113,74,21,78,24,146,121,181,48,169,234,186,224,246,1,126,32,1,31,177,157,253,154,125,51,17,167,254,161,78,5,5,234,126,226,112,111,194,49,254,252,244,75,195,83,153,218,106,14,242,186,201,216,71,21,61,155,230,55,158,131,71,20,250,253,45,61,31,41,233,148,191,209,226,93,205,41,115,52,4,186,165,80,132,181,51,162,48,214,107,208,184,148,255,66,77,221,245,188,97,205,19,93,250,119,7,164,255,39,45,34,207,232,43,224,129,218,236,159,234,221,185,22,44,136,7,244,166,135,233,12,36,205,93,65,179,141,52,129,208,59,48,95,199,45,32,104,31,15,95,58,196,200,71,95,44,144,104,207,53,112,81,179,234,159,48,158,166,51,187,124,12,76,185,191,61,191,133,127,80,111,79,184,86,104,254,90,185,187,99,167,203,220,157,251,144,250,61,47,253,101,254,220,89,
        ],
        self_hash: Hash(
            Blake2b256(0x9f78ee62f43990f7d8a32da9721154aa1a4d92983d8deb2ce594ff338ecd38fc),
        ),
    },
    contents: Contents(
        [
            PoolRegistration(
                Transaction {
                    payload: [
                        0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,54,202,34,43,221,211,253,44,62,252,47,174,152,63,32,241,148,27,236,107,75,125,49,69,59,3,228,148,209,156,251,126,57,145,144,255,233,223,51,167,34,195,10,158,230,55,133,253,103,45,206,144,129,28,119,111,18,225,214,87,11,87,33,8,1,136,74,41,183,106,167,248,22,6,106,30,197,172,237,71,25,220,119,232,193,133,126,116,197,31,136,116,195,243,30,124,245,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,20,0,0,0,0,0,0,0,0,0,1,1,
                    ]
                    nb_inputs: 1,
                    nb_outputs: 1,
                    nb_witnesses: 1,
                    total_input_value: Ok(
                        Value(
                            500700000,
                        ),
                    ),
                    total_output_value: Ok(
                        Value(
                            300000,
                        ),
                    ),
                },
            ),
        ],
    ),
}

That block has only 1 Transaction containing the mentioned Pool Registration and the values match the expectations. The output value is what your balance is (at this exact moment) 0.300000 ADA.

Let me know if you need more info.

@stakeada
Copy link
Author

Thank you very much, I was worried of a critical bug in jormungandr.

However, this ticket should be opened in the ShelleyExplorer then and fixed accordingly.

@rinor
Copy link
Contributor

rinor commented Jan 6, 2020

@stakeada for now a simple fix is provided by #1397. Thank you for the report.

@rinor rinor closed this as completed Jan 6, 2020
@rinor rinor added the A-explorer Area: Explorer API and backend label Jan 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-explorer Area: Explorer API and backend
Projects
None yet
Development

No branches or pull requests

2 participants