From 1c2a304aac0d7350e07846a0d4dcf637304e3830 Mon Sep 17 00:00:00 2001 From: Alain Brenzikofer Date: Sat, 20 Jun 2020 17:31:27 +0200 Subject: [PATCH] rebase on master v0.3.2. distinct naming TEE proxy --- Cargo.lock | 466 ++++------------ client/Cargo.toml | 101 ---- client/bootstrap_demo_currency.sh | 78 --- client/src/cli.yml | 138 ----- client/src/main.rs | 856 ------------------------------ node/Cargo.toml | 10 +- node/src/command.rs | 2 +- runtime/Cargo.toml | 2 +- runtime/src/lib.rs | 8 +- 9 files changed, 122 insertions(+), 1539 deletions(-) delete mode 100644 client/Cargo.toml delete mode 100755 client/bootstrap_demo_currency.sh delete mode 100644 client/src/cli.yml delete mode 100644 client/src/main.rs diff --git a/Cargo.lock b/Cargo.lock index 49c69b3c..2eec3e67 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -162,7 +162,7 @@ dependencies = [ "mio", "mio-uds", "num_cpus", - "once_cell 1.3.1", + "once_cell", "pin-project-lite", "pin-utils", "slab", @@ -186,7 +186,7 @@ checksum = "95fd83426b89b034bf4e9ceb9c533c2f2386b813fd3dcae0a425ec6f1837d78a" dependencies = [ "futures 0.3.4", "rustls", - "webpki", + "webpki 0.21.2", "webpki-roots 0.19.0", ] @@ -502,7 +502,6 @@ dependencies = [ "textwrap", "unicode-width", "vec_map", - "yaml-rust", ] [[package]] @@ -607,7 +606,7 @@ dependencies = [ "lazy_static", "maybe-uninit", "memoffset", - "scopeguard 1.1.0", + "scopeguard", ] [[package]] @@ -656,19 +655,6 @@ dependencies = [ "sct", ] -[[package]] -name = "curve25519-dalek" -version = "1.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b7dcd30ba50cdf88b55b033456138b7c0ac4afdc436d82e1b79f370f24cc66d" -dependencies = [ - "byteorder", - "clear_on_drop", - "digest", - "rand_core 0.3.1", - "subtle 2.2.2", -] - [[package]] name = "curve25519-dalek" version = "2.0.0" @@ -679,7 +665,7 @@ dependencies = [ "digest", "rand_core 0.5.1", "subtle 2.2.2", - "zeroize 1.1.0", + "zeroize", ] [[package]] @@ -731,7 +717,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "978710b352437433c97b2bff193f2fb1dfd58a093f863dd95e225a19baa599a2" dependencies = [ "clear_on_drop", - "curve25519-dalek 2.0.0", + "curve25519-dalek", "rand 0.7.3", "sha2", ] @@ -743,43 +729,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3" [[package]] -name = "encointer-client" -version = "0.2.1" -dependencies = [ - "base58", - "clap", - "encointer-node-runtime", - "env_logger", - "frame-system", - "geojson", - "hex", - "json", - "log", - "pallet-balances", - "pallet-encointer-balances", - "pallet-encointer-ceremonies", - "pallet-encointer-currencies", - "pallet-encointer-scheduler", - "parity-scale-codec", - "primitive-types 0.6.2", - "sc-keystore", - "serde", - "serde_json", - "sp-application-crypto", - "sp-core", - "sp-keyring", - "sp-runtime", - "substrate-api-client", - "substrate-bip39 0.3.1", - "substrate-fixed", - "tiny-bip39 0.6.2", -] - -[[package]] -name = "encointer-node" -version = "0.3.0" +name = "encointer-node-teeproxy" +version = "0.3.2" dependencies = [ - "encointer-node-runtime", + "encointer-node-teeproxy-runtime", "futures 0.3.4", "jsonrpc-core", "log", @@ -810,8 +763,8 @@ dependencies = [ ] [[package]] -name = "encointer-node-runtime" -version = "0.3.0" +name = "encointer-node-teeproxy-runtime" +version = "0.3.2" dependencies = [ "frame-executive", "frame-support", @@ -825,6 +778,7 @@ dependencies = [ "pallet-encointer-scheduler", "pallet-grandpa", "pallet-randomness-collective-flip", + "pallet-substratee-registry", "pallet-sudo", "pallet-timestamp", "pallet-transaction-payment", @@ -947,18 +901,6 @@ dependencies = [ "parking_lot 0.9.0", ] -[[package]] -name = "fixed-hash" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3367952ceb191f4ab95dd5685dc163ac539e36202f9fcfd0cb22f9f9c542fefc" -dependencies = [ - "byteorder", - "rand 0.7.3", - "rustc-hex", - "static_assertions", -] - [[package]] name = "fixed-hash" version = "0.6.0" @@ -996,21 +938,6 @@ version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" -[[package]] -name = "foreign-types" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" -dependencies = [ - "foreign-types-shared", -] - -[[package]] -name = "foreign-types-shared" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" - [[package]] name = "fork-tree" version = "2.0.0-alpha.7" @@ -1077,7 +1004,7 @@ dependencies = [ "frame-support-procedural", "impl-trait-for-tuples", "log", - "once_cell 1.3.1", + "once_cell", "parity-scale-codec", "paste", "serde", @@ -1379,17 +1306,6 @@ dependencies = [ "typenum", ] -[[package]] -name = "geojson" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4ac03428b3276fc7f1756eba0c76c7c0c91ef77e1c43fbdd47a460238419cb9" -dependencies = [ - "num-traits 0.2.11", - "serde", - "serde_json", -] - [[package]] name = "get_if_addrs" version = "0.5.3" @@ -1494,16 +1410,6 @@ dependencies = [ "crunchy", ] -[[package]] -name = "hashbrown" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bae29b6653b3412c2e71e9d486db9f9df5d701941d86683005efb9f2d28e3da" -dependencies = [ - "byteorder", - "scopeguard 0.3.3", -] - [[package]] name = "hashbrown" version = "0.6.3" @@ -1706,7 +1612,23 @@ dependencies = [ "rustls-native-certs", "tokio 0.2.18", "tokio-rustls", - "webpki", + "webpki 0.21.2", +] + +[[package]] +name = "ias-verify" +version = "0.1.0" +source = "git+https://github.com/scs/pallet-substratee-registry.git?tag=v0.6.8-sub2.0.0-alpha.7#9adb121943960f983e6261d64c74f7d4bba37918" +dependencies = [ + "base64", + "chrono", + "frame-support", + "parity-scale-codec", + "serde_json", + "sp-core", + "sp-io", + "sp-std", + "webpki 0.21.0", ] [[package]] @@ -1854,12 +1776,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "json" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "078e285eafdfb6c4b434e0d31e8cfcb5115b651496faca5749b88fafd4f23bfd" - [[package]] name = "jsonrpc-client-transports" version = "14.0.5" @@ -1964,7 +1880,7 @@ dependencies = [ "log", "parking_lot 0.10.2", "slab", - "ws 0.9.1", + "ws", ] [[package]] @@ -2139,14 +2055,14 @@ dependencies = [ "prost", "prost-build", "rand 0.7.3", - "ring", + "ring 0.16.12", "rw-stream-sink", "sha2", "smallvec 1.3.0", "thiserror", "unsigned-varint", "void", - "zeroize 1.1.0", + "zeroize", ] [[package]] @@ -2257,7 +2173,7 @@ version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "918e94a649e1139c24ee9f1f8c1f2adaba6d157b9471af787f2d9beac8c29c77" dependencies = [ - "curve25519-dalek 2.0.0", + "curve25519-dalek", "futures 0.3.4", "lazy_static", "libp2p-core", @@ -2269,7 +2185,7 @@ dependencies = [ "snow", "static_assertions", "x25519-dalek", - "zeroize 1.1.0", + "zeroize", ] [[package]] @@ -2348,7 +2264,7 @@ dependencies = [ "rw-stream-sink", "soketto", "url 2.1.1", - "webpki", + "webpki 0.21.2", "webpki-roots 0.18.0", ] @@ -2431,22 +2347,13 @@ dependencies = [ "statrs", ] -[[package]] -name = "lock_api" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62ebf1391f6acad60e5c8b43706dde4582df75c06698ab44511d15016bc2442c" -dependencies = [ - "scopeguard 0.3.3", -] - [[package]] name = "lock_api" version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4da24a77a3d8a6d4862d95f72e6fdb9c09a643ecdb402d754004a557f2bec75" dependencies = [ - "scopeguard 1.1.0", + "scopeguard", ] [[package]] @@ -2464,7 +2371,7 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0609345ddee5badacf857d4f547e0e5a2e987db77085c24cd887f73573a04237" dependencies = [ - "hashbrown 0.6.3", + "hashbrown", ] [[package]] @@ -2521,7 +2428,7 @@ checksum = "f58381b20ebe2c578e75dececd9da411414903415349548ccc46aac3209cdfbc" dependencies = [ "ahash", "hash-db", - "hashbrown 0.6.3", + "hashbrown", "parity-util-mem", ] @@ -2531,18 +2438,6 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71d96e3f3c0b6325d8ccd83c33b28acb183edcb6c67938ba104ec546854b0882" -[[package]] -name = "merlin" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b0942b357c1b4d0dc43ba724674ec89c3218e6ca2b3e8269e7cb53bcecd2f6e" -dependencies = [ - "byteorder", - "keccak", - "rand_core 0.4.2", - "zeroize 1.1.0", -] - [[package]] name = "merlin" version = "2.0.0" @@ -2552,7 +2447,7 @@ dependencies = [ "byteorder", "keccak", "rand_core 0.5.1", - "zeroize 1.1.0", + "zeroize", ] [[package]] @@ -2830,15 +2725,6 @@ dependencies = [ "winapi-build", ] -[[package]] -name = "once_cell" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "532c29a261168a45ce28948f9537ddd7a5dd272cc513b3017b1e82a88f962c37" -dependencies = [ - "parking_lot 0.7.1", -] - [[package]] name = "once_cell" version = "1.3.1" @@ -2854,39 +2740,12 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" -[[package]] -name = "openssl" -version = "0.10.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cee6d85f4cb4c4f59a6a85d5b68a233d280c82e29e822913b9c8b129fbf20bdd" -dependencies = [ - "bitflags", - "cfg-if", - "foreign-types", - "lazy_static", - "libc", - "openssl-sys", -] - [[package]] name = "openssl-probe" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" -[[package]] -name = "openssl-sys" -version = "0.9.55" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7717097d810a0f2e2323f9e5d11e71608355e24828410b55b9d4f18aa5f9a5d8" -dependencies = [ - "autocfg 1.0.0", - "cc", - "libc", - "pkg-config", - "vcpkg", -] - [[package]] name = "owning_ref" version = "0.4.1" @@ -2937,7 +2796,7 @@ dependencies = [ [[package]] name = "pallet-encointer-balances" version = "0.3.0" -source = "git+https://github.com/encointer/pallets?tag=v0.3.0#f60169a908675bb90ae54cfa8b9000fc08ca45e7" +source = "git+https://github.com/encointer/pallets?tag=v0.3.1#21f1fba74f66052564764d93c119a712d27d0aa3" dependencies = [ "frame-support", "frame-system", @@ -2956,7 +2815,7 @@ dependencies = [ [[package]] name = "pallet-encointer-ceremonies" version = "0.3.0" -source = "git+https://github.com/encointer/pallets?tag=v0.3.0#f60169a908675bb90ae54cfa8b9000fc08ca45e7" +source = "git+https://github.com/encointer/pallets?tag=v0.3.1#21f1fba74f66052564764d93c119a712d27d0aa3" dependencies = [ "frame-support", "frame-system", @@ -2976,7 +2835,7 @@ dependencies = [ [[package]] name = "pallet-encointer-currencies" version = "0.3.0" -source = "git+https://github.com/encointer/pallets?tag=v0.3.0#f60169a908675bb90ae54cfa8b9000fc08ca45e7" +source = "git+https://github.com/encointer/pallets?tag=v0.3.1#21f1fba74f66052564764d93c119a712d27d0aa3" dependencies = [ "frame-support", "frame-system", @@ -2992,8 +2851,8 @@ dependencies = [ [[package]] name = "pallet-encointer-scheduler" -version = "0.3.0" -source = "git+https://github.com/encointer/pallets?tag=v0.3.0#f60169a908675bb90ae54cfa8b9000fc08ca45e7" +version = "0.3.1" +source = "git+https://github.com/encointer/pallets?tag=v0.3.1#21f1fba74f66052564764d93c119a712d27d0aa3" dependencies = [ "frame-support", "frame-system", @@ -3076,6 +2935,22 @@ dependencies = [ "sp-trie", ] +[[package]] +name = "pallet-substratee-registry" +version = "0.6.8-sub2.0.0-alpha.7" +source = "git+https://github.com/scs/pallet-substratee-registry.git?tag=v0.6.8-sub2.0.0-alpha.7#9adb121943960f983e6261d64c74f7d4bba37918" +dependencies = [ + "frame-support", + "frame-system", + "ias-verify", + "pallet-timestamp", + "parity-scale-codec", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + [[package]] name = "pallet-sudo" version = "2.0.0-alpha.7" @@ -3262,7 +3137,7 @@ dependencies = [ "impl-trait-for-tuples", "parity-util-mem-derive", "parking_lot 0.10.2", - "primitive-types 0.7.0", + "primitive-types", "smallvec 1.3.0", "winapi 0.3.8", ] @@ -3284,23 +3159,13 @@ version = "0.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ddfc878dac00da22f8f61e7af3157988424567ab01d9920b962ef7dcbd7cd865" -[[package]] -name = "parking_lot" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab41b4aed082705d1056416ae4468b6ea99d52599ecf3169b00088d43113e337" -dependencies = [ - "lock_api 0.1.5", - "parking_lot_core 0.4.0", -] - [[package]] name = "parking_lot" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252" dependencies = [ - "lock_api 0.3.4", + "lock_api", "parking_lot_core 0.6.2", "rustc_version", ] @@ -3311,23 +3176,10 @@ version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3a704eb390aafdc107b0e392f56a82b668e3a71366993b5340f5833fd62505e" dependencies = [ - "lock_api 0.3.4", + "lock_api", "parking_lot_core 0.7.1", ] -[[package]] -name = "parking_lot_core" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94c8c7923936b28d546dfd14d4472eaf34c99b14e1c973a32b3e6d4eb04298c9" -dependencies = [ - "libc", - "rand 0.6.5", - "rustc_version", - "smallvec 0.6.13", - "winapi 0.3.8", -] - [[package]] name = "parking_lot_core" version = "0.6.2" @@ -3467,24 +3319,13 @@ version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74490b50b9fbe561ac330df47c08f3f33073d2d00c150f719147d7c54522fa1b" -[[package]] -name = "primitive-types" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4336f4f5d5524fa60bcbd6fe626f9223d8142a50e7053e979acdf0da41ab975" -dependencies = [ - "fixed-hash 0.5.2", - "impl-codec", - "uint", -] - [[package]] name = "primitive-types" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5e4b9943a2da369aec5e96f7c10ebc74fcf434d39590d974b0a3460e6f67fbb" dependencies = [ - "fixed-hash 0.6.0", + "fixed-hash", "impl-codec", "impl-serde 0.3.0", "uint", @@ -3955,6 +3796,18 @@ dependencies = [ "winapi 0.3.8", ] +[[package]] +name = "ring" +version = "0.16.9" +source = "git+https://github.com/Phala-Network/phala-blockchain.git?rev=7d342012105f2125ca0e48a3b9c702176af23471#7d342012105f2125ca0e48a3b9c702176af23471" +dependencies = [ + "cc", + "libc", + "spin", + "untrusted", + "winapi 0.3.8", +] + [[package]] name = "ring" version = "0.16.12" @@ -4031,9 +3884,9 @@ checksum = "c0d4a31f5d68413404705d6982529b0e11a9aacd4839d1d6222ee3b8cb4015e1" dependencies = [ "base64", "log", - "ring", + "ring 0.16.12", "sct", - "webpki", + "webpki 0.21.2", ] [[package]] @@ -4501,7 +4354,7 @@ dependencies = [ "unsigned-varint", "void", "wasm-timer", - "zeroize 1.1.0", + "zeroize", ] [[package]] @@ -4808,23 +4661,6 @@ dependencies = [ "winapi 0.3.8", ] -[[package]] -name = "schnorrkel" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eacd8381b3c37840c9c9f40472af529e49975bdcbc24f83c31059fd6539023d3" -dependencies = [ - "curve25519-dalek 1.2.3", - "failure", - "merlin 1.3.0", - "rand 0.6.5", - "rand_core 0.4.2", - "rand_os", - "sha2", - "subtle 2.2.2", - "zeroize 0.9.3", -] - [[package]] name = "schnorrkel" version = "0.9.1" @@ -4833,22 +4669,16 @@ checksum = "021b403afe70d81eea68f6ea12f6b3c9588e5d536a94c3bf80f15e7faa267862" dependencies = [ "arrayref", "arrayvec 0.5.1", - "curve25519-dalek 2.0.0", + "curve25519-dalek", "getrandom", - "merlin 2.0.0", + "merlin", "rand 0.7.3", "rand_core 0.5.1", "sha2", "subtle 2.2.2", - "zeroize 1.1.0", + "zeroize", ] -[[package]] -name = "scopeguard" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" - [[package]] name = "scopeguard" version = "1.1.0" @@ -4861,7 +4691,7 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3042af939fca8c3453b7af0f1c66e533a15a86169e39de2657310ade8f98d3c" dependencies = [ - "ring", + "ring 0.16.12", "untrusted", ] @@ -5085,7 +4915,7 @@ dependencies = [ "chacha20-poly1305-aead", "rand 0.7.3", "rand_core 0.5.1", - "ring", + "ring 0.16.12", "rustc_version", "sha2", "subtle 2.2.2", @@ -5176,7 +5006,7 @@ dependencies = [ "integer-sqrt", "num-traits 0.2.11", "parity-scale-codec", - "primitive-types 0.7.0", + "primitive-types", "serde", "sp-debug-derive", "sp-std", @@ -5278,15 +5108,15 @@ dependencies = [ "lazy_static", "libsecp256k1", "log", - "merlin 2.0.0", + "merlin", "num-traits 0.2.11", "parity-scale-codec", "parity-util-mem", "parking_lot 0.10.2", - "primitive-types 0.7.0", + "primitive-types", "rand 0.7.3", "regex", - "schnorrkel 0.9.1", + "schnorrkel", "serde", "sha2", "sp-debug-derive", @@ -5294,12 +5124,12 @@ dependencies = [ "sp-runtime-interface", "sp-std", "sp-storage", - "substrate-bip39 0.4.1", - "tiny-bip39 0.7.3", + "substrate-bip39", + "tiny-bip39", "tiny-keccak", "twox-hash", "wasmi", - "zeroize 1.1.0", + "zeroize", ] [[package]] @@ -5466,7 +5296,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc743ea280556cbaf82203ec63ade39f4167402cb571aaf012c6c43f092ccf33" dependencies = [ "parity-scale-codec", - "primitive-types 0.7.0", + "primitive-types", "sp-externalities", "sp-runtime-interface-proc-macro", "sp-std", @@ -5739,43 +5569,6 @@ dependencies = [ "syn 1.0.17", ] -[[package]] -name = "substrate-api-client" -version = "0.4.3-sub2.0.0-alpha.7" -source = "git+https://github.com/scs/substrate-api-client.git?branch=marcel-use_substrate-api-client-test-node#7cf68e39b357ace1256194ef93fe143d5000b869" -dependencies = [ - "env_logger", - "frame-metadata", - "frame-support", - "frame-system", - "hex", - "log", - "pallet-balances", - "parity-scale-codec", - "primitive-types 0.6.2", - "serde", - "serde_json", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", - "sp-version", - "thiserror", - "ws 0.7.9", -] - -[[package]] -name = "substrate-bip39" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3be511be555a3633e71739a79e4ddff6a6aaa6579fa6114182a51d72c3eb93c5" -dependencies = [ - "hmac", - "pbkdf2", - "schnorrkel 0.8.5", - "sha2", -] - [[package]] name = "substrate-bip39" version = "0.4.1" @@ -5784,7 +5577,7 @@ checksum = "c004e8166d6e0aa3a9d5fa673e5b7098ff25f930de1013a21341988151e681bb" dependencies = [ "hmac", "pbkdf2", - "schnorrkel 0.9.1", + "schnorrkel", "sha2", ] @@ -5926,7 +5719,7 @@ dependencies = [ "doc-comment", "libc", "ntapi", - "once_cell 1.3.1", + "once_cell", "rayon", "winapi 0.3.8", ] @@ -6018,21 +5811,6 @@ dependencies = [ "winapi 0.3.8", ] -[[package]] -name = "tiny-bip39" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1c5676413eaeb1ea35300a0224416f57abc3bd251657e0fafc12c47ff98c060" -dependencies = [ - "failure", - "hashbrown 0.1.8", - "hmac", - "once_cell 0.1.8", - "pbkdf2", - "rand 0.6.5", - "sha2", -] - [[package]] name = "tiny-bip39" version = "0.7.3" @@ -6041,7 +5819,7 @@ checksum = "b0165e045cc2ae1660270ca65e1676dbaab60feb0f91b10f7d0665e9b47e31f2" dependencies = [ "failure", "hmac", - "once_cell 1.3.1", + "once_cell", "pbkdf2", "rand 0.7.3", "rustc-hash", @@ -6207,7 +5985,7 @@ dependencies = [ "futures-core", "rustls", "tokio 0.2.18", - "webpki", + "webpki 0.21.2", ] [[package]] @@ -6373,7 +6151,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bcc309f34008563989045a4c4dbcc5770467f3a3785ee80a9b5cc0d83362475f" dependencies = [ "hash-db", - "hashbrown 0.6.3", + "hashbrown", "log", "rustc-hex", "smallvec 1.3.0", @@ -6678,13 +6456,22 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "webpki" +version = "0.21.0" +source = "git+https://github.com/Phala-Network/phala-blockchain.git?rev=7d342012105f2125ca0e48a3b9c702176af23471#7d342012105f2125ca0e48a3b9c702176af23471" +dependencies = [ + "ring 0.16.9", + "untrusted", +] + [[package]] name = "webpki" version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1f50e1972865d6b1adb54167d1c8ed48606004c2c9d0ea5f1eeb34d95e863ef" dependencies = [ - "ring", + "ring 0.16.12", "untrusted", ] @@ -6694,7 +6481,7 @@ version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91cd5736df7f12a964a5067a12c62fa38e1bd8080aff1f80bc29be7c80d19ab4" dependencies = [ - "webpki", + "webpki 0.21.2", ] [[package]] @@ -6703,7 +6490,7 @@ version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8eff4b7516a57307f9349c64bf34caa34b940b66fed4b2fb3136cb7386e5739" dependencies = [ - "webpki", + "webpki 0.21.2", ] [[package]] @@ -6758,25 +6545,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "ws" -version = "0.7.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "329d3e6dd450a9c5c73024e1047f0be7e24121a68484eb0b5368977bee3cf8c3" -dependencies = [ - "byteorder", - "bytes 0.4.12", - "httparse", - "log", - "mio", - "mio-extras", - "openssl", - "rand 0.4.6", - "sha1", - "slab", - "url 1.7.2", -] - [[package]] name = "ws" version = "0.9.1" @@ -6811,9 +6579,9 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "637ff90c9540fa3073bb577e65033069e4bae7c79d49d74aa3ffdf5342a53217" dependencies = [ - "curve25519-dalek 2.0.0", + "curve25519-dalek", "rand_core 0.5.1", - "zeroize 1.1.0", + "zeroize", ] [[package]] @@ -6822,12 +6590,6 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d089681aa106a86fade1b0128fb5daf07d5867a509ab036d99988dec80429a57" -[[package]] -name = "yaml-rust" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e66366e18dc58b46801afbf2ca7661a9f59cc8c5962c29892b6039b4f86fa992" - [[package]] name = "yamux" version = "0.4.5" @@ -6842,12 +6604,6 @@ dependencies = [ "static_assertions", ] -[[package]] -name = "zeroize" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45af6a010d13e4cf5b54c94ba5a2b2eba5596b9e46bf5875612d332a1f2b3f86" - [[package]] name = "zeroize" version = "1.1.0" diff --git a/client/Cargo.toml b/client/Cargo.toml deleted file mode 100644 index cbb056d8..00000000 --- a/client/Cargo.toml +++ /dev/null @@ -1,101 +0,0 @@ -[package] -name = "encointer-client-notee" -version = "0.3.2" -authors = ["encointer.org "] -edition = "2018" - -[dependencies] -substrate-api-client = { git = "https://github.com/scs/substrate-api-client.git", branch="marcel-use_substrate-api-client-test-node"} -log = "0.4" -env_logger = "0.7" -hex = "0.4" -json = "0.12.0" -substrate-bip39 = "0.3.1" -tiny-bip39 = "0.6.2" -serde_json = { version = "1.0"} -clap = { version = "2.33", features = [ "yaml" ] } -primitive-types = { version = "0.6.1", default-features = false, features = ["codec"] } -geojson = "0.17" -base58 = "0.1" - -[dependencies.encointer-scheduler] -default-features = false -git = "https://github.com/encointer/pallets" -tag = "v0.3.1" -package = "pallet-encointer-scheduler" - -[dependencies.encointer-ceremonies] -default-features = false -git = "https://github.com/encointer/pallets" -tag = "v0.3.1" -package = "pallet-encointer-ceremonies" - -[dependencies.encointer-currencies] -default-features = false -git = "https://github.com/encointer/pallets" -tag = "v0.3.1" -package = "pallet-encointer-currencies" - -[dependencies.encointer-balances] -default-features = false -git = "https://github.com/encointer/pallets" -tag = "v0.3.1" -package = "pallet-encointer-balances" - -[dependencies.fixed] -default-features = false -git = "https://github.com/encointer/substrate-fixed" -tag = "v0.5.4+sub_v0.1" -package = "substrate-fixed" - -[dependencies.serde] -features = ['derive'] -optional = true -version = '1.0.101' - -[dependencies.codec] -default-features = false -package = "parity-scale-codec" -features = ["derive"] -version = "1.3.0" - -[dependencies.primitives] -default-features = false -package = "sp-core" -version = "2.0.0-alpha.7" - -[dependencies.sp-runtime] -default-features = false -version = '2.0.0-alpha.7' - -[dependencies.keystore] -version = '2.0.0-alpha.7' -package = "sc-keystore" - -[dependencies.balances] -default-features = false -package = 'pallet-balances' -version = '2.0.0-alpha.7' - -[dependencies.system] -default-features = false -version = '2.0.0-alpha.7' -package = 'frame-system' - -[dependencies.encointer-node-runtime] -package = "encointer-node-notee-runtime" -path = '../runtime' - -[dependencies.keyring] -version = '2.0.0-alpha.7' -package = "sp-keyring" - -[dependencies.app-crypto] -version = '2.0.0-alpha.7' -package = "sp-application-crypto" - -[dependencies.substrate-frame-rpc-system] -version = "2.0.0-alpha.7" - -#[patch.crates-io] -#ed25519-dalek = { git = "https://github.com/scs/ed25519-dalek.git", branch = "no_std_sgx"} \ No newline at end of file diff --git a/client/bootstrap_demo_currency.sh b/client/bootstrap_demo_currency.sh deleted file mode 100755 index 4788b015..00000000 --- a/client/bootstrap_demo_currency.sh +++ /dev/null @@ -1,78 +0,0 @@ -#!/bin/bash -CLIENT="../target/release/encointer-client ws://127.0.0.1:9979 " - -# register new currency -cid=$($CLIENT new-currency test-locations-mediterranean.json //Alice) -echo $cid - -# list currenies -$CLIENT list-currencies - -# bootstrap currency with well-known keys -phase=$($CLIENT get-phase) -echo "phase is $phase" -if [ "$phase" == "REGISTERING" ]; then - echo "that's fine" -elif [ "$phase" == "ASSIGNING" ]; then - echo "need to advance" - $CLIENT next-phase - $CLIENT next-phase -elif [ "$phase" == "ATTESTING" ]; then - echo "need to advance" - $CLIENT next-phase -fi -phase=$($CLIENT get-phase) -echo "phase is now: $phase" - -account1=//Alice -account2=//Bob -account3=//Charlie - -# charlie has no genesis funds -$CLIENT fund-account $account3 - -$CLIENT --cid $cid register-participant $account1 -$CLIENT --cid $cid register-participant $account2 -$CLIENT --cid $cid register-participant $account3 - -# list registry -$CLIENT --cid $cid list-participant-registry - -$CLIENT next-phase -# should now be ASSIGNING - -$CLIENT --cid $cid list-meetup-registry - -$CLIENT next-phase -# should now be ATTESTING - -echo "*** start meetup" -claim1=$($CLIENT --cid $cid new-claim $account1 3) -echo "claim for $account1 is $claim1" -claim2=$($CLIENT --cid $cid new-claim $account2 3) -claim3=$($CLIENT --cid $cid new-claim $account3 3) - -echo "*** sign each others claims" -witness1_2=$($CLIENT sign-claim $account1 $claim2) -witness1_3=$($CLIENT sign-claim $account1 $claim3) - -witness2_1=$($CLIENT sign-claim $account2 $claim1) -echo "attestation for $account1 by $account2 is $witness2_1" -witness2_3=$($CLIENT sign-claim $account2 $claim3) - -witness3_1=$($CLIENT sign-claim $account3 $claim1) -witness3_2=$($CLIENT sign-claim $account3 $claim2) - -echo "*** send witnesses to chain" -$CLIENT register-attestations $account1 $witness2_1 $witness3_1 -$CLIENT register-attestations $account2 $witness1_2 $witness3_2 -$CLIENT register-attestations $account3 $witness1_3 $witness2_3 - -$CLIENT --cid $cid list-attestations-registry - -$CLIENT next-phase -# should now be REGISTERING - -echo "account balances for new currency with cid $cid" -$CLIENT --cid $cid get-balance //Alice -$CLIENT --cid $cid get-balance //Bob \ No newline at end of file diff --git a/client/src/cli.yml b/client/src/cli.yml deleted file mode 100644 index 8c8a57cf..00000000 --- a/client/src/cli.yml +++ /dev/null @@ -1,138 +0,0 @@ -name: "encointer client" -version: "0.3.2" -about: Example client for encointer-node without TEEs -author: encointer.org - -# AppSettings can be defined as a list and are **not** ascii case sensitive -settings: - - ColoredHelp - -# All Args must be defined in the 'args:' list where the name of the arg, is the -# key to a Hash object -args: - - URL: - help: Sets the url and port for the encointer node - required: true - index: 1 -# - keystore: -# help: Sets the keystore directory path -# value_name: PATH -# takes_value: true - - cid: - long: cid - takes_value: true - help: Currency identifier (base58 encoded hash) -subcommands: - - next-phase: - about: Advance ceremony state machine to next phase by ROOT call - - grant-reputation: - about: pretend that an account has previous reputation - args: - - account: - required: true - index: 1 - - get-phase: - about: read current ceremony phase from chain - - get-balance: - about: get balance for account. If no --cid is specified, get NCTR balance - settings: - - ColoredHelp - args: - - account: - required: true - index: 1 - - register-participant: - about: call register_participant with extrinsic - settings: - - ColoredHelp - args: - - account: - required: true - index: 1 - - proof: - long: proof - - new-currency: - about: register a new currency - settings: - - ColoredHelp - args: - - specfile: - required: true - index: 1 - - signer: - required: true - index: 2 - - new-account: - about: generate new account and store it in keystore - settings: - - ColoredHelp - - new-claim: - about: generate a new claim for meetup - settings: - - ColoredHelp - args: - - account: - required: true - index: 1 - - n-participants: - required: true - index: 2 - - sign-claim: - about: attest another participants attendance by signing her claim - args: - - signer: - required: true - index: 1 - - claim: - required: true - index: 2 - - fund-account: - about: Alice will pre-fund this new account - settings: - - ColoredHelp - args: - - account: - required: true - index: 1 - - list-accounts: - about: list all accounts in the keystore - settings: - - ColoredHelp - - listen: - about: listen to events form EncointerCeremonies - - print-metadata: - about: query node metadata and print it to stdout - - transfer: - about: transfer funds from one account to another - settings: - - ColoredHelp - args: - - from: - required: true - index: 1 - - to: - required: true - index: 2 - - amount: - required: true - index: 3 - - list-meetup-registry: - about: query entire meetup registry and list all meetups and participants - - list-participant-registry: - about: query entire participant registry - - list-attestations-registry: - about: query entire witnesses registry - - list-currencies: - about: list all currencies and their properties - - register-attestations: - about: send attestations for other participants to the chain - args: - - account: - required: true - index: 1 - - attestation: - required: true - multiple: true - min_values: 1 - - \ No newline at end of file diff --git a/client/src/main.rs b/client/src/main.rs deleted file mode 100644 index 20bd2f4a..00000000 --- a/client/src/main.rs +++ /dev/null @@ -1,856 +0,0 @@ -// Copyright (c) 2019 Alain Brenzikofer -// -// 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. - -//! an RPC client to encointer node using websockets -//! -//! examples -//! encointer-client 127.0.0.1:9944 transfer //Alice 5G9RtsTbiYJYQYMHbWfyPoeuuxNaCbC16tZ2JGrZ4gRKwz14 1000 -//! - -#[macro_use] -extern crate clap; -extern crate log; -extern crate env_logger; - -use app_crypto::{ed25519, sr25519}; -use keyring::AccountKeyring; -use keystore::Store; -use std::path::PathBuf; -use std::str::FromStr; -use std::convert::TryInto; - -use codec::{Decode, Encode}; -use primitives::{ - crypto::Ss58Codec, - hashing::blake2_256, - sr25519 as sr25519_core, Pair -}; -use fixed::traits::LossyInto; -use fixed::transcendental::exp; - -use substrate_api_client::{ - compose_extrinsic, - extrinsic::xt_primitives::{GenericAddress, UncheckedExtrinsicV4}, - node_metadata::Metadata, - utils::hexstr_to_vec, - Api, XtStatus -}; - -use base58::{FromBase58, ToBase58}; -use encointer_ceremonies::{ - Attestation, AttestationIndexType, ClaimOfAttendance, - CurrencyCeremony, MeetupIndexType, ParticipantIndexType, ProofOfAttendance, Reputation -}; -use encointer_scheduler::{CeremonyIndexType, CeremonyPhaseType}; -use encointer_currencies::{CurrencyIdentifier, CurrencyPropertiesType, Location, Degree}; -use encointer_node_runtime::{ - AccountId, Event, Hash, Signature, Moment, ONE_DAY, BalanceType, BalanceEntry, BlockNumber, Header -}; - -use sp_runtime::traits::{IdentifyAccount, Verify}; -//use primitive_types::U256; -use clap::App; -use geojson::GeoJson; -use log::*; -use serde_json; -use std::collections::HashMap; -use std::fs; -use std::sync::mpsc::channel; - -type AccountPublic = ::Signer; -const KEYSTORE_PATH: &str = "my_keystore"; -const PREFUNDING_AMOUNT: u128 = 1_000_000_000; - -fn main() { - env_logger::init(); - let yml = load_yaml!("cli.yml"); - let matches = App::from_yaml(yml).get_matches(); - - let url = matches.value_of("URL").expect("must specify URL"); - info!("connecting to {}", url); - let api = Api::::new(format!("{}", url)); - - if let Some(_matches) = matches.subcommand_matches("print-metadata") { - let metaraw = api.get_metadata(); - println!("{}", Metadata::pretty_format(&metaraw).unwrap()); - } - - if let Some(_matches) = matches.subcommand_matches("new-account") { - // open store without password protection - let store = Store::open(PathBuf::from(&KEYSTORE_PATH), None).unwrap(); - let key: sr25519::AppPair = store.write().generate().unwrap(); - drop(store); - println!("{}", key.public().to_ss58check()) - } - - if let Some(_matches) = matches.subcommand_matches("new-claim") { - let account = _matches.value_of("account").unwrap(); - let accountid = get_accountid_from_str(account); - let cid = get_cid( - matches - .value_of("cid") - .expect("please supply argument --cid"), - ); - let n_participants = _matches - .value_of("n-participants") - .unwrap() - .parse::() - .unwrap(); - let claim = new_claim_for(&api, accountid, cid, n_participants); - println!("{}", hex::encode(claim)) - } - - if let Some(_matches) = matches.subcommand_matches("sign-claim") { - let signer_arg = _matches.value_of("signer").unwrap(); - info!("first call to get_pair_from_str"); - let claim = ClaimOfAttendance::decode( - &mut &hex::decode(_matches.value_of("claim").unwrap()).unwrap()[..], - ) - .unwrap(); - let attestation = sign_claim(claim, signer_arg); - println!("{}", hex::encode(attestation)) - } - - if let Some(_matches) = matches.subcommand_matches("fund-account") { - let account = _matches.value_of("account").unwrap(); - let accountid = get_accountid_from_str(account); - - let _api = api.clone().set_signer(AccountKeyring::Alice.pair()); - let xt = _api.balance_transfer(GenericAddress::from(accountid.clone()), PREFUNDING_AMOUNT); - info!( - "[+] Alice is generous and pre funds account {}\n", - accountid.to_ss58check() - ); - let tx_hash = _api.send_extrinsic(xt.hex_encode(), XtStatus::InBlock).unwrap(); - info!( - "[+] Pre-Funding transaction got finalized. Hash: {:?}\n", - tx_hash - ); - let result = _api.get_account_data(&accountid.clone()).unwrap(); - println!("balance for {} is now {}", accountid.to_ss58check(), result.free); - } - - if let Some(_matches) = matches.subcommand_matches("list-accounts") { - let store = Store::open(PathBuf::from(&KEYSTORE_PATH), None).unwrap(); - println!("sr25519 keys:"); - for pubkey in store - .read() - .public_keys::() - .unwrap() - .into_iter() - { - println!("{}", pubkey.to_ss58check()); - } - println!("ed25519 keys:"); - for pubkey in store - .read() - .public_keys::() - .unwrap() - .into_iter() - { - println!("{}", pubkey.to_ss58check()); - } - drop(store); - } - - if let Some(_matches) = matches.subcommand_matches("listen") { - info!("Subscribing to events"); - let (events_in, events_out) = channel(); - api.subscribe_events(events_in.clone()); - loop { - let event_str = events_out.recv().unwrap(); - let _unhex = hexstr_to_vec(event_str).unwrap(); - let mut _er_enc = _unhex.as_slice(); - let _events = Vec::>::decode(&mut _er_enc); - match _events { - Ok(evts) => { - for evr in &evts { - debug!("decoded: phase {:?} event {:?}", evr.phase, evr.event); - match &evr.event { - /* Event::balances(be) => { - println!(">>>>>>>>>> balances event: {:?}", be); - match &be { - balances::RawEvent::Transfer(transactor, dest, value, fee) => { - println!("Transactor: {:?}", transactor); - println!("Destination: {:?}", dest); - println!("Value: {:?}", value); - println!("Fee: {:?}", fee); - } - _ => { - debug!("ignoring unsupported balances event"); - } - } - },*/ - Event::encointer_ceremonies(ee) => { - println!(">>>>>>>>>> ceremony event: {:?}", ee); - match &ee { - encointer_ceremonies::RawEvent::ParticipantRegistered( - accountid, - ) => { - println!( - "Participant registered for ceremony: {:?}", - accountid - ); - } - } - }, - Event::encointer_scheduler(ee) => { - println!(">>>>>>>>>> scheduler event: {:?}", ee); - match &ee { - encointer_scheduler::Event::PhaseChangedTo(phase) => { - println!("Phase changed to: {:?}", phase); - } - } - } - Event::encointer_currencies(ee) => { - println!(">>>>>>>>>> currency event: {:?}", ee); - match &ee { - encointer_currencies::RawEvent::CurrencyRegistered(account, cid) => { - println!("Currency registered: by {}, cid: {:?}", account, cid); - } - } - }, - _ => debug!("ignoring unsupported module event: {:?}", evr.event), - } - } - } - Err(_) => error!("couldn't decode event record list"), - } - } - } - - if let Some(_matches) = matches.subcommand_matches("get-balance") { - let account = _matches.value_of("account").unwrap(); - let accountid = get_accountid_from_str(account); - info!("ss58 is {}", accountid.to_ss58check()); - match matches.value_of("cid") { - Some(cid_str) => { - let cid = get_cid(cid_str); - let bn = get_block_number(&api); - let dr = get_demurrage_per_block(&api, cid); - let balance = if let Some(entry) = api - .get_storage_double_map("EncointerBalances", "Balance", cid, accountid) { - apply_demurrage(entry, bn, dr) - } else { BalanceType::from_num(0) }; - println!("NCTR balance for {} is {} in currency {}", account, balance, cid.encode().to_base58()); - } - None => { - let balance = if let Some(data) = api.get_account_data(&accountid) { - data.free - } else { - 0 - }; - println!("ERT balance for {} is {}", account, balance); - } - }; - } - - if let Some(_matches) = matches.subcommand_matches("get-phase") { - let bn = get_block_number(&api); - info!("block number: {}", bn); - let cindex = get_ceremony_index(&api); - info!("ceremony index: {}", cindex); - let tnext: Moment = api.get_storage_value( - "EncointerScheduler", - "NextPhaseTimestamp" - ).unwrap(); - info!("next phase timestamp: {}", tnext); - let phase = get_current_phase(&api); - println!("{:?}", phase); - } - - if let Some(_matches) = matches.subcommand_matches("transfer") { - let arg_from = _matches.value_of("from").unwrap(); - let arg_to = _matches.value_of("to").unwrap(); - - let from = get_pair_from_str(arg_from); - let to = get_accountid_from_str(arg_to); - info!("from ss58 is {}", from.public().to_ss58check()); - info!("to ss58 is {}", to.to_ss58check()); - let _api = api.clone().set_signer(sr25519_core::Pair::from(from)); - let tx_hash = match matches.value_of("cid") { - Some(cid_str) => { - let cid = get_cid(cid_str); - let amount = BalanceType::from_str(_matches.value_of("amount").unwrap()) - .expect("amount can be converted to fixpoint"); - let xt: UncheckedExtrinsicV4<_> = compose_extrinsic!( - _api.clone(), - "EncointerBalances", - "transfer", - to.clone(), - cid, - amount - ); - _api.send_extrinsic(xt.hex_encode(), XtStatus::InBlock).unwrap() - }, - None => { - let amount = u128::from_str_radix(_matches.value_of("amount").unwrap(), 10) - .expect("amount can be converted to u128"); - let xt = _api.balance_transfer(GenericAddress::from(to.clone()), amount); - _api.send_extrinsic(xt.hex_encode(), XtStatus::InBlock).unwrap() - } - }; - println!("[+] Transaction in pool. Hash: {:?}\n", tx_hash); - let result = _api.get_account_data(&to.clone()).unwrap(); - println!("balance for {} is now {}", to, result.free); - } - - if let Some(_matches) = matches.subcommand_matches("next-phase") { - let _api = api.clone().set_signer(AccountKeyring::Alice.pair()); - - let xt: UncheckedExtrinsicV4<_> = - compose_extrinsic!(_api.clone(), "EncointerScheduler", "next_phase"); - - // send and watch extrinsic until finalized - let tx_hash = _api.send_extrinsic(xt.hex_encode(), XtStatus::InBlock).unwrap(); - let phase = get_current_phase(&api); - println!( - "Transaction got finalized. Phase is now: {:?}. tx hash: {:?}", - phase, tx_hash - ); - } - - if let Some(_matches) = matches.subcommand_matches("grant-reputation") { - // root call, must be signed by master - let _api = api.clone().set_signer(AccountKeyring::Alice.pair()); - let p_arg = _matches.value_of("account").unwrap(); - let accountid = get_accountid_from_str(p_arg); - let cid = get_cid( - matches - .value_of("cid") - .expect("please supply argument --cid"), - ); - - let xt: UncheckedExtrinsicV4<_> = compose_extrinsic!( - _api.clone(), - "EncointerCeremonies", - "grant_reputation", - cid, - accountid.clone() - ); - - // send and watch extrinsic until finalized - let tx_hash = _api.send_extrinsic(xt.hex_encode(), XtStatus::InBlock).unwrap(); - println!( - "Transaction got finalized. Account: {} should now have reputation. txhash: {:?}", - accountid.to_ss58check(), - tx_hash - ); - } - - if let Some(_matches) = matches.subcommand_matches("register-participant") { - let p_arg = _matches.value_of("account").unwrap(); - let accountid = get_accountid_from_str(p_arg); - let p = get_pair_from_str(p_arg); - let cindex = get_ceremony_index(&api); - let cid = get_cid( - matches - .value_of("cid") - .expect("please supply argument --cid"), - ); - let rep = get_reputation(&api, &accountid, cid, cindex -1); - info!("{} has reputation {:?}", accountid, rep); - let proof = match rep { - Reputation::Unverified => None, - Reputation::UnverifiedReputable => None, // this should never by the case during REGISTERING! - Reputation::VerifiedUnlinked => Some(prove_attendance(accountid, cid, cindex - 1, p_arg)), - Reputation::VerifiedLinked => panic!("reputation of {} has already been linked! Not registering again", accountid), - }; - debug!("proof: {:x?}", proof.encode()); - // FIXME: -/* let proof = if _matches.is_present("proof") { - Some(prove_attendance(accountid, cid, cindex - 1, p_arg)) - } else { - None - }; - */ - //let proof : Option> = None; - // assume users keep the same pair forever (so prover == attendee) - //let proof = prove_attendance(acountid, cid, cindex-1) - - info!("ss58 is {}", p.public().to_ss58check()); - if get_current_phase(&api) != CeremonyPhaseType::REGISTERING { - println!("wrong ceremony phase for registering participant"); - return; - } - let _api = api.clone().set_signer(sr25519_core::Pair::from(p.clone())); - let xt: UncheckedExtrinsicV4<_> = compose_extrinsic!( - _api.clone(), - "EncointerCeremonies", - "register_participant", - cid, - proof - ); - - // send and watch extrinsic until finalized - let tx_hash = _api.send_extrinsic(xt.hex_encode(), XtStatus::InBlock).unwrap(); - info!("Transaction in pool. tx hash: {:?}", tx_hash); - println!("registration finalized: {}", p.public().to_ss58check()); - } - - if let Some(_matches) = matches.subcommand_matches("register-attestations") { - let p_arg = _matches.value_of("account").unwrap(); - let signer = get_pair_from_str(p_arg); - - if get_current_phase(&api) != CeremonyPhaseType::ATTESTING { - println!("wrong ceremony phase for registering participant"); - return; - } - let attestation_args: Vec<_> = _matches.values_of("attestation").unwrap().collect(); - let mut attestations: Vec> = vec![]; - for arg in attestation_args.iter() { - let w = Attestation::decode(&mut &hex::decode(arg).unwrap()[..]).unwrap(); - attestations.push(w); - } - - let _api = api.clone().set_signer(sr25519_core::Pair::from(signer)); - let xt: UncheckedExtrinsicV4<_> = compose_extrinsic!( - _api.clone(), - "EncointerCeremonies", - "register_attestations", - attestations.clone() - ); - // send and watch extrinsic until finalized - let tx_hash = _api.send_extrinsic(xt.hex_encode(), XtStatus::InBlock).unwrap(); - info!("Transaction in pool. tx hash: {:?}", tx_hash); - println!("Transaction got finalized. tx hash: {:?}", tx_hash); - } - - if let Some(_matches) = matches.subcommand_matches("list-meetup-registry") { - let cindex = get_ceremony_index(&api); - let cid = get_cid( - matches - .value_of("cid") - .expect("please supply argument --cid"), - ); - println!( - "listing meetups for cid {} and ceremony nr {}", - cid.encode().to_base58(), - cindex - ); - let mcount = get_meetup_count(&api, (cid, cindex)); - println!("number of meetups assigned: {}", mcount); - for m in 1..=mcount { - println!("MeetupRegistry[{}, {}] location is {:?}", - cindex, m, get_meetup_location(&api, cid, m)); - println!("MeetupRegistry[{}, {}] meeting time is {:?}", - cindex, m, get_meetup_time(&api, cid, m)); - match get_meetup_participants(&api, (cid, cindex), m) { - Some(participants) => { - println!("MeetupRegistry[{}, {}] participants are:", cindex, m); - for p in participants.iter() { - println!(" {}", p); - } - } - None => println!("MeetupRegistry[{}, {}] EMPTY", cindex, m), - } - } - } - - if let Some(_matches) = matches.subcommand_matches("list-participant-registry") { - let cindex = get_ceremony_index(&api); - let cid = get_cid( - matches - .value_of("cid") - .expect("please supply argument --cid"), - ); - println!( - "listing participants for cid {} and ceremony nr {}", - cid.encode().to_base58(), - cindex - ); - let pcount = get_participant_count(&api, (cid, cindex)); - println!("number of participants assigned: {}", pcount); - for p in 1..pcount + 1 { - let accountid = get_participant(&api, (cid, cindex), p).unwrap(); - println!("ParticipantRegistry[{}, {}] = {}", cindex, p, accountid); - } - } - - if let Some(_matches) = matches.subcommand_matches("list-currencies") { - let cids = get_currency_identifiers(&api).expect("no currency registered"); - println!("number of currencies: {}", cids.len()); - for cid in cids.iter() { - println!("currency with cid {}", cid.encode().to_base58()); - } - } - - if let Some(_matches) = matches.subcommand_matches("list-attestations-registry") { - let cindex = get_ceremony_index(&api); - let cid = get_cid( - matches - .value_of("cid") - .expect("please supply argument --cid"), - ); - println!( - "listing attestations for cid {} and ceremony nr {}", - cid.encode().to_base58(), - cindex - ); - let wcount = get_attestation_count(&api, (cid, cindex)); - println!("number of attestations: {}", wcount); - let pcount = get_participant_count(&api, (cid, cindex)); - - let mut participants_windex = HashMap::new(); - for p in 1..pcount + 1 { - let accountid = - get_participant(&api, (cid, cindex), p).expect("error getting participant"); - match get_participant_attestation_index(&api, (cid, cindex), &accountid) { - Some(windex) => { - participants_windex.insert(windex as AttestationIndexType, accountid) - } - _ => continue, - }; - } - for w in 1..wcount + 1 { - let attestations = get_attestations(&api, (cid, cindex), w); - println!( - "AttestationRegistry[{}, {} ({})] = {:?}", - cindex, w, participants_windex[&w], attestations - ); - } - } - - if let Some(_matches) = matches.subcommand_matches("new-currency") { - let p_arg = _matches.value_of("signer").unwrap(); - let signer = get_pair_from_str(p_arg); - - let spec_file = _matches.value_of("specfile").unwrap(); - - let spec_str = fs::read_to_string(spec_file).unwrap(); - let geoloc = spec_str.parse::().unwrap(); - - let mut loc = Vec::with_capacity(100); - match geoloc { - GeoJson::FeatureCollection(ref ctn) => { - for feature in &ctn.features { - let val = &feature.geometry.as_ref().unwrap().value; - if let geojson::Value::Point(pt) = val { - let l = Location { - lon: Degree::from_num(pt[0]), - lat: Degree::from_num(pt[1]), - }; - loc.push(l); - debug!("lon: {} lat {} => {:?}", pt[0], pt[1], l); - } - } - } - _ => (), - }; - let meta: serde_json::Value = serde_json::from_str(&spec_str).unwrap(); - debug!("meta: {:?}", meta["currency_meta"]); - let bootstrappers: Vec = meta["currency_meta"]["bootstrappers"] - .as_array() - .expect("bootstrappers must be array") - .iter() - .map(|a| get_accountid_from_str(&a.as_str().unwrap())) - .collect(); - - let cid = blake2_256(&(loc.clone(), bootstrappers.clone()).encode()); - let name = meta["currency_meta"]["name"].as_str().unwrap(); - info!("bootstrappers: {:?}", bootstrappers); - info!("name: {}", name); - info!("Currency registered by {}", signer.public().to_ss58check()); - - let _api = api.clone().set_signer(sr25519_core::Pair::from(signer)); - let xt: UncheckedExtrinsicV4<_> = compose_extrinsic!( - _api.clone(), - "EncointerCurrencies", - "new_currency", - loc, - bootstrappers - ); - let tx_hash = _api.send_extrinsic(xt.hex_encode(), XtStatus::InBlock).unwrap(); - info!("[+] Transaction got finalized. Hash: {:?}\n", tx_hash); - println!("{}", cid.to_base58()) - } -} - -fn get_cid(cid: &str) -> CurrencyIdentifier { - CurrencyIdentifier::decode(&mut &cid.from_base58().unwrap()[..]).unwrap() -} - -fn get_accountid_from_str(account: &str) -> AccountId { - info!("getting AccountId from -{}-", account); - match &account[..2] { - "//" => AccountPublic::from(sr25519::Pair::from_string(account, None).unwrap().public()) - .into_account(), - _ => AccountPublic::from(sr25519::Public::from_ss58check(account).unwrap()).into_account(), - } -} - -// get a pair either form keyring (well known keys) or from the store -fn get_pair_from_str(account: &str) -> sr25519::AppPair { - info!("getting pair for {}", account); - match &account[..2] { - "//" => sr25519::AppPair::from_string(account, None).unwrap(), - _ => { - info!("fetching from keystore at {}", &KEYSTORE_PATH); - // open store without password protection - let store = - Store::open(PathBuf::from(&KEYSTORE_PATH), None).expect("store should exist"); - info!("store opened"); - let _pair = store - .read() - .key_pair::( - &sr25519::Public::from_ss58check(account).unwrap().into(), - ) - .unwrap(); - drop(store); - _pair - } - } -} - -fn get_block_number(api: &Api) -> BlockNumber { - let hdr: Header = api.get_header(None).unwrap(); - debug!("decoded: {:?}", hdr); - //let hdr: Header= Decode::decode(&mut .as_bytes()).unwrap(); - hdr.number -} - -fn get_demurrage_per_block(api: &Api, cid: CurrencyIdentifier) -> BalanceType { - let cp: CurrencyPropertiesType = api - .get_storage_map("EncointerCurrencies", "CurrencyProperties", cid) - .unwrap(); - debug!("CurrencyProperties are {:?}", cp); - cp.demurrage_per_block -} - -fn get_ceremony_index(api: &Api) -> CeremonyIndexType { - api.get_storage_value("EncointerScheduler", "CurrentCeremonyIndex") - .unwrap() -} - -fn get_current_phase(api: &Api) -> CeremonyPhaseType { - api.get_storage_value("EncointerScheduler", "CurrentPhase") - .or(Some(CeremonyPhaseType::default())) - .unwrap() -} - -fn get_meetup_count(api: &Api, key: CurrencyCeremony) -> MeetupIndexType { - api.get_storage_map("EncointerCeremonies", "MeetupCount", key) - .or(Some(0)) - .unwrap() -} - -fn get_participant_count(api: &Api, key: CurrencyCeremony) -> ParticipantIndexType { - api.get_storage_map( - "EncointerCeremonies", - "ParticipantCount", - key, - ).or(Some(0)).unwrap() -} - -fn get_attestation_count(api: &Api, key: CurrencyCeremony) -> ParticipantIndexType { - api.get_storage_map( - "EncointerCeremonies", - "AttestationCount", - key, - ).or(Some(0)).unwrap() -} - -fn get_participant( - api: &Api, - key: CurrencyCeremony, - pindex: ParticipantIndexType, -) -> Option { - api.get_storage_double_map( - "EncointerCeremonies", - "ParticipantRegistry", - key, - pindex, - ) -} - -fn get_meetup_index_for( - api: &Api, - key: CurrencyCeremony, - account: &AccountId, -) -> Option { - api.get_storage_double_map( - "EncointerCeremonies", - "MeetupIndex", - key, - account.clone(), - ) -} - -fn get_meetup_participants( - api: &Api, - key: CurrencyCeremony, - mindex: MeetupIndexType, -) -> Option> { - api.get_storage_double_map( - "EncointerCeremonies", - "MeetupRegistry", - key, - mindex, - ) -} - -fn get_attestations( - api: &Api, - key: CurrencyCeremony, - windex: ParticipantIndexType, -) -> Option> { - api.get_storage_double_map( - "EncointerCeremonies", - "AttestationRegistry", - key, - windex, - ) -} - -fn get_participant_attestation_index( - api: &Api, - key: CurrencyCeremony, - accountid: &AccountId, -) -> Option { - api.get_storage_double_map( - "EncointerCeremonies", - "AttestationIndex", - key, - accountid, - ) -} - -fn new_claim_for( - api: &Api, - accountid: AccountId, - cid: CurrencyIdentifier, - n_participants: u32, -) -> Vec { - let cindex = get_ceremony_index(api); - let mindex = get_meetup_index_for(api, (cid, cindex), &accountid).unwrap(); - - // implicitly assume that participant meet at the right place at the right time - let mloc = get_meetup_location(api, cid, mindex).unwrap(); - let mtime = get_meetup_time(api, cid, mindex).unwrap(); - - let claim = ClaimOfAttendance:: { - claimant_public: accountid, - currency_identifier: cid, - ceremony_index: cindex, - meetup_index: mindex, - location: mloc, - timestamp: mtime, - number_of_participants_confirmed: n_participants, - }; - claim.encode() -} - -fn sign_claim(claim: ClaimOfAttendance, account_str: &str) -> Vec { - info!("second call to get_pair_from_str"); - let pair = get_pair_from_str(account_str); - let accountid = get_accountid_from_str(account_str); - let attestation = Attestation { - claim: claim.clone(), - signature: Signature::from(sr25519_core::Signature::from(pair.sign(&claim.encode()))), - public: accountid, - }; - attestation.encode() -} - -fn get_currency_identifiers(api: &Api) -> Option> { - api.get_storage_value("EncointerCurrencies", "CurrencyIdentifiers") -} - -fn get_currency_locations(api: &Api, cid: CurrencyIdentifier) -> Option> { - api.get_storage_map( - "EncointerCurrencies", - "Locations", - cid - ) -} - -fn get_meetup_location(api: &Api, cid: CurrencyIdentifier, mindex: MeetupIndexType) -> Option { - let locations = get_currency_locations(api, cid).or(Some(vec![])).unwrap(); - let lidx = (mindex -1) as usize; - if lidx >= locations.len() { - return None - } - Some(locations[lidx]) -} - -fn get_meetup_time(api: &Api, cid: CurrencyIdentifier, mindex: MeetupIndexType) -> Option { - let mlocation = get_meetup_location(api, cid, mindex).unwrap(); - let mlon: f64 = mlocation.lon.lossy_into(); - - let next_phase_timestamp: Moment = api.get_storage_value( - "EncointerScheduler", - "NextPhaseTimestamp" - ).unwrap(); - - let attesting_start = match get_current_phase(api) { - CeremonyPhaseType::ASSIGNING => next_phase_timestamp, // - next_phase_timestamp.rem(ONE_DAY), - CeremonyPhaseType::ATTESTING => { - let attesting_duration: Moment = api.get_storage_map( - "EncointerScheduler", - "PhaseDurations", - CeremonyPhaseType::ATTESTING, - ).unwrap(); - next_phase_timestamp - attesting_duration //- next_phase_timestamp.rem(ONE_DAY) - }, - CeremonyPhaseType::REGISTERING => panic!("ceremony phase must be ASSIGNING or ATTESTING to request meetup location.") - }; - - Some(attesting_start + ONE_DAY - - (mlon * (ONE_DAY as f64) / 360.0) as Moment ) -} - -fn prove_attendance( - prover: AccountId, - cid: CurrencyIdentifier, - cindex: CeremonyIndexType, - attendee_str: &str, -) -> ProofOfAttendance { - let msg = (prover.clone(), cindex); - let attendee = get_pair_from_str(attendee_str); - let attendeeid = get_accountid_from_str(attendee_str); - debug!("generating proof of attendance for {} and cindex: {}", prover, cindex); - ProofOfAttendance { - prover_public: prover, - currency_identifier: cid, - ceremony_index: cindex, - attendee_public: attendeeid, - attendee_signature: Signature::from(sr25519_core::Signature::from( - attendee.sign(&msg.encode()), - )), - } -} - -fn get_reputation( - api: &Api, - prover: &AccountId, - cid: CurrencyIdentifier, - cindex: CeremonyIndexType, -) -> Reputation { - api.get_storage_double_map( - "EncointerCeremonies", - "ParticipantReputation", - (cid, cindex), - prover.clone() - ).or(Some(Reputation::Unverified)).unwrap() -} - -fn apply_demurrage(entry: BalanceEntry, current_block: BlockNumber, demurrage_per_block: BalanceType) -> BalanceType { - let elapsed_time_block_number = current_block.checked_sub(entry.last_update).unwrap(); - let elapsed_time_u32: u32 = elapsed_time_block_number.try_into().unwrap(); - let elapsed_time = BalanceType::from_num(elapsed_time_u32); - let exponent : BalanceType = -demurrage_per_block * elapsed_time; - debug!("demurrage per block {}, current_block {}, last {}, elapsed_blocks {}", demurrage_per_block, current_block, entry.last_update, elapsed_time); - let exp_result : BalanceType = exp(exponent).unwrap(); - entry.principal.checked_mul(exp_result).unwrap() -} \ No newline at end of file diff --git a/node/Cargo.toml b/node/Cargo.toml index 6d281be2..3a5a250f 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -1,11 +1,11 @@ [package] authors = ["encointer.org "] build = 'build.rs' -description = 'Encointer Node noTEE' +description = 'Encointer Node TEE proxy' edition = '2018' homepage = 'https://encointer.org' license = "GPL-3.0" -name = 'encointer-node-notee' +name = 'encointer-node-teeproxy' repository = 'https://github.com/encointer/encointer-node' version = '0.3.2' @@ -19,9 +19,9 @@ structopt = '0.3.8' jsonrpc-core = "14.2.0" [dependencies.encointer-node-runtime] -package = "encointer-node-notee-runtime" +package = "encointer-node-teeproxy-runtime" path = '../runtime' -version = '0.3.0' +version = '0.3.2' [dependencies.sc-basic-authorship] version = '0.8.0-alpha.7' @@ -93,4 +93,4 @@ version = "2.0.0-alpha.7" version = "2.0.0-alpha.7" [[bin]] -name = 'encointer-node-notee' +name = 'encointer-node-teeproxy' diff --git a/node/src/command.rs b/node/src/command.rs index c0dc2d84..7cf41514 100644 --- a/node/src/command.rs +++ b/node/src/command.rs @@ -21,7 +21,7 @@ use sc_cli::SubstrateCli; impl SubstrateCli for Cli { fn impl_name() -> &'static str { - "Encointer Node noTEE" + "Encointer Node TEE proxy" } fn impl_version() -> &'static str { diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index e7e95799..e37f7371 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -3,7 +3,7 @@ authors = ["encointer.org "] edition = '2018' homepage = 'https://encointer.org' license = "GPL-3.0" -name = 'encointer-node-notee-runtime' +name = 'encointer-node-teeproxy-runtime' repository = 'https://github.com/paritytech/substrate/' version = '0.3.2' diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 98913d2e..92ca69cf 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -106,11 +106,11 @@ pub mod opaque { /// This runtime version. pub const VERSION: RuntimeVersion = RuntimeVersion { - spec_name: create_runtime_str!("encointer-node-notee"), - impl_name: create_runtime_str!("encointer-node-notee"), + spec_name: create_runtime_str!("encointer-node-teeproxy"), + impl_name: create_runtime_str!("encointer-node-teeproxy"), authoring_version: 2, - spec_version: 4, - impl_version: 4, + spec_version: 5, + impl_version: 5, apis: RUNTIME_API_VERSIONS, transaction_version: 1, };