multiversx / mx-chain-go

⚡ The official implementation of the MultiversX blockchain protocol, written in golang.

Home Page:https://multiversx.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug]: `claimRewards` to self and `reDelegateRewards` afterwards

silvestrst-crypto opened this issue · comments

Contact Details

No response

Description

It is possible for a delegator to submit claimRewards to "self". It seems like that it might be clearing the UnClaimedRewards in the node, and messing with the reDelegateRewards.

Node version

No response

Host machine

No response

Steps to reproduce

  1. Ensure that there are claimable rewards with some delegation contract.

  2. Create self claimRewards like in this tx.

  3. Create reDelegateRewards with the delegation contract that has accumulated rewards.

Expect the following error:
delegate value must be higher than 0

Relevant code snippet(HEAD at 69d5f59):
vm/systemSmartContracts/delegation.go:

...
  if delegator.UnClaimedRewards.Cmp(zero) <= 0 {
    d.eei.AddReturnMessage("delegate value must be higher than 0")
    return vmcommon.UserError
  }
...

On which network is the bug manifesting itself?

Mainnet

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Hello
If you send a self transaction with the data field claimRewards the protocol will treat this transaction like a move balance and will be a transfer transaction with a value of zero to self.

This transaction will not reach the Metachain and there will be no code from delegation.go file that is executed.

As @miiu96 mentioned, the claimRewards to self is just a simple transfer transaction (0 value) with some data field. It will not execute any claimRewards call as the user account (receiver) does not have a callable "claimRewards" endpoint.

I am closing this issue. If there is anything else that needs to be clarified you can open a question.