near / near-explorer

NEAR blockchain explorer
https://explorer.near.org/
Apache License 2.0
87 stars 55 forks source link

Account balance is increasing without transfers #402

Open MaksymZavershynskyi opened 4 years ago

MaksymZavershynskyi commented 4 years ago

Observe https://explorer.testnet.near.org/accounts/ethonnearclient08

It is receiving transactions that increase its state. The transactions do not have attached tokens. However, the balance reported by explorer is increasing, instead of decreasing. I would expect explorer to show the liquid balance, which is the balance minus locked tokens. Is it possible that we are adding locked balance instead of subtracting it?

frol commented 4 years ago

Hmmmmm, that sounds very suspicious! There is no locked balance. Here are the RPC responses:

$ http post https://rpc.testnet.near.org jsonrpc=2.0 id=dontcare method=query   params:='{
    "request_type": "view_account",
    "finality": "final",
    "account_id": "ethonnearclient08"
  }'

{
    "id": "dontcare", 
    "jsonrpc": "2.0", 
    "result": {
        "amount": "2016248820508503486541357071", 
        "block_hash": "2QAPBaD8WgEx2zLPYcvng49KSew6ry5JSq6bh85V2tTd", 
        "block_height": 13755385, 
        "code_hash": "HqS81rTmHBUCE9EhYJUXNnYjxp9woEVYHPknfP9ZxGFM", 
        "locked": "0", 
        "storage_paid_at": 0, 
        "storage_usage": 8416050
    }
}

$ http post https://rpc.testnet.near.org jsonrpc=2.0 id=dontcare method=query   params:='{
    "request_type": "view_account",
    "finality": "final",
    "account_id": "ethonnearclient08"
  }'

{
    "id": "dontcare", 
    "jsonrpc": "2.0", 
    "result": {
        "amount": "2016301175039300695641357071", 
        "block_hash": "Bapzema3UgdSMEAM2zM2eeNRitTSUncCJaiVgN58quhQ", 
        "block_height": 13758870, 
        "code_hash": "HqS81rTmHBUCE9EhYJUXNnYjxp9woEVYHPknfP9ZxGFM", 
        "locked": "0", 
        "storage_paid_at": 0, 
        "storage_usage": 8444544
    }
}

Notice that the amount has changed! @bowenwang1996 @SkidanovAlex @evgenykuzyakov WTF?

bowenwang1996 commented 4 years ago

It is developer reward. When a contract is called, there is a 30% kickback from the transaction fee.

frol commented 4 years ago

@bowenwang1996 where is it documented/announced? How can we observe it? Is it a matter of config? Will it require hard-fork to disable these rewards?

bowenwang1996 commented 4 years ago

where is it documented/announced? How can we observe it?

https://near.org/papers/economics-in-sharded-blockchain/#developer-business-models

Is it a matter of config? Will it require hard-fork to disable these rewards?

It is in genesis config (burnt_gas_reward). It will require a protocol change to disable this reward, but why do you think we should disable it?

frol commented 4 years ago

@kcole16 @corwinharrell @vgrichina @khorolets @amgando FYI, the balance may increase with incoming function call transactions due to fees paid by the caller are partially rewarded to the receiver/contract account. We can observe the rewards through the State Changes (here is the transaction I use for this example):

$ http post https://rpc.testnet.near.org/ jsonrpc=2.0 id=dontcare method=EXPERIMENTAL_changes 'params:={"block_id": "8GdqoEmDx7SnvsRcQx7ZjpP9Jeth3tdqq8jEZtCGx74w", "changes_type": "account_changes", "account_ids": ["ethonnearclient08"]}'

{
    "id": "dontcare",
    "jsonrpc": "2.0",
    "result": {
        "block_hash": "8GdqoEmDx7SnvsRcQx7ZjpP9Jeth3tdqq8jEZtCGx74w",
        "changes": [
            {
                "cause": {
                    "receipt_hash": "GuYAFm8egDTC3Boq7sfdisAEYZeKCxZzmyzsC4meRQj5",
                    "type": "action_receipt_gas_reward"
                },
                "change": {
                    "account_id": "ethonnearclient08",
                    "amount": "2051300069168615931841357071",
                    "code_hash": "HqS81rTmHBUCE9EhYJUXNnYjxp9woEVYHPknfP9ZxGFM",
                    "locked": "0",
                    "storage_paid_at": 0,
                    "storage_usage": 8941901
                },
                "type": "account_update"
            },
            {
                "cause": {
                    "receipt_hash": "4rhVmFj1UEwPHHex4skeXdutZNtgAmRinGQioQDAsxhA",
                    "type": "action_receipt_gas_reward"
                },
                "change": {
                    "account_id": "ethonnearclient08",
                    "amount": "2051300470239495770741357071",
                    "code_hash": "HqS81rTmHBUCE9EhYJUXNnYjxp9woEVYHPknfP9ZxGFM",
                    "locked": "0",
                    "storage_paid_at": 0,
                    "storage_usage": 8941901
                },
                "type": "account_update"
            },
            {
                "cause": {
                    "receipt_hash": "DeaG1WoB89bCcoQmB25biuG9g1wG6TTT8tDrwGFpNJTp",
                    "type": "action_receipt_gas_reward"
                },
                "change": {
                    "account_id": "ethonnearclient08",
                    "amount": "2051300871310375609641357071",
                    "code_hash": "HqS81rTmHBUCE9EhYJUXNnYjxp9woEVYHPknfP9ZxGFM",
                    "locked": "0",
                    "storage_paid_at": 0,
                    "storage_usage": 8941901
                },
                "type": "account_update"
            },
            {
                "cause": {
                    "receipt_hash": "HfHSAYgizfddDYNmtGL9qXShGSjBfWYGLcW1Vjr6XfTr",
                    "type": "action_receipt_gas_reward"
                },
                "change": {
                    "account_id": "ethonnearclient08",
                    "amount": "2051301272381255448541357071",
                    "code_hash": "HqS81rTmHBUCE9EhYJUXNnYjxp9woEVYHPknfP9ZxGFM",
                    "locked": "0",
                    "storage_paid_at": 0,
                    "storage_usage": 8941901
                },
                "type": "account_update"
            },
            {
                "cause": {
                    "receipt_hash": "DFkfqG5GcsdPmNU25kNZPqDD9besJwWEjuBiW9ywzvEz",
                    "type": "action_receipt_gas_reward"
                },
                "change": {
                    "account_id": "ethonnearclient08",
                    "amount": "2051301672969076609741357071",
                    "code_hash": "HqS81rTmHBUCE9EhYJUXNnYjxp9woEVYHPknfP9ZxGFM",
                    "locked": "0",
                    "storage_paid_at": 0,
                    "storage_usage": 8941901
                },
                "type": "account_update"
            },
            {
                "cause": {
                    "receipt_hash": "6PmSt6bSBE79yhGnqD2VNNG5wB9rcFbqxxt97AhmkwEd",
                    "type": "action_receipt_gas_reward"
                },
                "change": {
                    "account_id": "ethonnearclient08",
                    "amount": "2051302074039956448641357071",
                    "code_hash": "HqS81rTmHBUCE9EhYJUXNnYjxp9woEVYHPknfP9ZxGFM",
                    "locked": "0",
                    "storage_paid_at": 0,
                    "storage_usage": 8941901
                },
                "type": "account_update"
            },
            {
                "cause": {
                    "receipt_hash": "FzhLTBCbUc6m7EPTPC7TzUyicFbvgsE6unLisUa2YZaw",
                    "type": "action_receipt_gas_reward"
                },
                "change": {
                    "account_id": "ethonnearclient08",
                    "amount": "2051302474627777609841357071",
                    "code_hash": "HqS81rTmHBUCE9EhYJUXNnYjxp9woEVYHPknfP9ZxGFM",
                    "locked": "0",
                    "storage_paid_at": 0,
                    "storage_usage": 8941901
                },
                "type": "account_update"
            },
            {
                "cause": {
                    "receipt_hash": "12NVdUpRvVFzZg2bhbkZ85cqgdXhQejEAj3xzkVdUAVS",
                    "type": "action_receipt_gas_reward"
                },
                "change": {
                    "account_id": "ethonnearclient08",
                    "amount": "2051302875698657448741357071",
                    "code_hash": "HqS81rTmHBUCE9EhYJUXNnYjxp9woEVYHPknfP9ZxGFM",
                    "locked": "0",
                    "storage_paid_at": 0,
                    "storage_usage": 8941901
                },
                "type": "account_update"
            },
            {
                "cause": {
                    "receipt_hash": "FEfE3BwqrzU5Qg5aKwnVjce6jJ19vLw2PLitLFyUok4p",
                    "type": "action_receipt_gas_reward"
                },
                "change": {
                    "account_id": "ethonnearclient08",
                    "amount": "2051303276769537287641357071",
                    "code_hash": "HqS81rTmHBUCE9EhYJUXNnYjxp9woEVYHPknfP9ZxGFM",
                    "locked": "0",
                    "storage_paid_at": 0,
                    "storage_usage": 8941901
                },
                "type": "account_update"
            }
        ]
    }
}

The account balance before the transaction (block # 14041390) was:

2051294069168615931841357071 yoctoNEAR

The block that includes the transaction (block # 14041391) has the following balance for the account:

2051303276769537287641357071 yoctoNEAR (+0.0092 NEAR)

The block after the transaction was submitted (block # 14041392) includes the receipt for the transaction and thus the contract account receives another reward and the balance is now:

2051303677840417126541357071 yoctoNEAR (+0.0004 NEAR)

$ http post https://rpc.testnet.near.org/ jsonrpc=2.0 id=dontcare method=EXPERIMENTAL_changes 'params:={"block_id": 14041392, "changes_type": "account_changes", "account_ids": ["ethonnearclient08"]}'

{
    "id": "dontcare",
    "jsonrpc": "2.0",
    "result": {
        "block_hash": "EttMZLLKa9RJJeSTCzujE6yaLwitzDpNLZkvXx7qf1sd",
        "changes": [
            {
                "cause": {
                    "receipt_hash": "An4cemkYdd8srt6bL6XpzUoXY7XYhs7qLeQ5id9Fz2jF",
                    "type": "action_receipt_gas_reward"
                },
                "change": {
                    "account_id": "ethonnearclient08",
                    "amount": "2051303677840417126541357071",
                    "code_hash": "HqS81rTmHBUCE9EhYJUXNnYjxp9woEVYHPknfP9ZxGFM",
                    "locked": "0",
                    "storage_paid_at": 0,
                    "storage_usage": 8941901
                },
                "type": "account_update"
            }
        ]
    }
}

We cannot expose this information in the current Explorer due to the lack of receipts stored on the backend. With the new Indexer for Explorer we will be able to track these down (@khorolets we will need to dig down the state changes for gas rewards like this, validation rewards, etc)

frol commented 4 years ago

why do you think we should disable it?

I somehow thought it was a temporary solution; now I see that it is a permanent economic incentive.

icerove commented 4 years ago

so should we ignore it right now and deploy this in the indexer?

frol commented 4 years ago

Yes, there is no actionable item at the moment