From e9b68cf9ee801d3b6508864616a86e6cccf8a522 Mon Sep 17 00:00:00 2001 From: Yurii Koba Date: Wed, 8 Jan 2025 13:27:33 +0200 Subject: [PATCH 1/4] s3 client implementation for transactions details --- Cargo.lock | 305 +++++------------- configuration/Cargo.toml | 2 +- .../src/configs/tx_details_storage.rs | 55 +++- configuration/src/default_env_configs.rs | 12 + rpc-server/Cargo.toml | 1 - rpc-server/src/config.rs | 2 +- tx-details-storage/Cargo.toml | 2 +- tx-details-storage/src/lib.rs | 39 +-- tx-indexer/src/main.rs | 2 +- 9 files changed, 160 insertions(+), 260 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2436a0b9..1fec3e99 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -130,7 +130,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e01ed3140b2f8d422c68afa1ed2e85d996ea619c988ac834d255db32138655cb" dependencies = [ "quote", - "syn 2.0.94", + "syn 2.0.95", ] [[package]] @@ -269,7 +269,7 @@ dependencies = [ "actix-router", "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.95", ] [[package]] @@ -280,7 +280,7 @@ checksum = "b6ac1e58cded18cb28ddc17143c4dea5345b3ad575e14f32f66e4054a56eb271" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.95", ] [[package]] @@ -504,18 +504,18 @@ checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.95", ] [[package]] name = "async-trait" -version = "0.1.84" +version = "0.1.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b1244b10dcd56c92219da4e14caa97e312079e185f04ba3eea25061561dc0a0" +checksum = "3f934833b4b7233644e5848f235df3f57ed8c80f1528a26c3dfa13d2147fa056" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.95", ] [[package]] @@ -1143,7 +1143,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn 2.0.94", + "syn 2.0.95", ] [[package]] @@ -1266,7 +1266,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.95", ] [[package]] @@ -1479,9 +1479,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.23" +version = "4.5.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3135e7ec2ef7b10c6ed8950f0f792ed96ee093fa088608f1c76e569722700c84" +checksum = "9560b07a799281c7e0958b9296854d6fafd4c5f31444a7e5bb1ad6dde5ccf1bd" dependencies = [ "clap_builder", "clap_derive", @@ -1489,9 +1489,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.23" +version = "4.5.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30582fc632330df2bd26877bde0c1f4470d57c582bbc070376afcd04d8cb4838" +checksum = "874e0dd3eb68bf99058751ac9712f622e61e6f393a94f7128fa26e3f02f5c7cd" dependencies = [ "anstream", "anstyle", @@ -1501,14 +1501,14 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.18" +version = "4.5.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab" +checksum = "54b755194d6389280185988721fffba69495eed5ee9feeee9a599b53db80318c" dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.95", ] [[package]] @@ -1530,7 +1530,7 @@ dependencies = [ "dotenv", "futures-util", "hex", - "jsonwebtoken 7.2.0", + "jsonwebtoken", "lazy_static", "openssl", "percent-encoding", @@ -1583,8 +1583,8 @@ name = "configuration" version = "0.3.3" dependencies = [ "anyhow", + "aws-sdk-s3", "dotenv", - "google-cloud-storage", "lazy_static", "near-lake-framework", "opentelemetry 0.19.0", @@ -1979,7 +1979,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.95", ] [[package]] @@ -2027,7 +2027,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.11.1", - "syn 2.0.94", + "syn 2.0.95", ] [[package]] @@ -2049,7 +2049,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core 0.20.10", "quote", - "syn 2.0.94", + "syn 2.0.95", ] [[package]] @@ -2133,7 +2133,7 @@ checksum = "62d671cc41a825ebabc75757b62d3d168c577f9149b2d49ece1dad1f72119d25" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.95", ] [[package]] @@ -2144,7 +2144,7 @@ checksum = "30542c1ad912e0e3d22a1935c290e12e8a29d704a420177a31faad4a601a0800" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.95", ] [[package]] @@ -2188,7 +2188,7 @@ dependencies = [ "proc-macro2", "quote", "rustc_version 0.4.1", - "syn 2.0.94", + "syn 2.0.95", ] [[package]] @@ -2249,7 +2249,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.95", ] [[package]] @@ -2430,7 +2430,7 @@ checksum = "f282cfdfe92516eb26c2af8589c274c7c17681f5ecc03c18255fe741c6aa64eb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.95", ] [[package]] @@ -2451,7 +2451,7 @@ dependencies = [ "darling 0.20.10", "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.95", ] [[package]] @@ -2510,9 +2510,9 @@ checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" [[package]] name = "event-listener" -version = "5.3.1" +version = "5.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6032be9bd27023a771701cc49f9f053c751055f71efb2e0ae5c15809093675ba" +checksum = "3492acde4c3fc54c845eaab3eed8bd00c7a7d881f78bfc801e43a93dec1331ae" dependencies = [ "concurrent-queue", "parking", @@ -2753,7 +2753,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.95", ] [[package]] @@ -2845,10 +2845,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if 1.0.0", - "js-sys", "libc", "wasi 0.11.0+wasi-snapshot-preview1", - "wasm-bindgen", ] [[package]] @@ -2874,81 +2872,6 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2" -[[package]] -name = "google-cloud-auth" -version = "0.17.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e57a13fbacc5e9c41ded3ad8d0373175a6b7a6ad430d99e89d314ac121b7ab06" -dependencies = [ - "async-trait", - "base64 0.21.7", - "google-cloud-metadata", - "google-cloud-token", - "home", - "jsonwebtoken 9.3.0", - "reqwest 0.12.12", - "serde", - "serde_json", - "thiserror 1.0.69", - "time", - "tokio", - "tracing", - "urlencoding", -] - -[[package]] -name = "google-cloud-metadata" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04f945a208886a13d07636f38fb978da371d0abc3e34bad338124b9f8c135a8f" -dependencies = [ - "reqwest 0.12.12", - "thiserror 1.0.69", - "tokio", -] - -[[package]] -name = "google-cloud-storage" -version = "0.23.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e81dff54dbfa83705c896179ecaa4f384bfbfac90f3b637f38541443275b8a3f" -dependencies = [ - "anyhow", - "async-stream", - "async-trait", - "base64 0.21.7", - "bytes", - "futures-util", - "google-cloud-auth", - "google-cloud-metadata", - "google-cloud-token", - "hex", - "once_cell", - "percent-encoding", - "pkcs8 0.10.2", - "regex", - "reqwest 0.12.12", - "reqwest-middleware", - "ring 0.17.8", - "serde", - "serde_json", - "sha2", - "thiserror 1.0.69", - "time", - "tokio", - "tracing", - "url", -] - -[[package]] -name = "google-cloud-token" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f49c12ba8b21d128a2ce8585955246977fbce4415f680ebf9199b6f9d6d725f" -dependencies = [ - "async-trait", -] - [[package]] name = "group" version = "0.12.1" @@ -3457,7 +3380,7 @@ checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.95", ] [[package]] @@ -3659,26 +3582,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "afabcc15e437a6484fc4f12d0fd63068fe457bf93f1c148d3d9649c60b103f32" dependencies = [ "base64 0.12.3", - "pem 0.8.3", + "pem", "ring 0.16.20", "serde", "serde_json", - "simple_asn1 0.4.1", -] - -[[package]] -name = "jsonwebtoken" -version = "9.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9ae10193d25051e74945f1ea2d0b42e03cc3b890f7e4cc5faa44997d808193f" -dependencies = [ - "base64 0.21.7", - "js-sys", - "pem 3.0.4", - "ring 0.17.8", - "serde", - "serde_json", - "simple_asn1 0.6.2", + "simple_asn1", ] [[package]] @@ -3788,9 +3696,9 @@ dependencies = [ [[package]] name = "libz-sys" -version = "1.1.20" +version = "1.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2d16453e800a8cf6dd2fc3eb4bc99b786a9b90c663b8559a5b1a041bf89e472" +checksum = "df9b68e50e6e0b26f672573834882eb57759f6db9b3be2ea3c35c91188bb4eaa" dependencies = [ "cc", "libc", @@ -3800,9 +3708,9 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.4.14" +version = "0.4.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" +checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" [[package]] name = "litemap" @@ -3957,7 +3865,7 @@ checksum = "5cf92c10c7e361d6b99666ec1c6f9805b0bea2c3bd8c78dc6fe98ac5bd78db11" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.95", ] [[package]] @@ -4170,7 +4078,7 @@ source = "git+https://github.com/near/nearcore?rev=27974494a5f9f2fd3e534456dbf0b dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.95", ] [[package]] @@ -4900,7 +4808,7 @@ version = "2.4.0" source = "git+https://github.com/near/nearcore?rev=27974494a5f9f2fd3e534456dbf0bbe001bff1bd#27974494a5f9f2fd3e534456dbf0bbe001bff1bd" dependencies = [ "quote", - "syn 2.0.94", + "syn 2.0.95", ] [[package]] @@ -5080,7 +4988,7 @@ checksum = "80fca203c51edd9595ec14db1d13359fb9ede32314990bf296b6c5c4502f6ab7" dependencies = [ "quote", "serde", - "syn 2.0.94", + "syn 2.0.95", ] [[package]] @@ -5092,7 +5000,7 @@ dependencies = [ "fs2", "near-rpc-error-core", "serde", - "syn 2.0.94", + "syn 2.0.95", ] [[package]] @@ -5724,7 +5632,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.95", ] [[package]] @@ -6217,16 +6125,6 @@ dependencies = [ "regex", ] -[[package]] -name = "pem" -version = "3.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e459365e590736a54c3fa561947c84837534b8e9af6fc5bf781307e82658fae" -dependencies = [ - "base64 0.22.1", - "serde", -] - [[package]] name = "pem-rfc7468" version = "0.7.0" @@ -6273,29 +6171,29 @@ dependencies = [ [[package]] name = "pin-project" -version = "1.1.7" +version = "1.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be57f64e946e500c8ee36ef6331845d40a93055567ec57e8fae13efd33759b95" +checksum = "1e2ec53ad785f4d35dac0adea7f7dc6f1bb277ad84a680c7afefeae05d1f5916" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.7" +version = "1.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c0f5fad0874fc7abcd4d750e76917eaebbecaa2c20bde22e1dbeeba8beb758c" +checksum = "d56a66c0c55993aa927429d0f8a0abfd74f084e4d9c192cffed01e418d83eefb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.95", ] [[package]] name = "pin-project-lite" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "915a1e146535de9163f3987b8944ed8cf49a18bb0056bcebcdcece385cece4ff" +checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" [[package]] name = "pin-utils" @@ -6379,12 +6277,12 @@ checksum = "aa06bd51638b6e76ac9ba9b6afb4164fa647bd2916d722f2623fbb6d1ed8bdba" [[package]] name = "prettyplease" -version = "0.2.25" +version = "0.2.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64d1ec885c64d0457d564db4ec299b2dae3f9c02808b8ad9c3a089c591b18033" +checksum = "483f8c21f64f3ea09fe0f30f5d48c3e8eefe5dac9129f0075f76593b4c1da705" dependencies = [ "proc-macro2", - "syn 2.0.94", + "syn 2.0.95", ] [[package]] @@ -6449,7 +6347,7 @@ dependencies = [ "proc-macro-error-attr2", "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.95", ] [[package]] @@ -6539,7 +6437,7 @@ dependencies = [ "itertools 0.12.1", "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.95", ] [[package]] @@ -6811,7 +6709,6 @@ dependencies = [ "serde_json", "thiserror 2.0.9", "tokio", - "tokio-stream", "tracing", "tracing-actix-web", "tx-details-storage", @@ -7061,7 +6958,6 @@ dependencies = [ "js-sys", "log", "mime", - "mime_guess", "native-tls", "once_cell", "percent-encoding", @@ -7074,32 +6970,15 @@ dependencies = [ "system-configuration 0.6.1", "tokio", "tokio-native-tls", - "tokio-util 0.7.13", "tower 0.5.2", "tower-service", "url", "wasm-bindgen", "wasm-bindgen-futures", - "wasm-streams", "web-sys", "windows-registry", ] -[[package]] -name = "reqwest-middleware" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1ccd3b55e711f91a9885a2fa6fbbb2e39db1776420b062efc058c6410f7e5e3" -dependencies = [ - "anyhow", - "async-trait", - "http 1.2.0", - "reqwest 0.12.12", - "serde", - "thiserror 1.0.69", - "tower-service", -] - [[package]] name = "rfc6979" version = "0.3.1" @@ -7298,9 +7177,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.42" +version = "0.38.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f93dc38ecbab2eb790ff964bb77fa94faf256fd3e73285fd7ba0903b76bedb85" +checksum = "a78891ee6bf2340288408954ac787aa063d8e8817e9f53abb37c695c6d834ef6" dependencies = [ "bitflags 2.6.0", "errno 0.3.10", @@ -7499,9 +7378,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.13.0" +version = "2.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1863fd3768cd83c56a7f60faa4dc0d403f1b6df0a38c3c25f44b7894e45370d5" +checksum = "49db231d56a190491cb4aeda9527f1ad45345af50b0851622a7adb8c03b01c32" dependencies = [ "core-foundation-sys", "libc", @@ -7576,7 +7455,7 @@ checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.95", ] [[package]] @@ -7590,9 +7469,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.134" +version = "1.0.135" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d00f4175c42ee48b15416f6193a959ba3a0d67fc699a0db9ad12df9f83991c7d" +checksum = "2b0d7ba2887406110130a978386c4e1befb98c674b4fba677954e4db976630d9" dependencies = [ "itoa", "memchr", @@ -7608,7 +7487,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.95", ] [[package]] @@ -7659,7 +7538,7 @@ dependencies = [ "darling 0.20.10", "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.95", ] [[package]] @@ -7774,18 +7653,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "simple_asn1" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adc4e5204eb1910f40f9cfa375f6f05b68c3abac4b6fd879c8ff5e7ae8a0a085" -dependencies = [ - "num-bigint 0.4.6", - "num-traits", - "thiserror 1.0.69", - "time", -] - [[package]] name = "sized-chunks" version = "0.6.5" @@ -7928,7 +7795,7 @@ dependencies = [ "crc", "crossbeam-queue", "either", - "event-listener 5.3.1", + "event-listener 5.4.0", "futures-core", "futures-intrusive", "futures-io", @@ -7962,7 +7829,7 @@ dependencies = [ "quote", "sqlx-core", "sqlx-macros-core", - "syn 2.0.94", + "syn 2.0.95", ] [[package]] @@ -7985,7 +7852,7 @@ dependencies = [ "sqlx-mysql", "sqlx-postgres", "sqlx-sqlite", - "syn 2.0.94", + "syn 2.0.95", "tempfile", "tokio", "url", @@ -8210,9 +8077,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.94" +version = "2.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "987bc0be1cdea8b10216bd06e2ca407d40b9543468fafd3ddfb02f36e77f71f3" +checksum = "46f71c0377baf4ef1cc3e3402ded576dccc315800fbc62dfc7fe04b009773b4a" dependencies = [ "proc-macro2", "quote", @@ -8242,7 +8109,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.95", ] [[package]] @@ -8360,7 +8227,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.95", ] [[package]] @@ -8371,7 +8238,7 @@ checksum = "7b50fa271071aae2e6ee85f842e2e28ba8cd2c5fb67f11fcb1fd70b276f9e7d4" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.95", ] [[package]] @@ -8509,7 +8376,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.95", ] [[package]] @@ -8798,7 +8665,7 @@ checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.95", ] [[package]] @@ -8946,7 +8813,7 @@ name = "tx-details-storage" version = "0.3.3" dependencies = [ "anyhow", - "google-cloud-storage", + "aws-sdk-s3", ] [[package]] @@ -9128,7 +8995,7 @@ dependencies = [ "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.95", ] [[package]] @@ -9215,7 +9082,7 @@ dependencies = [ "log", "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.95", "wasm-bindgen-shared", ] @@ -9250,7 +9117,7 @@ checksum = "30d7a95b763d3c45903ed6c81f156801839e5ee968bb07e534c44df0fcd330c2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.95", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -9708,7 +9575,7 @@ checksum = "09b5575a75e711ca6c36bb9ad647c93541cdc8e34218031acba5da3f35919dd3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.95", ] [[package]] @@ -10037,9 +9904,9 @@ dependencies = [ [[package]] name = "xml-rs" -version = "0.8.24" +version = "0.8.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea8b391c9a790b496184c29f7f93b9ed5b16abb306c05415b68bcc16e4d06432" +checksum = "c5b940ebc25896e71dd073bad2dbaa2abfe97b0a391415e22ad1326d9c54e3c4" [[package]] name = "xmlparser" @@ -10082,7 +9949,7 @@ checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.95", "synstructure", ] @@ -10104,7 +9971,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.95", ] [[package]] @@ -10124,7 +9991,7 @@ checksum = "595eed982f7d355beb85837f651fa22e90b3c044842dc7f2c2842c086f295808" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.95", "synstructure", ] @@ -10145,7 +10012,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.95", ] [[package]] @@ -10180,7 +10047,7 @@ checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.95", ] [[package]] diff --git a/configuration/Cargo.toml b/configuration/Cargo.toml index 70da9cb4..5b9d0f5e 100644 --- a/configuration/Cargo.toml +++ b/configuration/Cargo.toml @@ -9,8 +9,8 @@ license.workspace = true [dependencies] anyhow = "1.0.70" +aws-sdk-s3 = "1.68.0" dotenv = "0.15.0" -google-cloud-storage = "0.23.0" lazy_static = "1.4.0" regex = "1.10.2" serde = "1.0.145" diff --git a/configuration/src/configs/tx_details_storage.rs b/configuration/src/configs/tx_details_storage.rs index e85a6cf3..c82f01d5 100644 --- a/configuration/src/configs/tx_details_storage.rs +++ b/configuration/src/configs/tx_details_storage.rs @@ -5,25 +5,42 @@ use crate::configs::{deserialize_optional_data_or_env, required_value_or_panic}; #[derive(Debug, Clone)] pub struct TxDetailsStorageConfig { pub bucket_name: String, + pub access_key: String, + pub secret_key: String, + pub region: String, + pub endpoint: Option, } impl TxDetailsStorageConfig { - pub async fn gcs_config(&self) -> google_cloud_storage::client::ClientConfig { - let default_config = google_cloud_storage::client::ClientConfig::default(); - if std::env::var("STORAGE_EMULATOR_HOST").is_ok() { - // if we are running local, and we are using gcs emulator - // we need to use anonymous access with the emulator host - let mut config = default_config.anonymous(); - config.storage_endpoint = std::env::var("STORAGE_EMULATOR_HOST").unwrap(); - config - } else { - default_config.with_auth().await.unwrap() + pub async fn s3_config(&self) -> aws_sdk_s3::Config { + // Define custom region and endpoint + let region = aws_sdk_s3::config::Region::new(self.region.clone()); + + // Create custom credentials + let credentials = aws_sdk_s3::config::Credentials::new( + self.access_key.clone(), + self.secret_key.clone(), + None, + None, + "tx-storage-provider", // It is + ); + + // Build AWS SDK config + let mut s3_conf = aws_sdk_s3::Config::builder() + .region(region) + .credentials_provider(credentials); + + // Override S3 endpoint in case you want to use custom solution + if let Some(s3_endpoint) = self.endpoint.clone() { + s3_conf = s3_conf.endpoint_url(s3_endpoint.to_string()); } + + s3_conf.build() } - pub async fn storage_client(&self) -> google_cloud_storage::client::Client { - let gcs_config = self.gcs_config().await; - google_cloud_storage::client::Client::new(gcs_config) + pub async fn s3_client(&self) -> aws_sdk_s3::Client { + let s3_config = self.s3_config().await; + aws_sdk_s3::Client::from_conf(s3_config) } } @@ -31,12 +48,24 @@ impl TxDetailsStorageConfig { pub struct CommonTxDetailStorageConfig { #[serde(deserialize_with = "deserialize_optional_data_or_env", default)] pub bucket_name: Option, + #[serde(deserialize_with = "deserialize_optional_data_or_env", default)] + pub access_key: Option, + #[serde(deserialize_with = "deserialize_optional_data_or_env", default)] + pub secret_key: Option, + #[serde(deserialize_with = "deserialize_optional_data_or_env", default)] + pub region: Option, + #[serde(deserialize_with = "deserialize_optional_data_or_env", default)] + pub endpoint: Option, } impl From for TxDetailsStorageConfig { fn from(common_config: CommonTxDetailStorageConfig) -> Self { Self { bucket_name: required_value_or_panic("bucket_name", common_config.bucket_name), + access_key: required_value_or_panic("access_key", common_config.access_key), + secret_key: required_value_or_panic("secret_key", common_config.secret_key), + region: required_value_or_panic("region", common_config.region), + endpoint: common_config.endpoint, } } } diff --git a/configuration/src/default_env_configs.rs b/configuration/src/default_env_configs.rs index b251969b..eba59921 100644 --- a/configuration/src/default_env_configs.rs +++ b/configuration/src/default_env_configs.rs @@ -132,6 +132,18 @@ tracked_changes = "${TRACKED_CHANGES}" ## Storage Bucket Name bucket_name = "${TX_BUCKET_NAME}" +## Transaction storage access key +access_key = "${TX_ACCESS_KEY}" + +## Transaction storage secret key +secret_key = "${TX_SECRET_KEY}" + +## Transaction storage region +region = "${TX_REGION}" + +## Transaction storage endpoint (optional) for custom storage solutions +endpoint = "${TX_ENDPOINT}" + ## Database configuration [database] diff --git a/rpc-server/Cargo.toml b/rpc-server/Cargo.toml index c1624bf9..bc05cf0f 100644 --- a/rpc-server/Cargo.toml +++ b/rpc-server/Cargo.toml @@ -29,7 +29,6 @@ serde = { version = "1.0.145", features = ["derive"] } serde_json = "1.0.85" thiserror = "2.0.6" tokio = { version = "1.36.0", features = ["full", "tracing"] } -tokio-stream = { version = "0.1.12" } tracing = { version = "0.1.36", features = ["std"] } tracing-actix-web = "0.7.9" diff --git a/rpc-server/src/config.rs b/rpc-server/src/config.rs index a9e3e597..b1749ae2 100644 --- a/rpc-server/src/config.rs +++ b/rpc-server/src/config.rs @@ -140,7 +140,7 @@ impl ServerContext { ); let tx_details_storage = tx_details_storage::TxDetailsStorage::new( - rpc_server_config.tx_details_storage.storage_client().await, + rpc_server_config.tx_details_storage.s3_client().await, rpc_server_config.tx_details_storage.bucket_name.clone(), ); diff --git a/tx-details-storage/Cargo.toml b/tx-details-storage/Cargo.toml index e2251ec3..a7aff007 100644 --- a/tx-details-storage/Cargo.toml +++ b/tx-details-storage/Cargo.toml @@ -11,4 +11,4 @@ license.workspace = true [dependencies] anyhow = "1.0.70" -google-cloud-storage = "0.23.0" +aws-sdk-s3 = "1.68.0" diff --git a/tx-details-storage/src/lib.rs b/tx-details-storage/src/lib.rs index ea9cf09a..35d22b4c 100644 --- a/tx-details-storage/src/lib.rs +++ b/tx-details-storage/src/lib.rs @@ -1,47 +1,40 @@ -use google_cloud_storage::http::objects::download::Range; -use google_cloud_storage::http::objects::get::GetObjectRequest; -use google_cloud_storage::http::objects::upload::{Media, UploadObjectRequest, UploadType}; - pub struct TxDetailsStorage { - client: google_cloud_storage::client::Client, + client: aws_sdk_s3::Client, bucket_name: String, } impl TxDetailsStorage { /// Create a new instance of the `TxDetailsStorage` struct. - pub fn new(client: google_cloud_storage::client::Client, bucket_name: String) -> Self { + pub fn new(client: aws_sdk_s3::Client, bucket_name: String) -> Self { Self { client, bucket_name, } } + /// Store data in the S3 bucket. pub async fn store(&self, key: &str, data: Vec) -> anyhow::Result<()> { + let byte_stream = aws_sdk_s3::primitives::ByteStream::from(data); self.client - .upload_object( - &UploadObjectRequest { - bucket: self.bucket_name.to_string(), - ..Default::default() - }, - data, - &UploadType::Simple(Media::new(key.to_string())), - ) + .put_object() + .bucket(&self.bucket_name) + .key(key) + .body(byte_stream) + .send() .await?; Ok(()) } + /// Retrieve data from the S3 bucket. pub async fn retrieve(&self, key: &str) -> anyhow::Result> { - let data = self + let object = self .client - .download_object( - &GetObjectRequest { - bucket: self.bucket_name.to_string(), - object: key.to_string(), - ..Default::default() - }, - &Range::default(), - ) + .get_object() + .bucket(&self.bucket_name) + .key(key) + .send() .await?; + let data = object.body.collect().await?.into_bytes().to_vec(); Ok(data) } } diff --git a/tx-indexer/src/main.rs b/tx-indexer/src/main.rs index 98c471f8..47c3b028 100644 --- a/tx-indexer/src/main.rs +++ b/tx-indexer/src/main.rs @@ -80,7 +80,7 @@ async fn main() -> anyhow::Result<()> { tracing::info!(target: INDEXER, "Instantiating the tx_details storage client..."); let tx_details_storage = std::sync::Arc::new(TxDetailsStorage::new( - indexer_config.tx_details_storage.storage_client().await, + indexer_config.tx_details_storage.s3_client().await, indexer_config.tx_details_storage.bucket_name.clone(), )); From 7e5becbc0ffc0c6eacfcd2d345dd125b27d28d6c Mon Sep 17 00:00:00 2001 From: Yurii Koba Date: Wed, 8 Jan 2025 14:54:30 +0200 Subject: [PATCH 2/4] fix client connections --- configuration/Cargo.toml | 2 +- configuration/src/configs/tx_details_storage.rs | 2 +- database/Cargo.toml | 2 +- rpc-server/src/utils.rs | 2 +- tx-details-storage/Cargo.toml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/configuration/Cargo.toml b/configuration/Cargo.toml index 5b9d0f5e..9663ada1 100644 --- a/configuration/Cargo.toml +++ b/configuration/Cargo.toml @@ -9,7 +9,7 @@ license.workspace = true [dependencies] anyhow = "1.0.70" -aws-sdk-s3 = "1.68.0" +aws-sdk-s3 = { version = "1.68.0", features = ["behavior-version-latest"] } dotenv = "0.15.0" lazy_static = "1.4.0" regex = "1.10.2" diff --git a/configuration/src/configs/tx_details_storage.rs b/configuration/src/configs/tx_details_storage.rs index c82f01d5..d722ac4a 100644 --- a/configuration/src/configs/tx_details_storage.rs +++ b/configuration/src/configs/tx_details_storage.rs @@ -22,7 +22,7 @@ impl TxDetailsStorageConfig { self.secret_key.clone(), None, None, - "tx-storage-provider", // It is + "Static", ); // Build AWS SDK config diff --git a/database/Cargo.toml b/database/Cargo.toml index 5e88c08b..3e1e8683 100644 --- a/database/Cargo.toml +++ b/database/Cargo.toml @@ -19,7 +19,7 @@ hex = "0.4.3" lazy_static = "1.4.0" prometheus = "0.13.4" serde_json = "1.0.117" -sqlx = { version = "0.8.2", features = [ +sqlx = { version = "0.8.3", features = [ "runtime-tokio-native-tls", "postgres", "migrate", diff --git a/rpc-server/src/utils.rs b/rpc-server/src/utils.rs index 6a570db9..2c952065 100644 --- a/rpc-server/src/utils.rs +++ b/rpc-server/src/utils.rs @@ -263,7 +263,7 @@ async fn task_optimistic_block_status() { .get(); loop { // check every second - tokio::time::sleep(std::time::Duration::from_secs(1)).await; + tokio::time::sleep(std::time::Duration::from_secs(2)).await; // get the current final block height let current_final = crate::metrics::LATEST_BLOCK_HEIGHT_BY_FINALITIY diff --git a/tx-details-storage/Cargo.toml b/tx-details-storage/Cargo.toml index a7aff007..9f555e22 100644 --- a/tx-details-storage/Cargo.toml +++ b/tx-details-storage/Cargo.toml @@ -11,4 +11,4 @@ license.workspace = true [dependencies] anyhow = "1.0.70" -aws-sdk-s3 = "1.68.0" +aws-sdk-s3 = { version = "1.68.0", features = ["behavior-version-latest"] } From 8edbb2b89f8492d4b1b479cef434d5e8ea26fdd1 Mon Sep 17 00:00:00 2001 From: Yurii Koba Date: Wed, 8 Jan 2025 15:02:30 +0200 Subject: [PATCH 3/4] disable StalledStreamProtection --- configuration/src/configs/tx_details_storage.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/configuration/src/configs/tx_details_storage.rs b/configuration/src/configs/tx_details_storage.rs index d722ac4a..e88e1582 100644 --- a/configuration/src/configs/tx_details_storage.rs +++ b/configuration/src/configs/tx_details_storage.rs @@ -26,9 +26,13 @@ impl TxDetailsStorageConfig { ); // Build AWS SDK config - let mut s3_conf = aws_sdk_s3::Config::builder() - .region(region) - .credentials_provider(credentials); + let mut s3_conf = + aws_sdk_s3::Config::builder() + .stalled_stream_protection( + aws_sdk_s3::config::StalledStreamProtectionConfig::disabled(), + ) + .region(region) + .credentials_provider(credentials); // Override S3 endpoint in case you want to use custom solution if let Some(s3_endpoint) = self.endpoint.clone() { From f60f16d85db01883c2435f8766ebc967d6617e80 Mon Sep 17 00:00:00 2001 From: Yurii Koba Date: Wed, 8 Jan 2025 15:14:03 +0200 Subject: [PATCH 4/4] update changelog --- CHANGELOG.md | 2 ++ rpc-server/src/utils.rs | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4fb67f6c..8ce812d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### What's Changed * Migrate from lake data to fastnear data * Add metrics to calculate the number of blocks which fetched from the cache and fastnear +* Add blocks chunks cache and optimize cache layer for read-rpc-server +* Add S3 Client Implementation for Transaction Details with Support for Multiple Storage Providers ## [0.3.3](https://github.com/near/read-rpc/releases/tag/v0.3.3) diff --git a/rpc-server/src/utils.rs b/rpc-server/src/utils.rs index 2c952065..c0602651 100644 --- a/rpc-server/src/utils.rs +++ b/rpc-server/src/utils.rs @@ -262,7 +262,7 @@ async fn task_optimistic_block_status() { .with_label_values(&["optimistic"]) .get(); loop { - // check every second + // check every 2 seconds tokio::time::sleep(std::time::Duration::from_secs(2)).await; // get the current final block height