Today I started dogfooding in my development of the contracts which back the EthPM.com package registry.

Eating your own dog food, also called dogfooding, is a slang term used to reference a scenario in which a company uses its own product to test and promote the product.

- https://en.wikipedia.org/wiki/Eating_your_own_dog_food

The smart contracts which makeup the package index include two libraries.

SemVersionLib : A library which handles version comparisons as defined by the semver spec.

: A library which handles version comparisons as defined by the semver spec. IndexedEnumerableSetLib : A library which implements an enumerable set struct with O(1) existence, addition, and removal operations.

The SemVersionLib library is used to ensure that package authors may only release new versions. For example if 1.0.1 and 1.0.3 have been released but there was never a 1.0.2 release you are not allowed to backfill that version.

Proper version comparison as laid out by the semver spec isn’t trivial so if you need to do version number comparisons, feel free to use the sem-version-lib package.

The IndexedEnumerableSetLib library is a relatively simple abstraction for a common use case we had in the package index codebase. We needed a datatype with all of the following features.

Array-like in that it can be enumerated (but ordering doesn’t matter).

Mapping-like in that it only contains one instance of any given item.

Constant time checks for existence

Constant time addition of new items

Constant time removal of items

If you find yourself in need of such a data type I’d suggest trying out indexed-enumerable-set-lib package rather than re-inventing the wheel.

Both of these packages have comprehensive test suites as well as deployed instances on both the mainnet and Ropsten testnet.

I ended up being blocked by a solidity bug so it may be a bit before I can ship these changes, but I’m already in love with how this hash improved my development workflow.