-
Notifications
You must be signed in to change notification settings - Fork 0
Necessary conditions for robustness and portability #1
Description
To increase the robustness and portability of wallet3 it should be built around a purely functional library that meets the following conditions:
- C ABI
- No concurrency and networking mixed in.
- No hidden assumptions about the environment.
- No side effects and hidden control flows.
- No unnecessary dependencies sprinkled in (for example boost)
- Minimal amount of code paths per function.
One of the lessons to learn from wallet2:
instead of creating one very tightly integrated piece of software that tries to solve all of these things at once, the following issues should be dealt with by the wallet implementers:
- concurrency (respond to user input and not stall)
- networking (communicating with the daemon)
- parallelism (threading)
- logging
The side effect of leaving these problems to implementers is that there will be a better separation of concerns. There should be no full implementation of a wallet that does these things in the monero core repo.
We need to avoid at all costs that the example wallet library is turned again into the de facto standard wallet implementation.
We should make a hard rule that no code gets checked into the main monero repo that breaks these rules:
- "example" wallet code that touches the concerns mentioned above
- code that breaks the 6 conditions necessary for robust and portable wallet code.
I invite you to read the custom vendored easylogging_c++ library that gets shipped with Monero:
https://github.com/monero-project/monero/blob/master/external/easylogging%2B%2B/easylogging%2B%2B.cc
This library introduces a dependency on signal.h even for code that should be strictly functional and without side effects.
This is an example for 3 issues that we need to avoid:
- Code with side effects that serve no purpose
- Dubious unnecessary dependencies
- Creeping hidden assumptions about the environment the code is running in
Ask yourself this: do you want the code that handles your money contain a 4000 line library to print strings to a console?
(in many different colors and formats)