diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000000..4960fc5ca9 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "exonum-java-binding/common/src/main/proto"] + path = exonum-java-binding/common/src/main/proto + url = https://github.com/exonum/exonum-proto-sources.git diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9ed007afc7..375f7759b2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -23,6 +23,7 @@ You need to install the following dependencies: To install a specific Rust version, use `rustup install 1.36.0` command. * The [system dependencies](https://exonum.com/doc/version/0.12/get-started/install/) of Exonum. You do _not_ need to manually fetch and compile Exonum. + __Important__: On Mac OS it is necessary to install RocksDB package and to set the environment variable `ROCKSDB_LIB_DIR`. To install the package via Homebrew: @@ -36,6 +37,11 @@ You need to install the following dependencies: Also on Mac you need a [`coreutils`](https://formulae.brew.sh/formula/coreutils) package installed. ### Building +__Important__: Keep in mind that project contains git submodules and extra steps are required +to init and/or update them: + * `git submodule update --init` before the first build + * `git submodule update` when the submodule revision changes. + Set required environment variables, once in a shell you use to build the project: ```$sh $ source exonum-java-binding/tests_profile diff --git a/exonum-java-binding/common/pom.xml b/exonum-java-binding/common/pom.xml index f16cc1375d..4c3b15d8f0 100644 --- a/exonum-java-binding/common/pom.xml +++ b/exonum-java-binding/common/pom.xml @@ -147,6 +147,7 @@ com.google.protobuf:protoc:${protobuf.version}:exe:${os.detected.classifier} + ${basedir}/src/main/proto/src diff --git a/exonum-java-binding/common/src/main/proto b/exonum-java-binding/common/src/main/proto new file mode 160000 index 0000000000..1c0eb41fa9 --- /dev/null +++ b/exonum-java-binding/common/src/main/proto @@ -0,0 +1 @@ +Subproject commit 1c0eb41fa952b60c5709be616470d0b3fcf34300 diff --git a/exonum-java-binding/common/src/main/proto/blockchain.proto b/exonum-java-binding/common/src/main/proto/blockchain.proto deleted file mode 100644 index c194ea9ff1..0000000000 --- a/exonum-java-binding/common/src/main/proto/blockchain.proto +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2019 The Exonum Team -// -// 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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// 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. - -syntax = "proto3"; - -package exonum; - -import "types.proto"; - -option java_package = "com.exonum.binding.messages"; - -message Block { - uint32 proposer_id = 1; - uint64 height = 2; - uint32 tx_count = 3; - exonum.crypto.Hash prev_hash = 4; - exonum.crypto.Hash tx_hash = 5; - exonum.crypto.Hash state_hash = 6; -} - -message TxLocation { - uint64 block_height = 1; - uint64 position_in_block = 2; -} - -// Consensus configuration parameters - -// Public keys of a validator. -message ValidatorKeys { - // Consensus key is used for messages related to the consensus algorithm. - exonum.crypto.PublicKey consensus_key = 1; - // Service key is used for services, for example, the configuration - // updater service, the anchoring service, etc. - exonum.crypto.PublicKey service_key = 2; -} - -// Consensus algorithm parameters. -message Config { - // List of validators public keys. - repeated ValidatorKeys validator_keys = 1; - // Interval between first two rounds. - uint64 first_round_timeout = 2; - // Period of sending a Status message. - uint64 status_timeout = 3; - // Peer exchange timeout. - uint64 peers_timeout = 4; - // Maximum number of transactions per block. - uint32 txs_block_limit = 5; - // Maximum message length (in bytes). - uint32 max_message_len = 6; - // Minimal propose timeout. - uint64 min_propose_timeout = 7; - // Maximal propose timeout. - uint64 max_propose_timeout = 8; - // Amount of transactions in pool to start use `min_propose_timeout`. - uint32 propose_timeout_threshold = 9; -} diff --git a/exonum-java-binding/common/src/main/proto/common.proto b/exonum-java-binding/common/src/main/proto/common.proto deleted file mode 100644 index 3b58e771ed..0000000000 --- a/exonum-java-binding/common/src/main/proto/common.proto +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2019 The Exonum Team -// -// 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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// 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. - -syntax = "proto3"; - -package exonum.common; - -option java_package = "com.exonum.binding.messages"; - -message BitVec { - bytes data = 1; - uint64 len = 2; -} diff --git a/exonum-java-binding/common/src/main/proto/consensus.proto b/exonum-java-binding/common/src/main/proto/consensus.proto deleted file mode 100644 index a2f0428ccf..0000000000 --- a/exonum-java-binding/common/src/main/proto/consensus.proto +++ /dev/null @@ -1,143 +0,0 @@ -// Copyright 2019 The Exonum Team -// -// 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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// 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. - -// The messages collection for the default Exonum consensus implementation. - -syntax = "proto3"; - -package exonum.consensus; - -option java_package = "com.exonum.binding.messages"; - -import "types.proto"; -import "common.proto"; -import "blockchain.proto"; -import "runtime.proto"; -import "google/protobuf/timestamp.proto"; - -// Container for the signed messages. -// -// Keep in mind, that: -// hash(SignedMessage) = hash(payload || key.bytes || sign.bytes) -message SignedMessage { - // Message payload. - bytes payload = 1; - // Message author. - exonum.crypto.PublicKey author = 2; - // Digital signature. - exonum.crypto.Signature signature = 3; -} - -// List of consensus messages - -message Connect { - string host = 1; - google.protobuf.Timestamp time = 2; - string user_agent = 3; -} - -message Status { - uint64 height = 1; - exonum.crypto.Hash last_hash = 2; - uint64 pool_size = 3; -} - -message Propose { - uint32 validator = 1; - uint64 height = 2; - uint32 round = 3; - exonum.crypto.Hash prev_hash = 4; - repeated exonum.crypto.Hash transactions = 5; -} - -message Prevote { - uint32 validator = 1; - uint64 height = 2; - uint32 round = 3; - exonum.crypto.Hash propose_hash = 4; - uint32 locked_round = 5; -} - -message Precommit { - uint32 validator = 1; - uint64 height = 2; - uint32 round = 3; - exonum.crypto.Hash propose_hash = 4; - exonum.crypto.Hash block_hash = 5; - google.protobuf.Timestamp time = 6; -} - -message BlockResponse { - exonum.crypto.PublicKey to = 1; - exonum.Block block = 2; - repeated bytes precommits = 3; - repeated exonum.crypto.Hash transactions = 4; -} - -message TransactionsResponse { - exonum.crypto.PublicKey to = 1; - repeated bytes transactions = 2; -} - -message ProposeRequest { - exonum.crypto.PublicKey to = 1; - uint64 height = 2; - exonum.crypto.Hash propose_hash = 3; -} - -message TransactionsRequest { - exonum.crypto.PublicKey to = 1; - repeated exonum.crypto.Hash txs = 2; -} - -message PrevotesRequest { - exonum.crypto.PublicKey to = 1; - uint64 height = 2; - uint32 round = 3; - exonum.crypto.Hash propose_hash = 4; - exonum.common.BitVec validators = 5; -} - -message PeersRequest { exonum.crypto.PublicKey to = 1; } - -message BlockRequest { - exonum.crypto.PublicKey to = 1; - uint64 height = 2; -} - -message PoolTransactionsRequest { - exonum.crypto.PublicKey to = 1; -} - -message ExonumMessage { - oneof message { - exonum.runtime.AnyTx any_tx = 1; - Connect connect = 2; - Status status = 3; - - Precommit precommit = 4; - Propose propose = 5; - Prevote prevote = 6; - - TransactionsResponse transactions_response = 7; - BlockResponse block_response = 8; - - ProposeRequest propose_request = 9; - TransactionsRequest transactions_request = 10; - PrevotesRequest prevotes_request = 11; - PeersRequest peers_request = 12; - BlockRequest block_request = 13; - PoolTransactionsRequest pool_transactions_request = 14; - } -} diff --git a/exonum-java-binding/common/src/main/proto/runtime.proto b/exonum-java-binding/common/src/main/proto/runtime.proto deleted file mode 100644 index 91449ebe87..0000000000 --- a/exonum-java-binding/common/src/main/proto/runtime.proto +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright 2019 The Exonum Team -// -// 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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// 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. - -syntax = "proto3"; - -package exonum.runtime; - -/* - TODO: (All .proto) (1) Better package structure? - (2) Shall they all reside in common (i.e. are they all useful to any client)? - */ -option java_package = "com.exonum.binding.messages"; - -import "blockchain.proto"; -import "google/protobuf/empty.proto"; - -// Unique service transaction identifier. -message CallInfo { - // Unique service instance identifier. The dispatcher uses this identifier to find the - // corresponding runtime to execute a transaction. - uint32 instance_id = 1; - // Identifier of the method in the service interface required for the call. - uint32 method_id = 2; -} - -message AnyTx { - CallInfo call_info = 1; - bytes arguments = 2; -} - -message ArtifactId { - uint32 runtime_id = 1; - string name = 2; -} - -message InstanceSpec { - uint32 id = 1; - string name = 2; - ArtifactId artifact = 3; -} - -/// Result of unsuccessful runtime execution. -message ExecutionError { - /// The kind of error that indicates in which module the error occurred. - uint32 kind = 1; - /// User defined error code that can have different meanings for the different - /// error kinds. - uint32 code = 2; - /// Optional description which doesn't affect `object_hash`. - string description = 3; -} - -/// Result of runtime execution. -message ExecutionStatus { - oneof result { - google.protobuf.Empty ok = 1; - ExecutionError error = 2; - } -} - -// Configuration parameters of the certain service instance. -message ServiceConfig { - // Corresponding service instance ID. - uint32 instance_id = 1; - // Raw bytes representation of service configuration parameters. - bytes params = 2; -} - -// This message contains one atomic configuration change. -message ConfigChange { - oneof message { - // New consensus config. - exonum.Config consensus = 1; - // New service instance config. - ServiceConfig service = 2; - } -} diff --git a/exonum-java-binding/common/src/main/proto/types.proto b/exonum-java-binding/common/src/main/proto/types.proto deleted file mode 100644 index c968fb52d3..0000000000 --- a/exonum-java-binding/common/src/main/proto/types.proto +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2019 The Exonum Team -// -// 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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// 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. - -syntax = "proto3"; - -package exonum.crypto; - -option java_package = "com.exonum.binding.messages"; - -message Hash { bytes data = 1; } - -message PublicKey { bytes data = 1; } - -message Signature { bytes data = 1; }