# Final Update
## Abstract
This document captures the timeline, progress, and a retrospective of the Ethereum Protocol Fellowship. Key accomplishments include working on opcodes in intermediate language (IL), implementing a stats analyzer for accumulating execution opcode pattern stats, writing implementations for top opcode patterns found through the stats analyzer, and testing. The journey involved a steep learning curve, transitioning from research and development of a tool for execution code analysis to hands-on bytecode manipulation. It also involved addressing challenges such as selecting patterns that don't overlap and task management to ensure analysis occurs in the background. This report reflects a major part of the year dedicated to learning about and contributing to Ethereum's execution layer and the EVM.
## TimeLine
| Week | Task(s) |
| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| Week 1 | Explored the Nethermind IL-EVM codebase, built tools like AvaloniaILSpy, and started learning C#. |
| Week 2 | Progressed with understanding IL-EVM issues, installed tools like PerfView, and configured a Windows VM for better .NET support. |
| Week 3 | Studied C# memory management, explored sequential pattern mining, and examined Solidity’s representation in EVM code. |
| Weeks 4–5 | Created a graph of IL-EVM, studied Solidity/Yul memory management, and prepared a project presentation. |
| Weeks 6–7 | Began working on LOG instructions, meetings with mentors, and drafted a project proposal. |
| Week 8 | Augmented IL-EVM tests with LOG opcode implementation and began working on opcode statistics. |
| Weeks 9–10 | Developed basic tools for opcode statistics, implemented Count-Min Sketch for data analysis, and started identifying top patterns. |
| Weeks 11–12 | Improvements on tool for statistics processing, handled stats asynchronously, and experimented with log scales to segregate top patterns. |
| Week 14 | Focused on writing and testing the Stats Analyzer, simplified the Top-N algorithm, and resolved CMSketch hash issues. |
| Week 16 | Developed tracers for NGram stats, implemented a highly configurable plugin. |
| Week 18 | Implemented opcode patterns and tests, addressing challenges like pattern overlaps and test reliability. |
| Week 19-20 | Developed a script to automate opcode pattern selection, and debugged IL implementations. |
## PR's
| Task | PR | Status |
| ----------------------------------------- | ----------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Implement the 5 LOG0 - LOG4 instructions | [LOG Instructions](https://github.com/NethermindEth/nethermind/pull/7290) | Merged |
| code db stats | [Op Code stats tool](https://github.com/NethermindEth/nethermind/pull/7325) | Was never expecting it to be merged, execution stats are more usefull. If code db stats are required in the future the PR can be combined with the stats analyzer and merged |
| Stats Analyzer implementation | [CMSketch & StatsAnalyzer](https://github.com/NethermindEth/nethermind/pull/7345) | Draft |
| Implementations for NGrams of size 2 | [Top opcode patterns](https://github.com/NethermindEth/nethermind/pull/7597) | Merged |
| Implementation for NGrams of larger sizes | [IL-EVM: Adds 11 Patterns to ILVM Pattern swap mode](https://github.com/NethermindEth/nethermind/pull/7638) | Under Review |
| Testing and bugfixing | [Fix/il evm opcodes](https://github.com/NethermindEth/nethermind/pull/7703) | Merged |
| " | [Fix TStore, TLoad gas](https://github.com/NethermindEth/nethermind/pull/7709) | Merged |
## Current Status
This solely pertains to the stats analyzer PR: It remains in a draft state until I enhance test coverage and boost my confidence in the implementation's correctness; it also requires improved naming and minor refactoring. However, that being said, as far as I can tell, the existing PR delivers on all the requirements given to me for the tool.
## Future Plans
Will keep contributing to the project.
## EPF Retrospective
I worked on opcode implementations in IL during the fellowship, developed tools for pattern stats, analyzed data, implemented top patterns, and conducted tests. Early efforts focused on understanding the Nethermind IL-EVM codebase, including exploring libraries like Sigil for IL generation and tools such as PerfView to analyze dotnet.
As the project progressed, major tasks included implementing the stats analyzer for opcode patterns, which utilizes CMSketch, a probabilistic datastructure, to enable efficient tracking of the top K opcode patterns and their statistics. This work also involved developing a tracer and a highly configurable plugin. This tool laid the foundation for analyzing execution patterns and consequently writing implementations for them.
The fellowship also provided opportunities to explore Solidity memory management, bytecode manipulation, and the intricacies of the EVM. Despite challenges, including debugging IL implementations and handling large-scale data, the fellowship proved to be immeasurably valuable toward my goal of learning and contributing to the Ethereum Protocol. To that end, I would like to express my deepest gratitude to Josh Davis and Mario Havel for their invaluable guidance through the EPF journey, which for me began in the study group.
## Acknowledgments
- **Mentor**: Szymon Kulec
- **Mentor**: Ayman Bouchareb
- Lukasz Rozmej
- Ben Adams
- Damian Orzechowski
- Marek Moraczyński
- Tomasz Stańczak
I deeply value Szymon’s expertise in .NET— he mentored me during the core focus of my EPF project gaining clarity on what duties the stats tool should perform and also helped me zereo in on the underlying datastruccture for the task. when dealing with talent of his caliber, we’re dealing with god-level skills. The same holds true for Ben Adams, whose advice and chats during devcon are treasured. Their guidance has been invaluable.
Among everyone, I was most in communication with Ayman, who played an important role in helping me keep my EPF project on track. He helped me stay focused on the timeline by helping me define my next task. Lukasz helped me whenever I felt stuck—whether it was clarifying technical uncertainties or helping me steer the tool towards being a plugin and a tracer. Damian offered clarity on the near-term goals of the IL-EVM project, ensuring we had a solid roadmap.
Marek and Tomasz, on the other hand, were instrumental in connecting me with everyone. It’s safe to say that without the collective support and guidance of all these incredibly helpful people, the final update would have been a blank page with a meme.