Ethereum Study Notes (i)

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

Related command analysis

    • Eth.blocknumber
      View the current block height.
    • Eth.getblock ()
      View block content based on height.
    • Eth.syncing
      Get the synchronization status, you can see the whole network the latest block high, prompting the user synchronization progress.

Block analysis

Genesis Block:

{difficulty:17179869184, Extradata: "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa", gaslimit:5000, gasused:0, hash: "0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3", LogsBloom: " 0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000 ", Miner:" 0x0000000000000000000000000000000000000000 ", Mixhash:"  0x0000000000000000000000000000000000000000000000000000000000000000 ", nonce:" 0x0000000000000042 ", number:0, Parenthash: "0x0000000000000000000000000000000000000000000000000000000000000", Receiptsroot:" 0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421 ", Sha3Uncles:" 0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347 ", size:540, Stateroot:"  0xd7f8974fb5ac78d9ac099b9ad5018bedc2ce0a72dad1827a1709da30580f0544 ", timestamp:0, totaldifficulty:17179869184, Transactions: [], Transactionsroot: "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", Uncles: []}

Block No. 410000 of the Ethereum main network:

{difficulty:1390302857940436, Extradata: "0x7563776f6e67", gaslimit:6708771, gasused:105000, hash: "0xa1085801441 42887e58cf074d4ea0be93b00c13ed1992d3897edb078fabe7118 ", Logsbloom:" 0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000 ", Miner:" 0x9435d50503aee35c8757ae4933f7a0ab56597805 ", Mixhash:"  0xfe8975ce7e272e88243ce9ec91d1a826fa5fe930d9e18de6a72ef57b4f9aa954 ", nonce:" 0xf0d4aef0039682a8 ", number:4100000, Parenthash: "0XD060E9516FC2A26AAB3728D7FAD2F2301D9822E6B2100EFF58A16ABD185881A1", ReceiptsRoot: "0xa36be6a4f6a8e9a63a6b90dfa174d5cc6e7662f0d05007f39ef8a14aab54da95 ", Sha3uncles:" 0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347 ", size:1095, StateRoot:" 0xf49e0946c05d675cafd607613b009a3121a7e9ed6ed1f614a0c05e3bf6bebea1 ", timestamp:1501511212, TotalDifficulty: 595854527970155343606, transactions: ["0x5728a5597f1dd7bb3e8843bfd6a8fe4156ae4605408d990c54dced5945e4a7af", " 0x902aa2582c63328fcca071296a389b55a1c84983f1a3553ef05b1a14b16bd913 "," 0x452169cbce264f8d30074d2ddcb8caca2ba7e7b4effdca26301696c6a242ea5f "," 0x9dee172d17a82354010ad18c9a7d32e49141b406d4802a6b0d5b25359809a1b3 "," 0xaa1b5f94f285a344d3e99f85529343daa3f72741752cad946a995e6544bd14ab "], Transactionsroot:" 0xe3eec697b2dcc74678edff5b022e65263c8428e47f11c25b9d4ba9d518632269 ", Uncles: []}
Key value
Difficulty Represents the difficulty level of the current chunk, which is calculated based on the difficulty level and timestamp of the previous block.
Extradata Additional data, byte array within 32 bytes
Gaslimit Current fuel consumption limit per block
Gasused The sum of the fuel used for all transactions in the current block
Hash Block hash, which can be understood as the index of this block in the entire blockchain
Logsbloom The journal Bloom Filter consists of indexed information (log address and log subject), which is included in each log entry, from the recipient of each transaction in the trade list
Miner Pack this block's miner's address.
Mixhash A mixed hash, calculated with a 256-bit hash associated with a random number (nonce), to prove that sufficient computation has been done for the current chunk
Nonce Random number, a 64-bit hash, and calculated mixed hash correlation, used to prove that enough computation has been done for the current chunk
Number Block number, equal to the number of immediate predecessors in the current chunk (the block number of the founding block is 0)
Parenthash Parent hash (no parent hash for Genesis Block, so Parenthash is 0x0000000000000000000000000000000000000000000000000000000000000000)
Receiptsroot Recipient dictionary root node hash: Keccak 256-bit hash of the recipient's Dictionary root node, in the recipient's Dictionary tree contains the recipient of all the transaction information in the chunk
Sha3uncles ????
Size Guessing the size of the block package
Stateroot State dictionary tree root node hash: Keccak 256-bit hash of the state dictionary tree root node, the transaction is packaged into the current chunk and the chunk is finalized to generate this value
Timestamp Timestamp, the Unix timestamp at the time the current chunk was initialized
Totaldifficulty ???
Transactions The transactions contained in block
Transactionsroot Trading Dictionary root node hash: Keccak 256-bit hash of the root node of the trading dictionary, in the Trading dictionary tree contains all the trading lists in the block
Uncles ????

It can be seen from the Genesis block to the present Ethereum block structure has not changed, the table is the Ethereum Yellow Book on the block data structure interpretation. Address of the Yellow Book

Key value
Difficulty Represents the difficulty level of the current chunk, which is calculated based on the difficulty level and timestamp of the previous block.
Extradata Additional data, byte array within 32 bytes
Gaslimit Current fuel consumption limit per block
Gasused The sum of the fuel used for all transactions in the current block
Hash Block hash, which can be understood as the index of this block in the entire blockchain
Logsbloom The journal Bloom Filter consists of indexed information (log address and log subject), which is included in each log entry, from the recipient of each transaction in the trade list
Miner Pack this block's miner's address.
Mixhash A mixed hash, calculated with a 256-bit hash associated with a random number (nonce), to prove that sufficient computation has been done for the current chunk
Nonce Random number, a 64-bit hash, and calculated mixed hash correlation, used to prove that enough computation has been done for the current chunk
Number Block number, equal to the number of immediate predecessors in the current chunk (the block number of the founding block is 0)
Parenthash Parent hash (no parent hash for Genesis Block, so Parenthash is 0x0000000000000000000000000000000000000000000000000000000000000000)
Receiptsroot Recipient dictionary root node hash: Keccak 256-bit hash of the recipient's Dictionary root node, in the recipient's Dictionary tree contains the recipient of all the transaction information in the chunk
Sha3uncles ????
Size Guessing the size of the block package
Stateroot State dictionary tree root node hash: Keccak 256-bit hash of the state dictionary tree root node, the transaction is packaged into the current chunk and the chunk is finalized to generate this value
Timestamp Timestamp, the Unix timestamp at the time the current chunk was initialized
Totaldifficulty ???
Transactions The transactions contained in block
Transactionsroot Trading Dictionary root node hash: Keccak 256-bit hash of the root node of the trading dictionary, in the Trading dictionary tree contains all the trading lists in the block
Uncles ????
    • Difficulty: Is the difficulty of the current block, the value is calculated based on the difficulty level and timestamp of the previous block. We recommend that you look at an article on how ethereum is calculating the difficulty. The specific calculation formula is as follows, interested friends can try to calculate a bit. ( Ethereum requires no block to be less difficult than the creation block )

Periodcount = block_num/100000
diff = (Parent_diff + (parent_diff/2048 * MAX (1-(Block_timestamp-parent_timestamp)/ten, -99)) + 2^ (Periodcount- 2)

    • Transactionsroot: In order to prevent data tampering, the merkletree of BTC used by ETH proves that the relevant technical content will be discussed separately.

Golang Data Structure Source code

Location: Core/types/block.go

Header represents a block header in the Ethereum blockchain.type header struct {parenthash common. Hash ' JSON: "Parenthash" Gencodec: "Required" ' Unclehash common. Hash ' JSON: "Sha3uncles" Gencodec: "Required" ' Coinbase common. Address ' JSON: ' Miner ' Gencodec: ' Required ' Root common. Hash ' JSON: "Stateroot" Gencodec: "Required" ' Txhash common. Hash ' JSON: "Transactionsroot" Gencodec: "Required" ' Receipthash common. Hash ' JSON: ' Receiptsroot ' gencodec: ' Required ' ' Bloom Bloom ' json: ' Logsbloom ' Gencodec: ' req Uired "' Difficulty *big. Int ' JSON: "Difficulty" GENCODEC: "Required" ' number *big. Int ' JSON: "Number" GENCODEC: "Required" ' Gaslimit *big. Int ' JSON: "Gaslimit" Gencodec: "Required" ' gasused *big. Int ' JSON: "gasused" Gencodec: "Required" ' time *big. Int ' JSON: "timestamp" GENCODEC: "Required" ' EXtra []byte ' JSON: "Extradata" Gencodec: "Required" ' mixdigest common. Hash ' JSON: "Mixhash" Gencodec: "Required" ' nonce blocknonce ' JSON: "Nonce" Gencodec: "req Uired "'}//block represents an entire block in the Ethereum blockchain.type block struct {header *header Uncl es []*header Transactions transactions//caches hash atomic. Value size atomic.    Value//Td is used by package core to store the total difficulty//of the chain and including the block. TD *big.    Int//These fields is used by package ETH to track//Inter-peer block relay. Receivedat time. Time Receivedfrom interface{}}
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.