# Week 2 Updates ## PeerDAS I authored a blog on [PeerDAS](https://open.substack.com/pub/0xrosetteeee/p/peerdas?r=2r6vww&utm_campaign=post&utm_medium=web&showWelcomeOnShare=true) detailing the implementation of Peer-to-Peer Data Availability Sampling (PeerDAS) through its development stages: * Stage 0 (EIP-4844): Explored basic subnet-based blob distribution without Data Availability Sampling (DAS). * Stage 1: Discussed the deployment of 1D PeerDAS, featuring horizontally extended blobs and the setup of networking components for peer sampling. * Stage 2 (Full Danksharding): Covered the advancement to 2D PeerDAS, enhancing data handling efficiency and robustness by utilizing matrix cells for peer sampling and integrating both horizontal and vertical data extensions. My study also included aspects of distributed reconstruction, network-level optimizations, and scalability solutions such as the deployment of super-full nodes and adjustments in `NUM_COLUMN_SUBNETS` for optimized security and operational efficiency. [ Blog link](https://open.substack.com/pub/0xrosetteeee/p/peerdas?r=2r6vww&utm_campaign=post&utm_medium=web&showWelcomeOnShare=true) #### PeerDAS Implementation I tried to set up the [PeerDAS implementation in Rust by Grandine](https://github.com/grandinetech/grandine/tree/das) but was unable to do so. I studied the codebase and will try to identify and fix the errors. ## libp2p * Engaged in a comprehensive review of libp2p, a framework essential for constructing decentralized peer-to-peer network applications, focusing on its architectural design and modular components that support various decentralized services. #### DHT * Investigated the implementation and functionality of the Distributed Hash Table (DHT) within libp2p, which is critical for efficient peer routing and discovery across a distributed network. DHTs enable a decentralized mechanism for storing and retrieving key-value pairs spread across network nodes. ![image](https://hackmd.io/_uploads/rJhpHrPLA.png) * Delved into the specific adaptations of DHT used in [Proto's DHT Notes](https://notes.ethereum.org/cG-j3r7kRD6ChQyxjUdKkw), which is tailored to meet the Ethereum network's unique requirements for scalability and security. This study involved analyzing enhancements and optimizations proposed for Ethereum’s peer discovery and data availability. * Studied the codebase of Rust implementation of libp2p to gain a deeper understanding of its low-level network operations, including transport protocols, peer identity management, and encrypted communications. This exploration provided practical insights into deploying libp2p’s theoretical constructs in real-world applications. [Rust libp2p GitHub Repository](https://github.com/libp2p/rust-libp2p) ## DAS fork choice * I also examined the DAS fork choice rules and here is the simple implementation of simple specification of the (block, slot) fork-choice ``` def get_head(store: Store) -> Root: # Get filtered block tree that only includes viable branches blocks = get_filtered_block_tree(store) # Execute the LMD-GHOST fork choice head = store.justified_checkpoint.root slot = Slot(blocks[head].slot + 1) while slot <= get_current_slot(store): children = [ root for root in blocks.keys() if (blocks[root].parent_root == head and blocks[root].slot == slot) ] if len(children) > 0: best_child = max(children, key=lambda root: (get_weight(store, root), root)) best_child_weight = get_weight(store, best_child) empty_slot_weight = get_empty_slot_weight(store, head, slot) if best_child_weight >= empty_slot_weight: head = best_child slot = Slot(slot + 1) return head def get_empty_slot_weight(store: Store, root: Root, slot: Slot) -> Gwei: ... attestation_score = Gwei(sum( state.validators[i].effective_balance for i in unslashed_and_active_indices if (i in store.latest_messages and i not in store.equivocating_indices and ( (store.latest_messages[i].root == root and store.latest_messages[i].slot >= slot or (store.latest_messages[i].slot > slot and not store.latest_messages[i].root == root and get_ancestor(store, store.latest_messages[i].root, slot) == root ) )))) ... return attestation_score + proposer_score ```