From 4d444a11c9b5fc91db325c660f8984c88402e88f Mon Sep 17 00:00:00 2001 From: mario4tier Date: Thu, 11 Jan 2024 11:52:43 -0500 Subject: [PATCH] (#85) Network Viewer - Write Sui events in SQLite in-memory DB --- rust/demo-app/Cargo.lock | 1729 ++--------------- rust/demo-app/crates/demo/src/counter.rs | 2 +- rust/demo-app/move/sources/counter.move | 4 +- rust/helper/Cargo.lock | 28 +- .../suibase-daemon/src/admin_controller.rs | 11 +- .../suibase-daemon/src/api/api_server.rs | 4 +- .../suibase-daemon/src/api/def_methods.rs | 2 +- .../src/basic_types/auto_thread.rs | 9 +- .../src/basic_types/db_objects.rs | 7 +- .../src/basic_types/suibase_basic_types.rs | 35 +- .../suibase-daemon/src/clock_trigger.rs | 4 +- .../suibase-daemon/src/network_monitor.rs | 4 +- .../suibase-daemon/src/workdirs_watcher.rs | 4 +- .../suibase-daemon/src/workers/db_worker.rs | 771 +++++++- .../src/workers/events_writer_worker.rs | 65 +- .../src/workers/package_tracking.rs | 20 +- .../src/workers/request_worker.rs | 4 +- .../src/workers/shell_worker.rs | 8 +- .../src/workers/websocket_worker.rs | 269 ++- scripts/common/__publish.sh | 10 +- 20 files changed, 1235 insertions(+), 1755 deletions(-) diff --git a/rust/demo-app/Cargo.lock b/rust/demo-app/Cargo.lock index 2594b8e3..a3d0d4cb 100644 --- a/rust/demo-app/Cargo.lock +++ b/rust/demo-app/Cargo.lock @@ -69,7 +69,7 @@ version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a824f2aa7e75a0c98c5a504fceb80649e9c35265d44525b5f94de4771a395cd" dependencies = [ - "getrandom 0.2.10", + "getrandom", "once_cell", "version_check", ] @@ -149,7 +149,7 @@ dependencies = [ "pkcs8 0.9.0", "quinn", "quinn-proto", - "rand 0.8.5", + "rand", "rcgen", "ring 0.16.20", "rustls 0.21.8", @@ -257,9 +257,6 @@ name = "arc-swap" version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bddcadddf5e9015d310179a59bb28c4d4b9920ad0f11e8e14dbadf654890c9a6" -dependencies = [ - "serde", -] [[package]] name = "ark-bls12-381" @@ -454,7 +451,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94893f1e0c6eeab764ade8dc4c0db24caf4fe7cbbaafc0eba0a9030f447b5185" dependencies = [ "num-traits", - "rand 0.8.5", + "rand", ] [[package]] @@ -463,12 +460,6 @@ version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" -[[package]] -name = "arrayvec" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" - [[package]] name = "arrayvec" version = "0.7.4" @@ -575,12 +566,6 @@ dependencies = [ "syn 2.0.38", ] -[[package]] -name = "async_once" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ce4f10ea3abcd6617873bae9f91d1c5332b4a778bd9ce34d0cd517474c1de82" - [[package]] name = "atomic_float" version = "0.1.0" @@ -699,10 +684,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b62ddb9cb1ec0a098ad4bbf9344d0713fa193ae1a80af55febcff2627b6a00c1" dependencies = [ "futures-core", - "getrandom 0.2.10", + "getrandom", "instant", "pin-project-lite", - "rand 0.8.5", + "rand", "tokio", ] @@ -776,6 +761,12 @@ dependencies = [ "thiserror", ] +[[package]] +name = "bech32" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d86b93f97252c47b41663388e6d155714a9d0c398b99f1005cbc5f978b29f445" + [[package]] name = "beef" version = "0.5.2" @@ -809,26 +800,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "better_any" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b359aebd937c17c725e19efcb661200883f04c49c53e7132224dac26da39d4a0" -dependencies = [ - "better_typeid_derive", -] - -[[package]] -name = "better_typeid_derive" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3deeecb812ca5300b7d3f66f730cc2ebd3511c3d36c691dd79c165d5b19a26e3" -dependencies = [ - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 1.0.109", -] - [[package]] name = "bincode" version = "1.3.3" @@ -870,7 +841,7 @@ dependencies = [ "k256", "once_cell", "pbkdf2", - "rand_core 0.6.4", + "rand_core", "ripemd", "sha2 0.10.8", "subtle", @@ -968,7 +939,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23285ad32269793932e830392f2fe2f83e26488fd3ec778883a93c8323735780" dependencies = [ "arrayref", - "arrayvec 0.7.4", + "arrayvec", "constant_time_eq", ] @@ -979,7 +950,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94230421e395b9920d23df13ea5d77a20e1725331f90fbbf6df6040b33f756ae" dependencies = [ "arrayref", - "arrayvec 0.7.4", + "arrayvec", "constant_time_eq", ] @@ -990,7 +961,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0231f06152bf547e9c2b5194f247cd97aacf6dcd8b15d8e5ec0663f64580da87" dependencies = [ "arrayref", - "arrayvec 0.7.4", + "arrayvec", "cc", "cfg-if", "constant_time_eq", @@ -1054,7 +1025,7 @@ dependencies = [ "ff 0.13.0", "group 0.13.0", "pairing", - "rand_core 0.6.4", + "rand_core", "serde", "subtle", ] @@ -1110,8 +1081,8 @@ dependencies = [ "curve25519-dalek-ng", "digest 0.9.0", "merlin", - "rand 0.8.5", - "rand_core 0.6.4", + "rand", + "rand_core", "serde", "serde_derive", "sha3 0.9.1", @@ -1178,50 +1149,6 @@ dependencies = [ "pkg-config", ] -[[package]] -name = "cached" -version = "0.43.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc2fafddf188d13788e7099295a59b99e99b2148ab2195cae454e754cc099925" -dependencies = [ - "async-trait", - "async_once", - "cached_proc_macro", - "cached_proc_macro_types", - "futures", - "hashbrown 0.13.2", - "instant", - "lazy_static", - "once_cell", - "thiserror", - "tokio", -] - -[[package]] -name = "cached_proc_macro" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e10ca87c81aaa3a949dbbe2b5e6c2c45dbc94ba4897e45ea31ff9ec5087be3dc" -dependencies = [ - "cached_proc_macro_types", - "darling 0.14.4", - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 1.0.109", -] - -[[package]] -name = "cached_proc_macro_types" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a4f925191b4367301851c6d99b09890311d74b0d43f274c0b34c86d308a3663" - -[[package]] -name = "camino" -version = "1.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c59e92b5a388f549b863a7bea62612c09f24c8393560709a54558a9abdfb3b9c" - [[package]] name = "cbc" version = "0.1.2" @@ -1271,28 +1198,6 @@ dependencies = [ "windows-targets 0.48.5", ] -[[package]] -name = "chrono-tz" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e23185c0e21df6ed832a12e2bda87c7d1def6842881fb634a8511ced741b0d76" -dependencies = [ - "chrono", - "chrono-tz-build", - "phf", -] - -[[package]] -name = "chrono-tz-build" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "433e39f13c9a060046954e0592a8d0a4bcb1040125cbf91cb8ee58964cfb350f" -dependencies = [ - "parse-zoneinfo", - "phf", - "phf_codegen", -] - [[package]] name = "cipher" version = "0.4.4" @@ -1550,30 +1455,6 @@ dependencies = [ "crossbeam-utils", ] -[[package]] -name = "crossbeam-deque" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" -dependencies = [ - "cfg-if", - "crossbeam-epoch", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-epoch" -version = "0.9.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7" -dependencies = [ - "autocfg", - "cfg-if", - "crossbeam-utils", - "memoffset", - "scopeguard", -] - [[package]] name = "crossbeam-utils" version = "0.8.16" @@ -1593,7 +1474,7 @@ dependencies = [ "crossterm_winapi", "libc", "mio", - "parking_lot 0.12.1", + "parking_lot", "signal-hook", "signal-hook-mio", "winapi", @@ -1621,7 +1502,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef2b4b23cddf68b89b8f8069890e8c270d54e2d5fe1b143820234805e4cb17ef" dependencies = [ "generic-array", - "rand_core 0.6.4", + "rand_core", "subtle", "zeroize", ] @@ -1633,7 +1514,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "740fe28e594155f10cfc383984cbefd529d7396050557148f79cb0f621204124" dependencies = [ "generic-array", - "rand_core 0.6.4", + "rand_core", "subtle", "zeroize", ] @@ -1645,7 +1526,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ "generic-array", - "rand_core 0.6.4", + "rand_core", "typenum", ] @@ -1687,7 +1568,7 @@ checksum = "1c359b7249347e46fb28804470d071c921156ad62b3eef5d34e2ba867533dec8" dependencies = [ "byteorder", "digest 0.9.0", - "rand_core 0.6.4", + "rand_core", "serde", "subtle-ng", "zeroize", @@ -1773,7 +1654,7 @@ dependencies = [ "hashbrown 0.14.2", "lock_api", "once_cell", - "parking_lot_core 0.9.9", + "parking_lot_core", ] [[package]] @@ -1931,12 +1812,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "deunicode" -version = "1.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ae2a35373c5c74340b79ae6780b498b2b183915ec5dacf263aac5a099bf485a" - [[package]] name = "difference" version = "2.0.0" @@ -2097,7 +1972,7 @@ checksum = "3c8465edc8ee7436ffea81d21a019b16676ee3db267aa8d5a8d729581ecf998b" dependencies = [ "curve25519-dalek-ng", "hex", - "rand_core 0.6.4", + "rand_core", "serde", "sha2 0.9.9", "thiserror", @@ -2123,7 +1998,7 @@ dependencies = [ "ff 0.12.1", "generic-array", "group 0.12.1", - "rand_core 0.6.4", + "rand_core", "sec1 0.3.0", "subtle", "zeroize", @@ -2143,7 +2018,7 @@ dependencies = [ "group 0.13.0", "pem-rfc7468 0.7.0", "pkcs8 0.10.2", - "rand_core 0.6.4", + "rand_core", "sec1 0.7.3", "subtle", "zeroize", @@ -2231,21 +2106,10 @@ dependencies = [ "once_cell", ] -[[package]] -name = "fail" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3be3c61c59fdc91f5dbc3ea31ee8623122ce80057058be560654c5d410d181a6" -dependencies = [ - "lazy_static", - "log", - "rand 0.7.3", -] - [[package]] name = "fastcrypto" version = "0.1.7" -source = "git+https://github.com/MystenLabs/fastcrypto?rev=643831ec3b67bdd2b5f998c0bec1b7c91823351f#643831ec3b67bdd2b5f998c0bec1b7c91823351f" +source = "git+https://github.com/MystenLabs/fastcrypto?rev=c18dc3835f26bc5cf2848ffd32228071fe540071#c18dc3835f26bc5cf2848ffd32228071fe540071" dependencies = [ "aes", "aes-gcm", @@ -2255,6 +2119,7 @@ dependencies = [ "ark-serialize", "auto_ops", "base64ct", + "bech32", "bincode", "blake2", "blake3", @@ -2276,9 +2141,10 @@ dependencies = [ "hkdf", "lazy_static", "merlin", + "num-bigint 0.4.4", "once_cell", "p256", - "rand 0.8.5", + "rand", "readonly", "rfc6979 0.4.0", "rsa", @@ -2301,7 +2167,7 @@ dependencies = [ [[package]] name = "fastcrypto-derive" version = "0.1.3" -source = "git+https://github.com/MystenLabs/fastcrypto?rev=643831ec3b67bdd2b5f998c0bec1b7c91823351f#643831ec3b67bdd2b5f998c0bec1b7c91823351f" +source = "git+https://github.com/MystenLabs/fastcrypto?rev=c18dc3835f26bc5cf2848ffd32228071fe540071#c18dc3835f26bc5cf2848ffd32228071fe540071" dependencies = [ "convert_case 0.6.0", "proc-macro2 1.0.69", @@ -2312,7 +2178,7 @@ dependencies = [ [[package]] name = "fastcrypto-tbls" version = "0.1.0" -source = "git+https://github.com/MystenLabs/fastcrypto?rev=643831ec3b67bdd2b5f998c0bec1b7c91823351f#643831ec3b67bdd2b5f998c0bec1b7c91823351f" +source = "git+https://github.com/MystenLabs/fastcrypto?rev=c18dc3835f26bc5cf2848ffd32228071fe540071#c18dc3835f26bc5cf2848ffd32228071fe540071" dependencies = [ "bcs", "bincode", @@ -2321,7 +2187,7 @@ dependencies = [ "fastcrypto-derive", "hex", "itertools 0.10.5", - "rand 0.8.5", + "rand", "serde", "sha3 0.10.8", "tap", @@ -2333,7 +2199,7 @@ dependencies = [ [[package]] name = "fastcrypto-zkp" version = "0.1.2" -source = "git+https://github.com/MystenLabs/fastcrypto?rev=643831ec3b67bdd2b5f998c0bec1b7c91823351f#643831ec3b67bdd2b5f998c0bec1b7c91823351f" +source = "git+https://github.com/MystenLabs/fastcrypto?rev=c18dc3835f26bc5cf2848ffd32228071fe540071#c18dc3835f26bc5cf2848ffd32228071fe540071" dependencies = [ "ark-bls12-381", "ark-bn254", @@ -2384,7 +2250,7 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d013fc25338cc558c5c2cfbad646908fb23591e2404481826742b651c9af7160" dependencies = [ - "rand_core 0.6.4", + "rand_core", "subtle", ] @@ -2397,7 +2263,7 @@ dependencies = [ "bitvec 1.0.1", "byteorder", "ff_derive", - "rand_core 0.6.4", + "rand_core", "subtle", ] @@ -2424,7 +2290,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cfcf0ed7fe52a17a03854ec54a9f76d6d84508d1c0e66bc1793301c73fc8493c" dependencies = [ "byteorder", - "rand 0.8.5", + "rand", "rustc-hex", "static_assertions", ] @@ -2600,17 +2466,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "getrandom" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" -dependencies = [ - "cfg-if", - "libc", - "wasi 0.9.0+wasi-snapshot-preview1", -] - [[package]] name = "getrandom" version = "0.2.10" @@ -2619,17 +2474,7 @@ checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" dependencies = [ "cfg-if", "libc", - "wasi 0.11.0+wasi-snapshot-preview1", -] - -[[package]] -name = "gettid" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34b20f40277dfb8a9dec7e2e945f6d8ff711e733c8f2a2c9b257562764b4c60d" -dependencies = [ - "libc", - "winapi", + "wasi", ] [[package]] @@ -2648,26 +2493,6 @@ version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" -[[package]] -name = "git-version" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ad568aa3db0fcbc81f2f116137f263d7304f512a1209b35b85150d3ef88ad19" -dependencies = [ - "git-version-macro", -] - -[[package]] -name = "git-version-macro" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53010ccb100b96a67bc32c0175f0ed1426b31b655d562898e57325f81c023ac0" -dependencies = [ - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 2.0.38", -] - [[package]] name = "glob" version = "0.3.1" @@ -2687,17 +2512,6 @@ dependencies = [ "regex-syntax 0.8.2", ] -[[package]] -name = "globwalk" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93e3af942408868f6934a7b85134a3230832b9977cf66125df2f9edcfce4ddcc" -dependencies = [ - "bitflags 1.3.2", - "ignore", - "walkdir", -] - [[package]] name = "governor" version = "0.6.0" @@ -2710,9 +2524,9 @@ dependencies = [ "futures-timer", "no-std-compat", "nonzero_ext", - "parking_lot 0.12.1", + "parking_lot", "quanta", - "rand 0.8.5", + "rand", "smallvec", ] @@ -2723,7 +2537,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" dependencies = [ "ff 0.12.1", - "rand_core 0.6.4", + "rand_core", "subtle", ] @@ -2734,8 +2548,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" dependencies = [ "ff 0.13.0", - "rand 0.8.5", - "rand_core 0.6.4", + "rand", + "rand_core", "rand_xorshift", "subtle", ] @@ -2924,15 +2738,6 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" -[[package]] -name = "humansize" -version = "2.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6cb51c9a029ddc91b07a787f1d86b53ccfa49b0e86688c946ebe8d3555685dd7" -dependencies = [ - "libm", -] - [[package]] name = "humantime" version = "2.1.0" @@ -3046,22 +2851,6 @@ dependencies = [ "unicode-normalization", ] -[[package]] -name = "ignore" -version = "0.4.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "747ad1b4ae841a78e8aba0d63adbfbeaea26b517b63705d47856b73015d27060" -dependencies = [ - "crossbeam-deque", - "globset", - "log", - "memchr", - "regex-automata 0.4.3", - "same-file", - "walkdir", - "winapi-util", -] - [[package]] name = "im" version = "15.1.0" @@ -3069,7 +2858,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d0acd33ff0285af998aaf9b57342af478078f53492322fafc47450e09397e0e9" dependencies = [ "bitmaps", - "rand_core 0.6.4", + "rand_core", "rand_xoshiro", "sized-chunks", "typenum", @@ -3130,6 +2919,7 @@ checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" dependencies = [ "equivalent", "hashbrown 0.14.2", + "serde", ] [[package]] @@ -3196,7 +2986,7 @@ dependencies = [ "dashmap", "hashbrown 0.12.3", "once_cell", - "parking_lot 0.12.1", + "parking_lot", ] [[package]] @@ -3316,7 +3106,7 @@ version = "0.16.2" source = "git+https://github.com/wlmyng/jsonrpsee.git?rev=b1b300784795f6a64d0fcdf8f03081a9bc38bde8#b1b300784795f6a64d0fcdf8f03081a9bc38bde8" dependencies = [ "anyhow", - "arrayvec 0.7.4", + "arrayvec", "async-lock", "async-trait", "beef", @@ -3326,8 +3116,8 @@ dependencies = [ "globset", "hyper", "jsonrpsee-types", - "parking_lot 0.12.1", - "rand 0.8.5", + "parking_lot", + "rand", "rustc-hash", "serde", "serde_json", @@ -3449,12 +3239,6 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" -[[package]] -name = "leb128" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" - [[package]] name = "libc" version = "0.2.149" @@ -3596,24 +3380,6 @@ version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" -[[package]] -name = "memmap2" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f49388d20533534cd19360ad3d6a7dadc885944aa802ba3995040c5ec11288c6" -dependencies = [ - "libc", -] - -[[package]] -name = "memoffset" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" -dependencies = [ - "autocfg", -] - [[package]] name = "merlin" version = "3.0.0" @@ -3622,7 +3388,7 @@ checksum = "58c38e2799fc0978b65dfff8023ec7843e2330bb462f19198840b34b6582397d" dependencies = [ "byteorder", "keccak", - "rand_core 0.6.4", + "rand_core", "zeroize", ] @@ -3642,15 +3408,6 @@ dependencies = [ "unicase", ] -[[package]] -name = "minibytes" -version = "0.1.0" -source = "git+https://github.com/MystenLabs/mysticeti?rev=318d61d27f47d257d99a86983d835e9e9756bc59#318d61d27f47d257d99a86983d835e9e9756bc59" -dependencies = [ - "memmap2", - "serde", -] - [[package]] name = "minimal-lexical" version = "0.2.1" @@ -3674,7 +3431,7 @@ checksum = "3dce281c5e46beae905d4de1870d8b1509a9142b62eedf18b443b011ca8343d0" dependencies = [ "libc", "log", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", "windows-sys 0.48.0", ] @@ -3763,42 +3520,6 @@ dependencies = [ "petgraph 0.5.1", ] -[[package]] -name = "move-bytecode-verifier-next-vm" -version = "0.1.0" -dependencies = [ - "move-abstract-stack", - "move-binary-format", - "move-borrow-graph", - "move-core-types", - "move-vm-config", - "petgraph 0.5.1", -] - -[[package]] -name = "move-bytecode-verifier-v0" -version = "0.1.0" -dependencies = [ - "move-abstract-stack", - "move-binary-format", - "move-borrow-graph", - "move-core-types", - "move-vm-config", - "petgraph 0.5.1", -] - -[[package]] -name = "move-bytecode-verifier-v1" -version = "0.1.0" -dependencies = [ - "move-abstract-stack", - "move-binary-format", - "move-borrow-graph", - "move-core-types", - "move-vm-config", - "petgraph 0.5.1", -] - [[package]] name = "move-command-line-common" version = "0.1.0" @@ -3853,7 +3574,7 @@ dependencies = [ "num", "once_cell", "primitive-types", - "rand 0.8.5", + "rand", "ref-cast", "serde", "serde_bytes", @@ -3913,17 +3634,6 @@ dependencies = [ "serde", ] -[[package]] -name = "move-errmapgen" -version = "0.1.0" -dependencies = [ - "anyhow", - "move-command-line-common", - "move-core-types", - "move-model", - "serde", -] - [[package]] name = "move-ir-to-bytecode" version = "0.1.0" @@ -3996,6 +3706,7 @@ dependencies = [ "anyhow", "clap 4.4.7", "colored", + "itertools 0.10.5", "move-binary-format", "move-bytecode-source-map", "move-bytecode-utils", @@ -4030,179 +3741,16 @@ dependencies = [ ] [[package]] -name = "move-prover" +name = "move-symbol-pool" version = "0.1.0" dependencies = [ - "anyhow", - "clap 4.4.7", - "codespan-reporting", - "itertools 0.10.5", - "log", - "move-command-line-common", - "move-compiler", - "move-docgen", - "move-errmapgen", - "move-model", - "move-prover-boogie-backend", - "move-stackless-bytecode", "once_cell", + "phf", "serde", - "simplelog", - "toml", ] [[package]] -name = "move-prover-boogie-backend" -version = "0.1.0" -dependencies = [ - "anyhow", - "async-trait", - "codespan", - "codespan-reporting", - "futures", - "itertools 0.10.5", - "log", - "move-binary-format", - "move-command-line-common", - "move-core-types", - "move-model", - "move-stackless-bytecode", - "num", - "once_cell", - "pretty", - "rand 0.8.5", - "regex", - "serde", - "tera", - "tokio", -] - -[[package]] -name = "move-read-write-set-types" -version = "0.0.3" -dependencies = [ - "move-binary-format", - "move-core-types", - "serde", -] - -[[package]] -name = "move-stackless-bytecode" -version = "0.1.0" -dependencies = [ - "codespan", - "codespan-reporting", - "ethnum", - "im", - "itertools 0.10.5", - "log", - "move-binary-format", - "move-command-line-common", - "move-compiler", - "move-core-types", - "move-model", - "move-read-write-set-types", - "num", - "paste", - "petgraph 0.5.1", - "serde", -] - -[[package]] -name = "move-stdlib" -version = "0.1.1" -dependencies = [ - "anyhow", - "hex", - "log", - "move-binary-format", - "move-command-line-common", - "move-core-types", - "move-docgen", - "move-errmapgen", - "move-prover", - "move-vm-runtime", - "move-vm-types", - "sha2 0.9.9", - "sha3 0.9.1", - "smallvec", - "walkdir", -] - -[[package]] -name = "move-stdlib-next-vm" -version = "0.1.1" -dependencies = [ - "anyhow", - "hex", - "log", - "move-binary-format", - "move-command-line-common", - "move-core-types", - "move-docgen", - "move-errmapgen", - "move-prover", - "move-vm-runtime-next-vm", - "move-vm-types", - "sha2 0.9.9", - "sha3 0.9.1", - "smallvec", - "walkdir", -] - -[[package]] -name = "move-stdlib-v0" -version = "0.1.1" -dependencies = [ - "anyhow", - "hex", - "log", - "move-binary-format", - "move-command-line-common", - "move-core-types", - "move-docgen", - "move-errmapgen", - "move-prover", - "move-vm-runtime-v0", - "move-vm-types", - "sha2 0.9.9", - "sha3 0.9.1", - "smallvec", - "walkdir", -] - -[[package]] -name = "move-stdlib-v1" -version = "0.1.1" -dependencies = [ - "anyhow", - "hex", - "log", - "move-binary-format", - "move-command-line-common", - "move-core-types", - "move-docgen", - "move-errmapgen", - "move-prover", - "move-vm-runtime-v1", - "move-vm-types", - "sha2 0.9.9", - "sha3 0.9.1", - "smallvec", - "walkdir", -] - -[[package]] -name = "move-symbol-pool" -version = "0.1.0" -dependencies = [ - "once_cell", - "phf", - "serde", -] - -[[package]] -name = "move-vm-config" +name = "move-vm-config" version = "0.1.0" dependencies = [ "move-binary-format", @@ -4218,82 +3766,6 @@ dependencies = [ "serde_json", ] -[[package]] -name = "move-vm-runtime" -version = "0.1.0" -dependencies = [ - "better_any", - "fail", - "move-binary-format", - "move-bytecode-verifier", - "move-core-types", - "move-vm-config", - "move-vm-profiler", - "move-vm-types", - "once_cell", - "parking_lot 0.11.2", - "sha3 0.9.1", - "smallvec", - "tracing", -] - -[[package]] -name = "move-vm-runtime-next-vm" -version = "0.1.0" -dependencies = [ - "better_any", - "fail", - "move-binary-format", - "move-bytecode-verifier-next-vm", - "move-core-types", - "move-vm-config", - "move-vm-profiler", - "move-vm-types", - "once_cell", - "parking_lot 0.11.2", - "sha3 0.9.1", - "smallvec", - "tracing", -] - -[[package]] -name = "move-vm-runtime-v0" -version = "0.1.0" -dependencies = [ - "better_any", - "fail", - "move-binary-format", - "move-bytecode-verifier-v0", - "move-core-types", - "move-vm-config", - "move-vm-profiler", - "move-vm-types", - "once_cell", - "parking_lot 0.11.2", - "sha3 0.9.1", - "smallvec", - "tracing", -] - -[[package]] -name = "move-vm-runtime-v1" -version = "0.1.0" -dependencies = [ - "better_any", - "fail", - "move-binary-format", - "move-bytecode-verifier-v1", - "move-core-types", - "move-vm-config", - "move-vm-profiler", - "move-vm-types", - "once_cell", - "parking_lot 0.11.2", - "sha3 0.9.1", - "smallvec", - "tracing", -] - [[package]] name = "move-vm-test-utils" version = "0.1.0" @@ -4337,7 +3809,7 @@ dependencies = [ "msim-macros", "naive-timer", "pin-project-lite", - "rand 0.8.5", + "rand", "real_tokio", "serde", "socket2 0.4.10", @@ -4425,7 +3897,7 @@ name = "mysten-common" version = "0.1.0" dependencies = [ "futures", - "parking_lot 0.12.1", + "parking_lot", "tokio", "workspace-hack", ] @@ -4439,7 +3911,7 @@ dependencies = [ "dashmap", "futures", "once_cell", - "parking_lot 0.12.1", + "parking_lot", "prometheus", "prometheus-closure-metric", "scopeguard", @@ -4483,10 +3955,10 @@ dependencies = [ "fastcrypto-tbls", "hashbrown 0.12.3", "impl-trait-for-tuples", - "indexmap 1.9.3", + "indexmap 2.1.0", "mysten-util-mem-derive", "once_cell", - "parking_lot 0.12.1", + "parking_lot", "roaring", "smallvec", "workspace-hack", @@ -4502,40 +3974,6 @@ dependencies = [ "workspace-hack", ] -[[package]] -name = "mysticeti-core" -version = "0.1.0" -source = "git+https://github.com/MystenLabs/mysticeti?rev=318d61d27f47d257d99a86983d835e9e9756bc59#318d61d27f47d257d99a86983d835e9e9756bc59" -dependencies = [ - "async-trait", - "axum", - "bincode", - "blake2", - "crc32fast", - "digest 0.10.7", - "ed25519-consensus", - "eyre", - "futures", - "gettid", - "hex", - "hyper", - "libc", - "memmap2", - "minibytes", - "parking_lot 0.12.1", - "prometheus", - "rand 0.8.5", - "serde", - "serde_yaml 0.9.27", - "tabled", - "tempfile", - "tokio", - "tracing", - "tracing-core", - "tracing-subscriber", - "zeroize", -] - [[package]] name = "naive-timer" version = "0.2.0" @@ -4550,7 +3988,7 @@ checksum = "40a3eb6b7c682b65d1f631ec3176829d72ab450b3aacdd3f719bf220822e59ac" dependencies = [ "libc", "once_cell", - "parking_lot 0.12.1", + "parking_lot", "thiserror", "widestring", "winapi", @@ -4566,7 +4004,7 @@ dependencies = [ "mysten-network", "mysten-util-mem", "narwhal-crypto", - "rand 0.8.5", + "rand", "serde", "serde_json", "thiserror", @@ -4586,35 +4024,6 @@ dependencies = [ "workspace-hack", ] -[[package]] -name = "narwhal-executor" -version = "0.1.0" -dependencies = [ - "async-trait", - "bcs", - "bincode", - "bytes", - "fastcrypto", - "futures", - "mockall", - "mysten-metrics", - "narwhal-config", - "narwhal-crypto", - "narwhal-network", - "narwhal-primary", - "narwhal-storage", - "narwhal-types", - "prometheus", - "serde", - "sui-protocol-config", - "thiserror", - "tokio", - "tonic 0.10.2", - "tracing", - "typed-store", - "workspace-hack", -] - [[package]] name = "narwhal-network" version = "0.1.0" @@ -4633,149 +4042,14 @@ dependencies = [ "mysten-metrics", "narwhal-crypto", "narwhal-types", - "parking_lot 0.12.1", + "parking_lot", "prometheus", "quinn-proto", - "rand 0.8.5", - "sui-macros", - "tokio", - "tower", - "tracing", - "workspace-hack", -] - -[[package]] -name = "narwhal-node" -version = "0.1.0" -dependencies = [ - "anemo", - "arc-swap", - "async-trait", - "axum", - "bytes", - "cfg-if", - "clap 4.4.7", - "eyre", - "fastcrypto", - "futures", - "mysten-metrics", - "mysten-network", - "narwhal-config", - "narwhal-crypto", - "narwhal-executor", - "narwhal-network", - "narwhal-primary", - "narwhal-storage", - "narwhal-types", - "narwhal-worker", - "prometheus", - "rand 0.8.5", - "reqwest", - "sui-keys", - "sui-protocol-config", - "sui-types", - "telemetry-subscribers", - "thiserror", - "tokio", - "tokio-stream", - "tracing", - "tracing-subscriber", - "url", - "workspace-hack", -] - -[[package]] -name = "narwhal-primary" -version = "0.1.0" -dependencies = [ - "anemo", - "anemo-tower", - "anyhow", - "async-trait", - "backoff", - "bcs", - "bytes", - "cfg-if", - "fastcrypto", - "fastcrypto-tbls", - "futures", - "governor", - "itertools 0.10.5", - "mysten-common", - "mysten-metrics", - "mysten-network", - "narwhal-config", - "narwhal-crypto", - "narwhal-network", - "narwhal-storage", - "narwhal-types", - "once_cell", - "parking_lot 0.12.1", - "prometheus", - "rand 0.8.5", + "rand", "sui-macros", - "sui-protocol-config", - "tap", - "thiserror", "tokio", - "tokio-stream", "tower", "tracing", - "typed-store", - "workspace-hack", -] - -[[package]] -name = "narwhal-storage" -version = "0.1.0" -dependencies = [ - "fastcrypto", - "futures", - "lru", - "mysten-common", - "narwhal-config", - "narwhal-types", - "parking_lot 0.12.1", - "prometheus", - "sui-macros", - "tap", - "tempfile", - "tokio", - "tracing", - "typed-store", - "workspace-hack", -] - -[[package]] -name = "narwhal-test-utils" -version = "0.1.0" -dependencies = [ - "anemo", - "fastcrypto", - "fdlimit", - "indexmap 1.9.3", - "itertools 0.10.5", - "mysten-metrics", - "mysten-network", - "narwhal-config", - "narwhal-crypto", - "narwhal-executor", - "narwhal-network", - "narwhal-node", - "narwhal-primary", - "narwhal-storage", - "narwhal-types", - "narwhal-worker", - "once_cell", - "prometheus", - "rand 0.8.5", - "sui-protocol-config", - "telemetry-subscribers", - "tempfile", - "tokio", - "tonic 0.10.2", - "tracing", - "typed-store", "workspace-hack", ] @@ -4794,7 +4068,7 @@ dependencies = [ "fastcrypto", "fastcrypto-tbls", "futures", - "indexmap 1.9.3", + "indexmap 2.1.0", "mockall", "mysten-common", "mysten-metrics", @@ -4809,7 +4083,7 @@ dependencies = [ "prost 0.12.1", "prost-build", "protobuf-src", - "rand 0.8.5", + "rand", "roaring", "rustversion", "serde", @@ -4824,41 +4098,6 @@ dependencies = [ "workspace-hack", ] -[[package]] -name = "narwhal-worker" -version = "0.1.0" -dependencies = [ - "anemo", - "anemo-tower", - "anyhow", - "arc-swap", - "async-trait", - "byteorder", - "bytes", - "eyre", - "fastcrypto", - "futures", - "governor", - "itertools 0.10.5", - "mysten-metrics", - "mysten-network", - "narwhal-config", - "narwhal-crypto", - "narwhal-network", - "narwhal-types", - "prometheus", - "rand 0.8.5", - "sui-protocol-config", - "tap", - "thiserror", - "tokio", - "tonic 0.10.2", - "tower", - "tracing", - "typed-store", - "workspace-hack", -] - [[package]] name = "neptune" version = "13.0.0" @@ -4894,6 +4133,12 @@ dependencies = [ "minimal-lexical", ] +[[package]] +name = "nonempty" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "995defdca0a589acfdd1bd2e8e3b896b4d4f7675a31fd14c32611440c7f608e6" + [[package]] name = "nonzero_ext" version = "0.3.0" @@ -4950,7 +4195,7 @@ dependencies = [ "autocfg", "num-integer", "num-traits", - "rand 0.8.5", + "rand", ] [[package]] @@ -4965,7 +4210,7 @@ dependencies = [ "num-integer", "num-iter", "num-traits", - "rand 0.8.5", + "rand", "smallvec", "zeroize", ] @@ -5082,10 +4327,10 @@ dependencies = [ "humantime", "hyper", "itertools 0.11.0", - "parking_lot 0.12.1", + "parking_lot", "percent-encoding", "quick-xml", - "rand 0.8.5", + "rand", "reqwest", "ring 0.16.20", "rustls-pemfile", @@ -5206,7 +4451,7 @@ dependencies = [ "opentelemetry_api", "ordered-float", "percent-encoding", - "rand 0.8.5", + "rand", "regex", "serde_json", "thiserror", @@ -5297,7 +4542,7 @@ version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "373b1a4c1338d9cd3d1fa53b3a11bdab5ab6bd80a20f7f7becd76953ae2be909" dependencies = [ - "arrayvec 0.7.4", + "arrayvec", "bitvec 0.20.4", "byte-slice-cast", "impl-trait-for-tuples", @@ -5317,17 +4562,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "parking_lot" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" -dependencies = [ - "instant", - "lock_api", - "parking_lot_core 0.8.6", -] - [[package]] name = "parking_lot" version = "0.12.1" @@ -5335,21 +4569,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" dependencies = [ "lock_api", - "parking_lot_core 0.9.9", -] - -[[package]] -name = "parking_lot_core" -version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60a2cfe6f0ad2bfc16aefa463b497d5c7a5ecd44a23efa72aa342d90177356dc" -dependencies = [ - "cfg-if", - "instant", - "libc", - "redox_syscall 0.2.16", - "smallvec", - "winapi", + "parking_lot_core", ] [[package]] @@ -5365,15 +4585,6 @@ dependencies = [ "windows-targets 0.48.5", ] -[[package]] -name = "parse-zoneinfo" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c705f256449c60da65e11ff6626e0c16a0a0b96aaa348de61376b249bc340f41" -dependencies = [ - "regex", -] - [[package]] name = "pasta_curves" version = "0.5.1" @@ -5386,7 +4597,7 @@ dependencies = [ "group 0.13.0", "hex", "lazy_static", - "rand 0.8.5", + "rand", "serde", "static_assertions", "subtle", @@ -5521,16 +4732,6 @@ dependencies = [ "phf_shared", ] -[[package]] -name = "phf_codegen" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8d39688d359e6b34654d328e262234662d16cc0f60ec8dcbe5e718709342a5a" -dependencies = [ - "phf_generator", - "phf_shared", -] - [[package]] name = "phf_generator" version = "0.11.2" @@ -5538,7 +4739,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "48e4cc64c2ad9ebe670cb8fd69dd50ae301650392e81c05f9bfcb2d5bdbc24b0" dependencies = [ "phf_shared", - "rand 0.8.5", + "rand", ] [[package]] @@ -5693,16 +4894,6 @@ dependencies = [ "termtree", ] -[[package]] -name = "pretty" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad9940b913ee56ddd94aec2d3cd179dd47068236f42a1a6415ccf9d880ce2a61" -dependencies = [ - "arrayvec 0.5.2", - "typed-arena", -] - [[package]] name = "prettyplease" version = "0.1.25" @@ -5806,7 +4997,7 @@ dependencies = [ "fnv", "lazy_static", "memchr", - "parking_lot 0.12.1", + "parking_lot", "protobuf", "thiserror", ] @@ -5832,8 +5023,8 @@ dependencies = [ "bitflags 2.4.1", "lazy_static", "num-traits", - "rand 0.8.5", - "rand_chacha 0.3.1", + "rand", + "rand_chacha", "rand_xorshift", "regex-syntax 0.7.5", "rusty-fork", @@ -5958,7 +5149,7 @@ dependencies = [ "mach2", "once_cell", "raw-cpuid", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", "web-sys", "winapi", ] @@ -6004,7 +5195,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2c78e758510582acc40acb90458401172d41f1016f8c9dde89e49677afb7eec1" dependencies = [ "bytes", - "rand 0.8.5", + "rand", "ring 0.16.20", "rustc-hash", "rustls 0.21.8", @@ -6058,37 +5249,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" [[package]] -name = "rand" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" -dependencies = [ - "getrandom 0.1.16", - "libc", - "rand_chacha 0.2.2", - "rand_core 0.5.1", - "rand_hc", -] - -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "libc", - "rand_chacha 0.3.1", - "rand_core 0.6.4", -] - -[[package]] -name = "rand_chacha" -version = "0.2.2" +name = "rand" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ - "ppv-lite86", - "rand_core 0.5.1", + "libc", + "rand_chacha", + "rand_core", ] [[package]] @@ -6098,16 +5266,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core 0.6.4", -] - -[[package]] -name = "rand_core" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" -dependencies = [ - "getrandom 0.1.16", + "rand_core", ] [[package]] @@ -6116,16 +5275,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.10", -] - -[[package]] -name = "rand_hc" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" -dependencies = [ - "rand_core 0.5.1", + "getrandom", ] [[package]] @@ -6134,7 +5284,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d25bf25ec5ae4a3f1b92f929810509a2f53d7dca2f50b794ff57e3face536c8f" dependencies = [ - "rand_core 0.6.4", + "rand_core", ] [[package]] @@ -6143,7 +5293,7 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6f97cdb2a36ed4183de61b2f824cc45c9f1037f28afe0a322e9fff4c108b5aaa" dependencies = [ - "rand_core 0.6.4", + "rand_core", ] [[package]] @@ -6188,7 +5338,7 @@ dependencies = [ "libc", "mio", "num_cpus", - "parking_lot 0.12.1", + "parking_lot", "pin-project-lite", "signal-hook-registry", "socket2 0.4.10", @@ -6220,7 +5370,7 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" dependencies = [ - "getrandom 0.2.10", + "getrandom", "redox_syscall 0.2.16", "thiserror", ] @@ -6386,7 +5536,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb0205304757e5d899b9c2e448b867ffd03ae7f988002e47cd24954391394d0b" dependencies = [ "cc", - "getrandom 0.2.10", + "getrandom", "libc", "spin 0.9.8", "untrusted 0.9.0", @@ -6437,7 +5587,7 @@ dependencies = [ "num-traits", "pkcs1", "pkcs8 0.9.0", - "rand_core 0.6.4", + "rand_core", "sha2 0.10.8", "signature 2.1.0", "subtle", @@ -6665,7 +5815,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "25996b82292a7a57ed3508f052cfff8640d38d32018784acd714758b43da9c8f" dependencies = [ "bitcoin_hashes", - "rand 0.8.5", + "rand", "secp256k1-sys", ] @@ -7000,7 +6150,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" dependencies = [ "digest 0.10.7", - "rand_core 0.6.4", + "rand_core", ] [[package]] @@ -7010,7 +6160,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5e1788eed21689f9cf370582dfc467ef36ed9c707f073528ddafa8d83e3b8500" dependencies = [ "digest 0.10.7", - "rand_core 0.6.4", + "rand_core", ] [[package]] @@ -7019,17 +6169,6 @@ version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2aeaf503862c419d66959f5d7ca015337d864e9c49485d771b732e2a20453597" -[[package]] -name = "simplelog" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bc0ffd69814a9b251d43afcabf96dad1b29f5028378056257be9e3fecc9f720" -dependencies = [ - "chrono", - "log", - "termcolor", -] - [[package]] name = "siphasher" version = "0.3.11" @@ -7064,16 +6203,6 @@ dependencies = [ "hmac-sha512", ] -[[package]] -name = "slug" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bd94acec9c8da640005f8e135a39fc0372e74535e6b368b7a04b875f784c8c4" -dependencies = [ - "deunicode", - "wasm-bindgen", -] - [[package]] name = "smallvec" version = "1.11.1" @@ -7140,7 +6269,7 @@ dependencies = [ "http", "httparse", "log", - "rand 0.8.5", + "rand", "sha-1", ] @@ -7222,135 +6351,6 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "734676eb262c623cec13c3155096e08d1f8f29adce39ba17948b18dad1e54142" -[[package]] -name = "sui-adapter-latest" -version = "0.1.0" -dependencies = [ - "anyhow", - "bcs", - "leb128", - "move-binary-format", - "move-bytecode-utils", - "move-bytecode-verifier", - "move-core-types", - "move-vm-config", - "move-vm-profiler", - "move-vm-runtime", - "move-vm-types", - "parking_lot 0.12.1", - "serde", - "sui-macros", - "sui-move-natives-latest", - "sui-protocol-config", - "sui-types", - "sui-verifier-latest", - "tracing", - "workspace-hack", -] - -[[package]] -name = "sui-adapter-next-vm" -version = "0.1.0" -dependencies = [ - "anyhow", - "bcs", - "leb128", - "move-binary-format", - "move-bytecode-utils", - "move-bytecode-verifier-next-vm", - "move-core-types", - "move-vm-config", - "move-vm-profiler", - "move-vm-runtime-next-vm", - "move-vm-types", - "parking_lot 0.12.1", - "serde", - "sui-macros", - "sui-move-natives-next-vm", - "sui-protocol-config", - "sui-types", - "sui-verifier-next-vm", - "tracing", - "workspace-hack", -] - -[[package]] -name = "sui-adapter-v0" -version = "0.1.0" -dependencies = [ - "anyhow", - "bcs", - "leb128", - "move-binary-format", - "move-bytecode-utils", - "move-bytecode-verifier-v0", - "move-core-types", - "move-vm-config", - "move-vm-profiler", - "move-vm-runtime-v0", - "move-vm-types", - "once_cell", - "parking_lot 0.12.1", - "serde", - "sui-macros", - "sui-move-natives-v0", - "sui-protocol-config", - "sui-types", - "sui-verifier-v0", - "tracing", - "workspace-hack", -] - -[[package]] -name = "sui-adapter-v1" -version = "0.1.0" -dependencies = [ - "anyhow", - "bcs", - "leb128", - "move-binary-format", - "move-bytecode-utils", - "move-bytecode-verifier-v1", - "move-core-types", - "move-vm-config", - "move-vm-profiler", - "move-vm-runtime-v1", - "move-vm-types", - "parking_lot 0.12.1", - "serde", - "sui-macros", - "sui-move-natives-v1", - "sui-protocol-config", - "sui-types", - "sui-verifier-v1", - "tracing", - "workspace-hack", -] - -[[package]] -name = "sui-archival" -version = "0.1.0" -dependencies = [ - "anyhow", - "byteorder", - "bytes", - "fastcrypto", - "futures", - "indicatif", - "num_enum", - "object_store", - "prometheus", - "rand 0.8.5", - "serde", - "sui-config", - "sui-simulator", - "sui-storage", - "sui-types", - "tokio", - "tracing", - "workspace-hack", -] - [[package]] name = "sui-config" version = "0.0.0" @@ -7364,7 +6364,7 @@ dependencies = [ "narwhal-config", "once_cell", "prometheus", - "rand 0.8.5", + "rand", "serde", "serde_with", "serde_yaml 0.8.26", @@ -7377,87 +6377,6 @@ dependencies = [ "workspace-hack", ] -[[package]] -name = "sui-core" -version = "0.1.0" -dependencies = [ - "anyhow", - "arc-swap", - "async-trait", - "bcs", - "bytes", - "chrono", - "dashmap", - "either", - "enum_dispatch", - "eyre", - "fastcrypto", - "fastcrypto-zkp", - "futures", - "im", - "indexmap 1.9.3", - "itertools 0.10.5", - "lru", - "move-binary-format", - "move-bytecode-utils", - "move-core-types", - "move-package", - "move-symbol-pool", - "mysten-common", - "mysten-metrics", - "mysten-network", - "mysticeti-core", - "narwhal-config", - "narwhal-crypto", - "narwhal-executor", - "narwhal-network", - "narwhal-node", - "narwhal-test-utils", - "narwhal-types", - "narwhal-worker", - "num_cpus", - "object_store", - "once_cell", - "parking_lot 0.12.1", - "prometheus", - "rand 0.8.5", - "rocksdb", - "scopeguard", - "serde", - "serde_json", - "serde_with", - "shared-crypto", - "signature 1.6.4", - "static_assertions", - "sui-archival", - "sui-config", - "sui-execution", - "sui-framework", - "sui-genesis-builder", - "sui-json-rpc-types", - "sui-macros", - "sui-move-build", - "sui-network", - "sui-protocol-config", - "sui-simulator", - "sui-storage", - "sui-swarm-config", - "sui-transaction-checks", - "sui-types", - "tap", - "telemetry-subscribers", - "tempfile", - "thiserror", - "tokio", - "tokio-retry", - "tokio-stream", - "tracing", - "typed-store", - "typed-store-derive", - "workspace-hack", - "zeroize", -] - [[package]] name = "sui-enum-compat-util" version = "0.1.0" @@ -7466,37 +6385,6 @@ dependencies = [ "workspace-hack", ] -[[package]] -name = "sui-execution" -version = "0.1.0" -dependencies = [ - "move-binary-format", - "move-bytecode-verifier", - "move-bytecode-verifier-next-vm", - "move-bytecode-verifier-v0", - "move-bytecode-verifier-v1", - "move-vm-config", - "move-vm-runtime", - "move-vm-runtime-next-vm", - "move-vm-runtime-v0", - "move-vm-runtime-v1", - "sui-adapter-latest", - "sui-adapter-next-vm", - "sui-adapter-v0", - "sui-adapter-v1", - "sui-move-natives-latest", - "sui-move-natives-next-vm", - "sui-move-natives-v0", - "sui-move-natives-v1", - "sui-protocol-config", - "sui-types", - "sui-verifier-latest", - "sui-verifier-next-vm", - "sui-verifier-v0", - "sui-verifier-v1", - "workspace-hack", -] - [[package]] name = "sui-framework" version = "0.1.0" @@ -7514,49 +6402,6 @@ dependencies = [ "workspace-hack", ] -[[package]] -name = "sui-framework-snapshot" -version = "0.1.0" -dependencies = [ - "anyhow", - "bcs", - "git-version", - "serde", - "serde_json", - "sui-framework", - "sui-protocol-config", - "sui-types", - "workspace-hack", -] - -[[package]] -name = "sui-genesis-builder" -version = "0.0.0" -dependencies = [ - "anyhow", - "bcs", - "camino", - "fastcrypto", - "move-binary-format", - "move-core-types", - "prometheus", - "rand 0.8.5", - "serde", - "serde_with", - "serde_yaml 0.8.26", - "shared-crypto", - "sui-config", - "sui-execution", - "sui-framework", - "sui-framework-snapshot", - "sui-protocol-config", - "sui-simulator", - "sui-types", - "tempfile", - "tracing", - "workspace-hack", -] - [[package]] name = "sui-json" version = "0.0.0" @@ -7576,49 +6421,22 @@ dependencies = [ ] [[package]] -name = "sui-json-rpc" +name = "sui-json-rpc-api" version = "0.0.0" -dependencies = [ - "anyhow", - "arc-swap", - "async-trait", - "axum", - "bcs", - "cached", - "eyre", +dependencies = [ + "anyhow", "fastcrypto", - "futures", - "hyper", - "itertools 0.10.5", "jsonrpsee", - "linked-hash-map", - "move-binary-format", - "move-bytecode-utils", - "move-core-types", - "move-package", "mysten-metrics", "once_cell", "prometheus", - "serde", - "serde_json", - "shared-crypto", - "signature 1.6.4", - "sui-core", "sui-json", "sui-json-rpc-types", "sui-open-rpc", "sui-open-rpc-macros", - "sui-protocol-config", - "sui-storage", - "sui-transaction-builder", "sui-types", "tap", - "thiserror", - "tokio", - "tower", - "tower-http", "tracing", - "typed-store-error", "workspace-hack", ] @@ -7658,7 +6476,8 @@ dependencies = [ "anyhow", "bip32", "fastcrypto", - "rand 0.8.5", + "rand", + "regex", "serde", "serde_json", "shared-crypto", @@ -7682,7 +6501,7 @@ dependencies = [ [[package]] name = "sui-move-build" -version = "0.0.0" +version = "1.16.0" dependencies = [ "anyhow", "fastcrypto", @@ -7696,129 +6515,16 @@ dependencies = [ "move-package", "move-symbol-pool", "serde-reflection", + "sui-protocol-config", "sui-types", "sui-verifier-latest", "tempfile", "workspace-hack", ] -[[package]] -name = "sui-move-natives-latest" -version = "0.1.0" -dependencies = [ - "bcs", - "better_any", - "fastcrypto", - "fastcrypto-zkp", - "linked-hash-map", - "move-binary-format", - "move-core-types", - "move-stdlib", - "move-vm-runtime", - "move-vm-types", - "smallvec", - "sui-protocol-config", - "sui-types", - "tracing", - "workspace-hack", -] - -[[package]] -name = "sui-move-natives-next-vm" -version = "0.1.0" -dependencies = [ - "bcs", - "better_any", - "fastcrypto", - "fastcrypto-zkp", - "linked-hash-map", - "move-binary-format", - "move-core-types", - "move-stdlib-next-vm", - "move-vm-runtime-next-vm", - "move-vm-types", - "smallvec", - "sui-protocol-config", - "sui-types", - "tracing", - "workspace-hack", -] - -[[package]] -name = "sui-move-natives-v0" -version = "0.1.0" -dependencies = [ - "bcs", - "better_any", - "fastcrypto", - "fastcrypto-zkp", - "linked-hash-map", - "move-binary-format", - "move-core-types", - "move-stdlib-v0", - "move-vm-runtime-v0", - "move-vm-types", - "smallvec", - "sui-protocol-config", - "sui-types", - "tracing", - "workspace-hack", -] - -[[package]] -name = "sui-move-natives-v1" -version = "0.1.0" -dependencies = [ - "bcs", - "better_any", - "fastcrypto", - "fastcrypto-zkp", - "linked-hash-map", - "move-binary-format", - "move-core-types", - "move-stdlib-v1", - "move-vm-runtime-v1", - "move-vm-types", - "smallvec", - "sui-protocol-config", - "sui-types", - "tracing", - "workspace-hack", -] - -[[package]] -name = "sui-network" -version = "0.0.0" -dependencies = [ - "anemo", - "anemo-build", - "anemo-tower", - "anyhow", - "dashmap", - "futures", - "governor", - "mysten-metrics", - "mysten-network", - "prometheus", - "rand 0.8.5", - "serde", - "sui-archival", - "sui-config", - "sui-storage", - "sui-swarm-config", - "sui-types", - "tap", - "tokio", - "tonic 0.10.2", - "tonic-build", - "tower", - "tracing", - "workspace-hack", -] - [[package]] name = "sui-open-rpc" -version = "1.15.0" +version = "1.16.0" dependencies = [ "bcs", "schemars", @@ -7879,7 +6585,7 @@ dependencies = [ [[package]] name = "sui-sdk" -version = "1.15.0" +version = "1.16.0" dependencies = [ "anyhow", "async-trait", @@ -7898,7 +6604,7 @@ dependencies = [ "shared-crypto", "sui-config", "sui-json", - "sui-json-rpc", + "sui-json-rpc-api", "sui-json-rpc-types", "sui-keys", "sui-transaction-builder", @@ -7920,7 +6626,7 @@ dependencies = [ "move-package", "msim", "narwhal-network", - "rand 0.8.5", + "rand", "sui-framework", "sui-move-build", "sui-types", @@ -7959,12 +6665,13 @@ dependencies = [ "mysten-metrics", "num_enum", "object_store", - "parking_lot 0.12.1", + "parking_lot", "percent-encoding", "prometheus", "reqwest", "rocksdb", "serde", + "serde_json", "sui-json-rpc-types", "sui-protocol-config", "sui-types", @@ -7980,31 +6687,6 @@ dependencies = [ "zstd", ] -[[package]] -name = "sui-swarm-config" -version = "0.0.0" -dependencies = [ - "anemo", - "anyhow", - "fastcrypto", - "move-bytecode-utils", - "narwhal-config", - "prometheus", - "rand 0.8.5", - "serde", - "serde_with", - "serde_yaml 0.8.26", - "shared-crypto", - "sui-config", - "sui-genesis-builder", - "sui-protocol-config", - "sui-simulator", - "sui-types", - "tempfile", - "tracing", - "workspace-hack", -] - [[package]] name = "sui-transaction-builder" version = "0.0.0" @@ -8022,21 +6704,6 @@ dependencies = [ "workspace-hack", ] -[[package]] -name = "sui-transaction-checks" -version = "0.1.0" -dependencies = [ - "fastcrypto-zkp", - "once_cell", - "sui-config", - "sui-execution", - "sui-macros", - "sui-protocol-config", - "sui-types", - "tracing", - "workspace-hack", -] - [[package]] name = "sui-types" version = "0.1.0" @@ -8053,7 +6720,7 @@ dependencies = [ "fastcrypto", "fastcrypto-zkp", "im", - "indexmap 1.9.3", + "indexmap 2.1.0", "itertools 0.10.5", "move-binary-format", "move-bytecode-utils", @@ -8068,11 +6735,12 @@ dependencies = [ "mysten-network", "narwhal-config", "narwhal-crypto", + "nonempty", "once_cell", "prometheus", "proptest", "proptest-derive", - "rand 0.8.5", + "rand", "roaring", "schemars", "serde", @@ -8105,53 +6773,11 @@ dependencies = [ "move-bytecode-verifier", "move-core-types", "move-vm-config", - "sui-types", - "workspace-hack", -] - -[[package]] -name = "sui-verifier-next-vm" -version = "0.1.0" -dependencies = [ - "move-abstract-stack", - "move-binary-format", - "move-bytecode-utils", - "move-bytecode-verifier-next-vm", - "move-core-types", - "move-vm-config", - "sui-types", - "workspace-hack", -] - -[[package]] -name = "sui-verifier-v0" -version = "0.1.0" -dependencies = [ - "move-abstract-stack", - "move-binary-format", - "move-bytecode-utils", - "move-bytecode-verifier-v0", - "move-core-types", - "move-vm-config", "sui-protocol-config", "sui-types", "workspace-hack", ] -[[package]] -name = "sui-verifier-v1" -version = "0.1.0" -dependencies = [ - "move-abstract-stack", - "move-binary-format", - "move-bytecode-utils", - "move-bytecode-verifier-v1", - "move-core-types", - "move-vm-config", - "sui-types", - "workspace-hack", -] - [[package]] name = "suibase" version = "0.0.1" @@ -8304,28 +6930,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "tera" -version = "1.19.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "970dff17c11e884a4a09bc76e3a17ef71e01bb13447a11e85226e254fe6d10b8" -dependencies = [ - "chrono", - "chrono-tz", - "globwalk", - "humansize", - "lazy_static", - "percent-encoding", - "pest", - "pest_derive", - "rand 0.8.5", - "regex", - "serde", - "serde_json", - "slug", - "unic-segment", -] - [[package]] name = "termcolor" version = "1.1.3" @@ -8435,7 +7039,7 @@ dependencies = [ "hmac", "once_cell", "pbkdf2", - "rand 0.8.5", + "rand", "rustc-hash", "sha2 0.10.8", "thiserror", @@ -8470,7 +7074,7 @@ dependencies = [ "libc", "mio", "num_cpus", - "parking_lot 0.12.1", + "parking_lot", "pin-project-lite", "signal-hook-registry", "socket2 0.5.5", @@ -8510,17 +7114,6 @@ dependencies = [ "syn 2.0.38", ] -[[package]] -name = "tokio-retry" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f57eb36ecbe0fc510036adff84824dd3c24bb781e21bfa67b69d556aa85214f" -dependencies = [ - "pin-project", - "rand 0.8.5", - "tokio", -] - [[package]] name = "tokio-rustls" version = "0.23.4" @@ -8715,7 +7308,7 @@ dependencies = [ "indexmap 1.9.3", "pin-project", "pin-project-lite", - "rand 0.8.5", + "rand", "slab", "tokio", "tokio-util 0.7.10", @@ -8904,19 +7497,13 @@ dependencies = [ "http", "httparse", "log", - "rand 0.8.5", + "rand", "sha1", "thiserror", "url", "utf-8", ] -[[package]] -name = "typed-arena" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6af6ae20167a9ece4bcb41af5b80f8a1f1df981f6391189ce00fd257af04126a" - [[package]] name = "typed-store" version = "0.4.0" @@ -8933,7 +7520,7 @@ dependencies = [ "once_cell", "ouroboros", "prometheus", - "rand 0.8.5", + "rand", "rocksdb", "serde", "sui-macros", @@ -9000,56 +7587,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ccb97dac3243214f8d8507998906ca3e2e0b900bf9bf4870477f125b82e68f6e" -[[package]] -name = "unic-char-property" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8c57a407d9b6fa02b4795eb81c5b6652060a15a7903ea981f3d723e6c0be221" -dependencies = [ - "unic-char-range", -] - -[[package]] -name = "unic-char-range" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0398022d5f700414f6b899e10b8348231abf9173fa93144cbc1a43b9793c1fbc" - -[[package]] -name = "unic-common" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80d7ff825a6a654ee85a63e80f92f054f904f21e7d12da4e22f9834a4aaa35bc" - -[[package]] -name = "unic-segment" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4ed5d26be57f84f176157270c112ef57b86debac9cd21daaabbe56db0f88f23" -dependencies = [ - "unic-ucd-segment", -] - -[[package]] -name = "unic-ucd-segment" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2079c122a62205b421f499da10f3ee0f7697f012f55b675e002483c73ea34700" -dependencies = [ - "unic-char-property", - "unic-char-range", - "unic-ucd-version", -] - -[[package]] -name = "unic-ucd-version" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96bd2f2237fe450fcd0a1d2f5f4e91711124f7857ba2e964247776ebeeb7b0c4" -dependencies = [ - "unic-common", -] - [[package]] name = "unicase" version = "2.7.0" @@ -9173,8 +7710,8 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "88ad59a7560b41a70d191093a945f0b87bc1deeda46fb237479708a1d6b6cdfc" dependencies = [ - "getrandom 0.2.10", - "rand 0.8.5", + "getrandom", + "rand", ] [[package]] @@ -9243,12 +7780,6 @@ dependencies = [ "try-lock", ] -[[package]] -name = "wasi" -version = "0.9.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" - [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" diff --git a/rust/demo-app/crates/demo/src/counter.rs b/rust/demo-app/crates/demo/src/counter.rs index f1f45603..b7c300b8 100644 --- a/rust/demo-app/crates/demo/src/counter.rs +++ b/rust/demo-app/crates/demo/src/counter.rs @@ -86,7 +86,7 @@ pub async fn count() -> Result<(), anyhow::Error> { let signature = keystore.sign_secure(&client_address, &move_call, Intent::sui_transaction())?; - let tx = Transaction::from_data(move_call, Intent::sui_transaction(), vec![signature]); + let tx = Transaction::from_data(move_call, vec![signature]); let response = sui_client .quorum_driver_api() .execute_transaction_block( diff --git a/rust/demo-app/move/sources/counter.move b/rust/demo-app/move/sources/counter.move index 1a415c75..01d62893 100644 --- a/rust/demo-app/move/sources/counter.move +++ b/rust/demo-app/move/sources/counter.move @@ -52,7 +52,7 @@ module demo::Counter { public(friend) fun inc(self: &mut Counter, console: &Console, ctx: &TxContext) { - console.debug(b"inc called"); + console.debug(b"internal inc() called"); self.count = self.count + 1; @@ -68,7 +68,7 @@ module demo::Counter { log::console::set_log_level(&mut console, log::consts::Info()); // Log a message. - console.info(b"increment() entry"); + console.info(b"increment() entry called"); // No check of the sender. Anyone can increment the counter. demo::Counter::inc(self, &console, ctx); diff --git a/rust/helper/Cargo.lock b/rust/helper/Cargo.lock index acad9b8f..6d234b0e 100644 --- a/rust/helper/Cargo.lock +++ b/rust/helper/Cargo.lock @@ -634,6 +634,12 @@ dependencies = [ "thiserror", ] +[[package]] +name = "bech32" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d86b93f97252c47b41663388e6d155714a9d0c398b99f1005cbc5f978b29f445" + [[package]] name = "bellpepper" version = "0.4.1" @@ -1595,7 +1601,7 @@ dependencies = [ [[package]] name = "fastcrypto" version = "0.1.7" -source = "git+https://github.com/MystenLabs/fastcrypto?rev=643831ec3b67bdd2b5f998c0bec1b7c91823351f#643831ec3b67bdd2b5f998c0bec1b7c91823351f" +source = "git+https://github.com/MystenLabs/fastcrypto?rev=c18dc3835f26bc5cf2848ffd32228071fe540071#c18dc3835f26bc5cf2848ffd32228071fe540071" dependencies = [ "aes", "aes-gcm", @@ -1605,6 +1611,7 @@ dependencies = [ "ark-serialize", "auto_ops", "base64ct", + "bech32", "bincode", "blake2", "blake3", @@ -1626,6 +1633,7 @@ dependencies = [ "hkdf", "lazy_static", "merlin", + "num-bigint 0.4.4", "once_cell", "p256", "rand", @@ -1651,7 +1659,7 @@ dependencies = [ [[package]] name = "fastcrypto-derive" version = "0.1.3" -source = "git+https://github.com/MystenLabs/fastcrypto?rev=643831ec3b67bdd2b5f998c0bec1b7c91823351f#643831ec3b67bdd2b5f998c0bec1b7c91823351f" +source = "git+https://github.com/MystenLabs/fastcrypto?rev=c18dc3835f26bc5cf2848ffd32228071fe540071#c18dc3835f26bc5cf2848ffd32228071fe540071" dependencies = [ "convert_case 0.6.0", "proc-macro2 1.0.69", @@ -1662,7 +1670,7 @@ dependencies = [ [[package]] name = "fastcrypto-tbls" version = "0.1.0" -source = "git+https://github.com/MystenLabs/fastcrypto?rev=643831ec3b67bdd2b5f998c0bec1b7c91823351f#643831ec3b67bdd2b5f998c0bec1b7c91823351f" +source = "git+https://github.com/MystenLabs/fastcrypto?rev=c18dc3835f26bc5cf2848ffd32228071fe540071#c18dc3835f26bc5cf2848ffd32228071fe540071" dependencies = [ "bcs", "bincode", @@ -1683,7 +1691,7 @@ dependencies = [ [[package]] name = "fastcrypto-zkp" version = "0.1.2" -source = "git+https://github.com/MystenLabs/fastcrypto?rev=643831ec3b67bdd2b5f998c0bec1b7c91823351f#643831ec3b67bdd2b5f998c0bec1b7c91823351f" +source = "git+https://github.com/MystenLabs/fastcrypto?rev=c18dc3835f26bc5cf2848ffd32228071fe540071#c18dc3835f26bc5cf2848ffd32228071fe540071" dependencies = [ "ark-bls12-381", "ark-bn254", @@ -2278,6 +2286,7 @@ checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" dependencies = [ "equivalent", "hashbrown 0.14.2", + "serde", ] [[package]] @@ -2879,7 +2888,7 @@ dependencies = [ "fastcrypto-tbls", "hashbrown 0.12.3", "impl-trait-for-tuples", - "indexmap 1.9.3", + "indexmap 2.1.0", "mysten-util-mem-derive", "once_cell", "parking_lot", @@ -2957,6 +2966,12 @@ dependencies = [ "minimal-lexical", ] +[[package]] +name = "nonempty" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "995defdca0a589acfdd1bd2e8e3b896b4d4f7675a31fd14c32611440c7f608e6" + [[package]] name = "num" version = "0.4.1" @@ -4606,7 +4621,7 @@ dependencies = [ "fastcrypto", "fastcrypto-zkp", "im", - "indexmap 1.9.3", + "indexmap 2.1.0", "itertools 0.10.5", "move-binary-format", "move-bytecode-utils", @@ -4621,6 +4636,7 @@ dependencies = [ "mysten-network", "narwhal-config", "narwhal-crypto", + "nonempty", "once_cell", "prometheus", "proptest", diff --git a/rust/suibase/crates/suibase-daemon/src/admin_controller.rs b/rust/suibase/crates/suibase-daemon/src/admin_controller.rs index 8bd43ee0..131ac852 100644 --- a/rust/suibase/crates/suibase-daemon/src/admin_controller.rs +++ b/rust/suibase/crates/suibase-daemon/src/admin_controller.rs @@ -239,7 +239,7 @@ impl AdminController { // Forward the message to the ShellWorker. let mut worker_msg = GenericChannelMsg::new(); worker_msg.event_id = EVENT_EXEC; - worker_msg.data_string = msg.data_string; + worker_msg.command = msg.data_string; worker_msg.workdir_idx = msg.workdir_idx; worker_msg.resp_channel = msg.resp_channel; shell_worker_tx.send(worker_msg).await.unwrap(); @@ -465,12 +465,15 @@ impl AdminController { { let (events_writer_worker_tx, events_writer_worker_rx) = tokio::sync::mpsc::channel(100); - wd_tracking.events_writer_worker_tx = Some(events_writer_worker_tx); + let events_writer_worker_params = EventsWriterWorkerParams::new( self.globals.clone(), events_writer_worker_rx, + events_writer_worker_tx.clone(), workdir_idx, ); + wd_tracking.events_writer_worker_tx = Some(events_writer_worker_tx); + let events_writer_worker = EventsWriterWorker::new(events_writer_worker_params); let nested = subsys.start(SubsystemBuilder::new("events-writer-worker", |a| { events_writer_worker.run(a) @@ -527,11 +530,11 @@ impl AdminController { match self.event_loop(&subsys).cancel_on_shutdown(&subsys).await { Ok(()) => { - log::info!("shutting down - normal exit (2)"); + log::info!("normal thread exit (2)"); Ok(()) } Err(_cancelled_by_shutdown) => { - log::info!("shutting down - normal exit (1)"); + log::info!("normal thread exit (1)"); Ok(()) } } diff --git a/rust/suibase/crates/suibase-daemon/src/api/api_server.rs b/rust/suibase/crates/suibase-daemon/src/api/api_server.rs index 807a20a7..18e79555 100644 --- a/rust/suibase/crates/suibase-daemon/src/api/api_server.rs +++ b/rust/suibase/crates/suibase-daemon/src/api/api_server.rs @@ -83,11 +83,11 @@ impl Runnable for APIServerThread { match self.event_loop(&subsys).cancel_on_shutdown(&subsys).await { Ok(_) => { - log::info!("shutting down - normal exit (2)"); + log::info!("normal thread exit (2)"); Ok(()) } Err(_cancelled_by_shutdown) => { - log::info!("shutting down - normal exit (1)"); + log::info!("normal thread exit (1)"); Ok(()) } } diff --git a/rust/suibase/crates/suibase-daemon/src/api/def_methods.rs b/rust/suibase/crates/suibase-daemon/src/api/def_methods.rs index 5c538bc7..bcce170b 100644 --- a/rust/suibase/crates/suibase-daemon/src/api/def_methods.rs +++ b/rust/suibase/crates/suibase-daemon/src/api/def_methods.rs @@ -310,7 +310,7 @@ impl SuiObjectInstance { #[derive(Clone, Debug, JsonSchema, Serialize, Deserialize, PartialEq, Eq)] #[serde(rename_all = "camelCase")] pub struct PackageInstance { - pub package_id: String, + pub package_id: String, // Hexa (no 0x). pub package_name: String, pub package_timestamp: String, pub init_objects: Option>, diff --git a/rust/suibase/crates/suibase-daemon/src/basic_types/auto_thread.rs b/rust/suibase/crates/suibase-daemon/src/basic_types/auto_thread.rs index 6bafdebc..a0684475 100644 --- a/rust/suibase/crates/suibase-daemon/src/basic_types/auto_thread.rs +++ b/rust/suibase/crates/suibase-daemon/src/basic_types/auto_thread.rs @@ -80,9 +80,14 @@ impl + Send + 'static, Parameter: Send + Clone> Runn break; } - log::info!("{} restarting...", inner_thread_name); + // Make an exception to not display "WebSocketWorker" restart + // because they normally restart every ~30 seconds because of + // "normal" connection closing from many public servers. + if self.name != "WebSocketWorker" { + log::info!("{} restarting...", inner_thread_name); + } } - log::info!("{} shutting down - normal exit", outer_thread_name); + log::info!("{} normal thread exit", outer_thread_name); Ok(()) } } diff --git a/rust/suibase/crates/suibase-daemon/src/basic_types/db_objects.rs b/rust/suibase/crates/suibase-daemon/src/basic_types/db_objects.rs index 3f157c9f..7f7f0a1f 100644 --- a/rust/suibase/crates/suibase-daemon/src/basic_types/db_objects.rs +++ b/rust/suibase/crates/suibase-daemon/src/basic_types/db_objects.rs @@ -2,7 +2,12 @@ use rusqlite::Connection; // Generic DBTable. pub trait DBTable { - fn create_table(conn: &Connection) -> rusqlite::Result<()>; + fn create_table( + conn: &Connection, + workdir_name: String, // Always prepended to table_name. + namespace: Option, // Optional. Always prepended to table name. + name_suffix: Option, // Optional. Sometimes appended to table name (ignored with table targeted by foreign key). + ) -> rusqlite::Result<()>; } // Can have its Versioned JSON data persisted in a DB table. diff --git a/rust/suibase/crates/suibase-daemon/src/basic_types/suibase_basic_types.rs b/rust/suibase/crates/suibase-daemon/src/basic_types/suibase_basic_types.rs index 0b2493f6..fded169f 100644 --- a/rust/suibase/crates/suibase-daemon/src/basic_types/suibase_basic_types.rs +++ b/rust/suibase/crates/suibase-daemon/src/basic_types/suibase_basic_types.rs @@ -1,6 +1,17 @@ // Some common types depending only on built-in or "standard" types. pub type EpochTimestamp = tokio::time::Instant; +// Event Level (matches consts used in the Suibase log Move module) +pub type EventLevel = u8; +pub const EVENT_LEVEL_INVALID: u8 = 0u8; +pub const EVENT_LEVEL_ERROR: u8 = 1u8; +pub const EVENT_LEVEL_WARN: u8 = 2u8; +pub const EVENT_LEVEL_INFO: u8 = 3u8; +pub const EVENT_LEVEL_DEBUG: u8 = 4u8; +pub const EVENT_LEVEL_TRACE: u8 = 5u8; +pub const EVENT_LEVEL_MIN: u8 = EVENT_LEVEL_ERROR; +pub const EVENT_LEVEL_MAX: u8 = EVENT_LEVEL_TRACE; + /* use std::sync::atomic::{AtomicUsize, Ordering}; @@ -39,12 +50,16 @@ pub type GenericRx = tokio::sync::mpsc::Receiver; pub type GenericChannelEventID = u8; pub const EVENT_AUDIT: u8 = 1; // Fast consistency check. Globals read-only access. Should emit an EVENT_UPDATE to self for globals update. pub const EVENT_UPDATE: u8 = 2; // Apply Globals config changes and/or update status. Globals write access allowed. -pub const EVENT_EXEC: u8 = 3; // Execute what is specified by the params. Globals write access allowed. +pub const EVENT_EXEC: u8 = 3; // Execute what is specified by the params (command, data_string...). Globals write access allowed. pub struct GenericChannelMsg { pub event_id: GenericChannelEventID, + // Params - pub data_string: Option, + pub command: Option, + pub params: Vec, + + pub data_json: Option, pub workdir_idx: Option, // Optional channel to send a one-time response. @@ -55,13 +70,20 @@ impl GenericChannelMsg { pub fn new() -> Self { Self { event_id: 0, - data_string: None, + command: None, + params: Vec::new(), + data_json: None, workdir_idx: None, resp_channel: None, } } - pub fn data_string(&self) -> Option { - self.data_string.clone() + + pub fn command(&self) -> Option { + self.command.clone() + } + + pub fn params(&self, index: usize) -> Option { + self.params.get(index).cloned() } pub fn workdir_idx(&self) -> Option { @@ -73,7 +95,8 @@ impl std::fmt::Debug for GenericChannelMsg { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_struct("GenericChannelMsg") .field("event_id", &self.event_id) - .field("data_string", &self.data_string) + .field("command", &self.command) + .field("params", &self.params) .field("workdir_idx", &self.workdir_idx) .finish() } diff --git a/rust/suibase/crates/suibase-daemon/src/clock_trigger.rs b/rust/suibase/crates/suibase-daemon/src/clock_trigger.rs index 0522dce2..e3cf5793 100644 --- a/rust/suibase/crates/suibase-daemon/src/clock_trigger.rs +++ b/rust/suibase/crates/suibase-daemon/src/clock_trigger.rs @@ -57,11 +57,11 @@ impl Runnable for ClockTriggerThread { match self.event_loop(&subsys).cancel_on_shutdown(&subsys).await { Ok(()) => { - log::info!("shutting down - normal exit (2)"); + log::info!("normal thread exit (2)"); Ok(()) } Err(_cancelled_by_shutdown) => { - log::info!("shutting down - normal exit (1)"); + log::info!("normal thread exit (1)"); Ok(()) } } diff --git a/rust/suibase/crates/suibase-daemon/src/network_monitor.rs b/rust/suibase/crates/suibase-daemon/src/network_monitor.rs index 9cab8ea1..6c404391 100644 --- a/rust/suibase/crates/suibase-daemon/src/network_monitor.rs +++ b/rust/suibase/crates/suibase-daemon/src/network_monitor.rs @@ -804,11 +804,11 @@ impl NetworkMonitor { .await { Ok(()) => { - log::info!("shutting down - normal exit (2)"); + log::info!("normal thread exit (2)"); Ok(()) } Err(_cancelled_by_shutdown) => { - log::info!("shutting down - normal exit (1)"); + log::info!("normal thread exit (1)"); Ok(()) } } diff --git a/rust/suibase/crates/suibase-daemon/src/workdirs_watcher.rs b/rust/suibase/crates/suibase-daemon/src/workdirs_watcher.rs index 6ec54c4e..e4491b02 100644 --- a/rust/suibase/crates/suibase-daemon/src/workdirs_watcher.rs +++ b/rust/suibase/crates/suibase-daemon/src/workdirs_watcher.rs @@ -327,11 +327,11 @@ impl WorkdirsWatcher { .await { Ok(()) => { - log::info!("shutting down - normal exit (2)"); + log::info!("normal thread exit (2)"); Ok(()) } Err(_cancelled_by_shutdown) => { - log::info!("shutting down - normal exit (1)"); + log::info!("normal thread exit (1)"); Ok(()) } } diff --git a/rust/suibase/crates/suibase-daemon/src/workers/db_worker.rs b/rust/suibase/crates/suibase-daemon/src/workers/db_worker.rs index 11b1688f..d2f48800 100644 --- a/rust/suibase/crates/suibase-daemon/src/workers/db_worker.rs +++ b/rust/suibase/crates/suibase-daemon/src/workers/db_worker.rs @@ -14,7 +14,7 @@ use crate::{ basic_types::{ self, AutoThread, DBTable, GenericChannelMsg, GenericRx, GenericTx, Runnable, WorkdirIdx, }, - shared_types::{Globals, GlobalsWorkdirsST, Workdir}, + shared_types::{self, Globals, GlobalsWorkdirsST, Workdir}, }; use rusqlite::Connection; @@ -25,67 +25,413 @@ use tokio::sync::Mutex; use tokio_graceful_shutdown::{FutureExt, SubsystemHandle}; // Schema: One entry per Package. -#[derive(Debug)] + +fn sanitize_table_name(name: String) -> String { + name.chars() + .map(|c| match c { + 'a'..='z' | 'A'..='Z' | '0'..='9' | '_' => c, + _ => '_', + }) + .collect() +} + +#[derive(Clone, Debug)] struct Package { - id: i32, + id: u64, // This is the DB id. The network package_id is stored in one of the child PackageInstance. package_uuid: String, package_name: String, - latest_instance_id: Option, + latest_instance_id: Option, // Foreign key into one of the PackageInstance child. + table_prefix: String, // {namespace}_{workdir_name} + table_fullname: String, // {namespace}_{workdir_name}_instance } -#[derive(Debug)] +impl DBTable for Package { + fn create_table( + conn: &Connection, + workdir_name: String, + namespace: Option, + _name_suffix: Option, + ) -> rusqlite::Result<()> { + // TODO Recreate the table if not the latest schema version. + let sql = format!( + "CREATE TABLE IF NOT EXISTS {0}_{1}_package ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + package_uuid TEXT NOT NULL, + package_name TEXT NOT NULL, + latest_instance_id INTEGER REFERENCES {0}_{1}_package_instance (id) + )", + workdir_name, + namespace.unwrap_or_else(|| "sui".to_string()), + ); + conn.execute(&sql, [])?; + Ok(()) + } +} + +impl Package { + pub fn get_objs_from_db( + conn: &Connection, + workdir_name: String, + namespace: Option, + package_uuid: String, + package_name: String, + package_id: String, + ) -> Option> { + let namespace = namespace.unwrap_or_else(|| "sui".to_string()); + + // Get the Package from the DB (will be created as needed). + let mut package = Self::get_package_from_db( + conn, + workdir_name.clone(), + namespace.clone(), + package_uuid.clone(), + package_name.clone(), + ); + + if let Ok(package) = package.as_mut() { + // Create a PackageInstance as needed. + // When created, this become the "latest" instance. + let package_instance = package.get_package_instance_from_db(conn, package_id.clone()); + if let Err(e) = package_instance { + log::error!( + "Failed to create PackageInstance in DB for {} {} {} {} {:?}", + workdir_name, + namespace, + package_uuid, + package_name, + e + ); + return None; + } + + let package_instance = package_instance.as_ref().unwrap(); + + let latest_instance_id: Option = package.latest_instance_id; + if latest_instance_id.is_none() || (latest_instance_id.unwrap() != package_instance.id) + { + package.latest_instance_id = Some(package_instance.id); + if let Err(e) = package.update_latest_instance_id_in_db(conn, package_instance.id) { + log::error!("Failed to update Package latest_instance_id: {:?}", e); + return None; + } + } + // TODO Find a way to eliminate clone here! (which was the intent for using Box<>). + return Some(Box::new((package.clone(), package_instance.clone()))); + } + + log::error!( + "Failed to create package in DB for {} {} {} {}", + workdir_name, + namespace, + package_uuid, + package_name + ); + None + } + + fn get_package_instance_from_db( + &self, + conn: &Connection, + package_id: String, + ) -> rusqlite::Result { + let table_name = format!("{}_instance", self.table_fullname); + let sql = format!( + "SELECT id + FROM {} + WHERE package_id = \"{}\" AND parent_id = {}", + table_name, package_id, self.id + ); + // log::info!("DOING SQL: {}", sql); + let mut stmt = conn.prepare(&sql); + if let Ok(stmt) = stmt.as_mut() { + let mut rows = stmt.query([]); + if let Ok(rows) = rows.as_mut() { + let row = rows.next()?; + if let Some(row) = row { + let id: u64 = row.get(0)?; + return Ok(PackageInstance { + id, + parent_id: self.id, + package_id, + }); + } else { + // Default initialization. + let mut new_row = PackageInstance { + id: 0, + parent_id: self.id, + package_id: package_id.clone(), + }; + if let Err(e) = new_row.insert_in_db(conn, self) { + log::error!("Failed to insert new Package instance in {} for parent_id={} and package_id={} row: {:?}", + table_name, self.id, package_id, e); + return Err(e); + } else { + return Ok(new_row); + } + } + } + } else { + log::error!("Failed to prepare SQL: {}", sql); + return Err(rusqlite::Error::InvalidQuery); + } + + log::error!("Failed to query SQL: {}", sql); + Err(rusqlite::Error::InvalidQuery) + } + + fn get_package_from_db( + conn: &Connection, + workdir_name: String, + namespace: String, + package_uuid: String, + package_name: String, + ) -> rusqlite::Result { + let table_prefix = format!("{}_{}", workdir_name, namespace); + let table_fullname = format!("{}_package", table_prefix); + let sql = format!( + "SELECT id, package_uuid, package_name, latest_instance_id + FROM {} + WHERE package_uuid = ?1", + table_fullname + ); + // log::info!("DOING SQL: {}", sql); + let mut stmt = conn.prepare(&sql); + if let Ok(stmt) = stmt.as_mut() { + let rows = stmt.query([package_uuid.clone()]); + if let Ok(mut rows) = rows { + let row = rows.next()?; + if let Some(row) = row { + let id: u64 = row.get(0)?; + let package_uuid: String = row.get(1)?; + let package_name: String = row.get(2)?; + let latest_instance_id: Option = row.get(3)?; + return Ok(Package { + id, + package_uuid, + package_name, + latest_instance_id, + table_prefix, + table_fullname, + }); + } else { + // Row Insertion + let mut new_row = Self { + id: 0, + package_uuid, + package_name, + latest_instance_id: None, + table_prefix, + table_fullname, + }; + if let Err(e) = new_row.insert_in_db(conn) { + log::error!("Failed to insert new Package row: {:?}", e); + return Err(e); + } else { + return Ok(new_row); + } + } + } + } + Err(rusqlite::Error::QueryReturnedNoRows) + } + + fn insert_in_db(&mut self, conn: &Connection) -> rusqlite::Result<()> { + let sql = if let Some(latest_instance_id) = self.latest_instance_id { + format!( + "INSERT INTO {0} (package_uuid, package_name, latest_instance_id) + VALUES (\"{1}\", \"{2}\", {3}) RETURNING id", + self.table_fullname, + self.package_uuid.clone(), + self.package_name.clone(), + latest_instance_id + ) + } else { + format!( + "INSERT INTO {0} (package_uuid, package_name) + VALUES (\"{1}\", \"{2}\") RETURNING id", + self.table_fullname, + self.package_uuid.clone(), + self.package_name.clone() + ) + }; + let mut stmt = conn.prepare(&sql)?; + self.id = stmt.query_row([], |row| row.get(0))?; + + // Runtime test (Remove eventually). + // Verify that the entry can be retrieve back. + let sql = format!( + "SELECT id, package_uuid, package_name, latest_instance_id + FROM {} + WHERE id = ?1", + self.table_fullname + ); + let mut stmt = conn.prepare(&sql)?; + let row = stmt.query_row([self.id], |row| { + let id: u64 = row.get(0)?; + let package_uuid: String = row.get(1)?; + let package_name: String = row.get(2)?; + let latest_instance_id: Option = row.get(3)?; + Ok((id, package_uuid, package_name, latest_instance_id)) + })?; + if row.0 != self.id + || row.1 != self.package_uuid + || row.2 != self.package_name + || row.3 != self.latest_instance_id + { + log::error!("Sanity test failed for {:?}", self); + return Err(rusqlite::Error::QueryReturnedNoRows); + } + + Ok(()) + } + + fn update_latest_instance_id_in_db( + &mut self, + conn: &Connection, + new_latest_id: u64, + ) -> rusqlite::Result<()> { + if self.latest_instance_id.is_none() { + log::error!("Missing latest_instance_id for update"); + return Err(rusqlite::Error::QueryReturnedNoRows); + } + let sql = format!( + "UPDATE {} SET latest_instance_id = ?1 WHERE id = ?2", + self.table_fullname + ); + let mut stmt = conn.prepare(&sql)?; + stmt.execute([new_latest_id, self.id])?; + self.latest_instance_id = Some(new_latest_id); + Ok(()) + } +} + +#[derive(Clone, Debug)] struct PackageInstance { - id: i32, - package_id: String, + id: u64, + parent_id: u64, // Foreign key into Package table. + package_id: String, // Package id on the network. +} + +impl DBTable for PackageInstance { + fn create_table( + conn: &Connection, + workdir_name: String, + namespace: Option, + _name_suffix: Option, + ) -> rusqlite::Result<()> { + // TODO Recreate the table if not the latest schema version. + let sql = format!( + "CREATE TABLE IF NOT EXISTS {0}_{1}_package_instance ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + parent_id INTEGER NOT NULL REFERENCES {0}_{1}_package (id) ON DELETE CASCADE, + package_id TEXT NOT NULL + )", + workdir_name, + namespace.unwrap_or_else(|| "sui".to_string()) + ); + conn.execute(&sql, [])?; + Ok(()) + } +} + +impl PackageInstance { + fn insert_in_db(&mut self, conn: &Connection, package: &Package) -> rusqlite::Result<()> { + let table_name = format!("{}_instance", package.table_fullname); + let sql = format!( + "INSERT INTO {0} (parent_id, package_id) + VALUES ({1}, \"{2}\") RETURNING id", + table_name, package.id, self.package_id + ); + // log::info!("DOING SQL: {}", sql); + let mut stmt = conn.prepare(&sql)?; + self.id = stmt.query_row([], |row| row.get(0))?; + + // Runtime test (Remove eventually). + // Verify that the entry can be retrieve back. + let sql = format!( + "SELECT id, parent_id, package_id + FROM {} + WHERE id = ?1", + table_name + ); + let mut stmt = conn.prepare(&sql)?; + let row = stmt.query_row([self.id], |row| { + let id: u64 = row.get(0)?; + let parent_id: u64 = row.get(1)?; + let package_id: String = row.get(2)?; + Ok((id, parent_id, package_id)) + })?; + if row.0 != self.id || row.1 != self.parent_id || row.2 != self.package_id { + log::error!("Sanity test failed for {:?}", self); + return Err(rusqlite::Error::QueryReturnedNoRows); + } + + Ok(()) + } + + fn insert_event_in_db( + &self, + conn: &Connection, + package: &Package, + name_suffix: String, + event: &mut SuiEvent, + ) -> rusqlite::Result<()> { + // Create the SuiEvent table as needed. + let table_name = format!("{}_event_{}", package.table_prefix, name_suffix); + + let sql = format!( + "INSERT INTO {0} (package_instance_id, timestamp, event_json) + VALUES ({1}, {2}, \"{3}\") RETURNING id", + table_name, self.id, event.timestamp_ms, event.event_json + ); + // log::info!("DOING SQL: {}", sql); + let mut stmt = conn.prepare(&sql)?; + event.id = stmt.query_row([], |row| row.get(0))?; + Ok(()) + } } #[derive(Debug)] struct SuiEvent { - id: i32, - package_id: i32, - event_json: String, + id: u64, // Sequence number within this table. Event assumed inserted in chronological order. + package_instance_id: u64, // Foreign key into PackageInstance table. + timestamp_ms: u64, // milliseconds. Also in results, but put here for sorting convenience. + event_json: String, // This is the content of the "result" field (JSON object). } -impl DBTable for Package { - fn create_table(conn: &Connection) -> rusqlite::Result<()> { +impl DBTable for SuiEvent { + fn create_table( + conn: &Connection, + workdir_name: String, + namespace: Option, + name_suffix: Option, + ) -> rusqlite::Result<()> { // TODO Recreate the table if not the latest schema version. - conn.execute( - "CREATE TABLE IF NOT EXISTS package ( + let sql = format!( + "CREATE TABLE IF NOT EXISTS {0}_{1}_event_{2} ( id INTEGER PRIMARY KEY AUTOINCREMENT, - schema_version TEXT NOT NULL, - package_uuid TEXT NOT NULL, - package_name TEXT NOT NULL, - latest_instance_id INTEGER + package_instance_id INTEGER NOT NULL REFERENCES {0}_{1}_package_instance (id) ON DELETE CASCADE, + timestamp INTEGER NOT NULL, + event_json TEXT NOT NULL )", - [], - )?; + workdir_name, + namespace.unwrap_or_else(|| "sui".to_string()), + name_suffix.unwrap_or_else(|| "default".to_string()), + ); + conn.execute(&sql, [])?; Ok(()) } } -impl Package { - pub fn new(package_uuid: String, package_name: String) -> Self { +impl SuiEvent { + pub fn new(package_instance_id: u64, timestamp_ms: u64, event_json: String) -> Self { Self { id: 0, - package_uuid, - package_name, - latest_instance_id: None, + package_instance_id, + timestamp_ms, + event_json, } } - pub fn insert(&mut self, conn: &Connection) -> rusqlite::Result<()> { - let mut stmt = conn.prepare( - "INSERT INTO package (package_uuid, package_name, latest_instance_id) - VALUES (?1, ?2, ?3)", - )?; - let latest_instance_id = self.latest_instance_id.unwrap_or(0); - let mut rows = stmt.query([ - self.package_uuid.clone(), - self.package_name.clone(), - latest_instance_id.to_string(), - ])?; - self.id = rows.next()?.unwrap().get(0)?; - Ok(()) - } } // Schema: global variables. @@ -99,16 +445,22 @@ struct DBSuibaseConfig { } impl DBTable for DBSuibaseConfig { - fn create_table(conn: &Connection) -> rusqlite::Result<()> { + fn create_table( + conn: &Connection, + workdir_name: String, + namespace: Option, + _name_suffix: Option, + ) -> rusqlite::Result<()> { // TODO Recreate the table if not the latest schema version. - conn.execute( - "CREATE TABLE IF NOT EXISTS suibase_globals ( + let sql = format!( + "CREATE TABLE IF NOT EXISTS {0}_{1}_config ( id INTEGER PRIMARY KEY AUTOINCREMENT, - schema_version TEXT NOT NULL, - workdir_name TEXT NOT NULL + schema_version TEXT NOT NULL )", - [], - )?; + workdir_name, + namespace.unwrap_or_else(|| "sui".to_string()) + ); + conn.execute(&sql, [])?; Ok(()) } } @@ -121,12 +473,13 @@ impl DBSuibaseConfig { } } pub fn insert(&mut self, conn: &Connection) -> rusqlite::Result<()> { - let mut stmt = conn.prepare( + let sql = format!( "INSERT INTO suibase_globals (version, workdir_name) - VALUES (?1, ?2)", - )?; - let mut rows = stmt.query([self.version.clone(), self.workdir_name.clone()])?; - self.id = rows.next()?.unwrap().get(0)?; + VALUES ({0}, {1})", + self.version, self.workdir_name + ); + let mut stmt = conn.prepare(&sql)?; + self.id = stmt.query_row([], |row| row.get(0))?; Ok(()) } } @@ -137,6 +490,7 @@ pub struct DBWorkerParams { event_rx: Arc>, event_tx: GenericTx, workdir_idx: WorkdirIdx, + workdir_name: String, } impl DBWorkerParams { @@ -145,12 +499,14 @@ impl DBWorkerParams { event_rx: GenericRx, event_tx: GenericTx, workdir_idx: WorkdirIdx, + workdir_name: String, ) -> Self { Self { globals, event_rx: Arc::new(Mutex::new(event_rx)), event_tx, workdir_idx, + workdir_name, } } } @@ -205,15 +561,16 @@ impl Runnable for DBWorkerThread { } async fn run(mut self, subsys: SubsystemHandle) -> anyhow::Result<()> { - log::info!("started"); + let output = format!("started for {}", self.params.workdir_name); + log::info!("{}", output); match self.event_loop(&subsys).cancel_on_shutdown(&subsys).await { Ok(()) => { - log::info!("shutting down - normal exit (2)"); + log::info!("normal thread exit (2)"); Ok(()) } Err(_cancelled_by_shutdown) => { - log::info!("shutting down - normal exit (1)"); + log::info!("normal thread exit (1)"); Ok(()) } } @@ -272,6 +629,229 @@ impl DBWorkerThread { } } + async fn process_add_sui_event(&mut self, msg: GenericChannelMsg) { + // Make sure the event is valid. + if msg.event_id != basic_types::EVENT_EXEC { + log::error!("Unexpected event_id {:?}", msg); + return; + } + let workdir_name = if let Some(workdir_idx) = msg.workdir_idx { + if workdir_idx != self.params.workdir_idx { + log::error!( + "Unexpected workdir_idx {:?} (expected {:?})", + workdir_idx, + self.params.workdir_idx + ); + } + shared_types::WORKDIRS_KEYS[workdir_idx as usize] + } else { + log::error!("Unexpected workdir_idx {:?}", msg); + return; + }; + + // Producer of add_sui_event should always set the Suibase uuid in msg.data_string. + let package_uuid = if let Some(package_uuid) = msg.params(0) { + package_uuid + } else { + log::error!("Missing Suibase package UUID in params(0) {:?}", msg); + return; + }; + + let package_name = if let Some(package_name) = msg.params(1) { + package_name + } else { + log::error!("Missing package name in params(1) {:?}", msg); + return; + }; + + let data_json = if let Some(data_json) = msg.data_json { + data_json + } else { + log::error!("Missing data_json {:?}", msg); + return; + }; + + // Extract the "params" Object form data_json. + let params_json = + if let Some(params_json) = data_json.get("params").and_then(|v| v.as_object()) { + params_json + } else { + log::error!("Missing params Object {:?}", data_json); + return; + }; + + // Extract the "result" Object from params_json. + + let result_json = + if let Some(result_json) = params_json.get("result").and_then(|v| v.as_object()) { + result_json + } else { + log::error!("Missing result Object {:?}", data_json); + return; + }; + + // Extract expected fields from the result_json + // + // Example of result_json + // Object { "id": Object {"txDigest": String("3VuaCUx5K7bo7SCakPsFrVnoQzytvaVcYgcmVuftChrL"), "eventSeq": String("0")}, + // "packageId": String("0xe0654f522ae3cb1a364174f740275d57f5a87b430d669c5a0554b975af683b08"), + // "transactionModule": String("Counter"), + // "sender": String("0xf7ae71f84fabc58662bd4209a8893f462c60f247095bb35b19ff659ad0081462"), + // "type": String("0xe0654f522ae3cb1a364174f740275d57f5a87b430d669c5a0554b975af683b08::console::ConsoleEvent"), + // "parsedJson": Object {"level": Number(3), "message": String("increment() entry called")}, + // "bcs": String("6VrJC24y6KXNLbxK6HzfZWFwiEkJRrs"), + // "timestampMs": String("1703895010111") + // } + + let package_id = + if let Some(package_id) = result_json.get("packageId").and_then(|v| v.as_str()) { + package_id + } else { + log::error!("Missing packageId {:?}", data_json); + return; + }; + + // Verify there is an 0x prefix and remove it from package_id. + if !package_id.starts_with("0x") { + log::error!("Invalid packageId {:?}", data_json); + return; + } + let package_id = package_id[2..].to_string(); + + let timestamp_ms: u64 = + if let Some(timestamp_ms) = result_json.get("timestampMs").and_then(|v| v.as_str()) { + timestamp_ms.parse::().unwrap_or(0) + } else { + log::error!("Missing timestampMs {:?}", data_json); + return; + }; + + if timestamp_ms == 0 { + log::error!("Invalid timestampMs {:?}", data_json); + return; + }; + + let type_str = if let Some(type_str) = result_json.get("type").and_then(|v| v.as_str()) { + type_str + } else { + log::error!("Missing type {:?}", data_json); + return; + }; + + let (is_console, sub_table_name) = if type_str.ends_with("::ConsoleEvent") { + (true, "console") + } else { + (false, "user") + }; + + let (event_level, event_message, event_sender) = if !is_console { + (0u8, "", None) + } else { + // "parsedJson": Object {"level": Number(3), "message": String("X"), "sender": String("0x...")}, + + let parsed_json = if let Some(parsed_json) = + result_json.get("parsedJson").and_then(|v| v.as_object()) + { + parsed_json + } else { + log::error!("Missing parsedJson {:?}", data_json); + return; + }; + + let event_level = + if let Some(event_level) = parsed_json.get("level").and_then(|v| v.as_u64()) { + if event_level > basic_types::EVENT_LEVEL_MAX as u64 { + log::error!("Invalid above MAX parsedJson.level {:?}", data_json); + return; + } + if event_level < basic_types::EVENT_LEVEL_MIN as u64 { + log::error!("Invalid below MIN parsedJson.level {:?}", data_json); + return; + } + event_level as u8 + } else { + log::error!("Missing parsedJson.level {:?}", data_json); + return; + }; + let event_message = parsed_json.get("message").and_then(|v| v.as_str()); + if event_message.is_none() { + log::error!("Missing parsedJson.message {:?}", data_json); + return; + }; + + let event_message = event_message.unwrap(); + let event_sender = parsed_json.get("sender").and_then(|v| v.as_str()); + // log::info!("parsed_json {:?}", parsed_json); + + (event_level, event_message, event_sender) + }; + + // TODO Handle re-establish a DB connection if disconnected. + // For now, just return with an error if no DB connection. + if self.db.conn.is_none() { + log::error!("No DB connection to handle Sui event {:?}", data_json); + return; + } + let conn = self.db.conn.as_ref().unwrap(); + + // Get the related package fields from the DB. + // Create the Package/PackageInstance in DB as needed. + let objs = Package::get_objs_from_db( + conn, + workdir_name.to_string(), + None, + package_uuid, + package_name, + package_id, + ); + let (package, package_instance): (Package, PackageInstance) = match objs { + Some(boxed_tuple) => *boxed_tuple, + None => { + log::error!("Failed to get Package from DB {:?}", data_json); + return; + } + }; + // TODO: If new latest, purge very old events in all tables. + + // Insert event into proper table (should be already created). + let name_suffix = format!("{}_{}", sub_table_name, event_level); + let event_json = if is_console { + serde_json::json!({ + "sender": event_sender, + "message": event_message, + }) + } else { + let res = serde_json::to_string(&result_json); + let message = if let Ok(res) = res { + res + } else { + format!("Failed to stringify result_json {:?}", result_json) + }; + // TODO Find a way to resolve the sender. + serde_json::json!({ + "sender": "unknown", + "message": message, + }) + }; + // Stringify event_json and insert it in DB. + let event_json = serde_json::to_string(&event_json); + if event_json.is_err() { + log::error!("Failed to stringify event_json {:?}", event_json); + return; + } + let event_json = event_json.unwrap(); + // Make sure even_json is safe by escaping all double quotes with double-double quotes (SQLite way). + let event_json = event_json.replace('\"', "\"\""); + let mut new_sui_event = SuiEvent::new(package_instance.id, timestamp_ms, event_json); + if let Err(e) = + package_instance.insert_event_in_db(conn, &package, name_suffix, &mut new_sui_event) + { + log::error!("Failed to insert SuiEvent in DB {:?}", e); + } + + // TODO Broadcast the sequence number increment of this sui_event object to websocket users. + } + async fn open_db(&mut self) -> bool { // Get copy of latest workdir info from globals. let workdir = @@ -303,17 +883,79 @@ impl DBWorkerThread { return false; } let conn = conn.unwrap(); - // Create now all the tables in the schema to simplify access from this code later. - if let Err(e) = DBSuibaseConfig::create_table(&conn) { - log::error!("Failed to create suibase_globals table {:?}", e); + + if let Err(e) = conn.execute("PRAGMA foreign_keys = ON;", []) { + log::error!("Failed to enable foreign keys {:?}", e); return false; } - if let Err(e) = Package::create_table(&conn) { - log::error!("Failed to create package table {:?}", e); + + // Create some tables in the schema to simplify access from this code later. + // This is a single row table with frequently used globals. + if let Err(e) = DBSuibaseConfig::create_table(&conn, "all".to_string(), None, None) { + log::error!("Failed to create suibase_globals table {:?}", e); return false; } + // Create tables that exists for each workdir. + for workdir_name in shared_types::WORKDIRS_KEYS.iter() { + if let Err(e) = + DBSuibaseConfig::create_table(&conn, workdir_name.to_string(), None, None) + { + log::error!( + "Failed to create {} SuibaseConfig table {:?}", + workdir_name, + e + ); + return false; + } + + if let Err(e) = Package::create_table(&conn, workdir_name.to_string(), None, None) { + log::error!("Failed to create {} package table {:?}", workdir_name, e); + return false; + } + + if let Err(e) = + PackageInstance::create_table(&conn, workdir_name.to_string(), None, None) + { + log::error!( + "Failed to create {} package_instance table {:?}", + workdir_name, + e + ); + return false; + } + + // Create the console SuiEvent tables (one table per level). + for level in basic_types::EVENT_LEVEL_MIN..=basic_types::EVENT_LEVEL_MAX { + let name_suffix = format!("console_{}", level); + if let Err(e) = + SuiEvent::create_table(&conn, workdir_name.to_string(), None, Some(name_suffix)) + { + log::error!( + "Failed to create {} console level={} event table {:?}", + workdir_name, + level, + e + ); + return false; + } + } + + // Create the user SuiEvent table. + let name_suffix = "user_0"; + if let Err(e) = SuiEvent::create_table( + &conn, + workdir_name.to_string(), + None, + Some(name_suffix.to_string()), + ) { + log::error!("Failed to create {} user event table {:?}", workdir_name, e); + return false; + } + } + // All success. This is a good DB connection. + log::info!("Open connection success"); self.db.conn = Some(conn); true } @@ -356,6 +998,17 @@ impl DBWorkerThread { basic_types::EVENT_UPDATE => { self.process_update_msg(msg).await; }, + basic_types::EVENT_EXEC => { + if let Some(command) = msg.command() { + if command == "add_sui_event" { + self.process_add_sui_event(msg).await; + } else { + log::error!("Received a EVENT_EXEC message with unexpected command {}", command); + } + } else { + log::error!("Received a EVENT_EXEC message without command"); + } + }, _ => { // Consume unexpected messages. log::error!("Unexpected event_id {:?}", msg ); diff --git a/rust/suibase/crates/suibase-daemon/src/workers/events_writer_worker.rs b/rust/suibase/crates/suibase-daemon/src/workers/events_writer_worker.rs index e40a84b6..ac80a102 100644 --- a/rust/suibase/crates/suibase-daemon/src/workers/events_writer_worker.rs +++ b/rust/suibase/crates/suibase-daemon/src/workers/events_writer_worker.rs @@ -7,8 +7,10 @@ use std::sync::Arc; use crate::{ - basic_types::{self, AutoThread, GenericChannelMsg, GenericRx, Runnable, WorkdirIdx}, - shared_types::Globals, + basic_types::{ + self, AutoThread, GenericChannelMsg, GenericRx, GenericTx, Runnable, WorkdirIdx, + }, + shared_types::{self, Globals}, workers::{DBWorker, DBWorkerParams, WebSocketWorker, WebSocketWorkerParams}, }; @@ -22,15 +24,27 @@ use tokio_graceful_shutdown::{FutureExt, SubsystemBuilder, SubsystemHandle}; pub struct EventsWriterWorkerParams { globals: Globals, event_rx: Arc>, + event_tx: GenericTx, workdir_idx: WorkdirIdx, + workdir_name: String, } impl EventsWriterWorkerParams { - pub fn new(globals: Globals, event_rx: GenericRx, workdir_idx: WorkdirIdx) -> Self { + pub fn new( + globals: Globals, + event_rx: GenericRx, + event_tx: GenericTx, + workdir_idx: WorkdirIdx, + ) -> Self { + // For now, support only built-in workdirs ("localnet", "testnet"...). + let workdir_name = shared_types::WORKDIRS_KEYS[workdir_idx as usize].to_string(); + Self { globals, event_rx: Arc::new(Mutex::new(event_rx)), + event_tx, workdir_idx, + workdir_name, } } } @@ -70,27 +84,29 @@ impl Runnable for EventsWriterThread { } async fn run(mut self, subsys: SubsystemHandle) -> Result<()> { - log::info!("started"); + log::info!("started for {}", self.params.workdir_name); - // Start a child websocket_worker thread. + // Start a child websocket_worker thread (in future, more than one might be started). let (worker_tx, worker_rx) = tokio::sync::mpsc::channel(1000); let ws_worker_params = WebSocketWorkerParams::new( self.params.globals.clone(), worker_rx, worker_tx.clone(), + self.params.event_tx.clone(), self.params.workdir_idx, ); let ws_worker = WebSocketWorker::new(ws_worker_params); subsys.start(SubsystemBuilder::new("ws-worker", |a| ws_worker.run(a))); self.ws_workers_channel.push(worker_tx); - // Start a child db_worker thread. + // Start a single child db_worker thread. let (db_worker_tx, db_worker_rx) = tokio::sync::mpsc::channel(1000); let db_worker_params = DBWorkerParams::new( self.params.globals.clone(), db_worker_rx, db_worker_tx.clone(), self.params.workdir_idx, + self.params.workdir_name.clone(), ); let db_worker = DBWorker::new(db_worker_params); subsys.start(SubsystemBuilder::new("db-worker", |a| db_worker.run(a))); @@ -98,11 +114,11 @@ impl Runnable for EventsWriterThread { match self.event_loop(&subsys).cancel_on_shutdown(&subsys).await { Ok(()) => { - log::info!("shutting down - normal exit (2)"); + log::info!("normal thread exit (2)"); Ok(()) } Err(_cancelled_by_shutdown) => { - log::info!("shutting down - normal exit (1)"); + log::info!("normal thread exit (1)"); Ok(()) } } @@ -115,17 +131,26 @@ impl EventsWriterThread { for tx in &self.ws_workers_channel { let forward_msg = GenericChannelMsg { event_id: msg.event_id, - data_string: msg.data_string.clone(), + command: msg.command.clone(), + params: msg.params.clone(), + data_json: msg.data_json.clone(), workdir_idx: msg.workdir_idx, resp_channel: None, }; let _ = tx.send(forward_msg).await; } + // Forward the message to the single self.db_worker_channel. + self.forward_to_db_worker(msg).await; + } + + async fn forward_to_db_worker(&mut self, msg: GenericChannelMsg) { // Forward the message to the single self.db_worker_channel. if let Some(tx) = &self.db_worker_channel { let forward_msg = GenericChannelMsg { event_id: msg.event_id, - data_string: msg.data_string.clone(), + command: msg.command, + params: msg.params, + data_json: msg.data_json, workdir_idx: msg.workdir_idx, resp_channel: None, }; @@ -141,6 +166,12 @@ impl EventsWriterThread { self.forward_to_children(msg).await; } + async fn process_add_sui_event(&mut self, msg: GenericChannelMsg) { + // TODO Dedup logic to be done here, for now just forward everything since + // suibase currently support only a single websocket worker per workdir. + self.forward_to_db_worker(msg).await; + } + async fn event_loop(&mut self, subsys: &SubsystemHandle) { // Take mutable ownership of the event_rx channel as long this thread is running. let event_rx = Arc::clone(&self.params.event_rx); @@ -157,6 +188,20 @@ impl EventsWriterThread { basic_types::EVENT_UPDATE => { self.process_update_msg(msg).await; } + basic_types::EVENT_EXEC => { + if let Some(command) = msg.command() { + if command == "add_sui_event" { + self.process_add_sui_event(msg).await; + } else { + log::error!( + "Received a EVENT_EXEC message with unexpected command {}", + command + ); + } + } else { + log::error!("Received a EVENT_EXEC message without command"); + } + } _ => { // Consume unexpected messages. log::error!("Unexpected event_id {:?}", msg); diff --git a/rust/suibase/crates/suibase-daemon/src/workers/package_tracking.rs b/rust/suibase/crates/suibase-daemon/src/workers/package_tracking.rs index 419fab27..584d63ae 100644 --- a/rust/suibase/crates/suibase-daemon/src/workers/package_tracking.rs +++ b/rust/suibase/crates/suibase-daemon/src/workers/package_tracking.rs @@ -64,9 +64,14 @@ pub struct PackageTracking { request_retry: u8, // Set when a subscription response is received. This is then - // used later to cleanly unsubscribe. + // used later to do event correlation and unsubscribe. unsubscribed_id: Option, + // This is a cached u64 conversion of unsubscribed_id. + // Initialize to u64::MAX and updated whenever unsubscribed_id is set + // with a valid number. + subscription_number: u64, + // sequence numbers that were used for // subscription request(s). subscribe_seq_numbers: Vec, @@ -92,6 +97,7 @@ impl PackageTracking { request_sent_timestamp: None, request_retry: 0, unsubscribed_id: None, + subscription_number: u64::MAX, subscribe_seq_numbers: Vec::new(), unsubscribe_seq_numbers: Vec::new(), remove_request: false, @@ -126,6 +132,10 @@ impl PackageTracking { self.unsubscribed_id.as_ref() } + pub fn subscription_number(&self) -> u64 { + self.subscription_number + } + pub fn did_sent_subscribe_request(&self, seq_number: u64) -> bool { self.subscribe_seq_numbers.contains(&seq_number) } @@ -189,6 +199,7 @@ impl PackageTracking { self.subscribe_seq_numbers.clear(); self.unsubscribe_seq_numbers.clear(); self.unsubscribed_id = None; + self.subscription_number = u64::MAX; self.request_retry = 0; } self.state_change_timestamp = tokio::time::Instant::now(); @@ -210,6 +221,12 @@ impl PackageTracking { pub fn report_subscribing_response(&mut self, unsubscribe_id: String) { self.request_sent_timestamp = None; self.request_retry = 0; + // Convert unsubscribed_id to subscription_number (u64). The number is + // an integer base 10. If fails, to convert, then set to u64::MAX. + self.subscription_number = match unsubscribe_id.parse() { + Ok(number) => number, + Err(_e) => u64::MAX, + }; self.unsubscribed_id = Some(unsubscribe_id); } @@ -227,6 +244,7 @@ impl PackageTracking { self.request_sent_timestamp = None; self.request_retry = 0; self.unsubscribed_id = None; + self.subscription_number = u64::MAX; } pub fn report_remove_request(&mut self) { diff --git a/rust/suibase/crates/suibase-daemon/src/workers/request_worker.rs b/rust/suibase/crates/suibase-daemon/src/workers/request_worker.rs index 40a36c0f..8115e230 100644 --- a/rust/suibase/crates/suibase-daemon/src/workers/request_worker.rs +++ b/rust/suibase/crates/suibase-daemon/src/workers/request_worker.rs @@ -64,11 +64,11 @@ impl RequestWorker { match self.event_loop(&subsys).cancel_on_shutdown(&subsys).await { Ok(()) => { - log::info!("shutting down - normal exit (2)"); + log::info!("normal thread exit (2)"); Ok(()) } Err(_cancelled_by_shutdown) => { - log::info!("shutting down - normal exit (1)"); + log::info!("normal thread exit (1)"); Ok(()) } } diff --git a/rust/suibase/crates/suibase-daemon/src/workers/shell_worker.rs b/rust/suibase/crates/suibase-daemon/src/workers/shell_worker.rs index dbdfce6a..000a406b 100644 --- a/rust/suibase/crates/suibase-daemon/src/workers/shell_worker.rs +++ b/rust/suibase/crates/suibase-daemon/src/workers/shell_worker.rs @@ -52,7 +52,7 @@ impl ShellWorker { } else if msg.event_id != crate::basic_types::EVENT_EXEC { log::error!("Unexpected event_id {:?}", msg.event_id); format!("Error: Unexpected event_id {:?}", msg.event_id) - } else if let Some(cmd) = &msg.data_string { + } else if let Some(cmd) = &msg.command { // Execute the command as if it was a bash script. let output = Command::new("bash").arg("-c").arg(cmd).output(); @@ -89,7 +89,7 @@ impl ShellWorker { if let Err(e) = &resp_channel.send(resp) { let error_msg = format!( "Error: do_exec({:?}, {:?}) error 3: {}", - msg.workdir_idx, msg.data_string, e + msg.workdir_idx, msg.command, e ); log::error!("{}", error_msg); } @@ -114,11 +114,11 @@ impl ShellWorker { match self.event_loop(&subsys).cancel_on_shutdown(&subsys).await { Ok(()) => { - log::info!("shutting down - normal exit (2)"); + log::info!("normal thread exit (2)"); Ok(()) } Err(_cancelled_by_shutdown) => { - log::info!("shutting down - normal exit (1)"); + log::info!("normal thread exit (1)"); Ok(()) } } diff --git a/rust/suibase/crates/suibase-daemon/src/workers/websocket_worker.rs b/rust/suibase/crates/suibase-daemon/src/workers/websocket_worker.rs index d5e17f8a..d3136347 100644 --- a/rust/suibase/crates/suibase-daemon/src/workers/websocket_worker.rs +++ b/rust/suibase/crates/suibase-daemon/src/workers/websocket_worker.rs @@ -37,7 +37,8 @@ use super::package_tracking::{PackageTracking, PackageTrackingState}; pub struct WebSocketWorkerParams { globals: Globals, event_rx: Arc>, - event_tx: GenericTx, + event_tx: GenericTx, // To send message to self. + events_writer_tx: GenericTx, // To send message to parent EventsWriterWorker. workdir_idx: WorkdirIdx, workdir_name: String, } @@ -47,12 +48,14 @@ impl WebSocketWorkerParams { globals: Globals, event_rx: GenericRx, event_tx: GenericTx, + events_writer_tx: GenericTx, workdir_idx: WorkdirIdx, ) -> Self { Self { globals, event_rx: Arc::new(Mutex::new(event_rx)), event_tx, + events_writer_tx, workdir_idx, workdir_name: WORKDIRS_KEYS[workdir_idx as usize].to_string(), } @@ -119,16 +122,16 @@ impl Runnable for WebSocketWorkerThread { } async fn run(mut self, subsys: SubsystemHandle) -> Result<()> { - let output = format!("started {}", self.params.workdir_name); - log::info!("{}", output); + // let output = format!("started {}", self.params.workdir_name); + // log::info!("{}", output); match self.event_loop(&subsys).cancel_on_shutdown(&subsys).await { Ok(()) => { - log::info!("shutting down - normal exit (2)"); + // log::info!("normal thread exit (2)"); Ok(()) } Err(_cancelled_by_shutdown) => { - log::info!("shutting down - normal exit (1)"); + log::info!("normal thread exit (1)"); Ok(()) } } @@ -153,6 +156,15 @@ impl WebSocketWorkerThread { async fn process_ws_msg(&mut self, msg: Message) { //log::info!("Received a websocket message: {:?}", msg); + // ********************************************************************** + // ********************************************************************** + // ********************************************************************** + // ********************************************************************** + // TODO Important !!!!!!! Replace all [] with get()... like done in DB worker + // ********************************************************************** + // ********************************************************************** + // ********************************************************************** + // ********************************************************************** let (json_msg, msg_seq_number) = match msg { Message::Text(text) => { let json = serde_json::from_str(&text); @@ -173,58 +185,215 @@ impl WebSocketWorkerThread { // Check for expected response (correlate using the JSON-RPC id). let mut trig_audit_event = false; let mut correlated_msg = false; - for package in self.packages.values_mut() { - let state = package.state(); - if state == &PackageTrackingState::Subscribing { - if package.did_sent_subscribe_request(msg_seq_number) { + if msg_seq_number != 0 { + for package in self.packages.values_mut() { + let state = package.state(); + if state == &PackageTrackingState::Subscribing { + if package.did_sent_subscribe_request(msg_seq_number) { + correlated_msg = true; + log::info!( + "Received subscribe resp. workdir={} package id={} resp={:?}", + self.params.workdir_name, + package.id(), + json_msg, + ); + // Got an expected subscribe response. + // Extract the result string from the JSON message. + let result = json_msg["result"].as_u64(); + if result.is_none() { + log::error!( + "Missing result field in subscribe JSON resp. workdir={} package id={} resp={:?}", + self.params.workdir_name, + package.id(), + json_msg + ); + return; + } + let unsubscribe_id = result.unwrap(); + package.report_subscribing_response(unsubscribe_id.to_string()); + trig_audit_event = true; + break; + } + } else if state == &PackageTrackingState::Unsubscribing + && package.did_sent_unsubscribe_request(msg_seq_number) + { + // Got an expected unsubscribe response. correlated_msg = true; log::info!( - "Received {} subscribe resp: {:?} for package id {}", + "Received unsubscribe resp. workdir={} package id={} resp={:?}", self.params.workdir_name, + package.id(), json_msg, - package.id() ); - // Got an expected subscribe response. - // Extract the result string from the JSON message. - let result = json_msg["result"].as_u64(); - if result.is_none() { - log::error!("Missing result in subscribe JSON response: {:?}", json_msg); + + package.report_unsubscribing_response(); + trig_audit_event = true; + break; + } + } + } + + if !correlated_msg { + // Check if a valid Sui event message. + let method = json_msg["method"].as_str(); + if method.is_none() { + log::error!( + "Missing method in Sui Event message. workdir={} message={:?}", + self.params.workdir_name, + json_msg + ); + return; + } + let method = method.unwrap(); + if method != "suix_subscribeEvent" { + log::error!( + "Unexpected method in Sui Event message. workdir={} message={:?}", + self.params.workdir_name, + json_msg + ); + return; + } + + let params = json_msg["params"].as_object(); + if params.is_none() { + log::error!( + "Missing params in Sui Event message. workdir={} message={:?}", + self.params.workdir_name, + json_msg + ); + return; + } + let params = params.unwrap(); + let subscription = params["subscription"].as_u64(); + if subscription.is_none() { + log::error!( + "Missing subscription in Sui Event message. workdir={} message={:?}", + self.params.workdir_name, + json_msg + ); + return; + } + let subscription_number = subscription.unwrap(); + let result = params["result"].as_object(); + if result.is_none() { + log::error!( + "Missing result in Sui Event message. workdir={} message={:?}", + self.params.workdir_name, + json_msg + ); + return; + } + let result = result.unwrap(); + + // Find the related package uuid (Suibase ID) and name using the + // subscription number. + let mut package_uuid: Option = None; + let mut package_name: Option = None; + for package in self.packages.values_mut() { + let state = package.state(); + if state == &PackageTrackingState::Subscribed + && package.subscription_number() == subscription_number + { + package_uuid = Some(package.uuid().clone()); + package_name = Some(package.name().clone()); + // While we are here... do a sanity check that packageId field + // match what is in PackageTrackingState. + let package_id = result["packageId"].as_str(); + if package_id.is_none() { + log::error!( + "Missing packageId in Sui Event message. workdir={} message={:?}", + self.params.workdir_name, + json_msg + ); + return; + } + let package_id = package_id.unwrap(); + // Verify package_id starts with "0x", and then create a slice that + // remove the "0x". + if !package_id.starts_with("0x") { + log::error!( + "Invalid packageId in Sui Event message. workdir={} message={:?}", + self.params.workdir_name, + json_msg + ); + return; + } + let package_id = &package_id[2..]; + if package.id() != package_id { + log::error!( + "packageId {} not matching {} in Sui Event message. workdir={} message={:?}", + package.id(), + package_id, + self.params.workdir_name, + json_msg + ); return; } - let unsubscribe_id = result.unwrap(); - package.report_subscribing_response(unsubscribe_id.to_string()); - trig_audit_event = true; break; } - } else if state == &PackageTrackingState::Unsubscribing - && package.did_sent_unsubscribe_request(msg_seq_number) - { - // Got an expected unsubscribe response. - correlated_msg = true; - log::info!( - "Received {} unsubscribe resp: {:?} for package id {}", + } + + if package_uuid.is_none() { + log::warn!( + "Unsubscribed state for subscription number {} for Sui Event message. workdir={} message={:?}", + subscription_number, self.params.workdir_name, - json_msg, - package.id() + json_msg ); + return; + } + let package_uuid = package_uuid.unwrap(); - package.report_unsubscribing_response(); - trig_audit_event = true; - break; + if package_name.is_none() { + log::warn!( + "Missing package name for subscription number {} for Sui Event message. workdir={} message={:?}", + subscription_number, + self.params.workdir_name, + json_msg + ); + return; + } + let package_name = package_name.unwrap(); + + // {"jsonrpc": String("2.0"), + // "method": String("suix_subscribeEvent"), + // "params": Object { "subscription": Number(6351273490251832), + // "result": Object { + // "id": Object {"txDigest": String("3Vua...ChrL"), "eventSeq": String("1")}, + // "packageId": String("0xe065...3b08"), + // "transactionModule": String("Counter"), + // "sender": String("0xf7ae...1462"), + // "type": String("0xe065...3b08::Counter::CounterChanged"), + // "parsedJson": Object {"by_address": String("0xf7ae...1462"), "count": String("1")}, + // "bcs": String("3t9dC...ELZ"), + // "timestampMs": String("1703895010111") + // } + // } + // } + // TODO Validate here if from an expected subscribed package. + // Forward to the parent thread for deduplication. + let msg = GenericChannelMsg { + event_id: basic_types::EVENT_EXEC, + command: Some("add_sui_event".to_string()), + params: vec![package_uuid, package_name], + data_json: Some(json_msg), + workdir_idx: Some(self.params.workdir_idx), + resp_channel: None, + }; + if self.params.events_writer_tx.send(msg).await.is_err() { + log::error!( + "Failed to add_sui_event for workdir_idx={}", + self.params.workdir_idx + ); } - } - if !correlated_msg { - log::error!( - "Received {} message: {:?}", - self.params.workdir_name, - json_msg - ); } if trig_audit_event { let msg = GenericChannelMsg { event_id: basic_types::EVENT_AUDIT, - data_string: None, + command: None, + params: Vec::new(), + data_json: None, workdir_idx: Some(self.params.workdir_idx), resp_channel: None, }; @@ -385,7 +554,9 @@ impl WebSocketWorkerThread { // Update the packages_config globals. let msg = GenericChannelMsg { event_id: basic_types::EVENT_UPDATE, - data_string: None, + command: None, + params: Vec::new(), + data_json: None, workdir_idx: Some(self.params.workdir_idx), resp_channel: None, }; @@ -404,7 +575,7 @@ impl WebSocketWorkerThread { // // Unlike an audit, changes to packages_config globals are // allowed here. - log::info!("Received an update message: {:?}", msg); + //log::info!("Received an update message: {:?}", msg); // Make sure the event_id is EVENT_UPDATE. if msg.event_id != basic_types::EVENT_UPDATE { @@ -478,7 +649,9 @@ impl WebSocketWorkerThread { if trig_audit { let msg = GenericChannelMsg { event_id: basic_types::EVENT_AUDIT, - data_string: None, + command: None, + params: Vec::new(), + data_json: None, workdir_idx: Some(self.params.workdir_idx), resp_channel: None, }; @@ -708,8 +881,16 @@ impl WebSocketWorkerThread { tokio::select! { msg = ws_stream_future => { if let Some(msg) = msg { - let msg = msg.unwrap(); - self.process_ws_msg(msg).await; + if let Ok(msg) = msg { + // Process the message. + self.process_ws_msg(msg).await; + } else { + // Connection lost. + //log::info!("Connection lost for {}", self.params.workdir_name); + self.websocket.write = None; + self.websocket.read = None; + return; + } } else { // Shutdown requested. log::info!("Received {} None websocket message", self.params.workdir_name); diff --git a/scripts/common/__publish.sh b/scripts/common/__publish.sh index f97a92c2..58283062 100644 --- a/scripts/common/__publish.sh +++ b/scripts/common/__publish.sh @@ -54,7 +54,7 @@ publish_all() { echo "$_CMD_TO_DISPLAY" # Execute $CMD - echo "=============== Sui client output ========================" + echo "=================== Sui client output ====================" eval "$_CMD" # TODO Investigate problem with exit status here... @@ -73,15 +73,15 @@ publish_all() { if [ -z "$_ID_PACKAGE" ]; then cat "$INSTALL_DIR/publish-output.json" fi - echo "============ End of Sui client output =====================" if [ -z "$_ID_PACKAGE" ]; then + echo "======================= Summary ==========================" setup_error "Publication failed." fi # Test the publication by retreiving object information from the network # using that parsed package id. - echo "suibase: Verifying new package is on network." + echo "================ Verification on Network =================" # Retry for up to 30 seconds to allow for the propagation time of information to the RPC nodes. # Check no more than once per second. @@ -125,13 +125,13 @@ publish_all() { _WORKDIR_NAME_FOR_LINK="local" fi - echo "===================== Summary =============================" + echo "======================= Summary ==========================" echo "Publication Successful" echo "Package ID=[$_ID_PACKAGE]" echo "Package ID also in [~/suibase/workdirs/$WORKDIR_NAME/published-data/$MOVE_TOML_PACKAGE_NAME/most-recent/package-id.json]" echo "Created objects in [~/suibase/workdirs/$WORKDIR_NAME/published-data/$MOVE_TOML_PACKAGE_NAME/most-recent/created-objects.json]" echo "Complete output in [~/suibase/workdirs/$WORKDIR_NAME/published-data/$_SUB_INSTALL_DIR/publish-output.json]" - echo "================= Explorer Links ==========================" + echo "==================== Explorer Links ======================" echo "Package [https://suiexplorer.com/object/$_ID_PACKAGE_FOR_LINK?network=$_WORKDIR_NAME_FOR_LINK]" if [ -n "$SUI_PUBLISH_TXDIGEST" ]; then echo "TxBlock [https://suiexplorer.com/txblock/$SUI_PUBLISH_TXDIGEST?network=$_WORKDIR_NAME_FOR_LINK]"