tronprotocol / java-tron

Java implementation of the Tron whitepaper
GNU Lesser General Public License v3.0
3.71k stars 1.39k forks source link

Question about multiple ret in transactions #5987

Open bbaktaeho opened 1 week ago

bbaktaeho commented 1 week ago

I have a question about transaction ret. In the normal case, the size of ret was 1. However, cases where this was not the case were found, and the results were also strange.

Here are two transaction examples:

First transactions:

{
  "ret": [
    {},
    {}
  ],
  "signature": [
    "744af932ea582657fb14bde2a8732d7e5e383446283788e18482a5d23547b87b40fab2a11c7714fd5a035d8560974f6dc743e94f6b0e3b99b770a796b89b476201"
  ],
  "txID": "39bed0802db9f1b3a202709ae904e23457f6058ded46c9dddbd2e373d322bfc8",
  "raw_data": {
    "contract": [
      {
        "parameter": {
          "value": {
            "amount": 13481144,
            "owner_address": "4146e2a8df08481447d2a935df71b6f7d5eda427d1",
            "to_address": "41546f0925b8dd9076382a0e61bddc24f15bd67b35"
          },
          "type_url": "type.googleapis.com/protocol.TransferContract"
        },
        "type": "TransferContract"
      }
    ],
    "ref_block_bytes": "f418",
    "ref_block_hash": "5c6982ea74578e8a",
    "expiration": 1533230781000,
    "timestamp": 1533230723866
  },
  "raw_data_hex": "0a02f41822085c6982ea74578e8a40c8a4b4ddcf2c5a68080112640a2d747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e73666572436f6e747261637412330a154146e2a8df08481447d2a935df71b6f7d5eda427d1121541546f0925b8dd9076382a0e61bddc24f15bd67b3518b8e9b606709ae6b0ddcf2c"
}

The result of ret is an empty object. I am curious as to why these results occur.

Second transactions:

{
  "ret": [
    {
      "contractRet": "SUCCESS"
    },
    {
      "unfreeze_amount": 1000000000
    }
  ],
  "signature": [
    "4772a6c0c0acb8c63690c6328b8b717f7020ab4b4265e53eefb814f385b5802f1473f3c79d09b30be65de7c29a2117280902889e45acd14f4f3d68354e3a404a01"
  ],
  "txID": "f43a9591f31c14c8853f32d0d07e019fa666a20f28754b064166331a3034b2e2",
  "raw_data": {
    "contract": [
      {
        "parameter": {
          "value": {
            "data": "5439a565",
            "owner_address": "41c05142fd1ca1e03688a43585096866ae658f2cb2",
            "contract_address": "41aac7dbcfc71587b2aa689f0b0b89aab5a7fc2bb8",
            "call_value": 9217917153
          },
          "type_url": "type.googleapis.com/protocol.TriggerSmartContract"
        },
        "type": "TriggerSmartContract"
      }
    ],
    "ref_block_bytes": "d62c",
    "ref_block_hash": "85f7851d5c748144",
    "expiration": 1561251255587,
    "fee_limit": 10000000,
    "timestamp": 1561229655307
  },
  "raw_data_hex": "0a02d62c220885f7851d5c74814440a3aace8eb82d5a73081f126f0a31747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e54726967676572536d617274436f6e7472616374123a0a1541c05142fd1ca1e03688a43585096866ae658f2cb2121541aac7dbcfc71587b2aa689f0b0b89aab5a7fc2bb818e181b9ab2222045439a565708bfaa784b82d900180ade204"
}

// transactionInfo
{
  "id": "f43a9591f31c14c8853f32d0d07e019fa666a20f28754b064166331a3034b2e2",
  "fee": 1670,
  "blockNumber": 10344002,
  "blockTimeStamp": 1561229664000,
  "contractResult": [
    ""
  ],
  "contract_address": "41aac7dbcfc71587b2aa689f0b0b89aab5a7fc2bb8",
  "receipt": {
    "energy_fee": 1670,
    "energy_usage_total": 167,
    "net_usage": 285,
    "result": "SUCCESS"
  }
}

This transaction has a result value. I'm curious why this responds with two result values, and why the unfreeze_amount value can't be checked in transactionInfo .

Leopoldo2209 commented 1 week ago

Tenho uma pergunta sobre transaction ret. No caso normal, o tamanho de ret era 1. No entanto, foram encontrados casos em que isso não era o caso, e os resultados também foram estranhos.

Aqui estão dois exemplos de transações:

Primeiras transações:

{
  "ret": [
    {},
    {}
  ],
  "signature": [
    "744af932ea582657fb14bde2a8732d7e5e383446283788e18482a5d23547b87b40fab2a11c7714fd5a035d8560974f6dc743e94f6b0e3b99b770a796b89b476201"
  ],
  "txID": "39bed0802db9f1b3a202709ae904e23457f6058ded46c9dddbd2e373d322bfc8",
  "raw_data": {
    "contract": [
      {
        "parameter": {
          "value": {
            "amount": 13481144,
            "owner_address": "4146e2a8df08481447d2a935df71b6f7d5eda427d1",
            "to_address": "41546f0925b8dd9076382a0e61bddc24f15bd67b35"
          },
          "type_url": "type.googleapis.com/protocol.TransferContract"
        },
        "type": "TransferContract"
      }
    ],
    "ref_block_bytes": "f418",
    "ref_block_hash": "5c6982ea74578e8a",
    "expiration": 1533230781000,
    "timestamp": 1533230723866
  },
  "raw_data_hex": "0a02f41822085c6982ea74578e8a40c8a4b4ddcf2c5a68080112640a2d747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e73666572436f6e747261637412330a154146e2a8df08481447d2a935df71b6f7d5eda427d1121541546f0925b8dd9076382a0e61bddc24f15bd67b3518b8e9b606709ae6b0ddcf2c"
}

O resultado de ret é um objeto vazio. Estou curioso para saber por que esses resultados ocorrem.

Segundas transações:

{
  "ret": [
    {
      "contractRet": "SUCCESS"
    },
    {
      "unfreeze_amount": 1000000000
    }
  ],
  "signature": [
    "4772a6c0c0acb8c63690c6328b8b717f7020ab4b4265e53eefb814f385b5802f1473f3c79d09b30be65de7c29a2117280902889e45acd14f4f3d68354e3a404a01"
  ],
  "txID": "f43a9591f31c14c8853f32d0d07e019fa666a20f28754b064166331a3034b2e2",
  "raw_data": {
    "contract": [
      {
        "parameter": {
          "value": {
            "data": "5439a565",
            "owner_address": "41c05142fd1ca1e03688a43585096866ae658f2cb2",
            "contract_address": "41aac7dbcfc71587b2aa689f0b0b89aab5a7fc2bb8",
            "call_value": 9217917153
          },
          "type_url": "type.googleapis.com/protocol.TriggerSmartContract"
        },
        "type": "TriggerSmartContract"
      }
    ],
    "ref_block_bytes": "d62c",
    "ref_block_hash": "85f7851d5c748144",
    "expiration": 1561251255587,
    "fee_limit": 10000000,
    "timestamp": 1561229655307
  },
  "raw_data_hex": "0a02d62c220885f7851d5c74814440a3aace8eb82d5a73081f126f0a31747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e54726967676572536d617274436f6e7472616374123a0a1541c05142fd1ca1e03688a43585096866ae658f2cb2121541aac7dbcfc71587b2aa689f0b0b89aab5a7fc2bb818e181b9ab2222045439a565708bfaa784b82d900180ade204"
}

// transactionInfo
{
  "id": "f43a9591f31c14c8853f32d0d07e019fa666a20f28754b064166331a3034b2e2",
  "fee": 1670,
  "blockNumber": 10344002,
  "blockTimeStamp": 1561229664000,
  "contractResult": [
    ""
  ],
  "contract_address": "41aac7dbcfc71587b2aa689f0b0b89aab5a7fc2bb8",
  "receipt": {
    "energy_fee": 1670,
    "energy_usage_total": 167,
    "net_usage": 285,
    "result": "SUCCESS"
  }
}

Esta transação tem um valor de resultado. Estou curioso para saber por que isso responde com dois valores de resultado e por que o valor unfreeze_amount não pode ser verificado em transactionInfo . { "ret": [ {}, {} ], "signature": [ "744af932ea582657fb14bde2a8732d7e5e383446283788e18482a5d23547b87b40fab2a11c7714fd5a035d8560974f6dc743e94f6b0e3b99b770a796b89b476201" ], "txID": "39bed0802db9f1b3a202709ae904e23457f6058ded46c9dddbd2e373d322bfc8", "raw_data": { "contract": [ { "parameter": { "value": { "amount": 13481144, "owner_address": "4146e2a8df08481447d2a935df71b6f7d5eda427d1", "to_address": "41546f0925b8dd9076382a0e61bddc24f15bd67b35" }, "type_url": "type.googleapis.com/protocol.TransferContract" }, "type": "TransferContract" } ], "ref_block_bytes": "f418", "ref_block_hash": "5c6982ea74578e8a", "expiration": 1533230781000, "timestamp": 1533230723866 }, "raw_data_hex": "0a02f41822085c6982ea74578e8a40c8a4b4ddcf2c5a68080112640a2d747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e73666572436f6e747261637412330a154146e2a8df08481447d2a935df71b6f7d5eda427d1121541546f0925b8dd9076382a0e61bddc24f15bd67b3518b8e9b606709ae6b0ddcf2c" }

abn2357 commented 1 week ago

It seems 'multi ret' is due to multi internal calls, any tron dev can confirm my idea?

ferdinand026 commented 1 week ago

As far as I know there can be multiple "contract" by design, so there can be multiple return results, so the type of these two fields are both array. But in fact there is only one "contract" in a transaction now, so there is a return result. As for why these transaction examples return two results, they were triggered a long time ago and the code has also been upgraded many times, so I do not know and maybe it's hard to know the reason.