How to resolve negative balances for mining reward transactions? [rosetta-cli@0.3.1 check]

Hi, our blockchain reward miners directly to their addresses by design; as a result, certain accounts contains only outgoing transactions to miners without prior incoming transactions.

Examples of such transactions in our blockchain:

In such cases, the rosetta-cli checks would definitely flagged a negative balance error.

It is not feasible to exempt these accounts in a json file as there are thousands of miners and we do not have a full list of them.

How do we continue the checks in such a situation; is there a flag in the cli which we can toggle to suppress the negative balances errors?

This is a great question @fluffy!

Our blockchain reward miners directly to their addresses by design; as a result, certain accounts contains only outgoing transactions to miners without prior incoming transactions.

This is one of the many reasons we opted to make Operations one-sided. I wrote about this decision on our website.

In a block reward transaction, you would only include a positive “reward” operation:

{
  "operations": [
    {
      "operation_identifier": {
        "index": 0
      },
      "type": "Reward",
      "status": "Success",
      "account": {
        "address": "{{ miner }}"
      },
      "amount": {
        "value": "1000000",
        "currency": {
          "symbol": "ZIL",
          "decimals": 12
        }
      }
    }
  ]
}

If there is no negative operation amount, the rosetta-cli does not attempt to deduct a balance from any account (which would trigger a negative account balance error). It considers this a “value creation transaction”.

There is NO requirement that the balance changes on any particular block must sum to zero. If this was the case, it would be impossible to represent block rewards (like this). We considered this early in the design process but dropped the idea for reasons like this.

The rosetta-cli would, in fact, not mark these sort of transfers as a negative balance error. There is no requirement that balance changes on any particular block must net to zero.

It is not feasible to exempt these accounts in a json file as there are thousands of miners and we do not have a full list of them.

If there is a “system-owned” sending address that “distributes” block rewards (that never has a “balance”), I’d recommend including this address in the Transaction with no Amount or populating the Operation.Metadata of the reward operation from the earlier example:

{
  "operations": [
    {
      "operation_identifier": {
        "index": 0
      },
      "type": "Reward",
      "status": "Success",
      "account": {
        "address": "{{ system address }}"
      }
    },
    {
      "operation_identifier": {
        "index": 1
      },
      "related_operations": [
        {
          "index": 0
        }
      ],
      "type": "Reward",
      "status": "Success",
      "account": {
        "address": "{{ reward address }}"
      },
      "amount": {
        "value": "1000000",
        "currency": {
          "symbol": "ZIL",
          "decimals": 12
        }
      }
    }
  ]
}

rosetta-cli Update

On a side note, check out the new v0.4.0 release of the rosetta-cli!

Thanks, @patrick.ogrady for the detailed explanations and suggestions!

I guess along the way we were misled by the requirement of signed balances together with historical lookups and thought that block balances must sum to zero. Coupled with the fact that a payment transaction in rosetta is split into sender and recipient further lead us to believe it is incorrect to specify a single sided operation in a Transaction.

I am glad this is cleared up!

Thanks again, will checkout v0.4.0 too!

1 Like