이더리움 - Block

choko's avatar
Jun 29, 2024
이더리움 - Block
 
 
 
 
https://ethereum.stackexchange.com/questions/268/ethereum-block-architecture

Block 구조

type Block struct { header *Header uncles []*Header transactions Transactions //실제 거래데이터 withdrawals Withdrawals //caches : 실제 블록데이터로 저장되지 않고 생겼다가 사라짐. hast atomic.Value size atomic.Value // These fields are used by package eth to track // inter-peer block rely를 할 때만 사용. ReceovedAt time.Time ReceivedFrom interface{} }
  • Ethereum의 Block 구조는 Bitcoin Block 구조와 유사.
  • Uncles란 Fork 발생 시에 생기는 동시 블록 정보를 의미
 

Block Header 구조

type Header struct { ParentHash common.Hash `json:"parentHash" gencodec:"required"` UncleHash common.Hash `json:"sha3Uncles" gencodec:"required"` Coinbase common.Address `json:"miner"` Root common.Hash `json:"stateRoot" gencodec:"required"` TxHash common.Hash `json:"transactionsRoot" gencodec:"required"` ReceiptHash common.Hash `json:"receiptsRoot" gencodec:"required"` Difficulty *big.Int `json:"difficulty" gencodec:"required"` Number *big.Int `json:"number" gencodec:"required"` GasLimit uint64 `json:"gasLimit" gencodec:"required"` GasUsed uint64 `json:"gasUsed" gencodec:"required"` Nonce BlockNonce `json:"nonce"` // ... 그외 정보들 // // BaseFee was added by EIP-1559 and is ignored in legacy headers. BaseFee *big.Int `json:"baseFeePerGas" rlp:"optional"` // WithdrawalsHash was added by EIP-4895 and is ignored in legacy headers. WithdrawalsHash *common.Hash `json:"withdrawalsRoot" rlp:"optional"` // BlobGasUsed was added by EIP-4844 and is ignored in legacy headers. BlobGasUsed *uint64 `json:"blobGasUsed" rlp:"optional"` // ExcessBlobGas was added by EIP-4844 and is ignored in legacy headers. ExcessBlobGas *uint64 `json:"excessBlobGas" rlp:"optional"` // ParentBeaconRoot was added by EIP-4788 and is ignored in legacy headers. ParentBeaconRoot *common.Hash `json:"parentBeaconBlockRoot" rlp:"optional"` }
  • 머클 패트리시아 트리 구조
    • Root(stateRoot)
      • state 트리의 루트 노드 해시값
    • TxHash(transactionsRoot)
      • 이 블록에 포함된 모든 트랜잭션을 포함한 트리의 루트 노드의 해시값
    • ReceiptHash(receiptsRoot)
      • 이 블록에서의 모든 트랜잭션의 receipt(일종의 거래 영수증)를 포함한 트리의 루트 노드의 해시값
  • Difficulty(난이도)
  • Number, GasLimit, GasUsed..
  • Nonce - POW에서 사용한 블록 해시 계산 과정에서 변경되는 값
 

Block의 작동 방식

  1. 12초마다 한번씩 블록이 생성되고, 한 블록은 수십/수백개의 트랜잭션으로 구성된다.
  1. 거래 내역을 보존하기 위해 블록과 블록 내에서의 트랜잭션은 엄격하게 정렬된다.
  1. 네트워크에서 무작위로 선택된 validator가 블록을 구성하면, 해당 블록은 네트워크의 나머지 부분으로 전파된다. → 합의는 지분증명(POS) 프로토콜에 의해 지정됨
  1. 모든 노드는 이 블록을 블록체인 끝에 추가하고, 다음 블록 생성을 위해 새로운 validator가 선택된다.
 
 
 
  • 아래 자료는 예전 POW를 시각화한 자료이다.
 
 
notion image
Share article

Tom의 TIL 정리방