harmony icon indicating copy to clipboard operation
harmony copied to clipboard

Regarding the latest chain headers response format change

Open gupadhyaya opened this issue 3 years ago • 4 comments

I wanted to give a heads-up on the upcoming change to latest chain headers rpc response format change. The change is currently deployed to testnet and will soon be pushed to mainnet. This is required to make ethereum tooling compatible (e.g., chainlink). I am aware that many validator tools rely on this, hence asking if there any concerns in updating your tooling.

Before:

./hmy -n https://api.s0.t.hmny.io blockchain latest-headers
{
  "id": "0",
  "jsonrpc": "2.0",
  "result": {
    "beacon-chain-header": {
      "block-header-hash": "0x3db1639202e5333bac1e635796f307ebc8ae4a9d7791f89624de768823123d70",
      "block-number": 11711625,
      "epoch": 530,
      "shard-id": 0,
      "view-id": 11711962
    },
    "shard-chain-header": {
      "block-header-hash": "0x3db1639202e5333bac1e635796f307ebc8ae4a9d7791f89624de768823123d70",
      "block-number": 11711625,
      "epoch": 530,
      "shard-id": 0,
      "view-id": 11711962
    }
  }
}

After:

./hmy -n https://api.s0.b.hmny.io blockchain latest-headers
{
  "id": "0",
  "jsonrpc": "2.0",
  "result": {
    "beacon-chain-header": {
      "difficulty": "0x0",
      "epoch": 73679,
      "extraData": "0x",
      "gasLimit": "0x4c4b400",
      "gasUsed": "0x0",
      "hash": "0xec767a28f8002c0d30b3198010924f88096fd213c2b4831a8809ca0492528282",
      "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
      "miner": "0x3f6e680ec5456f540a833e77df4c8ed20a20f274",
      "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "nonce": "0x0000000000000000",
      "number": "0x7f3832",
      "parentHash": "0x52a577e98dd73f0cc186d5a423e6d5e7d8c26b74986b54106790180a3588a860",
      "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
      "sha3Uncles": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "shardID": 0,
      "stateRoot": "0x1808695162c90c02743aa47cea077ab7977275e8a4b3993ae2a6fa6bc445dcb3",
      "timestamp": "0x6076178f",
      "transactionsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
      "viewID": 8337804
    },
    "shard-chain-header": {
      "difficulty": "0x0",
      "epoch": 73679,
      "extraData": "0x",
      "gasLimit": "0x4c4b400",
      "gasUsed": "0x0",
      "hash": "0xec767a28f8002c0d30b3198010924f88096fd213c2b4831a8809ca0492528282",
      "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
      "miner": "0x3f6e680ec5456f540a833e77df4c8ed20a20f274",
      "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "nonce": "0x0000000000000000",
      "number": "0x7f3832",
      "parentHash": "0x52a577e98dd73f0cc186d5a423e6d5e7d8c26b74986b54106790180a3588a860",
      "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
      "sha3Uncles": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "shardID": 0,
      "stateRoot": "0x1808695162c90c02743aa47cea077ab7977275e8a4b3993ae2a6fa6bc445dcb3",
      "timestamp": "0x6076178f",
      "transactionsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
      "viewID": 8337804
    }
  }
}

Also the rpcs impacted are:

curl --location --request POST 'https://api.s0.b.hmny.io' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "hmyv2_getLatestChainHeaders",
    "params": []
}'

and

curl --location --request POST 'https://rpc.s0.b.hmny.io' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "hmy_getLatestChainHeaders",
    "params": []
}'

Also, the newBlockHeaders subscription:

web3.eth
  .subscribe("newBlockHeaders", function (error, result) {
    if (!error) {
        console.log(result);
      return;
    }

    console.error(error);
  })
  .on("connected", function (subscriptionId) {
    console.log(subscriptionId);
  })
  .on("data", function (blockHeader) {
      console.log(blockHeader);
  })
  .on("error", console.error);

PRs responsible for this change: https://github.com/harmony-one/harmony/pull/3655, https://github.com/harmony-one/harmony/pull/3658, and https://github.com/harmony-one/harmony/pull/3659

gupadhyaya avatar Apr 13 '21 22:04 gupadhyaya

@gupadhyaya can you see if #3662 could be related to that change ? cc @mirrormirage0

sophoah avatar Apr 14 '21 11:04 sophoah

@gupadhyaya , is this change only impact RPC hmyv2_getLatestChainHeaders? how about the old hmy_getLatestChainHeaders api?

LeoHChen avatar Apr 14 '21 16:04 LeoHChen

@gupadhyaya , is this change only impact RPC hmyv2_getLatestChainHeaders? how about the old hmy_getLatestChainHeaders api?

yes. updated.

gupadhyaya avatar Apr 14 '21 18:04 gupadhyaya

is this issue fixed now? we can close if fixed.

rlan35 avatar Aug 18 '21 18:08 rlan35