Good question. Actually the state is not stored in the reference but rather the inputs of the transactions that caused the state change. And the complete history of all these transactions is stored and linked. So therefore any participant can determine the current state by walking through the state changes in the block order that they were recorded. The validators are only concerned with the accounting of tokens so that there is no double spend. Therefore an functional operation of cryptocurrency would have to be done via state that is accessible to the validators. In that case, you’d have to use another technique such as ZKSnarks. Which on their current form are a bit slow for complex functions, but I image a combination of the two strategies my yield an acceptable solution for whatever your use case might be.