Atlassian uses cookies to improve your browsing experience, perform analytics and research, and conduct advertising. Accept all cookies to indicate that you agree to our use of cookies on your device.
Atlassian uses cookies to improve your browsing experience, perform analytics and research, and conduct advertising. Accept all cookies to indicate that you agree to our use of cookies on your device. Atlassian cookies and tracking notice, (opens new window)
This section describes the object model of the design.
Layers
According to Dan Boneh Blockchain applications may be divided into four layers:
3
User Interface
2
Applications
1.5
Compute Layer
1
Consensus Layer
We will use this classifications to group Iroha components and 3rd party components that can be integrated with Iroha components.
Components
Layer
Components
Description
User Interface
Iroha Clients + 3rd Party Clients
Web/Mobile/CLI
User Facing Services
Applications
Iroha Modules + Custom Iroha Special Instructions
Run on blockchain computer
Compute Layer
Iroha + Iroha Modules + Iroha Special Instructions
Application logic is encoded in a program that runs on blockchain • Rules are enforced by a public program (public source code) ➔ transparency: no single trusted 3rd party • The APP program is executed by parties who create new blocks ➔ public verifiability: anyone can verify state transitions
Consensus Layer
Iroha
Sumeragi
A public data structure (ledger) that provides:
Persistence: once added, data can never be removed
Consensus: all honest participants have the same data
Liveness: honest participants can add new transactions
Open(?): anyone can be a participant (no authentication)
Iroha receives Queries from Clients and execute them. More on that in Process View Section.
Process View
This section describes the activities of the system, captures the concurrency and synchronization aspects of the design.
Clients ↔ Peers Communications
Let's start with Iroha Peers - as described in WhitePaper, Iroha as a system is build on top of a Peer to Peer Network.
So by Peer we will assume every Iroha instance up and running.
@startuml
'default
top to bottom direction
:User Interface: --> (Submit Iroha Special Instruction)
:User Interface: --> (Send Iroha Query)
@enduml
So basically we have two main interaction scenarios:
Submission of Iroha Special Instructions
Every User Interface will use `iroha-client` under the hood, so we will look at the sequence with it:
@startuml
actor "User" as user
participant "Iroha Clinet" as client
participant "Iroha Network" as network
participant "Iroha" as iroha
participant "Transactions Queue" as queue
user -> client: submit(Instruction)
client -> client: build_transaction(Instruction)
client -> client: sign(Transaction)
client -> network: send(Transaction)
network -> iroha: request
iroha -> iroha: accept(Transaction)
alt successful case
iroha -> queue: push(Transaction)
iroha -> network: response(Ok)
network -> client: Ok
client -> user: Confirmation
else some kind of failure
iroha -> network: response(Error)
network -> client: Error
client -> user: Error Message
end
@enduml
Sending Iroha Queries
@startuml
actor "User" as user
participant "Iroha Clinet" as client
participant "Iroha Network" as network
participant "Iroha" as iroha
participant "World State View" as view
user -> client: request(Query)
client -> client: sign(Query)
client -> network: send(Query)
network -> iroha: request
iroha -> view: execute(Query)
alt successful case
view -> iroha: QueryResult
iroha -> network: response(Ok(QueryResult))
network -> client: Ok(QueryResult)
client -> user: Result
else some kind of failure
iroha -> network: response(Error)
network -> client: Error
client -> user: Error Message
end
@enduml
Peer ↔ Peer Communications
In this section we will look at Peer to Peer communications in different aspects:
Iroha Qeuries Processing
Let's start from the quite simple Iroha Queries Processing.
@startuml
start
:receive Query;
if (Authority has enough permissions?) then (yes)
:lock World State View;
:gather Data;
:return Result;
else (no)
:return Error;
endif
stop
@enduml
Iroha Transactions Processing
In this section we will cover only Transactions related part of the whole End to End process of Iroha Special Instructions execution.
Let's start from sequence:
@startuml
participant "Iroha Network" as network
participant "Torii" as torii
participant "Transactions Queue" as queue
network -> torii: request
torii -> torii: accept(Transaction)
alt successful case
torii -> queue: push(Transaction)
torii -> network: response(Ok)
else some kind of failure
torii -> network: response(Error)
end
@enduml
You already see this as a part of Submission of Iroha Special Instructions. Now we introduce Torii - which is Iroha Entity responsible for Network requests and Connections handling.
Queue is like a portal between Torii and another and the most important part of Iroha - Consensus.
Blocks Processing
Consensus works with group of Transactions called Blocks. The whole set of actions that it does with them too big so let's describe each item one by one.
Validation
We will briefly discuss roles that Peer can have, for more information read the White Paper.
In this case we will mainly consider Peer in a `Leader` role. We also will use `Sumeragi` as the only supported by the moment implementation of Consensus in Iroha.
@startuml
start
:round;
if (Queue has transaction to vote) then (yes)
if (Peer has the Leader role) then (yes)
:build PendingBlock;
:lock World State View;
:validate PendingBlok;
:send VotingBlock messages to peers;
else (no)
:send transactions to the leader;
endif
endif
stop
@enduml
As you can see, validation triggers next Consensus step.
Voting
The science behind Consensus (and Sumeragi) is fully described in the White Paper.
We will look at the high level and simple case of voting here:
@startuml
participant "Leader Peer" as leader
participant "Voting Peers" as peers
participant "Proxy Tail" as proxy
leader -> peers: BlockCreated
peers -> peers: validate(BlockCreated)
alt successful case
peers -> proxy: BlockSigned
alt enough signatures
proxy -> leader: BlockCommited
proxy -> peers: BlockCommited
proxy -> proxy: commit(block)
end
end
@enduml
As we can see - in simple cases we just sign valid Blocks by Voting Peers and then move to the next stage.
Commitment
This stage involves new Iroha entity - Kura in cooperation with already familiar to you World State View.
@startuml
participant "Consensus (Sumeragi)" as consensus
participant "Kura" as kura
participant "Storage" as storage
participant "World State View" as view
consensus -> kura: commit(ValidBlock)
kura -> storage: store(ValidBlock)
alt successful case
kura -> view: put(CommitedBlock)
end
@enduml
Synchronization
Some Peers may be "out of work" because of network or other issues. New Peers may be added. All of them need a mechanism to receive already committed blocks and stay in sync with Ledger.
@startuml
participant "Blocks Synchronizer" as synchronizer
participant "Peers" as peers
participant "Consensus (Sumeragi)" as consensus
synchronizer -> peers: LatestBlock
alt LatestBlock is next to the the current state
peers -> consensus: commit(LatestBlock)
end
@enduml
Development View
This section describes the static organization or structure of the software in its development of environment.
Great document!
Let's also add following stages and operations in the sequences when the decision will be made:
Permissions check
Trigger check and execution
Initial network setup (using the genesis block)