Gas Limits

Ethereum contract development has required me to rethink how I develop and architect software.  There is so many things that are fundamentally different than the software I've crafted thus far.  The current gas limit has turned out to be an interesting limitation.  If you take a look at the latest transaction that deployed the 0.2.0 version of the Alarm service, you'll see that it used 3,116,311 out of the maximum limit of 3,141,592 leaving just 25,281 gas worth of wiggle room.

Alarm was written initially as a single contract, and currently has it's business logic divided between two contracts (technically 4 if you want to count the two Relay contracts).   When I started getting close to a launchable version of the code, I realized that I was significantly over the gas limit at 5.5 million gas.  Enabling the compiler optimization got it down to 3.5 million gas.  Cutting all the logging statements got it down to 3.2 million gas.  And finally, commenting out a few non mission critical chunks of code dropped it to just under the pi-million ceiling.

I think the current limit is still a bit low for contracts that want to do something non-trivial.  However, I think that the limit also helps enforce modularity and compartmentalization of functionality.  One prime example of this is the structure that is used to store and query the scheduled calls.  It provides a quick way to store and lookup ordered data by traversing down into the tree in largely the same way that a binary search works.  I intend to try and separate it out from the main codebase into it's own contract that anyone can use.  I could see it being the start of a set of database contracts that improve the ways that we can query data.

With the recent support for use of another contract's code as library code without inheritance this may become even easier, allowing contracts to take advantage of the contract's code, while operating on it's own memory space.  It may turn out that one way to construct large services is to write all of it's business logic in independently deployable contracts that are all used as library code by some smaller set of master contracts which only implement the necessary storage locations.

As these small pieces of usefulness are starting to make there way onto the network, and I expect contract development to get easier as more and more show up.  It's looking like a pretty amazing place to write code.