Call For Action: "Standard Solidity Library"
Solidity is quickly improving thanks to the work of everyone involved. The compiler is getting in a better shape every day and providing the low level features nicely, however support for higher level features still needs to improve. Many have created helper functions, but all these efforts are scattered around in different places.
I have created a tree called density as a start to this effort. So far it contains a very limited set of features:
I've did the above a week ago, but only pushed it now. I have also some string utilities, such as conversion of address to string, which I haven't committed yet.
I wasn't able to find everything via Google before, but now more and more such snippets have surfaced. Either I'm getting bad at using Google or it is harder to get meaningful results out of it. The following "libraries" already exists out there:
I think the standard library should contain:
I don’t think it should go into dapp-bin, but a separate tree for the library only. And that tree probably should belong to an org on github as opposed to a person.
The questions are:
Based on git history, the following users have contributed to the libraries: @chriseth, @fivedogit, @obscuren, @bertani, @pipermerriam. Calling all you guys for input.
Appendix A. - List of useful helpers
In my opinion, the library should be extremely well documented using natspec and if possible, it should be formally verified.
It should also be semantically versioned, potentially providing a "staging area" with proposed updates which can be discussed and then accepted or rejected/amended.
Are there any opinions against putting it inside the solidity repository?
the library should be extremely well documented using natspec and if possible
+1. I'm in favor of requiring inclusion of proper natspec as well as documentation.
it should be formally verified.
Future requirement? This isn't currently doable correct?
It should also be semantically versioned
+1 but we should be sure to declare what semantic versioning means.
Are there any opinions against putting it inside the solidity repository?
I would like to be able to have the documentation live alongside the code. Readthedocs is an easy to configure resource for this sort of thing, so if it goes in the solidity library, I'd like for the docs to be able to live in the same branch as the code (as opposed to the ghpages branch that the current docs have to live in. If they aren't side-by-side, it's hard to enforce documentation with code modifications and additions.
I'm advocating a hard requirement of documentation because a culture of good documentation will pay us back 10 fold in making it easier for new devs to get up to speed.
My gut feel is that although it would be nice to have standard APIs in the standard libraries, it's a bit too early to start pushing them in there. We don't quite know where these standards will go. Even now, we are changing it (https://gist.github.com/frozeman/090ae32041bcfe120824).
are functions a first-class citizen in solidity? if so, it would be great to have the map(), flatMap(), filter() and reduce() constructs at the very least!
and if they're not, then maybe using an "functional interface" equivalent as java 8 does...
@anthony-cros hopefully, soon: https://www.pivotaltracker.com/n/projects/1189488/stories/101758856
Not sure if it's been fixed, but last time I documented with natspec it was not possible to document multiple return-values (like you do multiple params). It works, but it isn't formatted properly in devdoc. Natspec in general feels a bit under-developed, Perhaps start in that end?
I would be happy to contribute to this in any way I can, code, documentation, tests. Especially tests. I can probably put in as much as 20-25% time.
I think it is essential to have some way to run code directly through the EVM for testing. If the standard library is put in the Solidity rep like suggested, it would be simple to write either a separate suite or maybe include it in the regular library tests, depending on what's best.
Any updates on this project/issue?
I'm doing some contract that might make it in at some point (in fact I do them on chriseth's request), including a secp256k1 implementation, some string stuff etc. Gonna have RLP encoding/decoding and other Ethereum related functionality as well.
There is still the issue of how tests will be carried out and such, which is why i work in a separate repo. There's a new issue on how to do it from RPC (https://github.com/ethereum/solidity/issues/516), and when that's been settled maybe they will be accepted into official Solidity stl. In that case I will port the tests to that system.
Standard library!
(Made by a group of people that checks each-others code etc.)
See also @vbuterin's post: https://blog.ethereum.org/2016/06/19/thinking-smart-contract-security/
take common patterns and hardcode them ... create as many standardized mid-level components as possible
This is an ongoing process and will never be "closed", although we need a kind of "registry" of library contracts. I hope that tools like dapphub and live-libs can fill this gap soon.
support for bitwise operators until EVM and Solidity supports it natively
This from the original discussion is not a concern anymore after #527 is done.
Most helpful comment
are functions a first-class citizen in solidity? if so, it would be great to have the
map(),flatMap(),filter()andreduce()constructs at the very least!and if they're not, then maybe using an "functional interface" equivalent as java 8 does...