BlockstreamResearch / simplicity

Simplicity is a blockchain programming language designed as an alternative to Bitcoin script.
MIT License
301 stars 44 forks source link

Improve description of SIMPLICITY_ERR_HIDDEN #205

Open uncomputable opened 7 months ago

uncomputable commented 7 months ago

https://github.com/BlockstreamResearch/simplicity/blob/5e7976326156ac9db9b5f8695dd597e8e370e130/C/deserialize.c#L46

It is unclear what illegal children are.

Non-case nodes may not have hidden children, so these children are illegal. However, a case node may not have two hidden children, so these children are also illegal. SIMPLICITY_ERR_HIDDEN is returned in both cases.

apoelstra commented 7 months ago

HIDDEN children are illegal if they don't occur as part of an assertion.

Agreed, this text should be improved.

roconnor-blockstream commented 6 months ago

illegal HIDDEN children is formally defined in https://github.com/BlockstreamResearch/simplicity/blob/5e7976326156ac9db9b5f8695dd597e8e370e130/C/dag.h#L308-L314 (technically that defines legal HIDDEN children).

I suppose I can break the various conditions of well-formedness into their own names. But I'm not going to copy the entire formal definition into the error message.

Let me see what I can do.

uncomputable commented 6 months ago

Maybe "The parent of a hidden node is not an assertion." Assertions are defined to be case nodes with one left or right hidden child.