일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
- built in object
- hardhat
- Redux
- nextJS
- graphQL
- Ethereum
- API
- web
- blockchain
- concept
- SSR
- express.js
- typeScript
- middleware
- 기준
- Props
- Interface
- JavaScript
- CLASS
- tailwindcss
- HTML
- bitcoin
- useState
- evm
- 삶
- REACT
- node.js
- CSS
- solidity
- error
- Today
- Total
ReasonJun
Bitcoin : P2P Network 본문
The reason why Gossip Protocol (TCP) is used is that when a transaction occurs, it must be able to push even if there is no request.
When a transaction occurs in one node, the information must be spread to other nodes as quickly and widely as possible. At this time, whether each transaction is correct is determined by the basic rules and consensus algorithm of the Bitcoin network.
Join a network
The new node to be newly joined accesses the 6 domains and receives an address request. (version information + random value)
Domains transmit the addresses of trusted nodes to the new node. (version arc information + received random value)
The newly joined node attempts to connect to the received address.
Here, these domains (DNS Nodes) are somewhat centralized. For this reason, the Bitcoin network is set up to automatically access the source code where trusted addresses are stored if any of the above domains dies. (Addresses are continuously updated.)
Block Sync
- Ping / Pong
- Header Download
- Block Download
- Block Validation
Block Varification
- Receive new blocks
- Block structure matching
- Recalculation
- Block timestamp < now() + 2 hours
- Block Size < 1MB
- Coinbase Transaction Check
- Transaction Check
- Mempool Update
- LevelDB Insert New Block
- Block propagation
Block structure matching
Verifies whether each block has the data it should have. Verifying that a block in the Bitcoin blockchain is correct.
Recalculation
Check if the block is formed through normal operation. By hashing the nonce value of the header (found through proof-of-work) and the header value, it is checked whether the received hash value is correct. (Check block forgery)
Block timestamp < now() + 2hours
Bitcoin has two mechanisms to protect against miners manipulating the timestamp
Future Block Time Rule – The timestamp cannot be more than 2 hours in the future based on the MAX_FUTURE_BLOCK_TIME constant, relative to the median time from the node’s peers. The maximum allowed gap between the time provided by the nodes and the local system clock is 90 minutes, another safeguard. It should be noted that unlike the MPT rule above, this is not a full consensus rule. Blocks with a timestamp too far in the future are not invalid, they can become valid as time moves forwards.
Bitcoin’s Block Timestamp Protection Rules | BitMEX Blog
Bitcoin’s Block Timestamp Protection Rules | BitMEX Blog
Abstract: We examine two of Bitcoin’s little-known rules, designed to stop nefarious miners from manipulating the block timestamps and achieving unfairly high mining rewards. We discuss why constants such as the two-hour MAX_FUTURE_BLOCK_TIME value may h
blog.bitmex.com
Block Size < 1MB
Check the block size according to the rules. Up to this point, only block headers are used.
Coinbase Transaction Check
Transaction information about how much the miner will receive is included. Check whether the mining has proceeded normally and whether the fee is appropriate.
Transaction Check
Verifies the transaction included in the block.
Mempool Update / LevelDB Insert New Block
The node does not store the blockchain in the form of a file, but in a DB called level DB.
Transaction Propagation
- Transactions are propagated from other nodes.
- Check whether the transaction has already been received.
- If there is none, it is propagated to other nodes. => Deliver a new Transaction txid.
- If there is no counterpart node, getdata is requested. => MSG_TX and txid are received.
- Delivers a new transaction.
- Executes until it is delivered to all connected nodes.
Transaction Varification
- New Transaction received
- Check Transaction structural match
- In, out List check for existence
- Transaction Size < 1MB
- Output Value < 2100만 BTC
- Mempool check for existence
- Block check for existence
- Input Check(Double Spending)
- Input Check(Orphan Tx)
- Input Check (Coinbase)
- Input Check (Not UTXO)
- Input > Output value
- Check Input Script
- Add Mempool
- Transaction Propagation
Mempool
This is where received but not yet processed transactions are stored. In order to prevent multiple transaction processing, the existence of transactions in the mempool is checked.
Block check for existence
Avoid double spending. It is to check approved transactions.
Input Check (Orphan Tx)
Check if it has been processed and included in a block, but the block itself has ended unacknowledged.
Input Check (Coinbase)
In the case of miner reward transaction, it is created and set to be used only after the 100th block. So, if the 100th block has not been formed and it is a transaction to be used, it is deleted.
Input Check(Not UTXO)
Check if it is UTXO.
Input > Output value
Prevents 1BTC from becoming 2BTC.
Check Input Script
Check that the signature was done correctly.
Add Mempool
Notifies that it is a normal transaction that has not yet been processed by storing it in the mempool.
Block Propagation
- Ping
- The received Block Header is delivered.
- For blocks that have not yet been delivered, both headers and getdata are requested. => In headers, I send the latest Block Header List I have.
- The new block and the blocks in between are delivered to the node
ex)
If A node has only the 99th block according to the network situation, but B node sends information about the 105th block, A node sends getdata with its own 99th block information.
Then, information about blocks 99 to 105 is transmitted.
'Blockchain > Bitcoin' 카테고리의 다른 글
Bitcoin : Block Structure (0) | 2023.09.27 |
---|---|
Bitcoin : gRPC vs HTTP API (0) | 2023.09.17 |
Bitcoin : Merkle Tree (0) | 2023.09.17 |
Bitcoin : ECDSA (Elliptic Curve Digital Signature Algorithm) (0) | 2023.09.17 |
Bitcoin : Cryptographic systems (RSA / ElGamal Encryption / Hash Encryption) (0) | 2023.09.17 |