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

Problem: Complete redelgation amount may be null #684

Open
mr-kenikh opened this issue Dec 5, 2021 · 3 comments
Open

Problem: Complete redelgation amount may be null #684

mr-kenikh opened this issue Dec 5, 2021 · 3 comments

Comments

@mr-kenikh
Copy link

Tendermint Block Results API may return null amount for complete_redelegation event.

Problem with null amount found in block №3366204:

curl -s "https://mainnet.crypto.org:26657/block_results?height=3366204" | jq '.result.end_block_events[] | select(.type=="complete_redelegation") | .attributes[] | select(.key=="YW1vdW50") | .value'
"MTAyOTE4NjAzOGJhc2Vjcm8="
"MTE1MDAwMDAwMDAwMGJhc2Vjcm8="
null
null
@JayT106
Copy link
Contributor

JayT106 commented Dec 6, 2021

Looks like there is an error happening during the redelegation event,
https://github.com/cosmos/cosmos-sdk/blob/3458f64f0aeb68796e56dd334c04b5e066ebf089/x/staking/keeper/val_state_change.go#L82

possibly due to this error,
https://github.com/cosmos/cosmos-sdk/blob/3458f64f0aeb68796e56dd334c04b5e066ebf089/x/staking/keeper/delegation.go#L886
It is a silent fail.

if that possible for some operation issue to cause this error? Or just error in purpose, meaning no mature term can do redelegation.

@tomtau tomtau changed the title Complete redelgation amount may be null Problem: Complete redelgation amount may be null Dec 7, 2021
@mr-kenikh
Copy link
Author

mr-kenikh commented Dec 7, 2021

@JayT106

Decoded end block events:

[
  {
    "type": "complete_unbonding",
    "attributes": [
      { "key": "amount", "value": "100000000basecro", "index": true },
      {
        "key": "validator",
        "value": "crocncl1t322hc258gc7dm005xfq0tsjqp9egujuh5tsnu",
        "index": true
      },
      {
        "key": "delegator",
        "value": "cro1t322hc258gc7dm005xfq0tsjqp9eguju5ege3q",
        "index": true
      }
    ]
  },
  {
    "type": "complete_redelegation",
    "attributes": [
      { "key": "amount", "value": "1029186038basecro", "index": true },
      {
        "key": "delegator",
        "value": "cro1pnrv0hnqrd2ht2nect26yq7vpy30wlf3m2jqw0",
        "index": true
      },
      {
        "key": "source_validator",
        "value": "crocncl1t322hc258gc7dm005xfq0tsjqp9egujuh5tsnu",
        "index": true
      },
      {
        "key": "destination_validator",
        "value": "crocncl1n77qdxwpfhg3j7z0tpt9q4uq0cwjne64v84ks2",
        "index": true
      }
    ]
  },
  {
    "type": "complete_redelegation",
    "attributes": [
      { "key": "amount", "value": "1150000000000basecro", "index": true },
      {
        "key": "delegator",
        "value": "cro12xarkpk2f0psk3j6c49ek6p4hcc7kz7wf6qqtn",
        "index": true
      },
      {
        "key": "source_validator",
        "value": "crocncl1t322hc258gc7dm005xfq0tsjqp9egujuh5tsnu",
        "index": true
      },
      {
        "key": "destination_validator",
        "value": "crocncl1j47t9xajph8fxe87mx9n6yjz05u64vr77mxwkd",
        "index": true
      }
    ]
  },
  {
    "type": "complete_redelegation",
    "attributes": [
      { "key": "amount", "value": "", "index": true },
      {
        "key": "delegator",
        "value": "cro12xarkpk2f0psk3j6c49ek6p4hcc7kz7wf6qqtn",
        "index": true
      },
      {
        "key": "source_validator",
        "value": "crocncl1t322hc258gc7dm005xfq0tsjqp9egujuh5tsnu",
        "index": true
      },
      {
        "key": "destination_validator",
        "value": "crocncl1j47t9xajph8fxe87mx9n6yjz05u64vr77mxwkd",
        "index": true
      }
    ]
  },
  {
    "type": "complete_redelegation",
    "attributes": [
      { "key": "amount", "value": "", "index": true },
      {
        "key": "delegator",
        "value": "cro12xarkpk2f0psk3j6c49ek6p4hcc7kz7wf6qqtn",
        "index": true
      },
      {
        "key": "source_validator",
        "value": "crocncl1t322hc258gc7dm005xfq0tsjqp9egujuh5tsnu",
        "index": true
      },
      {
        "key": "destination_validator",
        "value": "crocncl1j47t9xajph8fxe87mx9n6yjz05u64vr77mxwkd",
        "index": true
      }
    ]
  }
]

Target account: cro12xarkpk2f0psk3j6c49ek6p4hcc7kz7wf6qqtn
Target validator: crocncl1t322hc258gc7dm005xfq0tsjqp9egujuh5tsnu

  1. Height 2,974,411 (28 Oct 2021 14:40:29 GMT):
    Validator jailed for reason dip below the min self bond and start unbonding

  2. 04FB14F9BC5FD6EEF00C585C9AC2FF5BD50E0E1D61C9978EF06CD4950F098CEC:
    Account redelegate 500 CRO from this validator to new one.
    Redelegate completion 28 Oct 2021 14:40:29 GMT + 28 days = 25 Nov 2021 14:40:29 GMT.

  3. 5A39418198F01D2CC8AB563E388579A1084C84560C09623E89304A0C284BC9AB:
    Account redelegate 6000 CRO from this validator to new one.
    Redelegate completion 28 Oct 2021 14:40:29 GMT + 28 days = 25 Nov 2021 14:40:29 GMT.

  4. 1F675434857E7F027D2A05C8BAB811A3FADD307A5240451812ECFC13245D8A45:
    Account redelegate 5000 CRO from this validator to new one.
    Redelegate completion 28 Oct 2021 14:40:29 GMT + 28 days = 25 Nov 2021 14:40:29 GMT.

Thus, total 11500 CRO for delegatorAddress, valSrcAddr and valDstAddr with same completion time, what has been emitted in one event 1150000000000basecro (index: 2).

And it doesn't look like an error anymore, but the last two events probably shouldn't have emitted?

@JayT106
Copy link
Contributor

JayT106 commented Dec 8, 2021

I see, thanks for the context.
So the redelegation at index 2 actually combined 3 operations in the end block event. And I agree with you, the last 2 events should be redundant.

It should be the same issue in the SDK
cosmos/cosmos-sdk#10216

The code patch is in the mainline branch (SDK v0.45) but not sure when will be released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants
@yihuang @tomtau @mr-kenikh @JayT106 @leejw51crypto and others