Skip to content
This repository has been archived by the owner on Jun 9, 2020. It is now read-only.

Update to Iroha V1, Akka & Monix library #21

Draft
wants to merge 19 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,4 @@ project/boot/
.cache

# End of https://www.gitignore.io/api/intellij,sbt
.bsp/
69 changes: 39 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,59 @@

Scala library for [Hyperledger Iroha](https://github.com/hyperledger/iroha).

## For end users

## Install
Add the following library dependency into your project:

Install [sbt](http://www.scala-sbt.org/0.13/docs/Setup.html).

```sh
git clone https://github.com/hyperledger/iroha-scala.git
cd iroha-scala
sbt publishLocal
```scala
libraryDependencies += "castleone" %% "iroha-akka" % "1.0.10"
```

## Usage
----

1. build.sbt
## For developers

```sh
libraryDependencies += "org.hyperledger" %% "iroha-scala" % "1.0.0"
```
### Requirements

## Test
* JDK8+ is required
* integration tests require one or more Iroha nodes
* a snapshot build of ed25519-sha3-java

### Building dependencies

Test required local iroha node with gRPC(50051).
```bash
#!/bin/bash

```sh
sbt test
mkdir ${HOME}/workspace
cd ${HOME}/workspace
git clone https://github.com/frgomes/ed25519-sha3-java
cd ed25519-sha3-java
git checkout RG0001-Code_review
./sbt publishLocal
```

## Compile proto
```
sbt compile
### Building iroha-scala

```bash
#!/bin/bash

mkdir ${HOME}/workspace
cd ${HOME}/workspace
git clone https://github.com/frgomes/iroha-scala
cd iroha-scala
git checkout RG0001-Code_review
./sbt compile
```

## License
### Unit tests

Copyright 2017 Daisuke SHIMADA.
```bash
#!/bin/bash

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
cd ${HOME}/workspace/iroha-scala
$ ./sbt test
```

http://www.apache.org/licenses/LICENSE-2.0
### Integration tests

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
TBD
35 changes: 35 additions & 0 deletions akka/src/main/protobuf/block.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* Copyright Soramitsu Co., Ltd. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/

syntax = "proto3";
package iroha.protocol;
import "primitive.proto";
import "transaction.proto";

message Block_v1 {
// everything that should be signed:
message Payload {
repeated Transaction transactions = 1;
uint32 tx_number = 2; ///< The number of accepted transactions inside.
///< Maximum 16384 or 2^14.
uint64 height = 3; ///< The current block number in a ledger.
string prev_block_hash = 4; ///< Previous block hash.
uint64 created_time = 5;

/// Hashes of the transactions that did not pass stateful validation.
/// Needed here to be able to guarantee the client that this transaction
/// was not and will never be executed.
repeated string rejected_transactions_hashes = 6;
}

Payload payload = 1;
repeated Signature signatures = 2;
}

message Block {
oneof block_version {
Block_v1 block_v1 = 1;
}
}
114 changes: 114 additions & 0 deletions akka/src/main/protobuf/commands.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
/**
* Copyright Soramitsu Co., Ltd. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/

syntax = "proto3";
package iroha.protocol;
import "primitive.proto";

message AddAssetQuantity {
string asset_id = 1;
string amount = 2;
}

message AddPeer {
Peer peer = 1;
}

message AddSignatory {
string account_id = 1;
string public_key = 2; // hex string
}

message CreateAsset {
string asset_name = 1;
string domain_id = 2;
uint32 precision = 3;
}

message CreateAccount {
string account_name = 1;
string domain_id = 2;
string public_key = 3; // hex string
}

message SetAccountDetail{
string account_id = 1;
string key = 2;
string value = 3;
}

message CreateDomain {
string domain_id = 1;
string default_role = 2;
}

message RemoveSignatory {
string account_id = 1;
string public_key = 2; // hex string
}

message SetAccountQuorum {
string account_id = 1;
uint32 quorum = 2;
}

message TransferAsset {
string src_account_id = 1;
string dest_account_id = 2;
string asset_id = 3;
string description = 4;
string amount = 5;
}

message AppendRole {
string account_id = 1;
string role_name = 2;
}

message DetachRole {
string account_id = 1;
string role_name = 2;
}

message CreateRole {
string role_name = 1;
repeated RolePermission permissions = 2;
}

message GrantPermission {
string account_id = 1;
GrantablePermission permission = 2;
}

message RevokePermission {
string account_id = 1;
GrantablePermission permission = 2;
}

message SubtractAssetQuantity {
string asset_id = 1;
string amount = 2;
}

message Command {
oneof command {
AddAssetQuantity add_asset_quantity = 1;
AddPeer add_peer = 2;
AddSignatory add_signatory = 3;
AppendRole append_role = 4;
CreateAccount create_account = 5;
CreateAsset create_asset = 6;
CreateDomain create_domain = 7;
CreateRole create_role = 8;
DetachRole detach_role = 9;
GrantPermission grant_permission = 10;
RemoveSignatory remove_signatory = 11;
RevokePermission revoke_permission = 12;
SetAccountDetail set_account_detail = 13;
SetAccountQuorum set_account_quorum = 14;
SubtractAssetQuantity subtract_asset_quantity = 15;
TransferAsset transfer_asset = 16;
}
}
54 changes: 54 additions & 0 deletions akka/src/main/protobuf/endpoint.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/**
* Copyright Soramitsu Co., Ltd. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/

syntax = "proto3";

package iroha.protocol;

import "transaction.proto";
import "queries.proto";
import "qry_responses.proto";
import "google/protobuf/empty.proto";

enum TxStatus {
STATELESS_VALIDATION_FAILED = 0;
STATELESS_VALIDATION_SUCCESS = 1;
STATEFUL_VALIDATION_FAILED = 2;
STATEFUL_VALIDATION_SUCCESS = 3;
REJECTED = 4;
COMMITTED = 5;
MST_EXPIRED = 6;
NOT_RECEIVED = 7;
MST_PENDING = 8;
ENOUGH_SIGNATURES_COLLECTED = 9;
}

message ToriiResponse {
TxStatus tx_status = 1;
string tx_hash = 2;
string err_or_cmd_name = 3;
uint64 failed_cmd_index = 4;
uint32 error_code = 5;
}

message TxStatusRequest {
string tx_hash = 1;
}

message TxList {
repeated Transaction transactions = 1;
}

service CommandService_v1 {
rpc Torii (Transaction) returns (google.protobuf.Empty);
rpc ListTorii (TxList) returns (google.protobuf.Empty);
rpc Status (TxStatusRequest) returns (ToriiResponse);
rpc StatusStream(TxStatusRequest) returns (stream ToriiResponse);
}

service QueryService_v1 {
rpc Find (Query) returns (QueryResponse);
rpc FetchCommits (BlocksQuery) returns (stream BlockQueryResponse);
}
Loading