streamingfast / substreams-erc20-balance-changes

Apache License 2.0
6 stars 2 forks source link

Negative balances on ERC20 balance changes #2

Closed DenisCarriere closed 11 months ago

DenisCarriere commented 11 months ago

Detected some negative balances which shouldn't be allowed since balanceOf should be UInt256

Substreams CLI

eth-substreams run https://github.com/streamingfast/substreams-erc20-balance-changes/releases/download/v1.1.0/erc20-balance-changes-v1.1.0.spkg \
  graph_out -s 6502350 -t 6502351

Data with negative balances

{"chain":"eth","block_number":6646447,"timestamp":"2018-11-05 06:33:57.000","contract":"ae8c1da747469ad5e7d9e5de14e206d301f3ea9e","owner":"74c4f45f9ce7831b1d1abd60b48a98281d8c58cc","new_balance":"-38538117462162835672581086349630566355124539066783356789276974351613114251535","old_balance":"-38538117462162835672581086349630566355124539066783356789276974351613114241535"}
{"chain":"eth","block_number":6646457,"timestamp":"2018-11-05 06:36:17.000","contract":"ae8c1da747469ad5e7d9e5de14e206d301f3ea9e","owner":"74c4f45f9ce7831b1d1abd60b48a98281d8c58cc","new_balance":"-38538117462162835672581086349630566355124539066783356789276974351613188999009","old_balance":"-38538117462162835672581086349630566355124539066783356789276974351613114251535"}
{"chain":"eth","block_number":6646457,"timestamp":"2018-11-05 06:36:17.000","contract":"ae8c1da747469ad5e7d9e5de14e206d301f3ea9e","owner":"74c4f45f9ce7831b1d1abd60b48a98281d8c58cc","new_balance":"-38538117462162835672581086349630566355124539066783356789973944041613188999009","old_balance":"-38538117462162835672581086349630566355124539066783356789276974351613188999009"}
{"chain":"eth","block_number":6647177,"timestamp":"2018-11-05 09:20:36.000","contract":"ae8c1da747469ad5e7d9e5de14e206d301f3ea9e","owner":"74c4f45f9ce7831b1d1abd60b48a98281d8c58cc","new_balance":"-38538117462162835672581086349630566355124539166783356789973944041613188999009","old_balance":"-38538117462162835672581086349630566355124539066783356789973944041613188999009"}
{"chain":"eth","block_number":5345221,"timestamp":"2018-03-29 21:37:42.000","contract":"0081a92d2dd3eabf8d0ca6b75f21afa988ff613f","owner":"0081a92d2dd3eabf8d0ca6b75f21afa988ff613f","new_balance":"-67604","old_balance":"-50104"}
{"chain":"eth","block_number":6502350,"timestamp":"2018-10-12 17:04:36.000","contract":"af47ebbd460f21c2b3262726572ca8812d7143b0","owner":"c3adeb1d8fb07d688197c01da0d5ef557f5a2dfa","new_balance":"-57896044618658097711785492504343953926634992332820282019728792003956564819968","old_balance":"-57896044618658097711785492504343953926634992332820282019728792003956564819963"}
{"chain":"eth","block_number":6503159,"timestamp":"2018-10-12 20:11:30.000","contract":"af47ebbd460f21c2b3262726572ca8812d7143b0","owner":"b39a559ee400ed11a985d18168f2a8f10fc901f3","new_balance":"-57896044618658097711785492504343953926634992332820282019728792003956564819968","old_balance":"-57896044618658097711785492504343953926634992332820282019728792003956564819963"}

negative_balances.json

EntityChanges data

substreams-data.json

{
        "entity": "BalanceChange",
        "id": "af47ebbd460f21c2b3262726572ca8812d7143b0:c3adeb1d8fb07d688197c01da0d5ef557f5a2dfa:aceba8fc32409b896d31b85c7944fff53f1822699b065d84ffec03f983975442",
        "operation": "OPERATION_CREATE",
        "fields": [
          {
            "name": "callIndex",
            "newValue": {
              "bigint": "1"
            }
          },
          {
            "name": "transaction",
            "newValue": {
              "string": "aceba8fc32409b896d31b85c7944fff53f1822699b065d84ffec03f983975442"
            }
          },
          {
            "name": "changeType",
            "newValue": {
              "int32": 1
            }
          },
          {
            "name": "storageKey",
            "newValue": {
              "string": "50a7e0ba54cd2a398f23c8c99c68976a601f94ba359ce10a341ca34195ac2f72"
            }
          },
          {
            "name": "owner",
            "newValue": {
              "string": "c3adeb1d8fb07d688197c01da0d5ef557f5a2dfa"
            }
          },
          {
            "name": "newBalance",
            "newValue": {
              "string": "-57896044618658097711785492504343953926634992332820282019728792003956564819968"
            }
          },
          {
            "name": "oldBalance",
            "newValue": {
              "string": "-57896044618658097711785492504343953926634992332820282019728792003956564819963"
            }
          },
          {
            "name": "contract",
            "newValue": {
              "string": "af47ebbd460f21c2b3262726572ca8812d7143b0"
            }
          },
          {
            "name": "transferValue",
            "newValue": {
              "string": "5"
            }
          }
        ]
      },
colindickson commented 11 months ago

@DenisCarriere I see now, likely because the graph_out module is taking in map_balance_changes as input instead of map_valid_balance_changes. Will test out this theory now

colindickson commented 11 months ago

perhaps not, since the graph_out module is filtering out those it considers invalid.

colindickson commented 11 months ago

should be fixed in v1.2.0