Skip to content
This repository has been archived by the owner on Nov 30, 2021. It is now read-only.

Cannot get eth.getBlock for block 1 #306

Closed
ayeteng opened this issue May 19, 2020 · 5 comments · Fixed by #333
Closed

Cannot get eth.getBlock for block 1 #306

ayeteng opened this issue May 19, 2020 · 5 comments · Fixed by #333
Assignees

Comments

@ayeteng
Copy link

ayeteng commented May 19, 2020

System info: [Include Ethermint commit, operating system name, and other relevant details]

Steps to reproduce:

  1. get the current ethermint repo by
    git clone https://github.com/ChainSafe/ethermint.git
  2. run ethermint init and start the ethermint chain
    > cd ethermint
    > ./init.sh
    > emintcli rest-server --laddr "tcp://localhost:9545" --unlock-key mykey
  3. run geth to interact with chain
    geth attach http://localhost:9545
  4. check eth.getBlock function
    > eth.getBlock(1)

Expected behavior: I get this log by another eth chain.

> eth.getBlock(1)
{
  difficulty: 2,
  extraData: "0xd683010810846765746886676f312e3131856c696e75780000000000000000005f48ce95ea46b03cbdb1f48d27084957d660092274ed9d23bea1d29857651b0420ea69516be3fb07c7078335b611bb3c57c73dc82d1e598d3c26420ae2999f8f00",
  gasLimit: 4704588,
  gasUsed: 0,
  hash: "0xa6af78ee701f070467baf2dad3186ec66693d5d1b4187b529b878b0749f4ed2a",
  logsBloom: "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
  miner: "0x0000000000000000000000000000000000000000",
  mixHash: "0x0000000000000000000000000000000000000000000000000000000000000000",
  nonce: "0x0000000000000000",
  number: 1,
  parentHash: "0x80a8a8be19127c765d87f11cb2b28e450864568ac9d83eb41ecad0bf665673b6",
  receiptsRoot: "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
  sha3Uncles: "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
  size: 606,
  stateRoot: "0x139cbe946152ed9e78b77b5b943f600f8fa2425a373d172e2c30c67540fb4dda",
  timestamp: 1538019650,
  totalDifficulty: 3,
  transactions: [],
  transactionsRoot: "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
  uncles: []
}

Actual behavior: [What actually happened]

> eth.getBlock(1)
Error: internal error
	at web3.js:6347:37(47)
	at web3.js:5081:62(37)
	at <eval>:1:13(4)

Additional info: [Include gist of relevant config, logs, etc.]
instance: Geth/v1.9.8-stable-d62e9b28/linux-amd64/go1.13.4
instance: Ethermint/0.0.0+1f63ddf/linux/go1.14.2

@noot
Copy link
Contributor

noot commented May 19, 2020

may be related to #301 since eth.getBlock is a wrapper around eth_getBlockByNumber and eth_getBlockByHash

will look into this!

@noot noot changed the title Cannot get eth.getBlock Cannot get eth.getBlock for block 1 May 21, 2020
@ayeteng
Copy link
Author

ayeteng commented Jun 5, 2020

I got the Block information by eth.getBlock() function with #319 update. Thank you! But it seems like still required the extraData to form the proofOfAuthorityData. Can you check please?

> eth.getBlock(1)
{
  difficulty: 0,
  extraData: null,
  gasLimit: 4294967295,
  gasUsed: 0,
  hash: "0xe22514e8bbbd3f12e9cadd8289843b3c4bb068358c09f3e6d260b082154181ae",
  logsBloom: "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
  miner: "0x0000000000000000000000000000000000000000",
  nonce: null,
  number: 1,
  parentHash: "0x",
  sha3Uncles: null,
  size: 153,
  stateRoot: "0x",
  timestamp: 1591333452,
  totalDifficulty: 0,
  transactions: [],
  transactionsRoot: "0x",
  uncles: null
}
>

The expected behavior with extraData as below:

> eth.getBlock(1)
{
  difficulty: 2,
  extraData: "0xd683010810846765746886676f312e3131856c696e75780000000000000000005f48ce95ea46b03cbdb1f48d27084957d660092274ed9d23bea1d29857651b0420ea69516be3fb07c7078335b611bb3c57c73dc82d1e598d3c26420ae2999f8f00",
  gasLimit: 4704588,
  gasUsed: 0,
  hash: "0xa6af78ee701f070467baf2dad3186ec66693d5d1b4187b529b878b0749f4ed2a",
  logsBloom: "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
  miner: "0x0000000000000000000000000000000000000000",
  mixHash: "0x0000000000000000000000000000000000000000000000000000000000000000",
  nonce: "0x0000000000000000",
  number: 1,
  parentHash: "0x80a8a8be19127c765d87f11cb2b28e450864568ac9d83eb41ecad0bf665673b6",
  receiptsRoot: "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
  sha3Uncles: "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
  size: 606,
  stateRoot: "0x139cbe946152ed9e78b77b5b943f600f8fa2425a373d172e2c30c67540fb4dda",
  timestamp: 1538019650,
  totalDifficulty: 3,
  transactions: [],
  transactionsRoot: "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
  uncles: []
}

@ayeteng
Copy link
Author

ayeteng commented Jun 6, 2020

https://ethereum.stackexchange.com/questions/16202/what-does-the-extradata-field-of-a-block-represent
"extraData An optional free, but max. 32-byte long space to conserve smart things for ethernity."
so, looks like the extraData can be anything depending on the miner. If miner doesn't put data inside, can we just return a 0x0 instead of null?

@ayeteng
Copy link
Author

ayeteng commented Jun 17, 2020

@noot Sorry, I might miss leading the extraData.

The extraData of PoA is defined.

Clique extradata field, used to define PoA validators/sealers must match the following format:

First part: 32bytes vanity, meaning whatever you want here since it's expressed as an hex string (64 chars long as one byte is 2 chars), here in the example it's just zeros.

Second part: concatenated list of sealers/validators nodes addresses. Each address written as hex string without the "0x" prefix and must be 20 bytes long (40 chars long as one byte is 2 chars).

Third part: a 65 bytes signature suffix called proposer seal. It's used to identify the proposer of the new validator in a block. Given we talk here about the genesis file, this seal has no reason to be because no specific node proposed it, it's the base on which everyone agree before starting. So it must be filled with zeros (65 zeros).

https://ethereum.stackexchange.com/questions/66927/how-to-set-sealers-in-genesis-block-extradata-for-a-clique-poa-network

Not only return 0x0 in very first 32bytes but also need 2nd/3rd parts for POA.

@noot
Copy link
Contributor

noot commented Jun 17, 2020

@ayeteng since ethermint isn't POA, that isn't applicable here. I think leaving it as 0x0 makes the most sense

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants