---
# System prepended metadata

title: Final Dev Update
tags: [Ethereum, EPF]

---

# Final Dev Update

## Abstract

Precompile contracts are subrutines that are executed on the client side for high efficiency. [EIP-5988](https://eips.ethereum.org/EIPS/eip-5988) proposes the inclusion of the Poseidon hash function to the current set of precompile contracts of the EVM. Poseidon is part of a new family of cryptographic hash functions  known as *arithmetization-friendly* hash functions. This type of hash function allows the generation of simpler arithmetizations of programs, and hence, shorter proofs in SNARKs, STARKs, etc. Therefore, zk-rollups can benefit greatly by having access to cheaper and faster executions of Poseidon.

In order to make an informed decision on whether to include Poseidon as a precompile contract, this project proposed to analize the computational costs of executing Poseidon using Rust, which is the programming language currently use in [reth](https://github.com/paradigmxyz/reth).

In this short article, we summarize the results obtained, the progress achieved with respect to the original project proposal, and future work. Finally, we present our conclusions of the project.

## Current Status

The aproved project proposal can be accessed from this [link](https://github.com/eth-protocol-fellows/cohort-four/blob/master/projects/Computational_Cost_Analysis_of_Poseidon_Hash_as_an_EVM_Precompile.md). For this project I received valuable feedback from mentors Ignacio and Kev.

The project included four expected results:
1. A Rust implementation of Poseidon.
2. Benchmarks comparing different production-ready Poseidon implementations from popular repositories.
3. A solidity implementation.
4. A technical report about all results obtained.

During the execution of the project, the following products were obtained.
1. A [Rust implementation](https://github.com/mdvillagra/poseidon-rust), and
2. a set of [benchmarks](https://github.com/mdvillagra/poseidon-benchmarks) comparing production-ready code.

The [Rust implementation](https://github.com/mdvillagra/poseidon-rust) served mainly as an educational tool in order to have a better understanding of practical implementations of Poseidon. The main work was in the constructions of the [benchmarks](https://github.com/mdvillagra/poseidon-benchmarks). Theses benchmarks were constructed using production-ready code from [Dusk-Network](https://github.com/dusk-network/Poseidon252), [Risc0](https://github.com/risc0/risc0), [Neptune](https://github.com/lurk-lab/neptune), and [Cryptoexperts](https://github.com/CryptoExperts/poseidon). The repository of the benchmarks present all results comparing these implementations with different parameters of Poseidon. The graph below show a comparison the different Poseidon instantiations with the default parameters from each repository and using inputs of the size in bits.

![Captura de Pantalla 2023-11-05 a la(s) 21.24.39.png](https://hackmd.io/_uploads/SJoYz3S7p.png)

Running the benchmarks several times always present similar results where the Risc0 implementations are the fastest.

The repository for [benchmarks](https://github.com/mdvillagra/poseidon-benchmarks) can be easily expanded to add other repositories implementing Poseidon. It suffices to add the repository as a submodule and then add the function to the benchmark code.

The other two expected results, the Solidity code and technical report, were started but left unfinished in order to favor a sound implementation of the benchmarks. We talk a little bit more about these two expected results in the Future Work section below.

## Future Work

As mentioned in the previous section, two expected results were not achieved, that is, a Solidity implementation of Poseidon and the tecnical report using a rigorous presentation of all the results obtained in this project. Therefore, as a future work, I expect to finish these two expected results.

The Solidity implementation of Poseidon will be made available as a public repository using precomputed parameters. The tecnical report, however, I plan to add more information with more comparisons using other Poseidon implementations. I also plan to add an statistical analysis of the usage of precompile contracts through the years. I started working on this using [Dune](https://dune.com). My goal with this technical report will be to publish it as a conference paper in an academic conference.

## Conclusions

This project explored the computational costs of implementing Poseidon hash as an EVM precompile contract following [EIP-5988](https://eips.ethereum.org/EIPS/eip-5988). We developed our own version of Poseidon hash with parameter customizations and developed a set of benchmarks comparing the execution of four production-ready implementations of Poseidon. In our benchmarks, we observed that the [Risc0](https://www.risczero.com/) instantiation of Poseidon has the best performance with input sizes of at most 256 bits.

### Self-Evaluation

From the beginning of the program I invested at least twenty hours per week, with peak hours of thirty hours per week during the month of October. Even though I haven't obtained all expected results, I managed to deliver two of the most relevant ones, in particular the benchmark suite for Poseidon.

For the program I had to learn Rust for the first time. I have chosen Rust because of its popularity for doing backend cryptography and because I could use it for comparison with other precompile contracts in [reth](https://github.com/paradigmxyz/reth). Rust is not an easy language use due mainly to its ownership system for handling memory. Usually, one is acostume to handling memory manually or using the garbage collector. However, I learn to use ownership and thrive with it, and I expect from now own to only use Rust for all my coding unless I am forced to change to another language.

With all the benefits that Rust can bring, Rust was also the reason that I got behind several times in my projected plan. However, taking the EPF as a learning experience, it was also a good oportunity to learn new skills and learning Rust was probably the best decision I took this year in my career.

Another good decision was to chose [EIP-5988](https://eips.ethereum.org/EIPS/eip-5988) for my EPF project.  Even though I have been working on theoretical cryptography and computational complexity for many years, [EIP-5988](https://eips.ethereum.org/EIPS/eip-5988) allowed me to deal with problems implementing cryptographic primitives. This also made me realize about the huge gap between theoretical and applied work, and the urgent need of human resources filling that gap.

In summary, I feel that I achieved and learned a lot during the EPF considering that I have a full-time job.

### Feedback on the program

I have found the call for EPF by pure chance in the Ethereum blog while I was learning everything that I could about Ethereum. The EPF was a great opportunity to gain insights on how one the most important inventions in human history is currently being developed. 

The program is very well run and organized. The weekly calls and weekly updates forces the participants to follow and execute their plan. The AMAs were very insightful and fun. The life experience of the people involved with core development were diverse and rich of life lessons.

The conversations in the discord channel were very helpful and alleviated the tough path on becomming a core developer.

The entire process layed out by the EPF program where participants are given time to delve into a subject, prepare a project proposal, execute a plan, and finally reporting their results, helps to develop skills that are important in any job.

I am more than happy to have been selected for the EPF. I can confidently say that this have been a life changing experience for me. I not only used this opportunity to develop technical skills in cryptography and blockchain engineering, but I also spent time studying more about economics and finance. This made me realize about the importance of decentralization and censorship resistance in order to protect our freedom, which is arguably the most fundamental of all human rights.

Personally, I will be continuing working on my project about Poseidon hash. For future side projects, I will look to contribute to the protocol in other ways. In particular, I am very interested in trying to help in accelerating the adoption of Verkle tries.