Zilliqa / zq2

Zilliqa 2.0 code base
Apache License 2.0
10 stars 0 forks source link

Z2-Converter : GetTxBlock API doesnot return all the fields in response for the legacy blocks #1586

Open chetan-zilliqa opened 1 month ago

chetan-zilliqa commented 1 month ago

I used z2 converter and converted testnet persistence from ZQ1 to ZQ2. The MicroBlockInfos and other fields like MinerPubKey object is missing from the response.

curl --request POST \
  --url 'http://localhost:4201/?=' \
  --header 'Content-Type: application/json' \
  --data '{
    "id": "1",
    "jsonrpc": "2.0",
            "method": "GetTxBlock",
    "params": ["7325387"]
}'

ZQ2 response:

{
  "jsonrpc": "2.0",
  "id": "1",
  "result": {
    "header": {
      "Version": 0,
      "GasLimit": 0,
      "GasUsed": 0,
      "Rewards": 0,
      "TxnFees": 0,
      "PrevBlockHash": "6468c13e552b2fa08066595d7de342ac638a3e6ab63a897ae05bbc59f81fe134",
      "BlockNum": "7325387",
      "Timestamp": "1727867100537522",
      "MbInfoHash": "0000000000000000000000000000000000000000000000000000000000000000",
      "StateRootHash": "a515d38c163f672ec78ed784ac8e608e69164d3f498ed908014363c1edb3df31",
      "StateDeltaHash": "0000000000000000000000000000000000000000000000000000000000000000",
      "NumTxns": 0,
      "NumPages": 0,
      "NumMicroBlocks": 0,
      "MinerPubKey": "0x000000000000000000000000000000000000000000000000000000000000000000",
      "DsBlockNum": 73254
    },
    "body": {
      "HeaderSign": "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
      "BlockHash": "900a3443a0ff17dd5048ffa3b47baa51110c616bf8c925fec3aa90bf7b1cf777",
      "MicroBlockInfos": []
    }
  }
}
chetan-zilliqa commented 1 month ago

Adding @DrZoltanFazekas @JamesHinshelwood @bzawisto

JamesHinshelwood commented 1 month ago

@chetan-zilliqa Did you post the ZQ1 response twice? Both the responses look the same to me. :stuck_out_tongue:

chetan-zilliqa commented 1 month ago

haha. Yeah, here is the zq1 response

{
    "id": "1",
    "jsonrpc": "2.0",
    "result": {
        "body": {
            "BlockHash": "cfc9972754842cb3d94475c52c81d8caac6ed63073275c52b7a21af9799e9077",
            "HeaderSign": "2CFFD020EC434242F1FAC9662EBC93E8ADC391423D923EFB4E777BAC34E36D66C3074B7C5B039118B0D5287CE0BBD5DA1CE88B0C5DF52655A69FED1C49937CBF",
            "MicroBlockInfos": [
                {
                    "MicroBlockHash": "34faf1c98b03205613d5f5c1c8bc8bf8aaeb4db59e5f6a1f28116d01d379773b",
                    "MicroBlockShardId": 1,
                    "MicroBlockTxnRootHash": "0000000000000000000000000000000000000000000000000000000000000000"
                }
            ]
        },
        "header": {
            "BlockNum": "7325387",
            "DSBlockNum": "73250",
            "GasLimit": "200000",
            "GasUsed": "0",
            "MbInfoHash": "5689c607526f779f00eb71d3d6bc4eb10be5b529266351ad2a517714a3cbe70c",
            "MinerPubKey": "0x03E23726080A4B5FEC5E3F4E3DF215E9905A0A831BD39CBFB488E4234438F3F3E7",
            "NumMicroBlocks": 1,
            "NumPages": 0,
            "NumTxns": 0,
            "PrevBlockHash": "02a9bd2ba7b3677f3a92ae16b53e9cb51903265518ba08a662959ac75934f732",
            "Rewards": "0",
            "StateDeltaHash": "0000000000000000000000000000000000000000000000000000000000000000",
            "StateRootHash": "9c0b640c619ca6dab992b7f6c709bf4c6553441853e6616efc1bcb230605c849",
            "Timestamp": "1727867100537522",
            "TxnFees": "0",
            "Version": 1
        }
    }
}
chetan-zilliqa commented 1 week ago

Values that differ between ZQ2 and ZQ1:
  root['result']['body']['HeaderSign']:
    ZQ2 -> 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
    ZQ1 -> 0F2902579BD02FACE1778FDAAC4872000DD3C463A82405354CC342DABC64CD001D8DA143F0688A520E21E7382CEC7C366FA1D9F98C0B6B0F9A946CC4F67AA0B4
  root['result']['header']['MbInfoHash']:
    ZQ2 -> 0000000000000000000000000000000000000000000000000000000000000000
    ZQ1 -> 2f9dd0a266f5ef9a4294ee1f961b096e4af7f9da3cb878d88ee1e89a54ce8759
  root['result']['header']['NumMicroBlocks']:
    ZQ2 -> 0
    ZQ1 -> 4
  root['result']['header']['StateDeltaHash']:
    ZQ2 -> 0000000000000000000000000000000000000000000000000000000000000000
    ZQ1 -> 4675069ff186f06d1af45a42bf65c1fe132612af6d8070b5cda8d30b0fad5bea
  root['result']['header']['StateRootHash']:
    ZQ2 -> e8e3b27a5a9629bf026556477750c888f763212b6adddb94234d7ac2f6135efb
    ZQ1 -> 3a600ca11a0afb3ec7cbd3467e4d7d65ab7e6ba9514bf53e9d549e207cf07e6d
  root['result']['header']['TxnFees']:
    ZQ2 -> 0
    ZQ1 -> 6102000035136

So, we know that we don't have microblocks and microblock hashes in zq2 so we will completely remove those keys from the responses. But not sure about the other keys.

1) TxnFees 2) StateRootHash 3) StateDeltaHash 4) HeaderSign

cc @JamesHinshelwood @DrZoltanFazekas @bzawisto

maxconway commented 1 week ago

So, from checking the code:

JamesHinshelwood commented 5 days ago

Lets accept the mismatch in stateRootHash. The state is stored differently in ZQ1 vs ZQ2 and we accept the breakage there.

chetan-zilliqa commented 4 days ago

@chetan-zilliqa or @bzawisto Need to check below point raised by @maxconway Should TxnFees be taken from the gas_used field of the block?