Glow end point projection (EPP)
End-Point Projection is used to extract:
- Client code for each participant, in a client language.
- Contract code for each blockchain, in a contract language.
- Verified logical model for DApp, in a logical language.
These are called End-Point languages.
Simple implementation - Direct Style
Divide into interaction steps. Each step is the largest consecutive block of elementary actions (arithmetic, copying data etc…), which satisfy specific constraints.
Simple functions that can be completed within a single interaction step, can be inlined or translated into function calls in contract language.
For more complex control structures without such guarantee:
They have to be first reduced to data structure, using CPS.
Divide code into atomic blocks with only simple functions, and no change in participant.
Control structure replaced with explicit pushing / popping of frames to and from an explicit control stack.
For each action EPP generates:
- Client code for participant to perform the action
- Code in all other participants’ clients to check that the action is performed correctly. Or else take correction action.
- Code in the on-chain contract to verify whether action was performed correctly, and enact appropriate consequences.
- Logical specification of DApp behavior, when participant performs the action.
- Logical specification of DApp behavior, when participant fails to perform action.
- For each consensual action EPP generates:
- Code in all participants’ clients to perform action and monitor contract as it performs the action.
- Code in the on-chain contract to perform the action
- Logical specification of the DApp behavior as the contract performs the action.
- Each interaction step is then translated in the step’s active participant performing:
- in sequence all the actions in the step,
- finally sending a single message to the contract containing all the data published, together with all the assets transferred. We may merklize DApp state at this point.
- The contract will then verify that message is valid. That each action applies to the current state of the contract, and satisfies all requirements.
- Each participant watch the blockchain to see when the message is posted, and interaction step completed. They don’t have to do consensual checks, since contract enforces these.
- Each interaction step comes with a deadline, typically based on a time limit since previous interaction step.
- If participant fails to complete interaction step, other participants can send msg to contract to declare him default.
Why group into interaction steps?
consequences are the same regardless of which action in the group a participant stops cooperating at. It minimizes amount of messages exchanged between participants.
- Actions must be consecutive, by the participant or consensus.
- Boundary is when another participant takes an action / interaction protocol ends.