# EPF Cohort 6 – Week 12 Update
## New challenges this week
A really great thing from Rust is that a lot of issues can be caught at compile time, or through Clippy testing.
Because this week I was working on that to **ensure all tests pass** -> after applying tracing globally.
The great thing is that tracing and its instrumentation are mostly implemented through macros, which are expanded into code at compile time and show errors immediately.
But this week I got a new fun challenge: **fearless concurrency** in Rust.
### Current work
- Code is formatted
- Program is tested
- I needed to switch some tests to tracing, which were previously based on the logging system – e.g. in [issue](https://github.com/sntntn/grandine/issues/13) where I had to change a test to work with tracing. This required small implementation changes in the feature crate to work with macros, because the old logging system (through functions) combined with new tracing was not testable in unit tests.
> That change should not ruin the DX experience, because Grandine mostly used implementation of feature logging through macros (their previous) instead of feature logging through functions. And these logging macros kept the same interface as before.
- A lot of Clippy lints were solved by adding `threshold` for cognitive complexity, as debugging macros with peers seem to inflate counted complexity - that was Tumas' advice :). Some others required minor changes.
- Some of the `consensus-spec-tests` fail and the reason should be [future is not send](https://rust-lang.github.io/rust-clippy/master/index.html#future_not_send).
The interesting thing is that I didn't change protocol implementation, so I was wondering how it is possible to fail consensus-spec-tests. After some research, it seems that removing the logger from message passing in some threads broke thread safety (which can lead to race conditions - but I won't rush and I will write full explanation when I solve this issue officially, Until then, I’ll share some useful fearless concurrency tutorials in the Resources section, which helped me).
## Next Steps
I am going to ensure all tests pass after solving the thread safety issue.
This is a big step in the **Final log to tracing Migration**, originally planned for **Phase 4**, I’m following Tumas’ advice and doing it now.
For Phase 4 I also planned optional implementation of Tokio Console and Flamegraph for better observability, but from Saulious’ experience, he didn’t get much value from that in his career (so **it’s not the main focus now** - but maybe tracing will open new perspectives later).
Because of that, I’m also waiting for advice from the last [office hour](https://github.com/eth-protocol-fellows/cohort-six/issues/345) speaker, Eitan, and his perspective after integrating tracing. He works on Lighthouse, and Grandine extracted the network layer from them, so it would be meaningful to hear something from his p2p experience and Rust consensus client experience in general.
Additionally I watched **[Devcon SEA](https://www.youtube.com/playlist?list=PLvu3JfoGPg5l_85qIF8U3xu3wBXndwOJH)** fellows' presentations and learned from them, including the [presentation of tracing for lighthouse](https://www.youtube.com/watch?v=MuOh05pJID0&list=PLvu3JfoGPg5l_85qIF8U3xu3wBXndwOJH&index=10) where I learned from Sayan's experience :).
After completing this, I will work on instrumentation of core logic from Phase 3 (where tracing is already integrated). This should **not be technically demanding** but it will require **research skills**, since these calls are frequent and I’ll need to carefully manage instrumentation overhead.
After that research, I hope I will have an answer to question: *"What would I change in the Ethereum protocol?"* (this was a question from a previous office hour - where I didn’t have enough experience to give a useful answer)
## Resources
- [Grandine GitHub Repository](https://github.com/grandinetech/grandine)
- [Roadmap HackMD](https://hackmd.io/JX5Q0ObtQ-iStLwSmVRPVg)
- [**PR** Phase 2 & Final log to tracing Migration from Phase 4](https://github.com/sntntn/grandine/pull/9)
- [**PR** Phase 2: Tracing the Network Boundary (eth2_libp2p submodule)](https://github.com/sntntn/eth2_libp2p/pull/3)
- useful videos for fearless concurrency in Rust:
- [Threads, Mutexes & Channels](https://www.youtube.com/watch?v=6VMJOmNBubg)
- [Creating Threads](https://www.youtube.com/watch?v=06WcsNPUNC8), [Message Passing](https://www.youtube.com/watch?v=FE1BkKqYCGU), [Sharing State](https://www.youtube.com/watch?v=mupwF9jbVZ4)
- [Send, Sync, and Thread Safety](https://www.youtube.com/watch?v=5Oc1dJWsEfQ)
- [future is not send](https://rust-lang.github.io/rust-clippy/master/index.html#future_not_send)
- [Devcon SEA](https://www.youtube.com/playlist?list=PLvu3JfoGPg5l_85qIF8U3xu3wBXndwOJH) fellows' presentations