autonity / autonity-cli

Command line interface to interact with Autonity
MIT License
11 stars 10 forks source link

`validator info` returns incorrect values for `liquidContract` , `liquidSupply` and `totalSlashed`. `selfUnbondingStakeLocked` missing #125

Closed cmjc closed 11 months ago

cmjc commented 1 year ago

See also following comment where a second bug was found after bonding self-bonded and delegated stake

Bug The command validator info is returning the zero address in the liquidContract field instead of the actual validator liquid contract address.

Expected behaviour The correct address is returned.

aut version

$ aut --version
aut, version 0.3.0.dev1

Example

aut validator info --validator 0x21bb01Ae8EB831fFf68EbE1D87B11c85a766C94C
{
  "treasury": "0x61EE7d3244642E5f6D654416a098DEabFBF5306e",
  "node_address": "0x21bb01Ae8EB831fFf68EbE1D87B11c85a766C94C",
  "oracle_address": "0x9b844631B7279576330B9B822bE79266696fF8C2",
  "enode": "enode://b2748268c31ebab8603058335bb4bed062e05b9ceaa3562f69868a01d1038a84136fc587fb913e1cb8ce821f1eb0bf9879e3249f18adcd39f1211a104ceb57a9@35.197.223.249:30303",
  "commission_rate": 1000,
  "bonded_stake": 10000000000000000000000,
  "unbonding_stake": 0,
  "unbonding_shares": 0,
  "self_bonded_stake": 10000000000000000000000,
  "self_unbonding_stake": 0,
  "self_unbonding_shares": 0,
  "liquid_contract": "0x0000000000000000000000000000000000000000",
  "liquid_supply": 1397840815523076466699159265359708166239426845751,
  "registration_block": 0,
  "total_slashed": 0,
  "jail_release_block": 0,
  "provable_fault_count": 0,
  "state": 0
}

Using an RPC curl the actual value is correctly returned:


curl --silent --location --request GET 'http://127.0.0.1:8545' --header 'Content-Type: application/json' --data-raw '{
                "jsonrpc":"2.0",
                "method":"aut_getValidator", "params":["0x21bb01Ae8EB831fFf68EbE1D87B11c85a766C94C"],
                "id":1}' | jq
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "treasury": "0x61ee7d3244642e5f6d654416a098deabfbf5306e",
    "nodeAddress": "0x21bb01ae8eb831fff68ebe1d87b11c85a766c94c",
    "oracleAddress": "0x9b844631b7279576330b9b822be79266696ff8c2",
    "enode": "enode://b2748268c31ebab8603058335bb4bed062e05b9ceaa3562f69868a01d1038a84136fc587fb913e1cb8ce821f1eb0bf9879e3249f18adcd39f1211a104ceb57a9@35.197.223.249:30303",
    "commissionRate": 1000,
    "bondedStake": 1e+22,
    "unbondingStake": 0,
    "unbondingShares": 0,
    "selfBondedStake": 1e+22,
    "selfUnbondingStake": 0,
    "selfUnbondingShares": 0,
    "selfUnbondingStakeLocked": 0,
    "liquidContract": "0xf4d9599afd90b5038b18e3b551bc21a97ed21c37",
    "liquidSupply": 0,
    "registrationBlock": 0,
    "totalSlashed": 0,
    "jailReleaseBlock": 0,
    "provableFaultCount": 0,
    "state": 0
  }

To replicate

  1. call aut validator list to return the list of validators.
  2. call aut validator info on one of the validators
  3. returned liquidContract value is the zero address
  4. repeat using a curl - actual liquidContract address is returned
cmjc commented 1 year ago

Bug Having registered and bonded to a validator, I now find aut validator info is also returning an incorrect liquidSupply, totalSlashed and registrationBlock value. Also, the selfUnbondingStakeLocked field is missing.

Expected behaviour The correct data object and values are returned.

aut version

$ aut --version
aut, version 0.3.0.dev1

Example

At this point the validator is registered, but has no bonded stake:

ubuntu@vps-c7c3e8c7:~/TEST/autcli$ aut validator info --validator 0xa418A886fbE5E08016d59AD90FC84fEe912D7A5B
{
  "treasury": "0xF47FDD88C8f6F80239E177386cC5AE3d6BCdEeEa",
  "node_address": "0xa418A886fbE5E08016d59AD90FC84fEe912D7A5B",
  "oracle_address": "0xFd91928d58Af4AFbD78C96821D3147ef1f517072",
  "enode": "enode://a3b821f89d8ea172421dedacdb00e76d8d6a929e4c5ff3c2b30ec84144a7405698ce30ba2ed482770ad2df94d050311b350c036d7f2cef3c9ef32be3f635d62e@51.89.151.55:30303",
  "commission_rate": 1000,
  "bonded_stake": 0,
  "unbonding_stake": 0,
  "unbonding_shares": 0,
  "self_bonded_stake": 0,
  "self_unbonding_stake": 0,
  "self_unbonding_shares": 0,
  "liquid_contract": "0x0000000000000000000000000000000000000000",
  "liquid_supply": 245822994132721560041932967934037774519317912847,
  "registration_block": 0,
  "total_slashed": 573883,
  "jail_release_block": 0,
  "provable_fault_count": 0,
  "state": 0
}

Now I bond 1 NTN from Alice (validator operator, self-bonded stake) and 0.5 NTN from Bob (delegator, delegated stake):

ubuntu@vps-c7c3e8c7:~/TEST/autcli$ aut validator bond --validator 0xa418A886fbE5E08016d59AD90FC84fEe912D7A5B 1 | aut tx sign - | aut tx send -
(consider using 'KEYFILEPWD' env var).
Enter passphrase (or CTRL-d to exit): 
0x2f80ce1539d8eb688b5ed953b20d1f72a0967abfcee3934f87c7b1d4b88a6b38
ubuntu@vps-c7c3e8c7:~/TEST/autcli$ nano .autrc
ubuntu@vps-c7c3e8c7:~/TEST/autcli$ aut validator bond --validator 0xa418A886fbE5E08016d59AD90FC84fEe912D7A5B 0.5 | aut tx sign - | aut tx send -                                                                                                                    
(consider using 'KEYFILEPWD' env var).
Enter passphrase (or CTRL-d to exit): 
0x59d05fd010ba67ac9fdd3c02874bc99fa0f8315a4d8db66f81de0bc6282600bb
ubuntu@vps-c7c3e8c7:~/TEST/autcli$ aut validator info --validator 0xa418A886fbE5E08016d59AD90FC84fEe912D7A5B                      
{
  "treasury": "0xF47FDD88C8f6F80239E177386cC5AE3d6BCdEeEa",
  "node_address": "0xa418A886fbE5E08016d59AD90FC84fEe912D7A5B",
  "oracle_address": "0xFd91928d58Af4AFbD78C96821D3147ef1f517072",
  "enode": "enode://a3b821f89d8ea172421dedacdb00e76d8d6a929e4c5ff3c2b30ec84144a7405698ce30ba2ed482770ad2df94d050311b350c036d7f2cef3c9ef32be3f635d62e@51.89.151.55:30303",
  "commission_rate": 1000,
  "bonded_stake": 0,
  "unbonding_stake": 0,
  "unbonding_shares": 0,
  "self_bonded_stake": 0,
  "self_unbonding_stake": 0,
  "self_unbonding_shares": 0,
  "liquid_contract": "0x0000000000000000000000000000000000000000",
  "liquid_supply": 245822994132721560041932967934037774519317912847,
  "registration_block": 0,
  "total_slashed": 573883,
  "jail_release_block": 0,
  "provable_fault_count": 0,
  "state": 0
}

After the staking transition has been applied, bonded_stake and self_bonded_stake values are updated correctly. The registration_block, liquid_supply and total_slashed values are incorrect. There should be selfUnbondingStakeLocked i.e. self_unbonding_stake_locked with a value of 0 before liquid_contract:

ubuntu@vps-c7c3e8c7:~/TEST/autcli$ aut validator info --validator 0xa418A886fbE5E08016d59AD90FC84fEe912D7A5B
{
  "treasury": "0xF47FDD88C8f6F80239E177386cC5AE3d6BCdEeEa",
  "node_address": "0xa418A886fbE5E08016d59AD90FC84fEe912D7A5B",
  "oracle_address": "0xFd91928d58Af4AFbD78C96821D3147ef1f517072",
  "enode": "enode://a3b821f89d8ea172421dedacdb00e76d8d6a929e4c5ff3c2b30ec84144a7405698ce30ba2ed482770ad2df94d050311b350c036d7f2cef3c9ef32be3f635d62e@51.89.151.55:30303",
  "commission_rate": 1000,
  "bonded_stake": 1500000000000000000,
  "unbonding_stake": 0,
  "unbonding_shares": 0,
  "self_bonded_stake": 1000000000000000000,
  "self_unbonding_stake": 0,
  "self_unbonding_shares": 0,
  "liquid_contract": "0x0000000000000000000000000000000000000000",
  "liquid_supply": 245822994132721560041932967934037774519317912847,
  "registration_block": 500000000000000000,
  "total_slashed": 573883,
  "jail_release_block": 0,
  "provable_fault_count": 0,
  "state": 0
}

A curl returns the correct result:

ubuntu@vps-c7c3e8c7:~/TEST/autcli$ curl --silent --location --request GET 'http://127.0.0.1:8545' --header 'Content-Type: application/json' --data-raw '{
                "jsonrpc":"2.0",
                "method":"aut_getValidator", "params":["0xa418A886fbE5E08016d59AD90FC84fEe912D7A5B"],
                "id":1}' | jq
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "treasury": "0xf47fdd88c8f6f80239e177386cc5ae3d6bcdeeea",
    "nodeAddress": "0xa418a886fbe5e08016d59ad90fc84fee912d7a5b",
    "oracleAddress": "0xfd91928d58af4afbd78c96821d3147ef1f517072",
    "enode": "enode://a3b821f89d8ea172421dedacdb00e76d8d6a929e4c5ff3c2b30ec84144a7405698ce30ba2ed482770ad2df94d050311b350c036d7f2cef3c9ef32be3f635d62e@51.89.151.55:30303",
    "commissionRate": 1000,
    "bondedStake": 1.5e+18,
    "unbondingStake": 0,
    "unbondingShares": 0,
    "selfBondedStake": 1e+18,
    "selfUnbondingStake": 0,
    "selfUnbondingShares": 0,
    "selfUnbondingStakeLocked": 0,
    "liquidContract": "0x2b0f159443599fbb6723cdb33d0db94f96b95d0f",
    "liquidSupply": 5e+17,
    "registrationBlock": 573883,
    "totalSlashed": 0,
    "jailReleaseBlock": 0,
    "provableFaultCount": 0,
    "state": 0
  }
}

I.e.:

field aut curl
"bonded_stake" 1500000000000000000 1.5e+18
"unbonding_stake" 0 0
"unbonding_shares" 0 0
"self_bonded_stake" 1000000000000000000 1e+18
"self_unbonding_stake" 0 0
"self_unbonding_shares" 0 0
"selfUnbondingStakeLocked" Missing 0
"liquid_contract" "0x0000000000000000000000000000000000000000" "0x2b0f159443599fbb6723cdb33d0db94f96b95d0f"
"liquid_supply" 245822994132721560041932967934037774519317912847 5e+17
"registration_block" 500000000000000000 573883
"total_slashed" 573883 0

In aut:

cmjc commented 11 months ago

@aiman I can confirm this is fixed with the dev2 patch:

% aut validator info --validator 0x13a21D4BcE7Dc097596327898c46963b85De9dAC
{
  "treasury": "0xF47FDD88C8f6F80239E177386cC5AE3d6BCdEeEa",
  "node_address": "0x13a21D4BcE7Dc097596327898c46963b85De9dAC",
  "oracle_address": "0x3967A8575B6D81c0C0f2840abf591E584F47fa1C",
  "enode": "enode://fc1330bccd700af3d91372b7a68145dd5f1b809737e71fca89542926755cb1d73feac132f8863628fc4af9560bde0e5ff6df24e61aff74dd9917b138c290f78c@51.89.151.55:30303",
  "commission_rate": 1000,
  "bonded_stake": 750000000000000000,
  "self_bonded_stake": 0,
  "liquid_contract": "0x0000000000000000000000000000000000000000",
  "liquid_supply": 750000000000000000,
  "registration_block": 0,
  "total_slashed": 0,
  "jail_release_block": 0,
  "provable_fault_count": 505848991113437799075886508572918351698200139580,
  "state": 0
}
aiman commented 11 months ago

Thanks, fixed in v0.3.0.dev2