diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml deleted file mode 100644 index 889b1df5..00000000 --- a/.buildkite/pipeline.yml +++ /dev/null @@ -1,13 +0,0 @@ -steps: - - command: "source ~/.cargo/env && cargo fmt --all -- --check" - label: "Formatter" - - - command: "source ~/.cargo/env && cargo clippy" - label: "Linter" - - - command: "source ~/.cargo/env && cargo test" - label: "Tests" - - - command: "fossa init && fossa analyze --server-scan && fossa test" - label: "Fossa" - branches: "master" diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index 645fa63b..00000000 --- a/.dockerignore +++ /dev/null @@ -1,15 +0,0 @@ -.git -.gitignore -target -*.swp - -# Don't invalidate the Docker cache if this file or the Dockerfile change since -# the engine will be forced to read it anyways -.dockerignore -Dockerfile - -# Don't invalidate the Docker cache if the docs change -*.md -docs -LICENSE -CODEOWNERS diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..6939923c --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,51 @@ +name: ci +on: + pull_request: + branches: [master] + push: + branches: [master] + # schedule: + # - cron: '00 01 * * *' +jobs: + test: + name: test + runs-on: ubuntu-latest + env: + # For some builds, we disable ledger support + FEATURES_FLAGS: + # Emit backtraces on panics. + RUST_BACKTRACE: 1 + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Install Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + profile: minimal + override: true + + - name: Build indexer-explorer-lake and all crates + run: cargo build --verbose --all ${{ env.FEATURES_FLAGS }} + + - name: Run tests + run: cargo test --verbose --all ${{ env.FEATURES_FLAGS }} + + rustfmt: + name: rustfmt + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - name: Install Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + profile: minimal + components: rustfmt + - name: Check formatting + run: | + cargo fmt --all -- --check diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c39613eb..02a9d10f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -56,7 +56,7 @@ We use the following order to group our imports (use statements): 1. standard Rust library imports (e.g. `std::sync::Arc`) 2. external crates (e.g. `tokio::time`) -3. near-* crates (e.g. `near_indexer::near_primitives::types`) +3. near-* crates (e.g. `near_lake_framework::near_indexer_primitives::types`) 4. local crate modules (e.g. `crate::db`) 5. local modules (e.g. `self::access_keys`) 6. `mod` statements @@ -104,7 +104,7 @@ fn my_func() { over: ```rust -use near_indexer::near_primitives::types::Account; +use near_lake_framework::near_indexer_primitives::types::Account; fn my_func() { let my_account = Account::from("test.near"); diff --git a/Cargo.lock b/Cargo.lock index e470ad2b..092adb31 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -25,11 +25,11 @@ dependencies = [ "futures-util", "log", "once_cell", - "parking_lot 0.12.1", + "parking_lot", "pin-project-lite", "smallvec", "tokio", - "tokio-util 0.7.2", + "tokio-util", ] [[package]] @@ -46,22 +46,7 @@ dependencies = [ "memchr", "pin-project-lite", "tokio", - "tokio-util 0.7.2", -] - -[[package]] -name = "actix-cors" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "414360eed71ba2d5435b185ba43ecbe281dfab5df3898286d6b7be8074372c92" -dependencies = [ - "actix-utils", - "actix-web", - "derive_more", - "futures-util", - "log", - "once_cell", - "smallvec", + "tokio-util", ] [[package]] @@ -80,9 +65,9 @@ dependencies = [ [[package]] name = "actix-http" -version = "3.0.4" +version = "3.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5885cb81a0d4d0d322864bea1bb6c2a8144626b4fdc625d4c51eba197e7797a" +checksum = "0c83abf9903e1f0ad9973cc4f7b9767fd5a03a583f51a5b7a339e07987cd2724" dependencies = [ "actix-codec", "actix-rt", @@ -105,13 +90,13 @@ dependencies = [ "itoa", "language-tags", "local-channel", - "log", "mime", "percent-encoding", "pin-project-lite", "rand 0.8.5", - "sha-1", + "sha1", "smallvec", + "tracing", "zstd", ] @@ -127,16 +112,15 @@ dependencies = [ [[package]] name = "actix-router" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb60846b52c118f2f04a56cc90880a274271c489b2498623d58176f8ca21fa80" +checksum = "d66ff4d247d2b160861fa2866457e85706833527840e4133f8f49aa423a38799" dependencies = [ "bytestring", - "firestorm", "http", - "log", "regex", "serde", + "tracing", ] [[package]] @@ -179,30 +163,11 @@ dependencies = [ "pin-project-lite", ] -[[package]] -name = "actix-tls" -version = "3.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fde0cf292f7cdc7f070803cb9a0d45c018441321a78b1042ffbbb81ec333297" -dependencies = [ - "actix-codec", - "actix-rt", - "actix-service", - "actix-utils", - "futures-core", - "http", - "log", - "openssl", - "pin-project-lite", - "tokio-openssl", - "tokio-util 0.7.2", -] - [[package]] name = "actix-utils" -version = "3.0.0" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e491cbaac2e7fc788dfff99ff48ef317e23b3cf63dbaf7aaab6418f40f92aa94" +checksum = "88a1dcdff1466e3c2488e1cb5c36a71822750ad43839937f85d2f4d9f8b705d8" dependencies = [ "local-waker", "pin-project-lite", @@ -250,9 +215,9 @@ dependencies = [ [[package]] name = "actix-web-codegen" -version = "4.0.0" +version = "4.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7525bedf54704abb1d469e88d7e7e9226df73778798a69cea5022d53b2ae91bc" +checksum = "1fa9362663c8643d67b2d5eafba49e4cb2c8a053a29ed00a0bea121f17c76b13" dependencies = [ "actix-router", "proc-macro2", @@ -271,15 +236,6 @@ dependencies = [ "syn", ] -[[package]] -name = "addr2line" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9ecd88a8c8378ca913a680cd98f0f13ac67383d35993f86c90a70e3f137816b" -dependencies = [ - "gimli", -] - [[package]] name = "adler" version = "1.0.2" @@ -314,15 +270,15 @@ dependencies = [ [[package]] name = "alloc-no-stdlib" -version = "2.0.3" +version = "2.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35ef4730490ad1c4eae5c4325b2a95f521d023e5c885853ff7aca0a6a1631db3" +checksum = "cc7bb162ec39d46ab1ca8c77bf72e890535becd1751bb45f64c597edb4c8c6b3" [[package]] name = "alloc-stdlib" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "697ed7edc0f1711de49ce108c541623a0af97c6c60b2f6e2b65229847ac843c2" +checksum = "94fb8275041c72129eb51b7d0322c29b8387a0386127718b096429201a5d6ece" dependencies = [ "alloc-no-stdlib", ] @@ -338,15 +294,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.62" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1485d4d2cc45e7b201ee3767015c96faa5904387c9d87c6efdd0fb511f12d305" - -[[package]] -name = "arc-swap" -version = "1.5.0" +version = "1.0.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5d78ce20460b82d3fa150275ed9d55e21064fc7951177baacf86a145c4a4b1f" +checksum = "08f9b8508dccb7687a1d6c4ce66b2b0ecef467c94667de27d8d7fe1f8d2a9cdc" [[package]] name = "arrayref" @@ -361,10 +311,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" [[package]] -name = "assert_matches" -version = "1.5.0" +name = "arrayvec" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9" +checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" [[package]] name = "async-mutex" @@ -375,17 +325,6 @@ dependencies = [ "event-listener", ] -[[package]] -name = "async-recursion" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7d78656ba01f1b93024b7c3a0467f1608e4be67d725749fdcd7d2c7678fd7a2" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "async-stream" version = "0.3.3" @@ -429,15 +368,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "autocfg" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dde43e75fd43e8a1bf86103336bc699aa8d17ad1be60c76c0bdfd4828e19b78" -dependencies = [ - "autocfg 1.1.0", -] - [[package]] name = "autocfg" version = "1.1.0" @@ -445,224 +375,432 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] -name = "awc" -version = "3.0.0" +name = "aws-config" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65c60c44fbf3c8cee365e86b97d706e513b733c4eeb16437b45b88d2fffe889a" -dependencies = [ - "actix-codec", - "actix-http", - "actix-rt", - "actix-service", - "actix-tls", - "actix-utils", - "ahash 0.7.6", - "base64 0.13.0", +checksum = "588c761aa9f0587106d77c6523b59b49532ebb6c048052fe878f9f8a3c830599" +dependencies = [ + "aws-http", + "aws-sdk-sso", + "aws-sdk-sts", + "aws-smithy-async", + "aws-smithy-client", + "aws-smithy-http", + "aws-smithy-http-tower", + "aws-smithy-json", + "aws-smithy-types", + "aws-types", "bytes", - "cfg-if 1.0.0", - "cookie", - "derive_more", - "futures-core", - "futures-util", - "h2", + "hex", "http", - "itoa", - "log", - "mime", - "openssl", - "percent-encoding", - "pin-project-lite", - "rand 0.8.5", - "serde", - "serde_json", - "serde_urlencoded", + "hyper", + "ring", "tokio", + "tower", + "tracing", + "zeroize", ] [[package]] -name = "backtrace" -version = "0.3.65" +name = "aws-endpoint" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11a17d453482a265fd5f8479f2a3f405566e6ca627837aaddb85af8b1ab8ef61" +checksum = "04619a4c0339675fdb7082a3c2a1799bf2b6398fbe0889d69a14f2bd130feb67" dependencies = [ - "addr2line", - "cc", - "cfg-if 1.0.0", - "libc", - "miniz_oxide", - "object", - "rustc-demangle", + "aws-smithy-http", + "aws-types", + "http", + "regex", + "tracing", ] [[package]] -name = "base64" -version = "0.11.0" +name = "aws-http" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7" +checksum = "d023c3e17c572f3c071699763ad5035ea6e94f3ecf5712c301355beef0c80893" +dependencies = [ + "aws-smithy-http", + "aws-smithy-types", + "aws-types", + "http", + "lazy_static", + "percent-encoding", + "tracing", +] [[package]] -name = "base64" +name = "aws-sdk-s3" version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" +checksum = "2e4421aa343a7eb324446d839c4744272190f396c787056f587f5258c1bc3f98" +dependencies = [ + "aws-endpoint", + "aws-http", + "aws-sig-auth", + "aws-sigv4", + "aws-smithy-async", + "aws-smithy-client", + "aws-smithy-eventstream", + "aws-smithy-http", + "aws-smithy-http-tower", + "aws-smithy-types", + "aws-smithy-xml", + "aws-types", + "bytes", + "http", + "md-5", + "tokio-stream", + "tower", +] [[package]] -name = "bigdecimal" -version = "0.1.0" +name = "aws-sdk-sso" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "460825c9e21708024d67c07057cd5560e5acdccac85de0de624a81d3de51bacb" -dependencies = [ - "num-bigint 0.2.6", - "num-integer", - "num-traits", +checksum = "06d3a467637b986708c9299a4031ea120680b43056ee9013f79aa8e949467fa8" +dependencies = [ + "aws-endpoint", + "aws-http", + "aws-sig-auth", + "aws-smithy-async", + "aws-smithy-client", + "aws-smithy-http", + "aws-smithy-http-tower", + "aws-smithy-json", + "aws-smithy-types", + "aws-types", + "bytes", + "http", + "tokio-stream", + "tower", ] [[package]] -name = "bincode" -version = "1.3.3" +name = "aws-sdk-sts" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" -dependencies = [ - "serde", +checksum = "9fa1ba5309db9d1c988c53a57eb80f6ccf9af4626b11068ba48e457fdab3aacf" +dependencies = [ + "aws-endpoint", + "aws-http", + "aws-sig-auth", + "aws-smithy-async", + "aws-smithy-client", + "aws-smithy-http", + "aws-smithy-http-tower", + "aws-smithy-query", + "aws-smithy-types", + "aws-smithy-xml", + "aws-types", + "bytes", + "http", + "tower", ] [[package]] -name = "bindgen" -version = "0.59.2" +name = "aws-sig-auth" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bd2a9a458e8f4304c52c43ebb0cfbd520289f8379a52e329a38afda99bf8eb8" +checksum = "1c9d556c7432b15b180c4d7015dfe16050ce86fd82602efb7aa415cd7929b4ea" dependencies = [ - "bitflags", - "cexpr", - "clang-sys", - "lazy_static", - "lazycell", - "peeking_take_while", - "proc-macro2", - "quote", - "regex", - "rustc-hash", - "shlex", + "aws-sigv4", + "aws-smithy-eventstream", + "aws-smithy-http", + "aws-types", + "http", + "tracing", ] [[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - -[[package]] -name = "bitmaps" -version = "2.1.0" +name = "aws-sigv4" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "031043d04099746d8db04daf1fa424b2bc8bd69d92b25962dcde24da39ab64a2" +checksum = "47f44f6f9aecc1ccbf3d410d6f00552046a4c808c320b51bdd72df0baa6cbbc1" dependencies = [ - "typenum", + "aws-smithy-eventstream", + "aws-smithy-http", + "bytes", + "form_urlencoded", + "hex", + "http", + "once_cell", + "percent-encoding", + "regex", + "ring", + "time 0.3.9", + "tracing", ] [[package]] -name = "blake2" -version = "0.9.2" +name = "aws-smithy-async" +version = "0.43.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a4e37d16930f5459780f5621038b6382b9bb37c19016f39fb6b5808d831f174" +checksum = "dd107a426047cff81691b598ce5b9488bf23d8b8fd803564c8aad4046521d069" dependencies = [ - "crypto-mac", - "digest 0.9.0", - "opaque-debug", + "futures-util", + "pin-project-lite", + "tokio", + "tokio-stream", ] [[package]] -name = "blake3" -version = "0.3.8" +name = "aws-smithy-client" +version = "0.43.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b64485778c4f16a6a5a9d335e80d449ac6c70cdd6a06d2af18a6f6f775a125b3" +checksum = "14afb75139d67d3e076afbdc25110d409573e941e69ce1434d7d85107a2886f4" dependencies = [ - "arrayref", - "arrayvec", - "cc", - "cfg-if 0.1.10", - "constant_time_eq", - "crypto-mac", - "digest 0.9.0", + "aws-smithy-async", + "aws-smithy-http", + "aws-smithy-http-tower", + "aws-smithy-types", + "bytes", + "fastrand", + "http", + "http-body", + "hyper", + "hyper-rustls", + "lazy_static", + "pin-project", + "pin-project-lite", + "tokio", + "tower", + "tracing", ] [[package]] -name = "block-buffer" -version = "0.9.0" +name = "aws-smithy-eventstream" +version = "0.43.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +checksum = "33b2f9543079950a3864a62fc8559a89572daab429e5777b5a1aa6c06378e51c" dependencies = [ - "block-padding", - "generic-array 0.14.5", + "aws-smithy-types", + "bytes", + "crc32fast", ] [[package]] -name = "block-buffer" -version = "0.10.2" +name = "aws-smithy-http" +version = "0.43.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bf7fe51849ea569fd452f37822f606a5cabb684dc918707a0193fd4664ff324" +checksum = "1976aaf680a01d5ca920cc5834bb808576e803845107907b991d6a441747098b" dependencies = [ - "generic-array 0.14.5", + "aws-smithy-eventstream", + "aws-smithy-types", + "bytes", + "bytes-utils", + "futures-core", + "http", + "http-body", + "hyper", + "once_cell", + "percent-encoding", + "pin-project", + "tokio", + "tokio-util", + "tracing", ] [[package]] -name = "block-padding" -version = "0.2.1" +name = "aws-smithy-http-tower" +version = "0.43.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" +checksum = "ba6a7a52b67bab2277e677e656970ed38e06b9f74e42c37a54f7f61550d3264d" +dependencies = [ + "aws-smithy-http", + "bytes", + "http", + "http-body", + "pin-project", + "tower", + "tracing", +] [[package]] -name = "borsh" -version = "0.7.2" +name = "aws-smithy-json" +version = "0.43.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b42b13fa9bf62be34702e5ee4526aff22530ae22fe34a0c4290d30d5e4e782e6" +checksum = "168c5afb872e8d11f086bfa0157833293d2cac0ab66176690a887ad1367dd4a7" dependencies = [ - "borsh-derive 0.7.2", + "aws-smithy-types", ] [[package]] -name = "borsh" -version = "0.8.2" +name = "aws-smithy-query" +version = "0.43.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09a7111f797cc721407885a323fb071636aee57f750b1a4ddc27397eba168a74" +checksum = "306dc0963ee08df39ba50969c20926718a3efa5061bb15e54082c1f74335bf86" dependencies = [ - "borsh-derive 0.8.2", - "hashbrown 0.9.1", + "aws-smithy-types", + "urlencoding", ] [[package]] -name = "borsh" -version = "0.9.3" +name = "aws-smithy-types" +version = "0.43.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15bf3650200d8bffa99015595e10f1fbd17de07abbc25bb067da79e769939bfa" +checksum = "72afd4e14f068f773d53123b28cabbfd44cfb1f69418f83fa16f2fca65959daf" dependencies = [ - "borsh-derive 0.9.3", - "hashbrown 0.11.2", + "itoa", + "num-integer", + "ryu", + "time 0.3.9", ] [[package]] -name = "borsh-derive" -version = "0.7.2" +name = "aws-smithy-xml" +version = "0.43.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6aaa45f8eec26e4bf71e7e5492cf53a91591af8f871f422d550e7cc43f6b927" +checksum = "b606d35369febb651b1911039731625a23102cf775bde10295a2cf9a722de55a" dependencies = [ - "borsh-derive-internal 0.7.2", - "borsh-schema-derive-internal 0.7.2", - "proc-macro2", - "syn", + "xmlparser", ] [[package]] -name = "borsh-derive" -version = "0.8.2" +name = "aws-types" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "307f3740906bac2c118a8122fe22681232b244f1369273e45f1156b45c43d2dd" +checksum = "23b500c108f8aa03ff2a401373abcc20e7752795ecd6fa6d4628e606d0d26a23" dependencies = [ - "borsh-derive-internal 0.8.2", - "borsh-schema-derive-internal 0.8.2", - "proc-macro-crate", - "proc-macro2", - "syn", + "aws-smithy-async", + "aws-smithy-client", + "aws-smithy-http", + "aws-smithy-types", + "http", + "rustc_version", + "tracing", + "zeroize", +] + +[[package]] +name = "base64" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7" + +[[package]] +name = "base64" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" + +[[package]] +name = "bigdecimal" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "460825c9e21708024d67c07057cd5560e5acdccac85de0de624a81d3de51bacb" +dependencies = [ + "num-bigint 0.2.6", + "num-integer", + "num-traits", +] + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitvec" +version = "0.20.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7774144344a4faa177370406a7ff5f1da24303817368584c6206c8303eb07848" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] + +[[package]] +name = "blake2" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a4e37d16930f5459780f5621038b6382b9bb37c19016f39fb6b5808d831f174" +dependencies = [ + "crypto-mac", + "digest 0.9.0", + "opaque-debug", +] + +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "block-padding", + "generic-array", +] + +[[package]] +name = "block-buffer" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf7fe51849ea569fd452f37822f606a5cabb684dc918707a0193fd4664ff324" +dependencies = [ + "generic-array", +] + +[[package]] +name = "block-padding" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" + +[[package]] +name = "borsh" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b42b13fa9bf62be34702e5ee4526aff22530ae22fe34a0c4290d30d5e4e782e6" +dependencies = [ + "borsh-derive 0.7.2", +] + +[[package]] +name = "borsh" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09a7111f797cc721407885a323fb071636aee57f750b1a4ddc27397eba168a74" +dependencies = [ + "borsh-derive 0.8.2", + "hashbrown 0.9.1", +] + +[[package]] +name = "borsh" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15bf3650200d8bffa99015595e10f1fbd17de07abbc25bb067da79e769939bfa" +dependencies = [ + "borsh-derive 0.9.3", + "hashbrown 0.11.2", +] + +[[package]] +name = "borsh-derive" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6aaa45f8eec26e4bf71e7e5492cf53a91591af8f871f422d550e7cc43f6b927" +dependencies = [ + "borsh-derive-internal 0.7.2", + "borsh-schema-derive-internal 0.7.2", + "proc-macro2", + "syn", +] + +[[package]] +name = "borsh-derive" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "307f3740906bac2c118a8122fe22681232b244f1369273e45f1156b45c43d2dd" +dependencies = [ + "borsh-derive-internal 0.8.2", + "borsh-schema-derive-internal 0.8.2", + "proc-macro-crate 0.1.5", + "proc-macro2", + "syn", ] [[package]] @@ -673,7 +811,7 @@ checksum = "6441c552f230375d18e3cc377677914d2ca2b0d36e52129fe15450a2dce46775" dependencies = [ "borsh-derive-internal 0.9.3", "borsh-schema-derive-internal 0.9.3", - "proc-macro-crate", + "proc-macro-crate 0.1.5", "proc-macro2", "syn", ] @@ -778,25 +916,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4a45a46ab1f2412e53d3a0ade76ffad2025804294569aae387231a0cd6e0899" [[package]] -name = "bytecheck" -version = "0.6.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a31f923c2db9513e4298b72df143e6e655a759b3d6a0966df18f81223fff54f" -dependencies = [ - "bytecheck_derive", - "ptr_meta", -] - -[[package]] -name = "bytecheck_derive" -version = "0.6.8" +name = "byte-slice-cast" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edb17c862a905d912174daa27ae002326fff56dc8b8ada50a0a5f0976cb174f0" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] +checksum = "87c5fdd0166095e1d463fc6cc01aa8ce547ad77a4e84d42eb6762b084e28067e" [[package]] name = "byteorder" @@ -806,37 +929,33 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "bytes" -version = "1.1.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8" +checksum = "dfb24e866b15a1af2a1b663f10c6b6b8f397a84aadb828f12e5b289ec23a3a3c" [[package]] -name = "bytesize" -version = "1.1.0" +name = "bytes-utils" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c58ec36aac5066d5ca17df51b3e70279f5670a72102f5752cb7e7c856adfc70" +checksum = "1934a3ef9cac8efde4966a92781e77713e1ba329f1d42e446c7d7eba340d8ef1" dependencies = [ - "serde", + "bytes", + "either", ] [[package]] -name = "bytestring" -version = "1.0.0" +name = "bytesize" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90706ba19e97b90786e19dc0d5e2abd80008d99d4c0c5d1ad0b5e72cec7c494d" -dependencies = [ - "bytes", -] +checksum = "6c58ec36aac5066d5ca17df51b3e70279f5670a72102f5752cb7e7c856adfc70" [[package]] -name = "bzip2-sys" -version = "0.1.11+1.0.8" +name = "bytestring" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "736a955f3fa7875102d57c82b8cac37ec45224a07fd32d58f9f7a186b6cd4cdc" +checksum = "f7f83e57d9154148e355404702e2694463241880b939570d7c97c014da7a69a1" dependencies = [ - "cc", - "libc", - "pkg-config", + "bytes", ] [[package]] @@ -871,7 +990,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4230b8d9f5db741004bfaef172c5b2dbf0eb94f105204cc6147a220080daaa85" dependencies = [ "cached_proc_macro_types", - "darling", + "darling 0.13.4", "quote", "syn", ] @@ -891,15 +1010,6 @@ dependencies = [ "jobserver", ] -[[package]] -name = "cexpr" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" -dependencies = [ - "nom", -] - [[package]] name = "cfg-if" version = "0.1.10" @@ -932,18 +1042,28 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "12f8e7987cbd042a63249497f41aed09f8e65add917ea6566effbc56578d6801" dependencies = [ - "generic-array 0.14.5", + "generic-array", ] [[package]] -name = "clang-sys" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cc00842eed744b858222c4c9faf7243aafc6d33f92f96935263ef4d8a41ce21" +name = "circulating-supply" +version = "0.1.0" dependencies = [ - "glob", - "libc", - "libloading", + "actix", + "anyhow", + "base64 0.11.0", + "bigdecimal", + "chrono", + "dotenv", + "explorer-database", + "near-indexer-primitives", + "near-jsonrpc-client", + "near-jsonrpc-primitives", + "near-sdk", + "tokio", + "tracing", + "tracing-subscriber", + "uint 0.8.5", ] [[package]] @@ -985,42 +1105,6 @@ dependencies = [ "os_str_bytes", ] -[[package]] -name = "cloudabi" -version = "0.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" -dependencies = [ - "bitflags", -] - -[[package]] -name = "conqueue" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eac4306c796b95d3964b94fa65018a57daee08b45a54b86a4f64910426427b66" - -[[package]] -name = "console" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a28b32d32ca44b70c3e4acd7db1babf555fa026e385fb95f18028f88848b3c31" -dependencies = [ - "encode_unicode", - "libc", - "once_cell", - "regex", - "terminal_size", - "unicode-width", - "winapi", -] - -[[package]] -name = "constant_time_eq" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" - [[package]] name = "convert_case" version = "0.4.0" @@ -1029,9 +1113,9 @@ checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" [[package]] name = "cookie" -version = "0.16.0" +version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94d4706de1b0fa5b132270cddffa8585166037822e260a944fe161acd137ca05" +checksum = "344adc371239ef32293cb1c4fe519592fcf21206c79c02854320afcdf3ab4917" dependencies = [ "percent-encoding", "time 0.3.9", @@ -1054,25 +1138,6 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" -[[package]] -name = "cpp_demangle" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eeaa953eaad386a53111e47172c2fedba671e5684c8dd601a5f474f4f118710f" -dependencies = [ - "cfg-if 1.0.0", -] - -[[package]] -name = "cpu-time" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9e393a7668fe1fad3075085b86c781883000b4ede868f43627b34a87c8b7ded" -dependencies = [ - "libc", - "winapi", -] - [[package]] name = "cpufeatures" version = "0.2.2" @@ -1083,255 +1148,183 @@ dependencies = [ ] [[package]] -name = "cranelift-bforest" -version = "0.84.0" +name = "crc32fast" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fa7c3188913c2d11a361e0431e135742372a2709a99b103e79758e11a0a797e" +checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" dependencies = [ - "cranelift-entity", + "cfg-if 1.0.0", ] [[package]] -name = "cranelift-codegen" -version = "0.84.0" +name = "crossbeam-channel" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29285f70fd396a8f64455a15a6e1d390322e4a5f5186de513141313211b0a23e" +checksum = "5aaa7bd5fb665c6864b5f963dd9097905c54125909c7aa94c9e18507cdbe6c53" dependencies = [ - "cranelift-bforest", - "cranelift-codegen-meta", - "cranelift-codegen-shared", - "cranelift-entity", - "gimli", - "log", - "regalloc2", - "smallvec", - "target-lexicon 0.12.3", + "cfg-if 1.0.0", + "crossbeam-utils", ] [[package]] -name = "cranelift-codegen-meta" -version = "0.84.0" +name = "crossbeam-utils" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "057eac2f202ec95aebfd8d495e88560ac085f6a415b3c6c28529dc5eb116a141" +checksum = "0bf124c720b7686e3c2663cf54062ab0f68a88af2fb6a030e87e30bf721fcb38" dependencies = [ - "cranelift-codegen-shared", + "cfg-if 1.0.0", + "lazy_static", ] [[package]] -name = "cranelift-codegen-shared" -version = "0.84.0" +name = "crunchy" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75d93869efd18874a9341cfd8ad66bcb08164e86357a694a0e939d29e87410b9" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" [[package]] -name = "cranelift-entity" -version = "0.84.0" +name = "crypto-common" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e34bd7a1fefa902c90a921b36323f17a398b788fa56a75f07a29d83b6e28808" +checksum = "57952ca27b5e3606ff4dd79b0020231aaf9d6aa76dc05fd30137538c50bd3ce8" dependencies = [ - "serde", + "generic-array", + "typenum", ] [[package]] -name = "cranelift-frontend" -version = "0.84.0" +name = "crypto-mac" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "457018dd2d6ee300953978f63215b5edf3ae42dbdf8c7c038972f10394599f72" +checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" dependencies = [ - "cranelift-codegen", - "log", - "smallvec", - "target-lexicon 0.12.3", + "generic-array", + "subtle", ] [[package]] -name = "cranelift-native" -version = "0.84.0" +name = "ct-logs" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bba027cc41bf1d0eee2ddf16caba2ee1be682d0214520fff0129d2c6557fda89" +checksum = "c1a816186fa68d9e426e3cb4ae4dff1fcd8e4a2c34b781bf7a822574a0d0aac8" dependencies = [ - "cranelift-codegen", - "libc", - "target-lexicon 0.12.3", + "sct", ] [[package]] -name = "cranelift-wasm" -version = "0.84.0" +name = "curve25519-dalek" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b17639ced10b9916c9be120d38c872ea4f9888aa09248568b10056ef0559bfa" +checksum = "0b9fdf9972b2bd6af2d913799d9ebc165ea4d2e65878e329d9c6b372c4491b61" dependencies = [ - "cranelift-codegen", - "cranelift-entity", - "cranelift-frontend", - "itertools", - "log", - "smallvec", - "wasmparser 0.84.0", - "wasmtime-types", + "byteorder", + "digest 0.9.0", + "rand_core 0.5.1", + "subtle", + "zeroize", ] [[package]] -name = "crc32fast" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" -dependencies = [ - "cfg-if 1.0.0", -] - -[[package]] -name = "crossbeam" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2801af0d36612ae591caa9568261fddce32ce6e08a7275ea334a06a4ad021a2c" -dependencies = [ - "cfg-if 1.0.0", - "crossbeam-channel", - "crossbeam-deque", - "crossbeam-epoch", - "crossbeam-queue", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-channel" -version = "0.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aaa7bd5fb665c6864b5f963dd9097905c54125909c7aa94c9e18507cdbe6c53" -dependencies = [ - "cfg-if 1.0.0", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-deque" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e" -dependencies = [ - "cfg-if 1.0.0", - "crossbeam-epoch", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-epoch" -version = "0.9.8" +name = "darling" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1145cf131a2c6ba0615079ab6a638f7e1973ac9c2634fcbeaaad6114246efe8c" +checksum = "a01d95850c592940db9b8194bc39f4bc0e89dee5c4265e4b1807c34a9aba453c" dependencies = [ - "autocfg 1.1.0", - "cfg-if 1.0.0", - "crossbeam-utils", - "lazy_static", - "memoffset", - "scopeguard", + "darling_core 0.13.4", + "darling_macro 0.13.4", ] [[package]] -name = "crossbeam-queue" -version = "0.3.6" +name = "darling" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cd42583b04998a5363558e5f9291ee5a5ff6b49944332103f251e7479a82aa7" +checksum = "4529658bdda7fd6769b8614be250cdcfc3aeb0ee72fe66f9e41e5e5eb73eac02" dependencies = [ - "cfg-if 1.0.0", - "crossbeam-utils", + "darling_core 0.14.1", + "darling_macro 0.14.1", ] [[package]] -name = "crossbeam-utils" -version = "0.8.8" +name = "darling_core" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bf124c720b7686e3c2663cf54062ab0f68a88af2fb6a030e87e30bf721fcb38" +checksum = "859d65a907b6852c9361e3185c862aae7fafd2887876799fa55f5f99dc40d610" dependencies = [ - "cfg-if 1.0.0", - "lazy_static", + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn", ] [[package]] -name = "crunchy" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" - -[[package]] -name = "crypto-common" -version = "0.1.3" +name = "darling_core" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57952ca27b5e3606ff4dd79b0020231aaf9d6aa76dc05fd30137538c50bd3ce8" +checksum = "649c91bc01e8b1eac09fb91e8dbc7d517684ca6be8ebc75bb9cafc894f9fdb6f" dependencies = [ - "generic-array 0.14.5", - "typenum", + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn", ] [[package]] -name = "crypto-mac" -version = "0.8.0" +name = "darling_macro" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" +checksum = "9c972679f83bdf9c42bd905396b6c3588a843a17f0f16dfcfa3e2c5d57441835" dependencies = [ - "generic-array 0.14.5", - "subtle", + "darling_core 0.13.4", + "quote", + "syn", ] [[package]] -name = "curve25519-dalek" -version = "3.2.1" +name = "darling_macro" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90f9d052967f590a76e62eb387bd0bbb1b000182c3cefe5364db6b7211651bc0" +checksum = "ddfc69c5bfcbd2fc09a0f38451d2daf0e372e367986a83906d1b0dbc88134fb5" dependencies = [ - "byteorder", - "digest 0.9.0", - "rand_core 0.5.1", - "subtle", - "zeroize", + "darling_core 0.14.1", + "quote", + "syn", ] [[package]] -name = "darling" -version = "0.13.4" +name = "derive_builder" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a01d95850c592940db9b8194bc39f4bc0e89dee5c4265e4b1807c34a9aba453c" +checksum = "d07adf7be193b71cc36b193d0f5fe60b918a3a9db4dad0449f57bcfd519704a3" dependencies = [ - "darling_core", - "darling_macro", + "derive_builder_macro", ] [[package]] -name = "darling_core" -version = "0.13.4" +name = "derive_builder_core" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "859d65a907b6852c9361e3185c862aae7fafd2887876799fa55f5f99dc40d610" +checksum = "1f91d4cfa921f1c05904dc3c57b4a32c38aed3340cce209f3a6fd1478babafc4" dependencies = [ - "fnv", - "ident_case", + "darling 0.14.1", "proc-macro2", "quote", - "strsim", "syn", ] [[package]] -name = "darling_macro" -version = "0.13.4" +name = "derive_builder_macro" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c972679f83bdf9c42bd905396b6c3588a843a17f0f16dfcfa3e2c5d57441835" +checksum = "8f0314b72bed045f3a68671b3c86328386762c93f82d98c65c3cb5e5f573dd68" dependencies = [ - "darling_core", - "quote", + "derive_builder_core", "syn", ] -[[package]] -name = "delay-detector" -version = "0.0.0" -source = "git+https://github.com/near/nearcore?rev=267e36e39fb5bb29c1df23c73afbcaa750ce96b1#267e36e39fb5bb29c1df23c73afbcaa750ce96b1" -dependencies = [ - "cpu-time", - "tracing", -] - [[package]] name = "derive_more" version = "0.99.17" @@ -1341,7 +1334,7 @@ dependencies = [ "convert_case", "proc-macro2", "quote", - "rustc_version 0.4.0", + "rustc_version", "syn", ] @@ -1385,22 +1378,13 @@ dependencies = [ "syn", ] -[[package]] -name = "digest" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" -dependencies = [ - "generic-array 0.12.4", -] - [[package]] name = "digest" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" dependencies = [ - "generic-array 0.14.5", + "generic-array", ] [[package]] @@ -1413,58 +1397,12 @@ dependencies = [ "crypto-common", ] -[[package]] -name = "dirs" -version = "3.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30baa043103c9d0c2a57cf537cc2f35623889dc0d405e6c3cccfadbc81c71309" -dependencies = [ - "dirs-sys", -] - -[[package]] -name = "dirs-sys" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" -dependencies = [ - "libc", - "redox_users", - "winapi", -] - [[package]] name = "dotenv" version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f" -[[package]] -name = "dynasm" -version = "1.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "add9a102807b524ec050363f09e06f1504214b0e1c7797f64261c891022dce8b" -dependencies = [ - "bitflags", - "byteorder", - "lazy_static", - "proc-macro-error", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "dynasmrt" -version = "1.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64fba5a42bd76a17cad4bfa00de168ee1cbfa06a5e8ce992ae880218c05641a9" -dependencies = [ - "byteorder", - "dynasm", - "memmap2", -] - [[package]] name = "easy-ext" version = "0.2.9" @@ -1500,21 +1438,6 @@ version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" -[[package]] -name = "elastic-array" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d63720ea2bc2e1b79f7aa044d9dc0b825f9ccb6930b32120f8fb9e873aa84bc" -dependencies = [ - "heapsize", -] - -[[package]] -name = "encode_unicode" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" - [[package]] name = "encoding_rs" version = "0.8.31" @@ -1525,79 +1448,34 @@ dependencies = [ ] [[package]] -name = "enum-map" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0348b2a57c82f98b9dbd8098b1abb2416f221823d3e50cbe24eaebdd16896826" -dependencies = [ - "enum-map-derive", -] - -[[package]] -name = "enum-map-derive" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a63b7a0ddec6f38dcec5e36257750b7a8fcaf4227e12ceb306e341d63634da05" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "enumset" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4799cdb24d48f1f8a7a98d06b7fde65a85a2d1e42b25a889f5406aa1fbefe074" -dependencies = [ - "enumset_derive", -] - -[[package]] -name = "enumset_derive" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea83a3fbdc1d999ccfbcbee717eab36f8edf2d71693a23ce0d7cca19e085304c" -dependencies = [ - "darling", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "errno" -version = "0.2.8" +name = "event-listener" +version = "2.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" -dependencies = [ - "errno-dragonfly", - "libc", - "winapi", -] +checksum = "77f3309417938f28bf8228fcff79a4a37103981e3e186d2ccd19c74b38f4eb71" [[package]] -name = "errno-dragonfly" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +name = "explorer-database" +version = "0.1.0" dependencies = [ - "cc", - "libc", + "actix-diesel", + "anyhow", + "base64 0.11.0", + "bigdecimal", + "cached", + "diesel", + "diesel-derive-enum", + "futures", + "hex", + "near-crypto", + "near-indexer-primitives", + "near-primitives", + "num-traits", + "serde", + "serde_json", + "tokio", + "tracing", ] -[[package]] -name = "event-listener" -version = "2.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" - -[[package]] -name = "fallible-iterator" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" - [[package]] name = "fastrand" version = "1.7.0" @@ -1607,36 +1485,25 @@ dependencies = [ "instant", ] -[[package]] -name = "firestorm" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d3d6188b8804df28032815ea256b6955c9625c24da7525f387a7af02fbb8f01" - [[package]] name = "fixed-hash" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cfcf0ed7fe52a17a03854ec54a9f76d6d84508d1c0e66bc1793301c73fc8493c" dependencies = [ + "byteorder", + "rand 0.8.5", + "rustc-hex", "static_assertions", ] -[[package]] -name = "fixedbitset" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" - [[package]] name = "flate2" -version = "1.0.23" +version = "1.0.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b39522e96686d38f4bc984b9198e3a0613264abaebaff2c5c918bfa6b6da09af" +checksum = "a8a2db397cb1c8772f31494cb8917e48cd1e64f0fa7efac59fbd741a0a8ce841" dependencies = [ - "cfg-if 1.0.0", "crc32fast", - "libc", "miniz_oxide", ] @@ -1672,26 +1539,16 @@ dependencies = [ ] [[package]] -name = "fs2" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9564fc758e15025b46aa6643b1b77d047d1a56a1aea6e01002ac0c7026876213" -dependencies = [ - "libc", - "winapi", -] - -[[package]] -name = "fs_extra" -version = "1.2.0" +name = "funty" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2022715d62ab30faffd124d40b76f4134a550a87792276512b18d63272333394" +checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7" [[package]] name = "futures" -version = "0.3.21" +version = "0.3.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f73fe65f54d1e12b726f517d3e2135ca3125a437b6d998caf1962961f7172d9e" +checksum = "ab30e97ab6aacfe635fad58f22c2bb06c8b685f7421eb1e064a729e2a5f481fa" dependencies = [ "futures-channel", "futures-core", @@ -1704,9 +1561,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.21" +version = "0.3.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3083ce4b914124575708913bca19bfe887522d6e2e6d0952943f5eac4a74010" +checksum = "2bfc52cbddcfd745bf1740338492bb0bd83d76c67b445f91c5fb29fae29ecaa1" dependencies = [ "futures-core", "futures-sink", @@ -1714,15 +1571,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.21" +version = "0.3.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c09fd04b7e4073ac7156a9539b57a484a8ea920f79c7c675d05d289ab6110d3" +checksum = "d2acedae88d38235936c3922476b10fced7b2b68136f5e3c03c2d5be348a1115" [[package]] name = "futures-executor" -version = "0.3.21" +version = "0.3.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9420b90cfa29e327d0429f19be13e7ddb68fa1cccb09d65e5706b8c7a749b8a6" +checksum = "1d11aa21b5b587a64682c0094c2bdd4df0076c5324961a40cc3abd7f37930528" dependencies = [ "futures-core", "futures-task", @@ -1731,15 +1588,15 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.21" +version = "0.3.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc4045962a5a5e935ee2fdedaa4e08284547402885ab326734432bed5d12966b" +checksum = "93a66fc6d035a26a3ae255a6d2bca35eda63ae4c5512bef54449113f7a1228e5" [[package]] name = "futures-macro" -version = "0.3.21" +version = "0.3.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33c1e13800337f4d4d7a316bf45a567dbcb6ffe087f16424852d97e97a91f512" +checksum = "0db9cce532b0eae2ccf2766ab246f114b56b9cf6d445e00c2549fbc100ca045d" dependencies = [ "proc-macro2", "quote", @@ -1748,21 +1605,21 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.21" +version = "0.3.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21163e139fa306126e6eedaf49ecdb4588f939600f0b1e770f4205ee4b7fa868" +checksum = "ca0bae1fe9752cf7fd9b0064c674ae63f97b37bc714d745cbde0afb7ec4e6765" [[package]] name = "futures-task" -version = "0.3.21" +version = "0.3.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57c66a976bf5909d801bbef33416c41372779507e7a6b3a5e25e4749c58f776a" +checksum = "842fc63b931f4056a24d59de13fb1272134ce261816e063e634ad0c15cdc5306" [[package]] name = "futures-util" -version = "0.3.21" +version = "0.3.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8b7abd5d659d9b90c8cba917f6ec750a74e2dc23902ef9cd4cc8c8b22e6036a" +checksum = "f0828a5471e340229c11c77ca80017937ce3c58cb788a17e5f1c2d5c485a9577" dependencies = [ "futures-channel", "futures-core", @@ -1777,31 +1634,13 @@ dependencies = [ ] [[package]] -name = "fxhash" -version = "0.2.1" +name = "generic-array" +version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" +checksum = "fd48d33ec7f05fbfa152300fdad764757cbded343c1aa1cff2fbaf4134851803" dependencies = [ - "byteorder", -] - -[[package]] -name = "generic-array" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" -dependencies = [ - "typenum", -] - -[[package]] -name = "generic-array" -version = "0.14.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd48d33ec7f05fbfa152300fdad764757cbded343c1aa1cff2fbaf4134851803" -dependencies = [ - "typenum", - "version_check", + "typenum", + "version_check", ] [[package]] @@ -1826,23 +1665,6 @@ dependencies = [ "wasi 0.10.0+wasi-snapshot-preview1", ] -[[package]] -name = "gimli" -version = "0.26.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78cc372d058dcf6d5ecd98510e7fbc9e5aec4d21de70f65fea8fecebcd881bd4" -dependencies = [ - "fallible-iterator", - "indexmap", - "stable_deref_trait", -] - -[[package]] -name = "glob" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" - [[package]] name = "h2" version = "0.3.13" @@ -1858,7 +1680,7 @@ dependencies = [ "indexmap", "slab", "tokio", - "tokio-util 0.7.2", + "tokio-util", "tracing", ] @@ -1880,24 +1702,6 @@ dependencies = [ "ahash 0.7.6", ] -[[package]] -name = "hashbrown" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db0d4cf898abf0081f964436dc980e96670a0f36863e4b83aaacdb65c9d7ccc3" -dependencies = [ - "ahash 0.7.6", -] - -[[package]] -name = "heapsize" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1679e6ea370dee694f91f1dc469bf94cf8f52051d147aec3e1f9497c6fc22461" -dependencies = [ - "winapi", -] - [[package]] name = "heck" version = "0.3.3" @@ -1987,15 +1791,20 @@ dependencies = [ ] [[package]] -name = "hyper-timeout" -version = "0.4.1" +name = "hyper-rustls" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1" +checksum = "5f9f7a97316d44c0af9b0301e65010573a853a9fc97046d7331d7f6bc0fd5a64" dependencies = [ + "ct-logs", + "futures-util", "hyper", - "pin-project-lite", + "log", + "rustls", + "rustls-native-certs", "tokio", - "tokio-io-timeout", + "tokio-rustls", + "webpki", ] [[package]] @@ -2029,54 +1838,54 @@ dependencies = [ ] [[package]] -name = "im" -version = "15.1.0" +name = "impl-codec" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0acd33ff0285af998aaf9b57342af478078f53492322fafc47450e09397e0e9" +checksum = "161ebdfec3c8e3b52bf61c4f3550a1eea4f9579d10dc1b936f3171ebdcd6c443" dependencies = [ - "bitmaps", - "rand_core 0.6.3", - "rand_xoshiro", - "sized-chunks", - "typenum", - "version_check", + "parity-scale-codec", +] + +[[package]] +name = "impl-trait-for-tuples" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" +dependencies = [ + "proc-macro2", + "quote", + "syn", ] [[package]] name = "indexer-explorer" -version = "0.10.31" +version = "0.11.0" dependencies = [ "actix", - "actix-diesel", "actix-rt", + "actix-web", "anyhow", - "base64 0.11.0", - "bigdecimal", + "aws-sdk-s3", + "aws-types", "borsh 0.7.2", "cached", "chrono", "clap", - "diesel", - "diesel-derive-enum", "dotenv", + "explorer-database", "futures", - "hex", "itertools", - "near-client", - "near-crypto", - "near-indexer", - "near-o11y", + "lazy_static", + "near-jsonrpc-client", + "near-lake-framework", "near-sdk", - "num-traits", - "once_cell", "openssl-probe", + "prometheus", "r2d2", - "serde", - "serde_json", "tokio", "tokio-stream", "tracing", - "tracing-subscriber 0.2.25", + "tracing-subscriber", "uint 0.8.5", ] @@ -2086,21 +1895,8 @@ version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0f647032dfaa1f8b6dc29bd3edb7bbef4861b8b8007ebb118d6db284fd59f6ee" dependencies = [ - "autocfg 1.1.0", + "autocfg", "hashbrown 0.11.2", - "serde", -] - -[[package]] -name = "indicatif" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7baab56125e25686df467fe470785512329883aab42696d661247aca2a2896e4" -dependencies = [ - "console", - "lazy_static", - "number_prefix", - "regex", ] [[package]] @@ -2113,10 +1909,10 @@ dependencies = [ ] [[package]] -name = "io-lifetimes" -version = "0.5.3" +name = "ipnet" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec58677acfea8a15352d42fc87d11d63596ade9239e0a7c9352914417515dbe6" +checksum = "879d54834c8c76457ef4293a689b2a8c59b076067ad77b15efafbb05f92a592b" [[package]] name = "itertools" @@ -2135,9 +1931,9 @@ checksum = "112c678d4050afce233f4f2852bb2eb519230b3cf12f33585275537d7e41578d" [[package]] name = "jobserver" -version = "0.1.24" +version = "0.1.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af25a77299a7f711a01975c35a6a424eb6862092cc2d6c72c4ed6cbc56dfc1fa" +checksum = "068b1ee6743e4d11fb9c6a1e6064b3693a1b600e7f5f5988047d98b3dc9fb90b" dependencies = [ "libc", ] @@ -2168,21 +1964,6 @@ name = "lazy_static" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" -dependencies = [ - "spin", -] - -[[package]] -name = "lazycell" -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" @@ -2190,55 +1971,6 @@ version = "0.2.125" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5916d2ae698f6de9bfb891ad7a8d65c09d232dc58cc4ac433c7da3b2fd84bc2b" -[[package]] -name = "libloading" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efbc0f03f9a775e9f6aed295c6a1ba2253c5757a9e03d55c6caa46a681abcddd" -dependencies = [ - "cfg-if 1.0.0", - "winapi", -] - -[[package]] -name = "librocksdb-sys" -version = "0.6.1+6.28.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81bc587013734dadb7cf23468e531aa120788b87243648be42e2d3a072186291" -dependencies = [ - "bindgen", - "bzip2-sys", - "cc", - "glob", - "libc", - "libz-sys", - "tikv-jemalloc-sys", - "zstd-sys", -] - -[[package]] -name = "libz-sys" -version = "1.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92e7e15d7610cce1d9752e137625f14e61a28cd45929b6e12e47b50fe154ee2e" -dependencies = [ - "cc", - "pkg-config", - "vcpkg", -] - -[[package]] -name = "linked-hash-map" -version = "0.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3" - -[[package]] -name = "linux-raw-sys" -version = "0.0.42" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5284f00d480e1c39af34e72f8ad60b94f47007e3481cd3b731c1d67190ddc7b7" - [[package]] name = "local-channel" version = "0.1.3" @@ -2257,24 +1989,14 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e34f76eb3611940e0e7d53a9aaa4e6a3151f69541a282fd0dad5571420c53ff1" -[[package]] -name = "lock_api" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4da24a77a3d8a6d4862d95f72e6fdb9c09a643ecdb402d754004a557f2bec75" -dependencies = [ - "scopeguard", -] - [[package]] name = "lock_api" version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "327fa5b6a6940e4699ec49a9beae1ea4845c6bab9314e4f84ac68742139d8c53" dependencies = [ - "autocfg 1.1.0", + "autocfg", "scopeguard", - "serde", ] [[package]] @@ -2286,55 +2008,6 @@ dependencies = [ "cfg-if 1.0.0", ] -[[package]] -name = "loupe" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b6a72dfa44fe15b5e76b94307eeb2ff995a8c5b283b55008940c02e0c5b634d" -dependencies = [ - "loupe-derive", - "rustversion", -] - -[[package]] -name = "loupe-derive" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0fbfc88337168279f2e9ae06e157cfed4efd3316e14dc96ed074d4f2e6c5952" -dependencies = [ - "quote", - "syn", -] - -[[package]] -name = "lru" -version = "0.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32613e41de4c47ab04970c348ca7ae7382cf116625755af070b008a15516a889" -dependencies = [ - "hashbrown 0.11.2", -] - -[[package]] -name = "lzma-sys" -version = "0.1.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdb4b7c3eddad11d3af9e86c487607d2d2442d185d848575365c4856ba96d619" -dependencies = [ - "cc", - "libc", - "pkg-config", -] - -[[package]] -name = "mach" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b823e83b2affd8f40a9ee8c29dbc56404c1e34cd2710921f2801e2cf29527afa" -dependencies = [ - "libc", -] - [[package]] name = "matchers" version = "0.0.1" @@ -2344,15 +2017,6 @@ dependencies = [ "regex-automata", ] -[[package]] -name = "matchers" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" -dependencies = [ - "regex-automata", -] - [[package]] name = "matches" version = "0.1.9" @@ -2360,38 +2024,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f" [[package]] -name = "memchr" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" - -[[package]] -name = "memmap" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6585fd95e7bb50d6cc31e20d4cf9afb4e2ba16c5846fc76793f11218da9c475b" -dependencies = [ - "libc", - "winapi", -] - -[[package]] -name = "memmap2" -version = "0.5.3" +name = "md-5" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "057a3db23999c867821a7a59feb06a578fcb03685e983dff90daf9e7d24ac08f" +checksum = "658646b21e0b72f7866c7038ab086d3d5e1cd6271f060fd37defb241949d0582" dependencies = [ - "libc", + "digest 0.10.3", ] [[package]] -name = "memoffset" -version = "0.6.5" +name = "memchr" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" -dependencies = [ - "autocfg 1.1.0", -] +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" [[package]] name = "memory_units" @@ -2405,17 +2050,11 @@ version = "0.3.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" -[[package]] -name = "minimal-lexical" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" - [[package]] name = "miniz_oxide" -version = "0.5.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2b29bd4bc3f33391105ebee3589c19197c4271e3e5a9ec9bfe8127eeff8f082" +checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa" dependencies = [ "adler", ] @@ -2432,18 +2071,6 @@ dependencies = [ "windows-sys", ] -[[package]] -name = "more-asserts" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7843ec2de400bcbc6a6328c958dc38e5359da6e93e72e37bc5246bf1ae776389" - -[[package]] -name = "multimap" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a" - [[package]] name = "native-tls" version = "0.2.10" @@ -2464,58 +2091,19 @@ dependencies = [ [[package]] name = "near-account-id" -version = "0.0.0" -source = "git+https://github.com/near/nearcore?rev=267e36e39fb5bb29c1df23c73afbcaa750ce96b1#267e36e39fb5bb29c1df23c73afbcaa750ce96b1" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71d258582a1878e6db67400b0504a5099db85718d22c2e07f747fe1706ae7150" dependencies = [ "borsh 0.9.3", "serde", ] -[[package]] -name = "near-cache" -version = "0.0.0" -source = "git+https://github.com/near/nearcore?rev=267e36e39fb5bb29c1df23c73afbcaa750ce96b1#267e36e39fb5bb29c1df23c73afbcaa750ce96b1" -dependencies = [ - "lru", -] - -[[package]] -name = "near-chain" -version = "0.0.0" -source = "git+https://github.com/near/nearcore?rev=267e36e39fb5bb29c1df23c73afbcaa750ce96b1#267e36e39fb5bb29c1df23c73afbcaa750ce96b1" -dependencies = [ - "actix", - "ansi_term", - "borsh 0.9.3", - "chrono", - "crossbeam-channel", - "delay-detector", - "enum-map", - "itertools", - "lru", - "near-cache", - "near-chain-configs", - "near-chain-primitives", - "near-client-primitives", - "near-crypto", - "near-epoch-manager", - "near-o11y", - "near-pool", - "near-primitives", - "near-store", - "num-rational", - "once_cell", - "rand 0.7.3", - "rayon", - "strum", - "thiserror", - "tracing", -] - [[package]] name = "near-chain-configs" -version = "0.0.0" -source = "git+https://github.com/near/nearcore?rev=267e36e39fb5bb29c1df23c73afbcaa750ce96b1#267e36e39fb5bb29c1df23c73afbcaa750ce96b1" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3632a1c691603cb32dd9944c95d8eadbf2c09f45abd95350ea6848c649036a0b" dependencies = [ "anyhow", "chrono", @@ -2532,8 +2120,9 @@ dependencies = [ [[package]] name = "near-chain-primitives" -version = "0.0.0" -source = "git+https://github.com/near/nearcore?rev=267e36e39fb5bb29c1df23c73afbcaa750ce96b1#267e36e39fb5bb29c1df23c73afbcaa750ce96b1" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a734353027698b21633a49d478e564c61ae0171c32f6912bb8844add15d72ebe" dependencies = [ "chrono", "near-crypto", @@ -2543,94 +2132,29 @@ dependencies = [ ] [[package]] -name = "near-chunks" -version = "0.0.0" -source = "git+https://github.com/near/nearcore?rev=267e36e39fb5bb29c1df23c73afbcaa750ce96b1#267e36e39fb5bb29c1df23c73afbcaa750ce96b1" +name = "near-chunks-primitives" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c17f6f22f1ab710731dfba4101f12a99cac120d6af80b99899bd335bb8971477" +dependencies = [ + "near-chain-primitives", + "near-primitives", +] + +[[package]] +name = "near-client-primitives" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1065d86012eeea838661434549f33bb6267c9950fd2aadd2af617fe773def38" dependencies = [ "actix", - "borsh 0.9.3", "chrono", - "futures", - "lru", - "near-chain", + "near-chain-configs", + "near-chain-primitives", "near-chunks-primitives", "near-crypto", - "near-network", "near-network-primitives", - "near-o11y", - "near-pool", "near-primitives", - "near-store", - "once_cell", - "rand 0.7.3", - "reed-solomon-erasure", - "tracing", -] - -[[package]] -name = "near-chunks-primitives" -version = "0.0.0" -source = "git+https://github.com/near/nearcore?rev=267e36e39fb5bb29c1df23c73afbcaa750ce96b1#267e36e39fb5bb29c1df23c73afbcaa750ce96b1" -dependencies = [ - "near-chain-primitives", - "near-primitives", -] - -[[package]] -name = "near-client" -version = "0.0.0" -source = "git+https://github.com/near/nearcore?rev=267e36e39fb5bb29c1df23c73afbcaa750ce96b1#267e36e39fb5bb29c1df23c73afbcaa750ce96b1" -dependencies = [ - "actix", - "actix-rt", - "ansi_term", - "borsh 0.9.3", - "chrono", - "delay-detector", - "futures", - "itertools", - "lru", - "near-chain", - "near-chain-configs", - "near-chain-primitives", - "near-chunks", - "near-client-primitives", - "near-crypto", - "near-network", - "near-network-primitives", - "near-o11y", - "near-performance-metrics", - "near-performance-metrics-macros", - "near-pool", - "near-primitives", - "near-store", - "near-telemetry", - "num-rational", - "once_cell", - "rand 0.7.3", - "reed-solomon-erasure", - "serde_json", - "strum", - "sysinfo", - "thiserror", - "tokio", - "tracing", -] - -[[package]] -name = "near-client-primitives" -version = "0.0.0" -source = "git+https://github.com/near/nearcore?rev=267e36e39fb5bb29c1df23c73afbcaa750ce96b1#267e36e39fb5bb29c1df23c73afbcaa750ce96b1" -dependencies = [ - "actix", - "chrono", - "near-chain-configs", - "near-chain-primitives", - "near-chunks-primitives", - "near-crypto", - "near-network-primitives", - "near-primitives", - "once_cell", "serde", "serde_json", "strum", @@ -2639,8 +2163,9 @@ dependencies = [ [[package]] name = "near-crypto" -version = "0.0.0" -source = "git+https://github.com/near/nearcore?rev=267e36e39fb5bb29c1df23c73afbcaa750ce96b1#267e36e39fb5bb29c1df23c73afbcaa750ce96b1" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e75673d69fd7365508f3d32483669fe45b03bfb34e4d9363e90adae9dfb416c" dependencies = [ "arrayref", "blake2", @@ -2652,192 +2177,90 @@ dependencies = [ "ed25519-dalek", "near-account-id", "once_cell", + "parity-secp256k1", "primitive-types", "rand 0.7.3", - "secp256k1", + "rand_core 0.5.1", "serde", "serde_json", "subtle", "thiserror", ] -[[package]] -name = "near-epoch-manager" -version = "0.0.0" -source = "git+https://github.com/near/nearcore?rev=267e36e39fb5bb29c1df23c73afbcaa750ce96b1#267e36e39fb5bb29c1df23c73afbcaa750ce96b1" -dependencies = [ - "borsh 0.9.3", - "near-cache", - "near-chain-configs", - "near-chain-primitives", - "near-crypto", - "near-primitives", - "near-store", - "num-rational", - "primitive-types", - "rand 0.6.5", - "rand 0.7.3", - "serde_json", - "smart-default", - "tracing", -] - -[[package]] -name = "near-indexer" -version = "0.0.0" -source = "git+https://github.com/near/nearcore?rev=267e36e39fb5bb29c1df23c73afbcaa750ce96b1#267e36e39fb5bb29c1df23c73afbcaa750ce96b1" -dependencies = [ - "actix", - "anyhow", - "async-recursion", - "futures", - "near-chain-configs", - "near-client", - "near-crypto", - "near-indexer-primitives", - "near-o11y", - "near-primitives", - "near-store", - "nearcore", - "node-runtime", - "once_cell", - "rocksdb", - "serde", - "serde_json", - "tokio", - "tracing", -] - [[package]] name = "near-indexer-primitives" -version = "0.0.0" -source = "git+https://github.com/near/nearcore?rev=267e36e39fb5bb29c1df23c73afbcaa750ce96b1#267e36e39fb5bb29c1df23c73afbcaa750ce96b1" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1c089edfb295575737e94f8bad60d125f632919a742d6648644939b1b847665" dependencies = [ "near-primitives", "serde", "serde_json", ] -[[package]] -name = "near-jsonrpc" -version = "0.0.0" -source = "git+https://github.com/near/nearcore?rev=267e36e39fb5bb29c1df23c73afbcaa750ce96b1#267e36e39fb5bb29c1df23c73afbcaa750ce96b1" -dependencies = [ - "actix", - "actix-cors", - "actix-web", - "easy-ext", - "futures", - "near-chain-configs", - "near-client", - "near-client-primitives", - "near-jsonrpc-client", - "near-jsonrpc-primitives", - "near-network", - "near-network-primitives", - "near-o11y", - "near-primitives", - "near-rpc-error-macro 0.0.0", - "once_cell", - "serde", - "serde_json", - "tokio", - "tracing", - "tracing-subscriber 0.3.15", -] - [[package]] name = "near-jsonrpc-client" -version = "0.0.0" -source = "git+https://github.com/near/nearcore?rev=267e36e39fb5bb29c1df23c73afbcaa750ce96b1#267e36e39fb5bb29c1df23c73afbcaa750ce96b1" +version = "0.4.0-beta.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bba462f54bc35289a1013ed3a2ebfa67cc8b12699f81c12dd67687f200c7b871" dependencies = [ - "actix-http", - "awc", - "futures", + "borsh 0.9.3", + "lazy_static", + "log", + "near-chain-configs", + "near-crypto", "near-jsonrpc-primitives", "near-primitives", + "reqwest", "serde", "serde_json", + "thiserror", + "uuid", ] [[package]] name = "near-jsonrpc-primitives" -version = "0.0.0" -source = "git+https://github.com/near/nearcore?rev=267e36e39fb5bb29c1df23c73afbcaa750ce96b1#267e36e39fb5bb29c1df23c73afbcaa750ce96b1" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34a14ee8ca393c0140cb232789259ebc61b13b4cceb177267d0131f50d0eda6c" dependencies = [ "near-chain-configs", "near-client-primitives", "near-crypto", "near-primitives", - "near-rpc-error-macro 0.0.0", + "near-rpc-error-macro 0.14.0", "serde", "serde_json", "thiserror", + "uuid", ] [[package]] -name = "near-mainnet-res" -version = "0.0.0" -source = "git+https://github.com/near/nearcore?rev=267e36e39fb5bb29c1df23c73afbcaa750ce96b1#267e36e39fb5bb29c1df23c73afbcaa750ce96b1" -dependencies = [ - "near-account-id", - "near-chain-configs", - "near-primitives", - "serde_json", -] - -[[package]] -name = "near-network" -version = "0.0.0" -source = "git+https://github.com/near/nearcore?rev=267e36e39fb5bb29c1df23c73afbcaa750ce96b1#267e36e39fb5bb29c1df23c73afbcaa750ce96b1" +name = "near-lake-framework" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5984129964c79102a489ccd9f2af31b4bb8e9f78b0e757f480cb13d426e1915f" dependencies = [ - "actix", "anyhow", - "arc-swap", - "assert_matches", - "borsh 0.9.3", - "bytes", - "bytesize", - "chrono", - "conqueue", - "crossbeam-channel", - "delay-detector", + "async-stream", + "aws-config", + "aws-sdk-s3", + "aws-types", + "derive_builder", "futures", - "futures-util", - "im", - "itertools", - "lru", - "near-crypto", - "near-network-primitives", - "near-o11y", - "near-performance-metrics", - "near-performance-metrics-macros", - "near-primitives", - "near-stable-hasher", - "near-store", - "once_cell", - "opentelemetry", - "parking_lot 0.12.1", - "protobuf 3.0.2", - "protobuf-codegen", - "rand 0.7.3", - "rand_xorshift 0.2.0", - "rayon", + "near-indexer-primitives", "serde", - "smart-default", - "strum", - "thiserror", + "serde_json", "tokio", "tokio-stream", - "tokio-util 0.7.2", "tracing", - "tracing-opentelemetry", ] [[package]] name = "near-network-primitives" -version = "0.0.0" -source = "git+https://github.com/near/nearcore?rev=267e36e39fb5bb29c1df23c73afbcaa750ce96b1#267e36e39fb5bb29c1df23c73afbcaa750ce96b1" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aa998a1e70ebf8cf3efa76c4562ef36038cc88b4aee60efb708d14273910357" dependencies = [ "actix", "anyhow", @@ -2845,95 +2268,29 @@ dependencies = [ "chrono", "near-crypto", "near-primitives", - "once_cell", - "opentelemetry", "serde", "strum", - "thiserror", - "time 0.3.9", - "tokio", - "tracing", -] - -[[package]] -name = "near-o11y" -version = "0.0.0" -source = "git+https://github.com/near/nearcore?rev=267e36e39fb5bb29c1df23c73afbcaa750ce96b1#267e36e39fb5bb29c1df23c73afbcaa750ce96b1" -dependencies = [ - "atty", - "backtrace", - "clap", - "once_cell", - "opentelemetry", - "opentelemetry-otlp", - "opentelemetry-semantic-conventions", - "prometheus", - "strum", - "thiserror", "tokio", "tracing", - "tracing-appender", - "tracing-opentelemetry", - "tracing-serde", - "tracing-subscriber 0.3.15", -] - -[[package]] -name = "near-performance-metrics" -version = "0.0.0" -source = "git+https://github.com/near/nearcore?rev=267e36e39fb5bb29c1df23c73afbcaa750ce96b1#267e36e39fb5bb29c1df23c73afbcaa750ce96b1" -dependencies = [ - "actix", - "bitflags", - "bytes", - "futures", - "libc", - "once_cell", - "strum", - "tokio", - "tokio-util 0.7.2", - "tracing", -] - -[[package]] -name = "near-performance-metrics-macros" -version = "0.0.0" -source = "git+https://github.com/near/nearcore?rev=267e36e39fb5bb29c1df23c73afbcaa750ce96b1#267e36e39fb5bb29c1df23c73afbcaa750ce96b1" -dependencies = [ - "quote", - "syn", -] - -[[package]] -name = "near-pool" -version = "0.0.0" -source = "git+https://github.com/near/nearcore?rev=267e36e39fb5bb29c1df23c73afbcaa750ce96b1#267e36e39fb5bb29c1df23c73afbcaa750ce96b1" -dependencies = [ - "borsh 0.9.3", - "near-crypto", - "near-o11y", - "near-primitives", - "once_cell", - "rand 0.7.3", ] [[package]] name = "near-primitives" -version = "0.0.0" -source = "git+https://github.com/near/nearcore?rev=267e36e39fb5bb29c1df23c73afbcaa750ce96b1#267e36e39fb5bb29c1df23c73afbcaa750ce96b1" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ad1a9a1640539c81f065425c31bffcfbf6b31ef1aeaade59ce905f5df6ac860" dependencies = [ "borsh 0.9.3", "byteorder", "bytesize", - "cfg-if 1.0.0", "chrono", "derive_more", "easy-ext", "hex", "near-crypto", - "near-primitives-core 0.0.0", - "near-rpc-error-macro 0.0.0", - "near-vm-errors 0.0.0", + "near-primitives-core 0.14.0", + "near-rpc-error-macro 0.14.0", + "near-vm-errors 0.14.0", "num-rational", "once_cell", "primitive-types", @@ -2946,23 +2303,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "near-primitives-core" -version = "0.0.0" -source = "git+https://github.com/near/nearcore?rev=267e36e39fb5bb29c1df23c73afbcaa750ce96b1#267e36e39fb5bb29c1df23c73afbcaa750ce96b1" -dependencies = [ - "base64 0.13.0", - "borsh 0.9.3", - "bs58", - "derive_more", - "near-account-id", - "num-rational", - "serde", - "serde_repr", - "sha2 0.10.2", - "strum", -] - [[package]] name = "near-primitives-core" version = "0.4.0" @@ -2982,41 +2322,20 @@ dependencies = [ ] [[package]] -name = "near-rosetta-rpc" -version = "0.0.0" -source = "git+https://github.com/near/nearcore?rev=267e36e39fb5bb29c1df23c73afbcaa750ce96b1#267e36e39fb5bb29c1df23c73afbcaa750ce96b1" +name = "near-primitives-core" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91d508f0fc340f6461e4e256417685720d3c4c00bb5a939b105160e49137caba" dependencies = [ - "actix", - "actix-cors", - "actix-http", - "actix-web", - "awc", + "base64 0.11.0", + "borsh 0.9.3", + "bs58", "derive_more", - "futures", - "hex", "near-account-id", - "near-chain-configs", - "near-client", - "near-client-primitives", - "near-crypto", - "near-network", - "near-primitives", - "paperclip", + "num-rational", "serde", - "serde_json", + "sha2 0.10.2", "strum", - "tokio", - "validator", -] - -[[package]] -name = "near-rpc-error-core" -version = "0.0.0" -source = "git+https://github.com/near/nearcore?rev=267e36e39fb5bb29c1df23c73afbcaa750ce96b1#267e36e39fb5bb29c1df23c73afbcaa750ce96b1" -dependencies = [ - "quote", - "serde", - "syn", ] [[package]] @@ -3033,11 +2352,12 @@ dependencies = [ ] [[package]] -name = "near-rpc-error-macro" -version = "0.0.0" -source = "git+https://github.com/near/nearcore?rev=267e36e39fb5bb29c1df23c73afbcaa750ce96b1#267e36e39fb5bb29c1df23c73afbcaa750ce96b1" +name = "near-rpc-error-core" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93ee0b41c75ef859c193a8ff1dadfa0c8207bc0ac447cc22259721ad769a1408" dependencies = [ - "near-rpc-error-core 0.0.0", + "quote", "serde", "syn", ] @@ -3056,6 +2376,17 @@ dependencies = [ "syn", ] +[[package]] +name = "near-rpc-error-macro" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e837bd4bacd807073ec5ceb85708da7f721b46a4c2a978de86027fb0034ce31" +dependencies = [ + "near-rpc-error-core 0.14.0", + "serde", + "syn", +] + [[package]] name = "near-runtime-utils" version = "4.0.0-pre.1" @@ -3077,7 +2408,7 @@ dependencies = [ "near-primitives-core 0.4.0", "near-sdk-macros", "near-sys", - "near-vm-logic 4.0.0-pre.1", + "near-vm-logic", "serde", "serde_json", "wee_alloc", @@ -3088,47 +2419,10 @@ name = "near-sdk-macros" version = "4.0.0-pre.3" source = "git+https://github.com/near/near-sdk-rs?rev=03487c184d37b0382dd9bd41c57466acad58fc1f#03487c184d37b0382dd9bd41c57466acad58fc1f" dependencies = [ - "Inflector", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "near-stable-hasher" -version = "0.0.0" -source = "git+https://github.com/near/nearcore?rev=267e36e39fb5bb29c1df23c73afbcaa750ce96b1#267e36e39fb5bb29c1df23c73afbcaa750ce96b1" - -[[package]] -name = "near-store" -version = "0.0.0" -source = "git+https://github.com/near/nearcore?rev=267e36e39fb5bb29c1df23c73afbcaa750ce96b1#267e36e39fb5bb29c1df23c73afbcaa750ce96b1" -dependencies = [ - "anyhow", - "borsh 0.9.3", - "byteorder", - "bytesize", - "crossbeam", - "derive_more", - "elastic-array", - "enum-map", - "fs2", - "itoa", - "lru", - "near-crypto", - "near-o11y", - "near-primitives", - "num_cpus", - "once_cell", - "rand 0.7.3", - "rlimit", - "rocksdb", - "serde", - "serde_json", - "strum", - "tempfile", - "thiserror", - "tracing", + "Inflector", + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -3136,35 +2430,16 @@ name = "near-sys" version = "0.1.0" source = "git+https://github.com/near/near-sdk-rs?rev=03487c184d37b0382dd9bd41c57466acad58fc1f#03487c184d37b0382dd9bd41c57466acad58fc1f" -[[package]] -name = "near-telemetry" -version = "0.0.0" -source = "git+https://github.com/near/nearcore?rev=267e36e39fb5bb29c1df23c73afbcaa750ce96b1#267e36e39fb5bb29c1df23c73afbcaa750ce96b1" -dependencies = [ - "actix", - "awc", - "futures", - "near-o11y", - "near-performance-metrics", - "near-performance-metrics-macros", - "near-primitives", - "once_cell", - "openssl", - "serde", - "serde_json", - "tracing", -] - [[package]] name = "near-vm-errors" -version = "0.0.0" -source = "git+https://github.com/near/nearcore?rev=267e36e39fb5bb29c1df23c73afbcaa750ce96b1#267e36e39fb5bb29c1df23c73afbcaa750ce96b1" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0da466a30f0446639cbd788c30865086fac3e8dcb07a79e51d2b0775ed4261e" dependencies = [ "borsh 0.9.3", "near-account-id", - "near-rpc-error-macro 0.0.0", + "near-rpc-error-macro 0.14.0", "serde", - "strum", ] [[package]] @@ -3179,28 +2454,6 @@ dependencies = [ "serde", ] -[[package]] -name = "near-vm-logic" -version = "0.0.0" -source = "git+https://github.com/near/nearcore?rev=267e36e39fb5bb29c1df23c73afbcaa750ce96b1#267e36e39fb5bb29c1df23c73afbcaa750ce96b1" -dependencies = [ - "borsh 0.9.3", - "bs58", - "byteorder", - "ed25519-dalek", - "near-account-id", - "near-crypto", - "near-o11y", - "near-primitives", - "near-primitives-core 0.0.0", - "near-vm-errors 0.0.0", - "ripemd", - "serde", - "sha2 0.9.9", - "sha3", - "zeropool-bn", -] - [[package]] name = "near-vm-logic" version = "4.0.0-pre.1" @@ -3219,163 +2472,13 @@ dependencies = [ "sha3", ] -[[package]] -name = "near-vm-runner" -version = "0.0.0" -source = "git+https://github.com/near/nearcore?rev=267e36e39fb5bb29c1df23c73afbcaa750ce96b1#267e36e39fb5bb29c1df23c73afbcaa750ce96b1" -dependencies = [ - "anyhow", - "borsh 0.9.3", - "loupe", - "memoffset", - "near-cache", - "near-primitives", - "near-stable-hasher", - "near-vm-errors 0.0.0", - "near-vm-logic 0.0.0", - "once_cell", - "parity-wasm 0.41.0", - "parity-wasm 0.42.2", - "pwasm-utils", - "serde", - "tracing", - "wasmer-compiler-near", - "wasmer-compiler-singlepass-near", - "wasmer-engine-near", - "wasmer-engine-universal-near", - "wasmer-runtime-core-near", - "wasmer-runtime-near", - "wasmer-types-near", - "wasmer-vm-near", - "wasmparser 0.78.2", - "wasmtime", -] - -[[package]] -name = "nearcore" -version = "1.30.0-rc.2" -source = "git+https://github.com/near/nearcore?rev=267e36e39fb5bb29c1df23c73afbcaa750ce96b1#267e36e39fb5bb29c1df23c73afbcaa750ce96b1" -dependencies = [ - "actix", - "actix-rt", - "actix-web", - "anyhow", - "awc", - "borsh 0.9.3", - "byteorder", - "chrono", - "delay-detector", - "dirs", - "easy-ext", - "futures", - "hyper", - "hyper-tls", - "indicatif", - "near-chain", - "near-chain-configs", - "near-chunks", - "near-client", - "near-client-primitives", - "near-crypto", - "near-epoch-manager", - "near-jsonrpc", - "near-mainnet-res", - "near-network", - "near-network-primitives", - "near-o11y", - "near-performance-metrics", - "near-pool", - "near-primitives", - "near-rosetta-rpc", - "near-store", - "near-telemetry", - "near-vm-runner", - "node-runtime", - "num-rational", - "once_cell", - "rand 0.7.3", - "rayon", - "rlimit", - "serde", - "serde_ignored", - "serde_json", - "smart-default", - "strum", - "tempfile", - "thiserror", - "tokio", - "tracing", - "xz2", -] - -[[package]] -name = "nix" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b2e0b4f3320ed72aaedb9a5ac838690a8047c7b275da22711fddff4f8a14229" -dependencies = [ - "bitflags", - "cc", - "cfg-if 0.1.10", - "libc", - "void", -] - -[[package]] -name = "node-runtime" -version = "0.0.0" -source = "git+https://github.com/near/nearcore?rev=267e36e39fb5bb29c1df23c73afbcaa750ce96b1#267e36e39fb5bb29c1df23c73afbcaa750ce96b1" -dependencies = [ - "borsh 0.9.3", - "byteorder", - "hex", - "near-chain-configs", - "near-crypto", - "near-o11y", - "near-primitives", - "near-store", - "near-vm-errors 0.0.0", - "near-vm-logic 0.0.0", - "near-vm-runner", - "num-bigint 0.3.3", - "num-rational", - "num-traits", - "once_cell", - "rand 0.7.3", - "rayon", - "serde", - "serde_json", - "sha2 0.10.2", - "thiserror", - "tracing", -] - -[[package]] -name = "nom" -version = "7.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8903e5a29a317527874d0402f867152a3d21c908bb0b933e416c65e301d4c36" -dependencies = [ - "memchr", - "minimal-lexical", -] - -[[package]] -name = "ntapi" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c28774a7fd2fbb4f0babd8237ce554b73af68021b5f695a3cebd6c59bac0980f" -dependencies = [ - "winapi", -] - [[package]] name = "num-bigint" version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "090c7f9998ee0ff65aa5b723e4009f7b217707f1fb5ea551329cc4d6231fb304" dependencies = [ - "autocfg 1.1.0", + "autocfg", "num-integer", "num-traits", ] @@ -3386,7 +2489,7 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f6f7833f2cbf2360a6cfd58cd41a53aa7a90bd4c202f5b1c7dd2ed73c57b2c3" dependencies = [ - "autocfg 1.1.0", + "autocfg", "num-integer", "num-traits", ] @@ -3397,7 +2500,7 @@ version = "0.1.45" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" dependencies = [ - "autocfg 1.1.0", + "autocfg", "num-traits", ] @@ -3407,7 +2510,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "12ac428b1cb17fce6f731001d307d351ec70a6d202fc2e60f7d4c5e42d8f4f07" dependencies = [ - "autocfg 1.1.0", + "autocfg", "num-bigint 0.3.3", "num-integer", "num-traits", @@ -3420,7 +2523,7 @@ version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" dependencies = [ - "autocfg 1.1.0", + "autocfg", ] [[package]] @@ -3442,29 +2545,11 @@ dependencies = [ "libc", ] -[[package]] -name = "number_prefix" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17b02fc0ff9a9e4b35b3342880f48e896ebf69f2967921fe8646bf5b7125956a" - -[[package]] -name = "object" -version = "0.28.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e42c982f2d955fac81dd7e1d0e1426a7d702acd9c98d19ab01083a6a0328c424" -dependencies = [ - "crc32fast", - "hashbrown 0.11.2", - "indexmap", - "memchr", -] - [[package]] name = "once_cell" -version = "1.13.1" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "074864da206b4973b84eb91683020dbefd6a8c3f0f38e054d93954e891935e4e" +checksum = "7709cef83f0c1f58f666e746a08b21e0085f7440fa6a29cc194d68aac97a4225" [[package]] name = "opaque-debug" @@ -3504,77 +2589,19 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" -[[package]] -name = "openssl-src" -version = "111.22.0+1.1.1q" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f31f0d509d1c1ae9cada2f9539ff8f37933831fd5098879e482aa687d659853" -dependencies = [ - "cc", -] - [[package]] name = "openssl-sys" version = "0.9.75" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5f9bd0c2710541a3cda73d6f9ac4f1b240de4ae261065d309dbe73d9dceb42f" dependencies = [ - "autocfg 1.1.0", + "autocfg", "cc", "libc", - "openssl-src", "pkg-config", "vcpkg", ] -[[package]] -name = "opentelemetry" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6105e89802af13fdf48c49d7646d3b533a70e536d818aae7e78ba0433d01acb8" -dependencies = [ - "async-trait", - "crossbeam-channel", - "futures-channel", - "futures-executor", - "futures-util", - "js-sys", - "lazy_static", - "percent-encoding", - "pin-project", - "rand 0.8.5", - "thiserror", - "tokio", - "tokio-stream", -] - -[[package]] -name = "opentelemetry-otlp" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d1a6ca9de4c8b00aa7f1a153bd76cb263287155cec642680d79d98706f3d28a" -dependencies = [ - "async-trait", - "futures", - "futures-util", - "http", - "opentelemetry", - "prost", - "thiserror", - "tokio", - "tonic", - "tonic-build", -] - -[[package]] -name = "opentelemetry-semantic-conventions" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "985cc35d832d412224b2cffe2f9194b1b89b6aa5d0bef76d080dce09d90e62bd" -dependencies = [ - "opentelemetry", -] - [[package]] name = "os_str_bytes" version = "6.0.1" @@ -3582,110 +2609,41 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "029d8d0b2f198229de29dca79676f2738ff952edf3fde542eb8bf94d8c21b435" [[package]] -name = "page_size" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eebde548fbbf1ea81a99b128872779c437752fb99f217c45245e1a61dcd9edcd" -dependencies = [ - "libc", - "winapi", -] - -[[package]] -name = "paperclip" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29edecb9b5de19fcdba789406bc39144de34c100e59151095aac1b97d2b4a25e" -dependencies = [ - "anyhow", - "itertools", - "once_cell", - "paperclip-actix", - "paperclip-core", - "paperclip-macros", - "parking_lot 0.12.1", - "semver 0.9.0", - "serde", - "serde_derive", - "serde_json", - "serde_yaml", - "thiserror", - "url", -] - -[[package]] -name = "paperclip-actix" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca6acb344bfe7c8be8e140ad01dc2a8bc1a1b829014a29291174be64bc45f06e" -dependencies = [ - "actix-service", - "actix-web", - "futures", - "once_cell", - "paperclip-core", - "paperclip-macros", - "parking_lot 0.12.1", - "serde_json", -] - -[[package]] -name = "paperclip-core" -version = "0.5.1" +name = "parity-scale-codec" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6ba1b92909712a1186613a6ba6e1c48c59baba59672cff2b242e8e03e90101f" +checksum = "373b1a4c1338d9cd3d1fa53b3a11bdab5ab6bd80a20f7f7becd76953ae2be909" dependencies = [ - "actix-web", - "mime", - "once_cell", - "paperclip-macros", - "parking_lot 0.12.1", - "pin-project", - "regex", + "arrayvec 0.7.2", + "bitvec", + "byte-slice-cast", + "impl-trait-for-tuples", + "parity-scale-codec-derive", "serde", - "serde_json", - "serde_yaml", - "thiserror", ] [[package]] -name = "paperclip-macros" -version = "0.6.0" +name = "parity-scale-codec-derive" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "992e1f19f6a449c41e166a2336c86912eedc17f5167886ef09d601607d9be1f1" +checksum = "1557010476e0595c9b568d16dcfb81b93cdeb157612726f5170d31aa707bed27" dependencies = [ - "heck 0.4.0", - "http", - "lazy_static", - "mime", - "proc-macro-error", + "proc-macro-crate 1.1.3", "proc-macro2", "quote", - "strum", - "strum_macros", "syn", ] [[package]] -name = "parity-wasm" -version = "0.41.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddfc878dac00da22f8f61e7af3157988424567ab01d9920b962ef7dcbd7cd865" - -[[package]] -name = "parity-wasm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be5e13c266502aadf83426d87d81a0f5d1ef45b8027f5a471c360abfe4bfae92" - -[[package]] -name = "parking_lot" -version = "0.10.2" +name = "parity-secp256k1" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3a704eb390aafdc107b0e392f56a82b668e3a71366993b5340f5833fd62505e" +checksum = "4fca4f82fccae37e8bbdaeb949a4a218a1bbc485d11598f193d2a908042e5fc1" dependencies = [ - "lock_api 0.3.4", - "parking_lot_core 0.7.2", + "arrayvec 0.5.2", + "cc", + "cfg-if 0.1.10", + "rand 0.7.3", ] [[package]] @@ -3694,22 +2652,8 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" dependencies = [ - "lock_api 0.4.7", - "parking_lot_core 0.9.3", -] - -[[package]] -name = "parking_lot_core" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d58c7c768d4ba344e3e8d72518ac13e259d7c7ade24167003b8488e10b6740a3" -dependencies = [ - "cfg-if 0.1.10", - "cloudabi", - "libc", - "redox_syscall 0.1.57", - "smallvec", - "winapi", + "lock_api", + "parking_lot_core", ] [[package]] @@ -3720,22 +2664,16 @@ checksum = "09a279cbf25cb0757810394fbc1e359949b59e348145c643a939a525692e6929" dependencies = [ "cfg-if 1.0.0", "libc", - "redox_syscall 0.2.13", + "redox_syscall", "smallvec", "windows-sys", ] [[package]] name = "paste" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c520e05135d6e763148b6426a837e239041653ba7becd2e538c076c738025fc" - -[[package]] -name = "peeking_take_while" -version = "0.1.2" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" +checksum = "b1de2e551fb905ac83f73f7aedf2f0cb4a0da7e35efa24a202a936269f1f18e1" [[package]] name = "percent-encoding" @@ -3743,16 +2681,6 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" -[[package]] -name = "petgraph" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5014253a1331579ce62aa67443b4a658c5e7dd03d4bc6d302b94474888143" -dependencies = [ - "fixedbitset", - "indexmap", -] - [[package]] name = "pin-project" version = "1.0.10" @@ -3799,9 +2727,9 @@ checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" [[package]] name = "pq-sys" -version = "0.4.7" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b845d6d8ec554f972a2c5298aad68953fd64e7441e846075450b44656a016d1" +checksum = "6ac25eee5a0582f45a67e837e350d784e7003bd29a5f460796772061ca49ffda" dependencies = [ "vcpkg", ] @@ -3813,6 +2741,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05e4722c697a58a99d5d06a08c30821d7c082a4632198de1eaa5a6c22ef42373" dependencies = [ "fixed-hash", + "impl-codec", "uint 0.9.3", ] @@ -3825,6 +2754,16 @@ dependencies = [ "toml", ] +[[package]] +name = "proc-macro-crate" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e17d47ce914bf4de440332250b0edd23ce48c005f59fab39d3335866b114f11a" +dependencies = [ + "thiserror", + "toml", +] + [[package]] name = "proc-macro-error" version = "1.0.4" @@ -3860,168 +2799,24 @@ dependencies = [ [[package]] name = "prometheus" -version = "0.13.1" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cface98dfa6d645ea4c789839f176e4b072265d085bfcc48eaa8d137f58d3c39" +checksum = "449811d15fbdf5ceb5c1144416066429cf82316e2ec8ce0c1f6f8a02e7bbcf8c" dependencies = [ "cfg-if 1.0.0", "fnv", "lazy_static", "memchr", - "parking_lot 0.12.1", - "protobuf 2.27.1", + "parking_lot", + "protobuf", "thiserror", ] -[[package]] -name = "prost" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "444879275cb4fd84958b1a1d5420d15e6fcf7c235fe47f053c9c2a80aceb6001" -dependencies = [ - "bytes", - "prost-derive", -] - -[[package]] -name = "prost-build" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62941722fb675d463659e49c4f3fe1fe792ff24fe5bbaa9c08cd3b98a1c354f5" -dependencies = [ - "bytes", - "heck 0.3.3", - "itertools", - "lazy_static", - "log", - "multimap", - "petgraph", - "prost", - "prost-types", - "regex", - "tempfile", - "which", -] - -[[package]] -name = "prost-derive" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9cc1a3263e07e0bf68e96268f37665207b49560d98739662cdfaae215c720fe" -dependencies = [ - "anyhow", - "itertools", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "prost-types" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "534b7a0e836e3c482d2693070f982e39e7611da9695d4d1f5a4b186b51faef0a" -dependencies = [ - "bytes", - "prost", -] - -[[package]] -name = "protobuf" -version = "2.27.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf7e6d18738ecd0902d30d1ad232c9125985a3422929b16c65517b38adc14f96" - [[package]] name = "protobuf" -version = "3.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a74937d52a466a535fda2e83f0e575f3ef1b34e4a84545b4a9e418fad32a3b1c" -dependencies = [ - "once_cell", - "protobuf-support", - "thiserror", -] - -[[package]] -name = "protobuf-codegen" -version = "3.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a02997c69a76d9dba3124e2041dc7bb32c98e2cc7bbd136950312a819c64f825" -dependencies = [ - "anyhow", - "once_cell", - "protobuf 3.0.2", - "protobuf-parse", - "regex", - "tempfile", - "thiserror", -] - -[[package]] -name = "protobuf-parse" -version = "3.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3272369e02691aef4ff079ef97bb278afa9d15c21a41fd727654ab712e4bb297" -dependencies = [ - "anyhow", - "indexmap", - "log", - "protobuf 3.0.2", - "protobuf-support", - "tempfile", - "thiserror", - "which", -] - -[[package]] -name = "protobuf-support" -version = "3.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebf34636d66670da249c3b6589142e7f0b4918a015ec72fa32102fd43e023b0e" -dependencies = [ - "thiserror", -] - -[[package]] -name = "psm" -version = "0.1.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "871372391786ccec00d3c5d3d6608905b3d4db263639cfe075d3b60a736d115a" -dependencies = [ - "cc", -] - -[[package]] -name = "ptr_meta" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0738ccf7ea06b608c10564b31debd4f5bc5e197fc8bfe088f68ae5ce81e7a4f1" -dependencies = [ - "ptr_meta_derive", -] - -[[package]] -name = "ptr_meta_derive" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "pwasm-utils" -version = "0.12.0" +version = "2.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f7a12f176deee919f4ba55326ee17491c8b707d0987aed822682c821b660192" -dependencies = [ - "byteorder", - "log", - "parity-wasm 0.41.0", -] +checksum = "106dd99e98437432fed6519dedecfade6a06a73bb7b2a1e019fdd2bee5778d94" [[package]] name = "quote" @@ -4039,27 +2834,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51de85fb3fb6524929c8a2eb85e6b6d363de4e8c48f9e2c2eac4944abc181c93" dependencies = [ "log", - "parking_lot 0.12.1", + "parking_lot", "scheduled-thread-pool", ] [[package]] -name = "rand" -version = "0.6.5" +name = "radium" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" -dependencies = [ - "autocfg 0.1.8", - "libc", - "rand_chacha 0.1.1", - "rand_core 0.4.2", - "rand_hc 0.1.0", - "rand_isaac", - "rand_jitter", - "rand_pcg", - "rand_xorshift 0.1.1", - "winapi", -] +checksum = "643f8f41a8ebc4c5dc4515c82bb8abd397b527fc20fd681b7c011c2aee5d44fb" [[package]] name = "rand" @@ -4071,7 +2854,7 @@ dependencies = [ "libc", "rand_chacha 0.2.2", "rand_core 0.5.1", - "rand_hc 0.2.0", + "rand_hc", ] [[package]] @@ -4085,16 +2868,6 @@ dependencies = [ "rand_core 0.6.3", ] -[[package]] -name = "rand_chacha" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" -dependencies = [ - "autocfg 0.1.8", - "rand_core 0.3.1", -] - [[package]] name = "rand_chacha" version = "0.2.2" @@ -4115,21 +2888,6 @@ dependencies = [ "rand_core 0.6.3", ] -[[package]] -name = "rand_core" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" -dependencies = [ - "rand_core 0.4.2", -] - -[[package]] -name = "rand_core" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" - [[package]] name = "rand_core" version = "0.5.1" @@ -4148,15 +2906,6 @@ dependencies = [ "getrandom 0.2.6", ] -[[package]] -name = "rand_hc" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" -dependencies = [ - "rand_core 0.3.1", -] - [[package]] name = "rand_hc" version = "0.2.0" @@ -4166,93 +2915,6 @@ dependencies = [ "rand_core 0.5.1", ] -[[package]] -name = "rand_isaac" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "rand_jitter" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" -dependencies = [ - "libc", - "rand_core 0.4.2", - "winapi", -] - -[[package]] -name = "rand_pcg" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" -dependencies = [ - "autocfg 0.1.8", - "rand_core 0.4.2", -] - -[[package]] -name = "rand_xorshift" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "rand_xorshift" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77d416b86801d23dde1aa643023b775c3a462efc0ed96443add11546cdf1dca8" -dependencies = [ - "rand_core 0.5.1", -] - -[[package]] -name = "rand_xoshiro" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f97cdb2a36ed4183de61b2f824cc45c9f1037f28afe0a322e9fff4c108b5aaa" -dependencies = [ - "rand_core 0.6.3", -] - -[[package]] -name = "rayon" -version = "1.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd99e5772ead8baa5215278c9b15bf92087709e9c1b2d1f97cdb5a183c933a7d" -dependencies = [ - "autocfg 1.1.0", - "crossbeam-deque", - "either", - "rayon-core", -] - -[[package]] -name = "rayon-core" -version = "1.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "258bcdb5ac6dad48491bb2992db6b7cf74878b0384908af124823d118c99683f" -dependencies = [ - "crossbeam-channel", - "crossbeam-deque", - "crossbeam-utils", - "num_cpus", -] - -[[package]] -name = "redox_syscall" -version = "0.1.57" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" - [[package]] name = "redox_syscall" version = "0.2.13" @@ -4262,17 +2924,6 @@ dependencies = [ "bitflags", ] -[[package]] -name = "redox_users" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" -dependencies = [ - "getrandom 0.2.6", - "redox_syscall 0.2.13", - "thiserror", -] - [[package]] name = "reed-solomon-erasure" version = "4.0.2" @@ -4282,18 +2933,6 @@ dependencies = [ "smallvec", ] -[[package]] -name = "regalloc2" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "904196c12c9f55d3aea578613219f493ced8e05b3d0c6a42d11cb4142d8b4879" -dependencies = [ - "fxhash", - "log", - "slice-group-by", - "smallvec", -] - [[package]] name = "regex" version = "1.5.5" @@ -4320,113 +2959,67 @@ version = "0.6.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" -[[package]] -name = "region" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "877e54ea2adcd70d80e9179344c97f93ef0dffd6b03e1f4529e6e83ab2fa9ae0" -dependencies = [ - "bitflags", - "libc", - "mach", - "winapi", -] - -[[package]] -name = "region" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76e189c2369884dce920945e2ddf79b3dff49e071a167dd1817fa9c4c00d512e" -dependencies = [ - "bitflags", - "libc", - "mach", - "winapi", -] - [[package]] name = "remove_dir_all" version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" dependencies = [ - "winapi", -] - -[[package]] -name = "rend" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79af64b4b6362ffba04eef3a4e10829718a4896dac19daa741851c86781edf95" -dependencies = [ - "bytecheck", -] - -[[package]] -name = "ripemd" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1facec54cb5e0dc08553501fa740091086d0259ad0067e0d4103448e4cb22ed3" -dependencies = [ - "digest 0.10.3", -] - -[[package]] -name = "rkyv" -version = "0.7.38" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "517a3034eb2b1499714e9d1e49b2367ad567e07639b69776d35e259d9c27cca6" -dependencies = [ - "bytecheck", - "hashbrown 0.12.1", - "ptr_meta", - "rend", - "rkyv_derive", - "seahash", -] - -[[package]] -name = "rkyv_derive" -version = "0.7.38" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "505c209ee04111a006431abf39696e640838364d67a107c559ababaf6fd8c9dd" -dependencies = [ - "proc-macro2", - "quote", - "syn", + "winapi", ] [[package]] -name = "rlimit" -version = "0.7.0" +name = "reqwest" +version = "0.11.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "347703a5ae47adf1e693144157be231dde38c72bd485925cae7407ad3e52480b" +checksum = "b75aa69a3f06bbcc66ede33af2af253c6f7a86b1ca0033f60c580a27074fbf92" dependencies = [ - "libc", + "base64 0.13.0", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "hyper", + "hyper-tls", + "ipnet", + "js-sys", + "lazy_static", + "log", + "mime", + "native-tls", + "percent-encoding", + "pin-project-lite", + "serde", + "serde_json", + "serde_urlencoded", + "tokio", + "tokio-native-tls", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "winreg", ] [[package]] -name = "rocksdb" -version = "0.18.0" +name = "ring" +version = "0.16.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "620f4129485ff1a7128d184bc687470c21c7951b64779ebc9cfdad3dcd920290" +checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" dependencies = [ + "cc", "libc", - "librocksdb-sys", + "once_cell", + "spin", + "untrusted", + "web-sys", + "winapi", ] -[[package]] -name = "rustc-demangle" -version = "0.1.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" - -[[package]] -name = "rustc-hash" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" - [[package]] name = "rustc-hex" version = "2.1.0" @@ -4435,34 +3028,36 @@ checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" [[package]] name = "rustc_version" -version = "0.2.3" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "semver 0.9.0", + "semver", ] [[package]] -name = "rustc_version" -version = "0.4.0" +name = "rustls" +version = "0.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +checksum = "35edb675feee39aec9c99fa5ff985081995a06d594114ae14cbe797ad7b7a6d7" dependencies = [ - "semver 1.0.9", + "base64 0.13.0", + "log", + "ring", + "sct", + "webpki", ] [[package]] -name = "rustix" -version = "0.33.7" +name = "rustls-native-certs" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "938a344304321a9da4973b9ff4f9f8db9caf4597dfd9dda6a60b523340a0fff0" +checksum = "5a07b7c1885bd8ed3831c289b7870b13ef46fe0e856d288c30d9cc17d75a2092" dependencies = [ - "bitflags", - "errno", - "io-lifetimes", - "libc", - "linux-raw-sys", - "winapi", + "openssl-probe", + "rustls", + "schannel", + "security-framework", ] [[package]] @@ -4493,7 +3088,7 @@ version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "977a7519bff143a44f842fd07e80ad1329295bd71686457f18e496736f4bf9bf" dependencies = [ - "parking_lot 0.12.1", + "parking_lot", ] [[package]] @@ -4503,28 +3098,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] -name = "seahash" -version = "4.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" - -[[package]] -name = "secp256k1" -version = "0.24.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7649a0b3ffb32636e60c7ce0d70511eda9c52c658cd0634e194d5a19943aeff" -dependencies = [ - "rand 0.8.5", - "secp256k1-sys", -] - -[[package]] -name = "secp256k1-sys" -version = "0.6.0" +name = "sct" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7058dc8eaf3f2810d7828680320acda0b25a288f6d288e19278e249bbf74226b" +checksum = "b362b83898e0e69f38515b82ee15aa80636befe47c3b6d3d89a911e78fc228ce" dependencies = [ - "cc", + "ring", + "untrusted", ] [[package]] @@ -4550,75 +3130,32 @@ dependencies = [ "libc", ] -[[package]] -name = "semver" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -dependencies = [ - "semver-parser", -] - [[package]] name = "semver" version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8cb243bdfdb5936c8dc3c45762a19d12ab4550cdc753bc247637d4ec35a040fd" -[[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" - [[package]] name = "serde" -version = "1.0.145" +version = "1.0.137" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "728eb6351430bccb993660dfffc5a72f91ccc1295abaa8ce19b27ebe4f75568b" +checksum = "61ea8d54c77f8315140a05f4c7237403bf38b72704d031543aa1d16abbf517d1" dependencies = [ "serde_derive", ] -[[package]] -name = "serde-bench" -version = "0.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d733da87e79faaac25616e33d26299a41143fd4cd42746cbb0e91d8feea243fd" -dependencies = [ - "byteorder", - "serde", -] - -[[package]] -name = "serde_bytes" -version = "0.11.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "212e73464ebcde48d723aa02eb270ba62eff38a9b732df31f33f1b4e145f3a54" -dependencies = [ - "serde", -] - [[package]] name = "serde_derive" -version = "1.0.145" +version = "1.0.137" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81fa1584d3d1bcacd84c277a0dfe21f5b0f6accf4a23d04d4c6d61f1af522b4c" +checksum = "1f26faba0c3959972377d3b2d306ee9f71faee9714294e41bb777f83f88578be" dependencies = [ "proc-macro2", "quote", "syn", ] -[[package]] -name = "serde_ignored" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1940036ca2411651a40012009d062087dfe62817b2191a03750fb569e11fa633" -dependencies = [ - "serde", -] - [[package]] name = "serde_json" version = "1.0.81" @@ -4631,17 +3168,6 @@ dependencies = [ "serde", ] -[[package]] -name = "serde_repr" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2ad84e47328a31223de7fed7a4f5087f2d6ddfe586cf3ca25b7a165bc0a5aed" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "serde_urlencoded" version = "0.7.1" @@ -4655,22 +3181,10 @@ dependencies = [ ] [[package]] -name = "serde_yaml" -version = "0.8.24" +name = "sha1" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "707d15895415db6628332b737c838b88c598522e4dc70647e59b72312924aebc" -dependencies = [ - "indexmap", - "ryu", - "serde", - "yaml-rust", -] - -[[package]] -name = "sha-1" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "028f48d513f9678cda28f6e4064755b3fbb2af6acd672f2c209b62323f7aea0f" +checksum = "006769ba83e921b3085caa8334186b00cf92b4cb1a6cf4632fbccc8eff5c7549" dependencies = [ "cfg-if 1.0.0", "cpufeatures", @@ -4722,12 +3236,6 @@ dependencies = [ "lazy_static", ] -[[package]] -name = "shlex" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3" - [[package]] name = "signal-hook-registry" version = "1.4.0" @@ -4743,28 +3251,12 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f054c6c1a6e95179d6f23ed974060dcefb2d9388bb7256900badad682c499de4" -[[package]] -name = "sized-chunks" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16d69225bde7a69b235da73377861095455d298f2b970996eec25ddbb42b3d1e" -dependencies = [ - "bitmaps", - "typenum", -] - [[package]] name = "slab" version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eb703cfe953bccee95685111adeedb76fabe4e97549a58d16f03ea7b9367bb32" -[[package]] -name = "slice-group-by" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03b634d87b960ab1a38c4fe143b508576f075e7c978bfad18217645ebfdfa2ec" - [[package]] name = "smallvec" version = "1.8.0" @@ -4798,12 +3290,6 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" -[[package]] -name = "stable_deref_trait" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" - [[package]] name = "static_assertions" version = "1.1.0" @@ -4868,31 +3354,10 @@ dependencies = [ ] [[package]] -name = "sysinfo" -version = "0.24.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d80929a3b477bce3a64360ca82bfb361eacce1dcb7b1fb31e8e5e181e37c212" -dependencies = [ - "cfg-if 1.0.0", - "core-foundation-sys", - "libc", - "ntapi", - "once_cell", - "rayon", - "winapi", -] - -[[package]] -name = "target-lexicon" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab0e7238dcc7b40a7be719a25365910f6807bd864f4cce6b2e6b873658e2b19d" - -[[package]] -name = "target-lexicon" -version = "0.12.3" +name = "tap" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7fa7e55043acb85fca6b3c01485a2eeb6b69c5d21002e273c79e465f43b7ac1" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tempfile" @@ -4903,7 +3368,7 @@ dependencies = [ "cfg-if 1.0.0", "fastrand", "libc", - "redox_syscall 0.2.13", + "redox_syscall", "remove_dir_all", "winapi", ] @@ -4917,16 +3382,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "terminal_size" -version = "0.1.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "633c1a546cee861a1a6d0dc69ebeca693bf4296661ba7852b9d21d159e0506df" -dependencies = [ - "libc", - "winapi", -] - [[package]] name = "textwrap" version = "0.15.0" @@ -4935,18 +3390,18 @@ checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb" [[package]] name = "thiserror" -version = "1.0.32" +version = "1.0.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5f6586b7f764adc0231f4c79be7b920e766bb2f3e51b3661cdb263828f19994" +checksum = "bd829fe32373d27f76265620b5309d0340cb8550f523c1dda251d6298069069a" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.32" +version = "1.0.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12bafc5b54507e0149cdf1b145a5d80ab80a90bcd9275df43d4fff68460f6c21" +checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a" dependencies = [ "proc-macro2", "quote", @@ -4962,17 +3417,6 @@ dependencies = [ "once_cell", ] -[[package]] -name = "tikv-jemalloc-sys" -version = "0.4.3+5.2.1-patched.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1792ccb507d955b46af42c123ea8863668fae24d03721e40cad6a41773dbb49" -dependencies = [ - "cc", - "fs_extra", - "libc", -] - [[package]] name = "time" version = "0.1.44" @@ -5029,35 +3473,13 @@ dependencies = [ "mio", "num_cpus", "once_cell", - "parking_lot 0.12.1", + "parking_lot", "pin-project-lite", "signal-hook-registry", "socket2", - "tokio-macros", "winapi", ] -[[package]] -name = "tokio-io-timeout" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30b74022ada614a1b4834de765f9bb43877f910cc8ce4be40e89042c9223a8bf" -dependencies = [ - "pin-project-lite", - "tokio", -] - -[[package]] -name = "tokio-macros" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b557f72f448c511a979e2564e55d74e6c4432fc96ff4f6241bc6bded342643b7" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "tokio-native-tls" version = "0.3.0" @@ -5069,38 +3491,23 @@ dependencies = [ ] [[package]] -name = "tokio-openssl" -version = "0.6.3" +name = "tokio-rustls" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08f9ffb7809f1b20c1b398d92acf4cc719874b3b2b2d9ea2f09b4a80350878a" +checksum = "bc6844de72e57df1980054b38be3a9f4702aba4858be64dd700181a8a6d0e1b6" dependencies = [ - "futures-util", - "openssl", - "openssl-sys", + "rustls", "tokio", + "webpki", ] [[package]] name = "tokio-stream" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df54d54117d6fdc4e4fea40fe1e4e566b3505700e148a6827e59b34b0d2600d9" -dependencies = [ - "futures-core", - "pin-project-lite", - "tokio", -] - -[[package]] -name = "tokio-util" -version = "0.6.10" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36943ee01a6d67977dd3f84a5a1d2efeb4ada3a1ae771cadfaa535d9d9fc6507" +checksum = "50145484efff8818b5ccd256697f36863f587da82cf8b409c53adf1e840798e3" dependencies = [ - "bytes", "futures-core", - "futures-sink", - "log", "pin-project-lite", "tokio", ] @@ -5128,49 +3535,6 @@ dependencies = [ "serde", ] -[[package]] -name = "tonic" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff08f4649d10a70ffa3522ca559031285d8e421d727ac85c60825761818f5d0a" -dependencies = [ - "async-stream", - "async-trait", - "base64 0.13.0", - "bytes", - "futures-core", - "futures-util", - "h2", - "http", - "http-body", - "hyper", - "hyper-timeout", - "percent-encoding", - "pin-project", - "prost", - "prost-derive", - "tokio", - "tokio-stream", - "tokio-util 0.6.10", - "tower", - "tower-layer", - "tower-service", - "tracing", - "tracing-futures", -] - -[[package]] -name = "tonic-build" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9403f1bafde247186684b230dc6f38b5cd514584e8bec1dd32514be4745fa757" -dependencies = [ - "proc-macro2", - "prost-build", - "quote", - "syn", -] - [[package]] name = "tower" version = "0.4.13" @@ -5179,13 +3543,9 @@ checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" dependencies = [ "futures-core", "futures-util", - "indexmap", "pin-project", "pin-project-lite", - "rand 0.8.5", - "slab", "tokio", - "tokio-util 0.7.2", "tower-layer", "tower-service", "tracing", @@ -5205,9 +3565,9 @@ checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6" [[package]] name = "tracing" -version = "0.1.36" +version = "0.1.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fce9567bd60a67d08a16488756721ba392f24f29006402881e43b19aac64307" +checksum = "5d0ecdcb44a79f0fe9844f0c4f33a342cbcbb5117de8001e6ba0dc2351327d09" dependencies = [ "cfg-if 1.0.0", "log", @@ -5216,22 +3576,11 @@ dependencies = [ "tracing-core", ] -[[package]] -name = "tracing-appender" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09d48f71a791638519505cefafe162606f706c25592e4bde4d97600c0195312e" -dependencies = [ - "crossbeam-channel", - "time 0.3.9", - "tracing-subscriber 0.3.15", -] - [[package]] name = "tracing-attributes" -version = "0.1.22" +version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11c75893af559bc8e10716548bdef5cb2b983f8e637db9d0e15126b61b484ee2" +checksum = "cc6b8ad3567499f98a1db7a752b07a7c8c7c7c34c332ec00effb2b0027974b7c" dependencies = [ "proc-macro2", "quote", @@ -5239,23 +3588,13 @@ dependencies = [ ] [[package]] -name = "tracing-core" -version = "0.1.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aeea4303076558a00714b823f9ad67d58a3bbda1df83d8827d21193156e22f7" -dependencies = [ - "once_cell", - "valuable", -] - -[[package]] -name = "tracing-futures" -version = "0.2.5" +name = "tracing-core" +version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2" +checksum = "f54c8ca710e81886d498c2fd3331b56c93aa248d49de2222ad2742247c60072f" dependencies = [ - "pin-project", - "tracing", + "lazy_static", + "valuable", ] [[package]] @@ -5269,20 +3608,6 @@ dependencies = [ "tracing-core", ] -[[package]] -name = "tracing-opentelemetry" -version = "0.17.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbbe89715c1dbbb790059e2565353978564924ee85017b5fff365c872ff6721f" -dependencies = [ - "once_cell", - "opentelemetry", - "tracing", - "tracing-core", - "tracing-log", - "tracing-subscriber 0.3.15", -] - [[package]] name = "tracing-serde" version = "0.1.3" @@ -5302,7 +3627,7 @@ dependencies = [ "ansi_term", "chrono", "lazy_static", - "matchers 0.0.1", + "matchers", "regex", "serde", "serde_json", @@ -5315,24 +3640,6 @@ dependencies = [ "tracing-serde", ] -[[package]] -name = "tracing-subscriber" -version = "0.3.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60db860322da191b40952ad9affe65ea23e7dd6a5c442c2c42865810c6ab8e6b" -dependencies = [ - "ansi_term", - "matchers 0.1.0", - "once_cell", - "regex", - "sharded-slab", - "smallvec", - "thread_local", - "tracing", - "tracing-core", - "tracing-log", -] - [[package]] name = "try-lock" version = "0.2.3" @@ -5377,9 +3684,9 @@ checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992" [[package]] name = "unicode-normalization" -version = "0.1.19" +version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54590932941a9e9266f0832deed84ebe1bf2e4c9e4a3554d393d18f5e854bf9" +checksum = "854cbdc4f7bc6ae19c820d44abdc3277ac3e1b2b93db20a636825d9322fb60e6" dependencies = [ "tinyvec", ] @@ -5390,18 +3697,18 @@ version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7e8820f5d777f6224dc4be3632222971ac30164d4a258d595640799554ebfd99" -[[package]] -name = "unicode-width" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" - [[package]] name = "unicode-xid" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "957e51f3646910546462e67d5f7599b9e4fb8acdd304b087a6494730f9eebf04" +[[package]] +name = "untrusted" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" + [[package]] name = "url" version = "2.2.2" @@ -5415,26 +3722,19 @@ dependencies = [ ] [[package]] -name = "validator" -version = "0.12.0" +name = "urlencoding" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "841d6937c33ec6039d8071bcf72933146b5bbe378d645d8fa59bdadabfc2a249" -dependencies = [ - "idna", - "lazy_static", - "regex", - "serde", - "serde_derive", - "serde_json", - "url", - "validator_types", -] +checksum = "68b90931029ab9b034b300b797048cf23723400aa757e8a2bfb9d748102f9821" [[package]] -name = "validator_types" -version = "0.12.0" +name = "uuid" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad9680608df133af2c1ddd5eaf1ddce91d60d61b6bc51494ef326458365a470a" +checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" +dependencies = [ + "getrandom 0.2.6", +] [[package]] name = "valuable" @@ -5454,12 +3754,6 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" -[[package]] -name = "void" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" - [[package]] name = "want" version = "0.3.0" @@ -5513,6 +3807,18 @@ dependencies = [ "wasm-bindgen-shared", ] +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f741de44b75e14c35df886aff5f1eb73aa114fa5d4d00dcd37b5e01259bf3b2" +dependencies = [ + "cfg-if 1.0.0", + "js-sys", + "wasm-bindgen", + "web-sys", +] + [[package]] name = "wasm-bindgen-macro" version = "0.2.80" @@ -5543,334 +3849,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d554b7f530dee5964d9a9468d95c1f8b8acae4f282807e7d27d4b03099a46744" [[package]] -name = "wasmer-compiler-near" -version = "2.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34d09dc0ba83ddaceb9b0846ed11a6c26a449b69fa2709e0335d268f44491921" -dependencies = [ - "enumset", - "rkyv", - "smallvec", - "target-lexicon 0.12.3", - "thiserror", - "wasmer-types-near", - "wasmer-vm-near", - "wasmparser 0.78.2", -] - -[[package]] -name = "wasmer-compiler-singlepass-near" -version = "2.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86f34bf0625219766759851c1f92e0797787b8b10b424c0a273ee4e0328a2ff7" -dependencies = [ - "byteorder", - "dynasm", - "dynasmrt", - "lazy_static", - "memoffset", - "more-asserts", - "rayon", - "smallvec", - "wasmer-compiler-near", - "wasmer-types-near", - "wasmer-vm-near", -] - -[[package]] -name = "wasmer-engine-near" -version = "2.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa8353167be3099f3bd033cb9c8479a02d69917777cf4c2e52a09946d5582457" -dependencies = [ - "backtrace", - "enumset", - "lazy_static", - "memmap2", - "more-asserts", - "rustc-demangle", - "target-lexicon 0.12.3", - "thiserror", - "wasmer-compiler-near", - "wasmer-types-near", - "wasmer-vm-near", -] - -[[package]] -name = "wasmer-engine-universal-near" -version = "2.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c34fb4f6af2209a36c5e6ed407c9e057fdd2e722e762f702dbd8575896349c62" -dependencies = [ - "cfg-if 1.0.0", - "enumset", - "leb128", - "region 3.0.0", - "rkyv", - "thiserror", - "wasmer-compiler-near", - "wasmer-engine-near", - "wasmer-types-near", - "wasmer-vm-near", - "winapi", -] - -[[package]] -name = "wasmer-runtime-core-near" -version = "0.18.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a3fac37da3c625e98708c5dd92d3f642aaf700fd077168d3d0fff277ec6a165" -dependencies = [ - "bincode", - "blake3", - "borsh 0.9.3", - "cc", - "digest 0.8.1", - "errno", - "hex", - "indexmap", - "lazy_static", - "libc", - "nix", - "page_size", - "parking_lot 0.10.2", - "rustc_version 0.2.3", - "serde", - "serde-bench", - "serde_bytes", - "serde_derive", - "smallvec", - "target-lexicon 0.10.0", - "wasmparser 0.51.4", - "winapi", -] - -[[package]] -name = "wasmer-runtime-near" -version = "0.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "158e6fff11e5e1ef805af50637374d5bd43d92017beafa18992cdf7f3f7ae3e4" -dependencies = [ - "lazy_static", - "memmap", - "serde", - "serde_derive", - "wasmer-runtime-core-near", - "wasmer-singlepass-backend-near", -] - -[[package]] -name = "wasmer-singlepass-backend-near" -version = "0.18.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f6edd0ba6c0bcf9b279186d4dbe81649dda3e5ef38f586865943de4dcd653f8" -dependencies = [ - "bincode", - "borsh 0.9.3", - "byteorder", - "dynasm", - "dynasmrt", - "lazy_static", - "libc", - "nix", - "serde", - "serde_derive", - "smallvec", - "wasmer-runtime-core-near", -] - -[[package]] -name = "wasmer-types-near" -version = "2.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1131dfac4d92947acef554a75b433122ca635414c23934f53434ec0efc5994d" -dependencies = [ - "indexmap", - "rkyv", - "thiserror", -] - -[[package]] -name = "wasmer-vm-near" -version = "2.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a47f13d5c412974a38bba01a8b009e1e49bffbee45387198403b269a74d7374" -dependencies = [ - "backtrace", - "cc", - "cfg-if 1.0.0", - "indexmap", - "libc", - "memoffset", - "more-asserts", - "region 3.0.0", - "rkyv", - "thiserror", - "wasmer-types-near", - "winapi", -] - -[[package]] -name = "wasmparser" -version = "0.51.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aeb1956b19469d1c5e63e459d29e7b5aa0f558d9f16fcef09736f8a265e6c10a" - -[[package]] -name = "wasmparser" -version = "0.78.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52144d4c78e5cf8b055ceab8e5fa22814ce4315d6002ad32cfd914f37c12fd65" - -[[package]] -name = "wasmparser" -version = "0.84.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77dc97c22bb5ce49a47b745bed8812d30206eff5ef3af31424f2c1820c0974b2" -dependencies = [ - "indexmap", -] - -[[package]] -name = "wasmtime" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfdd1101bdfa0414a19018ec0a091951a20b695d4d04f858d49f6c4cc53cd8dd" -dependencies = [ - "anyhow", - "backtrace", - "bincode", - "cfg-if 1.0.0", - "indexmap", - "lazy_static", - "libc", - "log", - "object", - "once_cell", - "paste", - "psm", - "region 2.2.0", - "serde", - "target-lexicon 0.12.3", - "wasmparser 0.84.0", - "wasmtime-cranelift", - "wasmtime-environ", - "wasmtime-jit", - "wasmtime-runtime", - "winapi", -] - -[[package]] -name = "wasmtime-cranelift" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16e78edcfb0daa9a9579ac379d00e2d5a5b2a60c0d653c8c95e8412f2166acb9" -dependencies = [ - "anyhow", - "cranelift-codegen", - "cranelift-entity", - "cranelift-frontend", - "cranelift-native", - "cranelift-wasm", - "gimli", - "log", - "more-asserts", - "object", - "target-lexicon 0.12.3", - "thiserror", - "wasmparser 0.84.0", - "wasmtime-environ", -] - -[[package]] -name = "wasmtime-environ" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4201389132ec467981980549574b33fc70d493b40f2c045c8ce5c7b54fbad97e" -dependencies = [ - "anyhow", - "cranelift-entity", - "gimli", - "indexmap", - "log", - "more-asserts", - "object", - "serde", - "target-lexicon 0.12.3", - "thiserror", - "wasmparser 0.84.0", - "wasmtime-types", -] - -[[package]] -name = "wasmtime-jit" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1587ca7752d00862faa540d00fd28e5ccf1ac61ba19756449193f1153cb2b127" -dependencies = [ - "addr2line", - "anyhow", - "bincode", - "cfg-if 1.0.0", - "cpp_demangle", - "gimli", - "log", - "object", - "region 2.2.0", - "rustc-demangle", - "rustix", - "serde", - "target-lexicon 0.12.3", - "thiserror", - "wasmtime-environ", - "wasmtime-runtime", - "winapi", -] - -[[package]] -name = "wasmtime-jit-debug" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b27233ab6c8934b23171c64f215f902ef19d18c1712b46a0674286d1ef28d5dd" -dependencies = [ - "lazy_static", -] - -[[package]] -name = "wasmtime-runtime" -version = "0.37.0" +name = "web-sys" +version = "0.3.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47d3b0b8f13db47db59d616e498fe45295819d04a55f9921af29561827bdb816" +checksum = "7b17e741662c70c8bd24ac5c5b18de314a2c26c32bf8346ee1e6f53de919c283" dependencies = [ - "anyhow", - "backtrace", - "cc", - "cfg-if 1.0.0", - "indexmap", - "libc", - "log", - "mach", - "memoffset", - "more-asserts", - "rand 0.8.5", - "region 2.2.0", - "rustix", - "thiserror", - "wasmtime-environ", - "wasmtime-jit-debug", - "winapi", + "js-sys", + "wasm-bindgen", ] [[package]] -name = "wasmtime-types" -version = "0.37.0" +name = "webpki" +version = "0.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1630d9dca185299bec7f557a7e73b28742fe5590caf19df001422282a0a98ad1" +checksum = "b8e38c0608262c46d4a56202ebabdeb094cef7e560ca7a226c6bf055188aa4ea" dependencies = [ - "cranelift-entity", - "serde", - "thiserror", - "wasmparser 0.84.0", + "ring", + "untrusted", ] [[package]] @@ -5885,17 +3880,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "which" -version = "4.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c4fb54e6113b6a8772ee41c3404fb0301ac79604489467e0a9ce1f3e97c24ae" -dependencies = [ - "either", - "lazy_static", - "libc", -] - [[package]] name = "winapi" version = "0.3.9" @@ -5971,28 +3955,31 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" [[package]] -name = "xz2" -version = "0.1.6" +name = "winreg" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c179869f34fc7c01830d3ce7ea2086bc3a07e0d35289b667d0a8bf910258926c" +checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" dependencies = [ - "lzma-sys", + "winapi", ] [[package]] -name = "yaml-rust" -version = "0.4.5" +name = "wyz" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85" -dependencies = [ - "linked-hash-map", -] +checksum = "85e60b0d1b5f99db2556934e21937020776a5d31520bf169e851ac44e6420214" + +[[package]] +name = "xmlparser" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "114ba2b24d2167ef6d67d7d04c8cc86522b87f490025f39f0303b7db5bf5e3d8" [[package]] name = "zeroize" -version = "1.3.0" +version = "1.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4756f7db3f7b5574938c3eb1c117038b8e07f95ee6718c0efad4ac21508f1efd" +checksum = "94693807d016b2f2d2e14420eb3bfcca689311ff775dcf113d74ea624b7cdf07" dependencies = [ "zeroize_derive", ] @@ -6009,34 +3996,20 @@ dependencies = [ "synstructure", ] -[[package]] -name = "zeropool-bn" -version = "0.5.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71e61de68ede9ffdd69c01664f65a178c5188b73f78faa21f0936016a888ff7c" -dependencies = [ - "borsh 0.9.3", - "byteorder", - "crunchy", - "lazy_static", - "rand 0.8.5", - "rustc-hex", -] - [[package]] name = "zstd" -version = "0.10.2+zstd.1.5.2" +version = "0.11.2+zstd.1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f4a6bd64f22b5e3e94b4e238669ff9f10815c27a5180108b849d24174a83847" +checksum = "20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4" dependencies = [ "zstd-safe", ] [[package]] name = "zstd-safe" -version = "4.1.6+zstd.1.5.2" +version = "5.0.2+zstd.1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94b61c51bb270702d6167b8ce67340d2754b088d0c091b06e593aa772c3ee9bb" +checksum = "1d2a5585e04f9eea4b2a3d1eca508c4dee9592a89ef6f450c11719da0726f4db" dependencies = [ "libc", "zstd-sys", @@ -6044,9 +4017,9 @@ dependencies = [ [[package]] name = "zstd-sys" -version = "1.6.3+zstd.1.5.2" +version = "2.0.3+zstd.1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc49afa5c8d634e75761feda8c592051e7eeb4683ba827211eb0d731d3402ea8" +checksum = "44ccf97612ac95f3ccb89b2d7346b345e52f1c3019be4984f0455fb4ba991f8a" dependencies = [ "cc", "libc", diff --git a/Cargo.toml b/Cargo.toml index d5def444..49e40e57 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,42 +1,6 @@ -[package] -name = "indexer-explorer" -version = "0.10.31" -authors = ["Near Inc "] -edition = "2021" - -[dependencies] -actix = "0.13.0" -actix-rt = "2.2.0" -anyhow = "1.0.51" -base64 = "0.11" -bigdecimal = "=0.1.0" -borsh = "0.7.1" -cached = "0.23.0" -chrono = "0.4.19" -clap = { version = "3.1.6", features = ["color", "derive", "env"] } -diesel = { version = "1.4.7", features = ["postgres", "numeric", "serde_json"] } -# Using hacky diesel-derive-enum https://github.com/adwhit/diesel-derive-enum/issues/52 -diesel-derive-enum = { git = "https://github.com/khorolets/diesel-derive-enum.git", branch = "lookup-hack", features = ["postgres"] } -dotenv = "0.15.0" -futures = "0.3.5" -hex = "0.4" -itertools = "0.10.3" -# syn version conflict, replace with crates.io version once released -near-sdk = { git = "https://github.com/near/near-sdk-rs", rev="03487c184d37b0382dd9bd41c57466acad58fc1f" } -num-traits = "0.2.11" -openssl-probe = { version = "0.1.2" } -once_cell = "1.5.2" -r2d2 = "0.8.8" -serde = { version = "1", features = ["derive"] } -serde_json = "1.0.55" -tokio = { version = "1.1", features = ["sync", "time"] } -tokio-stream = { version = "0.1" } -tracing = "0.1.13" -tracing-subscriber = "0.2.4" -uint = { version = "0.8.3", default-features = false } - -actix-diesel = { git = "https://github.com/frol/actix-diesel", rev = "3a001986c89dfabfc3c448d8bae28525101b4992" } -near-indexer = { git = "https://github.com/near/nearcore", rev = "267e36e39fb5bb29c1df23c73afbcaa750ce96b1" } -near-crypto = { git = "https://github.com/near/nearcore", rev = "267e36e39fb5bb29c1df23c73afbcaa750ce96b1" } -near-client = { git = "https://github.com/near/nearcore", rev = "267e36e39fb5bb29c1df23c73afbcaa750ce96b1" } -near-o11y = { git = "https://github.com/near/nearcore", rev = "267e36e39fb5bb29c1df23c73afbcaa750ce96b1" } +[workspace] +members = [ + "indexer", + "database", + "circulating-supply" +] diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 0cfaab95..00000000 --- a/Dockerfile +++ /dev/null @@ -1,78 +0,0 @@ -# syntax=docker/dockerfile-upstream:experimental - -# ============================== BUILD ====================================== -FROM ubuntu:18.04 as build - -RUN apt-get update -qq && apt-get install -y \ - git \ - cmake \ - g++ \ - pkg-config \ - libssl-dev \ - curl \ - llvm \ - clang \ - libpq-dev \ - ca-certificates \ - && rm -rf /var/lib/apt/lists/* - -COPY ./rust-toolchain /tmp/rust-toolchain - -ENV RUSTUP_HOME=/usr/local/rustup \ - CARGO_HOME=/usr/local/cargo \ - PATH=/usr/local/cargo/bin:$PATH - -RUN curl https://sh.rustup.rs -sSf | \ - sh -s -- -y --no-modify-path --default-toolchain "$(cat /tmp/rust-toolchain)" - -RUN cargo install diesel_cli --no-default-features --features "postgres" --bin diesel - -WORKDIR /near - -# This is some clever stuff we do to build JUST the Cargo.toml dependencies first, so that Docker can cache them so long as Cargo.toml doesn't change -# We do this because building dependencies takes ~45 minutes -RUN cargo +"$(cat /tmp/rust-toolchain)" new --bin indexer-explorer -WORKDIR /near/indexer-explorer - -COPY ./Cargo.toml ./Cargo.toml -COPY ./Cargo.lock ./Cargo.lock - -ENV CARGO_TARGET_DIR=/tmp/target -ENV RUSTC_FLAGS='-C target-cpu=x86-64' -ENV PORTABLE=ON -RUN cargo +"$(cat /tmp/rust-toolchain)" build --release -RUN rm src/*.rs -RUN rm /tmp/target/release/indexer-explorer* - -# Now that the dependencies are built, copy just the rest of the Rust code in and build -# that too (so that a change in the run-in-docker.sh script doesn't invalidate the entire -# Docker cache for the Rust build) -COPY ./src ./src - -# This touch is necessary so that Rust doesn't skip the build (even though the source has completely changed... Rust cache is weird :P) -RUN touch src/main.rs - -RUN cargo +"$(cat /tmp/rust-toolchain)" build --release -p indexer-explorer - -# ============================== EXECUTION ====================================== -FROM ubuntu:18.04 as execution - -RUN apt-get update -qq && apt-get install -y \ - libssl-dev \ - libpq-dev \ - ca-certificates \ - && rm -rf /var/lib/apt/lists/* - -WORKDIR /near/indexer-explorer - -COPY --from=build /tmp/target/release/indexer-explorer . - -COPY --from=build /usr/local/cargo/bin/diesel . - -COPY ./migrations ./migrations - -COPY ./run-in-docker.sh . - -# Pass the BOOT_NODES environment variable to set boot nodes in the initialized genesis -# An arbitrary number of extra parameters to the indexer that runs can be set via CMD -ENTRYPOINT bash run-in-docker.sh ./diesel "${DATABASE_URL}" ./indexer-explorer diff --git a/README.md b/README.md index 9143148a..e7f58cc5 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # NEAR Indexer for Explorer -NEAR Indexer for Explorer is built on top of [NEAR Indexer microframework](https://github.com/nearprotocol/nearcore/tree/master/chain/indexer) to watch the network and store all the events in the PostgreSQL database. +NEAR Indexer for Explorer is built on top of [NEAR Lake Framework](https://github.com/near/near-lake-framework-rs) to watch the network and store all the events in the PostgreSQL database. ## Shared Public Access @@ -15,11 +15,9 @@ NOTE: Please, keep in mind that the access to the database is shared across ever ## Self-hosting -> **HEAD UP!** There is [a fork of Indexer for Explorer](https://github.com/khorolets/near-indexer-for-explorer) that is based on [NEAR Lake](https://near-indexers.io/docs/projects/near-lake-framework), and thus it is much lighter in terms of resources, so if you plan to run Indexer for Explorer on mainnet or testnet, strongly consider using the fork. Pagoda runs both upstream and the fork versions side by side to ensure extra stability. - The final setup consists of the following components: -* PostgreSQL database (you can run it locally or in the cloud), which can hold the whole history of the blockchain (as of January 2022, mainnet takes 1.1TB of data in PostgreSQL storage, and testnet takes 420GB) -* NEAR Indexer for Explorer binary that operates as a regular NEAR Protocol peer-to-peer node, so you will operate it as any other [Archival Node in NEAR](https://docs.near.org/docs/develop/node/archival/hardware-archival) +* PostgreSQL database (you can run it locally or in the cloud), which can hold the whole history of the blockchain (as of August 2022, mainnet takes 3TB of data in PostgreSQL storage, and testnet takes 1TB) +* NEAR Indexer for Explorer binary that operates as a NEAR Lake Framework based indexer, it requires [AWS S3 credentials](https://docs.near.org/tutorials/indexer/credentials) ### Prepare Development Environment @@ -41,15 +39,22 @@ Setup PostgreSQL database, create a database with the regular tools, and note th Clone this repository and open the project folder ```bash -$ git clone git@github.com:near/near-indexer-for-explorer.git +$ git clone https://github.com/near/near-indexer-for-explorer.git $ cd near-indexer-for-explorer ``` -You need to provide database credentials in `.env` file like below (replace `user`, `password`, `host` and `db_name` with yours): +You need to provide credentials via `.env` file for: +- database -```bash -$ echo "DATABASE_URL=postgres://user:password@host/db_name" > .env -``` + (replace `user`, `password`, `host` and `db_name` with yours) + ```bash + $ echo "DATABASE_URL=postgres://user:password@host/db_name" > .env + ``` +- AWS S3 (permission to read from buckets): + ```bash + $ echo "AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE" >> .env + $ echo "AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" >> .env + ``` Then you need to apply migrations to create necessary database structure. For this you'll need `diesel-cli`, you can install it like so: @@ -61,7 +66,7 @@ $ cargo install diesel_cli --no-default-features --features "postgres" And apply migrations ```bash -$ diesel migration run +$ cd database && diesel migration run ``` ### Compile NEAR Indexer for Explorer @@ -70,62 +75,39 @@ $ diesel migration run $ cargo build --release ``` -### Configure NEAR Indexer for Explorer - -To connect NEAR Indexer for Explorer to the specific chain you need to have necessary configs, you can generate it as follows: - -```bash -$ ./target/release/near-indexer --home-dir ~/.near/testnet init --chain-id testnet --download-config --download-genesis -``` - -The above code will download the official genesis config and generate necessary configs. You can replace `testnet` in the command above to different network ID (`betanet`, `mainnet`). - -These are the default config files that one could use just for the reference: - - [testnet config.json](https://s3-us-west-1.amazonaws.com/build.nearprotocol.com/nearcore-deploy/testnet/config.json) - - [betanet config.json](https://s3-us-west-1.amazonaws.com/build.nearprotocol.com/nearcore-deploy/betanet/config.json) - - [mainnet config.json](https://s3-us-west-1.amazonaws.com/build.nearprotocol.com/nearcore-deploy/mainnet/config.json) - -Configs for the specified network are in the `--home-dir` provided folder. We need to ensure that NEAR Indexer for Explorer follows -all the necessary shards, so `"tracked_shards"` parameters in `~/.near/testnet/config.json` needs to be configured properly. -For example, with a single shared network, you just add the shard #0 to the list: - -``` -... -"tracked_shards": [0], -... -``` - ### Run NEAR Indexer for Explorer -Command to run NEAR Indexer for Explorer have to contain sync mode. +Command to run NEAR Indexer for Explorer have to include the chain-id and start options: -You can choose NEAR Indexer for Explorer sync mode by setting what to stream: - - `sync-from-latest` - start indexing blocks from the latest finalized block - - `sync-from-interruption --delta ` - start indexing blocks from the block NEAR Indexer was interrupted last time but earlier for `` if provided - - `sync-from-block --height ` - start indexing blocks from the specific block height +You can choose NEAR Indexer for Explorer start options: + - `from-latest` - start indexing blocks from the latest finalized block + - `from-interruption` - start indexing blocks from the block NEAR Indexer was interrupted last time but earlier for `` if provided + - `from-block --height ` - start indexing blocks from the specific block height -Optionally you can tell Indexer to store data from genesis (Accounts and Access Keys) by adding key `--store-genesis` to the `run` command. +#### Storing genesis file +Unlike the original NEAR Indexer for Explorer you **can't** tell Indexer to store data from genesis (Accounts and Access Keys) by adding key `--store-genesis` to the `run` command. So please, ensure you took care about the genesis data in your database in order this indexer to work properly. This capability will be implemented eventually, it's progress can be tracked here: #327. -NEAR Indexer for Explorer works in strict mode by default, but you can disable it for specific amount of blocks. The strict mode means that every piece of data -will be retried to store to database in case of error. Errors may occur when the parent piece of data is still processed but the child piece is already -trying to be stored. So Indexer keeps retrying to store the data until success. However if you're running Indexer not from the genesis it is possible that you -really miss some of parent data and it'll be impossible to store child one, so you can disable strict mode for 1000 blocks to ensure you've passed the strong -relation data area and you're running Indexer where it is impossible to loose any piece of data. +#### Strict mode +NEAR Indexer for Explorer works in strict mode by default. In strict mode, the Indexer will ensure parent data exists before storing children, infinitely retrying until this condition is met. This is necessary as a parent (i.e. `block`) may still be processing while a child (i.e. `receipt`) is ready to be stored. This scenario will likely occur if you have not stored the genesis file or do not have all data prior to the block you start indexing from. In this case, you can disable strict mode to store data prior to the block you are concerned about, and then re-enable it once you have passed this block. -To disable strict mode you need to provide: +To disable strict mode provide the following command arugment: ``` --non-strict-mode ``` -Sometimes you may want to index block while sync process is happening, by default an indexer node is waiting for full sync to complete but you can enable indexing while the node is syncing by passing `--stream-while-syncing` - +#### Concurrency By default NEAR Indexer for Explorer processes only a single block at a time. You can adjust this with the `--concurrency` argument (when the blocks are mostly empty, it is fine to go with as many as 100 blocks of concurrency). +#### Starting So final command to run NEAR Indexer for Explorer can look like: ```bash -$ cargo run --release -- --home-dir ~/.near/testnet run --store-genesis --stream-while-syncing --non-strict-mode --concurrency 1 sync-from-latest +$ ./target/release/indexer-explorer \ + --non-strict-mode \ + --concurrency 1 \ + mainnet \ + from-latest ``` After the network is synced, you should see logs of every block height currently received by NEAR Indexer for Explorer. @@ -168,81 +150,10 @@ GRANT readonly TO explorer; $ PGPASSWORD="password" psql -h 127.0.0.1 -U explorer databasename ``` -## Syncing - -Whenever you run NEAR Indexer for Explorer for any network except localnet you'll need to sync with the network. This is required because it's a natural behavior of `nearcore` node and NEAR Indexer for Explorer is a wrapper for the regular `nearcore` node. In order to work and index the data your node must be synced with the network. This process can take a while, so we suggest to download a fresh backup of the `data` folder and put it in you `--home-dir` of your choice (by default it is `~/.near`) - -Running your NEAR Indexer for Explorer node on top of a backup data will reduce the time of syncing process because your node will download only missing data and it will take reasonable time. - -All the backups can be downloaded from the public S3 bucket which contains latest daily snapshots following the instruction [here](https://near-nodes.io/intro/node-data-snapshots). - -## Running NEAR Indexer for Explorer as archival node - -It's not necessary but in order to index everything in the network it is better to do it from the genesis. `nearcore` node is running in non-archival mode by default. That means that the node keeps data only for [5 last epochs](https://docs.near.org/concepts/basics/epoch). In order to index data from the genesis we need to turn the node in archival mode. - -To do it we need to update `config.json` located in `--home-dir` or your choice (by default it is `~/.near`). - -Find next keys in the config and update them as following: - -```json -{ - ... - "archive": true, - "tracked_shards": [0], - ... -} -``` - -The syncing process in archival mode can take a lot of time, so it's better to download a backup provided by NEAR and put it in your `data` folder. After that your node will need to sync only missing data and it should take reasonable time. - -All the backups can be downloaded from the public S3 bucket which contains latest daily snapshots following the instruction [here](https://near-nodes.io/intro/node-data-snapshots). - -See [this link](https://docs.near.org/integrator/exchange-integration#running-an-archival-node) for reference - -## Local debugging - -If you want to play with the code locally, it's better not to copy existing mainnet/testnet (it requires LOTS of memory), but to have your own small example. -You need to have empty DB (we suggest to use [Docker](https://hub.docker.com/_/postgres) for that). -Go through steps [above](https://github.com/near/near-indexer-for-explorer#self-hosting) until (including) diesel migration. -Then, - -```bash -$ cargo run --release -- --home-dir ~/.near/localnet init --chain-id localnet -``` - -Edit `~/.near/localnet/config.json` by adding tracking shards and archiving option (see [example above](https://github.com/near/near-indexer-for-explorer#running-near-indexer-for-explorer-as-archival-node)). - -```bash -$ cargo run -- --home-dir ~/.near/localnet run --store-genesis sync-from-latest -``` - -Congrats, the blocks are being produced right now! -There should be some lines in the DB. -Now, we need to generate some activity to add new examples. +## Deployments +Both `indexer-explorer` and `circulating-supply` binaries are run within Docker, their `Dockerfile`s can be found within their respective directoires/workspaces. Docker images are built using Google Cloud Build and then deployed to Google Cloud Run. The following commands can be used to build the Docker images: ```bash -$ npm i -g near-cli -$ NEAR_ENV=local near create-account awesome.test.near --initialBalance 30 --masterAccount test.near --keyPath=~/.near/localnet/validator_key.json -$ NEAR_ENV=local near send test.near awesome.test.near 5 -``` - -All available commands are [here](https://github.com/near/near-cli#near-cli-command-line-interface). - -You can stop and re-run the example at any time. -Blocks will continue producing from the last state. - -## Troubleshooting - -When operating normally, you should see "INFO indexer_for_explorer: Block height ..." messages in the logs. - -### The node is fully synced and running, but no indexer messages and no transactions in the database (not indexing) - -Make sure the blocks you want to save exist on the node. Check them via [JSON RPC](https://docs.near.org/docs/api/rpc#block-details): - +$ docker build -f ./indexer/Dockerfile . +$ docker build -f ./circulating-supply/Dockerfile . ``` -curl http://127.0.0.1:3030/ -X POST --header 'Content-type: application/json' --data '{"jsonrpc": "2.0", "id": "dontcare", "method": "block", "params": {"block_id": 9820214}}' -``` - -NOTE: Block #9820214 is the first block after genesis block (#9820210) on Mainnet. - -If it returns an error that the block does not exist or missing, it means that your node does not have the necessary data. Your options here are to start from the blocks that are recorded on the node or start an archival node (see above) and make sure you have the full network history (either use a backup or let the node sync from scratch (it is quite slow, so backup is recommended)) diff --git a/TROBLESHOOTING.md b/TROBLESHOOTING.md index 16963631..98b53b41 100644 --- a/TROBLESHOOTING.md +++ b/TROBLESHOOTING.md @@ -76,6 +76,8 @@ Example of not fine indexer logs: For now, we want to try to “skip” that block. In order to achieve this, we would run the indexer syncing process from the block height number following for the one where we have stuck. +**WARNING:** This mode should only be used when there is no other way to get Indexer for Explorer unstuck and we want to trade correctness for livability of Explorer and Wallet for 99.999% users. After the incidents where some of the blocks were skipped, we MUST go back to fix the bug and re-index the borked blocks to ensure full consistency of the database! + If the stuck block height is 47961813 ```bash diff --git a/circulating-supply/Cargo.toml b/circulating-supply/Cargo.toml new file mode 100644 index 00000000..9648034d --- /dev/null +++ b/circulating-supply/Cargo.toml @@ -0,0 +1,29 @@ +[package] +name = "circulating-supply" +rust-version = "1.64" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +actix = "0.13.0" +anyhow = "1.0.51" +bigdecimal = "=0.1.0" +base64 = "0.11" +chrono = "0.4.19" +dotenv = "0.15.0" +# syn version conflict, replace with crates.io version once released +near-sdk = { git = "https://github.com/near/near-sdk-rs", rev="03487c184d37b0382dd9bd41c57466acad58fc1f" } +tokio = { version = "1.1", features = ["sync", "time"] } +tracing = "0.1.13" +tracing-subscriber = "0.2.4" +uint = { version = "0.8.3", default-features = false } + +near-indexer-primitives = "0.14" +near-jsonrpc-client = "0.4.0-beta.0" +# Remove manual base64 decoding of lockup state when upgrading to 0.15 +# https://github.com/khorolets/near-indexer-for-explorer/blob/master-lake/circulating_supply/src/lockup.rs#L60 +near-jsonrpc-primitives = "0.14.0" + +explorer-database = { path = '../database' } diff --git a/circulating-supply/Dockerfile b/circulating-supply/Dockerfile new file mode 100644 index 00000000..9851ebbe --- /dev/null +++ b/circulating-supply/Dockerfile @@ -0,0 +1,15 @@ +FROM rust:1.64 AS builder +WORKDIR /tmp/ +COPY Cargo.toml Cargo.lock ./ +COPY database database +# Copy 'indexer' because is member of the workspace but is not compiled or added to the +# output image. +COPY indexer indexer +COPY circulating-supply circulating-supply +RUN cargo build -p circulating-supply --release + +FROM ubuntu:20.04 +RUN apt update && apt install -yy openssl ca-certificates +RUN apt-get install libpq5 -y +COPY --from=builder /tmp/target/release/circulating-supply . +ENTRYPOINT [ "./circulating-supply" ] diff --git a/circulating-supply/src/account_details.rs b/circulating-supply/src/account_details.rs new file mode 100644 index 00000000..81a48430 --- /dev/null +++ b/circulating-supply/src/account_details.rs @@ -0,0 +1,59 @@ +use anyhow::Context; + +use near_jsonrpc_client::{methods, JsonRpcClient}; +use near_jsonrpc_primitives::types::query::QueryResponseKind; + +pub(crate) async fn get_account_balance( + rpc_client: &JsonRpcClient, + account_id: &near_indexer_primitives::types::AccountId, + block_height: &near_indexer_primitives::types::BlockHeight, +) -> anyhow::Result { + get_account_view_for_block_height(rpc_client, account_id, block_height) + .await + .map(|account| account.amount) + .with_context(|| format!("Unable to get account balance for {}", account_id)) +} + +pub(crate) async fn get_contract_code_hash( + rpc_client: &JsonRpcClient, + account_id: &near_indexer_primitives::types::AccountId, + block_height: &near_indexer_primitives::types::BlockHeight, +) -> anyhow::Result { + get_account_view_for_block_height(rpc_client, account_id, block_height) + .await + .map(|account| account.code_hash) + .with_context(|| format!("Unable to get contract code hash for {}", account_id)) +} + +async fn get_account_view_for_block_height( + rpc_client: &JsonRpcClient, + account_id: &near_indexer_primitives::types::AccountId, + block_height: &near_indexer_primitives::types::BlockHeight, +) -> anyhow::Result { + let block_reference = near_indexer_primitives::types::BlockReference::BlockId( + near_indexer_primitives::types::BlockId::Height(*block_height), + ); + let request = near_indexer_primitives::views::QueryRequest::ViewAccount { + account_id: account_id.clone(), + }; + let query = methods::query::RpcQueryRequest { + block_reference, + request, + }; + + let account_response = rpc_client.call(query).await.with_context(|| { + format!( + "Failed to deliver ViewAccount for account {}, block {}", + account_id, block_height + ) + })?; + + match account_response.kind { + QueryResponseKind::ViewAccount(account) => Ok(account), + _ => anyhow::bail!( + "Failed to extract ViewAccount response for account {}, block {}", + account_id, + block_height + ), + } +} diff --git a/src/aggregated/circulating_supply/lockup.rs b/circulating-supply/src/lockup.rs similarity index 85% rename from src/aggregated/circulating_supply/lockup.rs rename to circulating-supply/src/lockup.rs index 2ff4addc..2a053c07 100644 --- a/src/aggregated/circulating_supply/lockup.rs +++ b/circulating-supply/src/lockup.rs @@ -1,10 +1,9 @@ use std::time::Duration; -use actix::Addr; use anyhow::Context; -use near_client::{Query, ViewClientActor}; -use near_indexer::near_primitives; +use near_jsonrpc_client::{methods, JsonRpcClient}; +use near_jsonrpc_primitives::types::query::QueryResponseKind; use near_sdk::borsh::BorshDeserialize; use near_sdk::json_types::{U128, U64}; @@ -17,38 +16,31 @@ use super::lockup_types::{ pub(super) const TRANSFERS_ENABLED: Duration = Duration::from_nanos(1602614338293769340); pub(super) async fn get_lockup_contract_state( - view_client: &Addr, - account_id: &near_primitives::types::AccountId, - block_height: &near_primitives::types::BlockHeight, + rpc_client: &JsonRpcClient, + account_id: &near_indexer_primitives::types::AccountId, + block_height: &near_indexer_primitives::types::BlockHeight, ) -> anyhow::Result { - let block_reference = near_primitives::types::BlockReference::BlockId( - near_primitives::types::BlockId::Height(*block_height), + let block_reference = near_indexer_primitives::types::BlockReference::BlockId( + near_indexer_primitives::types::BlockId::Height(*block_height), ); - let request = near_primitives::views::QueryRequest::ViewState { + let request = near_indexer_primitives::views::QueryRequest::ViewState { account_id: account_id.clone(), prefix: vec![].into(), - include_proof: false, }; - let query = Query::new(block_reference, request); + let query = methods::query::RpcQueryRequest { + block_reference, + request, + }; - let state_response = view_client - .send(query) - .await - .with_context(|| { - format!( - "Failed to deliver ViewState for lockup contract {}, block_height {}", - account_id, block_height - ) - })? - .with_context(|| { - format!( - "Invalid ViewState query for lockup contract {}, block_height {}", - account_id, block_height - ) - })?; + let state_response = rpc_client.call(query).await.with_context(|| { + format!( + "Failed to deliver ViewState for lockup contract {}, block_height {}", + account_id, block_height + ) + })?; let view_state_result = match state_response.kind { - near_primitives::views::QueryResponseKind::ViewState(x) => x, + QueryResponseKind::ViewState(state) => state, _ => { anyhow::bail!( "Failed to extract ViewState response for lockup contract {}, block_height {}", @@ -57,6 +49,7 @@ pub(super) async fn get_lockup_contract_state( ) } }; + let view_state = view_state_result.values.get(0).with_context(|| { format!( "Failed to find encoded lockup contract for {}, block_height {}", @@ -64,7 +57,10 @@ pub(super) async fn get_lockup_contract_state( ) })?; - let mut state = LockupContract::try_from_slice(&view_state.value) + let decoded_view_state = base64::decode(&view_state.value) + .context(format!("Failed to decode lockup state for: {}", account_id))?; + + let mut state = LockupContract::try_from_slice(&decoded_view_state) .with_context(|| format!("Failed to construct LockupContract for {}", account_id))?; // If owner of the lockup account didn't call the @@ -81,8 +77,8 @@ pub(super) async fn get_lockup_contract_state( // https://github.com/near/core-contracts/pull/136 // For each contract, we should choose the logic based on the binary version of the contract pub(super) fn is_bug_inside_contract( - code_hash: &near_primitives::hash::CryptoHash, - account_id: &near_primitives::types::AccountId, + code_hash: &near_indexer_primitives::CryptoHash, + account_id: &near_indexer_primitives::types::AccountId, ) -> anyhow::Result { match &*code_hash.to_string() { // The first implementation, with the bug diff --git a/src/aggregated/circulating_supply/lockup_types.rs b/circulating-supply/src/lockup_types.rs similarity index 100% rename from src/aggregated/circulating_supply/lockup_types.rs rename to circulating-supply/src/lockup_types.rs diff --git a/src/aggregated/circulating_supply/mod.rs b/circulating-supply/src/main.rs similarity index 57% rename from src/aggregated/circulating_supply/mod.rs rename to circulating-supply/src/main.rs index 84629d60..3fa68423 100644 --- a/src/aggregated/circulating_supply/mod.rs +++ b/circulating-supply/src/main.rs @@ -2,39 +2,59 @@ use std::ops::{Add, Sub}; use std::str::FromStr; use std::time::{Duration, SystemTime}; -use actix::Addr; -use actix_diesel::Database; use anyhow::Context; use bigdecimal::{BigDecimal, ToPrimitive}; use chrono::NaiveDateTime; -use diesel::PgConnection; use tracing::{error, info, warn}; -use near_indexer::near_primitives; +use near_jsonrpc_client::{methods, JsonRpcClient}; -use crate::aggregated::{account_details, circulating_supply}; -use crate::db_adapters::accounts; -use crate::db_adapters::aggregated::circulating_supply::{ - add_circulating_supply, get_precomputed_circulating_supply_for_timestamp, -}; -use crate::db_adapters::blocks; -use crate::models; -use crate::models::aggregated::circulating_supply::CirculatingSupply; +use explorer_database::{adapters, models}; +mod account_details; mod lockup; mod lockup_types; const DAY: Duration = Duration::from_secs(60 * 60 * 24); const RETRY_DURATION: Duration = Duration::from_secs(60 * 60 * 2); +const CIRCULATING_SUPPLY: &str = "circulating_supply"; + +#[actix::main] +async fn main() { + dotenv::dotenv().ok(); + + let subscriber = tracing_subscriber::fmt() + .with_env_filter(tracing_subscriber::EnvFilter::from_default_env()); + + if std::env::var("ENABLE_JSON_LOGS").is_ok() { + subscriber.json().init() + } else { + subscriber.compact().init() + } + + let pool = models::establish_connection( + &std::env::var("DATABASE_URL") + .expect("DATABASE_URL must be set in either .env or environment "), + ); + + let rpc_client = JsonRpcClient::connect( + std::env::var("RPC_URL").expect("RPC_URL must be set in either .env or environment"), + ); + + info!(target: crate::CIRCULATING_SUPPLY, "Starting calculations"); + + run_circulating_supply_computation(rpc_client, pool).await; +} + // Compute circulating supply on a daily basis, starting from 13 Oct 2020 // (Transfers enabled moment on the Mainnet), and put it to the Indexer DB. // Circulating supply is calculated by the formula: // total_supply - sum(locked_tokens_on_each_lockup) - sum(locked_foundation_account) // The value is always computed for the last block in a day (UTC). -pub(super) async fn run_circulating_supply_computation( - view_client: Addr, - pool: Database, +pub async fn run_circulating_supply_computation( + rpc_client: JsonRpcClient, + pool: explorer_database::actix_diesel::Database, ) { // We perform actual computations 00:10 UTC each day to be sure that the data is finalized let mut day_to_compute = lockup::TRANSFERS_ENABLED @@ -50,20 +70,25 @@ pub(super) async fn run_circulating_supply_computation( .expect("Time went backwards"); if now < day_to_compute { + info!( + target: crate::CIRCULATING_SUPPLY, + "Waiting until {} to resume calculations", + NaiveDateTime::from_timestamp(day_to_compute.as_secs() as i64, 0) + ); tokio::time::sleep_until(tokio::time::Instant::now().add(day_to_compute.sub(now))) .await; } - wait_for_loading_needed_blocks(&view_client, &day_to_compute).await; + wait_for_loading_needed_blocks(&rpc_client, &day_to_compute).await; - match check_and_collect_daily_circulating_supply(&view_client, &pool, &day_to_compute).await + match check_and_collect_daily_circulating_supply(&rpc_client, &pool, &day_to_compute).await { Ok(_) => { day_to_compute = day_to_compute.add(DAY); } Err(err) => { error!( - target: crate::AGGREGATED, - "Failed to compute circulating supply for {}: {}. Retry in {} hours", + target: crate::CIRCULATING_SUPPLY, + "Failed to compute circulating supply for {}: {:#}. Retry in {} hours", NaiveDateTime::from_timestamp(day_to_compute.as_secs() as i64, 0).date(), err, RETRY_DURATION.as_secs() / 60 / 60, @@ -75,31 +100,37 @@ pub(super) async fn run_circulating_supply_computation( } async fn check_and_collect_daily_circulating_supply( - view_client: &Addr, - pool: &Database, + rpc_client: &JsonRpcClient, + pool: &explorer_database::actix_diesel::Database, request_datetime: &Duration, -) -> anyhow::Result> { - let start_of_day = request_datetime.as_nanos() - - request_datetime.as_nanos() % circulating_supply::DAY.as_nanos(); +) -> anyhow::Result> { + let start_of_day = + request_datetime.as_nanos() - request_datetime.as_nanos() % crate::DAY.as_nanos(); let printable_date = NaiveDateTime::from_timestamp(request_datetime.as_secs() as i64, 0).date(); - let block = blocks::get_latest_block_before_timestamp(pool, start_of_day as u64).await?; + let block = + adapters::blocks::get_latest_block_before_timestamp(pool, start_of_day as u64).await?; let block_timestamp = block .block_timestamp .to_u64() .context("`block_timestamp` expected to be u64")?; - match get_precomputed_circulating_supply_for_timestamp(pool, block_timestamp).await { + match adapters::aggregated::circulating_supply::get_precomputed_circulating_supply_for_timestamp( + pool, + block_timestamp, + ) + .await + { Ok(None) => { info!( - target: crate::AGGREGATED, + target: crate::CIRCULATING_SUPPLY, "Computing circulating supply for {} (timestamp {})", printable_date, block_timestamp ); - let supply = compute_circulating_supply_for_block(pool, view_client, &block).await?; - add_circulating_supply(pool, &supply).await; + let supply = compute_circulating_supply_for_block(pool, rpc_client, &block).await?; + adapters::aggregated::circulating_supply::add_circulating_supply(pool, &supply).await; info!( - target: crate::AGGREGATED, + target: crate::CIRCULATING_SUPPLY, "Circulating supply for {} (timestamp {}) is {}", printable_date, block_timestamp, @@ -109,7 +140,7 @@ async fn check_and_collect_daily_circulating_supply( } Ok(Some(supply)) => { info!( - target: crate::AGGREGATED, + target: crate::CIRCULATING_SUPPLY, "Circulating supply for {} (timestamp {}) was already computed: {}", printable_date, block_timestamp, @@ -122,10 +153,10 @@ async fn check_and_collect_daily_circulating_supply( } async fn compute_circulating_supply_for_block( - pool: &Database, - view_client: &Addr, + pool: &explorer_database::actix_diesel::Database, + rpc_client: &JsonRpcClient, block: &models::Block, -) -> anyhow::Result { +) -> anyhow::Result { let block_timestamp = block .block_timestamp .to_u64() @@ -141,23 +172,22 @@ async fn compute_circulating_supply_for_block( .context("`total_supply` expected to be u128")?; let lockup_account_ids = - accounts::get_lockup_account_ids_at_block_height(pool, &block_height).await?; + adapters::accounts::get_lockup_account_ids_at_block_height(pool, &block_height).await?; let mut lockups_locked_tokens: u128 = 0; let mut unfinished_lockup_contracts_count: i32 = 0; for lockup_account_id in &lockup_account_ids { - let state = - lockup::get_lockup_contract_state(view_client, lockup_account_id, &block_height) - .await - .with_context(|| { - format!( - "Failed to get lockup contract details for {}", - lockup_account_id - ) - })?; + let state = lockup::get_lockup_contract_state(rpc_client, lockup_account_id, &block_height) + .await + .with_context(|| { + format!( + "Failed to get lockup contract details for {}", + lockup_account_id + ) + })?; let code_hash = - account_details::get_contract_code_hash(view_client, lockup_account_id, &block_height) + account_details::get_contract_code_hash(rpc_client, lockup_account_id, &block_height) .await?; let is_lockup_with_bug = lockup::is_bug_inside_contract(&code_hash, lockup_account_id)?; let locked_amount = state @@ -170,21 +200,21 @@ async fn compute_circulating_supply_for_block( } // The list is taken from the conversation with Yessin - let foundation_locked_account_ids: [near_primitives::types::AccountId; 2] = [ - near_primitives::types::AccountId::from_str("lockup.near") + let foundation_locked_account_ids: [near_indexer_primitives::types::AccountId; 2] = [ + near_indexer_primitives::types::AccountId::from_str("lockup.near") .expect("lockup.near expected to be a valid AccountId"), - near_primitives::types::AccountId::from_str("contributors.near") + near_indexer_primitives::types::AccountId::from_str("contributors.near") .expect("contributors.near expected to be a valid AccountId"), ]; let mut foundation_locked_tokens: u128 = 0; for account_id in &foundation_locked_account_ids { foundation_locked_tokens += - account_details::get_account_balance(view_client, account_id, &block_height).await?; + account_details::get_account_balance(rpc_client, account_id, &block_height).await?; } let circulating_supply: u128 = total_supply - foundation_locked_tokens - lockups_locked_tokens; - Ok(CirculatingSupply { + Ok(models::aggregated::circulating_supply::CirculatingSupply { computed_at_block_timestamp: BigDecimal::from(block_timestamp), computed_at_block_hash: (&block.block_hash).to_string(), circulating_tokens_supply: BigDecimal::from_str(&circulating_supply.to_string()) @@ -200,48 +230,43 @@ async fn compute_circulating_supply_for_block( }) } -async fn wait_for_loading_needed_blocks( - view_client: &Addr, - day_to_compute: &Duration, -) { +async fn wait_for_loading_needed_blocks(rpc_client: &JsonRpcClient, day_to_compute: &Duration) { loop { - match get_final_block_timestamp(view_client).await { + match get_final_block_timestamp(rpc_client).await { Ok(timestamp) => { if timestamp > *day_to_compute { return; } warn!( - target: crate::AGGREGATED, + target: crate::CIRCULATING_SUPPLY, "Blocks are not loaded to calculate circulating supply for {}. Wait for {} hours", NaiveDateTime::from_timestamp(day_to_compute.as_secs() as i64, 0).date(), - circulating_supply::RETRY_DURATION.as_secs() / 60 / 60, + crate::RETRY_DURATION.as_secs() / 60 / 60, ); } Err(err) => { error!( - target: crate::AGGREGATED, + target: crate::CIRCULATING_SUPPLY, "Failed to get latest block timestamp: {}. Retry in {} hours", err, - circulating_supply::RETRY_DURATION.as_secs() / 60 / 60, + crate::RETRY_DURATION.as_secs() / 60 / 60, ); } } - tokio::time::sleep(circulating_supply::RETRY_DURATION).await; + tokio::time::sleep(crate::RETRY_DURATION).await; } } -async fn get_final_block_timestamp( - view_client: &Addr, -) -> anyhow::Result { - let block_reference = - near_primitives::types::BlockReference::Finality(near_primitives::types::Finality::Final); - let query = near_client::GetBlock(block_reference); +async fn get_final_block_timestamp(rpc_client: &JsonRpcClient) -> anyhow::Result { + let block_reference = near_indexer_primitives::types::BlockReference::Finality( + near_indexer_primitives::types::Finality::Final, + ); + let query = methods::block::RpcBlockRequest { block_reference }; - let block_response = view_client - .send(query) + let block_response = rpc_client + .call(query) .await - .context("Failed to deliver response")? - .context("Invalid request")?; + .context("Failed to deliver response")?; Ok(Duration::from_nanos(block_response.header.timestamp)) } diff --git a/database/Cargo.toml b/database/Cargo.toml new file mode 100644 index 00000000..456de9bf --- /dev/null +++ b/database/Cargo.toml @@ -0,0 +1,27 @@ +[package] +name = "explorer-database" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +anyhow = "1.0.51" +base64 = "0.11" +bigdecimal = "=0.1.0" +diesel = { version = "1.4.7", features = ["postgres", "numeric", "serde_json"] } +# Using hacky diesel-derive-enum https://github.com/adwhit/diesel-derive-enum/issues/52 +diesel-derive-enum = { git = "https://github.com/khorolets/diesel-derive-enum.git", branch = "lookup-hack", features = ["postgres"] } +cached = "0.23.0" +futures = "0.3.5" +hex = "0.4" +num-traits = "0.2.11" +serde = { version = "1", features = ["derive"] } +serde_json = "1.0.55" +tracing = "0.1.13" +tokio = { version = "1.1", features = ["sync", "time"] } + +actix-diesel = { git = "https://github.com/frol/actix-diesel", rev = "3a001986c89dfabfc3c448d8bae28525101b4992" } +near-indexer-primitives = "0.14" +near-primitives = "0.14" +near-crypto = "0.14" diff --git a/diesel.toml b/database/diesel.toml similarity index 100% rename from diesel.toml rename to database/diesel.toml diff --git a/migrations/00000000000000_diesel_initial_setup/down.sql b/database/migrations/00000000000000_diesel_initial_setup/down.sql similarity index 100% rename from migrations/00000000000000_diesel_initial_setup/down.sql rename to database/migrations/00000000000000_diesel_initial_setup/down.sql diff --git a/migrations/00000000000000_diesel_initial_setup/up.sql b/database/migrations/00000000000000_diesel_initial_setup/up.sql similarity index 100% rename from migrations/00000000000000_diesel_initial_setup/up.sql rename to database/migrations/00000000000000_diesel_initial_setup/up.sql diff --git a/migrations/2020-12-07-153402_initial_schema/down.sql b/database/migrations/2020-12-07-153402_initial_schema/down.sql similarity index 100% rename from migrations/2020-12-07-153402_initial_schema/down.sql rename to database/migrations/2020-12-07-153402_initial_schema/down.sql diff --git a/migrations/2020-12-07-153402_initial_schema/up.sql b/database/migrations/2020-12-07-153402_initial_schema/up.sql similarity index 100% rename from migrations/2020-12-07-153402_initial_schema/up.sql rename to database/migrations/2020-12-07-153402_initial_schema/up.sql diff --git a/migrations/2021-01-14-170424_index-receipt-originated-from-transaction-hash/down.sql b/database/migrations/2021-01-14-170424_index-receipt-originated-from-transaction-hash/down.sql similarity index 100% rename from migrations/2021-01-14-170424_index-receipt-originated-from-transaction-hash/down.sql rename to database/migrations/2021-01-14-170424_index-receipt-originated-from-transaction-hash/down.sql diff --git a/migrations/2021-01-14-170424_index-receipt-originated-from-transaction-hash/up.sql b/database/migrations/2021-01-14-170424_index-receipt-originated-from-transaction-hash/up.sql similarity index 100% rename from migrations/2021-01-14-170424_index-receipt-originated-from-transaction-hash/up.sql rename to database/migrations/2021-01-14-170424_index-receipt-originated-from-transaction-hash/up.sql diff --git a/migrations/2021-01-20-152056_index-transactions-receiver-account-id/down.sql b/database/migrations/2021-01-20-152056_index-transactions-receiver-account-id/down.sql similarity index 100% rename from migrations/2021-01-20-152056_index-transactions-receiver-account-id/down.sql rename to database/migrations/2021-01-20-152056_index-transactions-receiver-account-id/down.sql diff --git a/migrations/2021-01-20-152056_index-transactions-receiver-account-id/up.sql b/database/migrations/2021-01-20-152056_index-transactions-receiver-account-id/up.sql similarity index 100% rename from migrations/2021-01-20-152056_index-transactions-receiver-account-id/up.sql rename to database/migrations/2021-01-20-152056_index-transactions-receiver-account-id/up.sql diff --git a/migrations/2021-03-11-123839_index-action-kind-and-status/down.sql b/database/migrations/2021-03-11-123839_index-action-kind-and-status/down.sql similarity index 100% rename from migrations/2021-03-11-123839_index-action-kind-and-status/down.sql rename to database/migrations/2021-03-11-123839_index-action-kind-and-status/down.sql diff --git a/migrations/2021-03-11-123839_index-action-kind-and-status/up.sql b/database/migrations/2021-03-11-123839_index-action-kind-and-status/up.sql similarity index 100% rename from migrations/2021-03-11-123839_index-action-kind-and-status/up.sql rename to database/migrations/2021-03-11-123839_index-action-kind-and-status/up.sql diff --git a/migrations/2021-04-22-090505_execution_outcomes_replace_chunk_relation_with_shard_id/down.sql b/database/migrations/2021-04-22-090505_execution_outcomes_replace_chunk_relation_with_shard_id/down.sql similarity index 100% rename from migrations/2021-04-22-090505_execution_outcomes_replace_chunk_relation_with_shard_id/down.sql rename to database/migrations/2021-04-22-090505_execution_outcomes_replace_chunk_relation_with_shard_id/down.sql diff --git a/migrations/2021-04-22-090505_execution_outcomes_replace_chunk_relation_with_shard_id/up.sql b/database/migrations/2021-04-22-090505_execution_outcomes_replace_chunk_relation_with_shard_id/up.sql similarity index 100% rename from migrations/2021-04-22-090505_execution_outcomes_replace_chunk_relation_with_shard_id/up.sql rename to database/migrations/2021-04-22-090505_execution_outcomes_replace_chunk_relation_with_shard_id/up.sql diff --git a/migrations/2021-04-28-154439_denormalize_action_receipt_actions/down.sql b/database/migrations/2021-04-28-154439_denormalize_action_receipt_actions/down.sql similarity index 100% rename from migrations/2021-04-28-154439_denormalize_action_receipt_actions/down.sql rename to database/migrations/2021-04-28-154439_denormalize_action_receipt_actions/down.sql diff --git a/migrations/2021-04-28-154439_denormalize_action_receipt_actions/up.sql b/database/migrations/2021-04-28-154439_denormalize_action_receipt_actions/up.sql similarity index 100% rename from migrations/2021-04-28-154439_denormalize_action_receipt_actions/up.sql rename to database/migrations/2021-04-28-154439_denormalize_action_receipt_actions/up.sql diff --git a/migrations/2021-05-06-093622_additional_indexes_for_action_receipt_actions/down.sql b/database/migrations/2021-05-06-093622_additional_indexes_for_action_receipt_actions/down.sql similarity index 100% rename from migrations/2021-05-06-093622_additional_indexes_for_action_receipt_actions/down.sql rename to database/migrations/2021-05-06-093622_additional_indexes_for_action_receipt_actions/down.sql diff --git a/migrations/2021-05-06-093622_additional_indexes_for_action_receipt_actions/up.sql b/database/migrations/2021-05-06-093622_additional_indexes_for_action_receipt_actions/up.sql similarity index 100% rename from migrations/2021-05-06-093622_additional_indexes_for_action_receipt_actions/up.sql rename to database/migrations/2021-05-06-093622_additional_indexes_for_action_receipt_actions/up.sql diff --git a/migrations/2021-05-07-115559_convert_args_base64_to_args_json/down.sql b/database/migrations/2021-05-07-115559_convert_args_base64_to_args_json/down.sql similarity index 100% rename from migrations/2021-05-07-115559_convert_args_base64_to_args_json/down.sql rename to database/migrations/2021-05-07-115559_convert_args_base64_to_args_json/down.sql diff --git a/migrations/2021-05-07-115559_convert_args_base64_to_args_json/up.sql b/database/migrations/2021-05-07-115559_convert_args_base64_to_args_json/up.sql similarity index 100% rename from migrations/2021-05-07-115559_convert_args_base64_to_args_json/up.sql rename to database/migrations/2021-05-07-115559_convert_args_base64_to_args_json/up.sql diff --git a/migrations/2021-05-10-084700_indexer_on_args_field/down.sql b/database/migrations/2021-05-10-084700_indexer_on_args_field/down.sql similarity index 100% rename from migrations/2021-05-10-084700_indexer_on_args_field/down.sql rename to database/migrations/2021-05-10-084700_indexer_on_args_field/down.sql diff --git a/migrations/2021-05-10-084700_indexer_on_args_field/up.sql b/database/migrations/2021-05-10-084700_indexer_on_args_field/up.sql similarity index 100% rename from migrations/2021-05-10-084700_indexer_on_args_field/up.sql rename to database/migrations/2021-05-10-084700_indexer_on_args_field/up.sql diff --git a/migrations/2021-05-27-154211_account_changes_unique_idx/down.sql b/database/migrations/2021-05-27-154211_account_changes_unique_idx/down.sql similarity index 100% rename from migrations/2021-05-27-154211_account_changes_unique_idx/down.sql rename to database/migrations/2021-05-27-154211_account_changes_unique_idx/down.sql diff --git a/migrations/2021-05-27-154211_account_changes_unique_idx/up.sql b/database/migrations/2021-05-27-154211_account_changes_unique_idx/up.sql similarity index 100% rename from migrations/2021-05-27-154211_account_changes_unique_idx/up.sql rename to database/migrations/2021-05-27-154211_account_changes_unique_idx/up.sql diff --git a/migrations/2021-06-02-173100_add_migration_state_change_reason_kind/down.sql b/database/migrations/2021-06-02-173100_add_migration_state_change_reason_kind/down.sql similarity index 100% rename from migrations/2021-06-02-173100_add_migration_state_change_reason_kind/down.sql rename to database/migrations/2021-06-02-173100_add_migration_state_change_reason_kind/down.sql diff --git a/migrations/2021-06-02-173100_add_migration_state_change_reason_kind/up.sql b/database/migrations/2021-06-02-173100_add_migration_state_change_reason_kind/up.sql similarity index 100% rename from migrations/2021-06-02-173100_add_migration_state_change_reason_kind/up.sql rename to database/migrations/2021-06-02-173100_add_migration_state_change_reason_kind/up.sql diff --git a/migrations/2021-08-02-183200_transactions_sorting_idx/down.sql b/database/migrations/2021-08-02-183200_transactions_sorting_idx/down.sql similarity index 100% rename from migrations/2021-08-02-183200_transactions_sorting_idx/down.sql rename to database/migrations/2021-08-02-183200_transactions_sorting_idx/down.sql diff --git a/migrations/2021-08-02-183200_transactions_sorting_idx/up.sql b/database/migrations/2021-08-02-183200_transactions_sorting_idx/up.sql similarity index 100% rename from migrations/2021-08-02-183200_transactions_sorting_idx/up.sql rename to database/migrations/2021-08-02-183200_transactions_sorting_idx/up.sql diff --git a/migrations/2021-08-04-151515_circulating_supply_table/down.sql b/database/migrations/2021-08-04-151515_circulating_supply_table/down.sql similarity index 100% rename from migrations/2021-08-04-151515_circulating_supply_table/down.sql rename to database/migrations/2021-08-04-151515_circulating_supply_table/down.sql diff --git a/migrations/2021-08-04-151515_circulating_supply_table/up.sql b/database/migrations/2021-08-04-151515_circulating_supply_table/up.sql similarity index 100% rename from migrations/2021-08-04-151515_circulating_supply_table/up.sql rename to database/migrations/2021-08-04-151515_circulating_supply_table/up.sql diff --git a/migrations/2021-08-06-123500_account_changes_ordering_column/down.sql b/database/migrations/2021-08-06-123500_account_changes_ordering_column/down.sql similarity index 100% rename from migrations/2021-08-06-123500_account_changes_ordering_column/down.sql rename to database/migrations/2021-08-06-123500_account_changes_ordering_column/down.sql diff --git a/migrations/2021-08-06-123500_account_changes_ordering_column/up.sql b/database/migrations/2021-08-06-123500_account_changes_ordering_column/up.sql similarity index 100% rename from migrations/2021-08-06-123500_account_changes_ordering_column/up.sql rename to database/migrations/2021-08-06-123500_account_changes_ordering_column/up.sql diff --git a/migrations/2021-08-11-163800_account_changes_ordering_idx/down.sql b/database/migrations/2021-08-11-163800_account_changes_ordering_idx/down.sql similarity index 100% rename from migrations/2021-08-11-163800_account_changes_ordering_idx/down.sql rename to database/migrations/2021-08-11-163800_account_changes_ordering_idx/down.sql diff --git a/migrations/2021-08-11-163800_account_changes_ordering_idx/up.sql b/database/migrations/2021-08-11-163800_account_changes_ordering_idx/up.sql similarity index 100% rename from migrations/2021-08-11-163800_account_changes_ordering_idx/up.sql rename to database/migrations/2021-08-11-163800_account_changes_ordering_idx/up.sql diff --git a/migrations/2021-10-04-100000_assets_nft/down.sql b/database/migrations/2021-10-04-100000_assets_nft/down.sql similarity index 100% rename from migrations/2021-10-04-100000_assets_nft/down.sql rename to database/migrations/2021-10-04-100000_assets_nft/down.sql diff --git a/migrations/2021-10-04-100000_assets_nft/up.sql b/database/migrations/2021-10-04-100000_assets_nft/up.sql similarity index 100% rename from migrations/2021-10-04-100000_assets_nft/up.sql rename to database/migrations/2021-10-04-100000_assets_nft/up.sql diff --git a/migrations/2021-10-14-180948_add_resharding_state_change_reason_kind/down.sql b/database/migrations/2021-10-14-180948_add_resharding_state_change_reason_kind/down.sql similarity index 100% rename from migrations/2021-10-14-180948_add_resharding_state_change_reason_kind/down.sql rename to database/migrations/2021-10-14-180948_add_resharding_state_change_reason_kind/down.sql diff --git a/migrations/2021-10-14-180948_add_resharding_state_change_reason_kind/up.sql b/database/migrations/2021-10-14-180948_add_resharding_state_change_reason_kind/up.sql similarity index 100% rename from migrations/2021-10-14-180948_add_resharding_state_change_reason_kind/up.sql rename to database/migrations/2021-10-14-180948_add_resharding_state_change_reason_kind/up.sql diff --git a/migrations/2022-01-12-100000_assets_ft/down.sql b/database/migrations/2022-01-12-100000_assets_ft/down.sql similarity index 100% rename from migrations/2022-01-12-100000_assets_ft/down.sql rename to database/migrations/2022-01-12-100000_assets_ft/down.sql diff --git a/migrations/2022-01-12-100000_assets_ft/up.sql b/database/migrations/2022-01-12-100000_assets_ft/up.sql similarity index 100% rename from migrations/2022-01-12-100000_assets_ft/up.sql rename to database/migrations/2022-01-12-100000_assets_ft/up.sql diff --git a/migrations/2022-01-26-184200_drop_duplicated_index_execution_outcome/down.sql b/database/migrations/2022-01-26-184200_drop_duplicated_index_execution_outcome/down.sql similarity index 100% rename from migrations/2022-01-26-184200_drop_duplicated_index_execution_outcome/down.sql rename to database/migrations/2022-01-26-184200_drop_duplicated_index_execution_outcome/down.sql diff --git a/migrations/2022-01-26-184200_drop_duplicated_index_execution_outcome/up.sql b/database/migrations/2022-01-26-184200_drop_duplicated_index_execution_outcome/up.sql similarity index 100% rename from migrations/2022-01-26-184200_drop_duplicated_index_execution_outcome/up.sql rename to database/migrations/2022-01-26-184200_drop_duplicated_index_execution_outcome/up.sql diff --git a/migrations/2022-01-26-184201_index_action_receipt_actions/down.sql b/database/migrations/2022-01-26-184201_index_action_receipt_actions/down.sql similarity index 100% rename from migrations/2022-01-26-184201_index_action_receipt_actions/down.sql rename to database/migrations/2022-01-26-184201_index_action_receipt_actions/down.sql diff --git a/migrations/2022-01-26-184201_index_action_receipt_actions/up.sql b/database/migrations/2022-01-26-184201_index_action_receipt_actions/up.sql similarity index 100% rename from migrations/2022-01-26-184201_index_action_receipt_actions/up.sql rename to database/migrations/2022-01-26-184201_index_action_receipt_actions/up.sql diff --git a/migrations/2022-06-07-000000_drop_action_receipt_actions_args_amount_index/down.sql b/database/migrations/2022-06-07-000000_drop_action_receipt_actions_args_amount_index/down.sql similarity index 100% rename from migrations/2022-06-07-000000_drop_action_receipt_actions_args_amount_index/down.sql rename to database/migrations/2022-06-07-000000_drop_action_receipt_actions_args_amount_index/down.sql diff --git a/migrations/2022-06-07-000000_drop_action_receipt_actions_args_amount_index/up.sql b/database/migrations/2022-06-07-000000_drop_action_receipt_actions_args_amount_index/up.sql similarity index 100% rename from migrations/2022-06-07-000000_drop_action_receipt_actions_args_amount_index/up.sql rename to database/migrations/2022-06-07-000000_drop_action_receipt_actions_args_amount_index/up.sql diff --git a/migrations/2022-08-12-123800_ft_nft_indexes/down.sql b/database/migrations/2022-08-12-123800_ft_nft_indexes/down.sql similarity index 100% rename from migrations/2022-08-12-123800_ft_nft_indexes/down.sql rename to database/migrations/2022-08-12-123800_ft_nft_indexes/down.sql diff --git a/migrations/2022-08-12-123800_ft_nft_indexes/up.sql b/database/migrations/2022-08-12-123800_ft_nft_indexes/up.sql similarity index 100% rename from migrations/2022-08-12-123800_ft_nft_indexes/up.sql rename to database/migrations/2022-08-12-123800_ft_nft_indexes/up.sql diff --git a/migrations/2022-09-23-100000_index_action_receipt_actions_on_timestamp_and_order_index/down.sql b/database/migrations/2022-09-23-100000_index_action_receipt_actions_on_timestamp_and_order_index/down.sql similarity index 100% rename from migrations/2022-09-23-100000_index_action_receipt_actions_on_timestamp_and_order_index/down.sql rename to database/migrations/2022-09-23-100000_index_action_receipt_actions_on_timestamp_and_order_index/down.sql diff --git a/migrations/2022-09-23-100000_index_action_receipt_actions_on_timestamp_and_order_index/up.sql b/database/migrations/2022-09-23-100000_index_action_receipt_actions_on_timestamp_and_order_index/up.sql similarity index 100% rename from migrations/2022-09-23-100000_index_action_receipt_actions_on_timestamp_and_order_index/up.sql rename to database/migrations/2022-09-23-100000_index_action_receipt_actions_on_timestamp_and_order_index/up.sql diff --git a/src/db_adapters/access_keys.rs b/database/src/adapters/access_keys.rs similarity index 80% rename from src/db_adapters/access_keys.rs rename to database/src/adapters/access_keys.rs index f4f7d2a7..2427727b 100644 --- a/src/db_adapters/access_keys.rs +++ b/database/src/adapters/access_keys.rs @@ -1,24 +1,18 @@ use std::collections::HashMap; use actix_diesel::dsl::AsyncRunQueryDsl; -use actix_diesel::Database; + use diesel::{ExpressionMethods, PgConnection, QueryDsl}; use futures::try_join; -use tracing::info; - -use near_indexer::near_primitives; +use crate::models; use crate::schema; -use crate::{metrics, models}; -pub(crate) async fn handle_access_keys( +pub async fn handle_access_keys( pool: &actix_diesel::Database, - state_changes: &[near_primitives::views::StateChangeWithCauseView], - block_height: near_primitives::types::BlockHeight, + state_changes: &[near_indexer_primitives::views::StateChangeWithCauseView], + block_height: near_indexer_primitives::types::BlockHeight, ) -> anyhow::Result<()> { - let _timer = metrics::STORE_TIME - .with_label_values(&["AccessKeys"]) - .start_timer(); if state_changes.is_empty() { return Ok(()); } @@ -26,11 +20,12 @@ pub(crate) async fn handle_access_keys( let mut access_keys = HashMap::<(String, String), models::access_keys::AccessKey>::new(); for state_change in state_changes { - if let near_primitives::views::StateChangeCauseView::ReceiptProcessing { receipt_hash } = - state_change.cause + if let near_indexer_primitives::views::StateChangeCauseView::ReceiptProcessing { + receipt_hash, + } = state_change.cause { match &state_change.value { - near_primitives::views::StateChangeValueView::AccessKeyUpdate { + near_indexer_primitives::views::StateChangeValueView::AccessKeyUpdate { account_id, public_key, access_key, @@ -46,7 +41,7 @@ pub(crate) async fn handle_access_keys( ), ); } - near_primitives::views::StateChangeValueView::AccessKeyDeletion { + near_indexer_primitives::views::StateChangeValueView::AccessKeyDeletion { account_id, public_key, } => { @@ -150,24 +145,3 @@ pub(crate) async fn handle_access_keys( Ok(()) } - -pub(crate) async fn store_access_keys_from_genesis( - pool: Database, - access_keys_models: Vec, -) -> anyhow::Result<()> { - info!( - target: crate::INDEXER_FOR_EXPLORER, - "Adding/updating access keys from genesis..." - ); - - crate::await_retry_or_panic!( - diesel::insert_into(schema::access_keys::table) - .values(access_keys_models.clone()) - .on_conflict_do_nothing() - .execute_async(&pool), - 10, - "AccessKeys were stored from genesis".to_string(), - &access_keys_models - ); - Ok(()) -} diff --git a/src/db_adapters/account_changes.rs b/database/src/adapters/account_changes.rs similarity index 71% rename from src/db_adapters/account_changes.rs rename to database/src/adapters/account_changes.rs index 35b7403c..cc9c0312 100644 --- a/src/db_adapters/account_changes.rs +++ b/database/src/adapters/account_changes.rs @@ -2,30 +2,27 @@ use actix_diesel::dsl::AsyncRunQueryDsl; use diesel::PgConnection; use futures::future::try_join_all; +use crate::models; use crate::schema; -use crate::{metrics, models}; -pub(crate) async fn store_account_changes( +/// Saves state change related to account to database +pub async fn store_account_changes( pool: &actix_diesel::Database, - shards: &[near_indexer::IndexerShard], - block_hash: &near_indexer::near_primitives::hash::CryptoHash, + shards: &[near_indexer_primitives::IndexerShard], + block_hash: &near_indexer_primitives::CryptoHash, block_timestamp: u64, ) -> anyhow::Result<()> { - let _timer = metrics::STORE_TIME - .with_label_values(&["AccountChanges"]) - .start_timer(); let futures = shards.iter().map(|shard| { - store_account_changes_for_shard(pool, &shard.state_changes, block_hash, block_timestamp) + store_account_changes_for_chunk(pool, &shard.state_changes, block_hash, block_timestamp) }); try_join_all(futures).await.map(|_| ()) } -/// Saves state change related to account to database -async fn store_account_changes_for_shard( +async fn store_account_changes_for_chunk( pool: &actix_diesel::Database, - state_changes: &[near_indexer::near_primitives::views::StateChangeWithCauseView], - block_hash: &near_indexer::near_primitives::hash::CryptoHash, + state_changes: &[near_indexer_primitives::views::StateChangeWithCauseView], + block_hash: &near_indexer_primitives::CryptoHash, block_timestamp: u64, ) -> anyhow::Result<()> { if state_changes.is_empty() { diff --git a/src/db_adapters/accounts.rs b/database/src/adapters/accounts.rs similarity index 86% rename from src/db_adapters/accounts.rs rename to database/src/adapters/accounts.rs index 6ee1e03d..dde4f2c6 100644 --- a/src/db_adapters/accounts.rs +++ b/database/src/adapters/accounts.rs @@ -1,29 +1,21 @@ use std::collections::HashMap; -use std::convert::TryFrom; use actix_diesel::dsl::AsyncRunQueryDsl; -use actix_diesel::Database; use anyhow::Context; use bigdecimal::BigDecimal; + use diesel::{BoolExpressionMethods, ExpressionMethods, PgConnection, QueryDsl}; use futures::try_join; -use tracing::info; - -use near_indexer::near_primitives; - +use crate::models; use crate::schema; -use crate::{metrics, models}; /// Saves new Accounts to database or deletes the ones should be deleted -pub(crate) async fn handle_accounts( +pub async fn handle_accounts( pool: &actix_diesel::Database, - outcomes: &[near_indexer::IndexerExecutionOutcomeWithReceipt], - block_height: near_primitives::types::BlockHeight, + outcomes: &[near_indexer_primitives::IndexerExecutionOutcomeWithReceipt], + block_height: near_indexer_primitives::types::BlockHeight, ) -> anyhow::Result<()> { - let _timer = metrics::STORE_TIME - .with_label_values(&["Accounts"]) - .start_timer(); if outcomes.is_empty() { return Ok(()); } @@ -32,20 +24,22 @@ pub(crate) async fn handle_accounts( .filter(|outcome_with_receipt| { matches!( outcome_with_receipt.execution_outcome.outcome.status, - near_primitives::views::ExecutionStatusView::SuccessValue(_) - | near_primitives::views::ExecutionStatusView::SuccessReceiptId(_) + near_indexer_primitives::views::ExecutionStatusView::SuccessValue(_) + | near_indexer_primitives::views::ExecutionStatusView::SuccessReceiptId(_) ) }) .map(|outcome_with_receipt| &outcome_with_receipt.receipt); let mut accounts = - HashMap::::new(); + HashMap::::new(); for receipt in successful_receipts { - if let near_primitives::views::ReceiptEnumView::Action { actions, .. } = &receipt.receipt { + if let near_indexer_primitives::views::ReceiptEnumView::Action { actions, .. } = + &receipt.receipt + { for action in actions { match action { - near_primitives::views::ActionView::CreateAccount => { + near_indexer_primitives::views::ActionView::CreateAccount => { accounts.insert( receipt.receiver_id.clone(), models::accounts::Account::new_from_receipt( @@ -55,7 +49,7 @@ pub(crate) async fn handle_accounts( ), ); } - near_primitives::views::ActionView::Transfer { .. } => { + near_indexer_primitives::views::ActionView::Transfer { .. } => { if receipt.receiver_id.len() == 64usize { accounts.insert( receipt.receiver_id.clone(), @@ -67,7 +61,7 @@ pub(crate) async fn handle_accounts( ); } } - near_primitives::views::ActionView::DeleteAccount { .. } => { + near_indexer_primitives::views::ActionView::DeleteAccount { .. } => { accounts .entry(receipt.receiver_id.clone()) .and_modify(|existing_account| { @@ -204,29 +198,7 @@ pub(crate) async fn handle_accounts( Ok(()) } -pub(crate) async fn store_accounts_from_genesis( - pool: Database, - accounts_models: Vec, -) -> anyhow::Result<()> { - info!( - target: crate::INDEXER_FOR_EXPLORER, - "Adding/updating accounts from genesis..." - ); - - crate::await_retry_or_panic!( - diesel::insert_into(schema::accounts::table) - .values(accounts_models.clone()) - .on_conflict_do_nothing() - .execute_async(&pool), - 10, - "Accounts were stored from genesis".to_string(), - &accounts_models - ); - - Ok(()) -} - -pub(crate) async fn get_lockup_account_ids_at_block_height( +pub async fn get_lockup_account_ids_at_block_height( pool: &actix_diesel::Database, block_height: &near_primitives::types::BlockHeight, ) -> anyhow::Result> { diff --git a/src/db_adapters/aggregated/circulating_supply.rs b/database/src/adapters/aggregated/circulating_supply.rs similarity index 92% rename from src/db_adapters/aggregated/circulating_supply.rs rename to database/src/adapters/aggregated/circulating_supply.rs index 9842ee29..208657d4 100644 --- a/src/db_adapters/aggregated/circulating_supply.rs +++ b/database/src/adapters/aggregated/circulating_supply.rs @@ -6,7 +6,7 @@ use tracing::error; use crate::models::aggregated::circulating_supply::CirculatingSupply; use crate::schema; -pub(crate) async fn add_circulating_supply( +pub async fn add_circulating_supply( pool: &actix_diesel::Database, stats: &CirculatingSupply, ) { @@ -23,7 +23,7 @@ pub(crate) async fn add_circulating_supply( } Err(async_error) => { error!( - target: crate::AGGREGATED, + target: crate::EXPLORER_DATABASE, "Error occurred while Circulating Supply was adding to database. Retrying in {} milliseconds... \n {:#?}", interval.as_millis(), async_error @@ -37,7 +37,7 @@ pub(crate) async fn add_circulating_supply( } } -pub(crate) async fn get_precomputed_circulating_supply_for_timestamp( +pub async fn get_precomputed_circulating_supply_for_timestamp( pool: &actix_diesel::Database, timestamp: u64, ) -> anyhow::Result> { diff --git a/database/src/adapters/aggregated/mod.rs b/database/src/adapters/aggregated/mod.rs new file mode 100644 index 00000000..1f0c3ff1 --- /dev/null +++ b/database/src/adapters/aggregated/mod.rs @@ -0,0 +1 @@ +pub mod circulating_supply; diff --git a/src/db_adapters/assets/event_types.rs b/database/src/adapters/assets/event_types.rs similarity index 100% rename from src/db_adapters/assets/event_types.rs rename to database/src/adapters/assets/event_types.rs diff --git a/src/db_adapters/assets/events.rs b/database/src/adapters/assets/events.rs similarity index 89% rename from src/db_adapters/assets/events.rs rename to database/src/adapters/assets/events.rs index becb4f77..f1a0e6c1 100644 --- a/src/db_adapters/assets/events.rs +++ b/database/src/adapters/assets/events.rs @@ -2,13 +2,13 @@ use actix_diesel::{AsyncError, Database}; use diesel::PgConnection; use tracing::warn; -use crate::db_adapters::assets; +use crate::adapters::assets; use super::event_types; -pub(crate) async fn store_events( +pub async fn store_events( pool: &Database, - streamer_message: &near_indexer::StreamerMessage, + streamer_message: &near_indexer_primitives::StreamerMessage, ) -> anyhow::Result<()> { let futures = streamer_message.shards.iter().map(|shard| { collect_and_store_events(pool, shard, streamer_message.block.header.timestamp) @@ -33,7 +33,7 @@ pub(crate) async fn detect_db_error( return true; } else if constraint_name == broken_data_constraint_name { warn!( - target: crate::INDEXER_FOR_EXPLORER, + target: crate::EXPLORER_DATABASE, "assets::events: data inconsistency is found" ); } @@ -43,7 +43,7 @@ pub(crate) async fn detect_db_error( async fn collect_and_store_events( pool: &Database, - shard: &near_indexer::IndexerShard, + shard: &near_indexer_primitives::IndexerShard, block_timestamp: u64, ) -> anyhow::Result<()> { let mut ft_events_with_outcomes = Vec::new(); @@ -80,7 +80,7 @@ async fn collect_and_store_events( } fn extract_events( - outcome: &near_indexer::IndexerExecutionOutcomeWithReceipt, + outcome: &near_indexer_primitives::IndexerExecutionOutcomeWithReceipt, ) -> Vec { let prefix = "EVENT_JSON:"; outcome.execution_outcome.outcome.logs.iter().filter_map(|untrimmed_log| { @@ -95,7 +95,7 @@ fn extract_events( Ok(result) => Some(result), Err(err) => { warn!( - target: crate::INDEXER_FOR_EXPLORER, + target: crate::EXPLORER_DATABASE, "Provided event log does not correspond to any of formats defined in NEP. Will ignore this event. \n {:#?} \n{:#?}", err, untrimmed_log, diff --git a/src/db_adapters/assets/fungible_token_events.rs b/database/src/adapters/assets/fungible_token_events.rs similarity index 94% rename from src/db_adapters/assets/fungible_token_events.rs rename to database/src/adapters/assets/fungible_token_events.rs index c78b8a87..9ad99dba 100644 --- a/src/db_adapters/assets/fungible_token_events.rs +++ b/database/src/adapters/assets/fungible_token_events.rs @@ -3,7 +3,7 @@ use actix_diesel::{AsyncError, Database}; use bigdecimal::BigDecimal; use diesel::PgConnection; -use crate::db_adapters::{assets, CHUNK_SIZE_FOR_BATCH_INSERT}; +use crate::adapters::{assets, CHUNK_SIZE_FOR_BATCH_INSERT}; use crate::models; use crate::schema; @@ -11,11 +11,11 @@ use super::event_types; pub(crate) async fn store_ft_events( pool: &Database, - shard: &near_indexer::IndexerShard, + shard: &near_indexer_primitives::IndexerShard, block_timestamp: u64, events_with_outcomes: &[( assets::event_types::Nep141Event, - &near_indexer::IndexerExecutionOutcomeWithReceipt, + &near_indexer_primitives::IndexerExecutionOutcomeWithReceipt, )], ) -> anyhow::Result<()> { let ft_events = compose_ft_db_events(events_with_outcomes, block_timestamp, &shard.shard_id); @@ -29,7 +29,7 @@ pub(crate) async fn store_ft_events( 10, "FungibleTokenEvent were adding to database".to_string(), &ft_events_chunk, - &detect_ft_db_error + detect_ft_db_error ); } @@ -48,10 +48,10 @@ async fn detect_ft_db_error(async_error: &AsyncError) -> fn compose_ft_db_events( events_with_outcomes: &[( assets::event_types::Nep141Event, - &near_indexer::IndexerExecutionOutcomeWithReceipt, + &near_indexer_primitives::IndexerExecutionOutcomeWithReceipt, )], block_timestamp: u64, - shard_id: &near_indexer::near_primitives::types::ShardId, + shard_id: &near_indexer_primitives::types::ShardId, ) -> Vec { let mut ft_events = Vec::new(); for (event, outcome) in events_with_outcomes { diff --git a/src/db_adapters/assets/mod.rs b/database/src/adapters/assets/mod.rs similarity index 80% rename from src/db_adapters/assets/mod.rs rename to database/src/adapters/assets/mod.rs index e70925cf..ed6d5f98 100644 --- a/src/db_adapters/assets/mod.rs +++ b/database/src/adapters/assets/mod.rs @@ -1,4 +1,4 @@ mod event_types; -pub(crate) mod events; +pub mod events; pub(crate) mod fungible_token_events; pub(crate) mod non_fungible_token_events; diff --git a/src/db_adapters/assets/non_fungible_token_events.rs b/database/src/adapters/assets/non_fungible_token_events.rs similarity index 95% rename from src/db_adapters/assets/non_fungible_token_events.rs rename to database/src/adapters/assets/non_fungible_token_events.rs index b5c41f27..652fbeec 100644 --- a/src/db_adapters/assets/non_fungible_token_events.rs +++ b/database/src/adapters/assets/non_fungible_token_events.rs @@ -3,7 +3,7 @@ use actix_diesel::{AsyncError, Database}; use bigdecimal::BigDecimal; use diesel::PgConnection; -use crate::db_adapters::{assets, CHUNK_SIZE_FOR_BATCH_INSERT}; +use crate::adapters::{assets, CHUNK_SIZE_FOR_BATCH_INSERT}; use crate::models; use crate::schema; @@ -11,11 +11,11 @@ use super::event_types; pub(crate) async fn store_nft_events( pool: &Database, - shard: &near_indexer::IndexerShard, + shard: &near_indexer_primitives::IndexerShard, block_timestamp: u64, events_with_outcomes: &[( assets::event_types::Nep171Event, - &near_indexer::IndexerExecutionOutcomeWithReceipt, + &near_indexer_primitives::IndexerExecutionOutcomeWithReceipt, )], ) -> anyhow::Result<()> { let nft_events = compose_nft_db_events(events_with_outcomes, block_timestamp, &shard.shard_id); @@ -29,7 +29,7 @@ pub(crate) async fn store_nft_events( 10, "NonFungibleTokenEvent were adding to database".to_string(), &nft_events_chunk, - &detect_nft_db_error + detect_nft_db_error ); } @@ -48,10 +48,10 @@ async fn detect_nft_db_error(async_error: &AsyncError) -> fn compose_nft_db_events( events_with_outcomes: &[( assets::event_types::Nep171Event, - &near_indexer::IndexerExecutionOutcomeWithReceipt, + &near_indexer_primitives::IndexerExecutionOutcomeWithReceipt, )], block_timestamp: u64, - shard_id: &near_indexer::near_primitives::types::ShardId, + shard_id: &near_indexer_primitives::types::ShardId, ) -> Vec { let mut nft_events = Vec::new(); for (event, outcome) in events_with_outcomes { diff --git a/src/db_adapters/blocks.rs b/database/src/adapters/blocks.rs similarity index 69% rename from src/db_adapters/blocks.rs rename to database/src/adapters/blocks.rs index cb5d8dfa..33862b0c 100644 --- a/src/db_adapters/blocks.rs +++ b/database/src/adapters/blocks.rs @@ -3,19 +3,14 @@ use anyhow::Context; use bigdecimal::{BigDecimal, ToPrimitive}; use diesel::{ExpressionMethods, PgConnection, QueryDsl}; -use near_indexer::near_primitives; - +use crate::models; use crate::schema; -use crate::{metrics, models}; /// Saves block to database -pub(crate) async fn store_block( +pub async fn store_block( pool: &actix_diesel::Database, - block: &near_primitives::views::BlockView, + block: &near_indexer_primitives::views::BlockView, ) -> anyhow::Result<()> { - let _timer = metrics::STORE_TIME - .with_label_values(&["Block"]) - .start_timer(); let block_model = models::blocks::Block::from(block); crate::await_retry_or_panic!( @@ -31,21 +26,20 @@ pub(crate) async fn store_block( } /// Gets the latest block's height from database -pub(crate) async fn latest_block_height( +pub async fn latest_block_height( pool: &actix_diesel::Database, -) -> Result, String> { - tracing::debug!(target: crate::INDEXER_FOR_EXPLORER, "fetching latest"); +) -> anyhow::Result> { + tracing::debug!(target: crate::EXPLORER_DATABASE, "fetching latest"); Ok(schema::blocks::table .select((schema::blocks::dsl::block_height,)) .order(schema::blocks::dsl::block_height.desc()) .limit(1) - .get_optional_result_async::<(bigdecimal::BigDecimal,)>(pool) - .await - .map_err(|err| format!("DB Error: {}", err))? + .get_optional_result_async::<(BigDecimal,)>(pool) + .await? .and_then(|(block_height,)| block_height.to_u64())) } -pub(crate) async fn get_latest_block_before_timestamp( +pub async fn get_latest_block_before_timestamp( pool: &actix_diesel::Database, timestamp: u64, ) -> anyhow::Result { diff --git a/src/db_adapters/chunks.rs b/database/src/adapters/chunks.rs similarity index 75% rename from src/db_adapters/chunks.rs rename to database/src/adapters/chunks.rs index ea3f591a..f1cdb7c9 100644 --- a/src/db_adapters/chunks.rs +++ b/database/src/adapters/chunks.rs @@ -1,18 +1,15 @@ use actix_diesel::dsl::AsyncRunQueryDsl; use diesel::PgConnection; +use crate::models; use crate::schema; -use crate::{metrics, models}; /// Saves chunks to database -pub(crate) async fn store_chunks( +pub async fn store_chunks( pool: &actix_diesel::Database, - shards: &[near_indexer::IndexerShard], - block_hash: &near_indexer::near_primitives::hash::CryptoHash, + shards: &[near_indexer_primitives::IndexerShard], + block_hash: &near_indexer_primitives::CryptoHash, ) -> anyhow::Result<()> { - let _timer = metrics::STORE_TIME - .with_label_values(&["Chunks"]) - .start_timer(); if shards.is_empty() { return Ok(()); } diff --git a/src/db_adapters/execution_outcomes.rs b/database/src/adapters/execution_outcomes.rs similarity index 85% rename from src/db_adapters/execution_outcomes.rs rename to database/src/adapters/execution_outcomes.rs index 91a0d5dc..084d4793 100644 --- a/src/db_adapters/execution_outcomes.rs +++ b/database/src/adapters/execution_outcomes.rs @@ -3,18 +3,15 @@ use cached::Cached; use diesel::PgConnection; use futures::future::try_join_all; +use crate::models; use crate::schema; -use crate::{metrics, models}; -pub(crate) async fn store_execution_outcomes( +pub async fn store_execution_outcomes( pool: &actix_diesel::Database, - shards: &[near_indexer::IndexerShard], + shards: &[near_indexer_primitives::IndexerShard], block_timestamp: u64, - receipts_cache: crate::ReceiptsCache, + receipts_cache: crate::receipts_cache::ReceiptsCache, ) -> anyhow::Result<()> { - let _timer = metrics::STORE_TIME - .with_label_values(&["ExecutionOutcomes"]) - .start_timer(); let futures = shards.iter().map(|shard| { store_execution_outcomes_for_chunk( pool, @@ -31,10 +28,10 @@ pub(crate) async fn store_execution_outcomes( /// Saves ExecutionOutcome to database and then saves ExecutionOutcomesReceipts pub async fn store_execution_outcomes_for_chunk( pool: &actix_diesel::Database, - execution_outcomes: &[near_indexer::IndexerExecutionOutcomeWithReceipt], - shard_id: near_indexer::near_primitives::types::ShardId, + execution_outcomes: &[near_indexer_primitives::IndexerExecutionOutcomeWithReceipt], + shard_id: near_indexer_primitives::types::ShardId, block_timestamp: u64, - receipts_cache: crate::ReceiptsCache, + receipts_cache: crate::receipts_cache::ReceiptsCache, ) -> anyhow::Result<()> { let mut outcome_models: Vec = vec![]; let mut outcome_receipt_models: Vec = @@ -45,7 +42,7 @@ pub async fn store_execution_outcomes_for_chunk( // remove it from cache once found as it is not expected to observe the Receipt for // second time let parent_transaction_hash = receipts_cache_lock.cache_remove( - &crate::ReceiptOrDataId::ReceiptId(outcome.execution_outcome.id), + &crate::receipts_cache::ReceiptOrDataId::ReceiptId(outcome.execution_outcome.id), ); let model = models::execution_outcomes::ExecutionOutcome::from_execution_outcome( @@ -69,7 +66,7 @@ pub async fn store_execution_outcomes_for_chunk( // could find their parents in cache if let Some(transaction_hash) = &parent_transaction_hash { receipts_cache_lock.cache_set( - crate::ReceiptOrDataId::ReceiptId(*receipt_id), + crate::receipts_cache::ReceiptOrDataId::ReceiptId(*receipt_id), transaction_hash.clone(), ); } diff --git a/database/src/adapters/mod.rs b/database/src/adapters/mod.rs new file mode 100644 index 00000000..2a7b9a35 --- /dev/null +++ b/database/src/adapters/mod.rs @@ -0,0 +1,12 @@ +pub mod access_keys; +pub mod account_changes; +pub mod accounts; +pub mod aggregated; +pub mod assets; +pub mod blocks; +pub mod chunks; +pub mod execution_outcomes; +pub mod receipts; +pub mod transactions; + +const CHUNK_SIZE_FOR_BATCH_INSERT: usize = 500; diff --git a/src/db_adapters/receipts.rs b/database/src/adapters/receipts.rs similarity index 70% rename from src/db_adapters/receipts.rs rename to database/src/adapters/receipts.rs index 005c1014..3bcef678 100644 --- a/src/db_adapters/receipts.rs +++ b/database/src/adapters/receipts.rs @@ -2,8 +2,6 @@ use std::collections::HashMap; use std::convert::TryFrom; use std::str::FromStr; -use near_indexer::near_primitives; - use actix_diesel::dsl::AsyncRunQueryDsl; use cached::Cached; use diesel::pg::expression::array_comparison::any; @@ -13,21 +11,18 @@ use futures::try_join; use num_traits::cast::FromPrimitive; use tracing::{error, warn}; +use crate::models; use crate::schema; -use crate::{metrics, models}; /// Saves receipts to database -pub(crate) async fn store_receipts( +pub async fn store_receipts( pool: &actix_diesel::Database, - shards: &[near_indexer::IndexerShard], - block_hash: &near_indexer::near_primitives::hash::CryptoHash, + shards: &[near_indexer_primitives::IndexerShard], + block_hash: &near_indexer_primitives::CryptoHash, block_timestamp: u64, strict_mode: bool, - receipts_cache: crate::ReceiptsCache, + receipts_cache: crate::receipts_cache::ReceiptsCache, ) -> anyhow::Result<()> { - let _timer = metrics::STORE_TIME - .with_label_values(&["Receipts"]) - .start_timer(); let futures = shards .iter() .filter_map(|shard| shard.chunk.as_ref()) @@ -49,15 +44,15 @@ pub(crate) async fn store_receipts( async fn store_chunk_receipts( pool: &actix_diesel::Database, - receipts: &[near_indexer::near_primitives::views::ReceiptView], - block_hash: &near_indexer::near_primitives::hash::CryptoHash, - chunk_hash: &near_indexer::near_primitives::hash::CryptoHash, + receipts: &[near_indexer_primitives::views::ReceiptView], + block_hash: &near_indexer_primitives::CryptoHash, + chunk_hash: &near_indexer_primitives::CryptoHash, block_timestamp: u64, strict_mode: bool, - receipts_cache: crate::ReceiptsCache, + receipts_cache: crate::receipts_cache::ReceiptsCache, ) -> anyhow::Result<()> { let mut skipping_receipt_ids = - std::collections::HashSet::::new(); + std::collections::HashSet::::new(); let tx_hashes_for_receipts = find_tx_hashes_for_receipts( pool, @@ -78,11 +73,11 @@ async fn store_chunk_receipts( // In case of Action Receipt we are looking for ReceiptId // In case of Data Receipt we are looking for DataId let receipt_or_data_id = match r.receipt { - near_primitives::views::ReceiptEnumView::Action { .. } => { - crate::ReceiptOrDataId::ReceiptId(r.receipt_id) + near_indexer_primitives::views::ReceiptEnumView::Action { .. } => { + crate::receipts_cache::ReceiptOrDataId::ReceiptId(r.receipt_id) } - near_primitives::views::ReceiptEnumView::Data { data_id, .. } => { - crate::ReceiptOrDataId::DataId(data_id) + near_indexer_primitives::views::ReceiptEnumView::Data { data_id, .. } => { + crate::receipts_cache::ReceiptOrDataId::DataId(data_id) } }; if let Some(transaction_hash) = tx_hashes_for_receipts.get(&receipt_or_data_id) { @@ -96,7 +91,7 @@ async fn store_chunk_receipts( )) } else { warn!( - target: crate::INDEXER_FOR_EXPLORER, + target: crate::EXPLORER_DATABASE, "Skipping Receipt {} as we can't find parent Transaction for it. Happen in block hash {}, chunk hash {}", r.receipt_id.to_string(), block_hash, @@ -113,18 +108,18 @@ async fn store_chunk_receipts( // to ReceiptsCache let mut receipts_cache_lock = receipts_cache.lock().await; for receipt in receipts { - if let near_primitives::views::ReceiptEnumView::Action { + if let near_indexer_primitives::views::ReceiptEnumView::Action { output_data_receivers, .. } = &receipt.receipt { if !output_data_receivers.is_empty() { - if let Some(transaction_hash) = tx_hashes_for_receipts - .get(&crate::ReceiptOrDataId::ReceiptId(receipt.receipt_id)) - { + if let Some(transaction_hash) = tx_hashes_for_receipts.get( + &crate::receipts_cache::ReceiptOrDataId::ReceiptId(receipt.receipt_id), + ) { for data_receiver in output_data_receivers { receipts_cache_lock.cache_set( - crate::ReceiptOrDataId::DataId(data_receiver.data_id), + crate::receipts_cache::ReceiptOrDataId::DataId(data_receiver.data_id), transaction_hash.clone(), ); } @@ -138,15 +133,15 @@ async fn store_chunk_receipts( save_receipts(pool, receipt_models).await?; let (action_receipts, data_receipts): ( - Vec<&near_indexer::near_primitives::views::ReceiptView>, - Vec<&near_indexer::near_primitives::views::ReceiptView>, + Vec<&near_indexer_primitives::views::ReceiptView>, + Vec<&near_indexer_primitives::views::ReceiptView>, ) = receipts .iter() .filter(|r| !skipping_receipt_ids.contains(&r.receipt_id)) .partition(|receipt| { matches!( receipt.receipt, - near_indexer::near_primitives::views::ReceiptEnumView::Action { .. } + near_indexer_primitives::views::ReceiptEnumView::Action { .. } ) }); @@ -162,37 +157,44 @@ async fn store_chunk_receipts( /// Looks for already created parent transaction hash for given receipts async fn find_tx_hashes_for_receipts( pool: &actix_diesel::Database, - mut receipts: Vec, + mut receipts: Vec, strict_mode: bool, - block_hash: &near_indexer::near_primitives::hash::CryptoHash, - chunk_hash: &near_indexer::near_primitives::hash::CryptoHash, - receipts_cache: crate::ReceiptsCache, -) -> anyhow::Result> { + block_hash: &near_indexer_primitives::CryptoHash, + chunk_hash: &near_indexer_primitives::CryptoHash, + receipts_cache: crate::receipts_cache::ReceiptsCache, +) -> anyhow::Result< + HashMap< + crate::receipts_cache::ReceiptOrDataId, + crate::receipts_cache::ParentTransactionHashString, + >, +> { let mut tx_hashes_for_receipts: HashMap< - crate::ReceiptOrDataId, - crate::ParentTransactionHashString, + crate::receipts_cache::ReceiptOrDataId, + crate::receipts_cache::ParentTransactionHashString, > = HashMap::new(); let mut receipts_cache_lock = receipts_cache.lock().await; // add receipt-transaction pairs from the cache to the response tx_hashes_for_receipts.extend(receipts.iter().filter_map(|receipt| { match receipt.receipt { - near_primitives::views::ReceiptEnumView::Action { .. } => receipts_cache_lock - .cache_get(&crate::ReceiptOrDataId::ReceiptId(receipt.receipt_id)) + near_indexer_primitives::views::ReceiptEnumView::Action { .. } => receipts_cache_lock + .cache_get(&crate::receipts_cache::ReceiptOrDataId::ReceiptId( + receipt.receipt_id, + )) .map(|parent_transaction_hash| { ( - crate::ReceiptOrDataId::ReceiptId(receipt.receipt_id), + crate::receipts_cache::ReceiptOrDataId::ReceiptId(receipt.receipt_id), parent_transaction_hash.clone(), ) }), - near_primitives::views::ReceiptEnumView::Data { data_id, .. } => { + near_indexer_primitives::views::ReceiptEnumView::Data { data_id, .. } => { // Pair DataId:ParentTransactionHash won't be used after this moment // We want to clean it up to prevent our cache from growing receipts_cache_lock - .cache_remove(&crate::ReceiptOrDataId::DataId(data_id)) + .cache_remove(&crate::receipts_cache::ReceiptOrDataId::DataId(data_id)) .map(|parent_transaction_hash| { ( - crate::ReceiptOrDataId::DataId(data_id), + crate::receipts_cache::ReceiptOrDataId::DataId(data_id), parent_transaction_hash, ) }) @@ -204,19 +206,21 @@ async fn find_tx_hashes_for_receipts( // discard the Receipts already in cache from the attempts to search receipts.retain(|r| match r.receipt { - near_primitives::views::ReceiptEnumView::Data { data_id, .. } => { - !tx_hashes_for_receipts.contains_key(&crate::ReceiptOrDataId::DataId(data_id)) - } - near_primitives::views::ReceiptEnumView::Action { .. } => { - !tx_hashes_for_receipts.contains_key(&crate::ReceiptOrDataId::ReceiptId(r.receipt_id)) + near_indexer_primitives::views::ReceiptEnumView::Data { data_id, .. } => { + !tx_hashes_for_receipts + .contains_key(&crate::receipts_cache::ReceiptOrDataId::DataId(data_id)) } + near_indexer_primitives::views::ReceiptEnumView::Action { .. } => !tx_hashes_for_receipts + .contains_key(&crate::receipts_cache::ReceiptOrDataId::ReceiptId( + r.receipt_id, + )), }); if receipts.is_empty() { return Ok(tx_hashes_for_receipts); } warn!( - target: crate::INDEXER_FOR_EXPLORER, + target: crate::EXPLORER_DATABASE, "Looking for parent transaction hash in database for {} receipts {:#?}", &receipts.len(), &receipts, @@ -228,7 +232,7 @@ async fn find_tx_hashes_for_receipts( let data_ids: Vec = receipts .iter() .filter_map(|r| match r.receipt { - near_indexer::near_primitives::views::ReceiptEnumView::Data { data_id, .. } => { + near_indexer_primitives::views::ReceiptEnumView::Data { data_id, .. } => { Some(data_id.to_string()) } _ => None, @@ -237,8 +241,8 @@ async fn find_tx_hashes_for_receipts( if !data_ids.is_empty() { let mut interval = crate::INTERVAL; let tx_hashes_for_data_id_via_data_output: Vec<( - crate::ReceiptOrDataId, - crate::ParentTransactionHashString, + crate::receipts_cache::ReceiptOrDataId, + crate::receipts_cache::ParentTransactionHashString, )> = loop { match schema::action_receipt_output_data::table .inner_join( @@ -264,8 +268,8 @@ async fn find_tx_hashes_for_receipts( .map( |(receipt_id_string, transaction_hash_string): (String, String)| { ( - crate::ReceiptOrDataId::DataId( - near_primitives::hash::CryptoHash::from_str( + crate::receipts_cache::ReceiptOrDataId::DataId( + near_indexer_primitives::CryptoHash::from_str( &receipt_id_string, ) .expect("Failed to convert String to CryptoHash"), @@ -278,7 +282,7 @@ async fn find_tx_hashes_for_receipts( } Err(async_error) => { error!( - target: crate::INDEXER_FOR_EXPLORER, + target: crate::EXPLORER_DATABASE, "Error occurred while fetching the parent receipt for Receipt. Retrying in {} milliseconds... \n {:#?}", interval.as_millis(), async_error, @@ -291,26 +295,28 @@ async fn find_tx_hashes_for_receipts( } }; - let mut tx_hashes_for_data_id_via_data_output_hashmap = - HashMap::::new(); + let mut tx_hashes_for_data_id_via_data_output_hashmap = HashMap::< + crate::receipts_cache::ReceiptOrDataId, + crate::receipts_cache::ParentTransactionHashString, + >::new(); tx_hashes_for_data_id_via_data_output_hashmap .extend(tx_hashes_for_data_id_via_data_output); let tx_hashes_for_receipts_via_data_output: Vec<( - crate::ReceiptOrDataId, - crate::ParentTransactionHashString, + crate::receipts_cache::ReceiptOrDataId, + crate::receipts_cache::ParentTransactionHashString, )> = receipts .iter() .filter_map(|r| match r.receipt { - near_indexer::near_primitives::views::ReceiptEnumView::Data { - data_id, .. - } => tx_hashes_for_data_id_via_data_output_hashmap - .get(&crate::ReceiptOrDataId::DataId(data_id)) - .map(|tx_hash| { - ( - crate::ReceiptOrDataId::ReceiptId(r.receipt_id), - tx_hash.to_string(), - ) - }), + near_indexer_primitives::views::ReceiptEnumView::Data { data_id, .. } => { + tx_hashes_for_data_id_via_data_output_hashmap + .get(&crate::receipts_cache::ReceiptOrDataId::DataId(data_id)) + .map(|tx_hash| { + ( + crate::receipts_cache::ReceiptOrDataId::ReceiptId(r.receipt_id), + tx_hash.to_string(), + ) + }) + } _ => None, }) .collect(); @@ -323,51 +329,52 @@ async fn find_tx_hashes_for_receipts( } receipts.retain(|r| { - !tx_hashes_for_receipts - .contains_key(&crate::ReceiptOrDataId::ReceiptId(r.receipt_id)) + !tx_hashes_for_receipts.contains_key( + &crate::receipts_cache::ReceiptOrDataId::ReceiptId(r.receipt_id), + ) }); } - let tx_hashes_for_receipts_via_outcomes: Vec<(String, crate::ParentTransactionHashString)> = - crate::await_retry_or_panic!( - schema::execution_outcome_receipts::table - .inner_join( - schema::receipts::table - .on(schema::execution_outcome_receipts::dsl::executed_receipt_id - .eq(schema::receipts::dsl::receipt_id)), - ) - .filter( - schema::execution_outcome_receipts::dsl::produced_receipt_id.eq(any( - receipts - .clone() - .iter() - .filter(|r| { - matches!( + let tx_hashes_for_receipts_via_outcomes: Vec<( + String, + crate::receipts_cache::ParentTransactionHashString, + )> = crate::await_retry_or_panic!( + schema::execution_outcome_receipts::table + .inner_join( + schema::receipts::table + .on(schema::execution_outcome_receipts::dsl::executed_receipt_id + .eq(schema::receipts::dsl::receipt_id)), + ) + .filter( + schema::execution_outcome_receipts::dsl::produced_receipt_id.eq(any(receipts + .clone() + .iter() + .filter(|r| { + matches!( r.receipt, - near_indexer::near_primitives::views::ReceiptEnumView::Action { .. } + near_indexer_primitives::views::ReceiptEnumView::Action { .. } ) - }) - .map(|r| r.receipt_id.to_string()) - .collect::>() - )), - ) - .select(( - schema::execution_outcome_receipts::dsl::produced_receipt_id, - schema::receipts::dsl::originated_from_transaction_hash, - )) - .load_async::<(String, crate::ParentTransactionHashString)>(pool), - 10, - "Parent Transaction for Receipts were fetched".to_string(), - &receipts - ) - .unwrap_or_default(); + }) + .map(|r| r.receipt_id.to_string()) + .collect::>())), + ) + .select(( + schema::execution_outcome_receipts::dsl::produced_receipt_id, + schema::receipts::dsl::originated_from_transaction_hash, + )) + .load_async::<(String, crate::receipts_cache::ParentTransactionHashString)>(pool), + 10, + "Parent Transaction for Receipts were fetched".to_string(), + &receipts + ) + .unwrap_or_default(); let found_hashes_len = tx_hashes_for_receipts_via_outcomes.len(); tx_hashes_for_receipts.extend(tx_hashes_for_receipts_via_outcomes.into_iter().map( |(receipt_id_string, transaction_hash_string)| { ( - crate::ReceiptOrDataId::ReceiptId( - near_primitives::hash::CryptoHash::from_str(&receipt_id_string) + crate::receipts_cache::ReceiptOrDataId::ReceiptId( + near_indexer_primitives::CryptoHash::from_str(&receipt_id_string) .expect("Failed to convert String to CryptoHash"), ), transaction_hash_string, @@ -380,12 +387,14 @@ async fn find_tx_hashes_for_receipts( } receipts.retain(|r| { - !tx_hashes_for_receipts.contains_key(&crate::ReceiptOrDataId::ReceiptId(r.receipt_id)) + !tx_hashes_for_receipts.contains_key( + &crate::receipts_cache::ReceiptOrDataId::ReceiptId(r.receipt_id), + ) }); let tx_hashes_for_receipt_via_transactions: Vec<( String, - crate::ParentTransactionHashString, + crate::receipts_cache::ParentTransactionHashString, )> = crate::await_retry_or_panic!( schema::transactions::table .filter( @@ -395,7 +404,7 @@ async fn find_tx_hashes_for_receipts( .filter(|r| { matches!( r.receipt, - near_indexer::near_primitives::views::ReceiptEnumView::Action { .. } + near_indexer_primitives::views::ReceiptEnumView::Action { .. } ) }) .map(|r| r.receipt_id.to_string()) @@ -405,7 +414,7 @@ async fn find_tx_hashes_for_receipts( schema::transactions::dsl::converted_into_receipt_id, schema::transactions::dsl::transaction_hash, )) - .load_async::<(String, crate::ParentTransactionHashString)>(pool), + .load_async::<(String, crate::receipts_cache::ParentTransactionHashString)>(pool), 10, "Parent Transaction for ExecutionOutcome were fetched".to_string(), &receipts @@ -416,8 +425,8 @@ async fn find_tx_hashes_for_receipts( tx_hashes_for_receipts.extend(tx_hashes_for_receipt_via_transactions.into_iter().map( |(receipt_id_string, transaction_hash_string)| { ( - crate::ReceiptOrDataId::ReceiptId( - near_primitives::hash::CryptoHash::from_str(&receipt_id_string) + crate::receipts_cache::ReceiptOrDataId::ReceiptId( + near_indexer_primitives::CryptoHash::from_str(&receipt_id_string) .expect("Failed to convert String to CryptoHash"), ), transaction_hash_string, @@ -430,7 +439,9 @@ async fn find_tx_hashes_for_receipts( } receipts.retain(|r| { - !tx_hashes_for_receipts.contains_key(&crate::ReceiptOrDataId::ReceiptId(r.receipt_id)) + !tx_hashes_for_receipts.contains_key( + &crate::receipts_cache::ReceiptOrDataId::ReceiptId(r.receipt_id), + ) }); if !strict_mode { @@ -441,7 +452,7 @@ async fn find_tx_hashes_for_receipts( } } warn!( - target: crate::INDEXER_FOR_EXPLORER, + target: crate::EXPLORER_DATABASE, "Going to retry to find parent transactions for receipts in {} milliseconds... \n {:#?}\n block hash {} \nchunk hash {}", find_tx_retry_interval.as_millis(), &receipts, @@ -475,7 +486,7 @@ async fn save_receipts( async fn store_receipt_actions( pool: &actix_diesel::Database, - receipts: Vec<&near_indexer::near_primitives::views::ReceiptView>, + receipts: Vec<&near_indexer_primitives::views::ReceiptView>, block_timestamp: u64, ) -> anyhow::Result<()> { let receipt_actions: Vec = receipts @@ -486,9 +497,8 @@ async fn store_receipt_actions( let receipt_action_actions: Vec = receipts .iter() .filter_map(|receipt| { - if let near_indexer::near_primitives::views::ReceiptEnumView::Action { - actions, .. - } = &receipt.receipt + if let near_indexer_primitives::views::ReceiptEnumView::Action { actions, .. } = + &receipt.receipt { Some(actions.iter().enumerate().map(move |(index, action)| { models::ActionReceiptAction::from_action_view( @@ -510,9 +520,8 @@ async fn store_receipt_actions( let receipt_action_input_data: Vec = receipts .iter() .filter_map(|receipt| { - if let near_indexer::near_primitives::views::ReceiptEnumView::Action { - input_data_ids, - .. + if let near_indexer_primitives::views::ReceiptEnumView::Action { + input_data_ids, .. } = &receipt.receipt { Some(input_data_ids.iter().map(move |data_id| { @@ -531,7 +540,7 @@ async fn store_receipt_actions( let receipt_action_output_data: Vec = receipts .iter() .filter_map(|receipt| { - if let near_indexer::near_primitives::views::ReceiptEnumView::Action { + if let near_indexer_primitives::views::ReceiptEnumView::Action { output_data_receivers, .. } = &receipt.receipt @@ -594,7 +603,7 @@ async fn store_receipt_actions( async fn store_receipt_data( pool: &actix_diesel::Database, - receipts: Vec<&near_indexer::near_primitives::views::ReceiptView>, + receipts: Vec<&near_indexer_primitives::views::ReceiptView>, ) -> anyhow::Result<()> { let receipt_data_models: Vec = receipts .iter() diff --git a/src/db_adapters/transactions.rs b/database/src/adapters/transactions.rs similarity index 83% rename from src/db_adapters/transactions.rs rename to database/src/adapters/transactions.rs index 616aa2bd..f3f545f6 100644 --- a/src/db_adapters/transactions.rs +++ b/database/src/adapters/transactions.rs @@ -4,23 +4,18 @@ use cached::Cached; use diesel::{ExpressionMethods, PgConnection, QueryDsl}; use futures::future::try_join_all; -use near_indexer::near_primitives; - +use crate::models; use crate::schema; -use crate::{metrics, models}; /// Saves Transactions to database -pub(crate) async fn store_transactions( +pub async fn store_transactions( pool: &actix_diesel::Database, - shards: &[near_indexer::IndexerShard], - block_hash: &near_indexer::near_primitives::hash::CryptoHash, + shards: &[near_indexer_primitives::IndexerShard], + block_hash: &near_indexer_primitives::CryptoHash, block_timestamp: u64, - block_height: near_primitives::types::BlockHeight, - receipts_cache: crate::ReceiptsCache, + block_height: near_indexer_primitives::types::BlockHeight, + receipts_cache: crate::receipts_cache::ReceiptsCache, ) -> anyhow::Result<()> { - let _timer = metrics::STORE_TIME - .with_label_values(&["Transactions"]) - .start_timer(); let mut tried_to_insert_transactions_count = 0; let tx_futures = shards .iter() @@ -29,11 +24,10 @@ pub(crate) async fn store_transactions( tried_to_insert_transactions_count += chunk.transactions.len(); store_chunk_transactions( pool, - chunk - .transactions - .iter() - .enumerate() - .collect::>(), + chunk.transactions.iter().enumerate().collect::>(), &chunk.header.chunk_hash, block_hash, block_timestamp, @@ -77,7 +71,10 @@ pub(crate) async fn store_transactions( .to_string(); !inserted_receipt_ids.contains(converted_into_receipt_id) }) - .collect::>(), + .collect::>(), &chunk.header.chunk_hash, block_hash, block_timestamp, @@ -91,25 +88,28 @@ pub(crate) async fn store_transactions( async fn collect_converted_to_receipt_ids( pool: &actix_diesel::Database, - block_hash: &near_indexer::near_primitives::hash::CryptoHash, + block_hash: &near_indexer_primitives::CryptoHash, ) -> anyhow::Result> { - Ok(schema::transactions::table + schema::transactions::table .select(schema::transactions::dsl::converted_into_receipt_id) .filter(schema::transactions::dsl::included_in_block_hash.eq(block_hash.to_string())) .get_results_async::(pool) .await - .context("DB Error")?) + .context("DB Error") } async fn store_chunk_transactions( pool: &actix_diesel::Database, - transactions: Vec<(usize, &near_indexer::IndexerTransactionWithOutcome)>, - chunk_hash: &near_indexer::near_primitives::hash::CryptoHash, - block_hash: &near_indexer::near_primitives::hash::CryptoHash, + transactions: Vec<( + usize, + &near_indexer_primitives::IndexerTransactionWithOutcome, + )>, + chunk_hash: &near_indexer_primitives::CryptoHash, + block_hash: &near_indexer_primitives::CryptoHash, block_timestamp: u64, // hack for supporting duplicated transaction hashes. Empty for most of transactions transaction_hash_suffix: &str, - receipts_cache: crate::ReceiptsCache, + receipts_cache: crate::receipts_cache::ReceiptsCache, ) -> anyhow::Result<()> { let mut receipts_cache_lock = receipts_cache.lock().await; @@ -131,7 +131,7 @@ async fn store_chunk_transactions( // Later, while Receipt will be looking for a parent Transaction hash // it will be able to find it in the ReceiptsCache receipts_cache_lock.cache_set( - crate::ReceiptOrDataId::ReceiptId(*converted_into_receipt_id), + crate::receipts_cache::ReceiptOrDataId::ReceiptId(*converted_into_receipt_id), transaction_hash.clone(), ); diff --git a/database/src/lib.rs b/database/src/lib.rs new file mode 100644 index 00000000..d40ff571 --- /dev/null +++ b/database/src/lib.rs @@ -0,0 +1,17 @@ +#[macro_use] +pub extern crate diesel; + +pub use actix_diesel; + +pub mod adapters; +pub mod models; +pub mod receipts_cache; + +mod schema; +#[macro_use] +mod retryable; + +const INTERVAL: std::time::Duration = std::time::Duration::from_millis(100); +const EXPLORER_DATABASE: &str = "explorer_database"; + +const MAX_DELAY_TIME: std::time::Duration = std::time::Duration::from_secs(120); diff --git a/src/models/access_keys.rs b/database/src/models/access_keys.rs similarity index 71% rename from src/models/access_keys.rs rename to database/src/models/access_keys.rs index 89dca675..e2216004 100644 --- a/src/models/access_keys.rs +++ b/database/src/models/access_keys.rs @@ -17,10 +17,10 @@ pub struct AccessKey { impl AccessKey { pub fn from_action_view( public_key: &near_crypto::PublicKey, - account_id: &near_indexer::near_primitives::types::AccountId, - access_key: &near_indexer::near_primitives::views::AccessKeyView, - create_by_receipt_id: &near_indexer::near_primitives::hash::CryptoHash, - last_update_block_height: near_indexer::near_primitives::types::BlockHeight, + account_id: &near_indexer_primitives::types::AccountId, + access_key: &near_indexer_primitives::views::AccessKeyView, + create_by_receipt_id: &near_indexer_primitives::CryptoHash, + last_update_block_height: near_indexer_primitives::types::BlockHeight, ) -> Self { Self { public_key: public_key.to_string(), @@ -34,9 +34,9 @@ impl AccessKey { pub fn from_genesis( public_key: &near_crypto::PublicKey, - account_id: &near_indexer::near_primitives::types::AccountId, - access_key: &near_indexer::near_primitives::account::AccessKey, - last_update_block_height: near_indexer::near_primitives::types::BlockHeight, + account_id: &near_indexer_primitives::types::AccountId, + access_key: &near_primitives::account::AccessKey, + last_update_block_height: near_indexer_primitives::types::BlockHeight, ) -> Self { Self { public_key: public_key.to_string(), diff --git a/src/models/account_changes.rs b/database/src/models/account_changes.rs similarity index 57% rename from src/models/account_changes.rs rename to database/src/models/account_changes.rs index 16d94a72..affa360a 100644 --- a/src/models/account_changes.rs +++ b/database/src/models/account_changes.rs @@ -22,42 +22,40 @@ pub struct AccountChange { impl AccountChange { pub fn from_state_change_with_cause( - state_change_with_cause: &near_indexer::near_primitives::views::StateChangeWithCauseView, - changed_in_block_hash: &near_indexer::near_primitives::hash::CryptoHash, + state_change_with_cause: &near_indexer_primitives::views::StateChangeWithCauseView, + changed_in_block_hash: &near_indexer_primitives::CryptoHash, changed_in_block_timestamp: u64, index_in_block: i32, ) -> Option { - let near_indexer::near_primitives::views::StateChangeWithCauseView { cause, value } = + let near_indexer_primitives::views::StateChangeWithCauseView { cause, value } = state_change_with_cause; - let (account_id, account): ( - String, - Option<&near_indexer::near_primitives::views::AccountView>, - ) = match value { - near_indexer::near_primitives::views::StateChangeValueView::AccountUpdate { - account_id, - account, - } => (account_id.to_string(), Some(account)), - near_indexer::near_primitives::views::StateChangeValueView::AccountDeletion { - account_id, - } => (account_id.to_string(), None), - _ => return None, - }; + let (account_id, account): (String, Option<&near_indexer_primitives::views::AccountView>) = + match value { + near_indexer_primitives::views::StateChangeValueView::AccountUpdate { + account_id, + account, + } => (account_id.to_string(), Some(account)), + near_indexer_primitives::views::StateChangeValueView::AccountDeletion { + account_id, + } => (account_id.to_string(), None), + _ => return None, + }; Some(Self { affected_account_id: account_id, changed_in_block_timestamp: changed_in_block_timestamp.into(), changed_in_block_hash: changed_in_block_hash.to_string(), - caused_by_transaction_hash: if let near_indexer::near_primitives::views::StateChangeCauseView::TransactionProcessing {tx_hash } = cause { + caused_by_transaction_hash: if let near_indexer_primitives::views::StateChangeCauseView::TransactionProcessing {tx_hash } = cause { Some(tx_hash.to_string()) } else { None }, caused_by_receipt_id: match cause { - near_indexer::near_primitives::views::StateChangeCauseView::ActionReceiptProcessingStarted { receipt_hash} => Some(receipt_hash.to_string()), - near_indexer::near_primitives::views::StateChangeCauseView::ActionReceiptGasReward { receipt_hash } => Some(receipt_hash.to_string()), - near_indexer::near_primitives::views::StateChangeCauseView::ReceiptProcessing { receipt_hash } => Some(receipt_hash.to_string()), - near_indexer::near_primitives::views::StateChangeCauseView::PostponedReceipt { receipt_hash } => Some(receipt_hash.to_string()), + near_indexer_primitives::views::StateChangeCauseView::ActionReceiptProcessingStarted { receipt_hash} => Some(receipt_hash.to_string()), + near_indexer_primitives::views::StateChangeCauseView::ActionReceiptGasReward { receipt_hash } => Some(receipt_hash.to_string()), + near_indexer_primitives::views::StateChangeCauseView::ReceiptProcessing { receipt_hash } => Some(receipt_hash.to_string()), + near_indexer_primitives::views::StateChangeCauseView::PostponedReceipt { receipt_hash } => Some(receipt_hash.to_string()), _ => None, }, update_reason: cause.into(), diff --git a/src/models/accounts.rs b/database/src/models/accounts.rs similarity index 70% rename from src/models/accounts.rs rename to database/src/models/accounts.rs index dbda5a7c..9f5c1379 100644 --- a/src/models/accounts.rs +++ b/database/src/models/accounts.rs @@ -14,9 +14,9 @@ pub struct Account { impl Account { pub fn new_from_receipt( - account_id: &near_indexer::near_primitives::types::AccountId, - created_by_receipt_id: &near_indexer::near_primitives::hash::CryptoHash, - last_update_block_height: near_indexer::near_primitives::types::BlockHeight, + account_id: &near_indexer_primitives::types::AccountId, + created_by_receipt_id: &near_indexer_primitives::CryptoHash, + last_update_block_height: near_indexer_primitives::types::BlockHeight, ) -> Self { Self { account_id: account_id.to_string(), @@ -27,8 +27,8 @@ impl Account { } pub fn new_from_genesis( - account_id: &near_indexer::near_primitives::types::AccountId, - last_update_block_height: near_indexer::near_primitives::types::BlockHeight, + account_id: &near_indexer_primitives::types::AccountId, + last_update_block_height: near_indexer_primitives::types::BlockHeight, ) -> Self { Self { account_id: account_id.to_string(), diff --git a/src/models/aggregated/circulating_supply.rs b/database/src/models/aggregated/circulating_supply.rs similarity index 100% rename from src/models/aggregated/circulating_supply.rs rename to database/src/models/aggregated/circulating_supply.rs diff --git a/database/src/models/aggregated/mod.rs b/database/src/models/aggregated/mod.rs new file mode 100644 index 00000000..1f0c3ff1 --- /dev/null +++ b/database/src/models/aggregated/mod.rs @@ -0,0 +1 @@ +pub mod circulating_supply; diff --git a/src/models/assets/fungible_token_events.rs b/database/src/models/assets/fungible_token_events.rs similarity index 100% rename from src/models/assets/fungible_token_events.rs rename to database/src/models/assets/fungible_token_events.rs diff --git a/src/models/assets/mod.rs b/database/src/models/assets/mod.rs similarity index 100% rename from src/models/assets/mod.rs rename to database/src/models/assets/mod.rs diff --git a/src/models/assets/non_fungible_token_events.rs b/database/src/models/assets/non_fungible_token_events.rs similarity index 100% rename from src/models/assets/non_fungible_token_events.rs rename to database/src/models/assets/non_fungible_token_events.rs diff --git a/src/models/blocks.rs b/database/src/models/blocks.rs similarity index 86% rename from src/models/blocks.rs rename to database/src/models/blocks.rs index 257c306b..97c7ec9d 100644 --- a/src/models/blocks.rs +++ b/database/src/models/blocks.rs @@ -2,8 +2,6 @@ use std::str::FromStr; use bigdecimal::BigDecimal; -use near_indexer::near_primitives; - use crate::schema; use schema::blocks; @@ -18,8 +16,8 @@ pub struct Block { pub author_account_id: String, } -impl From<&near_primitives::views::BlockView> for Block { - fn from(block_view: &near_primitives::views::BlockView) -> Self { +impl From<&near_indexer_primitives::views::BlockView> for Block { + fn from(block_view: &near_indexer_primitives::views::BlockView) -> Self { Self { block_height: block_view.header.height.into(), block_hash: block_view.header.hash.to_string(), diff --git a/src/models/chunks.rs b/database/src/models/chunks.rs similarity index 87% rename from src/models/chunks.rs rename to database/src/models/chunks.rs index ba90f03b..de82715e 100644 --- a/src/models/chunks.rs +++ b/database/src/models/chunks.rs @@ -16,8 +16,8 @@ pub struct Chunk { impl Chunk { pub fn from_chunk_view( - chunk_view: &near_indexer::IndexerChunkView, - block_hash: &near_indexer::near_primitives::hash::CryptoHash, + chunk_view: &near_indexer_primitives::IndexerChunkView, + block_hash: &near_indexer_primitives::CryptoHash, ) -> Self { Self { included_in_block_hash: block_hash.to_string(), diff --git a/database/src/models/enums.rs b/database/src/models/enums.rs new file mode 100644 index 00000000..3e4f6ef7 --- /dev/null +++ b/database/src/models/enums.rs @@ -0,0 +1,148 @@ +use diesel_derive_enum::DbEnum; + +#[derive(Debug, DbEnum, Clone)] +#[DbValueStyle = "SCREAMING_SNAKE_CASE"] +#[DieselType = "Receipt_kind"] +#[PgType = "receipt_kind"] +pub enum ReceiptKind { + Action, + Data, +} + +impl From<&near_indexer_primitives::views::ReceiptEnumView> for ReceiptKind { + fn from(receipt_enum_view: &near_indexer_primitives::views::ReceiptEnumView) -> Self { + match receipt_enum_view { + near_indexer_primitives::views::ReceiptEnumView::Action { .. } => Self::Action, + near_indexer_primitives::views::ReceiptEnumView::Data { .. } => Self::Data, + } + } +} + +#[derive(Debug, DbEnum, Clone)] +#[DbValueStyle = "SCREAMING_SNAKE_CASE"] +#[DieselType = "Action_kind"] +#[PgType = "action_kind"] +pub enum ActionKind { + CreateAccount, + DeployContract, + FunctionCall, + Transfer, + Stake, + AddKey, + DeleteKey, + DeleteAccount, +} + +#[derive(Debug, DbEnum, Clone)] +#[DbValueStyle = "SCREAMING_SNAKE_CASE"] +#[DieselType = "Execution_outcome_status"] +#[PgType = "execution_outcome_status"] +pub enum ExecutionOutcomeStatus { + Unknown, + Failure, + SuccessValue, + SuccessReceiptId, +} + +impl From for ExecutionOutcomeStatus { + fn from(status: near_indexer_primitives::views::ExecutionStatusView) -> Self { + match status { + near_indexer_primitives::views::ExecutionStatusView::Unknown => Self::Unknown, + near_indexer_primitives::views::ExecutionStatusView::Failure(_) => Self::Failure, + near_indexer_primitives::views::ExecutionStatusView::SuccessValue(_) => { + Self::SuccessValue + } + near_indexer_primitives::views::ExecutionStatusView::SuccessReceiptId(_) => { + Self::SuccessReceiptId + } + } + } +} + +#[derive(Debug, DbEnum, Clone)] +#[DbValueStyle = "SCREAMING_SNAKE_CASE"] +#[DieselType = "Access_key_permission_kind"] +#[PgType = "access_key_permission_kind"] +pub enum AccessKeyPermission { + /// Used only with AccessKeyAction::Add + FullAccess, + /// Used only with AccessKeyAction::Add + FunctionCall, +} + +impl From<&near_indexer_primitives::views::AccessKeyPermissionView> for AccessKeyPermission { + fn from(item: &near_indexer_primitives::views::AccessKeyPermissionView) -> Self { + match item { + near_indexer_primitives::views::AccessKeyPermissionView::FunctionCall { .. } => { + Self::FunctionCall + } + near_indexer_primitives::views::AccessKeyPermissionView::FullAccess => Self::FullAccess, + } + } +} + +impl From<&near_primitives::account::AccessKeyPermission> for AccessKeyPermission { + fn from(item: &near_primitives::account::AccessKeyPermission) -> Self { + match item { + near_primitives::account::AccessKeyPermission::FunctionCall { .. } => { + Self::FunctionCall + } + near_primitives::account::AccessKeyPermission::FullAccess => Self::FullAccess, + } + } +} + +#[derive(Debug, DbEnum, Clone)] +#[DbValueStyle = "SCREAMING_SNAKE_CASE"] +#[DieselType = "State_change_reason_kind"] +#[PgType = "state_change_reason_kind"] +pub enum StateChangeReasonKind { + TransactionProcessing, + ActionReceiptProcessingStarted, + ActionReceiptGasReward, + ReceiptProcessing, + PostponedReceipt, + UpdatedDelayedReceipts, + ValidatorAccountsUpdate, + Migration, + Resharding, +} + +impl From<&near_indexer_primitives::views::StateChangeCauseView> for StateChangeReasonKind { + fn from( + state_change_cause_view: &near_indexer_primitives::views::StateChangeCauseView, + ) -> Self { + match state_change_cause_view { + near_indexer_primitives::views::StateChangeCauseView::TransactionProcessing { .. } => Self::TransactionProcessing, + near_indexer_primitives::views::StateChangeCauseView::ActionReceiptProcessingStarted { .. } => Self::ActionReceiptProcessingStarted, + near_indexer_primitives::views::StateChangeCauseView::ActionReceiptGasReward { .. } => Self::ActionReceiptGasReward, + near_indexer_primitives::views::StateChangeCauseView::ReceiptProcessing { .. } => Self::ReceiptProcessing, + near_indexer_primitives::views::StateChangeCauseView::PostponedReceipt { .. } => Self::PostponedReceipt, + near_indexer_primitives::views::StateChangeCauseView::UpdatedDelayedReceipts { .. } => Self::UpdatedDelayedReceipts, + near_indexer_primitives::views::StateChangeCauseView::ValidatorAccountsUpdate { .. } => Self::ValidatorAccountsUpdate, + near_indexer_primitives::views::StateChangeCauseView::Migration { .. } => Self::Migration, + near_indexer_primitives::views::StateChangeCauseView::Resharding { .. } => Self::Resharding, + near_indexer_primitives::views::StateChangeCauseView::NotWritableToDisk | near_indexer_primitives::views::StateChangeCauseView::InitialState => panic!("Unexpected variant {:?} received", state_change_cause_view), + } + } +} + +#[derive(Debug, DbEnum, Clone)] +#[DbValueStyle = "SCREAMING_SNAKE_CASE"] +#[DieselType = "Nft_event_kind"] +#[PgType = "nft_event_kind"] +pub enum NftEventKind { + Mint, + Transfer, + Burn, +} + +#[derive(Debug, DbEnum, Clone)] +#[DbValueStyle = "SCREAMING_SNAKE_CASE"] +#[DieselType = "Ft_event_kind"] +#[PgType = "ft_event_kind"] +pub enum FtEventKind { + Mint, + Transfer, + Burn, +} diff --git a/src/models/execution_outcomes.rs b/database/src/models/execution_outcomes.rs similarity index 94% rename from src/models/execution_outcomes.rs rename to database/src/models/execution_outcomes.rs index bac7f79b..15ac5918 100644 --- a/src/models/execution_outcomes.rs +++ b/database/src/models/execution_outcomes.rs @@ -22,7 +22,7 @@ pub struct ExecutionOutcome { impl ExecutionOutcome { pub fn from_execution_outcome( - execution_outcome: &near_indexer::near_primitives::views::ExecutionOutcomeWithIdView, + execution_outcome: &near_indexer_primitives::views::ExecutionOutcomeWithIdView, index_in_chunk: i32, executed_in_block_timestamp: u64, shard_id: u64, diff --git a/src/models/mod.rs b/database/src/models/mod.rs similarity index 67% rename from src/models/mod.rs rename to database/src/models/mod.rs index 0e90295c..344cd09a 100644 --- a/src/models/mod.rs +++ b/database/src/models/mod.rs @@ -1,7 +1,4 @@ -use std::env; - use diesel::PgConnection; -use dotenv::dotenv; pub use access_keys::AccessKey; pub use account_changes::AccountChange; @@ -30,16 +27,8 @@ pub mod receipts; mod serializers; pub mod transactions; -/// Get database credentials from `.env` or fail -pub(crate) fn get_database_credentials() -> String { - dotenv().ok(); - - env::var("DATABASE_URL").expect("DATABASE_URL must be set in .env file") -} - -pub(crate) fn establish_connection() -> actix_diesel::Database { - let database_url = get_database_credentials(); +pub fn establish_connection(database_url: &str) -> actix_diesel::Database { actix_diesel::Database::builder() .pool_max_size(30) - .open(&database_url) + .open(database_url) } diff --git a/src/models/receipts.rs b/database/src/models/receipts.rs similarity index 85% rename from src/models/receipts.rs rename to database/src/models/receipts.rs index 545505fd..e486e74e 100644 --- a/src/models/receipts.rs +++ b/database/src/models/receipts.rs @@ -3,7 +3,7 @@ use std::str::FromStr; use bigdecimal::BigDecimal; -use near_indexer::near_primitives::views::DataReceiverView; +use near_indexer_primitives::views::DataReceiverView; use crate::models::enums::{ActionKind, ReceiptKind}; use crate::schema; @@ -27,10 +27,10 @@ pub struct Receipt { impl Receipt { pub fn from_receipt_view( - receipt: &near_indexer::near_primitives::views::ReceiptView, - block_hash: &near_indexer::near_primitives::hash::CryptoHash, + receipt: &near_indexer_primitives::views::ReceiptView, + block_hash: &near_indexer_primitives::CryptoHash, transaction_hash: &str, - chunk_hash: &near_indexer::near_primitives::hash::CryptoHash, + chunk_hash: &near_indexer_primitives::CryptoHash, index_in_chunk: i32, block_timestamp: u64, ) -> Self { @@ -56,13 +56,13 @@ pub struct DataReceipt { pub data: Option>, } -impl TryFrom<&near_indexer::near_primitives::views::ReceiptView> for DataReceipt { +impl TryFrom<&near_indexer_primitives::views::ReceiptView> for DataReceipt { type Error = &'static str; fn try_from( - receipt_view: &near_indexer::near_primitives::views::ReceiptView, + receipt_view: &near_indexer_primitives::views::ReceiptView, ) -> Result { - if let near_indexer::near_primitives::views::ReceiptEnumView::Data { data_id, data } = + if let near_indexer_primitives::views::ReceiptEnumView::Data { data_id, data } = &receipt_view.receipt { Ok(Self { @@ -85,13 +85,13 @@ pub struct ActionReceipt { pub gas_price: BigDecimal, } -impl TryFrom<&near_indexer::near_primitives::views::ReceiptView> for ActionReceipt { +impl TryFrom<&near_indexer_primitives::views::ReceiptView> for ActionReceipt { type Error = &'static str; fn try_from( - receipt_view: &near_indexer::near_primitives::views::ReceiptView, + receipt_view: &near_indexer_primitives::views::ReceiptView, ) -> Result { - if let near_indexer::near_primitives::views::ReceiptEnumView::Action { + if let near_indexer_primitives::views::ReceiptEnumView::Action { signer_id, signer_public_key, gas_price, @@ -127,7 +127,7 @@ impl ActionReceiptAction { pub fn from_action_view( receipt_id: String, index: i32, - action_view: &near_indexer::near_primitives::views::ActionView, + action_view: &near_indexer_primitives::views::ActionView, predecessor_account_id: String, receiver_account_id: String, block_timestamp: u64, diff --git a/src/models/serializers.rs b/database/src/models/serializers.rs similarity index 73% rename from src/models/serializers.rs rename to database/src/models/serializers.rs index 3f6076ba..c741fd51 100644 --- a/src/models/serializers.rs +++ b/database/src/models/serializers.rs @@ -1,8 +1,8 @@ use serde::{Deserialize, Serialize}; use serde_json::json; -use near_indexer::near_primitives::serialize::dec_format; -use near_indexer::near_primitives::views::ActionView; +use near_indexer_primitives::views::ActionView; +use near_primitives::serialize::option_u128_dec_format; use crate::models::enums::ActionKind; @@ -10,12 +10,12 @@ use crate::models::enums::ActionKind; /// to change serde parameters of serialization. #[derive(Serialize, Deserialize, Debug, Clone)] pub(crate) struct AccessKeyView { - pub nonce: near_indexer::near_primitives::types::Nonce, + pub nonce: near_indexer_primitives::types::Nonce, pub permission: AccessKeyPermissionView, } -impl From<&near_indexer::near_primitives::views::AccessKeyView> for AccessKeyView { - fn from(access_key_view: &near_indexer::near_primitives::views::AccessKeyView) -> Self { +impl From<&near_indexer_primitives::views::AccessKeyView> for AccessKeyView { + fn from(access_key_view: &near_indexer_primitives::views::AccessKeyView) -> Self { Self { nonce: access_key_view.nonce, permission: access_key_view.permission.clone().into(), @@ -33,23 +33,19 @@ impl From<&near_indexer::near_primitives::views::AccessKeyView> for AccessKeyVie )] pub(crate) enum AccessKeyPermissionView { FunctionCall { - #[serde(with = "dec_format")] - allowance: Option, + #[serde(with = "option_u128_dec_format")] + allowance: Option, receiver_id: String, method_names: Vec, }, FullAccess, } -impl From - for AccessKeyPermissionView -{ - fn from(permission: near_indexer::near_primitives::views::AccessKeyPermissionView) -> Self { +impl From for AccessKeyPermissionView { + fn from(permission: near_indexer_primitives::views::AccessKeyPermissionView) -> Self { match permission { - near_indexer::near_primitives::views::AccessKeyPermissionView::FullAccess => { - Self::FullAccess - } - near_indexer::near_primitives::views::AccessKeyPermissionView::FunctionCall { + near_indexer_primitives::views::AccessKeyPermissionView::FullAccess => Self::FullAccess, + near_indexer_primitives::views::AccessKeyPermissionView::FunctionCall { allowance, receiver_id, method_names, @@ -66,13 +62,17 @@ impl From } pub(crate) fn extract_action_type_and_value_from_action_view( - action_view: &near_indexer::near_primitives::views::ActionView, + action_view: &near_indexer_primitives::views::ActionView, ) -> (crate::models::enums::ActionKind, serde_json::Value) { match action_view { ActionView::CreateAccount => (ActionKind::CreateAccount, json!({})), ActionView::DeployContract { code } => ( ActionKind::DeployContract, - json!({ "code_sha256": hex::encode(code) }), + json!({ + "code_sha256": hex::encode( + base64::decode(code).expect("code expected to be encoded to base64") + ) + }), ), ActionView::FunctionCall { method_name, @@ -82,17 +82,20 @@ pub(crate) fn extract_action_type_and_value_from_action_view( } => { let mut arguments = json!({ "method_name": method_name.escape_default().to_string(), - "args_base64": base64::encode(&args), + "args_base64": args, "gas": gas, "deposit": deposit.to_string(), }); // During denormalization of action_receipt_actions table we wanted to try to decode - // args in case if it is a JSON object and put them along side with args_base64 + // args which is base64 encoded in case if it is a JSON object and put them near initial + // args_base64 // See for reference https://github.com/near/near-indexer-for-explorer/issues/87 - if let Ok(mut args_json) = serde_json::from_slice(&args) { - escape_json(&mut args_json); - arguments["args_json"] = args_json; + if let Ok(decoded_args) = base64::decode(args) { + if let Ok(mut args_json) = serde_json::from_slice(&decoded_args) { + escape_json(&mut args_json); + arguments["args_json"] = args_json; + } } (ActionKind::FunctionCall, arguments) diff --git a/src/models/transactions.rs b/database/src/models/transactions.rs similarity index 91% rename from src/models/transactions.rs rename to database/src/models/transactions.rs index edcd9423..6ba76e66 100644 --- a/src/models/transactions.rs +++ b/database/src/models/transactions.rs @@ -26,12 +26,12 @@ pub struct Transaction { impl Transaction { pub fn from_indexer_transaction( - tx: &near_indexer::IndexerTransactionWithOutcome, + tx: &near_indexer_primitives::IndexerTransactionWithOutcome, // hack for supporting duplicated transaction hashes transaction_hash: &str, converted_into_receipt_id: &str, - block_hash: &near_indexer::near_primitives::hash::CryptoHash, - chunk_hash: &near_indexer::near_primitives::hash::CryptoHash, + block_hash: &near_indexer_primitives::CryptoHash, + chunk_hash: &near_indexer_primitives::CryptoHash, block_timestamp: u64, index_in_chunk: i32, ) -> Self { @@ -74,7 +74,7 @@ impl TransactionAction { pub fn from_action_view( transaction_hash: String, index: i32, - action_view: &near_indexer::near_primitives::views::ActionView, + action_view: &near_indexer_primitives::views::ActionView, ) -> Self { let (action_kind, args) = crate::models::extract_action_type_and_value_from_action_view(action_view); diff --git a/database/src/receipts_cache.rs b/database/src/receipts_cache.rs new file mode 100644 index 00000000..cd4c2179 --- /dev/null +++ b/database/src/receipts_cache.rs @@ -0,0 +1,16 @@ +use cached::SizedCache; +use tokio::sync::Mutex; + +#[derive(Clone, Hash, PartialEq, Eq, Debug)] +pub enum ReceiptOrDataId { + ReceiptId(near_indexer_primitives::CryptoHash), + DataId(near_indexer_primitives::CryptoHash), +} +// Creating type aliases to make HashMap types for cache more explicit +pub type ParentTransactionHashString = String; +// Introducing a simple cache for Receipts to find their parent Transactions without +// touching the database +// The key is ReceiptID +// The value is TransactionHash (the very parent of the Receipt) +pub type ReceiptsCache = + std::sync::Arc>>; diff --git a/src/retriable.rs b/database/src/retryable.rs similarity index 95% rename from src/retriable.rs rename to database/src/retryable.rs index c2d53635..dd0649ab 100644 --- a/src/retriable.rs +++ b/database/src/retryable.rs @@ -23,7 +23,7 @@ macro_rules! await_retry_or_panic { })? tracing::error!( - target: crate::INDEXER_FOR_EXPLORER, + target: crate::EXPLORER_DATABASE, "Error occurred during {}: \n{:#?} \n{:#?} \n Retrying in {} milliseconds...", async_error, &$error_message, diff --git a/src/schema.patch b/database/src/schema.patch similarity index 100% rename from src/schema.patch rename to database/src/schema.patch diff --git a/src/schema.rs b/database/src/schema.rs similarity index 100% rename from src/schema.rs rename to database/src/schema.rs diff --git a/CHANGELOG.md b/indexer/CHANGELOG.md similarity index 94% rename from CHANGELOG.md rename to indexer/CHANGELOG.md index a703d6ff..5dedd5c4 100644 --- a/CHANGELOG.md +++ b/indexer/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +## 0.11.0 + +* Migrate to NEAR Lake Framework, `indexer-explorer` no longer runs a NEAR node and instead consumes block from [near-lake-indexer](https://github.com/near/near-lake-indexer). + +### Breaking Changes + +* Storing genesis file is no longer possible (#327) +* Command line arguments for starting the indexer have changed slightly, see [Readme](../README.md) for updated reference +* AWS credentials are now required for reading data from S3 + ## 0.10.32 * Avoid recreating access key on transfer to implicit account diff --git a/indexer/Cargo.toml b/indexer/Cargo.toml new file mode 100644 index 00000000..37b58ed6 --- /dev/null +++ b/indexer/Cargo.toml @@ -0,0 +1,37 @@ +[package] +name = "indexer-explorer" +version = "0.11.0" +authors = ["Near Inc "] +edition = "2021" +rust-version = "1.64" + +[dependencies] +actix = "0.13.0" +actix-rt = "2.2.0" +actix-web = "=4.0.1" +anyhow = "1.0.51" +aws-types = "0.13.0" +aws-sdk-s3 = "0.13.0" +borsh = "0.7.1" +cached = "0.23.0" +chrono = "0.4.19" +clap = { version = "3.1.6", features = ["color", "derive", "env"] } +dotenv = "0.15.0" +futures = "0.3.5" +itertools = "0.10.3" +lazy_static = "^1.4" +# syn version conflict, replace with crates.io version once released +near-sdk = { git = "https://github.com/near/near-sdk-rs", rev="03487c184d37b0382dd9bd41c57466acad58fc1f" } +openssl-probe = { version = "0.1.2" } +prometheus = "0.13.0" +r2d2 = "0.8.8" +tokio = { version = "1.1", features = ["sync", "time"] } +tokio-stream = { version = "0.1" } +tracing = "0.1.13" +tracing-subscriber = "0.2.4" +uint = { version = "0.8.3", default-features = false } + +near-jsonrpc-client = "0.4.0-beta.0" +near-lake-framework = "0.5.2" + +explorer-database = { path = "../database" } diff --git a/indexer/Dockerfile b/indexer/Dockerfile new file mode 100644 index 00000000..c1fef49e --- /dev/null +++ b/indexer/Dockerfile @@ -0,0 +1,15 @@ +FROM rust:1.64 AS builder +WORKDIR /tmp/ +COPY Cargo.toml Cargo.lock ./ +COPY database database +COPY indexer indexer +# Copy 'circulating-supply' because is member of the workspace but is not compiled or added to the +# output image. +COPY circulating-supply circulating-supply +RUN cargo build -p indexer-explorer-lake --release + +FROM ubuntu:20.04 +RUN apt update && apt install -yy openssl ca-certificates +RUN apt-get install libpq5 -y +COPY --from=builder /tmp/target/release/indexer-explorer-lake . +ENTRYPOINT [ "./indexer-explorer-lake" ] diff --git a/indexer/src/configs.rs b/indexer/src/configs.rs new file mode 100644 index 00000000..8bed25f6 --- /dev/null +++ b/indexer/src/configs.rs @@ -0,0 +1,165 @@ +use clap::{Parser, Subcommand}; +use tracing_subscriber::EnvFilter; + +use explorer_database::{adapters, models}; + +use near_jsonrpc_client::{methods, JsonRpcClient}; +use near_lake_framework::near_indexer_primitives::types::{BlockReference, Finality}; + +/// NEAR Indexer for Explorer Lake +/// Watches for stream of blocks from the chain +/// built on top of NEAR Lake Framework +#[derive(Parser, Debug)] +#[clap( + version, + author, + about, + disable_help_subcommand(true), + propagate_version(true), + next_line_help(true) +)] +pub(crate) struct Opts { + /// Connection string to connect to the PostgreSQL Database to fetch AlertRules from + #[clap(long, env)] + pub database_url: String, + /// Enabled Indexer for Explorer debug level of logs + #[clap(long)] + pub debug: bool, + /// Switches indexer to non-strict mode (skips Receipts without parent Transaction hash, stops storing AccountChanges and AccessKeys) + #[clap(long)] + pub non_strict_mode: bool, + /// Sets the concurrency for indexing. Note: concurrency (set to 2+) may lead to warnings due to tight constraints between transactions and receipts (those will get resolved eventually, but unless it is the second pass of indexing, concurrency won't help at the moment). + #[clap(long, default_value = "1")] + pub concurrency: std::num::NonZeroU16, + /// Port to enable metrics/health service + #[clap(long, short, env, default_value_t = 3030)] + pub port: u16, + /// Chain ID: testnet or mainnet + #[clap(subcommand)] + pub chain_id: ChainId, +} + +#[derive(Subcommand, Debug, Clone)] +pub enum ChainId { + #[clap(subcommand)] + Mainnet(StartOptions), + #[clap(subcommand)] + Testnet(StartOptions), +} + +#[allow(clippy::enum_variant_names)] +#[derive(Subcommand, Debug, Clone)] +pub enum StartOptions { + /// Start from specific block height + FromBlock { height: u64 }, + /// Start from interruption (last_indexed_block value from Redis) + FromInterruption, + /// Start from the final block on the network (queries JSON RPC for finality: final) + FromLatest, +} + +impl Opts { + /// Returns [StartOptions] for current [Opts] + pub fn start_options(&self) -> &StartOptions { + match &self.chain_id { + ChainId::Mainnet(start_options) | ChainId::Testnet(start_options) => start_options, + } + } + + pub fn rpc_url(&self) -> &str { + match self.chain_id { + ChainId::Mainnet(_) => "https://rpc.mainnet.near.org", + ChainId::Testnet(_) => "https://rpc.testnet.near.org", + } + } +} + +impl Opts { + pub async fn to_lake_config(&self) -> near_lake_framework::LakeConfig { + let config_builder = near_lake_framework::LakeConfigBuilder::default(); + + match &self.chain_id { + ChainId::Mainnet(_) => config_builder.mainnet(), + ChainId::Testnet(_) => config_builder.testnet(), + } + .start_block_height(get_start_block_height(self).await) + .build() + .expect("Failed to build LakeConfig") + } +} + +async fn get_start_block_height(opts: &Opts) -> u64 { + match opts.start_options() { + StartOptions::FromBlock { height } => *height, + StartOptions::FromInterruption => { + let pool = models::establish_connection(&opts.database_url); + let last_indexed_block: u64 = match adapters::blocks::latest_block_height(&pool).await { + Ok(last_indexed_block) => { + if let Some(last_indexed_block) = last_indexed_block { + last_indexed_block + } else { + final_block_height(opts).await + } + } + Err(err) => { + tracing::warn!( + target: "alertexer", + "Failed to get last indexer block from Database. Failing to the latest one...\n{:#?}", + err + ); + final_block_height(opts).await + } + }; + last_indexed_block + } + StartOptions::FromLatest => final_block_height(opts).await, + } +} + +pub(crate) fn init_tracing(debug: bool) -> anyhow::Result<()> { + let mut env_filter = + EnvFilter::new("near_lake_framework=info,indexer_for_explorer=info,stats=info"); + + if debug { + env_filter = env_filter + .add_directive("indexer_for_explorer=debug".parse()?) + .add_directive("near_lake_framework=debug".parse()?); + } + + if let Ok(rust_log) = std::env::var("RUST_LOG") { + if !rust_log.is_empty() { + for directive in rust_log.split(',').filter_map(|s| match s.parse() { + Ok(directive) => Some(directive), + Err(err) => { + eprintln!("Ignoring directive `{}`: {}", s, err); + None + } + }) { + env_filter = env_filter.add_directive(directive); + } + } + } + + let subscriber = tracing_subscriber::fmt::Subscriber::builder() + .with_env_filter(env_filter) + .with_writer(std::io::stderr); + + if std::env::var("ENABLE_JSON_LOGS").is_ok() { + subscriber.json().init(); + } else { + subscriber.compact().init(); + } + + Ok(()) +} + +async fn final_block_height(opts: &Opts) -> u64 { + let client = JsonRpcClient::connect(opts.rpc_url()); + let request = methods::block::RpcBlockRequest { + block_reference: BlockReference::Finality(Finality::Final), + }; + + let latest_block = client.call(request).await.unwrap(); + + latest_block.header.height +} diff --git a/indexer/src/main.rs b/indexer/src/main.rs new file mode 100644 index 00000000..dc28c041 --- /dev/null +++ b/indexer/src/main.rs @@ -0,0 +1,197 @@ +use clap::Parser; + +pub use cached::SizedCache; +use futures::future::try_join_all; +use futures::{try_join, StreamExt}; +use tokio::sync::Mutex; +use tracing::{debug, info}; + +use explorer_database::{adapters, models, receipts_cache}; + +use crate::configs::Opts; + +mod configs; +mod metrics; + +// Categories for logging +const INDEXER_FOR_EXPLORER: &str = "indexer_for_explorer"; + +async fn handle_message( + pool: &explorer_database::actix_diesel::Database, + streamer_message: near_lake_framework::near_indexer_primitives::StreamerMessage, + strict_mode: bool, + receipts_cache: receipts_cache::ReceiptsCache, +) -> anyhow::Result<()> { + metrics::BLOCK_COUNT.inc(); + metrics::LATEST_BLOCK_HEIGHT.set(streamer_message.block.header.height.try_into().unwrap()); + + debug!( + target: INDEXER_FOR_EXPLORER, + "ReceiptsCache #{} \n {:#?}", streamer_message.block.header.height, &receipts_cache + ); + adapters::blocks::store_block(pool, &streamer_message.block).await?; + + // Chunks + adapters::chunks::store_chunks( + pool, + &streamer_message.shards, + &streamer_message.block.header.hash, + ) + .await?; + + // Transactions + let transactions_future = adapters::transactions::store_transactions( + pool, + &streamer_message.shards, + &streamer_message.block.header.hash, + streamer_message.block.header.timestamp, + streamer_message.block.header.height, + std::sync::Arc::clone(&receipts_cache), + ); + + // Receipts + let receipts_future = adapters::receipts::store_receipts( + pool, + &streamer_message.shards, + &streamer_message.block.header.hash, + streamer_message.block.header.timestamp, + strict_mode, + std::sync::Arc::clone(&receipts_cache), + ); + + // We can process transactions and receipts in parallel + // because most of receipts depend on transactions from previous blocks, + // so we can save up some time here. + // In case of local receipts (they are stored in the same block with corresponding transaction), + // we hope retry logic will cover it fine + try_join!(transactions_future, receipts_future)?; + + // ExecutionOutcomes + let execution_outcomes_future = adapters::execution_outcomes::store_execution_outcomes( + pool, + &streamer_message.shards, + streamer_message.block.header.timestamp, + std::sync::Arc::clone(&receipts_cache), + ); + + // Accounts + let accounts_future = async { + let futures = streamer_message.shards.iter().map(|shard| { + adapters::accounts::handle_accounts( + pool, + &shard.receipt_execution_outcomes, + streamer_message.block.header.height, + ) + }); + + try_join_all(futures).await.map(|_| ()) + }; + + // Event-based entities (FT, NFT) + let assets_events_future = adapters::assets::events::store_events(pool, &streamer_message); + + if strict_mode { + // AccessKeys + let access_keys_future = async { + let futures = streamer_message.shards.iter().map(|shard| { + adapters::access_keys::handle_access_keys( + pool, + &shard.state_changes, + streamer_message.block.header.height, + ) + }); + + try_join_all(futures).await.map(|_| ()) + }; + + // StateChange related to Account + let account_changes_future = adapters::account_changes::store_account_changes( + pool, + &streamer_message.shards, + &streamer_message.block.header.hash, + streamer_message.block.header.timestamp, + ); + + try_join!( + execution_outcomes_future, + accounts_future, + access_keys_future, + assets_events_future, + account_changes_future, + )?; + } else { + try_join!( + execution_outcomes_future, + accounts_future, + assets_events_future + )?; + } + + Ok(()) +} + +#[actix::main] +async fn main() -> anyhow::Result<()> { + // We use it to automatically search the for root certificates to perform HTTPS calls + // (sending telemetry and downloading genesis) + openssl_probe::init_ssl_cert_env_vars(); + + dotenv::dotenv().ok(); + + let opts: Opts = Opts::parse(); + + configs::init_tracing(opts.debug)?; + + // We establish connection as early as possible as an additional sanity check. + // Indexer should fail if .env file with credentials is missing/wrong + let pool = models::establish_connection(&opts.database_url); + + let strict_mode = !opts.non_strict_mode; + + // We want to prevent unnecessary SELECT queries to the database to find + // the Transaction hash for the Receipt. + // Later we need to find the Receipt which is a parent to underlying Receipts. + // Receipt ID will of the child will be stored as key and parent Transaction hash/Receipt ID + // will be stored as a value + let receipts_cache: receipts_cache::ReceiptsCache = + std::sync::Arc::new(Mutex::new(SizedCache::with_size(100_000))); + + let config: near_lake_framework::LakeConfig = opts.to_lake_config().await; + let (_, stream) = near_lake_framework::streamer(config); + + tokio::spawn(metrics::init_server(opts.port).expect("Failed to start metrics server")); + + tracing::info!( + target: INDEXER_FOR_EXPLORER, + "Starting Indexer for Explorer (lake)...", + ); + + let mut handlers = tokio_stream::wrappers::ReceiverStream::new(stream) + .map(|streamer_message| { + info!( + target: crate::INDEXER_FOR_EXPLORER, + "Block height {}", &streamer_message.block.header.height + ); + handle_message( + &pool, + streamer_message, + strict_mode, + std::sync::Arc::clone(&receipts_cache), + ) + }) + .buffer_unordered(1usize); + + while let Some(handle_message) = handlers.next().await { + if let Err(e) = handle_message { + tracing::error!( + target: crate::INDEXER_FOR_EXPLORER, + "Encountered error while indexing: {}", + e + ); + anyhow::bail!(e) + } + } + + // unreachable statement, loop above is endless + Ok(()) +} diff --git a/indexer/src/metrics.rs b/indexer/src/metrics.rs new file mode 100644 index 00000000..81c47aba --- /dev/null +++ b/indexer/src/metrics.rs @@ -0,0 +1,55 @@ +use actix_web::{get, App, HttpServer, Responder}; +use lazy_static::lazy_static; +use prometheus::{Encoder, IntCounter, IntGauge, Opts}; +use tracing::info; + +lazy_static! { + pub(crate) static ref LATEST_BLOCK_HEIGHT: IntGauge = try_create_int_gauge( + "indexer_explorer_latest_block_height", + "Height of last processed block" + ) + .unwrap(); + pub(crate) static ref BLOCK_COUNT: IntCounter = + try_create_int_counter("indexer_explorer_block_count", "Number of indexed blocks").unwrap(); +} + +fn try_create_int_gauge(name: &str, help: &str) -> prometheus::Result { + let opts = Opts::new(name, help); + let gauge = IntGauge::with_opts(opts)?; + prometheus::register(Box::new(gauge.clone()))?; + Ok(gauge) +} + +fn try_create_int_counter(name: &str, help: &str) -> prometheus::Result { + let opts = Opts::new(name, help); + let counter = IntCounter::with_opts(opts)?; + prometheus::register(Box::new(counter.clone()))?; + Ok(counter) +} + +#[get("/metrics")] +async fn get_metrics() -> impl Responder { + let mut buffer = Vec::::new(); + let encoder = prometheus::TextEncoder::new(); + loop { + match encoder.encode(&prometheus::gather(), &mut buffer) { + Ok(_) => break, + Err(err) => { + eprintln!("{:?}", err); + } + } + } + String::from_utf8(buffer.clone()).unwrap() +} + +pub(crate) fn init_server(port: u16) -> anyhow::Result { + info!( + target: crate::INDEXER_FOR_EXPLORER, + "Starting metrics server on http://0.0.0.0:{port}" + ); + + Ok(HttpServer::new(|| App::new().service(get_metrics)) + .bind(("0.0.0.0", port))? + .disable_signals() + .run()) +} diff --git a/migrations/.gitkeep b/migrations/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/run-in-docker.sh b/run-in-docker.sh deleted file mode 100755 index 71d6bcd6..00000000 --- a/run-in-docker.sh +++ /dev/null @@ -1,113 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail # Bash "strict mode" -script_dirpath="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" - - -# ================================================================================================== -# Constants -# ================================================================================================== -# The path where the localnet NEAR config dir will be initialized -LOCALNET_NEAR_DIRPATH="/root/.near/localnet" -CONFIG_JSON_FILEPATH="${LOCALNET_NEAR_DIRPATH}/config.json" - -# Config properties that will be set as part of startup -TRACKED_SHARD_CONFIG_PROPERTY="tracked_shards" -ARCHIVE_CONFIG_PROPERTY="archive" - - -# ================================================================================================== -# Arg Parsing & Validation -# ================================================================================================== -show_helptext_and_exit() { - echo "Usage: $(basename "${0}") diesel_binary_filepath database_url indexer_binary_filepath [extra_indexer_param]..." - echo "" - echo " diesel_binary_filepath The filepath to the Diesel binary that will be used to run the database migration" - echo " database_url The URL of the database against which the Diesel migration should be run, and the " - echo " indexer should connect to (e.g. \"postgres://near:near@contract-helper-db:5432/indexer\")" - echo " indexer_binary_filepath The filepath to the binary that will run the indexer node" - echo " extra_indexer_param... An arbitrary number of extra parameters that will be passed as-is to the indexer" - echo "" - exit 1 # Exit with an error so that if this is accidentally called by CI, the script will fail -} - -diesel_binary_filepath="${1:-}" -database_url="${2:-}" -indexer_binary_filepath="${3:-}" - -if [ -z "${diesel_binary_filepath}" ]; then - echo "Error: no Diesel binary filepath provided" >&2 - show_helptext_and_exit -fi -if ! [ -f "${diesel_binary_filepath}" ]; then - echo "Error: provided Diesel binary filepath '${some_filepath_arg}' isn't a valid file" >&2 - show_helptext_and_exit -fi -if [ -z "${database_url}" ]; then - echo "Error: no database URL provided" >&2 - show_helptext_and_exit -fi -if [ -z "${indexer_binary_filepath}" ]; then - echo "Error: no indexer binary filepath provided" >&2 - show_helptext_and_exit -fi -if ! [ -f "${indexer_binary_filepath}" ]; then - echo "Error: provided indexer binary filepath '${some_filepath_arg}' isn't a valid file" >&2 - show_helptext_and_exit -fi - -shift 3 # Prep for consuming the extra indexer params below - - -# ================================================================================================== -# Main Logic -# ================================================================================================== -# We add this check to see if the localnet directory already exists so that we can restart the -# indexer-for-explorer container: if the directory doesn't exist, the container is starting for the -# first time; if it already exists, the container is restarting so there's no need to do the migration -# or genesis setup -if ! [ -d "${LOCALNET_NEAR_DIRPATH}" ]; then - if ! DATABASE_URL="${database_url}" "${diesel_binary_filepath}" migration run; then - echo "Error: The Diesel migration failed" >&2 - exit 1 - fi - - if ! DATABASE_URL="${database_url}" "${indexer_binary_filepath}" --home-dir "${LOCALNET_NEAR_DIRPATH}" init ${BOOT_NODES:+--boot-nodes=${BOOT_NODES}} --chain-id localnet; then - echo "Error: An error occurred generating the genesis information" >&2 - exit 1 - fi - - # Required due to https://github.com/near/near-indexer-for-explorer#configure-near-indexer-for-explorer - if ! num_tracked_shard_instances="$(grep -c "\"${TRACKED_SHARD_CONFIG_PROPERTY}\":" "${CONFIG_JSON_FILEPATH}" || true)"; then - echo "Error: An error occurred getting the number of instances of the '${TRACKED_SHARD_CONFIG_PROPERTY}' config property to verify there's only one" >&2 - exit 1 - fi - if [ "${num_tracked_shard_instances}" -ne 1 ]; then - echo "Error: Expected exactly one line to match property '${TRACKED_SHARD_CONFIG_PROPERTY}' in config file '${CONFIG_JSON_FILEPATH}' but got ${num_tracked_shard_instances}" >&2 - exit 1 - fi - if ! sed -i 's/"'${TRACKED_SHARD_CONFIG_PROPERTY}'": \[\]/"'${TRACKED_SHARD_CONFIG_PROPERTY}'": \[0\]/' "${CONFIG_JSON_FILEPATH}"; then - echo "Error: An error occurred setting the tracked shards in the config" >&2 - exit 1 - fi - - # Required to keep more than 5 blocks in memory - if ! num_archive_instances="$(grep -c "\"${ARCHIVE_CONFIG_PROPERTY}\":" "${CONFIG_JSON_FILEPATH}" || true)"; then - echo "Error: An error occurred getting the number of instances of the '${ARCHIVE_CONFIG_PROPERTY}' config property to verify there's only one" >&2 - exit 1 - fi - if [ "${num_archive_instances}" -ne 1 ]; then - echo "Error: Expected exactly one line to match property '${ARCHIVE_CONFIG_PROPERTY}' in config file '${CONFIG_JSON_FILEPATH}' but got ${num_archive_instances}" >&2 - exit 1 - fi - if ! sed -i 's/"'${ARCHIVE_CONFIG_PROPERTY}'": false/"'${ARCHIVE_CONFIG_PROPERTY}'": true/' "${CONFIG_JSON_FILEPATH}"; then - echo "Error: An error occurred setting the archive mode to true" >&2 - exit 1 - fi -fi - -# NOTE1: If the --store-genesis flag isn't set, the accounts in genesis won't get created in the DB which will lead to foreign key constraint violations -# See https://github.com/near/near-indexer-for-explorer/issues/167 -# NOTE2: The funky ${1+"${@}"} incantation is how you you feed arguments exactly as-is to a child script in Bash -# ${*} loses quoting and ${@} trips set -e if no arguments are passed, so this incantation says, "if and only if -# ${1} exists, evaluate ${@}" -DATABASE_URL="${database_url}" "${indexer_binary_filepath}" --home-dir "${LOCALNET_NEAR_DIRPATH}" run --store-genesis sync-from-latest ${1+"${@}"} diff --git a/src/aggregated/account_details.rs b/src/aggregated/account_details.rs deleted file mode 100644 index ed59ed95..00000000 --- a/src/aggregated/account_details.rs +++ /dev/null @@ -1,66 +0,0 @@ -use actix::Addr; -use anyhow::Context; - -use near_client::{Query, ViewClientActor}; -use near_indexer::near_primitives; - -pub(crate) async fn get_account_balance( - view_client: &Addr, - account_id: &near_primitives::types::AccountId, - block_height: &near_primitives::types::BlockHeight, -) -> anyhow::Result { - get_account_view_for_block_height(view_client, account_id, block_height) - .await - .map(|account| account.amount) - .with_context(|| format!("Unable to get account balance for {}", account_id)) -} - -pub(crate) async fn get_contract_code_hash( - view_client: &Addr, - account_id: &near_primitives::types::AccountId, - block_height: &near_primitives::types::BlockHeight, -) -> anyhow::Result { - get_account_view_for_block_height(view_client, account_id, block_height) - .await - .map(|account| account.code_hash) - .with_context(|| format!("Unable to get contract code hash for {}", account_id)) -} - -async fn get_account_view_for_block_height( - view_client: &Addr, - account_id: &near_primitives::types::AccountId, - block_height: &near_primitives::types::BlockHeight, -) -> anyhow::Result { - let block_reference = near_primitives::types::BlockReference::BlockId( - near_primitives::types::BlockId::Height(*block_height), - ); - let request = near_primitives::views::QueryRequest::ViewAccount { - account_id: account_id.clone(), - }; - let query = Query::new(block_reference, request); - - let account_response = view_client - .send(query) - .await - .with_context(|| { - format!( - "Failed to deliver ViewAccount for account {}, block {}", - account_id, block_height - ) - })? - .with_context(|| { - format!( - "Invalid ViewAccount query for account {}, block {}", - account_id, block_height - ) - })?; - - match account_response.kind { - near_primitives::views::QueryResponseKind::ViewAccount(account) => Ok(account), - _ => anyhow::bail!( - "Failed to extract ViewAccount response for account {}, block {}", - account_id, - block_height - ), - } -} diff --git a/src/aggregated/mod.rs b/src/aggregated/mod.rs deleted file mode 100644 index 5c24db0c..00000000 --- a/src/aggregated/mod.rs +++ /dev/null @@ -1,16 +0,0 @@ -use actix_diesel::Database; -use diesel::PgConnection; -use near_indexer::Indexer; - -mod account_details; -mod circulating_supply; - -pub(crate) fn spawn_aggregated_computations(pool: Database, indexer: &Indexer) { - let view_client = indexer.client_actors().0; - if indexer.near_config().genesis.config.chain_id == "mainnet" { - actix::spawn(circulating_supply::run_circulating_supply_computation( - view_client, - pool, - )); - } -} diff --git a/src/configs.rs b/src/configs.rs deleted file mode 100644 index 680810ff..00000000 --- a/src/configs.rs +++ /dev/null @@ -1,133 +0,0 @@ -use std::convert::TryFrom; - -use clap::Parser; - -/// NEAR Indexer for Explorer -/// Watches for stream of blocks from the chain -#[derive(Parser, Debug)] -#[clap( - version, - author, - about, - disable_help_subcommand(true), - propagate_version(true), - next_line_help(true) -)] -pub(crate) struct Opts { - /// Sets a custom config dir. Defaults to ~/.near/ - #[clap(short, long)] - pub home_dir: Option, - /// Enabled Indexer for Explorer debug level of logs - #[clap(long)] - pub debug: bool, - #[clap(subcommand)] - pub subcmd: SubCommand, -} - -#[derive(Parser, Debug)] -pub(crate) enum SubCommand { - /// Run NEAR Indexer Example. Start observe the network - Run(RunArgs), - /// Initialize necessary configs - Init(InitConfigArgs), -} - -#[derive(Parser, Debug, Clone)] -pub(crate) struct RunArgs { - /// Store initial data from genesis like Accounts, AccessKeys - #[clap(long)] - pub store_genesis: bool, - /// Force streaming while node is syncing - #[clap(long)] - pub stream_while_syncing: bool, - /// Switches indexer to non-strict mode (skips Receipts without parent Transaction hash, stops storing AccountChanges and AccessKeys) - #[clap(long)] - pub non_strict_mode: bool, - /// Stops indexer completely after indexing the provided number of blocks - #[clap(long, short)] - pub stop_after_number_of_blocks: Option, - /// Sets the concurrency for indexing. Note: concurrency (set to 2+) may lead to warnings due to tight constraints between transactions and receipts (those will get resolved eventually, but unless it is the second pass of indexing, concurrency won't help at the moment). - #[clap(long, default_value = "1")] - pub concurrency: std::num::NonZeroU16, - #[clap(subcommand)] - pub sync_mode: SyncModeSubCommand, -} - -#[allow(clippy::enum_variant_names)] // we want commands to be more explicit -#[derive(Parser, Debug, Clone)] -pub(crate) enum SyncModeSubCommand { - /// continue from the block Indexer was interrupted - SyncFromInterruption(InterruptionArgs), - /// start from the newest block after node finishes syncing - SyncFromLatest, - /// start from specified block height - SyncFromBlock(BlockArgs), -} - -#[derive(Parser, Debug, Clone)] -pub(crate) struct InterruptionArgs { - /// start indexing this number of blocks earlier than the actual interruption happened - #[clap(long, default_value = "0")] - pub delta: u64, -} - -#[derive(Parser, Debug, Clone)] -pub(crate) struct BlockArgs { - /// block height for block sync mode - #[clap(long)] - pub height: u64, -} - -impl TryFrom for near_indexer::SyncModeEnum { - type Error = &'static str; - - fn try_from(sync_mode: SyncModeSubCommand) -> Result { - match sync_mode { - SyncModeSubCommand::SyncFromInterruption(_) => Err("Unable to convert SyncFromInterruption variant because it has additional parameter which is not acceptable by near_indexer::SyncModeEnum::SyncFromInterruption"), - SyncModeSubCommand::SyncFromLatest => Ok(Self::LatestSynced), - SyncModeSubCommand::SyncFromBlock(args) => Ok(Self::BlockHeight(args.height)), - } - } -} - -#[derive(Parser, Debug)] -pub(crate) struct InitConfigArgs { - /// chain/network id (localnet, testnet, devnet, betanet) - #[clap(short, long)] - pub chain_id: Option, - /// Account ID for the validator key - #[clap(long)] - pub account_id: Option, - /// Specify private key generated from seed (TESTING ONLY) - #[clap(long)] - pub test_seed: Option, - /// Number of shards to initialize the chain with - #[clap(short, long, default_value = "1")] - pub num_shards: u64, - /// Makes block production fast (TESTING ONLY) - #[clap(short, long)] - pub fast: bool, - /// Genesis file to use when initialize testnet (including downloading) - #[clap(short, long)] - pub genesis: Option, - #[clap(short, long)] - /// Download the verified NEAR config file automatically. - #[clap(long)] - pub download_config: bool, - #[clap(long)] - pub download_config_url: Option, - /// Download the verified NEAR genesis file automatically. - #[clap(long)] - pub download_genesis: bool, - /// Specify a custom download URL for the genesis-file. - #[clap(long)] - pub download_genesis_url: Option, - /// Customize max_gas_burnt_view runtime limit. If not specified, value - /// from genesis configuration will be taken. - #[clap(long)] - pub max_gas_burnt_view: Option, - /// Initialize boots nodes in @ format seperated by commas - /// to bootstrap the network and store them in config.json - #[clap(long)] - pub boot_nodes: Option, -} diff --git a/src/db_adapters/aggregated/mod.rs b/src/db_adapters/aggregated/mod.rs deleted file mode 100644 index eecd50a6..00000000 --- a/src/db_adapters/aggregated/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub(crate) mod circulating_supply; diff --git a/src/db_adapters/genesis.rs b/src/db_adapters/genesis.rs deleted file mode 100644 index 96518fa2..00000000 --- a/src/db_adapters/genesis.rs +++ /dev/null @@ -1,129 +0,0 @@ -use actix_diesel::Database; -use diesel::PgConnection; - -use crate::db_adapters::access_keys::store_access_keys_from_genesis; -use crate::db_adapters::accounts::store_accounts_from_genesis; - -/// This is an ugly hack that allows to execute an async body on a specified actix runtime. -/// You should only call it from a separate thread! -/// -/// ```ignore -/// async fn some_async_function() { -/// let current_actix_system = actix::System::current(); -/// tokio::tasks::spawn_blocking(move || { -/// let x = vec![0, 1, 2]; -/// x.map(|i| { -/// block_on(current_actix_system, async move { -/// reqwest::get(...).await.text().await -/// }) -/// }); -/// } -/// } -fn block_on( - actix_arbiter: &actix_rt::ArbiterHandle, - f: Fut, -) -> Result -where - T: Send + 'static, - Fut: std::future::Future + Send + 'static, -{ - let (tx, rx) = std::sync::mpsc::channel(); - actix_arbiter.spawn(async move { - let result = f.await; - let _ = tx.send(result); - }); - rx.recv() -} - -/// Iterates over GenesisRecords and stores selected ones (Accounts, AccessKeys) -/// to database. -/// Separately stores records divided in portions by 5000 to optimize -/// memory usage and minimize database queries -pub(crate) async fn store_genesis_records( - pool: Database, - near_config: near_indexer::NearConfig, -) -> anyhow::Result<()> { - tracing::info!( - target: crate::INDEXER_FOR_EXPLORER, - "Storing genesis records to database...", - ); - let genesis_height = near_config.genesis.config.genesis_height; - - // Remember the current actix runtime thread in order to be able to - // schedule async function on it from the thread that processes genesis in - // a blocking way. - let actix_system = actix::System::current(); - // Spawn the blocking genesis processing on a separate thread - tokio::task::spawn_blocking(move || { - let actix_arbiter = actix_system.arbiter(); - - let mut accounts_to_store: Vec = vec![]; - let mut access_keys_to_store: Vec = vec![]; - - near_config.genesis.for_each_record(|record| { - if accounts_to_store.len() == 5_000 { - let mut accounts_to_store_chunk = vec![]; - std::mem::swap(&mut accounts_to_store, &mut accounts_to_store_chunk); - let pool = pool.clone(); - block_on( - actix_arbiter, - store_accounts_from_genesis(pool, accounts_to_store_chunk), - ) - .expect("storing accounts from genesis failed") - .expect("storing accounts from genesis failed"); - } - if access_keys_to_store.len() == 5_000 { - let mut access_keys_to_store_chunk = vec![]; - std::mem::swap(&mut access_keys_to_store, &mut access_keys_to_store_chunk); - let pool = pool.clone(); - block_on( - actix_arbiter, - store_access_keys_from_genesis(pool, access_keys_to_store_chunk), - ) - .expect("storing access keys from genesis failed") - .expect("storing access keys from genesis failed"); - } - - match record { - near_indexer::near_primitives::state_record::StateRecord::Account { - account_id, - .. - } => { - accounts_to_store.push(crate::models::accounts::Account::new_from_genesis( - account_id, - genesis_height, - )); - } - near_indexer::near_primitives::state_record::StateRecord::AccessKey { - account_id, - public_key, - access_key, - } => { - access_keys_to_store.push(crate::models::access_keys::AccessKey::from_genesis( - public_key, - account_id, - access_key, - genesis_height, - )); - } - _ => {} - }; - }); - - let fut = || async move { - store_accounts_from_genesis(pool.clone(), accounts_to_store).await?; - store_access_keys_from_genesis(pool, access_keys_to_store).await?; - anyhow::Result::<()>::Ok(()) - }; - block_on(actix_arbiter, fut()) - .expect("storing leftover accounts and access keys from genesis failed") - .expect("storing leftover accounts and access keys from genesis failed"); - }) - .await?; - - tracing::info!( - target: crate::INDEXER_FOR_EXPLORER, - "Genesis records has been stored.", - ); - Ok(()) -} diff --git a/src/db_adapters/mod.rs b/src/db_adapters/mod.rs deleted file mode 100644 index 6f9b6ef5..00000000 --- a/src/db_adapters/mod.rs +++ /dev/null @@ -1,13 +0,0 @@ -pub(crate) mod access_keys; -pub(crate) mod account_changes; -pub(crate) mod accounts; -pub(crate) mod aggregated; -pub(crate) mod assets; -pub(crate) mod blocks; -pub(crate) mod chunks; -pub(crate) mod execution_outcomes; -pub(crate) mod genesis; -pub(crate) mod receipts; -pub(crate) mod transactions; - -const CHUNK_SIZE_FOR_BATCH_INSERT: usize = 500; diff --git a/src/main.rs b/src/main.rs deleted file mode 100644 index 27398f26..00000000 --- a/src/main.rs +++ /dev/null @@ -1,387 +0,0 @@ -use clap::Parser; -use std::convert::TryFrom; -#[macro_use] -extern crate diesel; - -use actix_diesel::Database; -pub use cached::SizedCache; -use diesel::PgConnection; -use futures::future::try_join_all; -use futures::{try_join, StreamExt}; -use tokio::sync::{mpsc, Mutex}; -use tracing::{debug, info, warn}; -use tracing_subscriber::EnvFilter; - -use crate::configs::{Opts, SubCommand}; - -mod aggregated; -mod configs; -mod db_adapters; -mod metrics; -mod models; -mod schema; -#[macro_use] -mod retriable; - -// Categories for logging -const INDEXER_FOR_EXPLORER: &str = "indexer_for_explorer"; -const AGGREGATED: &str = "aggregated"; - -const INTERVAL: std::time::Duration = std::time::Duration::from_millis(100); -const MAX_DELAY_TIME: std::time::Duration = std::time::Duration::from_secs(120); - -#[derive(Clone, Hash, PartialEq, Eq, Debug)] -pub enum ReceiptOrDataId { - ReceiptId(near_indexer::near_primitives::hash::CryptoHash), - DataId(near_indexer::near_primitives::hash::CryptoHash), -} -// Creating type aliases to make HashMap types for cache more explicit -pub type ParentTransactionHashString = String; -// Introducing a simple cache for Receipts to find their parent Transactions without -// touching the database -// The key is ReceiptID -// The value is TransactionHash (the very parent of the Receipt) -pub type ReceiptsCache = - std::sync::Arc>>; - -async fn handle_message( - pool: &actix_diesel::Database, - streamer_message: near_indexer::StreamerMessage, - strict_mode: bool, - receipts_cache: ReceiptsCache, -) -> anyhow::Result<()> { - let _timer = metrics::HANDLE_MESSAGE_TIME.start_timer(); - debug!( - target: INDEXER_FOR_EXPLORER, - "ReceiptsCache #{} \n {:#?}", streamer_message.block.header.height, &receipts_cache - ); - db_adapters::blocks::store_block(pool, &streamer_message.block).await?; - - // Chunks - db_adapters::chunks::store_chunks( - pool, - &streamer_message.shards, - &streamer_message.block.header.hash, - ) - .await?; - - // Transactions - let transactions_future = db_adapters::transactions::store_transactions( - pool, - &streamer_message.shards, - &streamer_message.block.header.hash, - streamer_message.block.header.timestamp, - streamer_message.block.header.height, - std::sync::Arc::clone(&receipts_cache), - ); - - // Receipts - let receipts_future = db_adapters::receipts::store_receipts( - pool, - &streamer_message.shards, - &streamer_message.block.header.hash, - streamer_message.block.header.timestamp, - strict_mode, - std::sync::Arc::clone(&receipts_cache), - ); - - // We can process transactions and receipts in parallel - // because most of receipts depend on transactions from previous blocks, - // so we can save up some time here. - // In case of local receipts (they are stored in the same block with corresponding transaction), - // we hope retry logic will cover it fine - try_join!(transactions_future, receipts_future)?; - - // ExecutionOutcomes - let execution_outcomes_future = db_adapters::execution_outcomes::store_execution_outcomes( - pool, - &streamer_message.shards, - streamer_message.block.header.timestamp, - std::sync::Arc::clone(&receipts_cache), - ); - - // Accounts - let accounts_future = async { - let futures = streamer_message.shards.iter().map(|shard| { - db_adapters::accounts::handle_accounts( - pool, - &shard.receipt_execution_outcomes, - streamer_message.block.header.height, - ) - }); - - try_join_all(futures).await.map(|_| ()) - }; - - // Event-based entities (FT, NFT) - let assets_events_future = db_adapters::assets::events::store_events(pool, &streamer_message); - - if strict_mode { - // AccessKeys - let access_keys_future = async { - let futures = streamer_message.shards.iter().map(|shard| { - db_adapters::access_keys::handle_access_keys( - pool, - &shard.state_changes, - streamer_message.block.header.height, - ) - }); - - try_join_all(futures).await.map(|_| ()) - }; - - // StateChange related to Account - let account_changes_future = db_adapters::account_changes::store_account_changes( - pool, - &streamer_message.shards, - &streamer_message.block.header.hash, - streamer_message.block.header.timestamp, - ); - - try_join!( - execution_outcomes_future, - accounts_future, - access_keys_future, - assets_events_future, - account_changes_future, - )?; - } else { - try_join!( - execution_outcomes_future, - accounts_future, - assets_events_future - )?; - } - Ok(()) -} - -async fn listen_blocks( - stream: mpsc::Receiver, - pool: Database, - concurrency: std::num::NonZeroU16, - strict_mode: bool, - stop_after_number_of_blocks: Option, -) { - if let Some(stop_after_n_blocks) = stop_after_number_of_blocks { - warn!( - target: crate::INDEXER_FOR_EXPLORER, - "Indexer will stop after indexing {} blocks", stop_after_n_blocks, - ); - } - if !strict_mode { - warn!( - target: crate::INDEXER_FOR_EXPLORER, - "Indexer is starting in NON-STRICT mode", - ); - } - info!(target: crate::INDEXER_FOR_EXPLORER, "Stream has started"); - - // We want to prevent unnecessary SELECT queries to the database to find - // the Transaction hash for the Receipt. - // Later we need to find the Receipt which is a parent to underlying Receipts. - // Receipt ID will of the child will be stored as key and parent Transaction hash/Receipt ID - // will be stored as a value - let receipts_cache: ReceiptsCache = - std::sync::Arc::new(Mutex::new(SizedCache::with_size(100_000))); - - let handle_messages = - tokio_stream::wrappers::ReceiverStream::new(stream).map(|streamer_message| { - info!( - target: crate::INDEXER_FOR_EXPLORER, - "Block height {}", &streamer_message.block.header.height - ); - handle_message( - &pool, - streamer_message, - strict_mode, - std::sync::Arc::clone(&receipts_cache), - ) - }); - let mut handle_messages = if let Some(stop_after_n_blocks) = stop_after_number_of_blocks { - handle_messages - .take(stop_after_n_blocks.get()) - .boxed_local() - } else { - handle_messages.boxed_local() - } - .buffer_unordered(usize::from(concurrency.get())); - - while let Some(_handled_message) = handle_messages.next().await {} - // Graceful shutdown - info!( - target: crate::INDEXER_FOR_EXPLORER, - "Indexer will be shutdown gracefully in 7 seconds...", - ); - drop(handle_messages); - tokio::time::sleep(std::time::Duration::from_secs(7)).await; -} - -/// Takes `home_dir` and `RunArgs` to build proper IndexerConfig and returns it -async fn construct_near_indexer_config( - pool: &Database, - home_dir: std::path::PathBuf, - args: configs::RunArgs, -) -> near_indexer::IndexerConfig { - // Extract await mode to avoid duplication - info!( - target: crate::INDEXER_FOR_EXPLORER, - "construct_near_indexer_config" - ); - let sync_mode: near_indexer::SyncModeEnum = match args.sync_mode { - configs::SyncModeSubCommand::SyncFromInterruption(interruption_args) - if interruption_args.delta == 1 => - { - info!(target: crate::INDEXER_FOR_EXPLORER, "got from interruption"); - // If delta is 0 we just return IndexerConfig with sync_mode FromInterruption - // without any changes - near_indexer::SyncModeEnum::FromInterruption - } - configs::SyncModeSubCommand::SyncFromInterruption(interruption_args) => { - info!(target: crate::INDEXER_FOR_EXPLORER, "got from interruption"); - info!( - target: crate::INDEXER_FOR_EXPLORER, - "delta is non zero, calculating..." - ); - - db_adapters::blocks::latest_block_height(pool) - .await - .ok() - .map(|latest_block_height| { - if let Some(height) = latest_block_height { - near_indexer::SyncModeEnum::BlockHeight( - height.saturating_sub(interruption_args.delta), - ) - } else { - near_indexer::SyncModeEnum::FromInterruption - } - }) - .unwrap_or_else(|| near_indexer::SyncModeEnum::FromInterruption) - } - configs::SyncModeSubCommand::SyncFromBlock(block_args) => { - near_indexer::SyncModeEnum::BlockHeight(block_args.height) - } - configs::SyncModeSubCommand::SyncFromLatest => near_indexer::SyncModeEnum::LatestSynced, - }; - - near_indexer::IndexerConfig { - home_dir, - sync_mode, - await_for_node_synced: if args.stream_while_syncing { - near_indexer::AwaitForNodeSyncedEnum::StreamWhileSyncing - } else { - near_indexer::AwaitForNodeSyncedEnum::WaitForFullSync - }, - } -} - -fn main() { - let opts: Opts = Opts::parse(); - - // We use it to automatically search the for root certificates to perform HTTPS calls - // (sending telemetry and downloading genesis) - openssl_probe::init_ssl_cert_env_vars(); - - // We establish connection as early as possible as an additional sanity check. - // Indexer should fail if .env file with credentials is missing/wrong - let pool = models::establish_connection(); - - let mut env_filter = EnvFilter::new( - "tokio_reactor=info,near=info,stats=info,telemetry=info,indexer=info,aggregated=info", - ); - - if opts.debug { - env_filter = env_filter.add_directive( - "indexer_for_explorer=debug" - .parse() - .expect("Failed to parse directive"), - ); - } else { - env_filter = env_filter.add_directive( - "indexer_for_explorer=info" - .parse() - .expect("Failed to parse directive"), - ); - }; - - if let Ok(rust_log) = std::env::var("RUST_LOG") { - if !rust_log.is_empty() { - for directive in rust_log.split(',').filter_map(|s| match s.parse() { - Ok(directive) => Some(directive), - Err(err) => { - eprintln!("Ignoring directive `{}`: {}", s, err); - None - } - }) { - env_filter = env_filter.add_directive(directive); - } - } - } - - tracing_subscriber::fmt::Subscriber::builder() - .with_env_filter(env_filter) - .with_writer(std::io::stderr) - .init(); - - let home_dir = opts.home_dir.unwrap_or_else(near_indexer::get_default_home); - - match opts.subcmd { - SubCommand::Run(args) => { - tracing::info!( - target: crate::INDEXER_FOR_EXPLORER, - "NEAR Indexer for Explorer v{} starting...", - env!("CARGO_PKG_VERSION") - ); - - let system = actix::System::new(); - system.block_on(async move { - let indexer_config = - construct_near_indexer_config(&pool, home_dir, args.clone()).await; - let indexer = - near_indexer::Indexer::new(indexer_config).expect("Failed to initiate Indexer"); - if args.store_genesis { - let near_config = indexer.near_config().clone(); - db_adapters::genesis::store_genesis_records(pool.clone(), near_config.clone()) - .await - .expect("Failed to store the records from the genesis"); - } - - // Regular indexer process starts here - let stream = indexer.streamer(); - - // Spawning the computation of aggregated data - aggregated::spawn_aggregated_computations(pool.clone(), &indexer); - - listen_blocks( - stream, - pool, - args.concurrency, - !args.non_strict_mode, - args.stop_after_number_of_blocks, - ) - .await; - - actix::System::current().stop(); - }); - system.run().unwrap(); - } - SubCommand::Init(config) => near_indexer::init_configs( - &home_dir, - config.chain_id.as_ref().map(AsRef::as_ref), - config.account_id.map(|account_id_string| { - near_indexer::near_primitives::types::AccountId::try_from(account_id_string) - .expect("Received accound_id is not valid") - }), - config.test_seed.as_ref().map(AsRef::as_ref), - config.num_shards, - config.fast, - config.genesis.as_ref().map(AsRef::as_ref), - config.download_genesis, - config.download_genesis_url.as_ref().map(AsRef::as_ref), - config.download_config, - config.download_config_url.as_ref().map(AsRef::as_ref), - config.boot_nodes.as_ref().map(AsRef::as_ref), - config.max_gas_burnt_view, - ) - .expect("Failed to initiate config"), - } -} diff --git a/src/metrics.rs b/src/metrics.rs deleted file mode 100644 index 77576a51..00000000 --- a/src/metrics.rs +++ /dev/null @@ -1,22 +0,0 @@ -use near_o11y::metrics::{ - exponential_buckets, try_create_histogram, try_create_histogram_vec, Histogram, HistogramVec, -}; -use once_cell::sync::Lazy; - -pub(crate) static HANDLE_MESSAGE_TIME: Lazy = Lazy::new(|| { - try_create_histogram( - "indexer_for_explorer_handle_message_time", - "Latency of handling a streamer message", - ) - .unwrap() -}); - -pub(crate) static STORE_TIME: Lazy = Lazy::new(|| { - try_create_histogram_vec( - "indexer_for_explorer_store_time", - "Latency of storing an object in the DB", - &["object"], - Some(exponential_buckets(0.001, 1.6, 30).unwrap()), - ) - .unwrap() -}); diff --git a/src/models/aggregated/mod.rs b/src/models/aggregated/mod.rs deleted file mode 100644 index eecd50a6..00000000 --- a/src/models/aggregated/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub(crate) mod circulating_supply; diff --git a/src/models/enums.rs b/src/models/enums.rs deleted file mode 100644 index 71623f35..00000000 --- a/src/models/enums.rs +++ /dev/null @@ -1,152 +0,0 @@ -use diesel_derive_enum::DbEnum; - -#[derive(Debug, DbEnum, Clone)] -#[DbValueStyle = "SCREAMING_SNAKE_CASE"] -#[DieselType = "Receipt_kind"] -#[PgType = "receipt_kind"] -pub enum ReceiptKind { - Action, - Data, -} - -impl From<&near_indexer::near_primitives::views::ReceiptEnumView> for ReceiptKind { - fn from(receipt_enum_view: &near_indexer::near_primitives::views::ReceiptEnumView) -> Self { - match receipt_enum_view { - near_indexer::near_primitives::views::ReceiptEnumView::Action { .. } => Self::Action, - near_indexer::near_primitives::views::ReceiptEnumView::Data { .. } => Self::Data, - } - } -} - -#[derive(Debug, DbEnum, Clone)] -#[DbValueStyle = "SCREAMING_SNAKE_CASE"] -#[DieselType = "Action_kind"] -#[PgType = "action_kind"] -pub enum ActionKind { - CreateAccount, - DeployContract, - FunctionCall, - Transfer, - Stake, - AddKey, - DeleteKey, - DeleteAccount, -} - -#[derive(Debug, DbEnum, Clone)] -#[DbValueStyle = "SCREAMING_SNAKE_CASE"] -#[DieselType = "Execution_outcome_status"] -#[PgType = "execution_outcome_status"] -pub enum ExecutionOutcomeStatus { - Unknown, - Failure, - SuccessValue, - SuccessReceiptId, -} - -impl From for ExecutionOutcomeStatus { - fn from(status: near_indexer::near_primitives::views::ExecutionStatusView) -> Self { - match status { - near_indexer::near_primitives::views::ExecutionStatusView::Unknown => Self::Unknown, - near_indexer::near_primitives::views::ExecutionStatusView::Failure(_) => Self::Failure, - near_indexer::near_primitives::views::ExecutionStatusView::SuccessValue(_) => { - Self::SuccessValue - } - near_indexer::near_primitives::views::ExecutionStatusView::SuccessReceiptId(_) => { - Self::SuccessReceiptId - } - } - } -} - -#[derive(Debug, DbEnum, Clone)] -#[DbValueStyle = "SCREAMING_SNAKE_CASE"] -#[DieselType = "Access_key_permission_kind"] -#[PgType = "access_key_permission_kind"] -pub enum AccessKeyPermission { - /// Used only with AccessKeyAction::Add - FullAccess, - /// Used only with AccessKeyAction::Add - FunctionCall, -} - -impl From<&near_indexer::near_primitives::views::AccessKeyPermissionView> for AccessKeyPermission { - fn from(item: &near_indexer::near_primitives::views::AccessKeyPermissionView) -> Self { - match item { - near_indexer::near_primitives::views::AccessKeyPermissionView::FunctionCall { - .. - } => Self::FunctionCall, - near_indexer::near_primitives::views::AccessKeyPermissionView::FullAccess => { - Self::FullAccess - } - } - } -} - -impl From<&near_indexer::near_primitives::account::AccessKeyPermission> for AccessKeyPermission { - fn from(item: &near_indexer::near_primitives::account::AccessKeyPermission) -> Self { - match item { - near_indexer::near_primitives::account::AccessKeyPermission::FunctionCall { - .. - } => Self::FunctionCall, - near_indexer::near_primitives::account::AccessKeyPermission::FullAccess => { - Self::FullAccess - } - } - } -} - -#[derive(Debug, DbEnum, Clone)] -#[DbValueStyle = "SCREAMING_SNAKE_CASE"] -#[DieselType = "State_change_reason_kind"] -#[PgType = "state_change_reason_kind"] -pub enum StateChangeReasonKind { - TransactionProcessing, - ActionReceiptProcessingStarted, - ActionReceiptGasReward, - ReceiptProcessing, - PostponedReceipt, - UpdatedDelayedReceipts, - ValidatorAccountsUpdate, - Migration, - Resharding, -} - -impl From<&near_indexer::near_primitives::views::StateChangeCauseView> for StateChangeReasonKind { - fn from( - state_change_cause_view: &near_indexer::near_primitives::views::StateChangeCauseView, - ) -> Self { - match state_change_cause_view { - near_indexer::near_primitives::views::StateChangeCauseView::TransactionProcessing { .. } => Self::TransactionProcessing, - near_indexer::near_primitives::views::StateChangeCauseView::ActionReceiptProcessingStarted { .. } => Self::ActionReceiptProcessingStarted, - near_indexer::near_primitives::views::StateChangeCauseView::ActionReceiptGasReward { .. } => Self::ActionReceiptGasReward, - near_indexer::near_primitives::views::StateChangeCauseView::ReceiptProcessing { .. } => Self::ReceiptProcessing, - near_indexer::near_primitives::views::StateChangeCauseView::PostponedReceipt { .. } => Self::PostponedReceipt, - near_indexer::near_primitives::views::StateChangeCauseView::UpdatedDelayedReceipts { .. } => Self::UpdatedDelayedReceipts, - near_indexer::near_primitives::views::StateChangeCauseView::ValidatorAccountsUpdate { .. } => Self::ValidatorAccountsUpdate, - near_indexer::near_primitives::views::StateChangeCauseView::Migration { .. } => Self::Migration, - near_indexer::near_primitives::views::StateChangeCauseView::Resharding { .. } => Self::Resharding, - near_indexer::near_primitives::views::StateChangeCauseView::NotWritableToDisk | near_indexer::near_primitives::views::StateChangeCauseView::InitialState => panic!("Unexpected variant {:?} received", state_change_cause_view), - } - } -} - -#[derive(Debug, DbEnum, Clone)] -#[DbValueStyle = "SCREAMING_SNAKE_CASE"] -#[DieselType = "Nft_event_kind"] -#[PgType = "nft_event_kind"] -pub enum NftEventKind { - Mint, - Transfer, - Burn, -} - -#[derive(Debug, DbEnum, Clone)] -#[DbValueStyle = "SCREAMING_SNAKE_CASE"] -#[DieselType = "Ft_event_kind"] -#[PgType = "ft_event_kind"] -pub enum FtEventKind { - Mint, - Transfer, - Burn, -}