diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 21d7a70..0000000 --- a/Dockerfile +++ /dev/null @@ -1,16 +0,0 @@ -FROM ubuntu:20.04 - -ENV DEBIAN_FRONTEND=noninteractive - -WORKDIR /root - -ENV PATH=$PATH:/root/.cargo/bin - -RUN apt-get update && \ - apt-get upgrade -y && \ - apt-get install -y cmake curl libssl-dev git clang && \ - apt-get clean -RUN curl https://sh.rustup.rs -sSf | sh -s -- -y -RUN rustup toolchain install stable -RUN rustup target add wasm32-unknown-unknown -RUN rustup default stable diff --git a/docker-compose.yml b/docker-compose.yml index ae4fcda..fc3ba65 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,27 +1,26 @@ version: "3.2" services: - dev: + gsy-node: container_name: gsy-node - image: gsy_dex_image:staging - working_dir: /var/www/gsy-node + build: + dockerfile: ./gsy-node/Dockerfile + depends_on: + gsy-matching-engine: + condition: service_started ports: - "9944:9944" environment: - CARGO_HOME=/var/www/gsy-node/.cargo - volumes: - - ./gsy-node:/var/www/gsy-node - command: bash -c "cargo build --release && ./target/release/gsy-node --dev --ws-external" + - ORDERBOOK_SERVICE_URL=gsy-orderbook:8080 - orderbook: - container_name: orderbook - image: gsy_dex_image:staging + gsy-orderbook: + container_name: gsy-orderbook build: - dockerfile: Dockerfile + dockerfile: ./gsy-orderbook-service/Dockerfile depends_on: mongodb: condition: service_started - working_dir: /var/www/orderbook ports: - "8080:8080" environment: @@ -35,9 +34,15 @@ services: - DATABASE_PASSWORD=gsy - NODE_URL=gsy-node:9944 - SCHEDULER_INTERVAL=900 - volumes: - - ./gsy-orderbook-service:/var/www/orderbook - command: bash -c "cargo build --release && ./target/release/gsy-orderbook-service" + + gsy-matching-engine: + container_name: gsy-matching-engine + build: + dockerfile: ./gsy-matching-engine/Dockerfile + depends_on: + gsy-orderbook: + condition: service_started + working_dir: /var/www/matching-engine mongodb: image: mongo:5.0 diff --git a/gsy-matching-engine/Cargo.lock b/gsy-matching-engine/Cargo.lock index b8c6810..415033a 100644 --- a/gsy-matching-engine/Cargo.lock +++ b/gsy-matching-engine/Cargo.lock @@ -563,6 +563,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "93f2635620bf0b9d4576eb7bb9a38a55df78bd1205d26fa994b25911a69f212f" dependencies = [ "bitcoin_hashes 0.11.0", + "serde", + "unicode-normalization", ] [[package]] @@ -724,12 +726,24 @@ version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d32a725bc159af97c3e629873bb9f88fb8cf8a4867175f76dc987815ea07c83b" +[[package]] +name = "cesu8" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" + [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "cfg_aliases" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" + [[package]] name = "chacha20" version = "0.9.1" @@ -795,7 +809,7 @@ version = "4.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "528131438037fd55894f62d6e9f068b8f45ac57ffa77517819645d10aed04f64" dependencies = [ - "heck 0.5.0", + "heck", "proc-macro2", "quote", "syn 2.0.60", @@ -1126,6 +1140,17 @@ dependencies = [ "syn 2.0.60", ] +[[package]] +name = "derive-where" +version = "1.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62d671cc41a825ebabc75757b62d3d168c577f9149b2d49ece1dad1f72119d25" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.60", +] + [[package]] name = "derive_more" version = "0.99.17" @@ -1290,9 +1315,9 @@ dependencies = [ [[package]] name = "either" -version = "1.11.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a47c1c47d2f5964e29c61246e81db715514cd532db6b5116a25ea3c03d6780a2" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" [[package]] name = "elliptic-curve" @@ -1429,6 +1454,16 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38793c55593b33412e3ae40c2c9781ffaa6f438f6f8c10f24e71846fbd7ae01e" +[[package]] +name = "finito" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2384245d85162258a14b43567a9ee3598f5ae746a1581fb5d3d2cb780f0dbf95" +dependencies = [ + "futures-timer", + "pin-project", +] + [[package]] name = "fixed-hash" version = "0.8.0" @@ -1702,8 +1737,8 @@ dependencies = [ "reqwest", "serde", "serde_json", - "sp-keyring", "subxt", + "subxt-signer", "tokio", "tracing", "tracing-bunyan-formatter", @@ -1794,12 +1829,6 @@ dependencies = [ "serde", ] -[[package]] -name = "heck" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" - [[package]] name = "heck" version = "0.5.0" @@ -2124,9 +2153,9 @@ dependencies = [ [[package]] name = "instant" -version = "0.1.12" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" dependencies = [ "cfg-if", ] @@ -2181,6 +2210,26 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +[[package]] +name = "jni" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6df18c2e3db7e453d3c6ac5b3e9d5182664d28788126d39b91f2d1e22b017ec" +dependencies = [ + "cesu8", + "combine", + "jni-sys", + "log", + "thiserror", + "walkdir", +] + +[[package]] +name = "jni-sys" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" + [[package]] name = "js-sys" version = "0.3.69" @@ -2196,10 +2245,21 @@ version = "0.22.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4b0e68d9af1f066c06d6e2397583795b912d78537d7d907c561e82c13d69fa1" dependencies = [ - "jsonrpsee-client-transport", - "jsonrpsee-core", + "jsonrpsee-client-transport 0.22.4", + "jsonrpsee-core 0.22.4", "jsonrpsee-http-client", - "jsonrpsee-types", + "jsonrpsee-types 0.22.4", +] + +[[package]] +name = "jsonrpsee" +version = "0.23.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b089779ad7f80768693755a031cc14a7766aba707cbe886674e3f79e9b7e47" +dependencies = [ + "jsonrpsee-core 0.23.2", + "jsonrpsee-types 0.23.2", + "jsonrpsee-ws-client", ] [[package]] @@ -2210,11 +2270,11 @@ checksum = "92f254f56af1ae84815b9b1325094743dcf05b92abb5e94da2e81a35cff0cada" dependencies = [ "futures-util", "http 0.2.12", - "jsonrpsee-core", + "jsonrpsee-core 0.22.4", "pin-project", "rustls-native-certs 0.7.0", "rustls-pki-types", - "soketto", + "soketto 0.7.1", "thiserror", "tokio", "tokio-rustls 0.25.0", @@ -2223,6 +2283,29 @@ dependencies = [ "url", ] +[[package]] +name = "jsonrpsee-client-transport" +version = "0.23.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08163edd8bcc466c33d79e10f695cdc98c00d1e6ddfb95cec41b6b0279dd5432" +dependencies = [ + "base64 0.22.0", + "futures-util", + "http 1.1.0", + "jsonrpsee-core 0.23.2", + "pin-project", + "rustls 0.23.7", + "rustls-pki-types", + "rustls-platform-verifier", + "soketto 0.8.0", + "thiserror", + "tokio", + "tokio-rustls 0.26.0", + "tokio-util", + "tracing", + "url", +] + [[package]] name = "jsonrpsee-core" version = "0.22.4" @@ -2235,7 +2318,29 @@ dependencies = [ "futures-timer", "futures-util", "hyper 0.14.28", - "jsonrpsee-types", + "jsonrpsee-types 0.22.4", + "pin-project", + "rustc-hash", + "serde", + "serde_json", + "thiserror", + "tokio", + "tokio-stream", + "tracing", +] + +[[package]] +name = "jsonrpsee-core" +version = "0.23.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79712302e737d23ca0daa178e752c9334846b08321d439fd89af9a384f8c830b" +dependencies = [ + "anyhow", + "async-trait", + "beef", + "futures-timer", + "futures-util", + "jsonrpsee-types 0.23.2", "pin-project", "rustc-hash", "serde", @@ -2255,8 +2360,8 @@ dependencies = [ "async-trait", "hyper 0.14.28", "hyper-rustls", - "jsonrpsee-core", - "jsonrpsee-types", + "jsonrpsee-core 0.22.4", + "jsonrpsee-types 0.22.4", "serde", "serde_json", "thiserror", @@ -2279,6 +2384,32 @@ dependencies = [ "thiserror", ] +[[package]] +name = "jsonrpsee-types" +version = "0.23.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9c465fbe385238e861fdc4d1c85e04ada6c1fd246161d26385c1b311724d2af" +dependencies = [ + "beef", + "http 1.1.0", + "serde", + "serde_json", + "thiserror", +] + +[[package]] +name = "jsonrpsee-ws-client" +version = "0.23.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c28759775f5cb2f1ea9667672d3fe2b0e701d1f4b7b67954e60afe7fd058b5e" +dependencies = [ + "http 1.1.0", + "jsonrpsee-client-transport 0.23.2", + "jsonrpsee-core 0.23.2", + "jsonrpsee-types 0.23.2", + "url", +] + [[package]] name = "k256" version = "0.13.3" @@ -3071,9 +3202,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.81" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] @@ -3138,6 +3269,22 @@ dependencies = [ "getrandom", ] +[[package]] +name = "reconnecting-jsonrpsee-ws-client" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06fa4f17e09edfc3131636082faaec633c7baa269396b4004040bc6c52f49f65" +dependencies = [ + "cfg_aliases", + "finito", + "futures", + "jsonrpsee 0.23.2", + "serde_json", + "thiserror", + "tokio", + "tracing", +] + [[package]] name = "redis" version = "0.25.3" @@ -3381,6 +3528,21 @@ dependencies = [ "zeroize", ] +[[package]] +name = "rustls" +version = "0.23.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebbbdb961df0ad3f2652da8f3fdc4b36122f568f968f45ad3316f26c025c677b" +dependencies = [ + "log", + "once_cell", + "ring", + "rustls-pki-types", + "rustls-webpki 0.102.3", + "subtle", + "zeroize", +] + [[package]] name = "rustls-native-certs" version = "0.6.3" @@ -3431,6 +3593,33 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "beb461507cee2c2ff151784c52762cf4d9ff6a61f3e80968600ed24fa837fa54" +[[package]] +name = "rustls-platform-verifier" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93bda3f493b9abe5b93b3e7e3ecde0df292f2bd28c0296b90586ee0055ff5123" +dependencies = [ + "core-foundation", + "core-foundation-sys", + "jni", + "log", + "once_cell", + "rustls 0.23.7", + "rustls-native-certs 0.7.0", + "rustls-platform-verifier-android", + "rustls-webpki 0.102.3", + "security-framework", + "security-framework-sys", + "webpki-roots", + "winapi", +] + +[[package]] +name = "rustls-platform-verifier-android" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f87165f0995f63a9fbeea62b64d10b4d9d8e78ec6d7d51fb2125fda7bb36788f" + [[package]] name = "rustls-webpki" version = "0.101.7" @@ -3486,9 +3675,9 @@ dependencies = [ [[package]] name = "scale-bits" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "662d10dcd57b1c2a3c41c9cf68f71fb09747ada1ea932ad961aca7e2ca28315f" +checksum = "e57b1e7f6b65ed1f04e79a85a57d755ad56d76fdf1e9bddcc9ae14f71fcdcf54" dependencies = [ "parity-scale-codec", "scale-info", @@ -3498,9 +3687,9 @@ dependencies = [ [[package]] name = "scale-decode" -version = "0.11.1" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afc79ba56a1c742f5aeeed1f1801f3edf51f7e818f0a54582cac6f131364ea7b" +checksum = "e98f3262c250d90e700bb802eb704e1f841e03331c2eb815e46516c4edbf5b27" dependencies = [ "derive_more", "parity-scale-codec", @@ -3513,9 +3702,9 @@ dependencies = [ [[package]] name = "scale-decode-derive" -version = "0.11.1" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5398fdb3c7bea3cb419bac4983aadacae93fe1a7b5f693f4ebd98c3821aad7a5" +checksum = "9bb22f574168103cdd3133b19281639ca65ad985e24612728f727339dcaf4021" dependencies = [ "darling 0.14.4", "proc-macro2", @@ -3525,9 +3714,9 @@ dependencies = [ [[package]] name = "scale-encode" -version = "0.6.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "628800925a33794fb5387781b883b5e14d130fece9af5a63613867b8de07c5c7" +checksum = "4ba0b9c48dc0eb20c60b083c29447c0c4617cb7c4a4c9fef72aa5c5bc539e15e" dependencies = [ "derive_more", "parity-scale-codec", @@ -3540,9 +3729,9 @@ dependencies = [ [[package]] name = "scale-encode-derive" -version = "0.6.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a304e1af7cdfbe7a24e08b012721456cc8cecdedadc14b3d10513eada63233c" +checksum = "82ab7e60e2d9c8d47105f44527b26f04418e5e624ffc034f6b4a86c0ba19c5bf" dependencies = [ "darling 0.14.4", "proc-macro-crate 1.3.1", @@ -3553,9 +3742,9 @@ dependencies = [ [[package]] name = "scale-info" -version = "2.11.2" +version = "2.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c453e59a955f81fb62ee5d596b450383d699f152d350e9d23a0db2adb78e4c0" +checksum = "eca070c12893629e2cc820a9761bedf6ce1dcddc9852984d1dc734b8bd9bd024" dependencies = [ "bitvec", "cfg-if", @@ -3567,11 +3756,11 @@ dependencies = [ [[package]] name = "scale-info-derive" -version = "2.11.2" +version = "2.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18cf6c6447f813ef19eb450e985bcce6705f9ce7660db221b59093d15c79c4b7" +checksum = "2d35494501194174bda522a32605929eefc9ecf7e0a326c26db1fdd85881eb62" dependencies = [ - "proc-macro-crate 1.3.1", + "proc-macro-crate 3.1.0", "proc-macro2", "quote", "syn 1.0.109", @@ -3579,9 +3768,9 @@ dependencies = [ [[package]] name = "scale-type-resolver" -version = "0.1.1" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10b800069bfd43374e0f96f653e0d46882a2cb16d6d961ac43bea80f26c76843" +checksum = "f0cded6518aa0bd6c1be2b88ac81bf7044992f0f154bfbabd5ad34f43512abcb" dependencies = [ "scale-info", "smallvec", @@ -3589,9 +3778,9 @@ dependencies = [ [[package]] name = "scale-typegen" -version = "0.2.1" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d470fa75e71b12b3244a4113adc4bc49891f3daba2054703cacd06256066397e" +checksum = "498d1aecf2ea61325d4511787c115791639c0fd21ef4f8e11e49dd09eff2bbac" dependencies = [ "proc-macro2", "quote", @@ -3602,9 +3791,9 @@ dependencies = [ [[package]] name = "scale-value" -version = "0.14.1" +version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c07ccfee963104335c971aaf8b7b0e749be8569116322df23f1f75c4ca9e4a28" +checksum = "5ab68da501822d2769c4c5823535f6104a6d4cd15f0d3eba3e647e725294ae22" dependencies = [ "base58", "blake2", @@ -3728,6 +3917,7 @@ dependencies = [ "core-foundation", "core-foundation-sys", "libc", + "num-bigint", "security-framework-sys", ] @@ -3749,9 +3939,9 @@ checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" [[package]] name = "serde" -version = "1.0.199" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c9f6e76df036c77cd94996771fb40db98187f096dd0b9af39c6c6e452ba966a" +checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" dependencies = [ "serde_derive", ] @@ -3767,9 +3957,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.199" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11bd257a6541e141e42ca6d24ae26f7714887b47e89aa739099104c7e4d3b7fc" +checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" dependencies = [ "proc-macro2", "quote", @@ -3778,11 +3968,12 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.116" +version = "1.0.122" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e17db7126d17feb94eb3fad46bf1a96b034e8aacbc2e775fe81505f8b0b2813" +checksum = "784b6203951c57ff748476b126ccb5e8e2959a5c19e5c617ab1956be3dbc68da" dependencies = [ "itoa", + "memchr", "ryu", "serde", ] @@ -3831,6 +4022,17 @@ dependencies = [ "opaque-debug", ] +[[package]] +name = "sha1" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.7", +] + [[package]] name = "sha1_smol" version = "1.0.0" @@ -3991,7 +4193,7 @@ dependencies = [ "siphasher", "slab", "smallvec", - "soketto", + "soketto 0.7.1", "twox-hash", "wasmi", "x25519-dalek", @@ -4059,6 +4261,21 @@ dependencies = [ "sha-1", ] +[[package]] +name = "soketto" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37468c595637c10857701c990f93a40ce0e357cedb0953d1c26c8d8027f9bb53" +dependencies = [ + "base64 0.22.0", + "bytes", + "futures", + "httparse", + "log", + "rand", + "sha1", +] + [[package]] name = "sp-application-crypto" version = "33.0.0" @@ -4199,17 +4416,6 @@ dependencies = [ "tracing-core", ] -[[package]] -name = "sp-keyring" -version = "34.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a07a31da596d705b3a3458d784a897af7fd2f8090de436dc386a112e8ea7f34f" -dependencies = [ - "sp-core", - "sp-runtime", - "strum", -] - [[package]] name = "sp-keystore" version = "0.37.0" @@ -4457,28 +4663,6 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" -[[package]] -name = "strum" -version = "0.24.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" -dependencies = [ - "strum_macros", -] - -[[package]] -name = "strum_macros" -version = "0.24.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" -dependencies = [ - "heck 0.4.1", - "proc-macro2", - "quote", - "rustversion", - "syn 1.0.109", -] - [[package]] name = "substrate-bip39" version = "0.5.0" @@ -4500,23 +4684,22 @@ checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" [[package]] name = "subxt" -version = "0.35.3" +version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd68bef23f4de5e513ab4c29af69053e232b098f9c87ab552d7ea153b4a1fbc5" +checksum = "a160cba1edbf3ec4fbbeaea3f1a185f70448116a6bccc8276bb39adb3b3053bd" dependencies = [ "async-trait", - "base58", - "blake2", - "derivative", + "derive-where", "either", "frame-metadata 16.0.0", "futures", "hex", "impl-serde", "instant", - "jsonrpsee", + "jsonrpsee 0.22.4", "parity-scale-codec", "primitive-types", + "reconnecting-jsonrpsee-ws-client", "scale-bits", "scale-decode", "scale-encode", @@ -4524,9 +4707,8 @@ dependencies = [ "scale-value", "serde", "serde_json", - "sp-core", "sp-crypto-hashing", - "sp-runtime", + "subxt-core", "subxt-lightclient", "subxt-macro", "subxt-metadata", @@ -4538,14 +4720,14 @@ dependencies = [ [[package]] name = "subxt-codegen" -version = "0.35.3" +version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d9e2b256b71d31a2629e44eb9cbfd944eb7d577c9e0c8e9802cc3c3943af2d9" +checksum = "d703dca0905cc5272d7cc27a4ac5f37dcaae7671acc7fef0200057cc8c317786" dependencies = [ "frame-metadata 16.0.0", - "heck 0.4.1", + "heck", "hex", - "jsonrpsee", + "jsonrpsee 0.22.4", "parity-scale-codec", "proc-macro2", "quote", @@ -4557,11 +4739,40 @@ dependencies = [ "tokio", ] +[[package]] +name = "subxt-core" +version = "0.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59f41eb2e2eea6ed45649508cc735f92c27f1fcfb15229e75f8270ea73177345" +dependencies = [ + "base58", + "blake2", + "derive-where", + "frame-metadata 16.0.0", + "hashbrown 0.14.5", + "hex", + "impl-serde", + "parity-scale-codec", + "primitive-types", + "scale-bits", + "scale-decode", + "scale-encode", + "scale-info", + "scale-value", + "serde", + "serde_json", + "sp-core", + "sp-crypto-hashing", + "sp-runtime", + "subxt-metadata", + "tracing", +] + [[package]] name = "subxt-lightclient" -version = "0.35.3" +version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d51f1ac12e3be7aafea4d037730a57da4f22f2e9c73955666081ffa2697c6f1" +checksum = "9d9406fbdb9548c110803cb8afa750f8b911d51eefdf95474b11319591d225d9" dependencies = [ "futures", "futures-util", @@ -4576,9 +4787,9 @@ dependencies = [ [[package]] name = "subxt-macro" -version = "0.35.3" +version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98dc84d7e6a0abd7ed407cce0bf60d7d58004f699460cffb979640717d1ab506" +checksum = "1c195f803d70687e409aba9be6c87115b5da8952cd83c4d13f2e043239818fcd" dependencies = [ "darling 0.20.8", "parity-scale-codec", @@ -4591,11 +4802,10 @@ dependencies = [ [[package]] name = "subxt-metadata" -version = "0.35.3" +version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc10c54028d079a9f1be65188707cd29e5ffd8d0031a2b1346a0941d57b7ab7e" +checksum = "738be5890fdeff899bbffff4d9c0f244fe2a952fb861301b937e3aa40ebb55da" dependencies = [ - "derive_more", "frame-metadata 16.0.0", "hashbrown 0.14.5", "parity-scale-codec", @@ -4603,6 +4813,28 @@ dependencies = [ "sp-crypto-hashing", ] +[[package]] +name = "subxt-signer" +version = "0.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f49888ae6ae90fe01b471193528eea5bd4ed52d8eecd2d13f4a2333b87388850" +dependencies = [ + "bip39", + "cfg-if", + "hex", + "hmac 0.12.1", + "parity-scale-codec", + "pbkdf2", + "regex", + "schnorrkel", + "secp256k1", + "secrecy", + "sha2 0.10.8", + "sp-crypto-hashing", + "subxt-core", + "zeroize", +] + [[package]] name = "syn" version = "1.0.109" @@ -4687,18 +4919,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.59" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0126ad08bff79f29fc3ae6a55cc72352056dfff61e3ff8bb7129476d44b23aa" +checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.59" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1cd413b5d558b4c5bf3680e324a6fa5014e7b7c067a51e69dbdf47eb7148b66" +checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2", "quote", @@ -4772,9 +5004,7 @@ dependencies = [ "libc", "mio", "num_cpus", - "parking_lot", "pin-project-lite", - "signal-hook-registry", "socket2", "tokio-macros", "windows-sys 0.48.0", @@ -4822,6 +5052,17 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-rustls" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" +dependencies = [ + "rustls 0.23.7", + "rustls-pki-types", + "tokio", +] + [[package]] name = "tokio-stream" version = "0.1.15" @@ -4835,9 +5076,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.10" +version = "0.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" +checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" dependencies = [ "bytes", "futures-core", @@ -4845,7 +5086,6 @@ dependencies = [ "futures-sink", "pin-project-lite", "tokio", - "tracing", ] [[package]] @@ -5518,6 +5758,15 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "webpki-roots" +version = "0.26.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd7c23921eeb1713a4e851530e9b9756e4fb0e89978582942612524cf09f01cd" +dependencies = [ + "rustls-pki-types", +] + [[package]] name = "winapi" version = "0.3.9" diff --git a/gsy-matching-engine/Cargo.toml b/gsy-matching-engine/Cargo.toml index d20a690..47342e2 100644 --- a/gsy-matching-engine/Cargo.toml +++ b/gsy-matching-engine/Cargo.toml @@ -12,22 +12,19 @@ path = "src/lib.rs" path = "src/main.rs" name = "gsy-matching-engine" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] anyhow = "1" async-recursion = "1" -chrono = { version = "0.4", features = ["serde", "rustc-serialize"]} +chrono = { version = "0.4.37", features = ["serde", "rustc-serialize"]} clap = { version = "4", features = ["derive"]} codec = { package = "parity-scale-codec", version = "3.6.9", default-features = false, features = ["derive", "full", "bit-vec"] } -futures = "0" +futures = "0.3.30" reqwest = { version = "0", features = ["json"] } serde = { version = "1.0", features = ["derive"] } -serde_json = "*" -subxt = { version = "0.35.1", features = ["substrate-compat"] } -# Needs to not conflict with the subxt version -sp-keyring = { version = "34.0.0" } -tokio = { version = "*", features = ["full"] } +serde_json = { version = "1.0"} +subxt = { version = "0.37", features = ["substrate-compat"] } +subxt-signer = "0.37" +tokio = { version = "1", features = ["macros", "rt-multi-thread"] } tracing = { version = "0.1", features = ["log"] } tracing-bunyan-formatter = "0.3" tracing-log = "0.2" diff --git a/gsy-matching-engine/Dockerfile b/gsy-matching-engine/Dockerfile index 0d96bbb..b865b12 100644 --- a/gsy-matching-engine/Dockerfile +++ b/gsy-matching-engine/Dockerfile @@ -1,28 +1,13 @@ -FROM rust:1.49 as build +FROM rust:1.80 -# create a new empty shell project -RUN USER=root cargo new --bin matching-engine -WORKDIR /gsy-matching-engine - -# copy manifests -COPY ./Cargo.toml ./Cargo.toml - -# cache dependencies -RUN cargo build --release -RUN rm src/*.rs - -# copy source tree -COPY ./src ./src +ADD gsy-matching-engine /var/www/gsy-matching-engine/ # build for release -RUN rm ./target/release/deps/gsy-matching-engine* -RUN cargo build --release +RUN rm -rf /var/www/gsy-matching-engine/target/ -# final base -FROM rust:1.49 +WORKDIR /var/www/gsy-matching-engine/ -# copy the build artifact from the build stage -COPY --from=build /matching-engine/target/release/gsy-matching-engine . +RUN cargo build --release # set the startup command to run your binary -CMD ["./gsy-matching-engine"] \ No newline at end of file +ENTRYPOINT ["/var/www/gsy-matching-engine/target/release/gsy-matching-engine", "web3", "http://gsy-orderbook", "8080", "ws://gsy-node", "9944"] diff --git a/gsy-matching-engine/src/connectors/substrate_connector.rs b/gsy-matching-engine/src/connectors/substrate_connector.rs index f7f007f..1b76c6a 100644 --- a/gsy-matching-engine/src/connectors/substrate_connector.rs +++ b/gsy-matching-engine/src/connectors/substrate_connector.rs @@ -6,18 +6,17 @@ use crate::primitives::web3_extension::BidOfferMatch as BidOfferMatchExtension; use anyhow::{Error, Result}; use async_recursion::async_recursion; use codec::{Decode, Encode}; -use sp_keyring::AccountKeyring; +use subxt_signer::sr25519::dev; use std::sync::{Arc, Mutex}; use std::{thread, time}; use subxt::{ SubstrateConfig, OnlineClient, - tx::PairSigner, utils::AccountId32 }; use tracing::{error, info}; -const MATCH_PER_NR_BLOCKS: u8 = 4; +const MATCH_PER_NR_BLOCKS: u64 = 4; #[subxt::subxt(runtime_metadata_path = "metadata.scale")] pub mod gsy_node {} @@ -30,7 +29,7 @@ use crate::connectors::substrate_connector::gsy_node::runtime_types::gsy_primiti pub async fn substrate_subscribe(orderbook_url: String, node_url: String) -> Result<(), Error> { info!("Connecting to {}", node_url); - let api = OnlineClient::::from_url(node_url.clone()).await?; + let api = OnlineClient::::from_insecure_url(node_url.clone()).await?; let mut gsy_blocks_events = api.blocks().subscribe_finalized().await?; @@ -130,13 +129,12 @@ async fn send_settle_trades_extrinsic( url: String, matches: Vec>, ) -> Result<(), Error> { - let signer = PairSigner::new(AccountKeyring::Alice.pair()); - info!("Signer: {:?}", signer.account_id()); let api = OnlineClient::::from_url(url).await?; let trade_settlement_tx = gsy_node::tx().trades_settlement().settle_trades(matches); + let signer = dev::alice(); let order_submit_and_watch = api .tx() .sign_and_submit_then_watch_default(&trade_settlement_tx, &signer) diff --git a/gsy-node/Cargo.toml b/gsy-node/Cargo.toml index ee4fa7f..5f1057c 100644 --- a/gsy-node/Cargo.toml +++ b/gsy-node/Cargo.toml @@ -14,6 +14,11 @@ panic = "unwind" [workspace.dependencies] gsy-primitives = { version = '0.0.2', default-features = false, path = '../primitives' } +gsy-collateral = { version = '0.0.2', default-features = false, path = './modules/gsy-collateral' } +orderbook-registry = { version = '0.0.2', default-features = false, path = './modules/orderbook-registry' } +orderbook-worker = { version = '0.0.2', default-features = false, path = './modules/orderbook-worker' } +trades-settlement = { version = '0.0.2', default-features = false, path = './modules/trades-settlement' } + # Base substrate frame dependencies codec = { package = "parity-scale-codec", version = "3.6.9", default-features = false, features = ["derive"] } scale-info = { version = "2.11.2", default-features = false, features = ["derive"] } diff --git a/gsy-node/Dockerfile b/gsy-node/Dockerfile new file mode 100644 index 0000000..dff66ab --- /dev/null +++ b/gsy-node/Dockerfile @@ -0,0 +1,27 @@ +FROM ubuntu:22.04 + +WORKDIR /root +ENV PATH=$PATH:/root/.cargo/bin + +RUN apt-get update && \ + apt-get upgrade -y && \ + apt-get install -y cmake curl libssl-dev git clang llvm libudev-dev protobuf-compiler && \ + apt-get clean && \ + curl https://sh.rustup.rs -sSf | sh -s -- -y +RUN rustup default stable && \ + rustup update && \ + rustup update nightly && \ + rustup component add rust-src --toolchain stable-x86_64-unknown-linux-gnu && \ + rustup target add wasm32-unknown-unknown --toolchain stable-x86_64-unknown-linux-gnu + +ADD gsy-node /var/www/gsy-node/ +ADD primitives /var/www/primitives/ + +WORKDIR /var/www/gsy-node/ + +ENV ORDERBOOK_SERVICE_URL=gsy-orderbook:8080 +RUN cargo build --release + +EXPOSE 9944 + +ENTRYPOINT ["./target/release/gsy-node", "--dev", "--rpc-external", "--ws-external"] diff --git a/gsy-node/modules/orderbook-worker/src/configuration.rs b/gsy-node/modules/orderbook-worker/src/configuration.rs index 1627ed2..dfd12bc 100644 --- a/gsy-node/modules/orderbook-worker/src/configuration.rs +++ b/gsy-node/modules/orderbook-worker/src/configuration.rs @@ -10,7 +10,7 @@ pub struct OrderBookServiceURL { impl Default for OrderBookServiceURL{ fn default() -> Self { // Set the environment variable "URL" for OrderBook_Service - let orderbook_service_url: &'static str = env!("URL", "Set the orderbook service url"); + let orderbook_service_url: &'static str = env!("ORDERBOOK_SERVICE_URL", "Set the orderbook service url"); OrderBookServiceURL{ url: orderbook_service_url.to_string() } } } diff --git a/gsy-node/runtime/Cargo.toml b/gsy-node/runtime/Cargo.toml index adc9da2..b1949d1 100644 --- a/gsy-node/runtime/Cargo.toml +++ b/gsy-node/runtime/Cargo.toml @@ -55,10 +55,10 @@ sp-version = { workspace = true } sp-genesis-builder = { workspace = true } # Custom Pallets -orderbook-registry = { version = "0.0.2", default-features = false, path = "../modules/orderbook-registry" } -orderbook-worker = { version = "0.0.2", default-features = false, path = "../modules/orderbook-worker" } -gsy-collateral = { version = "0.0.2", default-features = false, path = "../modules/gsy-collateral" } -trades-settlement = { version = "0.0.2", default-features = false, path = "../modules/trades-settlement" } +orderbook-registry = { workspace = true } +orderbook-worker = { workspace = true } +gsy-collateral = { workspace = true } +trades-settlement = { workspace = true } # Used for the GSy node's RPCs frame-system-rpc-runtime-api = { workspace = true } diff --git a/gsy-orderbook-service/Cargo.toml b/gsy-orderbook-service/Cargo.toml index 033b446..45343eb 100644 --- a/gsy-orderbook-service/Cargo.toml +++ b/gsy-orderbook-service/Cargo.toml @@ -24,7 +24,7 @@ envy = "0.4" futures = "0.3.30" mongodb = "2.8.2" serde = { version = "1.0", features = ["derive"] } -serde_json = {version = "1.0"} +serde_json = { version = "1.0"} subxt = { version = "0.35.1", features = ["substrate-compat"] } tokio = { version = "1", features = ["macros", "rt-multi-thread"] } tokio_schedule = "0.3.0" diff --git a/gsy-orderbook-service/Dockerfile b/gsy-orderbook-service/Dockerfile new file mode 100644 index 0000000..1698f37 --- /dev/null +++ b/gsy-orderbook-service/Dockerfile @@ -0,0 +1,14 @@ +FROM rust:1.80 + +ADD gsy-orderbook-service /var/www/gsy-orderbook-service/ + +# build for release +RUN rm -rf /var/www/gsy-orderbook-service/target/ + +WORKDIR /var/www/gsy-orderbook-service/ + +RUN cargo build --release + +EXPOSE 8080 + +ENTRYPOINT ["./target/release/gsy-orderbook-service"]