The Ethereum Protocol Fellowship provides aspiring protocol developers like myself a pathway to gaining the experience needed to make meaningful contributions to the core Ethereum protocol. For the EPF I chose to contribute to Lighthouse, an Ethereum consensus client implementation written in Rust.
I started as a Lighthouse open source contributor in April, 2023. I began with simple tasks, making updates to documentation, updating log messages etc. Each contribution I made gave me the confidence and comfort I needed to take on bigger, more complex issues.
Now as an EPF participant I am tasked with working on a "large" project. However, based on what I've experienced so far, client developers dont just work on individual features. They frequently work on multiple tasks at the same time. Furthermore, client developers provide technical suppport to users and spend time investigating/fixing bugs.
With this in mind, I propose a three-part project. These parts wont be completed in a specific order, but instead will be worked on in parallel.
I'll dig into some infrastructure changes regarding the Lighthouse slasher backend and beacon node. Theres some new database implementations that the Lighthouse team would like to implement and so my work will focus that.
As I work on the "Big" project, I'd like to continue picking up smaller tasks and issues. This will allow me keep contrubting to Lighthouse while working on a large task. In some respects this emulates the actual work of a core protocol developer which is the whole goal of the EPF!
I'm really interested in the networking side of Lighthouse. They use rust-libp2p as their peer to peer networking stack. I've decided to make some small contributions to rust-libp2p with the goal of
Each part of the project will be described seperately, but as mentioned before, the work will all be done in parallel.
The slasher backend in Lighthouse currently has support for two databases implementations, LMDB and MDBX. There has been interest from the Lighthouse team to increase the number of database implementations that the slasher backend can support. I will work to add support for three new database implementations: Redb, SQLite, and PostgreSQL. As I add new DB implementations to the slasher backend, I will test them to see if they may be suitable for the beacon node.
The beacon node is at the core of the Ethereum proof-of-stake protocol. It is responsible for running the beacon chain, and uses distributed consensus to agree on blocks both proposed and attested on by validators in the network. Beacon nodes communicate their processed blocks to their peers via a peer-to-peer network, which also manages the lifecycle process of active validator clients.
The beacon node backend uses LevelDB. LevelDB is quite dated and so there will come a time where a new database implementation will be needed. Instead of waiting for that day to come, I will proactively work towards adding at least one new database implementation to the beacon node. In order to add a new database implementation, the beacon node backend must first be modularised.
From what I've seen in my short time contributing to Lighthouse, Ethereum protocol developers are constantly working on various issues simulataneously. Some of these issues might be large features, while others might be small bug fixes or optimizations. In order to mimic the daily life of a protocol developer I'd like to work on more than just one big issue. My plan is to be a frequent and productive contributor of the Lighthouse codebase. Some things I am currently working on include:
I've added support for the expected withdrawals endpoint. This endpoint gets the withdrawals computed from the specified state, that will be included in the block that gets built on the specified state.
According to benchmarks related to encoding and decoding of signed-blinded-beacon-block payloads with SSZ vs JSON
SSZ seems 40-50x faster
Considering 20-40ms per coding on average, that's up to 200-300ms JSON latency (or more).Sending the data SSZ encoded could reliably shave 200-250ms off each getPayload roundtrip.
The following three pull requests will support SSZ for the full block proposal flow in Lighthouse
I worked on a small issue that Improves the readability of transport connection errors
I'm working on a task that significantly reduces Lighthouse binary size by Snappy compressing genesis.ssz files
I worked on a small issue that defaults Content-Type header to json for routes that expect json in the request body.
My goal is to continue working on smaller issues such as these as I work on my "Big" project.
rust-libp2p is designed as an async, event-based system. This makes it fairly hard to add rich logs in user land because peer information is not always available. This is where tracing comes in.
Tracing: A scoped, structured logging and diagnostics system.
Tracing would allow rust-libp2p to offer more detailed logs for users. These "traces" contain more context than traditional logging would. Also it allows users of rust-libp2p to opt in/out of tracing. Opting out of tracing will greatly reduce console noise associated with rust-libp2p. Once tracing is implemented, I will approach the Lighthouse client team about adding tracing support so that they can automatically pick up the improved logs from rust-libp2p. This should improve the Lighthouse developers ability to diagnose and resolve peer to peer network related issues.
The current pull request can be found here:
https://github.com/libp2p/rust-libp2p/pull/4282
Implement the following three databases in the slasher backend:
Within each database implementation the following steps will be made:
DatabaseBackend
enum.xxx_impl.rs
file with types named similarly to other existing backendsinterface.rs
for the new backendDEFAULT_BACKEND
set to the new backend, and cargo test --release -p slasher
After the above work is done
The goals for this portion of my project are a bit more open ended:
It's hard to create a specification for this portion of the project since its a bit open ended. I hope my explanations in previous sections have given the reader enough context to understand what goals I wish to accomplish here.
I will work on adding tracing to rust-libp2p with the end goal of giving the Lighthouse team cleaner and richer libp2p logs.
Note that week 1 indicates the first week of the EPF starting date. Some of the work here has already begun.
Add the three new database implementations to the slasher backend. They should be ready for testing/review by Week 8
Begin modularising the beacon node backend. Continue testing the new slasher backend database implementations. By week 12 we should have decided on which database we will implement for the modularised beacon node backend
Add a new database implementation to the beacon node backend.
Continue making "small", meaningful contributions to Lighthouse
Add tracing to ping protocol and have those changes finalized by the rust-libp2p team
Add tracing to all other rust-libp2p protocols
Mention to the lighthouse team that tracing in libp2p should be available "soon" (whenever the rust-libp2p decides to release these changes). Offer to add tracing support in Lighthouse
I might be trying to take on more than I can "chew" within the timeline of the EPF. As long as I put in the time and effort I believe I can accomplish the tasks laid out in the project proposal. However, unforseen issues could delay/block my progress. It'll be important for me to frequently reevalue my progress so I can narrow my project scope if it becomes necessary in order to accomplish my main tasks.
I have about four months of Rust experience. Its a language with a sharp learning curve. Though I've made large strides in terms of my ability to productively write Rust code, I could reach a situation where my lack of certain knowledge in the language could be deterimental to my productivity. I've already had long battles with the Rust "borrow checker". I expect more of those in the future.
I've been putting about 40-50 hours of work weekly on Lighthouse since I began the EPF. This is on top of juggling my current day job. I've frequently had 12+ hour work days and I work weekends. Its been a tough, yet very rewarding experience. I need to keep myself motivated in order to make it to the finish line. It will be important to continually remind myself why I'm working hard. I am not guaranteed to land an Ethereum protocol developer job after the end of EPF, I need to give myself the best chance possible to make that dream a reality.
WIP