diff --git a/Cargo.lock b/Cargo.lock index 17d3685884b18..521e102b98ced 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -91,6 +91,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" dependencies = [ "cfg-if", + "getrandom 0.2.7", "once_cell", "version_check", ] @@ -155,9 +156,11 @@ dependencies = [ "aptos-config", "aptos-crypto", "aptos-db-tool", + "aptos-debugger", "aptos-faucet-core", "aptos-framework", "aptos-gas", + "aptos-gas-profiling", "aptos-genesis", "aptos-github-client", "aptos-global-constants", @@ -906,6 +909,7 @@ dependencies = [ "anyhow", "aptos-crypto", "aptos-gas", + "aptos-gas-profiling", "aptos-logger", "aptos-resource-viewer", "aptos-rest-client", @@ -913,6 +917,7 @@ dependencies = [ "aptos-types", "aptos-validator-interface", "aptos-vm", + "aptos-vm-logging", "clap 3.2.23", "move-binary-format", "move-cli", @@ -1385,6 +1390,22 @@ dependencies = [ "move-core-types", ] +[[package]] +name = "aptos-gas-profiling" +version = "0.1.0" +dependencies = [ + "anyhow", + "aptos-framework", + "aptos-gas", + "aptos-package-builder", + "aptos-types", + "inferno", + "move-binary-format", + "move-core-types", + "move-vm-types", + "regex", +] + [[package]] name = "aptos-genesis" version = "0.1.0" @@ -3633,7 +3654,7 @@ version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" dependencies = [ - "hermit-abi", + "hermit-abi 0.1.19", "libc", "winapi 0.3.9", ] @@ -3664,7 +3685,7 @@ checksum = "c9e3356844c4d6a6d6467b8da2cffb4a2820be256f50a3a386c9d152bab31043" dependencies = [ "async-trait", "axum-core 0.2.8", - "bitflags", + "bitflags 1.3.2", "bytes", "futures-util", "http", @@ -3695,7 +3716,7 @@ checksum = "08b108ad2665fa3f6e6a517c3d80ec3e77d224c47d605167aefaa5d7ef97fa48" dependencies = [ "async-trait", "axum-core 0.3.0", - "bitflags", + "bitflags 1.3.2", "bytes", "futures-util", "http", @@ -3875,7 +3896,7 @@ version = "0.60.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "062dddbc1ba4aca46de6338e2bf87771414c335f7b2f2036e8f3e9befebf88e6" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cexpr", "clang-sys", "lazy_static 1.4.0", @@ -3909,6 +3930,12 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "487f1e0fcbe47deb8b0574e646def1c903389d95241dd1bbcc6ce4a715dfc0c1" + [[package]] name = "bitmaps" version = "2.1.0" @@ -4331,7 +4358,7 @@ checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" dependencies = [ "ansi_term 0.12.1", "atty", - "bitflags", + "bitflags 1.3.2", "strsim 0.8.0", "textwrap 0.11.0", "unicode-width", @@ -4345,9 +4372,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71655c45cb9845d3270c9d6df84ebe72b4dad3c2ba3f7023ad47c144e4e473a5" dependencies = [ "atty", - "bitflags", - "clap_derive", - "clap_lex", + "bitflags 1.3.2", + "clap_derive 3.2.18", + "clap_lex 0.2.4", "indexmap", "once_cell", "strsim 0.10.0", @@ -4355,6 +4382,21 @@ dependencies = [ "textwrap 0.16.0", ] +[[package]] +name = "clap" +version = "4.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42dfd32784433290c51d92c438bb72ea5063797fc3cc9a21a8c4346bebbb2098" +dependencies = [ + "bitflags 2.0.2", + "clap_derive 4.1.9", + "clap_lex 0.3.3", + "is-terminal", + "once_cell", + "strsim 0.10.0", + "termcolor", +] + [[package]] name = "clap_complete" version = "3.2.4" @@ -4377,6 +4419,19 @@ dependencies = [ "syn 1.0.105", ] +[[package]] +name = "clap_derive" +version = "4.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fddf67631444a3a3e3e5ac51c36a5e01335302de677bd78759eaa90ab1f46644" +dependencies = [ + "heck 0.4.0", + "proc-macro-error", + "proc-macro2 1.0.47", + "quote 1.0.21", + "syn 1.0.105", +] + [[package]] name = "clap_lex" version = "0.2.4" @@ -4386,6 +4441,15 @@ dependencies = [ "os_str_bytes", ] +[[package]] +name = "clap_lex" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "033f6b7a4acb1f358c742aaca805c939ee73b4c6209ae4318ec7aca81c42e646" +dependencies = [ + "os_str_bytes", +] + [[package]] name = "cloud-storage" version = "0.11.1" @@ -4763,7 +4827,7 @@ version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "486d44227f71a1ef39554c0dc47e44b9f4139927c75043312690c3f476d1d788" dependencies = [ - "bitflags", + "bitflags 1.3.2", "crossterm_winapi 0.8.0", "libc", "mio 0.7.14", @@ -4779,7 +4843,7 @@ version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c85525306c4291d1b73ce93c8acf9c339f9b213aef6c1d85c3830cbf1c16325c" dependencies = [ - "bitflags", + "bitflags 1.3.2", "crossterm_winapi 0.9.0", "libc", "mio 0.7.14", @@ -5093,7 +5157,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "01e2adfd0a7a81070ed7beec0c62636458926326c16fedb77796d41e447b282d" dependencies = [ "bigdecimal", - "bitflags", + "bitflags 1.3.2", "byteorder", "chrono", "diesel_derives", @@ -5420,6 +5484,15 @@ dependencies = [ "termcolor", ] +[[package]] +name = "env_logger" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0" +dependencies = [ + "log", +] + [[package]] name = "environmental" version = "1.1.4" @@ -6046,7 +6119,7 @@ version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2994bee4a3a6a51eb90c218523be382fd7ea09b16380b9312e9dbe955ff7c7d1" dependencies = [ - "bitflags", + "bitflags 1.3.2", "libc", "libgit2-sys", "log", @@ -6059,7 +6132,7 @@ version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ccf7f68c2995f392c49fffb4f95ae2c873297830eb25c6bc4c114ce8f4562acc" dependencies = [ - "bitflags", + "bitflags 1.3.2", "libc", "libgit2-sys", "log", @@ -6093,7 +6166,7 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "93e3af942408868f6934a7b85134a3230832b9977cf66125df2f9edcfce4ddcc" dependencies = [ - "bitflags", + "bitflags 1.3.2", "ignore", "walkdir", ] @@ -6212,7 +6285,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4cff78e5788be1e0ab65b04d306b2ed5092c815ec97ec70f4ebd5aee158aa55d" dependencies = [ "base64 0.13.0", - "bitflags", + "bitflags 1.3.2", "bytes", "headers-core", "http", @@ -6254,6 +6327,12 @@ dependencies = [ "libc", ] +[[package]] +name = "hermit-abi" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" + [[package]] name = "hex" version = "0.4.3" @@ -6702,6 +6781,29 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "adab1eaa3408fb7f0c777a73e7465fd5656136fc93b670eb6df3c88c2c1344e3" +[[package]] +name = "inferno" +version = "0.11.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fb7c1b80a1dfa604bb4a649a5c5aeef3d913f7c520cb42b40e534e8a61bcdfc" +dependencies = [ + "ahash 0.8.3", + "clap 4.1.11", + "crossbeam-channel", + "crossbeam-utils", + "dashmap", + "env_logger 0.10.0", + "indexmap", + "is-terminal", + "itoa", + "log", + "num-format", + "once_cell", + "quick-xml 0.26.0", + "rgb", + "str_stack", +] + [[package]] name = "instant" version = "0.1.12" @@ -6739,6 +6841,17 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ea37f355c05dde75b84bba2d767906ad522e97cd9e2eef2be7a4ab7fb442c06" +[[package]] +name = "io-lifetimes" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09270fd4fa1111bc614ed2246c7ef56239a3063d5be0d1ec3b589c505d400aeb" +dependencies = [ + "hermit-abi 0.3.1", + "libc", + "windows-sys 0.45.0", +] + [[package]] name = "ipnet" version = "2.5.0" @@ -6754,6 +6867,18 @@ dependencies = [ "ipnet", ] +[[package]] +name = "is-terminal" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8687c819457e979cc940d09cb16e42a1bf70aa6b60a549de6d3a62a0ee90c69e" +dependencies = [ + "hermit-abi 0.3.1", + "io-lifetimes 1.0.9", + "rustix 0.36.11", + "windows-sys 0.45.0", +] + [[package]] name = "is_debug" version = "1.0.1" @@ -6798,9 +6923,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.3" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8af84674fe1f223a982c933a0ee1086ac4d4052aa0fb8060c12c6ad838e754" +checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" [[package]] name = "jemalloc-sys" @@ -7049,7 +7174,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6607c62aa161d23d17a9072cc5da0be67cdfc89d3afb1e8d9c842bebc2525ffe" dependencies = [ "arrayvec 0.5.2", - "bitflags", + "bitflags 1.3.2", "cfg-if", "ryu", "static_assertions", @@ -7057,9 +7182,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.132" +version = "0.2.140" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8371e4e5341c3a96db127eb2465ac681ced4c433e01dd0e938adbef26ba93ba5" +checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c" [[package]] name = "libfuzzer-sys" @@ -7228,6 +7353,12 @@ version = "0.0.46" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4d2456c373231a208ad294c33dc5bff30051eafd954cd4caae83a712b12854d" +[[package]] +name = "linux-raw-sys" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" + [[package]] name = "listener" version = "0.1.0" @@ -7306,7 +7437,7 @@ version = "0.90.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6f3734ab1d7d157fc0c45110e06b587c31cd82bea2ccfd6b563cbff0aaeeb1d3" dependencies = [ - "bitflags", + "bitflags 1.3.2", "serde 1.0.149", "serde_json", "serde_repr", @@ -7489,7 +7620,7 @@ dependencies = [ "libc", "log", "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys", + "windows-sys 0.36.1", ] [[package]] @@ -8674,6 +8805,16 @@ dependencies = [ "syn 1.0.105", ] +[[package]] +name = "num-format" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a652d9771a63711fd3c3deb670acfbe5c30a4072e664d7a3bf5a9e1056ac72c3" +dependencies = [ + "arrayvec 0.7.2", + "itoa", +] + [[package]] name = "num-integer" version = "0.1.45" @@ -8731,7 +8872,7 @@ version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" dependencies = [ - "hermit-abi", + "hermit-abi 0.1.19", "libc", ] @@ -8795,7 +8936,7 @@ version = "0.10.41" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "618febf65336490dfcf20b73f885f5651a0c89c64c2d4a8c3662585a70bf5bd0" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cfg-if", "foreign-types", "libc", @@ -8990,7 +9131,7 @@ dependencies = [ "libc", "redox_syscall 0.2.16", "smallvec", - "windows-sys", + "windows-sys 0.36.1", ] [[package]] @@ -9249,7 +9390,7 @@ version = "0.17.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5d708eaf860a19b19ce538740d2b4bdeeb8337fa53f7738455e706623ad5c638" dependencies = [ - "bitflags", + "bitflags 1.3.2", "crc32fast", "flate2", "miniz_oxide 0.6.2", @@ -9569,13 +9710,13 @@ version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dfb6451c91904606a1abe93e83a8ec851f45827fa84273f256ade45dc095818" dependencies = [ - "bitflags", + "bitflags 1.3.2", "byteorder", "chrono", "flate2", "hex", "lazy_static 1.4.0", - "rustix", + "rustix 0.35.9", ] [[package]] @@ -9629,7 +9770,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e0d9cc07f18492d879586c92b485def06bc850da3118075cd45d50e9c95b0e5" dependencies = [ "bit-set", - "bitflags", + "bitflags 1.3.2", "byteorder", "lazy_static 1.4.0", "num-traits 0.2.15", @@ -9764,6 +9905,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "quick-xml" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f50b1c63b38611e7d4d7f68b82d3ad0cc71a2ad2e7f61fc10f1328d917c93cd" +dependencies = [ + "memchr", +] + [[package]] name = "quote" version = "0.6.13" @@ -9916,7 +10066,7 @@ version = "10.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6aa2540135b6a94f74c7bc90ad4b794f822026a894f3d7bcd185c100d13d4ad6" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] @@ -10012,7 +10162,7 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] @@ -10339,12 +10489,26 @@ version = "0.35.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72c825b8aa8010eb9ee99b75f05e10180b9278d161583034d7574c9d617aeada" dependencies = [ - "bitflags", + "bitflags 1.3.2", + "errno", + "io-lifetimes 0.7.3", + "libc", + "linux-raw-sys 0.0.46", + "windows-sys 0.36.1", +] + +[[package]] +name = "rustix" +version = "0.36.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db4165c9963ab29e422d6c26fbc1d37f15bace6b2810221f9d925023480fcf0e" +dependencies = [ + "bitflags 1.3.2", "errno", - "io-lifetimes", + "io-lifetimes 1.0.9", "libc", - "linux-raw-sys", - "windows-sys", + "linux-raw-sys 0.1.4", + "windows-sys 0.45.0", ] [[package]] @@ -10469,7 +10633,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "88d6731146462ea25d9244b2ed5fd1d716d25c52e4d54aa4fb0f3c4e9854dbe2" dependencies = [ "lazy_static 1.4.0", - "windows-sys", + "windows-sys 0.36.1", ] [[package]] @@ -10515,7 +10679,7 @@ version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2bc1bb97804af6631813c55739f771071e0f2ed33ee20b68c86ec505d906356c" dependencies = [ - "bitflags", + "bitflags 1.3.2", "core-foundation", "core-foundation-sys", "libc", @@ -10541,7 +10705,7 @@ dependencies = [ "hyper", "indicatif 0.17.3", "log", - "quick-xml", + "quick-xml 0.22.0", "regex", "reqwest", "semver", @@ -11125,6 +11289,12 @@ dependencies = [ "atty", ] +[[package]] +name = "str_stack" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9091b6114800a5f2141aee1d1b9d6ca3592ac062dc5decb3764ec5895a47b4eb" + [[package]] name = "string_cache" version = "0.8.4" @@ -11798,7 +11968,7 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c530c8675c1dbf98facee631536fa116b5fb6382d7dd6dc1b118d970eafe3ba" dependencies = [ - "bitflags", + "bitflags 1.3.2", "bytes", "futures-core", "futures-util", @@ -11942,7 +12112,7 @@ version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23ed0a32c88b039b73f1b6c5acbd0554bfa5b6be94467375fd947c4de3a02271" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cassowary", "crossterm 0.22.1", "unicode-segmentation", @@ -12213,7 +12383,7 @@ dependencies = [ "errno", "js-sys", "libc", - "rustix", + "rustix 0.35.9", "wasi 0.11.0+wasi-snapshot-preview1", "wasm-bindgen", "winapi 0.3.9", @@ -12568,43 +12738,109 @@ version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" dependencies = [ - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_msvc", + "windows_aarch64_msvc 0.36.1", + "windows_i686_gnu 0.36.1", + "windows_i686_msvc 0.36.1", + "windows_x86_64_gnu 0.36.1", + "windows_x86_64_msvc 0.36.1", +] + +[[package]] +name = "windows-sys" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc 0.42.2", ] +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" + [[package]] name = "windows_aarch64_msvc" version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" + [[package]] name = "windows_i686_gnu" version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" +[[package]] +name = "windows_i686_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" + [[package]] name = "windows_i686_msvc" version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" +[[package]] +name = "windows_i686_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" + [[package]] name = "windows_x86_64_gnu" version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" + [[package]] name = "windows_x86_64_msvc" version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" + [[package]] name = "winreg" version = "0.10.1" diff --git a/Cargo.toml b/Cargo.toml index 56c92ed75a5c7..8dc827daadb5e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,6 +9,7 @@ members = [ "aptos-move/aptos-aggregator", "aptos-move/aptos-debugger", "aptos-move/aptos-gas", + "aptos-move/aptos-gas-profiling", "aptos-move/aptos-release-builder", "aptos-move/aptos-resource-viewer", "aptos-move/aptos-sdk-builder", @@ -282,6 +283,7 @@ aptos-framework = { path = "aptos-move/framework" } aptos-fuzzer = { path = "testsuite/aptos-fuzzer" } aptos-gas = { path = "aptos-move/aptos-gas" } aptos-gas-algebra-ext = { path = "aptos-move/gas-algebra-ext" } +aptos-gas-profiling = { path = "aptos-move/aptos-gas-profiling" } aptos-genesis = { path = "crates/aptos-genesis" } aptos-github-client = { path = "secure/storage/github" } aptos-global-constants = { path = "config/global-constants" } @@ -454,6 +456,7 @@ hyper-tls = "0.5.0" include_dir = { version = "0.7.2", features = ["glob"] } indicatif = "0.15.0" indoc = "1.0.6" +inferno = "0.11.14" ipnet = "2.5.0" itertools = "0.10.3" jemallocator = { version = "0.3.2", features = [ diff --git a/aptos-move/aptos-debugger/Cargo.toml b/aptos-move/aptos-debugger/Cargo.toml index e73051012fe0f..73b83abc0d0c6 100644 --- a/aptos-move/aptos-debugger/Cargo.toml +++ b/aptos-move/aptos-debugger/Cargo.toml @@ -13,6 +13,7 @@ edition = "2021" anyhow = { workspace = true } aptos-crypto = { workspace = true } aptos-gas = { workspace = true } +aptos-gas-profiling = { workspace = true } aptos-logger = { workspace = true } aptos-resource-viewer = { workspace = true } aptos-rest-client = { workspace = true } @@ -20,6 +21,7 @@ aptos-state-view = { workspace = true } aptos-types = { workspace = true } aptos-validator-interface = { workspace = true } aptos-vm = { workspace = true } +aptos-vm-logging = { workspace = true } clap = { workspace = true } move-binary-format = { workspace = true } move-cli = { workspace = true } diff --git a/aptos-move/aptos-debugger/src/lib.rs b/aptos-move/aptos-debugger/src/lib.rs index 0844bd7927019..2dc40c7c7d1be 100644 --- a/aptos-move/aptos-debugger/src/lib.rs +++ b/aptos-move/aptos-debugger/src/lib.rs @@ -3,16 +3,22 @@ use anyhow::{format_err, Result}; use aptos_gas::{ - AbstractValueSizeGasParameters, ChangeSetConfigs, NativeGasParameters, + AbstractValueSizeGasParameters, ChangeSetConfigs, NativeGasParameters, StandardGasMeter, LATEST_GAS_FEATURE_VERSION, }; +use aptos_gas_profiling::{GasProfiler, TransactionGasLog}; use aptos_resource_viewer::{AnnotatedAccountStateBlob, AptosValueAnnotator}; use aptos_rest_client::Client; +use aptos_state_view::TStateView; use aptos_types::{ account_address::AccountAddress, chain_id::ChainId, on_chain_config::{Features, OnChainConfig, TimedFeatures}, - transaction::{ChangeSet, Transaction, TransactionInfo, TransactionOutput, Version}, + transaction::{ + ChangeSet, SignedTransaction, Transaction, TransactionInfo, TransactionOutput, + TransactionPayload, Version, + }, + vm_status::VMStatus, }; use aptos_validator_interface::{ AptosValidatorInterface, DBDebuggerInterface, DebuggerStateView, RestDebuggerInterface, @@ -22,6 +28,7 @@ use aptos_vm::{ move_vm_ext::{MoveVmExt, SessionExt, SessionId}, AptosVM, VMExecutor, }; +use aptos_vm_logging::log_schema::AdapterLogSchema; use move_binary_format::errors::VMResult; use std::{path::Path, sync::Arc}; @@ -54,6 +61,47 @@ impl AptosDebugger { .map_err(|err| format_err!("Unexpected VM Error: {:?}", err)) } + pub fn execute_transaction_at_version_with_gas_profiler( + &self, + version: Version, + txn: SignedTransaction, + ) -> Result<(VMStatus, TransactionOutput, TransactionGasLog)> { + let state_view = DebuggerStateView::new(self.debugger.clone(), version); + let log_context = AdapterLogSchema::new(state_view.id(), 0); + let txn = txn + .check_signature() + .map_err(|err| format_err!("Unexpected VM Error: {:?}", err))?; + + let (status, output, gas_profiler) = + AptosVM::execute_user_transaction_with_custom_gas_meter( + &state_view, + &txn, + &log_context, + |gas_feature_version, gas_params, storage_gas_params, balance| { + let gas_meter = StandardGasMeter::new( + gas_feature_version, + gas_params, + storage_gas_params, + balance, + ); + let gas_profiler = match txn.payload() { + TransactionPayload::Script(_) => GasProfiler::new_script(gas_meter), + TransactionPayload::EntryFunction(entry_func) => GasProfiler::new_function( + gas_meter, + entry_func.module().clone(), + entry_func.function().to_owned(), + entry_func.ty_args().to_vec(), + ), + TransactionPayload::ModuleBundle(..) => unreachable!("not supported"), + TransactionPayload::Multisig(..) => unimplemented!("not supported yet"), + }; + Ok(gas_profiler) + }, + )?; + + Ok((status, output, gas_profiler.finish())) + } + pub async fn execute_past_transactions( &self, mut begin: Version, diff --git a/aptos-move/aptos-gas-profiling/Cargo.toml b/aptos-move/aptos-gas-profiling/Cargo.toml new file mode 100644 index 0000000000000..1f0414bbf46a2 --- /dev/null +++ b/aptos-move/aptos-gas-profiling/Cargo.toml @@ -0,0 +1,26 @@ +[package] +name = "aptos-gas-profiling" +version = "0.1.0" + +# Workspace inherited keys +authors = { workspace = true } +edition = { workspace = true } +homepage = { workspace = true } +license = { workspace = true } +publish = { workspace = true } +repository = { workspace = true } +rust-version = { workspace = true } + +[dependencies] +anyhow = { workspace = true } +inferno = { workspace = true } +regex = { workspace = true } + +aptos-framework = { workspace = true } +aptos-gas = { workspace = true } +aptos-package-builder = { workspace = true } +aptos-types = { workspace = true } + +move-binary-format = { workspace = true } +move-core-types = { workspace = true } +move-vm-types = { workspace = true } diff --git a/aptos-move/aptos-gas-profiling/README.md b/aptos-move/aptos-gas-profiling/README.md new file mode 100644 index 0000000000000..cbd4357876c4e --- /dev/null +++ b/aptos-move/aptos-gas-profiling/README.md @@ -0,0 +1,41 @@ +# Gas Profiling + +## Overview +This crate implements a gas profiler that can be plugged into the Aptos VM to generate comprehensive traces of gas usage, referred to as the transaction gas log. +It also contains a module for visualizing the transaction gas log, in the form of a flamegraph. + +## Running the Gas Profiler +You can run the gas profiler by appending the `--profile-gas` option to the aptos cli's `move publish`, `move run` & `move run-script` commands. Here is an example: +``` +>> cargo run -p aptos -- move publish --profile-gas + Finished dev [unoptimized + debuginfo] target(s) in 0.51s + Running `/home/vgao/aptos-core/target/debug/aptos move publish --profile-gas` +Compiling, may take a little while to download git dependencies... +BUILDING empty_fun +package size 427 bytes + +Simulating transaction locally with the gas profiler... +This is still experimental so results may be inaccurate. + +Execution & IO Gas flamegraph saved to gas-profiling/txn-69e19ee4-0x1-code-publish_package_txn.exec_io.svg +Storage fee flamegraph saved to gas-profiling/txn-69e19ee4-0x1-code-publish_package_txn.storage.svg + +{ + "Result": { + "transaction_hash": "0x69e19ee4cc89cb1f84ee21a46e6b281bd8696115aa332275eca38c4857818dfe", + "gas_used": 1007, + "gas_unit_price": 100, + "sender": "dbcbe741d003a7369d87ec8717afb5df425977106497052f96f4e236372f7dd5", + "success": true, + "version": 473269362, + "vm_status": "status EXECUTED of type Execution" + } +} +``` + +## Performance Implications +It is important to note that the current gas profiler implementation is quite heavy-weight since it records every Move bytecode instruction and its cost. If real-time gas profiling is required, it is recommended to develop a custom profiler that operates on aggregated data. A standard light-weight implementation may be provided in the future. + +## Known Issues & Future Plans +1. While addresses are truncated in the flamegraphs, they are still somewhat cumbersome. We plan to come up with a smart rendering algorithm that omits addresses, provided that the functions/items can still be unambiguously identified. +2. At present, the storage fee graph does not display the free quota for events. We plan to address this in a future update. diff --git a/aptos-move/aptos-gas-profiling/src/flamegraph.rs b/aptos-move/aptos-gas-profiling/src/flamegraph.rs new file mode 100644 index 0000000000000..cd8a583288fbf --- /dev/null +++ b/aptos-move/aptos-gas-profiling/src/flamegraph.rs @@ -0,0 +1,349 @@ +// Copyright © Aptos Foundation +// SPDX-License-Identifier: Apache-2.0 + +use crate::log::{ + CallFrame, ExecutionGasEvent, FrameName, StorageFees, TransactionGasLog, WriteOpType, +}; +use aptos_types::{ + access_path::Path, + state_store::{ + state_key::{StateKey, StateKeyInner}, + table::TableHandle, + }, +}; +use inferno::flamegraph::TextTruncateDirection; +use move_core_types::{ + account_address::AccountAddress, + gas_algebra::InternalGas, + identifier::IdentStr, + language_storage::{ModuleId, TypeTag}, +}; +use regex::Captures; +use std::{ + fmt::{self, Display}, + ops::Deref, +}; + +/// Wrapper to help render the underlying data in formats desirable by the flamegraph. +struct Render<'a, T>(&'a T); + +impl<'a> Display for Render<'a, AccountAddress> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let addr_short = self.0.short_str_lossless(); + write!(f, "0x")?; + if addr_short.len() > 4 { + write!(f, "{}..", &addr_short[..4]) + } else { + write!(f, "{}", addr_short) + } + } +} + +impl<'a> Display for Render<'a, ModuleId> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{}::{}", Render(self.0.address()), self.0.name()) + } +} + +impl<'a> Display for Render<'a, (&'a ModuleId, &'a IdentStr, &'a [TypeTag])> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{}::{}", Render(self.0 .0), self.0 .1)?; + if !self.0 .2.is_empty() { + write!( + f, + "<{}>", + self.0 + .2 + .iter() + .map(|ty| format!("{}", ty)) + .collect::>() + .join(",") + )?; + } + Ok(()) + } +} + +impl Display for FrameName { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Self::Script => write!(f, "