Monad 백서

Monad

원문

bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 75쪽 중 60쪽

udes additional data for tracking each block's progression through consensus. # Blocksync Source: https://docs.monad.xyz/monad-arch/consensus/blocksync Mechanism for synchronizing missing blocks ## Summary Blocksync is a mechanism that nodes can use to acquire missing blocks. A block is considered missing when a Quorum Certificate is observed that references an unknown block. Blocks can be missing from a node in one of two scenarios: 1. After the node completes statesync and its local block height is close enough to the network tip. 2. During ordinary consensus operations, the node does not receive enough RaptorCast chunks to decode the block. This can be due to packet loss or a network partition. ## Blocksync procedure 1. A single header request is made for a range of `num_blocks` blocks, starting with `last_block_id`. 2. A chain of `num_blocks` headers are received, forming a cryptographically verifiable chain back to `last_block_`. 3. For each of the `num_blocks` headers received, concurrent (up to a max concurrency factor) body requests are made containing the `body_id` included in the header. 4. Each body response is cryptographically verifiable by comparing against the corresponding header `body_id`. <img alt="Blocksync procedure" /> # Forkpoint Source: https://docs.monad.xyz/monad-arch/consensus/forkpoint How a node persists consensus state and resumes from it on startup ## Summary A forkpoint is a saved snapshot of consensus state. It lets a node restart from a known-good point instead of replaying the chain from genesis. It holds everything the node needs to rejoin consensus: where it was in the blocktree, the proof it needs to enter the next round, and the validator sets that check that proof. On disk, a forkpoint is the `forkpoint.rlp` and `forkpoint.toml` pair you handle during installation and [recovery](/node-ops/node-recovery). This page covers what those files hold and how a node uses them to sync on startup. ## What a forkpoint contains A forkpoint holds three fields: * **`root`** — the root of the node's blocktree, which points to its highest committed block. Syncing starts here. * **`high_certificate`** — the highest quorum certificate (QC) or timeout certificate (TC) the node has seen. It's the proof the node needs to enter the next round. * **`validator_sets`** — the validator sets that check those certificates. There's usually one, for the current epoch. During an epoch change there are two, so the node can check certificates on both sides of the boundary. When a node loads a forkpoint, it checks that the `high_certificate` verifies against the `validator_sets` before using it. ## Startup sync A node loads its forkpoint and then syncs to the network tip in three steps. 1. **Fetch the blocks up to the root.** The node uses [blocksync](/monad-arch/consensus/blocksync) to pull the `2 × execution_delay` committed blocks up to and including `root`. These are needed for reserve-balance checking under the transaction fee mechanism, and they have to be in place before state can sync. 2. **Statesync.** The node brings [MonadDb](/monad-arch/execution/monaddb) up to version `root − execution_delay`. While this runs, it listens for new proposals and sets them aside in a buffer. See [statesync](/monad-arch/consensus/statesync). 3. **Replay.** Once both syncs finish, the node builds its blocktree from `root` and `high_certificate`, then replays the buffered proposals to reach the tip. One thing to keep straight: blocksync does two different jobs. * **On startup**, it pulls blocks that sit *behind* the root, and it runs before statesync (step 1 above). * **During normal operation**, it does the reverse: statesync gets the node close to the tip, and blocksync fetches the last few blocks to close the gap, the way getting into the stadium comes before finding your seat. This catch-up role is the one the [blocksync](/monad-arch/consensus/blocksync) page describes. Consensus resumes at `high_certificate.round() + 1`, so a node never votes at or below a round it already voted in. That's what makes restarting from a forkpoint safe instead of a source of double votes. ## How forkpoints are persisted A node writes a new forkpoint each time it enters a new round or finalizes a block. New rounds come constantly, so `forkpoint.toml` changes roughly every round. Each write produces two files: * **`forkpoint.rlp`** — the canonical, RLP-encoded form. * **`forkpoint.toml`** — a human-readable, TOML-encoded form. The node loads whichever file its `--forkpoint-config` path points at; the bundled systemd unit points at `forkpoint.toml`. Both are written to a temporary file first and then renamed, so a process crash mid-write doesn't corrupt the forkpoint. Each write also keeps a backup copy, keyed by the root sequence number and round, so earlier forkpoints stay around for recovery. # Consensus Source: https://docs.monad.xyz/monad-arch/consensus/index <CardGroup> <Card title="MonadBFT" href="/monad-arch/consensus/monad-bft"> Tail-fork-resistant pipelined consensus </Card> <Card title="RaptorCast" href="/monad-arch/consensus/raptorcast"> Efficient block propagation of large blocks, utilized by leaders in MonadBFT </Card> <Card title="Asynchronous Execution" href="/monad-arch/consensus/asynchronous-execution"> Moving execution out of the hot path of consensus so it can use the full block time </Card> <Card title="Block States" href="/monad-arch/consensus/block-states"> Summarizing the progression of Monad blocks from proposal to verification </Card> <Card title="Local Mempool" href="/monad-arch/consensus/local-mempool"> Policies for sharing pending transactions to leaders while minimizing bandwidth </Card> <Card title="Statesync" href="/monad-arch/consensus/statesync"> Algorithms for bootstrapping a node from peers </Card> <Card title="Blocksync" href="/monad-arch/consensus/blocksync"> Algorithms for catching up on missed traffic </Card> <Card title="Peer Discovery" href="/monad-arch/consensus/peer-discovery"> How nodes know where to find each other </Card> <Card title="Message Authentication" href="/monad-arch/consensus/authentication"> Signature schemes used in Monad </Card> <Card title="Transport Protocol Usage" href="/monad-arch/consensus/transport-protocols"> TCP and UDP usage for node communication </Card> </CardGroup> # Local Mempool Source: https://docs.monad.xyz/monad-arch/consensus/local-mempool Mempool local to each node ## Summary Most blockchains use a global mempool with peer-to-peer gossipping for transaction propagation. This approach is not suitable for high-performance distributed consensus for a few reasons: 1. It is slow because it may involve many hops for a transaction to reach a leader, increasing time to inclusion. 2. It is wasteful on bandwidth because the gossip protocol involves many retransmissions. 3. It ignores the leader schedule which is typically known well in advance. In Monad, there is no global mempool; instead, each validator maintains a local mempool, and RPC nodes forward transactions to the next few leaders for inclusion in their local mempool. This is much more efficient on bandwidth usage and allows transactions to be included more quickly. ## Background A mempool is a collection of pending transactions. Many blockchain networks use a global mempool design, using peer-to-peer gossip protocols to keep roughly the same mempool state across all nodes in the network. A primary motivation of a global mempool design is that no matter who is leader, they will have access to the same set of pending transactions to include in the next block. A global mempool is effective for low-throughput networks, where network bandwidth is typically not a bottleneck. However, at thousands of transactions per second, the gossip protocols (and especially the required retransmission at each node) can easily consume the entire network bandwidth budget. Moreover, a global mempool is wasteful since the leader schedule is typically known well in advance. ## Transaction Lifecycle in Monad There is no global mempool in Monad. Validators maintain local mempools; RPC nodes forward transactions to upcoming leaders to ensure that those transactions are available for inclusion. More precisely, transaction flow is as follows: 1. A transaction is submitted to the RPC process of a node (typically a full non-validator node). We'll call this node the **"owner node"** of the transaction, since it assumes responsibility for communicating the status with the user. 2. The RPC process performs some static checks on the transaction. 3. The RPC process passes the transaction to the consensus process. 4. The consensus process performs static checks and dynamic checks against local state in MonadDb, such as checking the sender's account balance and nonce. 5. If the transaction is valid, the consensus process forwards the transaction to `N` upcoming leader validator nodes. Currently, `N` is set to 3 in Monad testnet and mainnet. 6. Each of those `N` validators performs the same checks before inserting valid transactions into their local mempools. 7. When it is a leader's turn to create a proposal, it selects transactions from its local mempool. 8. The owner node of the transaction monitors for that transaction in subsequent blocks. If it doesn't see the transaction in the next `N` blocks, it will re-send to the next `N` leaders. It repeats this behavior for a total of `K` times. Currently, `K` is set to 3 in Monad testnet and mainnet. The behavior of this transaction flow is chosen to reduce time-to-inclusion while minimizing the number of messages. <img alt="Transaction path to leader" /> <p>Transaction path from RPC to leader (through the local mempool).</p> ## Local mempool eviction Transactions are evicted from a validator's local mempool for the following reasons: 1. Whenever a validator finalizes a block, any replicas of transactions in that block are pruned from the local mempool. 2. Validators periodically check the validity of each transaction in the mempool and evict invalid transactions (e.g. nonces are too low, account balances are insufficient). 3. If the local mempool's size reaches a soft limit, older transactions will be evicted. # MonadBFT Source: https://docs.monad.xyz/monad-arch/consensus/monad-bft MonadBFT - Fast, Responsive, Fork-Resistant, Streamlined Consensus ## Summary MonadBFT represents a major leap in Byzantine Fault Tolerant (BFT) consensus. It is responsible for ensuring that the Monad network aligns on valid proposed blocks efficiently and securely, while supporting 10,000+ tx/s and sub-second time-to-finality, while also supporting a large consensus node set. MonadBFT combines all of these properties while also being resilient to **tail-forking**, a critical weakness of pipelined leader-based BFT protocols where a leader can fork away its predecessor's block. For a full description and deep technical dive into MonadBFT, please refer to the [full research paper](https://arxiv.org/abs/2502.20692), the [latest blog post from Category Labs](https://www.category.xyz/blogs/monadbft-update-fast-recovery-leader-fault-isolation) and the [original blog post](https://www.category.xyz/blogs/monadbft-fast-responsive-fork-resistant-streamlined-consensus) introducing MonadBFT. MonadBFT achieves: * **Speculative finality in a single consensus round**, and **full finality in two rounds**. * **Linear message and authenticator complexity** on the happy path (meaning under normal operations, when no failures occur). This allows the consensus validator set to scale to a large number of nodes. * **Optimistic responsiveness**: round progression without waiting for the worst-case network delay, both in the common case and while recovering from failed rounds. * **Leader fault isolation** A single failed leader only incurs one timeout delay. All other rounds are able to proceed as quickly as the network allows. This is in contrast to existing pipelined BFT protocols, which have a two timeouts for a failed leader. * **Tail-forking resistance**: built-in protection against [tail-forking](#no-tail-forking), a class of Maximal Extractable Value (MEV) attacks where a malicious leader could otherwise fork away its predecessor's block. This resolves a critical issue in prior pipelined leader-based BFT consensus mechanisms. No other pipelined leader-based BFT protocol combines all these features. <Note> Category Labs has made several recent improvements to MonadBFT. This page and the research paper have now been updated with full details. Find out what's new in the [Fast Recovery](#fast-recovery) section or by reading [this blog post](https://www.category.xyz/blogs/monadbft-update-fast-recovery-leader-fault-isolation). </Note> ## Configuration in Monad <div> <table> <thead> <tr> <th /> <th /> </tr> </thead> <tbody> <tr> <td>Sybil resistance mechanism</td> <td>Proof-of-Stake (PoS)</td> </tr> <tr> <td>Min block time</td> <td>300 ms</td> </tr> <tr> <td>Finality</td> <td>2 slots (600 ms)</td> </tr> <tr> <td>Speculative finality *(can only revert in [rare circumstances](#speculative-finality) requiring equivocation by the original leader*)</td> <td>1 slot (300 ms)</td> </tr> <tr> <td>Delegation allowed</td> <td>Yes</td> </tr> </tbody> </table> </div> ## Demo See [this](https://www.category.xyz/blogs/monad-viz-a-visual-representation-of-monadbft) blog post from Category Labs for a live demo of MonadBFT! The demo runs the exact implementation of [`monad-bft`](https://github.com/category-labs/monad-bft) that powers the live Monad blockchain, compiled to Wasm and run in your browser against a simulation framework ([`mock-swarm`](https://github.com/category-labs/monad-bft/tree/master/monad-mock-swarm)). ## Common Concepts To explain MonadBFT, it helps to define a few concepts first. We will start with some concepts common to many BFT mechanisms: ### Byzantine threshold As is customary, let there be `n = 3f+1` nodes, where `f` is the max number of Byzantine (faulty) nodes. That is, `2f+1` (2/3) of the nodes are non-Byzantine. In the discussion below, we treat all nodes as having equal stake weight; in practice all thresholds can be expressed in terms of stake weight rather than in node count. ### Supermajority \>2/3 of the stake weight. ### Round The protocol proceeds in rounds, also referred to as views. The round number increases by 1 with each step of the protocol regardless of whether a block proposal is successfully made. ### Leader Each round has one leader who has the authority to make a block proposal. The leader rotates each round according to a schedule determined previously using the stake weights. ### Block A block consist of a round number, a payload (an ordered list of transactions), and a [QC](#quorum-certificate-qc). A block builds on a *parent* block, and includes a QC certifying that parent block. Blocks are chained together via the parent relationship, which is why we called it a blockchain. ### Quorum Certificate (QC) Validators evaluate the validity of each block proposal and send their votes to the next leader. If the next leader receives a supermajority of YES votes, they aggregate those votes into a Quorum Certificate (QC) on that block proposal. A QC is proof that 2/3 of the network received and voted YES on a block proposal. Although this is more of an implementation detail, it is worth noting that in Monad's implementation of MonadBFT, validators sign with [BLS signatures](https://en.wikipedia.org/wiki/BLS_digital_signature) because those signatures can be efficiently aggregated, making signature verification on the QC relatively inexpensive. ### Linear communication Each round follows a fan-out fan-in pattern. The leader sends their block proposal to each validator (using [RaptorCast](/monad-arch/consensus/raptorcast) for efficient broadcast). Validators evaluate the block proposal and send a signed vote directly to the next leader. This linear communication mechanism contrasts with other protocols which rely on all-to-all (quadratic) communication; it allows the consensus set to scale. ## Concepts relatively unique to MonadBFT The following are concepts that are relatively unique to MonadBFT. We are splitting them out to aid in comprehension. For simplicity, we focus on the standard recovery in MonadBFT. The fast recovery optimizations are explained in the [Fast Recovery](#fast-recovery) section. ### Proposal A block proposal (often just called *proposal*) consists of the current round number, a block, an optional [TC](#timeout-certificate-tc) or [NEC](#no-endorsement-message-and-no-endorsement-certificate), and a signature (from the leader making the proposal) over the previous elements. In the simple case, optional fields are blank and the round number is the same as the block's round number, such that the proposal is basically a signed block. Sometimes, a block that failed to get traction gets reproposed; in that case, the block will still have the round number from when it was first proposed, but the proposal will have the round number of when it is reproposed. #### Fresh Proposal A fresh proposal is a [proposal](#proposal) containing a new block, i.e. one that is not influenced by prior failed proposals. A fresh proposal will either: 1. have a round number that is equal to its [QC](#quorum-certificate-qc)'s round number plus 1. This is the common case, when leaders are honest and online, and the network does not have any abnormal delays. 2. have a [TC](#timeout-certificate-tc) identifying a high QC. This happens when a leader recovers from a failed round ([fast recovery](#fast-recovery)). 3. have a [NEC](#no-endorsement-message-and-no-endorsement-certificate). This happens very rarely, when a leader recovers from a more complex failure (standard recovery). #### Reproposal A reproposal is a [proposal](#proposal) containing a block from a previous fresh proposal that the current leader is trying to revive or finalize. A reproposal will have a round number greater than its [QC](#quorum-certificate-qc)'s round number plus 1. Whether a leader recovering from a failure has to repropose a previous block or not is determined by the [TC](#timeout-certificate-tc). If the TC contains a high tip (instead of a high QC), then the block corresponding to the high tip must be reproposed. Reproposals are part of the standard recovery. In practice, reproposals can often be skipped with fast recovery. ### Tip A tip is a proposal minus the block's payload. You can think of it as the block header of the proposal plus a bit of extra metadata, including the round number that that proposal was received. In MonadBFT, every validator keeps track of its latest tip, which is updated whenever the validator votes for a proposal. If the validator votes for a reproposal, the tip is set to the original proposal, not its reproposal. ### High Tip Given a set of tips, high tip is just the tip with the highest round number. If there are multiple such tips, then the tip that builds on the highest QC embedded in it is chosen. ### Timeout Message A timeout message is a signed attestation that a validator produces when it hasn't received a valid block from the scheduled leader in the expected time. The timeout message attests to the lack of a valid block. Each validator sends the timeout message to all other validators, utilizing all-to-all communication. Timeout messages are utilized in other BFT protocols. In MonadBFT, timeout messages include the sender's [tip](#tip) - additional information about their view of the world which will be utilized in MonadBFT to recover gracefully from the timeout. For fast recovery, the timeout message contains the validator's highest QC, if it is of equal or higher view than the view of the local tip. ### Timeout Certificate (TC) W
프로젝트로 돌아가기