Question

This is a conceptual question about applying UML State Machine model for smart contracts in blockchain. I want to develop a smart contract framework in a bitcoin-like blockchain which is based on the state machine concept. It would allow to define state machine events, states and transitions as a smart contract configuration and execute it. So we would not need coding to implement many smart contract applications but just define an approriate state machine configuration.

I want to follow UML State Machine concepts as I believe it is well-defined and consistent. In short, UML State Machine supposes that there exist several kinds of events which trigger transitions from a state to state. If we try to apply UML StateMachine concepts on the blockchain ground we'll find that in blockchain most events would be transactions which spend or transfer coins from some addresses.

My problem is that the UML State Machine concepts are not sufficient for implementation of state machines in blockchain: UML allows to define a State Action so we could do something when a state machine transitions from a state to state. But I also need a state machine feature to prevent events to occur in the blockchain.

The simplest example is funds time locking. Let a StateMachine could be in two states: 'Coins Locked on Address' and 'Coins Unlocked on Address when Timeout Passed'.

So when it is in the first state I need to disable spending from that address where coins are locked. So I suppose this spending is a event which I need to either enable or disable, depending on the current state, but could not find in UML standard any support for event conditions.

The question is: Is there something in UML State Machine concepts that would allow for events to occur conditionally (when the StateMachine is in a pre-defined state).

Or maybe I'm wrong and I need to use another concept for this (that is, not the 'event' what I'm trying to use)?

Was it helpful?

Solution

You can't prevent an event from occurring, but you can ignore an event just by not specifying a transition or action to happen when the event occurs.

For example, if you want the system not to spend when the state is 'locked', then you just don't specify any action when the event 'spend request' occurs in that state, or you specify that the system generates an error upon receiving the event.

Remember, a state machine diagram represents the behavior of a particular subject (class, component, subsystem, whatever). Carefully choose and specify which subject that is. Sometimes, a problem may be solved by choosing a different subject, e.g. an overarching system.

OTHER TIPS

So I suppose this spending is a event which I need to either enable or disable, depending on the current state, but could not find in UML standard any support for event conditions.

I'm not sure about your states (the question is not detailed in that dimension), but you can use the abstraction of locked as a guard condition to prevent a transition:

State diagram with guard condition

Licensed under: CC-BY-SA with attribution
scroll top