EOSIO / eos

An open source smart contract platform
https://developers.eos.io/manuals/eos
MIT License
11.28k stars 3.76k forks source link

Why can't get correct transaction info by /v1/history/get_transaction #4551

Closed Michael2008S closed 6 years ago

Michael2008S commented 6 years ago

eos version: v1.0.8

nb@bctest /d/b/e/JungleTestnet-bct1eostest1> curl -i -X POST \
                                                -H "Content-Type:application/json" \
                                                -d \
                                             '{"id":"e4d0eee622561e57b99627b72cd3a603125e16df5efe0eff328261867457e119"}' \
                                              'http://127.0.0.1:8888/v1/history/get_transaction'
HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Connection: close
Content-Length: 183
Content-type: application/json
Server: WebSocket++/0.7.0

{"id":"e4d0eee622561e57b99627b72cd3a603125e16df5efe0eff328261867457e119","trx":null,"block_time":"2000-01-01T00:00:00.000","block_num":0,"last_irreversible_block":4743332,"traces":[]}⏎
nb@bctest /d/b/e/JungleTestnet-bct1eostest1> ./cleos.sh get transaction "e4d0eee622561e57b99627b72cd3a603125e16df5efe0eff328261867457e119"
{
  "id": "e4d0eee622561e57b99627b72cd3a603125e16df5efe0eff328261867457e119",
  "trx": null,
  "block_time": "2000-01-01T00:00:00.000",
  "block_num": 0,
  "last_irreversible_block": 4741695,
  "traces": []
}
dhaneshvb commented 6 years ago

Can you pls ensure that the transaction ID is valid?

Michael2008S commented 6 years ago

@dhaneshvb

I get the id in http://jungle.cryptolions.io/#tx:e4d0eee622561e57b99627b72cd3a603125e16df5efe0eff328261867457e119

Is it correct ?

Block: # 4580739
TXid: e4d0eee622561e57b99627b72cd3a603125e16df5efe0eff328261867457e119
Date: 2018-07-08T10:45:05
Action: eosio.token::transfer
From: michael
Info: michael>michaeltest
1.0000 EOS
test memo text
valanced commented 6 years ago

I used txid from https://eostracker.io/transactions/0c79ce779f7642498e20c6efc324b5796f2ebb072f9b55220798aea27201c884 and got the same problem. but in api reference: https://developers.eos.io/eosio-nodeos/reference#get_transaction-1 declared that the id must be int32 (obviously do not match this type)

valanced commented 6 years ago

when i try to:

curl --request POST \
  --url http://172.17.0.2:19001/v1/history/get_transaction \
  --header 'Cache-Control: no-cache' \
  --header 'Content-Type: application/json' \
  --header 'Postman-Token: 74553389-389b-4f66-b4f2-80b6ac5835ad' \
  --data '{"id": "0c79ce779f7642498e20c6efc324b5796f2ebb072f9b55220798aea27201c884"}'

in my case node returns different tx id:

{
    "id": "0ca5db3d334515267c72035a59ec2b4505c7066b2682c9690fe32b70f592cd2f",
    "trx": null,
    "block_time": "2018-07-09T14:01:58.500",
    "block_num": 4988069,
    "last_irreversible_block": 4996543,
    "traces": []
}

And if i try to get info by new ID i obtain this:

{
    "id": "0ca5db3d334515267c72035a59ec2b4505c7066b2682c9690fe32b70f592cd2f",
    "trx": {
        "receipt": {
            "status": "executed",
            "cpu_usage_us": 2448,
            "net_usage_words": 16,
            "trx": [
                1,
                {
                    "signatures": [
                        "SIG_K1_K8FpPFCgUSfCRNk7g5i7gdBXkbc88jxKVEFDoCpQ5Xg93Gfy9RERwTGpR3HWFAdZUnQf5xQBoJZB3rhS2FwCtiDbvYXVXj"
                    ],
                    "compression": "none",
                    "packed_context_free_data": "",
                    "packed_trx": "0f6b435b571bbcf93a1000000000010000000000ea3055000000004873bd3e0150c81001527da77e00000000a8ed32322050c81001527da77e50c81001527da77ed00700000000000004454f530000000000"
                }
            ]
        },
        "trx": {
            "expiration": "2018-07-09T14:02:55",
            "ref_block_num": 6999,
            "ref_block_prefix": 272300476,
            "max_net_usage_words": 0,
            "max_cpu_usage_ms": 0,
            "delay_sec": 0,
            "context_free_actions": [],
            "actions": [
                {
                    "account": "eosio",
                    "name": "buyram",
                    "authorization": [
                        {
                            "actor": "junruok12345",
                            "permission": "active"
                        }
                    ],
                    "data": {
                        "payer": "junruok12345",
                        "receiver": "junruok12345",
                        "quant": "0.2000 EOS"
                    },
                    "hex_data": "50c81001527da77e50c81001527da77ed00700000000000004454f5300000000"
                }
            ],
            "transaction_extensions": [],
            "signatures": [
                "SIG_K1_K8FpPFCgUSfCRNk7g5i7gdBXkbc88jxKVEFDoCpQ5Xg93Gfy9RERwTGpR3HWFAdZUnQf5xQBoJZB3rhS2FwCtiDbvYXVXj"
            ],
            "context_free_data": []
        }
    },
    "block_time": "2018-07-09T14:01:58.500",
    "block_num": 4988069,
    "last_irreversible_block": 4996711,
    "traces": [
        {
         //smth not relevant here
        }
    ]
}

looks like undefined behavior

Michael2008S commented 6 years ago

@Magestro what's your node version? And what's your command?

valanced commented 6 years ago

@Michael2008S Node version: 1.07 (at now i updating my node to 1.08v)

Request:

curl --request POST \
  --url http://172.17.0.2:19001/v1/history/get_transaction \
  --header 'Cache-Control: no-cache' \
  --header 'Content-Type: application/json' \
  --header 'Postman-Token: 74553389-389b-4f66-b4f2-80b6ac5835ad' \
  --data '{"id": "0c79ce779f7642498e20c6efc324b5796f2ebb072f9b55220798aea27201c884"}'

Response:

{
    "id": "0ca5db3d334515267c72035a59ec2b4505c7066b2682c9690fe32b70f592cd2f",
    "trx": null,
    "block_time": "2018-07-09T14:01:58.500",
    "block_num": 4988069,
    "last_irreversible_block": 5000743,
    "traces": []
}

UPD

The same problem with 1.08v

Michael2008S commented 6 years ago

@Magestro Ok,Thanks. I know the problem now.Maybe I should change my version to v1.0.7.

valanced commented 6 years ago

@Michael2008S i've git the problem like u. my way is not a solution, 'cause new id do not contain information what i looked for

Jeiwan commented 6 years ago

You need to enable history_plugin and set filter-on option: https://github.com/EOSIO/eos/issues/3887

valanced commented 6 years ago

@Jeiwan yeah thx, i already try it it work's only for recent transactions. should i rescan all blockchain to be able to get info about older transactions?

jgiszczak commented 6 years ago

@Magestro Yes, you need to replay your blockchain to populate the history plugin data for old transactions. Note that you will need to increase chain-state-db-size-mb = in config.ini to something larger than the default 1024. I suggest 4096.

valanced commented 6 years ago

@jgiszczak thank you! i already set it in 8192