From 887f8970fd976b41bf8b64290d87a6ff53c11518 Mon Sep 17 00:00:00 2001 From: kukabi Date: Thu, 28 Nov 2024 14:57:10 +0300 Subject: [PATCH] Add performance metrics to validator list. --- Cargo.lock | 116 +++++++++--------- _docker/compose/.env.sample | 2 +- .../20211115071840_fx_validator_info.up.sql | 46 ++++++- ...125150658_fx_validator_info_batch.down.sql | 1 - ...41125150658_fx_validator_info_batch.up.sql | 19 --- ...61013_session_validator_performance.up.sql | 8 +- subvt-app-service/Cargo.toml | 2 +- subvt-block-processor/Cargo.toml | 2 +- subvt-config/Cargo.toml | 2 +- subvt-governance/Cargo.toml | 2 +- subvt-kline-updater/Cargo.toml | 2 +- subvt-logging/Cargo.toml | 2 +- subvt-metrics/Cargo.toml | 2 +- subvt-network-status-server/Cargo.toml | 2 +- subvt-network-status-updater/Cargo.toml | 2 +- subvt-nft/Cargo.toml | 2 +- subvt-notification-generator/Cargo.toml | 2 +- subvt-notification-processor/Cargo.toml | 2 +- subvt-onekv-updater/Cargo.toml | 2 +- subvt-persistence/Cargo.toml | 2 +- .../src/postgres/network/staking.rs | 34 ++--- subvt-plotter/Cargo.toml | 2 +- subvt-proc-macro/Cargo.toml | 2 +- subvt-referendum-updater/Cargo.toml | 2 +- subvt-report-service/Cargo.toml | 2 +- subvt-service-common/Cargo.toml | 2 +- .../Cargo.toml | 2 +- .../src/lib.rs | 5 +- subvt-substrate-client/Cargo.toml | 2 +- subvt-telegram-bot/Cargo.toml | 4 +- subvt-telemetry-processor/Cargo.toml | 2 +- subvt-types/Cargo.toml | 2 +- subvt-types/src/rdb.rs | 1 + subvt-types/src/subvt.rs | 3 + subvt-utility/Cargo.toml | 2 +- subvt-validator-details-server/Cargo.toml | 2 +- subvt-validator-list-server/Cargo.toml | 2 +- subvt-validator-list-updater/Cargo.toml | 2 +- subvt-validator-list-updater/src/lib.rs | 1 + 39 files changed, 159 insertions(+), 135 deletions(-) delete mode 100644 _migrations/network/migrations/20241125150658_fx_validator_info_batch.down.sql delete mode 100644 _migrations/network/migrations/20241125150658_fx_validator_info_batch.up.sql diff --git a/Cargo.lock b/Cargo.lock index d1ba592e..4e9f4224 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -852,9 +852,9 @@ dependencies = [ [[package]] name = "bon" -version = "2.3.0" +version = "3.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97493a391b4b18ee918675fb8663e53646fd09321c58b46afa04e8ce2499c869" +checksum = "1e47d5c63335658326076cf7c81795af665c534ea552da69526d6cef51b12ed9" dependencies = [ "bon-macros", "rustversion", @@ -862,14 +862,16 @@ dependencies = [ [[package]] name = "bon-macros" -version = "2.3.0" +version = "3.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a2af3eac944c12cdf4423eab70d310da0a8e5851a18ffb192c0a5e3f7ae1663" +checksum = "b162272b6d55562ea30cc937d74ef4d07399e507bfd6eb3860f6a845c7264eef" dependencies = [ "darling", "ident_case", + "prettyplease", "proc-macro2", "quote", + "rustversion", "syn 2.0.89", ] @@ -1815,9 +1817,9 @@ dependencies = [ [[package]] name = "email-encoding" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60d1d33cdaede7e24091f039632eb5d3c7469fe5b066a985281a34fc70fa317f" +checksum = "ea3d894bbbab314476b265f9b2d46bf24b123a36dd0e96b06a1b49545b9d9dcc" dependencies = [ "base64 0.22.1", "memchr", @@ -2420,9 +2422,9 @@ dependencies = [ [[package]] name = "frankenstein" -version = "0.34.1" +version = "0.35.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66f5e0e35cd8a8458c32f224ee98369774381bde8558a402e0ee2b350ee5736e" +checksum = "e25099af98a3c9fc81a754761987db1574687c31f24fb258a34f49a26a679efd" dependencies = [ "async-trait", "bon", @@ -2432,7 +2434,7 @@ dependencies = [ "serde", "serde_json", "serde_with", - "thiserror 1.0.69", + "thiserror 2.0.3", "tokio", ] @@ -3071,7 +3073,7 @@ dependencies = [ "hyper 1.5.1", "hyper-util", "log", - "rustls 0.23.18", + "rustls 0.23.19", "rustls-pki-types", "tokio", "tokio-rustls 0.26.0", @@ -3557,7 +3559,7 @@ dependencies = [ "http 1.1.0", "jsonrpsee-core", "pin-project", - "rustls 0.23.18", + "rustls 0.23.19", "rustls-pki-types", "rustls-platform-verifier", "soketto", @@ -3610,7 +3612,7 @@ dependencies = [ "hyper-util", "jsonrpsee-core", "jsonrpsee-types", - "rustls 0.23.18", + "rustls 0.23.19", "rustls-platform-verifier", "serde", "serde_json", @@ -3799,9 +3801,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.165" +version = "0.2.166" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb4d3d38eab6c5239a362fa8bae48c03baf980a6e7079f063942d563ef3533e" +checksum = "c2ccc108bbc0b1331bd061864e7cd823c0cab660bbe6970e66e2c0614decde36" [[package]] name = "libm" @@ -5534,7 +5536,7 @@ dependencies = [ "quinn-proto", "quinn-udp", "rustc-hash", - "rustls 0.23.18", + "rustls 0.23.19", "socket2", "thiserror 2.0.3", "tokio", @@ -5552,7 +5554,7 @@ dependencies = [ "rand 0.8.5", "ring", "rustc-hash", - "rustls 0.23.18", + "rustls 0.23.19", "rustls-pki-types", "slab", "thiserror 2.0.3", @@ -5933,7 +5935,7 @@ dependencies = [ "percent-encoding", "pin-project-lite", "quinn", - "rustls 0.23.18", + "rustls 0.23.19", "rustls-pemfile 2.2.0", "rustls-pki-types", "serde", @@ -6032,9 +6034,9 @@ checksum = "6c20b6793b5c2fa6553b250154b78d6d0db37e72700ae35fad9387a46f487c97" [[package]] name = "rsa" -version = "0.9.6" +version = "0.9.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d0e5124fcb30e76a7e79bfee683a2746db83784b86289f6251b54b7950a0dfc" +checksum = "47c75d7c5c6b673e58bf54d8544a9f432e3a925b0e80f7cd3602ab5c50c55519" dependencies = [ "const-oid", "digest 0.10.7", @@ -6127,9 +6129,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.18" +version = "0.23.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c9cc1d47e243d655ace55ed38201c19ae02c148ae56412ab8750e8f0166ab7f" +checksum = "934b404430bb06b3fae2cba809eb45a1ab1aecd64491213d7c3301b88393f8d1" dependencies = [ "log", "once_cell", @@ -6191,7 +6193,7 @@ dependencies = [ "jni", "log", "once_cell", - "rustls 0.23.18", + "rustls 0.23.19", "rustls-native-certs", "rustls-platform-verifier-android", "rustls-webpki 0.102.8", @@ -6751,9 +6753,9 @@ checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "socket2" -version = "0.5.7" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" +checksum = "c970269d99b64e60ec3bd6ad27270092a5394c4e309314b18ae3fe575695fbe8" dependencies = [ "libc", "windows-sys 0.52.0", @@ -7696,7 +7698,7 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "subvt-app-service" -version = "0.22.2" +version = "0.22.3" dependencies = [ "actix-http", "actix-rt", @@ -7725,7 +7727,7 @@ dependencies = [ [[package]] name = "subvt-block-processor" -version = "0.22.2" +version = "0.22.3" dependencies = [ "anyhow", "async-lock", @@ -7751,7 +7753,7 @@ dependencies = [ [[package]] name = "subvt-config" -version = "0.22.2" +version = "0.22.3" dependencies = [ "config", "serde", @@ -7759,7 +7761,7 @@ dependencies = [ [[package]] name = "subvt-governance" -version = "0.22.2" +version = "0.22.3" dependencies = [ "anyhow", "lazy_static", @@ -7773,7 +7775,7 @@ dependencies = [ [[package]] name = "subvt-kline-updater" -version = "0.22.2" +version = "0.22.3" dependencies = [ "anyhow", "async-trait", @@ -7796,7 +7798,7 @@ dependencies = [ [[package]] name = "subvt-logging" -version = "0.22.2" +version = "0.22.3" dependencies = [ "env_logger", "log", @@ -7805,7 +7807,7 @@ dependencies = [ [[package]] name = "subvt-metrics" -version = "0.22.2" +version = "0.22.3" dependencies = [ "env_logger", "log", @@ -7819,7 +7821,7 @@ dependencies = [ [[package]] name = "subvt-network-status-server" -version = "0.22.2" +version = "0.22.3" dependencies = [ "anyhow", "async-trait", @@ -7844,7 +7846,7 @@ dependencies = [ [[package]] name = "subvt-network-status-updater" -version = "0.22.2" +version = "0.22.3" dependencies = [ "anyhow", "async-trait", @@ -7866,7 +7868,7 @@ dependencies = [ [[package]] name = "subvt-nft" -version = "0.22.2" +version = "0.22.3" dependencies = [ "anyhow", "lazy_static", @@ -7878,7 +7880,7 @@ dependencies = [ [[package]] name = "subvt-notification-generator" -version = "0.22.2" +version = "0.22.3" dependencies = [ "anyhow", "async-lock", @@ -7905,7 +7907,7 @@ dependencies = [ [[package]] name = "subvt-notification-processor" -version = "0.22.2" +version = "0.22.3" dependencies = [ "a2", "anyhow", @@ -7940,7 +7942,7 @@ dependencies = [ [[package]] name = "subvt-onekv-updater" -version = "0.22.2" +version = "0.22.3" dependencies = [ "anyhow", "async-trait", @@ -7962,7 +7964,7 @@ dependencies = [ [[package]] name = "subvt-persistence" -version = "0.22.2" +version = "0.22.3" dependencies = [ "anyhow", "chrono", @@ -7981,7 +7983,7 @@ dependencies = [ [[package]] name = "subvt-plotter" -version = "0.22.2" +version = "0.22.3" dependencies = [ "anyhow", "chrono", @@ -8004,7 +8006,7 @@ dependencies = [ [[package]] name = "subvt-proc-macro" -version = "0.22.2" +version = "0.22.3" dependencies = [ "proc-macro2", "quote", @@ -8013,7 +8015,7 @@ dependencies = [ [[package]] name = "subvt-referendum-updater" -version = "0.22.2" +version = "0.22.3" dependencies = [ "anyhow", "async-trait", @@ -8037,7 +8039,7 @@ dependencies = [ [[package]] name = "subvt-report-service" -version = "0.22.2" +version = "0.22.3" dependencies = [ "actix-web", "anyhow", @@ -8065,7 +8067,7 @@ dependencies = [ [[package]] name = "subvt-service-common" -version = "0.22.2" +version = "0.22.3" dependencies = [ "actix-web", "anyhow", @@ -8082,7 +8084,7 @@ dependencies = [ [[package]] name = "subvt-session-validator-performance-updater" -version = "0.22.2" +version = "0.22.3" dependencies = [ "anyhow", "async-lock", @@ -8101,7 +8103,7 @@ dependencies = [ [[package]] name = "subvt-substrate-client" -version = "0.22.2" +version = "0.22.3" dependencies = [ "anyhow", "async-lock", @@ -8130,7 +8132,7 @@ dependencies = [ [[package]] name = "subvt-telegram-bot" -version = "0.22.2" +version = "0.22.3" dependencies = [ "anyhow", "async-recursion", @@ -8168,7 +8170,7 @@ dependencies = [ [[package]] name = "subvt-telemetry-processor" -version = "0.22.2" +version = "0.22.3" dependencies = [ "anyhow", "async-lock", @@ -8192,7 +8194,7 @@ dependencies = [ [[package]] name = "subvt-types" -version = "0.22.2" +version = "0.22.3" dependencies = [ "anyhow", "chrono", @@ -8234,7 +8236,7 @@ dependencies = [ [[package]] name = "subvt-utility" -version = "0.22.2" +version = "0.22.3" dependencies = [ "anyhow", "hex", @@ -8244,7 +8246,7 @@ dependencies = [ [[package]] name = "subvt-validator-details-server" -version = "0.22.2" +version = "0.22.3" dependencies = [ "anyhow", "async-trait", @@ -8268,7 +8270,7 @@ dependencies = [ [[package]] name = "subvt-validator-list-server" -version = "0.22.2" +version = "0.22.3" dependencies = [ "anyhow", "async-trait", @@ -8295,7 +8297,7 @@ dependencies = [ [[package]] name = "subvt-validator-list-updater" -version = "0.22.2" +version = "0.22.3" dependencies = [ "anyhow", "async-lock", @@ -8690,7 +8692,7 @@ version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" dependencies = [ - "rustls 0.23.18", + "rustls 0.23.19", "rustls-pki-types", "tokio", ] @@ -8784,9 +8786,9 @@ checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" [[package]] name = "tracing" -version = "0.1.40" +version = "0.1.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" dependencies = [ "log", "pin-project-lite", @@ -8796,9 +8798,9 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.27" +version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" dependencies = [ "proc-macro2", "quote", diff --git a/_docker/compose/.env.sample b/_docker/compose/.env.sample index ad309237..73fc7cd8 100644 --- a/_docker/compose/.env.sample +++ b/_docker/compose/.env.sample @@ -1,4 +1,4 @@ -VERSION=0.22.2 +VERSION=0.22.3 ENV=production LOG_LEVEL=debug diff --git a/_migrations/network/migrations/20211115071840_fx_validator_info.up.sql b/_migrations/network/migrations/20211115071840_fx_validator_info.up.sql index 0cf0bedf..939dcd83 100644 --- a/_migrations/network/migrations/20211115071840_fx_validator_info.up.sql +++ b/_migrations/network/migrations/20211115071840_fx_validator_info.up.sql @@ -1,3 +1,5 @@ +DROP FUNCTION IF EXISTS sub_get_validator_info_batch; + DO $$ BEGIN DROP FUNCTION IF EXISTS sub_get_validator_info; DROP TYPE IF EXISTS sub_validator_info; @@ -12,7 +14,8 @@ DO $$ BEGIN reward_points bigint, heartbeat_received boolean, dn_node_record_id INTEGER, - dn_status text + dn_status text, + performance TEXT[] ); END $$; @@ -98,7 +101,48 @@ BEGIN WHERE C.validator_account_id = account_id_param ORDER BY id DESC LIMIT 1; + + SELECT COALESCE( + ARRAY_AGG(performance), + ARRAY[]::TEXT[] + ) + FROM( + SELECT ( + era_index::TEXT || ',' || + session_index::TEXT || ',' || + implicit_attestation_count::TEXT || ',' || + explicit_attestation_count::TEXT || ',' || + missed_attestation_count::TEXT || ',' || + attestations_per_billion::TEXT + ) AS performance + FROM sub_session_validator_performance + WHERE validator_account_id = account_id_param + AND para_validator_index IS NOT NULL + ORDER BY id DESC + LIMIT 10 + ) AS subquery + INTO result_record.performance; RETURN result_record; END $$ LANGUAGE plpgsql PARALLEL SAFE STABLE; + +CREATE OR REPLACE FUNCTION sub_get_validator_info_batch (block_hash_param VARCHAR(66), account_ids_param VARCHAR(66)[], is_active_param boolean[], era_index_param bigint) +RETURNS SETOF sub_validator_info +AS $$ + +DECLARE + validator_info sub_validator_info; + account_id VARCHAR(66); + i INT = 1; + is_active BOOLEAN = false; +BEGIN + FOREACH account_id IN ARRAY account_ids_param + LOOP + is_active := is_active_param[i]; + validator_info := sub_get_validator_info(block_hash_param, account_id, is_active, era_index_param); + RETURN NEXT validator_info; + i:= i + 1; + END LOOP; +END +$$ LANGUAGE plpgsql PARALLEL SAFE STABLE; \ No newline at end of file diff --git a/_migrations/network/migrations/20241125150658_fx_validator_info_batch.down.sql b/_migrations/network/migrations/20241125150658_fx_validator_info_batch.down.sql deleted file mode 100644 index dcdfec40..00000000 --- a/_migrations/network/migrations/20241125150658_fx_validator_info_batch.down.sql +++ /dev/null @@ -1 +0,0 @@ -DROP FUNCTION sub_get_validator_info_batch; \ No newline at end of file diff --git a/_migrations/network/migrations/20241125150658_fx_validator_info_batch.up.sql b/_migrations/network/migrations/20241125150658_fx_validator_info_batch.up.sql deleted file mode 100644 index 2b5302fc..00000000 --- a/_migrations/network/migrations/20241125150658_fx_validator_info_batch.up.sql +++ /dev/null @@ -1,19 +0,0 @@ -CREATE OR REPLACE FUNCTION sub_get_validator_info_batch (block_hash_param VARCHAR(66), account_ids_param VARCHAR(66)[], is_active_param boolean[], era_index_param bigint) -RETURNS SETOF sub_validator_info -AS $$ - -DECLARE - validator_info sub_validator_info; - account_id VARCHAR(66); - i INT = 1; - is_active BOOLEAN = false; -BEGIN - FOREACH account_id IN ARRAY account_ids_param - LOOP - is_active := is_active_param[i]; - validator_info := sub_get_validator_info(block_hash_param, account_id, is_active, era_index_param); - RETURN NEXT validator_info; - i:= i + 1; - END LOOP; -END -$$ LANGUAGE plpgsql PARALLEL SAFE STABLE; \ No newline at end of file diff --git a/_migrations/network/migrations/20241127061013_session_validator_performance.up.sql b/_migrations/network/migrations/20241127061013_session_validator_performance.up.sql index fadb8a98..2bf73eab 100644 --- a/_migrations/network/migrations/20241127061013_session_validator_performance.up.sql +++ b/_migrations/network/migrations/20241127061013_session_validator_performance.up.sql @@ -12,9 +12,7 @@ CREATE TABLE IF NOT EXISTS sub_session_validator_performance explicit_attestation_count INT, missed_attestation_count INT, attestations_per_billion INT, - created_at TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT now(), - CONSTRAINT sub_era_validator_u_era_index_validator - UNIQUE (validator_account_id, era_index, session_index) + created_at TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT now() ); CREATE INDEX IF NOT EXISTS sub_session_validator_performance_idx_validator_account_id @@ -28,4 +26,6 @@ CREATE INDEX IF NOT EXISTS sub_session_validator_performance_idx_validator_accou CREATE INDEX IF NOT EXISTS sub_session_validator_performance_idx_validator_account_id_para_validator_index_session_index_desc ON sub_session_validator_performance (validator_account_id, para_validator_index, session_index DESC); CREATE UNIQUE INDEX IF NOT EXISTS sub_session_validator_performance_u_validator_era_session - ON sub_session_validator_performance (validator_account_id, era_index, session_index); \ No newline at end of file + ON sub_session_validator_performance (validator_account_id, era_index, session_index); +CREATE INDEX IF NOT EXISTS sub_session_validator_performance_idx_validator_para_id + ON sub_session_validator_performance (validator_account_id, para_validator_index, id DESC); \ No newline at end of file diff --git a/subvt-app-service/Cargo.toml b/subvt-app-service/Cargo.toml index 0828e6ae..b19ea232 100644 --- a/subvt-app-service/Cargo.toml +++ b/subvt-app-service/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "subvt-app-service" -version = "0.22.2" +version = "0.22.3" edition = "2021" rust-version = "1.67.0" diff --git a/subvt-block-processor/Cargo.toml b/subvt-block-processor/Cargo.toml index 8b067a27..d82f6ced 100644 --- a/subvt-block-processor/Cargo.toml +++ b/subvt-block-processor/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "subvt-block-processor" -version = "0.22.2" +version = "0.22.3" edition = "2021" rust-version = "1.67.0" diff --git a/subvt-config/Cargo.toml b/subvt-config/Cargo.toml index 78b1b8c6..bf5e7ae8 100644 --- a/subvt-config/Cargo.toml +++ b/subvt-config/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "subvt-config" -version = "0.22.2" +version = "0.22.3" edition = "2021" rust-version = "1.67.0" diff --git a/subvt-governance/Cargo.toml b/subvt-governance/Cargo.toml index 8fb28dfa..42ca932f 100644 --- a/subvt-governance/Cargo.toml +++ b/subvt-governance/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "subvt-governance" -version = "0.22.2" +version = "0.22.3" edition = "2021" rust-version = "1.67.0" diff --git a/subvt-kline-updater/Cargo.toml b/subvt-kline-updater/Cargo.toml index d779a6e6..b4ea44f0 100644 --- a/subvt-kline-updater/Cargo.toml +++ b/subvt-kline-updater/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "subvt-kline-updater" -version = "0.22.2" +version = "0.22.3" edition = "2021" rust-version = "1.67.0" diff --git a/subvt-logging/Cargo.toml b/subvt-logging/Cargo.toml index 9d97a210..2edbe076 100644 --- a/subvt-logging/Cargo.toml +++ b/subvt-logging/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "subvt-logging" -version = "0.22.2" +version = "0.22.3" edition = "2021" rust-version = "1.67.0" diff --git a/subvt-metrics/Cargo.toml b/subvt-metrics/Cargo.toml index 9c4a95ed..1a7abea2 100644 --- a/subvt-metrics/Cargo.toml +++ b/subvt-metrics/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "subvt-metrics" -version = "0.22.2" +version = "0.22.3" edition = "2021" rust-version = "1.67.0" diff --git a/subvt-network-status-server/Cargo.toml b/subvt-network-status-server/Cargo.toml index 741aec00..381c30c8 100644 --- a/subvt-network-status-server/Cargo.toml +++ b/subvt-network-status-server/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "subvt-network-status-server" -version = "0.22.2" +version = "0.22.3" edition = "2021" rust-version = "1.67.0" diff --git a/subvt-network-status-updater/Cargo.toml b/subvt-network-status-updater/Cargo.toml index 85b87522..1a83cdfb 100644 --- a/subvt-network-status-updater/Cargo.toml +++ b/subvt-network-status-updater/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "subvt-network-status-updater" -version = "0.22.2" +version = "0.22.3" edition = "2021" rust-version = "1.67.0" diff --git a/subvt-nft/Cargo.toml b/subvt-nft/Cargo.toml index 63de16e7..7489bd97 100644 --- a/subvt-nft/Cargo.toml +++ b/subvt-nft/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "subvt-nft" -version = "0.22.2" +version = "0.22.3" edition = "2021" rust-version = "1.67.0" diff --git a/subvt-notification-generator/Cargo.toml b/subvt-notification-generator/Cargo.toml index 93435509..050cfc39 100644 --- a/subvt-notification-generator/Cargo.toml +++ b/subvt-notification-generator/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "subvt-notification-generator" -version = "0.22.2" +version = "0.22.3" edition = "2021" rust-version = "1.67.0" diff --git a/subvt-notification-processor/Cargo.toml b/subvt-notification-processor/Cargo.toml index fb93e4e2..e8e6fefd 100644 --- a/subvt-notification-processor/Cargo.toml +++ b/subvt-notification-processor/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "subvt-notification-processor" -version = "0.22.2" +version = "0.22.3" edition = "2021" rust-version = "1.67.0" diff --git a/subvt-onekv-updater/Cargo.toml b/subvt-onekv-updater/Cargo.toml index 90adc6eb..4e6eea01 100644 --- a/subvt-onekv-updater/Cargo.toml +++ b/subvt-onekv-updater/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "subvt-onekv-updater" -version = "0.22.2" +version = "0.22.3" edition = "2021" rust-version = "1.67.0" diff --git a/subvt-persistence/Cargo.toml b/subvt-persistence/Cargo.toml index 8cc46fde..b8eb0363 100644 --- a/subvt-persistence/Cargo.toml +++ b/subvt-persistence/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "subvt-persistence" -version = "0.22.2" +version = "0.22.3" edition = "2021" rust-version = "1.67.0" diff --git a/subvt-persistence/src/postgres/network/staking.rs b/subvt-persistence/src/postgres/network/staking.rs index 088638bb..46eebb78 100644 --- a/subvt-persistence/src/postgres/network/staking.rs +++ b/subvt-persistence/src/postgres/network/staking.rs @@ -21,6 +21,7 @@ pub type PostgresValidatorInfo = ( Option, Option, Option, + Vec, ); impl PostgreSQLNetworkStorage { @@ -339,6 +340,16 @@ impl PostgreSQLNetworkStorage { } } unclaimed_era_indices.sort_unstable(); + let performance: Vec> = db_validator_info + .11 + .iter() + .map(|session_performance| { + session_performance + .split(',') + .map(|v| v.parse::().unwrap()) + .collect() + }) + .collect(); ValidatorInfo { discovered_at: db_validator_info.0.map(|value| value as u64), slash_count: db_validator_info.1 as u64, @@ -351,31 +362,10 @@ impl PostgreSQLNetworkStorage { heartbeat_received: db_validator_info.8, dn_record_id: db_validator_info.9.map(|value| value as u32), dn_status: db_validator_info.10.clone(), + performance, } } - pub async fn get_validator_info( - &self, - block_hash: &str, - validator_account_id: &AccountId, - is_active: bool, - era_index: u32, - ) -> anyhow::Result { - let db_validator_info: PostgresValidatorInfo = sqlx::query_as( - r#" - SELECT discovered_at, slash_count, offline_offence_count, active_era_count, inactive_era_count, unclaimed_eras, blocks_authored, reward_points, heartbeat_received, dn_node_record_id, dn_status - FROM sub_get_validator_info($1, $2, $3, $4) - "# - ) - .bind(block_hash) - .bind(validator_account_id.to_string()) - .bind(is_active) - .bind(era_index as i64) - .fetch_one(&self.connection_pool) - .await?; - Ok(Self::db_record_into_validator_info(&db_validator_info)) - } - pub async fn get_validator_info_batch( &self, block_hash: &str, diff --git a/subvt-plotter/Cargo.toml b/subvt-plotter/Cargo.toml index acc26e8c..dbd56eb5 100644 --- a/subvt-plotter/Cargo.toml +++ b/subvt-plotter/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "subvt-plotter" -version = "0.22.2" +version = "0.22.3" edition = "2021" rust-version = "1.67.0" diff --git a/subvt-proc-macro/Cargo.toml b/subvt-proc-macro/Cargo.toml index d65e9840..a928636f 100644 --- a/subvt-proc-macro/Cargo.toml +++ b/subvt-proc-macro/Cargo.toml @@ -3,7 +3,7 @@ proc-macro = true [package] name = "subvt-proc-macro" -version = "0.22.2" +version = "0.22.3" edition = "2021" rust-version = "1.67.0" diff --git a/subvt-referendum-updater/Cargo.toml b/subvt-referendum-updater/Cargo.toml index 92c6ab24..f49da02e 100644 --- a/subvt-referendum-updater/Cargo.toml +++ b/subvt-referendum-updater/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "subvt-referendum-updater" -version = "0.22.2" +version = "0.22.3" edition = "2021" rust-version = "1.67.0" diff --git a/subvt-report-service/Cargo.toml b/subvt-report-service/Cargo.toml index c1389f91..96b141b6 100644 --- a/subvt-report-service/Cargo.toml +++ b/subvt-report-service/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "subvt-report-service" -version = "0.22.2" +version = "0.22.3" edition = "2021" rust-version = "1.67.0" diff --git a/subvt-service-common/Cargo.toml b/subvt-service-common/Cargo.toml index e7c1f718..8e6cf2be 100644 --- a/subvt-service-common/Cargo.toml +++ b/subvt-service-common/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "subvt-service-common" -version = "0.22.2" +version = "0.22.3" edition = "2021" rust-version = "1.67.0" diff --git a/subvt-session-validator-performance-updater/Cargo.toml b/subvt-session-validator-performance-updater/Cargo.toml index 2f5e0b9f..2f46eb1f 100644 --- a/subvt-session-validator-performance-updater/Cargo.toml +++ b/subvt-session-validator-performance-updater/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "subvt-session-validator-performance-updater" -version = "0.22.2" +version = "0.22.3" edition = "2021" rust-version = "1.67.0" diff --git a/subvt-session-validator-performance-updater/src/lib.rs b/subvt-session-validator-performance-updater/src/lib.rs index d0684fd3..ad219952 100644 --- a/subvt-session-validator-performance-updater/src/lib.rs +++ b/subvt-session-validator-performance-updater/src/lib.rs @@ -166,7 +166,10 @@ impl Service for SessionValidatorPerformanceUpdater { "Sleep for {} seconds.", CONFIG.session_validator_performance_updater.sleep_seconds ); - tokio::time::sleep(std::time::Duration::from_secs(CONFIG.dn.refresh_seconds)).await; + tokio::time::sleep(std::time::Duration::from_secs( + CONFIG.session_validator_performance_updater.sleep_seconds, + )) + .await; } } } diff --git a/subvt-substrate-client/Cargo.toml b/subvt-substrate-client/Cargo.toml index 588af5cc..c0f21511 100644 --- a/subvt-substrate-client/Cargo.toml +++ b/subvt-substrate-client/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "subvt-substrate-client" -version = "0.22.2" +version = "0.22.3" edition = "2021" rust-version = "1.67.0" diff --git a/subvt-telegram-bot/Cargo.toml b/subvt-telegram-bot/Cargo.toml index ebab03a3..23e7ac38 100644 --- a/subvt-telegram-bot/Cargo.toml +++ b/subvt-telegram-bot/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "subvt-telegram-bot" -version = "0.22.2" +version = "0.22.3" edition = "2021" rust-version = "1.67.0" @@ -10,7 +10,7 @@ async-recursion = "1.0" async-trait = "0.1" chrono = "0.4" enum-iterator = "2.0" -frankenstein = { version = "0.34", default-features = false, features = ["async-http-client", "async-telegram-trait"] } +frankenstein = { version = "0.35", default-features = false, features = ["async-http-client", "async-telegram-trait"] } futures = "0.3" itertools = { workspace = true } lazy_static = { workspace = true } diff --git a/subvt-telemetry-processor/Cargo.toml b/subvt-telemetry-processor/Cargo.toml index be5039c1..3c887827 100644 --- a/subvt-telemetry-processor/Cargo.toml +++ b/subvt-telemetry-processor/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "subvt-telemetry-processor" -version = "0.22.2" +version = "0.22.3" edition = "2021" rust-version = "1.67.0" diff --git a/subvt-types/Cargo.toml b/subvt-types/Cargo.toml index 290fe0dc..45f7dfa2 100644 --- a/subvt-types/Cargo.toml +++ b/subvt-types/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "subvt-types" -version = "0.22.2" +version = "0.22.3" edition = "2021" rust-version = "1.67.0" diff --git a/subvt-types/src/rdb.rs b/subvt-types/src/rdb.rs index 8473773e..eccd376b 100644 --- a/subvt-types/src/rdb.rs +++ b/subvt-types/src/rdb.rs @@ -13,6 +13,7 @@ pub struct ValidatorInfo { pub heartbeat_received: Option, pub dn_record_id: Option, pub dn_status: Option, + pub performance: Vec>, } #[derive(Clone, Debug, Deserialize, Serialize)] diff --git a/subvt-types/src/subvt.rs b/subvt-types/src/subvt.rs index e3ebcc0f..3810e73d 100644 --- a/subvt-types/src/subvt.rs +++ b/subvt-types/src/subvt.rs @@ -87,6 +87,7 @@ pub struct ValidatorDetails { pub onekv_is_valid: Option, #[serde(skip_serializing_if = "Option::is_none")] pub onekv_offline_since: Option, + pub performance: Vec>, } #[derive(Clone, Debug, Default, Deserialize, Diff, Eq, Hash, PartialEq, Serialize)] @@ -124,6 +125,7 @@ pub struct ValidatorSummary { pub heartbeat_received: Option, #[serde(skip_serializing_if = "Option::is_none")] pub validator_stake: Option, + pub performance: Vec>, } impl From<&ValidatorDetails> for ValidatorSummary { @@ -175,6 +177,7 @@ impl From<&ValidatorDetails> for ValidatorSummary { .validator_stake .as_ref() .map(ValidatorStakeSummary::from), + performance: validator.performance.clone(), } } } diff --git a/subvt-utility/Cargo.toml b/subvt-utility/Cargo.toml index 19ba7b4d..8b79b35f 100644 --- a/subvt-utility/Cargo.toml +++ b/subvt-utility/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "subvt-utility" -version = "0.22.2" +version = "0.22.3" edition = "2021" rust-version = "1.67.0" diff --git a/subvt-validator-details-server/Cargo.toml b/subvt-validator-details-server/Cargo.toml index 8238cf99..bc0bc5bf 100644 --- a/subvt-validator-details-server/Cargo.toml +++ b/subvt-validator-details-server/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "subvt-validator-details-server" -version = "0.22.2" +version = "0.22.3" edition = "2021" rust-version = "1.67.0" diff --git a/subvt-validator-list-server/Cargo.toml b/subvt-validator-list-server/Cargo.toml index 0d6b78c7..3d3d8b29 100644 --- a/subvt-validator-list-server/Cargo.toml +++ b/subvt-validator-list-server/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "subvt-validator-list-server" -version = "0.22.2" +version = "0.22.3" edition = "2021" rust-version = "1.67.0" diff --git a/subvt-validator-list-updater/Cargo.toml b/subvt-validator-list-updater/Cargo.toml index 420c9539..2abcb28d 100644 --- a/subvt-validator-list-updater/Cargo.toml +++ b/subvt-validator-list-updater/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "subvt-validator-list-updater" -version = "0.22.2" +version = "0.22.3" edition = "2021" rust-version = "1.67.0" diff --git a/subvt-validator-list-updater/src/lib.rs b/subvt-validator-list-updater/src/lib.rs index 3a1e95c3..fe34d81d 100644 --- a/subvt-validator-list-updater/src/lib.rs +++ b/subvt-validator-list-updater/src/lib.rs @@ -262,6 +262,7 @@ impl ValidatorListUpdater { validator.onekv_is_valid = Some(db_validator_info.dn_status == Some("Active".to_string())); validator.onekv_offline_since = None; + validator.performance = db_validator_info.performance.clone(); } } log::info!("Got RDB content. Update Redis.");