NebulousLabs/Sia — pull request #142 by lukechampine (2014-06-15 06:09:41+00:00)
Title: Scripting/bootstrap improvements

Various improvements to the bytecode. The bootstrap script now accepts two types of input. Support for signature verification has been added, but not yet incorporated into the bootstrapping process. `CombinedMessage()` was also replaced with `GobEncode()`/`GobDecode()` methods for `SignedMessage`.

I think one of the biggest weaknesses of the scripting system right now is input handling. There's no way to check that the input matches what you want; you just have to process it as if it were correct, and hope that bad input will cause one of the opcodes will fail. This is a stark departure from the vision of scripts verifying and either accepting or rejecting input.

To address this, I'd like to implement some rudimentary argument/type checking. I'm not sure what exactly the opcodes will look like, but probably some form of chained if-statement that calls reject if the condition fails. Since gob-encoded data is self-describing, it should be fairly easy to extract the type of a given argument. Unencoded types are a bit trickier though; i.e. how do you distinguish a uint64 from two int32s? Maybe all inputs should be gob-encoded? I'll have to think about this.