Skip to content

Commit 655eb58

Browse files
Merge pull request #1183 from exonum/dynamic-services-upgraded-ECR-3664
Upgrade to newer core revision
2 parents 26b78eb + 6c203aa commit 655eb58

File tree

26 files changed

+653
-325
lines changed

26 files changed

+653
-325
lines changed

exonum-java-binding/common/src/main/java/com/exonum/binding/common/blockchain/TransactionResult.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
* code and an optional description. Unexpected errors include only a description.
3434
*/
3535
@AutoValue
36+
// todo: Fix the tx result support [ECR-3693]
3637
public abstract class TransactionResult {
3738

3839
/** The maximum allowed user-defined transaction error code. */

exonum-java-binding/common/src/main/java/com/exonum/binding/common/message/TransactionMessage.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,9 @@
2727
import com.exonum.binding.common.hash.HashCode;
2828
import com.exonum.binding.messages.Consensus;
2929
import com.exonum.binding.messages.Consensus.ExonumMessage;
30-
import com.exonum.binding.messages.Helpers;
31-
import com.exonum.binding.messages.Helpers.Signature;
3230
import com.exonum.binding.messages.Runtime.AnyTx;
3331
import com.exonum.binding.messages.Runtime.CallInfo;
32+
import com.exonum.binding.messages.Types;
3433
import com.google.protobuf.ByteString;
3534
import com.google.protobuf.InvalidProtocolBufferException;
3635
import com.google.protobuf.MessageLite;
@@ -191,11 +190,11 @@ public TransactionMessage sign(KeyPair keys, CryptoFunction crypto) {
191190
byte[] signature = crypto.signMessage(exonumMessage, keys.getPrivateKey());
192191

193192
Consensus.SignedMessage signedMessage = Consensus.SignedMessage.newBuilder()
194-
.setAuthor(Helpers.PublicKey.newBuilder()
193+
.setAuthor(Types.PublicKey.newBuilder()
195194
.setData(ByteString.copyFrom(authorPublicKey.toBytes()))
196195
.build())
197196
.setPayload(ByteString.copyFrom(exonumMessage))
198-
.setSignature(Signature.newBuilder()
197+
.setSignature(Types.Signature.newBuilder()
199198
.setData(ByteString.copyFrom(signature))
200199
.build())
201200
.build();

exonum-java-binding/common/src/main/proto/blockchain.proto

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,53 @@ syntax = "proto3";
1616

1717
package exonum;
1818

19-
import "helpers.proto";
19+
import "types.proto";
2020

2121
option java_package = "com.exonum.binding.messages";
2222

2323
message Block {
2424
uint32 proposer_id = 1;
2525
uint64 height = 2;
2626
uint32 tx_count = 3;
27-
exonum.Hash prev_hash = 4;
28-
exonum.Hash tx_hash = 5;
29-
exonum.Hash state_hash = 6;
30-
}
31-
32-
message ConfigReference {
33-
uint64 actual_from = 1;
34-
exonum.Hash cfg_hash = 2;
27+
exonum.crypto.Hash prev_hash = 4;
28+
exonum.crypto.Hash tx_hash = 5;
29+
exonum.crypto.Hash state_hash = 6;
3530
}
3631

3732
message TxLocation {
3833
uint64 block_height = 1;
3934
uint64 position_in_block = 2;
4035
}
36+
37+
// Consensus configuration parameters
38+
39+
// Public keys of a validator.
40+
message ValidatorKeys {
41+
// Consensus key is used for messages related to the consensus algorithm.
42+
exonum.crypto.PublicKey consensus_key = 1;
43+
// Service key is used for services, for example, the configuration
44+
// updater service, the anchoring service, etc.
45+
exonum.crypto.PublicKey service_key = 2;
46+
}
47+
48+
// Consensus algorithm parameters.
49+
message Config {
50+
// List of validators public keys.
51+
repeated ValidatorKeys validator_keys = 1;
52+
// Interval between first two rounds.
53+
uint64 first_round_timeout = 2;
54+
// Period of sending a Status message.
55+
uint64 status_timeout = 3;
56+
// Peer exchange timeout.
57+
uint64 peers_timeout = 4;
58+
// Maximum number of transactions per block.
59+
uint32 txs_block_limit = 5;
60+
// Maximum message length (in bytes).
61+
uint32 max_message_len = 6;
62+
// Minimal propose timeout.
63+
uint64 min_propose_timeout = 7;
64+
// Maximal propose timeout.
65+
uint64 max_propose_timeout = 8;
66+
// Amount of transactions in pool to start use `min_propose_timeout`.
67+
uint32 propose_timeout_threshold = 9;
68+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright 2019 The Exonum Team
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
syntax = "proto3";
16+
17+
package exonum.common;
18+
19+
option java_package = "com.exonum.binding.messages";
20+
21+
message BitVec {
22+
bytes data = 1;
23+
uint64 len = 2;
24+
}

exonum-java-binding/common/src/main/proto/consensus.proto

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,23 @@ package exonum.consensus;
2020

2121
option java_package = "com.exonum.binding.messages";
2222

23-
import "helpers.proto";
23+
import "types.proto";
24+
import "common.proto";
2425
import "blockchain.proto";
2526
import "runtime.proto";
2627
import "google/protobuf/timestamp.proto";
2728

2829
// Container for the signed messages.
2930
//
3031
// Keep in mind, that:
31-
// hash(SignedMessage) = hash(exonum_msg || key.bytes || sign.bytes)
32+
// hash(SignedMessage) = hash(payload || key.bytes || sign.bytes)
3233
message SignedMessage {
3334
// Message payload.
3435
bytes payload = 1;
3536
// Message author.
36-
exonum.PublicKey author = 2;
37+
exonum.crypto.PublicKey author = 2;
3738
// Digital signature.
38-
exonum.Signature signature = 3;
39+
exonum.crypto.Signature signature = 3;
3940
}
4041

4142
// List of consensus messages
@@ -48,75 +49,75 @@ message Connect {
4849

4950
message Status {
5051
uint64 height = 1;
51-
exonum.Hash last_hash = 2;
52+
exonum.crypto.Hash last_hash = 2;
5253
uint64 pool_size = 3;
5354
}
5455

5556
message Propose {
5657
uint32 validator = 1;
5758
uint64 height = 2;
5859
uint32 round = 3;
59-
exonum.Hash prev_hash = 4;
60-
repeated exonum.Hash transactions = 5;
60+
exonum.crypto.Hash prev_hash = 4;
61+
repeated exonum.crypto.Hash transactions = 5;
6162
}
6263

6364
message Prevote {
6465
uint32 validator = 1;
6566
uint64 height = 2;
6667
uint32 round = 3;
67-
exonum.Hash propose_hash = 4;
68+
exonum.crypto.Hash propose_hash = 4;
6869
uint32 locked_round = 5;
6970
}
7071

7172
message Precommit {
7273
uint32 validator = 1;
7374
uint64 height = 2;
7475
uint32 round = 3;
75-
exonum.Hash propose_hash = 4;
76-
exonum.Hash block_hash = 5;
76+
exonum.crypto.Hash propose_hash = 4;
77+
exonum.crypto.Hash block_hash = 5;
7778
google.protobuf.Timestamp time = 6;
7879
}
7980

8081
message BlockResponse {
81-
exonum.PublicKey to = 1;
82+
exonum.crypto.PublicKey to = 1;
8283
exonum.Block block = 2;
8384
repeated bytes precommits = 3;
84-
repeated exonum.Hash transactions = 4;
85+
repeated exonum.crypto.Hash transactions = 4;
8586
}
8687

8788
message TransactionsResponse {
88-
exonum.PublicKey to = 1;
89+
exonum.crypto.PublicKey to = 1;
8990
repeated bytes transactions = 2;
9091
}
9192

9293
message ProposeRequest {
93-
exonum.PublicKey to = 1;
94+
exonum.crypto.PublicKey to = 1;
9495
uint64 height = 2;
95-
exonum.Hash propose_hash = 3;
96+
exonum.crypto.Hash propose_hash = 3;
9697
}
9798

9899
message TransactionsRequest {
99-
exonum.PublicKey to = 1;
100-
repeated exonum.Hash txs = 2;
100+
exonum.crypto.PublicKey to = 1;
101+
repeated exonum.crypto.Hash txs = 2;
101102
}
102103

103104
message PrevotesRequest {
104-
exonum.PublicKey to = 1;
105+
exonum.crypto.PublicKey to = 1;
105106
uint64 height = 2;
106107
uint32 round = 3;
107-
exonum.Hash propose_hash = 4;
108-
exonum.BitVec validators = 5;
108+
exonum.crypto.Hash propose_hash = 4;
109+
exonum.common.BitVec validators = 5;
109110
}
110111

111-
message PeersRequest { exonum.PublicKey to = 1; }
112+
message PeersRequest { exonum.crypto.PublicKey to = 1; }
112113

113114
message BlockRequest {
114-
exonum.PublicKey to = 1;
115+
exonum.crypto.PublicKey to = 1;
115116
uint64 height = 2;
116117
}
117118

118119
message PoolTransactionsRequest {
119-
exonum.PublicKey to = 1;
120+
exonum.crypto.PublicKey to = 1;
120121
}
121122

122123
message ExonumMessage {

exonum-java-binding/common/src/main/proto/runtime.proto

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,21 @@ syntax = "proto3";
1616

1717
package exonum.runtime;
1818

19+
/*
20+
TODO: (All .proto) (1) Better package structure?
21+
(2) Shall they all reside in common (i.e. are they all useful to any client)?
22+
*/
1923
option java_package = "com.exonum.binding.messages";
2024

25+
import "blockchain.proto";
2126
import "google/protobuf/empty.proto";
2227

2328
// Unique service transaction identifier.
2429
message CallInfo {
25-
// Service instance identifier.
30+
// Unique service instance identifier. The dispatcher uses this identifier to find the
31+
// corresponding runtime to execute a transaction.
2632
uint32 instance_id = 1;
27-
// Identifier of method in service interface to call.
33+
// Identifier of the method in the service interface required for the call.
2834
uint32 method_id = 2;
2935
}
3036

@@ -62,3 +68,21 @@ message ExecutionStatus {
6268
ExecutionError error = 2;
6369
}
6470
}
71+
72+
// Configuration parameters of the certain service instance.
73+
message ServiceConfig {
74+
// Corresponding service instance ID.
75+
uint32 instance_id = 1;
76+
// Raw bytes representation of service configuration parameters.
77+
bytes params = 2;
78+
}
79+
80+
// This message contains one atomic configuration change.
81+
message ConfigChange {
82+
oneof message {
83+
// New consensus config.
84+
exonum.Config consensus = 1;
85+
// New service instance config.
86+
ServiceConfig service = 2;
87+
}
88+
}

exonum-java-binding/common/src/main/proto/helpers.proto renamed to exonum-java-binding/common/src/main/proto/types.proto

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
syntax = "proto3";
1616

17-
package exonum;
17+
package exonum.crypto;
1818

1919
option java_package = "com.exonum.binding.messages";
2020

@@ -23,8 +23,3 @@ message Hash { bytes data = 1; }
2323
message PublicKey { bytes data = 1; }
2424

2525
message Signature { bytes data = 1; }
26-
27-
message BitVec {
28-
bytes data = 1;
29-
uint64 len = 2;
30-
}

exonum-java-binding/common/src/test/java/com/exonum/binding/common/message/ParsedTransactionMessageTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525
import com.exonum.binding.messages.Consensus;
2626
import com.exonum.binding.messages.Consensus.ExonumMessage;
2727
import com.exonum.binding.messages.Consensus.Prevote;
28-
import com.exonum.binding.messages.Helpers;
29-
import com.exonum.binding.messages.Helpers.Signature;
3028
import com.exonum.binding.messages.Runtime.AnyTx;
3129
import com.exonum.binding.messages.Runtime.CallInfo;
30+
import com.exonum.binding.messages.Types;
31+
import com.exonum.binding.messages.Types.Signature;
3232
import com.google.protobuf.ByteString;
3333
import com.google.protobuf.InvalidProtocolBufferException;
3434
import nl.jqno.equalsverifier.EqualsVerifier;
@@ -63,7 +63,7 @@ void createSignedMessage() {
6363
.toByteArray();
6464

6565
signedMessage = aSignedMessageProto()
66-
.setAuthor(Helpers.PublicKey.newBuilder()
66+
.setAuthor(Types.PublicKey.newBuilder()
6767
.setData(ByteString.copyFrom(authorPublicKey.toBytes()))
6868
.build())
6969
.setPayload(ByteString.copyFrom(exonumMessage))
@@ -163,7 +163,7 @@ private static Consensus.SignedMessage signedConsensusMessage(String payload) {
163163
private static Consensus.SignedMessage.Builder aSignedMessageProto() {
164164
return Consensus.SignedMessage.newBuilder()
165165
// Set the author only and keep the rest as defaults as the parser requires a non-empty key
166-
.setAuthor(Helpers.PublicKey.newBuilder()
166+
.setAuthor(Types.PublicKey.newBuilder()
167167
.setData(ByteString.copyFrom(bytes(1, 2, 3, 4)))
168168
.build());
169169
}

exonum-java-binding/common/src/test/java/com/exonum/binding/common/message/SignedMessageTest.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
import com.exonum.binding.common.hash.HashCode;
3030
import com.exonum.binding.messages.Consensus;
3131
import com.exonum.binding.messages.Consensus.ExonumMessage;
32-
import com.exonum.binding.messages.Helpers;
33-
import com.exonum.binding.messages.Helpers.Signature;
32+
import com.exonum.binding.messages.Types;
33+
import com.exonum.binding.messages.Types.Signature;
3434
import com.google.protobuf.ByteString;
3535
import com.google.protobuf.InvalidProtocolBufferException;
3636
import org.junit.jupiter.api.BeforeEach;
@@ -51,11 +51,11 @@ class ParsedFromTestData {
5151
@BeforeEach
5252
void createProtoMessage() {
5353
payload = ExonumMessage.getDefaultInstance();
54-
Helpers.PublicKey authorPk = aPublicKey()
54+
Types.PublicKey authorPk = aPublicKey()
5555
.setData(ByteString.copyFrom(TEST_PUBLIC_KEY.toBytes()))
5656
.build();
5757
testSignature = new byte[Ed25519.SIGNATURE_BYTES];
58-
Helpers.Signature signature = aSignature()
58+
Types.Signature signature = aSignature()
5959
.setData(ByteString.copyFrom(testSignature))
6060
.build();
6161
message = Consensus.SignedMessage.newBuilder()
@@ -105,8 +105,8 @@ void parseFromWrongMessage() {
105105
void parseFromPayloadNotExonumMessage() {
106106
ByteString invalidPayload = ByteString.copyFrom(
107107
bytes("Invalid payload: not an ExonumMessage"));
108-
Helpers.PublicKey authorPk = aPublicKey().build();
109-
Helpers.Signature signature = aSignature().build();
108+
Types.PublicKey authorPk = aPublicKey().build();
109+
Types.Signature signature = aSignature().build();
110110
byte[] message = Consensus.SignedMessage.newBuilder()
111111
.setPayload(invalidPayload)
112112
.setAuthor(authorPk)
@@ -118,12 +118,12 @@ void parseFromPayloadNotExonumMessage() {
118118
assertThrows(InvalidProtocolBufferException.class, () -> SignedMessage.parseFrom(message));
119119
}
120120

121-
private static Helpers.PublicKey.Builder aPublicKey() {
122-
return Helpers.PublicKey.newBuilder()
121+
private static Types.PublicKey.Builder aPublicKey() {
122+
return Types.PublicKey.newBuilder()
123123
.setData(ByteString.copyFrom(TEST_PUBLIC_KEY.toBytes()));
124124
}
125125

126-
private static Helpers.Signature.Builder aSignature() {
126+
private static Types.Signature.Builder aSignature() {
127127
byte[] testSignature = new byte[Ed25519.SIGNATURE_BYTES];
128128
return Signature.newBuilder()
129129
.setData(ByteString.copyFrom(testSignature));

0 commit comments

Comments
 (0)