Skip to content

Commit 7a0ed8c

Browse files
authored
Prepare 1.0 release [ECR-4377] (#59)
1 parent 41c81b4 commit 7a0ed8c

28 files changed

+322
-167
lines changed

README.md

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ The following table shows versions compatibility:
3131
|--------------|-------------------------|
3232
| 0.1 | 0.9.* |
3333
| 0.2 | 0.10.* |
34-
| 0.3.x | 0.12.* |
35-
| master | dynamic_services branch |
34+
| 0.3.1 | 0.12.* |
35+
| 1.0.x | 1.0.* |
36+
| master | `exonum` master branch |
3637

3738
## System Dependencies
3839

@@ -180,32 +181,44 @@ working services:
180181

181182
```python
182183
{
183-
'artifacts': [
184+
"artifacts": [
184185
{
185-
'runtime_id': 0,
186-
'name': 'exonum-cryptocurrency-advanced:1.0.0'
186+
"runtime_id": 0,
187+
"name": "exonum-supervisor",
188+
"version": "1.0.0"
187189
},
188190
{
189-
'runtime_id': 0,
190-
'name': 'exonum-supervisor:1.0.0'
191+
"runtime_id": 0,
192+
"name": "exonum-explorer-service",
193+
"version": "1.0.0"
191194
}
192195
],
193-
'services': [
196+
"services": [
194197
{
195-
'id': 1024,
196-
'name': 'XNM',
197-
'artifact': {
198-
'runtime_id': 0,
199-
'name': 'exonum-cryptocurrency-advanced:1.0.0'
200-
}
198+
"spec": {
199+
"id": 2,
200+
"name": "explorer",
201+
"artifact": {
202+
"runtime_id": 0,
203+
"name": "exonum-explorer-service",
204+
"version": "1.0.0"
205+
}
206+
},
207+
"status": "Active",
208+
"pending_status": null
201209
},
202210
{
203-
'id': 0,
204-
'name': 'supervisor',
205-
'artifact': {
206-
'runtime_id': 0,
207-
'name': 'exonum-supervisor:1.0.0'
208-
}
211+
"spec": {
212+
"id": 0,
213+
"name": "supervisor",
214+
"artifact": {
215+
"runtime_id": 0,
216+
"name": "exonum-supervisor",
217+
"version": "1.0.0"
218+
}
219+
},
220+
"status": "Active",
221+
"pending_status": null
209222
}
210223
]
211224
}

docs/conf.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@
1414
import os
1515
import sys
1616

17-
sys.path.insert(0, os.path.abspath("../exonum"))
17+
sys.path.insert(0, os.path.abspath("../exonum_client"))
1818

1919

2020
# -- Project Information -----------------------------------------------------
2121

2222
project = "Exonum Python light client"
23-
copyright = "2019, The Exonum team"
23+
copyright = "2020, The Exonum team"
2424
author = "The Exonum team"
2525

2626
# The full version, including alpha/beta/rc tags:
27-
release = "0.3.0"
27+
release = "1.0.0"
2828

2929

3030
# -- General Configuration ---------------------------------------------------
@@ -65,6 +65,9 @@
6565
# unit titles (such as .. function::):
6666
add_module_names = False
6767

68+
# Mock pysodium so there will be no need in libsodium for building docs
69+
autodoc_mock_imports = ["pysodium"]
70+
6871
# -- Options for HTML Output -------------------------------------------------
6972

7073
# The theme to use for HTML and HTML Help pages. See the documentation for

docs/index.rst

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -151,42 +151,44 @@ list of working services:
151151

152152
>>> client.public_api.available_services().json()
153153
{
154-
'artifacts': [
154+
"artifacts": [
155155
{
156-
'runtime_id': 0,
157-
'name': 'exonum-cryptocurrency-advanced',
158-
'version': '0.12.0'
156+
"runtime_id": 0,
157+
"name": "exonum-supervisor",
158+
"version": "1.0.0"
159159
},
160160
{
161-
'runtime_id': 0,
162-
'name': 'exonum-supervisor',
163-
'version': '0.12.0'
161+
"runtime_id": 0,
162+
"name": "exonum-explorer-service",
163+
"version": "1.0.0"
164164
}
165165
],
166-
'services': [
166+
"services": [
167167
{
168-
'spec': {
169-
'id': 1024,
170-
'name': 'XNM',
171-
'artifact': {
172-
'runtime_id': 0,
173-
'name': 'exonum-cryptocurrency-advanced',
174-
'version': '0.12.0'
168+
"spec": {
169+
"id": 2,
170+
"name": "explorer",
171+
"artifact": {
172+
"runtime_id": 0,
173+
"name": "exonum-explorer-service",
174+
"version": "1.0.0"
175175
}
176176
},
177-
'status': 'Active'
177+
"status": "Active",
178+
"pending_status": null
178179
},
179180
{
180-
'spec': {
181-
'id': 0,
182-
'name': 'supervisor',
183-
'artifact': {
184-
'runtime_id': 0,
185-
'name': 'exonum-supervisor',
186-
'version': '0.12.0'
181+
"spec": {
182+
"id": 0,
183+
"name": "supervisor",
184+
"artifact": {
185+
"runtime_id": 0,
186+
"name": "exonum-supervisor",
187+
"version": "1.0.0"
187188
}
188189
},
189-
'status': 'Active'
190+
"status": "Active",
191+
"pending_status": null
190192
}
191193
]
192194
}

examples/README.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ Recommended order is the following:
88
- [api.py](api.py): Minimal example demonstrating how to initialize the client
99
and retrieve some information via REST API.
1010
- [protobuf.py](protobuf.py): Example of downloading and compiling Protobuf
11-
sources from the Exonum.
11+
sources received from the Exonum node.
12+
- [custom_protobuf_source.py](custom_protobuf_source.py): Example of downloading
13+
and compiling Protobuf sources received from different sources
14+
(github of filesystem).
1215
- [deploy.py](deploy.py): Sample script that deploys an artifact and starts a
1316
service instance.
1417
- [transactions.py](transactions.py): Sample script that uses the deployed and
@@ -37,17 +40,21 @@ pip install -e . --no-binary=protobuf
3740
Then, run the `exonum-cryptocurrency-advanced` example in the `run-dev` mode:
3841

3942
```sh
40-
exonum-cryptocurrency-advanced run-dev -a /tmp/crypt
43+
exonum-cryptocurrency-advanced run-dev -p /tmp/crypt
4144
```
4245

43-
`/tmp/crypt` here is a folder for temporary files of `exonum-cryptocurrency-advanced`.
46+
`/tmp/crypt` is a folder for temporary config and data files created
47+
by the `exonum-cryptocurrency-advanced` process.
4448

45-
You may optionally call `rm -rf /tmp/crypt` as well, if this is not the first launch.
49+
You may optionally run with `--clean` option as well, if this is not the first launch.
4650

4751
Then, you can run any example:
4852

4953
```sh
5054
python examples/api.py
55+
python examples/custom_protobuf_source.py
5156
python examples/deploy.py
57+
python examples/proofs.py
58+
python examples/protobuf.py
5259
python examples/transactions.py
5360
```

examples/custom_protobuf_source.py

Lines changed: 43 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,77 +5,89 @@
55
of actual one).
66
77
Though this may be not really useful (since light client itself is not compatible with Exonum
8-
0.12), it can be extrapolated to other use cases, e.g. work with other runtimes that do not
8+
1.0.0), it can be extrapolated to other use cases, e.g. work with other runtimes that do not
99
support obtaining protobuf sources from REST API.
1010
"""
1111
from exonum_client.protobuf_provider import ProtobufProvider
1212
from exonum_client import ExonumClient, ModuleManager
1313

1414
RUST_RUNTIME_ID = 0
15-
SERVICE_VERSION = "0.12"
15+
SERVICE_NAME = "cryptocurrency-advanced"
16+
SERVICE_VERSION = "0.2.0"
1617

1718

18-
def setup_protobuf_provider(protobuf_provider: ProtobufProvider) -> None:
19-
"""Setups a protobuf provider with main protobuf sources and cryptocurrency-advanced sources for v0.12.
19+
def setup_protobuf_provider(protobuf_provider: ProtobufProvider, source: str) -> None:
20+
"""Setups a protobuf provider with main protobuf sources and cryptocurrency-advanced sources for v0.2.0.
2021
2122
Exonum client creates a ProtobufProvider object during its initialization, so we take it here
2223
and just extend with new sources."""
23-
main_sources_url = "https://github.com/exonum/exonum/tree/v0.12/exonum/src/proto/schema/exonum"
24-
cryptocurrency_sources_url = (
25-
"https://github.com/exonum/exonum/tree/v0.12/examples/cryptocurrency-advanced/backend/src/proto"
26-
)
27-
protobuf_provider.add_main_source(main_sources_url)
28-
protobuf_provider.add_service_source(cryptocurrency_sources_url, "cryptocurrency-advanced", SERVICE_VERSION)
2924

25+
if source == "github":
26+
main_sources_url = "https://github.com/exonum/exonum-proto-sources/tree/master/src/exonum"
27+
cryptocurrency_sources_url = (
28+
"https://github.com/exonum/exonum/tree/v1.0.0/examples/cryptocurrency-advanced/backend/src/proto"
29+
)
30+
elif source == "file":
31+
main_sources_url = "../tests/proto_dir/proto/main"
32+
cryptocurrency_sources_url = "../tests/proto_dir/proto/exonum_cryptocurrency_advanced_1_0_0"
33+
else:
34+
raise RuntimeError("Wrong location type for protobuf loader")
35+
36+
protobuf_provider.add_main_source(main_sources_url)
37+
protobuf_provider.add_service_source(cryptocurrency_sources_url, SERVICE_NAME, SERVICE_VERSION)
3038

31-
def run() -> None:
32-
"""Example of downloading the Protobuf sources and using the compiled
33-
module."""
3439

40+
def run_example(source: str) -> None:
3541
# Create client.
3642
client = ExonumClient(hostname="127.0.0.1", public_api_port=8080, private_api_port=8081)
3743

3844
# Setup protobuf provider.
39-
setup_protobuf_provider(client.protobuf_provider)
45+
setup_protobuf_provider(client.protobuf_provider, source)
4046

4147
# Create ProtobufLoader via context manager (so that we will not have to
4248
# initialize/deinitialize it manually):
4349
with client.protobuf_loader() as loader:
4450
# Load core proto files:
4551
loader.load_main_proto_files()
4652
# Load proto files for the Exonum supervisor service:
47-
loader.load_service_proto_files(RUST_RUNTIME_ID, "cryptocurrency-advanced", SERVICE_VERSION)
53+
loader.load_service_proto_files(RUST_RUNTIME_ID, SERVICE_NAME, SERVICE_VERSION)
4854

49-
# Load the main module (helpers.proto).
50-
helpers_module = ModuleManager.import_main_module("helpers")
55+
# Load the main module (exonum/crypto/type.proto).
56+
types_module = ModuleManager.import_main_module("exonum.crypto.types")
5157

5258
# Create a Protobuf message object:
53-
public_key = helpers_module.PublicKey()
59+
public_key = types_module.PublicKey()
5460
public_key.data = bytes(i for i in range(32))
5561

56-
# Load the service module (cryptocurrency.proto from the cryptocurrency-advanced service).
57-
# Note that we load "cryptocurrency" module, which is absent in current version
58-
# of service, it only exists in Exonum 0.12.
59-
service_module = ModuleManager.import_service_module(
60-
"cryptocurrency-advanced", SERVICE_VERSION, "cryptocurrency"
61-
)
62-
# Note that if we want to work with service module, we should use helpers also from that module.
62+
# Load the service module (service.proto from the cryptocurrency-advanced service).
63+
# Note that we load "service" module, which is absent in current version
64+
# of the service, it only exists in Exonum 1.0.
65+
service_module = ModuleManager.import_service_module(SERVICE_NAME, SERVICE_VERSION, "service")
66+
# Note that if we want to work with service module, we should use types also from that module.
6367
# That's required because of the inner python Protobuf implementation check system.
64-
cryptocurrency_helpers_module = ModuleManager.import_service_module(
65-
"cryptocurrency-advanced", SERVICE_VERSION, "helpers"
66-
)
68+
types_module = ModuleManager.import_service_module(SERVICE_NAME, SERVICE_VERSION, "exonum.crypto.types")
6769

6870
# Workflow is the same as for the main modules:
6971
transfer = service_module.Transfer()
70-
cryptocurrency_public_key = cryptocurrency_helpers_module.PublicKey()
71-
cryptocurrency_public_key.data = bytes(i for i in range(32))
72+
to = types_module.Hash()
73+
to.data = bytes(i for i in range(32))
7274

7375
# Working with Protobuf objects, you have to follow Protobuf Python API conventions.
7476
# See Protobuf Python API docs for details.
75-
transfer.to.CopyFrom(cryptocurrency_public_key)
77+
transfer.to.CopyFrom(to)
7678
transfer.amount = 10
7779
transfer.seed = 1
7880

7981

82+
def run() -> None:
83+
"""Example of downloading the Protobuf sources from different locations and using the compiled module."""
84+
85+
# Run example with sources from github.
86+
run_example("github")
87+
88+
# Run example with sources from filesystem.
89+
run_example("file")
90+
91+
8092
if __name__ == "__main__":
8193
run()

examples/deploy.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55

66
RUST_RUNTIME_ID = 0
77
SUPERVISOR_ARTIFACT_NAME = "exonum-supervisor"
8-
SUPERVISOR_ARTIFACT_VERSION = "0.13.0-rc.2"
9-
CRYPTOCURRENCY_ARTIFACT_NAME = "exonum-cryptocurrency-advanced"
10-
CRYPTOCURRENCY_ARTIFACT_VERSION = "0.13.0-rc.2"
11-
CRYPTOCURRENCY_INSTANCE_NAME = "XNM"
8+
SUPERVISOR_ARTIFACT_VERSION = "1.0.0"
9+
CRYPTOCURRENCY_ARTIFACT_NAME = "exonum-cryptocurrency"
10+
CRYPTOCURRENCY_ARTIFACT_VERSION = "0.2.0"
11+
CRYPTOCURRENCY_INSTANCE_NAME = "crypto"
1212

1313

1414
def run() -> None:
@@ -118,23 +118,17 @@ def start_service(client: ExonumClient, service_name: str, service_version: str,
118118

119119
def send_request(client: ExonumClient, endpoint: str, data: bytes) -> None:
120120
"""This function encodes request from bytes to JSON, sends it to the Exonum and waits."""
121-
# Convert the request to a hexadecimal string:
122-
hex_request = data.hex()
123-
124-
# Convert the request to a JSON:
125-
json_request = json.dumps(hex_request)
126-
127121
# Post the request to Exonum:
128122
supervisor_private_api = client.service_private_api("supervisor")
129-
response = supervisor_private_api.post_service(endpoint, json_request)
123+
response = supervisor_private_api.post_service(endpoint, data, data_format="binary")
130124

131125
if response.status_code != 200:
132126
error_msg = f"Error occurred during the request to the '{endpoint}' endpoint: {response.content!r}"
133127
raise RuntimeError(error_msg)
134128

135129
# Wait for 10 seconds.
136130
# TODO: currently due to a bug in Exonum it takes up to 10 seconds to update the dispatcher info:
137-
time.sleep(10)
131+
time.sleep(5)
138132

139133

140134
if __name__ == "__main__":

examples/proofs.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
def run() -> None:
2424
"""This example creates a wallet in the Cryptocurrency service, retrieves
2525
proofs for the wallet and verifies them.
26-
For the example to work, be sure to have `exonum-cryptocurrency-advanced`
27-
service instance with name `XNM` deployed."""
26+
For the example to work, be sure to have `exonum-cryptocurrency-advanced` run."""
2827
client = ExonumClient(hostname="127.0.0.1", public_api_port=8080, private_api_port=8081)
2928

3029
with client.protobuf_loader() as loader:

0 commit comments

Comments
 (0)