diff --git a/Cargo.lock b/Cargo.lock index 41dadba0a..2c3d1e3c3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -55,7 +55,7 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" dependencies = [ - "getrandom 0.2.3", + "getrandom 0.2.4", "once_cell", "version_check", ] @@ -80,9 +80,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.52" +version = "1.0.53" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84450d0b4a8bd1ba4144ce8ce718fbc5d071358b1e5384bace6536b3d1f2d5b3" +checksum = "94a45b455c14666b85fc40a019e8ab9eb75e3a124e05494f5397122bc9eb06e0" [[package]] name = "arc-swap" @@ -342,9 +342,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.8.0" +version = "3.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f1e260c3a9040a7c19a12468758f4c16f31a81a1fe087482be9570ec864bb6c" +checksum = "a4a45a46ab1f2412e53d3a0ade76ffad2025804294569aae387231a0cd6e0899" [[package]] name = "byte-slice-cast" @@ -979,9 +979,9 @@ checksum = "ccaeedb56da03b09f598226e25e80088cb4cd25f316e6e4df7d695f0feeb1403" [[package]] name = "crc32fast" -version = "1.3.0" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "738c290dfaea84fc1ca15ad9c168d083b05a714e1efddd8edaab678dc28d2836" +checksum = "a2209c310e29876f7f0b2721e7e26b84aff178aa3da5d091f9bfbf47669e60e3" dependencies = [ "cfg-if 1.0.0", ] @@ -1024,9 +1024,9 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06ed27e177f16d65f0f0c22a213e17c696ace5dd64b14258b52f9417ccb52db4" +checksum = "e54ea8bc3fb1ee042f5aace6e3c6e025d3874866da222930f70ce62aceba0bfa" dependencies = [ "cfg-if 1.0.0", "crossbeam-utils", @@ -1045,9 +1045,9 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.5" +version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ec02e091aa634e2c3ada4a392989e7c3116673ef0ac5b72232439094d73b7fd" +checksum = "97242a70df9b89a65d0b6df3c4bf5b9ce03c5b7309019777fbde37e7537f8762" dependencies = [ "cfg-if 1.0.0", "crossbeam-utils", @@ -1058,9 +1058,9 @@ dependencies = [ [[package]] name = "crossbeam-queue" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b10ddc024425c88c2ad148c1b0fd53f4c6d38db9697c9f1588381212fa657c9" +checksum = "b979d76c9fcb84dffc80a73f7290da0f83e4c95773494674cb44b76d13a7a110" dependencies = [ "cfg-if 1.0.0", "crossbeam-utils", @@ -1068,9 +1068,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d82cfc11ce7f2c3faef78d8a684447b40d503d9681acebed6cb728d45940c4db" +checksum = "cfcae03edb34f947e64acdb1c33ec169824e20657e9ecb61cef6c8c74dcb8120" dependencies = [ "cfg-if 1.0.0", "lazy_static", @@ -1252,9 +1252,9 @@ dependencies = [ [[package]] name = "erased-serde" -version = "0.3.17" +version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44a5d80251b806a14cd3e4e1a582e912d5cbf6904ab19fdefbd7a56adca088e1" +checksum = "56047058e1ab118075ca22f9ecd737bcc961aa3566a3019cb71388afa280bd8a" dependencies = [ "serde", ] @@ -1325,9 +1325,9 @@ dependencies = [ [[package]] name = "event-listener" -version = "2.5.1" +version = "2.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7531096570974c3a9dcf9e4b8e1cede1ec26cf5046219fb3b9d897503b9be59" +checksum = "77f3309417938f28bf8228fcff79a4a37103981e3e186d2ccd19c74b38f4eb71" [[package]] name = "extensions" @@ -1384,6 +1384,15 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51e2ce894d53b295cf97b05685aa077950ff3e8541af83217fc720a6437169f8" +[[package]] +name = "fastrand" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3fcf0cee53519c866c09b5de1f6c56ff9d647101f81c1964fa632e148896cdf" +dependencies = [ + "instant", +] + [[package]] name = "fixed-hash" version = "0.7.0" @@ -1416,9 +1425,9 @@ dependencies = [ [[package]] name = "flume" -version = "0.10.9" +version = "0.10.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24c3fd473b3a903a62609e413ed7538f99e10b665ecb502b5e481a95283f8ab4" +checksum = "5d04dafd11240188e146b6f6476a898004cace3be31d4ec5e08e216bf4947ac0" dependencies = [ "futures-core", "futures-sink", @@ -1633,9 +1642,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" +checksum = "418d37c8b1d42553c93648be529cb70f920d3baf8ef469b74b9638df426e0b4c" dependencies = [ "cfg-if 1.0.0", "libc", @@ -1725,7 +1734,6 @@ dependencies = [ "ckb-types", "clap", "ctrlc", - "env_logger", "futures", "gw-chain", "gw-challenge", @@ -1749,10 +1757,12 @@ dependencies = [ "hex", "lazy_static", "log", + "opentelemetry", + "opentelemetry-jaeger", "rayon", "semver", "sentry", - "sentry-log", + "sentry-tracing", "serde", "serde_json", "sqlx", @@ -1760,6 +1770,9 @@ dependencies = [ "tikv-jemallocator", "tokio", "toml", + "tracing", + "tracing-opentelemetry", + "tracing-subscriber", ] [[package]] @@ -1903,6 +1916,7 @@ dependencies = [ "sha3", "thiserror", "tokio", + "tracing", ] [[package]] @@ -1949,6 +1963,7 @@ dependencies = [ "rdkafka", "tempfile", "tokio", + "tracing", ] [[package]] @@ -2026,6 +2041,7 @@ dependencies = [ "thiserror", "tokio", "toml", + "tracing", ] [[package]] @@ -2072,6 +2088,7 @@ dependencies = [ "tikv-jemalloc-sys", "tokio", "toml", + "tracing", ] [[package]] @@ -2095,6 +2112,7 @@ dependencies = [ "serde_json", "serde_plain", "tokio", + "tracing", ] [[package]] @@ -2280,13 +2298,14 @@ dependencies = [ "sqlx", "thiserror", "tokio", + "tracing", ] [[package]] name = "h2" -version = "0.3.9" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f072413d126e57991455e0a922b31e4c8ba7c2ffbebf6b78b4f8521397d65cd" +checksum = "0c9de88456263e249e241fcd211d3954e2c9b0ef7ccfc235a444eb367cae3689" dependencies = [ "bytes 1.1.0", "fnv", @@ -2538,9 +2557,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc633605454125dec4b66843673f01c7df2b89479b32e0ed634e43a91cff62a5" +checksum = "282a6247722caba404c065016bbfa522806e51714c34f5dfc3e4a3a46fcb4223" dependencies = [ "autocfg 1.0.1", "hashbrown", @@ -2548,14 +2567,14 @@ dependencies = [ [[package]] name = "inferno" -version = "0.10.9" +version = "0.10.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fe3ba15e9cce341de198353aebd07d8009d211fb5556920bd4bdd3bb79fafd7" +checksum = "5b4445abb2e1f32b02fb78f957f17efa7a43c8258cd3e848157949c59157657d" dependencies = [ "ahash", "atty", "indexmap", - "itoa 0.4.8", + "itoa 1.0.1", "lazy_static", "log", "num-format", @@ -2573,6 +2592,12 @@ dependencies = [ "cfg-if 1.0.0", ] +[[package]] +name = "integer-encoding" +version = "1.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48dc51180a9b377fd75814d0cc02199c20f8e99433d6762f650d39cdbbd3b56f" + [[package]] name = "iovec" version = "0.1.4" @@ -2611,9 +2636,9 @@ checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" [[package]] name = "js-sys" -version = "0.3.55" +version = "0.3.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cc9ffccd38c451a86bf13657df244e9c3f37493cce8e5e21e940963777acc84" +checksum = "a38fc24e30fd564ce974c02bf1d337caddff65be6cc4735a1f7eab22a7440f04" dependencies = [ "wasm-bindgen", ] @@ -2765,15 +2790,15 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.112" +version = "0.2.113" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b03d17f364a3a042d5e5d46b053bbbf82c92c9430c592dd4c064dc6ee997125" +checksum = "eef78b64d87775463c549fbd80e19249ef436ea3bf1de2a1eb7e717ec7fab1e9" [[package]] name = "libloading" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afe203d669ec979b7128619bae5a63b7b42e9203c1b29146079ee05e2f604b52" +checksum = "efbc0f03f9a775e9f6aed295c6a1ba2253c5757a9e03d55c6caa46a681abcddd" dependencies = [ "cfg-if 1.0.0", "winapi 0.3.9", @@ -2833,6 +2858,15 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ffbee8634e0d45d258acb448e7eaab3fce7a0a467395d4d9f228e3c1f01fb2e4" +[[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" @@ -3230,9 +3264,9 @@ dependencies = [ [[package]] name = "openssl-probe" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28988d872ab76095a6e6ac88d99b54fd267702734fd7ffe610ca27f533ddb95a" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" @@ -3247,6 +3281,58 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "opentelemetry" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1cf9b1c4e9a6c4de793c632496fa490bdc0e1eea73f0c91394f7b6990935d22" +dependencies = [ + "async-trait", + "crossbeam-channel", + "futures", + "js-sys", + "lazy_static", + "percent-encoding", + "pin-project", + "rand 0.8.4", + "thiserror", + "tokio", + "tokio-stream", +] + +[[package]] +name = "opentelemetry-jaeger" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db22f492873ea037bc267b35a0e8e4fb846340058cb7c864efe3d0bf23684593" +dependencies = [ + "async-trait", + "lazy_static", + "opentelemetry", + "opentelemetry-semantic-conventions", + "thiserror", + "thrift", + "tokio", +] + +[[package]] +name = "opentelemetry-semantic-conventions" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffeac823339e8b0f27b961f4385057bf9f97f2863bc745bd015fd6091f2270e9" +dependencies = [ + "opentelemetry", +] + +[[package]] +name = "ordered-float" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3305af35278dd29f46fcdd139e0b1fbfae2153f0e5928b39b035542dd31e37b7" +dependencies = [ + "num-traits", +] + [[package]] name = "parity-scale-codec" version = "2.3.1" @@ -3597,9 +3683,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47aa80447ce4daf1717500037052af176af5d38cc3e571d9ec1c7353fc10c87d" +checksum = "864d3e96a899863136fc6e99f3d7cae289dafe43bf2c5ac19b70df7210c0a145" dependencies = [ "proc-macro2", ] @@ -3728,7 +3814,7 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" dependencies = [ - "getrandom 0.2.3", + "getrandom 0.2.4", ] [[package]] @@ -3896,7 +3982,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64" dependencies = [ - "getrandom 0.2.3", + "getrandom 0.2.4", "redox_syscall", ] @@ -3916,6 +4002,9 @@ name = "regex-automata" version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +dependencies = [ + "regex-syntax", +] [[package]] name = "regex-syntax" @@ -3934,15 +4023,16 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.11.8" +version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c4e0a76dc12a116108933f6301b95e83634e0c47b0afbed6abbaa0601e99258" +checksum = "87f242f1488a539a79bac6dbe7c8609ae43b7914b7736210f239a37cccb32525" dependencies = [ "base64 0.13.0", "bytes 1.1.0", "encoding_rs", "futures-core", "futures-util", + "h2", "http", "http-body", "hyper", @@ -3988,9 +4078,9 @@ dependencies = [ [[package]] name = "rust_decimal" -version = "1.19.0" +version = "1.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c2d4912d369fb95a351c221475657970678d344d70c1a788223f6e74d1e3732" +checksum = "e0593ce4677e3800ddafb3de917e8397b1348e06e688128ade722d88fbe11ebf" dependencies = [ "arrayvec 0.7.2", "num-traits", @@ -4121,7 +4211,7 @@ version = "0.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97d03ceae636d0fed5bae6a7f4f664354c5f4fcedf6eef053fef17e49f837d0a" dependencies = [ - "secp256k1-sys 0.4.1", + "secp256k1-sys 0.4.2", ] [[package]] @@ -4144,18 +4234,18 @@ dependencies = [ [[package]] name = "secp256k1-sys" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "827cb7cce42533829c792fc51b82fbf18b125b45a702ef2c8be77fce65463a7b" +checksum = "957da2573cde917463ece3570eab4a0b3f19de6f1646cde62e6fd3868f566036" dependencies = [ "cc", ] [[package]] name = "security-framework" -version = "2.4.2" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525bc1abfda2e1998d152c45cf13e696f76d0a4972310b22fac1658b05df7c87" +checksum = "d09d3c15d814eda1d6a836f2f2b56a6abc1446c8a34351cb3180d3db92ffe4ce" dependencies = [ "bitflags", "core-foundation", @@ -4166,9 +4256,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.4.2" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9dd14d83160b528b7bfd66439110573efcfbe281b17fc2ca9f39f550d619c7e" +checksum = "e90dd10c41c6bfc633da6e0c659bd25d31e0791e5974ac42970267d59eba87f7" dependencies = [ "core-foundation-sys", "libc", @@ -4183,8 +4273,7 @@ checksum = "568a8e6258aa33c13358f81fd834adb854c6f7c9468520910a9b1e8fac068012" [[package]] name = "sentry" version = "0.23.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "546b9b6f76c26c60ffbcf0b7136e15169fe13d43949b4aadb7c1edc1c3f3a26f" +source = "git+https://github.com/getsentry/sentry-rust?rev=df694a49595d6890c510d80b85cfbb4b5ae6159a#df694a49595d6890c510d80b85cfbb4b5ae6159a" dependencies = [ "httpdate", "reqwest", @@ -4198,8 +4287,7 @@ dependencies = [ [[package]] name = "sentry-backtrace" version = "0.23.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cd0cba2aff36ac98708f7a6e7abbdde82dbaf180d5870c41084dc1b473648b9" +source = "git+https://github.com/getsentry/sentry-rust?rev=df694a49595d6890c510d80b85cfbb4b5ae6159a#df694a49595d6890c510d80b85cfbb4b5ae6159a" dependencies = [ "backtrace", "lazy_static", @@ -4210,13 +4298,10 @@ dependencies = [ [[package]] name = "sentry-contexts" version = "0.23.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bacf1c62427c6c97b896640d0c4dd204bbd3b79dd192d7cb40891aa5ee11d58" +source = "git+https://github.com/getsentry/sentry-rust?rev=df694a49595d6890c510d80b85cfbb4b5ae6159a#df694a49595d6890c510d80b85cfbb4b5ae6159a" dependencies = [ "hostname", - "lazy_static", "libc", - "regex", "rustc_version", "sentry-core", "uname", @@ -4225,8 +4310,7 @@ dependencies = [ [[package]] name = "sentry-core" version = "0.23.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9a957270c9a430218f8031c866493061a27e35a70250e9527f093563a33ce6b" +source = "git+https://github.com/getsentry/sentry-rust?rev=df694a49595d6890c510d80b85cfbb4b5ae6159a#df694a49595d6890c510d80b85cfbb4b5ae6159a" dependencies = [ "chrono", "lazy_static", @@ -4237,33 +4321,33 @@ dependencies = [ ] [[package]] -name = "sentry-log" +name = "sentry-panic" version = "0.23.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66da5759b0704a2fb0d420863b0795ea3429739e188ff67fff82bb13dcd3cc50" +source = "git+https://github.com/getsentry/sentry-rust?rev=df694a49595d6890c510d80b85cfbb4b5ae6159a#df694a49595d6890c510d80b85cfbb4b5ae6159a" dependencies = [ - "log", + "sentry-backtrace", "sentry-core", ] [[package]] -name = "sentry-panic" +name = "sentry-tracing" version = "0.23.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "692bf989f0c99f025e33d7f58e62822c3771f56d189698c66dcc863122255d95" +source = "git+https://github.com/getsentry/sentry-rust?rev=df694a49595d6890c510d80b85cfbb4b5ae6159a#df694a49595d6890c510d80b85cfbb4b5ae6159a" dependencies = [ - "sentry-backtrace", "sentry-core", + "tracing-core", + "tracing-subscriber", ] [[package]] name = "sentry-types" version = "0.23.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4dd2266fee014a86e250e98e389191ecd23be546b5c42b6a2fb9af2972fadac" +source = "git+https://github.com/getsentry/sentry-rust?rev=df694a49595d6890c510d80b85cfbb4b5ae6159a#df694a49595d6890c510d80b85cfbb4b5ae6159a" dependencies = [ "chrono", "debugid", + "getrandom 0.2.4", + "hex", "serde", "serde_json", "thiserror", @@ -4273,9 +4357,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.133" +version = "1.0.135" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97565067517b60e2d1ea8b268e59ce036de907ac523ad83a0475da04e818989a" +checksum = "2cf9235533494ea2ddcdb794665461814781c53f19d87b76e571a1c35acbad2b" dependencies = [ "serde_derive", ] @@ -4292,9 +4376,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.133" +version = "1.0.135" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed201699328568d8d08208fdd080e3ff594e6c422e438b6705905da01005d537" +checksum = "8dcde03d87d4c973c04be249e7d8f0b35db1c848c487bd43032808e59dd8328d" dependencies = [ "proc-macro2", "quote", @@ -4303,9 +4387,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.74" +version = "1.0.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee2bb9cd061c5865d345bb02ca49fcef1391741b672b54a0bf7b679badec3142" +checksum = "d23c1ba4cf0efd44be32017709280b32d1cea5c3f1275c3b6d9e8bc54f758085" dependencies = [ "itoa 1.0.1", "ryu", @@ -4323,12 +4407,12 @@ dependencies = [ [[package]] name = "serde_urlencoded" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edfa57a7f8d9c1d260a549e7224100f6c43d43f9103e06dd8b4095a9b2b43ce9" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" dependencies = [ "form_urlencoded", - "itoa 0.4.8", + "itoa 1.0.1", "ryu", "serde", ] @@ -4372,9 +4456,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.9.8" +version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b69f9a4c9740d74c5baa3fd2e547f9525fa8088a8a958e0ca2409a514e33f5fa" +checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" dependencies = [ "block-buffer 0.9.0", "cfg-if 1.0.0", @@ -4395,6 +4479,15 @@ dependencies = [ "opaque-debug 0.3.0", ] +[[package]] +name = "sharded-slab" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31" +dependencies = [ + "lazy_static", +] + [[package]] name = "shlex" version = "1.1.0" @@ -4412,9 +4505,9 @@ dependencies = [ [[package]] name = "siphasher" -version = "0.3.7" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "533494a8f9b724d33625ab53c6c4800f7cc445895924a8ef649222dcb76e938b" +checksum = "a86232ab60fa71287d7f2ddae4a7073f6b7aac33631c3015abb556f08c6d0a3e" [[package]] name = "slab" @@ -4424,15 +4517,15 @@ checksum = "9def91fd1e018fe007022791f865d0ccc9b3a0d5001e01aabb8b40e46000afb5" [[package]] name = "smallvec" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309" +checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83" [[package]] name = "socket2" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dc90fe6c7be1a323296982db1836d1ea9e47b6839496dde9a541bc496df3516" +checksum = "0f82496b90c36d70af5fcd482edaa2e0bd16fade569de1330405fecbbdac736b" dependencies = [ "libc", "winapi 0.3.9", @@ -4521,7 +4614,7 @@ dependencies = [ "serde", "serde_json", "sha-1 0.9.8", - "sha2 0.9.8", + "sha2 0.9.9", "smallvec", "sqlformat", "sqlx-rt", @@ -4544,7 +4637,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "sha2 0.9.8", + "sha2 0.9.9", "sqlx-core", "sqlx-rt", "syn", @@ -4634,9 +4727,9 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.84" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecb2e6da8ee5eb9a61068762a32fa9619cc591ceb055b3687f4cd4051ec2e06b" +checksum = "8a65b3f4ffa0092e9887669db0eae07941f023991ab58ea44da8fe8e2d511c6b" dependencies = [ "proc-macro2", "quote", @@ -4663,13 +4756,13 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tempfile" -version = "3.2.0" +version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22" +checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" dependencies = [ "cfg-if 1.0.0", + "fastrand", "libc", - "rand 0.8.4", "redox_syscall", "remove_dir_all", "winapi 0.3.9", @@ -4713,6 +4806,37 @@ dependencies = [ "syn", ] +[[package]] +name = "thread_local" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5516c27b78311c50bf42c071425c560ac799b11c30b31f87e3081965fe5e0180" +dependencies = [ + "once_cell", +] + +[[package]] +name = "threadpool" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa" +dependencies = [ + "num_cpus", +] + +[[package]] +name = "thrift" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c6d965454947cc7266d22716ebfd07b18d84ebaf35eec558586bbb2a8cb6b5b" +dependencies = [ + "byteorder", + "integer-encoding", + "log", + "ordered-float", + "threadpool", +] + [[package]] name = "tikv-jemalloc-ctl" version = "0.4.2" @@ -4886,9 +5010,21 @@ checksum = "375a639232caf30edfc78e8d89b2d4c375515393e7af7e16f01cd96917fb2105" dependencies = [ "cfg-if 1.0.0", "pin-project-lite", + "tracing-attributes", "tracing-core", ] +[[package]] +name = "tracing-attributes" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4f480b8f81512e825f337ad51e94c1eb5d3bbdf2b363dcd01e2b19a9ffe3f8e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "tracing-core" version = "0.1.21" @@ -4898,6 +5034,49 @@ dependencies = [ "lazy_static", ] +[[package]] +name = "tracing-log" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6923477a48e41c1951f1999ef8bb5a3023eb723ceadafe78ffb65dc366761e3" +dependencies = [ + "lazy_static", + "log", + "tracing-core", +] + +[[package]] +name = "tracing-opentelemetry" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ffbf13a0f8b054a4e59df3a173b818e9c6177c02789871f2073977fd0062076" +dependencies = [ + "opentelemetry", + "tracing", + "tracing-core", + "tracing-log", + "tracing-subscriber", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77be66445c4eeebb934a7340f227bfe7b338173d3f8c00a60a5a58005c9faecf" +dependencies = [ + "ansi_term", + "lazy_static", + "matchers", + "parking_lot", + "regex", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", +] + [[package]] name = "try-lock" version = "0.2.3" @@ -5007,7 +5186,7 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" dependencies = [ - "getrandom 0.2.3", + "getrandom 0.2.4", "serde", ] @@ -5064,9 +5243,9 @@ checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" [[package]] name = "wasm-bindgen" -version = "0.2.78" +version = "0.2.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "632f73e236b219150ea279196e54e610f5dbafa5d61786303d4da54f84e47fce" +checksum = "25f1af7423d8588a3d840681122e72e6a24ddbcb3f0ec385cac0d12d24256c06" dependencies = [ "cfg-if 1.0.0", "wasm-bindgen-macro", @@ -5074,9 +5253,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.78" +version = "0.2.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a317bf8f9fba2476b4b2c85ef4c4af8ff39c3c7f0cdfeed4f82c34a880aa837b" +checksum = "8b21c0df030f5a177f3cba22e9bc4322695ec43e7257d865302900290bcdedca" dependencies = [ "bumpalo", "lazy_static", @@ -5089,9 +5268,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.28" +version = "0.4.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e8d7523cb1f2a4c96c1317ca690031b714a51cc14e05f712446691f413f5d39" +checksum = "2eb6ec270a31b1d3c7e266b999739109abce8b6c87e4b31fcfcd788b65267395" dependencies = [ "cfg-if 1.0.0", "js-sys", @@ -5101,9 +5280,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.78" +version = "0.2.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d56146e7c495528bf6587663bea13a8eb588d39b36b679d83972e1a2dbbdacf9" +checksum = "2f4203d69e40a52ee523b2529a773d5ffc1dc0071801c87b3d270b471b80ed01" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -5111,9 +5290,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.78" +version = "0.2.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7803e0eea25835f8abdc585cd3021b3deb11543c6fe226dcd30b228857c5c5ab" +checksum = "bfa8a30d46208db204854cadbb5d4baf5fcf8071ba5bf48190c3e59937962ebc" dependencies = [ "proc-macro2", "quote", @@ -5124,15 +5303,15 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.78" +version = "0.2.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0237232789cf037d5480773fe568aac745bfe2afbc11a863e97901780a6b47cc" +checksum = "3d958d035c4438e28c70e4321a2911302f10135ce78a9c7834c0cab4123d06a2" [[package]] name = "web-sys" -version = "0.3.55" +version = "0.3.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38eb105f1c59d9eaa6b5cdc92b859d85b926e82cb2e0945cd0c9259faa6fe9fb" +checksum = "c060b319f29dd25724f09a2ba1418f142f539b2be99fbf4d2d5a8f7330afb8eb" dependencies = [ "js-sys", "wasm-bindgen", @@ -5140,9 +5319,9 @@ dependencies = [ [[package]] name = "which" -version = "4.2.2" +version = "4.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea187a8ef279bc014ec368c27a920da2024d2a711109bfbe3440585d5cf27ad9" +checksum = "2a5a7e487e921cf220206864a94a89b6c6905bfc19f1057fa26a4cb360e5c1d2" dependencies = [ "either", "lazy_static", diff --git a/crates/block-producer/Cargo.toml b/crates/block-producer/Cargo.toml index 9785898b5..ba11aa9c5 100644 --- a/crates/block-producer/Cargo.toml +++ b/crates/block-producer/Cargo.toml @@ -42,7 +42,6 @@ async-channel = "1.4.2" async-jsonrpc-client = { version = "0.3.0", default-features = false, features = ["http-tokio"] } clap = "2.33.3" ctrlc = {version = "3.2.1", features = ["termination"]} -env_logger = "0.8.3" futures = "0.3.13" log = "0.4.14" serde_json = "1.0" @@ -53,9 +52,15 @@ hex = "0.4" async-trait = "0.1" semver = "1.0" rayon = "1.5" -sentry = "0.23.0" -sentry-log = "0.23.0" thiserror = "1.0" +# For latest tracing +sentry = { git = "https://github.com/getsentry/sentry-rust", rev = "df694a49595d6890c510d80b85cfbb4b5ae6159a" } +sentry-tracing = { git = "https://github.com/getsentry/sentry-rust", rev = "df694a49595d6890c510d80b85cfbb4b5ae6159a" } +tracing = { version = "0.1", features = ["attributes"] } +tracing-subscriber = { version = "0.3", features = ["env-filter", "parking_lot", "smallvec", "tracing-log"] } +tracing-opentelemetry = "0.16" +opentelemetry-jaeger = { version = "0.15", features = ["rt-tokio"] } +opentelemetry = { version = "0.16", features = ["rt-tokio"] } [target.'cfg(all(not(target_env = "msvc"), not(target_os="macos")))'.dependencies] tikv-jemallocator = { version = "0.4.0", features = ["unprefixed_malloc_on_supported_platforms"] } diff --git a/crates/block-producer/src/block_producer.rs b/crates/block-producer/src/block_producer.rs index 1a4034d8f..6dce45328 100644 --- a/crates/block-producer/src/block_producer.rs +++ b/crates/block-producer/src/block_producer.rs @@ -50,6 +50,7 @@ use std::{ time::{Duration, Instant}, }; use tokio::sync::Mutex; +use tracing::instrument; const MAX_BLOCK_OUTPUT_PARAM_RETRY_COUNT: usize = 10; const TRANSACTION_SCRIPT_ERROR: &str = "TransactionScriptError"; @@ -79,7 +80,9 @@ fn generate_custodian_cells( deposit_cells.iter().map(to_custodian).collect() } +#[instrument(skip_all)] async fn resolve_tx_deps(rpc_client: &RPCClient, tx_hash: [u8; 32]) -> Result> { + #[instrument(skip_all)] async fn resolve_dep_group(rpc_client: &RPCClient, dep: CellDep) -> Result> { // return dep if dep.dep_type() == DepType::Code.into() { @@ -237,6 +240,7 @@ impl BlockProducer { self.last_submitted_tx_hash.clone() } + #[instrument(skip_all, fields(event = %event))] pub async fn handle_event(&mut self, event: ChainEvent) -> Result<()> { if let Some(ref tests_control) = self.tests_control { match tests_control.payload().await { @@ -372,6 +376,7 @@ impl BlockProducer { Ok(()) } + #[instrument(skip_all, fields(retry_count = retry_count))] async fn compose_next_block_submit_tx( &mut self, median_time: Duration, @@ -535,6 +540,7 @@ impl BlockProducer { } } + #[instrument(skip_all, fields(block = block_number))] async fn submit_block_tx( &mut self, block_number: u64, @@ -645,6 +651,7 @@ impl BlockProducer { } } + #[instrument(skip_all, fields(block = args.block.raw().number().unpack()))] async fn complete_tx_skeleton(&self, args: CompleteTxArgs) -> Result { let CompleteTxArgs { deposit_cells, diff --git a/crates/block-producer/src/custodian.rs b/crates/block-producer/src/custodian.rs index cae3a4a13..10edce3bc 100644 --- a/crates/block-producer/src/custodian.rs +++ b/crates/block-producer/src/custodian.rs @@ -1,9 +1,11 @@ use anyhow::Result; use gw_rpc_client::rpc_client::{QueryResult, RPCClient}; use gw_types::offchain::CollectedCustodianCells; +use tracing::instrument; pub const MAX_CUSTODIANS: usize = 50; +#[instrument(skip_all, fields(last_finalized_block_number = last_finalized_block_number))] pub async fn query_mergeable_custodians( rpc_client: &RPCClient, collected_custodians: CollectedCustodianCells, @@ -31,6 +33,7 @@ pub async fn query_mergeable_custodians( .await } +#[instrument(skip_all, fields(last_finalized_block_number = last_finalized_block_number))] async fn query_mergeable_ckb_custodians( rpc_client: &RPCClient, collected: CollectedCustodianCells, @@ -49,6 +52,7 @@ async fn query_mergeable_ckb_custodians( .await } +#[instrument(skip_all, fields(last_finalized_block_number = last_finalized_block_number))] async fn query_mergeable_sudt_custodians( rpc_client: &RPCClient, collected: CollectedCustodianCells, diff --git a/crates/block-producer/src/lib.rs b/crates/block-producer/src/lib.rs index 346de44bf..23064ed80 100644 --- a/crates/block-producer/src/lib.rs +++ b/crates/block-producer/src/lib.rs @@ -11,6 +11,7 @@ pub mod replay_block; pub mod runner; pub mod stake; pub mod test_mode_control; +pub mod trace; pub mod types; pub mod utils; pub mod withdrawal; diff --git a/crates/block-producer/src/main.rs b/crates/block-producer/src/main.rs index 903c82ec7..b8288efaa 100644 --- a/crates/block-producer/src/main.rs +++ b/crates/block-producer/src/main.rs @@ -4,10 +4,9 @@ static GLOBAL_ALLOC: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; use anyhow::{Context, Result}; use clap::{App, Arg, SubCommand}; -use gw_block_producer::{db_block_validator, runner}; +use gw_block_producer::{db_block_validator, runner, trace}; use gw_config::Config; use gw_version::Version; -use sentry_log::LogFilter; use std::{fs, path::Path}; const COMMAND_RUN: &str = "run"; @@ -103,15 +102,18 @@ async fn run_cli() -> Result<()> { (COMMAND_RUN, Some(m)) => { let config_path = m.value_of(ARG_CONFIG).unwrap(); let config = read_config(&config_path)?; + let _guard = trace::init(config.trace)?; runner::run(config, m.is_present(ARG_SKIP_CONFIG_CHECK)).await?; } (COMMAND_EXAMPLE_CONFIG, Some(m)) => { let path = m.value_of(ARG_OUTPUT_PATH).unwrap(); + let _guard = trace::init(None)?; generate_example_config(path)?; } (COMMAND_VERIFY_DB_BLOCK, Some(m)) => { let config_path = m.value_of(ARG_CONFIG).unwrap(); let config = read_config(&config_path)?; + let _guard = trace::init(None)?; let from_block: Option = m.value_of(ARG_FROM_BLOCK).map(str::parse).transpose()?; let to_block: Option = m.value_of(ARG_TO_BLOCK).map(str::parse).transpose()?; db_block_validator::verify(config, from_block, to_block).await?; @@ -120,6 +122,7 @@ async fn run_cli() -> Result<()> { // default command: start a Godwoken node let config_path = "./config.toml"; let config = read_config(&config_path)?; + let _guard = trace::init(config.trace)?; runner::run(config, false).await?; } }; @@ -130,20 +133,5 @@ async fn run_cli() -> Result<()> { /// Default to number of cpus, pass `worker_threads` to manually configure workers. #[tokio::main(flavor = "multi_thread")] async fn main() { - init_log(); run_cli().await.expect("run cli"); } - -fn init_log() { - let logger = env_logger::builder() - .parse_env(env_logger::Env::default().default_filter_or("info")) - .build(); - let level = logger.filter(); - let logger = sentry_log::SentryLogger::with_dest(logger).filter(|md| match md.level() { - log::Level::Error | log::Level::Warn => LogFilter::Event, - _ => LogFilter::Ignore, - }); - log::set_boxed_logger(Box::new(logger)) - .map(|()| log::set_max_level(level)) - .expect("set log"); -} diff --git a/crates/block-producer/src/poller.rs b/crates/block-producer/src/poller.rs index 902e86a20..f8b5fb1d3 100644 --- a/crates/block-producer/src/poller.rs +++ b/crates/block-producer/src/poller.rs @@ -29,6 +29,7 @@ use gw_web3_indexer::indexer::Web3Indexer; use serde_json::json; use std::{collections::HashSet, sync::Arc}; use tokio::sync::Mutex; +use tracing::instrument; #[derive(thiserror::Error, Debug)] #[error("chain updater query l1 tx {tx_hash} error {source}")] @@ -79,6 +80,7 @@ impl ChainUpdater { } // Start syncing + #[instrument(skip_all, fields(event = %_event))] pub async fn handle_event(&mut self, _event: ChainEvent) -> Result<()> { let initial_syncing = !self.initialized; // Always start from last valid tip on l1 @@ -135,6 +137,7 @@ impl ChainUpdater { Ok(()) } + #[instrument(skip_all)] pub async fn try_sync(&mut self) -> anyhow::Result<()> { let valid_tip_l1_block_number = { let chain = self.chain.lock().await; @@ -195,6 +198,7 @@ impl ChainUpdater { Ok(()) } + #[instrument(skip_all)] pub async fn update(&mut self, txs: &[Tx]) -> anyhow::Result<()> { for tx in txs.iter() { self.update_single(&tx.tx_hash).await?; @@ -204,6 +208,7 @@ impl ChainUpdater { Ok(()) } + #[instrument(skip_all)] async fn update_single(&mut self, tx_hash: &H256) -> anyhow::Result<()> { if let Some(last_tx_hash) = &self.last_tx_hash { if last_tx_hash == tx_hash { @@ -306,6 +311,7 @@ impl ChainUpdater { Ok(()) } + #[instrument(skip_all)] async fn find_l2block_on_l1(&self, committed_info: L2BlockCommittedInfo) -> Result { let rpc_client = &self.rpc_client; let tx_hash: gw_common::H256 = @@ -320,6 +326,7 @@ impl ChainUpdater { Ok(l1_block_hash == Some(block_hash)) } + #[instrument(skip_all)] async fn revert_to_valid_tip_on_l1(&mut self) -> Result<()> { let db = { self.chain.lock().await.store().begin_transaction() }; let mut revert_l1_actions = Vec::new(); @@ -404,6 +411,7 @@ impl ChainUpdater { Ok(()) } + #[instrument(skip_all)] fn extract_rollup_action(&self, tx: &Transaction) -> Result { let rollup_type_hash: [u8; 32] = { let hash = self.rollup_type_script.calc_script_hash(); @@ -438,6 +446,7 @@ impl ChainUpdater { RollupAction::from_slice(&output_type).map_err(|e| anyhow!("invalid rollup action {}", e)) } + #[instrument(skip_all)] async fn extract_challenge_context( &self, tx: &Transaction, @@ -485,6 +494,7 @@ impl ChainUpdater { unreachable!("challenge output not found"); } + #[instrument(skip_all)] async fn extract_deposit_requests( &self, tx: &Transaction, @@ -534,6 +544,7 @@ impl ChainUpdater { } } +#[instrument(skip_all)] fn try_parse_deposit_request( cell_output: &CellOutput, cell_data: &Bytes, diff --git a/crates/block-producer/src/produce_block.rs b/crates/block-producer/src/produce_block.rs index d17539b89..c22089e9c 100644 --- a/crates/block-producer/src/produce_block.rs +++ b/crates/block-producer/src/produce_block.rs @@ -26,6 +26,7 @@ use gw_types::{ }, prelude::*, }; +use tracing::instrument; #[derive(Clone)] pub struct ProduceBlockResult { @@ -45,6 +46,7 @@ pub struct ProduceBlockParam { /// this method take txs & withdrawal requests from tx pool and produce a new block /// the package method should packs the items in order: /// withdrawals, then deposits, finally the txs. Thus, the state-validator can verify this correctly +#[instrument(skip_all)] pub fn produce_block( db: &StoreTransaction, generator: &Generator, @@ -172,6 +174,7 @@ pub fn produce_block( } // Generate produce block param +#[instrument(skip_all, fields(mem_block = mem_block.block_info().number().unpack()))] pub fn generate_produce_block_param( store: &Store, mut mem_block: MemBlock, diff --git a/crates/block-producer/src/runner.rs b/crates/block-producer/src/runner.rs index b5589f74b..bcc30fedc 100644 --- a/crates/block-producer/src/runner.rs +++ b/crates/block-producer/src/runner.rs @@ -488,6 +488,7 @@ pub async fn run(config: Config, skip_config_check: bool) -> Result<()> { )), None => sentry::init(()), }; + // Enable smol threads before smol::spawn let runtime_threads = match std::env::var(SMOL_THREADS_ENV_VAR) { Ok(s) => s.parse()?, diff --git a/crates/block-producer/src/trace.rs b/crates/block-producer/src/trace.rs new file mode 100644 index 000000000..a911341e6 --- /dev/null +++ b/crates/block-producer/src/trace.rs @@ -0,0 +1,51 @@ +use anyhow::Result; +use gw_config::Trace; +use sentry_tracing::EventFilter; +use tracing_subscriber::prelude::*; + +pub struct ShutdownGuard { + trace: Option, +} + +impl Drop for ShutdownGuard { + fn drop(&mut self) { + if let Some(Trace::Jaeger) = self.trace { + opentelemetry::global::shutdown_tracer_provider(); // Sending remaining spans + } + } +} + +pub fn init(trace: Option) -> Result { + let env_filter_layer = tracing_subscriber::EnvFilter::try_from_default_env() + .or_else(|_| tracing_subscriber::EnvFilter::try_new("info"))?; + + // NOTE: `traces_sample_rate` in sentry client option is 0.0 by default, which disable sentry + // tracing. Here we just use sentry-log feature. + let sentry_layer = sentry_tracing::layer().event_filter(|md| match md.level() { + &tracing::Level::ERROR | &tracing::Level::WARN => EventFilter::Event, + _ => EventFilter::Ignore, + }); + + let registry = tracing_subscriber::registry() + .with(tracing_subscriber::fmt::layer()) + .with(env_filter_layer) + .with(sentry_layer); + + match trace { + Some(Trace::Jaeger) => { + opentelemetry::global::set_text_map_propagator(opentelemetry_jaeger::Propagator::new()); + + let jaeger_layer = { + let tracer = opentelemetry_jaeger::new_pipeline() + .with_service_name("godwoken") + .install_batch(opentelemetry::runtime::Tokio)?; + tracing_opentelemetry::layer().with_tracer(tracer) + }; + + registry.with(jaeger_layer).try_init()? + } + None => registry.try_init()?, + } + + Ok(ShutdownGuard { trace }) +} diff --git a/crates/config/src/config.rs b/crates/config/src/config.rs index e2d465e4a..d4331f877 100644 --- a/crates/config/src/config.rs +++ b/crates/config/src/config.rs @@ -10,6 +10,12 @@ use std::{ path::PathBuf, }; +#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize, Hash)] +#[serde(rename_all = "lowercase")] +pub enum Trace { + Jaeger, +} + #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct Config { pub node_mode: NodeMode, @@ -32,6 +38,8 @@ pub struct Config { pub store: StoreConfig, pub sentry_dsn: Option, #[serde(default)] + pub trace: Option, + #[serde(default)] pub consensus: ConsensusConfig, pub reload_config_github_url: Option, #[serde(default)] diff --git a/crates/generator/Cargo.toml b/crates/generator/Cargo.toml index d68bcb8b5..359cba53f 100644 --- a/crates/generator/Cargo.toml +++ b/crates/generator/Cargo.toml @@ -33,6 +33,7 @@ log = "0.4" hex = "0.4" tokio = "1.15" arc-swap = "1.5" +tracing = { version = "0.1", features = ["attributes"] } [dev-dependencies] gw-utils = {path = "../utils" } diff --git a/crates/generator/src/generator.rs b/crates/generator/src/generator.rs index f51798ae0..89a0ecd76 100644 --- a/crates/generator/src/generator.rs +++ b/crates/generator/src/generator.rs @@ -48,6 +48,7 @@ use ckb_vm::{DefaultMachineBuilder, SupportMachine}; #[cfg(not(has_asm))] use ckb_vm::TraceMachine; +use tracing::instrument; pub struct ApplyBlockArgs { pub l2block: L2Block, @@ -134,6 +135,7 @@ impl Generator { &self.account_lock_manage } + #[instrument(skip_all, fields(backend = ?backend.backend_type))] fn machine_run<'a, S: State + CodeStore, C: ChainView>( &'a self, chain: &'a C, @@ -203,6 +205,7 @@ impl Generator { /// Verify withdrawal request /// Notice this function do not perform signature check + #[instrument(skip_all)] pub fn verify_withdrawal_request( &self, state: &S, @@ -297,6 +300,7 @@ impl Generator { } /// Check withdrawal request signature + #[instrument(skip_all)] pub fn check_withdrawal_request_signature( &self, state: &S, @@ -331,6 +335,7 @@ impl Generator { /// verify transaction /// Notice this function do not perform signature check + #[instrument(skip_all)] pub fn verify_transaction( &self, state: &S, @@ -355,6 +360,7 @@ impl Generator { } // Check transaction signature + #[instrument(skip_all)] pub fn check_transaction_signature( &self, state: &S, @@ -399,6 +405,7 @@ impl Generator { } /// Apply l2 state transition + #[instrument(skip_all, fields(block = args.l2block.raw().number().unpack(), deposits_count = args.deposit_requests.len()))] pub fn verify_and_apply_block( &self, db: &StoreTransaction, @@ -646,6 +653,7 @@ impl Generator { } } + #[instrument(skip_all, fields(script_hash = %script_hash.pack()))] pub fn load_backend( &self, state: &S, @@ -675,6 +683,7 @@ impl Generator { } /// execute a layer2 tx + #[instrument(skip_all)] pub fn execute_transaction( &self, chain: &C, @@ -700,6 +709,7 @@ impl Generator { } /// execute a layer2 tx, doesn't check exit code + #[instrument(skip_all, fields(block = block_info.number().unpack(), tx_hash = %raw_tx.hash().pack()))] pub fn unchecked_execute_transaction( &self, chain: &C, diff --git a/crates/generator/src/traits.rs b/crates/generator/src/traits.rs index 626f34635..e1f286939 100644 --- a/crates/generator/src/traits.rs +++ b/crates/generator/src/traits.rs @@ -14,6 +14,7 @@ use gw_types::{ packed::{AccountMerkleState, DepositRequest, Script, WithdrawalReceipt, WithdrawalRequest}, prelude::*, }; +use tracing::instrument; pub trait StateExt { fn create_account_from_script(&mut self, script: Script) -> Result; @@ -90,6 +91,7 @@ impl StateExt for S { Ok(merkle_state) } + #[instrument(skip_all)] fn apply_run_result(&mut self, run_result: &RunResult) -> Result<(), Error> { for (k, v) in &run_result.write_values { self.update_raw(*k, *v)?; @@ -126,6 +128,7 @@ impl StateExt for S { Ok(()) } + #[instrument(skip_all)] fn apply_deposit_request( &mut self, ctx: &RollupContext, @@ -190,6 +193,7 @@ impl StateExt for S { Ok(()) } + #[instrument(skip_all)] fn apply_withdrawal_request( &mut self, ctx: &RollupContext, diff --git a/crates/mem-pool/Cargo.toml b/crates/mem-pool/Cargo.toml index 9249fc0d0..2ba6ef65b 100644 --- a/crates/mem-pool/Cargo.toml +++ b/crates/mem-pool/Cargo.toml @@ -25,6 +25,7 @@ anyhow = "1.0" log = "0.4" hex = "0.4" async-trait = "0.1" +tracing = { version = "0.1", features = ["attributes"] } [dev-dependencies] tempfile = "3.2" diff --git a/crates/mem-pool/src/custodian.rs b/crates/mem-pool/src/custodian.rs index 7e8b1e096..bd611fe5a 100644 --- a/crates/mem-pool/src/custodian.rs +++ b/crates/mem-pool/src/custodian.rs @@ -11,6 +11,7 @@ use gw_types::{ packed::{CellOutput, CustodianLockArgs, DepositLockArgs, Script, WithdrawalRequest}, prelude::*, }; +use tracing::instrument; use crate::constants::MAX_CUSTODIANS; @@ -118,6 +119,7 @@ pub fn sum_withdrawals>(reqs: Iter) -> ) } +#[instrument(skip_all, fields(last_finalized_block_number = last_finalized_block_number))] pub async fn query_finalized_custodians>( rpc_client: &RPCClient, db: &impl ChainStore, @@ -183,6 +185,7 @@ pub fn generate_finalized_custodian( (output, data) } +#[instrument(skip_all, fields(withdrawals_amount = ?withdrawals_amount))] fn sum_change_capacity( db: &impl ChainStore, rollup_context: &RollupContext, diff --git a/crates/mem-pool/src/default_provider.rs b/crates/mem-pool/src/default_provider.rs index 17597e53a..d0e1510ab 100644 --- a/crates/mem-pool/src/default_provider.rs +++ b/crates/mem-pool/src/default_provider.rs @@ -13,6 +13,7 @@ use gw_types::{ prelude::*, }; use tokio::sync::Mutex; +use tracing::instrument; use crate::{ constants::{MAX_MEM_BLOCK_DEPOSITS, MIN_CKB_DEPOSIT_CAPACITY, MIN_SUDT_DEPOSIT_CAPACITY}, @@ -40,6 +41,7 @@ impl DefaultMemPoolProvider { #[async_trait] impl MemPoolProvider for DefaultMemPoolProvider { + #[instrument(skip_all)] async fn estimate_next_blocktime(&self) -> Result { // estimate next l2block timestamp let poa = self.poa.lock().await; @@ -60,6 +62,7 @@ impl MemPoolProvider for DefaultMemPoolProvider { Ok(timestamp) } + #[instrument(skip_all)] async fn collect_deposit_cells(&self) -> Result> { let rpc_client = self.rpc_client.clone(); rpc_client @@ -71,10 +74,12 @@ impl MemPoolProvider for DefaultMemPoolProvider { .await } + #[instrument(skip_all)] async fn get_cell(&self, out_point: OutPoint) -> Result> { self.rpc_client.get_cell(out_point).await } + #[instrument(skip_all)] async fn query_available_custodians( &self, withdrawals: Vec, diff --git a/crates/mem-pool/src/fee/queue.rs b/crates/mem-pool/src/fee/queue.rs index 45e9c9e47..af7179b0d 100644 --- a/crates/mem-pool/src/fee/queue.rs +++ b/crates/mem-pool/src/fee/queue.rs @@ -1,6 +1,7 @@ use anyhow::Result; use gw_common::state::State; use std::collections::{BinaryHeap, HashMap}; +use tracing::instrument; /// Max queue size const MAX_QUEUE_SIZE: usize = 10000; @@ -31,6 +32,7 @@ impl FeeQueue { } /// Add item to queue + #[instrument(skip_all, fields(count = self.len()))] pub fn add(&mut self, entry: FeeEntry) { // push to queue log::debug!( @@ -66,6 +68,7 @@ impl FeeQueue { } /// Fetch items by fee sort + #[instrument(skip_all, fields(count = count))] pub fn fetch(&mut self, state: &impl State, count: usize) -> Result> { // sorted fee items let mut fetched_items = Vec::with_capacity(count as usize); diff --git a/crates/mem-pool/src/pool.rs b/crates/mem-pool/src/pool.rs index 23e9e4cb6..589e1c52d 100644 --- a/crates/mem-pool/src/pool.rs +++ b/crates/mem-pool/src/pool.rs @@ -34,7 +34,7 @@ use gw_types::{ AccountMerkleState, BlockInfo, L2Block, L2Transaction, Script, TxReceipt, WithdrawalRequest, WithdrawalRequestExtra, }, - prelude::{Entity, Unpack}, + prelude::{Entity, Pack, Unpack}, }; use std::{ cmp::{max, min}, @@ -44,6 +44,7 @@ use std::{ sync::Arc, time::Instant, }; +use tracing::instrument; use crate::{ constants::{MAX_MEM_BLOCK_TXS, MAX_MEM_BLOCK_WITHDRAWALS, MAX_TX_SIZE, MAX_WITHDRAWAL_SIZE}, @@ -263,6 +264,7 @@ impl MemPool { } /// Push a layer2 tx into pool + #[instrument(skip_all)] pub async fn push_transaction(&mut self, tx: L2Transaction) -> Result<()> { let db = self.store.begin_transaction(); @@ -274,6 +276,7 @@ impl MemPool { } /// Push a layer2 tx into pool + #[instrument(skip_all, fields(tx_hash = %tx.hash().pack()))] async fn push_transaction_with_db( &mut self, db: &StoreTransaction, @@ -318,6 +321,7 @@ impl MemPool { } /// verify tx + #[instrument(skip_all)] fn verify_tx(&self, state: &(impl State + CodeStore), tx: &L2Transaction) -> Result<()> { // check tx size if tx.as_slice().len() > MAX_TX_SIZE { @@ -333,6 +337,7 @@ impl MemPool { } /// Push a withdrawal request into pool + #[instrument(skip_all, fields(withdrawal = %withdrawal.hash().pack()))] pub async fn push_withdrawal_request( &mut self, withdrawal: WithdrawalRequestExtra, @@ -371,6 +376,7 @@ impl MemPool { // Withdrawal request verification // TODO: duplicate withdrawal check + #[instrument(skip_all)] async fn verify_withdrawal_request( &self, withdrawal: &WithdrawalRequestExtra, @@ -421,6 +427,7 @@ impl MemPool { /// Notify new tip /// this method update current state of mem pool + #[instrument(skip_all)] pub async fn notify_new_tip(&mut self, new_tip: H256) -> Result<()> { // reset pool state self.reset(Some(self.current_tip.0), Some(new_tip)).await?; @@ -428,6 +435,7 @@ impl MemPool { } /// Clear mem block state and recollect deposits + #[instrument(skip_all)] pub async fn reset_mem_block(&mut self) -> Result<()> { log::info!("[mem-pool] reset mem block"); // reset pool state @@ -458,6 +466,7 @@ impl MemPool { } /// output mem block + #[instrument(skip_all, fields(retry_count = output_param.retry_count))] pub fn output_mem_block(&self, output_param: &OutputParam) -> (MemBlock, AccountMerkleState) { Self::package_mem_block(&self.mem_block, output_param) } @@ -479,6 +488,7 @@ impl MemPool { /// Reset /// this method reset the current state of the mem pool /// discarded txs & withdrawals will be reinject to pool + #[instrument(skip_all, fields(old_tip = old_tip.map(|h| display(h.pack())), new_tip = new_tip.map(|h| display(h.pack()))))] async fn reset(&mut self, old_tip: Option, new_tip: Option) -> Result<()> { let mut reinject_txs = Default::default(); let mut reinject_withdrawals = Default::default(); @@ -631,6 +641,7 @@ impl MemPool { } /// Discard unexecutables from pending. + #[instrument(skip_all)] async fn remove_unexecutables(&mut self, db: &StoreTransaction) -> Result<()> { let snap = self.mem_pool_state.load(); let state = snap.state()?; @@ -666,6 +677,7 @@ impl MemPool { } /// Prepare for next mem block + #[instrument(skip_all, fields(withdrawals_count = withdrawals.size_hint().1, txs_count = txs.size_hint().1))] async fn prepare_next_mem_block< WithdrawalIter: Iterator, TxIter: Iterator + Clone, @@ -733,6 +745,7 @@ impl MemPool { } /// expire if pending deposits is handled by new l2block + #[instrument(skip_all)] async fn refresh_deposit_cells( &mut self, db: &StoreTransaction, @@ -829,6 +842,7 @@ impl MemPool { Ok(()) } + #[instrument(skip_all, fields(deposits_count = deposit_cells.len()))] async fn finalize_deposits(&mut self, deposit_cells: Vec) -> Result<()> { let snap = self.mem_pool_state.load(); let mut state = snap.state()?; @@ -860,6 +874,7 @@ impl MemPool { } /// Execute withdrawal & update local state + #[instrument(skip_all, fields(withdrawals_count = withdrawals.len()))] async fn finalize_withdrawals( &mut self, mut withdrawals: Vec, @@ -1000,6 +1015,7 @@ impl MemPool { } /// Execute tx & update local state + #[instrument(skip_all)] async fn finalize_tx(&mut self, db: &StoreTransaction, tx: L2Transaction) -> Result { let snap = self.mem_pool_state.load(); let mut state = snap.state()?; @@ -1078,6 +1094,7 @@ impl MemPool { // Always expects next block number equals with current_tip_block_number + 1. // This function returns Ok(Some(block_number)), if refresh is successful. // Or returns Ok(None) if current tip has not synced yet. + #[instrument(skip_all, fields(block = block_info.number().unpack(), withdrawals_count = withdrawals.len(), deposits_count = deposits.len()))] pub(crate) async fn refresh_mem_block( &mut self, block_info: BlockInfo, @@ -1125,6 +1142,7 @@ impl MemPool { // Only **ReadOnly** node needs this. // Sync tx from fullnode to readonly. + #[instrument(skip_all, fields(tx_hash = %tx.hash().pack(), current_tip_block = current_tip_block_number))] pub(crate) async fn append_tx( &mut self, tx: L2Transaction, diff --git a/crates/rpc-client/Cargo.toml b/crates/rpc-client/Cargo.toml index 6443aaa46..0fdf58c3b 100644 --- a/crates/rpc-client/Cargo.toml +++ b/crates/rpc-client/Cargo.toml @@ -32,3 +32,4 @@ semver = "1.0" rand = "0.8" arc-swap = "1.5" thiserror = "1.0" +tracing = { version = "0.1", features = ["attributes"] } diff --git a/crates/rpc-client/src/ckb_client.rs b/crates/rpc-client/src/ckb_client.rs index 2064abd2b..2cdf33f71 100644 --- a/crates/rpc-client/src/ckb_client.rs +++ b/crates/rpc-client/src/ckb_client.rs @@ -7,6 +7,7 @@ use async_jsonrpc_client::{HttpClient, Params as ClientParams, Transport}; use gw_jsonrpc_types::blockchain::CellDep; use serde::de::DeserializeOwned; use serde_json::json; +use tracing::instrument; #[derive(Clone)] pub struct CKBClient(HttpClient); @@ -27,6 +28,7 @@ impl CKBClient { &self.0 } + #[instrument(skip_all, fields(method = method))] pub async fn request( &self, method: &str, @@ -51,6 +53,7 @@ impl CKBClient { } } + #[instrument(skip_all)] pub async fn query_type_script( &self, contract: &str, diff --git a/crates/rpc-client/src/contract.rs b/crates/rpc-client/src/contract.rs index b1ee5fbb0..269ce48ac 100644 --- a/crates/rpc-client/src/contract.rs +++ b/crates/rpc-client/src/contract.rs @@ -10,6 +10,7 @@ use gw_jsonrpc_types::blockchain::{CellDep, Script}; use gw_types::packed::RollupConfig; use gw_types::prelude::Pack; use serde_json::json; +use tracing::instrument; use crate::indexer_types::{Cell, Order, Pagination, ScriptType, SearchKey}; use crate::rpc_client::RPCClient; @@ -41,6 +42,7 @@ impl ContractsCellDepManager { self.deps.load() } + #[instrument(skip_all)] pub async fn refresh(&self) -> Result<()> { log::info!("[contracts dep] refresh"); diff --git a/crates/rpc-client/src/indexer_client.rs b/crates/rpc-client/src/indexer_client.rs index 1608487d0..aae0f8c86 100644 --- a/crates/rpc-client/src/indexer_client.rs +++ b/crates/rpc-client/src/indexer_client.rs @@ -16,6 +16,7 @@ use gw_types::{ }; use serde::de::DeserializeOwned; use serde_json::json; +use tracing::instrument; use std::collections::{HashMap, HashSet}; @@ -38,6 +39,7 @@ impl CKBIndexerClient { &self.0 } + #[instrument(skip_all, fields(method = method))] pub async fn request( &self, method: &str, @@ -63,6 +65,7 @@ impl CKBIndexerClient { /// query payment cells, the returned cells should provide at least required_capacity fee, /// and the remained fees should be enough to cover a charge cell + #[instrument(skip_all, fields(required_capacity = required_capacity))] pub async fn query_payment_cells( &self, lock: Script, @@ -142,6 +145,7 @@ impl CKBIndexerClient { Ok(collected_cells) } + #[instrument(skip_all, fields(last_finalized_block_number = last_finalized_block_number))] pub async fn stat_custodian_cells( &self, lock: Script, diff --git a/crates/rpc-client/src/rpc_client.rs b/crates/rpc-client/src/rpc_client.rs index 13aed82a1..be2dda229 100644 --- a/crates/rpc-client/src/rpc_client.rs +++ b/crates/rpc-client/src/rpc_client.rs @@ -27,6 +27,7 @@ use gw_types::{ }; use rand::prelude::*; use serde_json::json; +use tracing::instrument; use std::time::Instant; use std::{collections::HashSet, time::Duration}; @@ -132,6 +133,7 @@ impl RPCClient { } /// query lived rollup cell + #[instrument(skip_all)] pub async fn query_rollup_cell(&self) -> Result> { let search_key = SearchKey { script: self.rollup_type_script.clone().into(), @@ -178,6 +180,7 @@ impl RPCClient { } /// this function queries identity cell by args + #[instrument(skip_all)] pub async fn query_identity_cell(&self, args: Bytes) -> Result> { let search_key = SearchKey { script: ckb_types::packed::Script::new_builder() @@ -233,6 +236,7 @@ impl RPCClient { } /// this function return a cell that do not has data & _type fields + #[instrument(skip_all)] pub async fn query_owner_cell( &self, lock: Script, @@ -288,6 +292,7 @@ impl RPCClient { Ok(cell) } + #[instrument(skip_all, fields(tx_hash = %out_point.tx_hash(), index = Unpack::::unpack(&out_point.index())))] pub async fn get_cell(&self, out_point: OutPoint) -> Result> { let json_out_point: ckb_jsonrpc_types::OutPoint = { let out_point = ckb_types::packed::OutPoint::new_unchecked(out_point.as_bytes()); @@ -334,6 +339,7 @@ impl RPCClient { })) } + #[instrument(skip_all, fields(tx_hash = %out_point.tx_hash(), index = Unpack::::unpack(&out_point.index())))] pub async fn get_cell_from_mempool(&self, out_point: OutPoint) -> Result> { let tx = match self.get_transaction(out_point.tx_hash().unpack()).await? { Some(tx) => tx, @@ -359,12 +365,14 @@ impl RPCClient { })) } + #[instrument(skip_all)] pub async fn get_tip(&self) -> Result { let number_hash: gw_jsonrpc_types::blockchain::NumberHash = self.indexer.request("get_tip", None).await?; Ok(number_hash.into()) } + #[instrument(skip_all, fields(block_hash = %block_hash.pack()))] pub async fn get_block_median_time(&self, block_hash: H256) -> Result> { let opt_median_time: Option = self .ckb @@ -377,6 +385,7 @@ impl RPCClient { Ok(opt_median_time.map(|t| Duration::from_millis(t.into()))) } + #[instrument(skip_all, fields(block = number))] pub async fn get_block_by_number(&self, number: u64) -> Result> { let block_number = BlockNumber::from(number); let block_opt: Option = self @@ -394,6 +403,7 @@ impl RPCClient { /// return all lived deposit requests /// NOTICE the returned cells may contains invalid cells. + #[instrument(skip(self))] pub async fn query_deposit_cells( &self, count: usize, @@ -517,6 +527,10 @@ impl RPCClient { /// query stake /// return cell which stake_block_number is less than last_finalized_block_number if the args isn't none /// otherwise return stake cell randomly + #[instrument( + skip_all, + fields(required_staking_capacity, last_finalized_block_number) + )] pub async fn query_stake( &self, rollup_context: &RollupContext, @@ -606,6 +620,7 @@ impl RPCClient { Ok(stake_cell.map(fetch_cell_info)) } + #[instrument(skip_all)] pub async fn query_stake_cells_by_owner_lock_hashes( &self, owner_lock_hashes: impl Iterator, @@ -676,6 +691,7 @@ impl RPCClient { Ok(collected_cells) } + #[instrument(skip(self))] pub async fn query_custodian_cells_by_block_hashes( &self, block_hashes: &HashSet, @@ -740,6 +756,7 @@ impl RPCClient { Ok((collected, collected_block_hashes)) } + #[instrument(skip_all, fields(last_finalized_block_number = last_finalized_block_number, max_cells = max_cells))] pub async fn query_mergeable_ckb_custodians_cells( &self, mut collected: CollectedCustodianCells, @@ -847,6 +864,7 @@ impl RPCClient { } } + #[instrument(skip_all, fields(last_finalized_block_number = last_finalized_block_number, max_cells = max_cells))] pub async fn query_mergeable_sudt_custodians_cells( &self, mut collected: CollectedCustodianCells, @@ -966,6 +984,10 @@ impl RPCClient { } } + #[instrument( + skip_all, + fields(withdrawals_amount, last_finalized_block_number, max_cells) + )] pub async fn query_finalized_custodian_cells( &self, withdrawals_amount: &WithdrawalsAmount, @@ -1151,6 +1173,7 @@ impl RPCClient { Ok(QueryResult::Full(collected)) } + #[instrument(skip_all)] pub async fn query_verified_custodian_type_script( &self, sudt_script_hash: &[u8; 32], @@ -1224,6 +1247,7 @@ impl RPCClient { } } + #[instrument(skip_all)] pub async fn query_withdrawal_cells_by_block_hashes( &self, block_hashes: &HashSet, @@ -1289,6 +1313,7 @@ impl RPCClient { Ok((collected, collected_block_hashes)) } + #[instrument(skip_all)] pub async fn query_verifier_cell( &self, allowed_script_type_hash: [u8; 32], @@ -1356,6 +1381,7 @@ impl RPCClient { Ok(verifier_cell) } + #[instrument(skip_all)] pub async fn query_finalized_owner_lock_withdrawal_cells( &self, last_finalized_block_number: u64, @@ -1426,6 +1452,7 @@ impl RPCClient { Ok(collected) } + #[instrument(skip_all, fields(block_hash = %block_hash.pack()))] pub async fn get_block( &self, block_hash: H256, @@ -1441,6 +1468,7 @@ impl RPCClient { Ok(block) } + #[instrument(skip_all, fields(block_hash = %block_hash.pack()))] pub async fn get_header( &self, block_hash: H256, @@ -1456,6 +1484,7 @@ impl RPCClient { Ok(block) } + #[instrument(skip_all, fields(tx_hash = %tx_hash.pack()))] pub async fn get_transaction_block_hash(&self, tx_hash: H256) -> Result> { let tx_with_status: Option = self .ckb @@ -1477,6 +1506,7 @@ impl RPCClient { } } + #[instrument(skip_all, fields(tx_hash = %tx_hash.pack()))] pub async fn get_transaction_block_number(&self, tx_hash: H256) -> Result> { match self.get_transaction_block_hash(tx_hash).await? { Some(block_hash) => { @@ -1487,6 +1517,7 @@ impl RPCClient { } } + #[instrument(skip_all, fields(tx_hash = %tx_hash.pack()))] pub async fn get_transaction(&self, tx_hash: H256) -> Result> { let tx_with_status: Option = self .ckb @@ -1501,6 +1532,7 @@ impl RPCClient { })) } + #[instrument(skip_all, fields(tx_hash = %tx_hash.pack()))] pub async fn get_transaction_status(&self, tx_hash: H256) -> Result> { let tx_with_status: Option = self .ckb @@ -1519,6 +1551,7 @@ impl RPCClient { ) } + #[instrument(skip_all, fields(tx_hash = %tx.hash().pack()))] pub async fn send_transaction(&self, tx: &Transaction) -> Result { let tx: ckb_jsonrpc_types::Transaction = { let tx = ckb_types::packed::Transaction::new_unchecked(tx.as_bytes()); @@ -1534,11 +1567,13 @@ impl RPCClient { Ok(to_h256(tx_hash)) } + #[instrument(skip_all)] pub async fn get_ckb_version(&self) -> Result { let node: ckb_jsonrpc_types::LocalNode = self.ckb.request("local_node_info", None).await?; Ok(node.version) } + #[instrument(skip_all, fields(tx_hash = %tx.hash().pack()))] pub async fn dry_run_transaction(&self, tx: &Transaction) -> Result { let tx: ckb_jsonrpc_types::Transaction = { let tx = ckb_types::packed::Transaction::new_unchecked(tx.as_bytes()); @@ -1554,6 +1589,7 @@ impl RPCClient { Ok(dry_run_result.cycles.into()) } + #[instrument(skip_all)] pub async fn get_current_epoch_number(&self) -> Result { let epoch_view: ckb_jsonrpc_types::EpochView = self.ckb.request("get_current_epoch", None).await?; @@ -1561,6 +1597,7 @@ impl RPCClient { Ok(epoch_number) } + #[instrument(skip_all)] pub async fn get_hardfork_switch(&self) -> Result { let consensus: Consensus = self.ckb.request("get_consensus", None).await?; let rfc_0028 = self.get_hardfork_feature_epoch_number(&consensus, "0028")?; @@ -1585,6 +1622,7 @@ impl RPCClient { Ok(hardfork_switch) } + #[instrument(skip_all)] fn get_hardfork_feature_epoch_number(&self, consensus: &Consensus, rfc: &str) -> Result { let rfc_info = consensus .hardfork_features @@ -1597,6 +1635,7 @@ impl RPCClient { Ok(epoch_number) } + #[instrument(skip(self))] async fn query_random_sudt_type_script( &self, last_finalized_block_number: u64, @@ -1692,6 +1731,7 @@ impl RPCClient { Ok(sudt_type_script_set) } + #[instrument(skip_all, fields(last_finalized_block_number = last_finalized_block_number, max_cells = max_cells))] async fn query_mergeable_sudt_custodians_cells_by_sudt_type_script( &self, sudt_type_script: &Script, diff --git a/crates/rpc-server/Cargo.toml b/crates/rpc-server/Cargo.toml index ef85d3ace..4e908cc59 100644 --- a/crates/rpc-server/Cargo.toml +++ b/crates/rpc-server/Cargo.toml @@ -47,3 +47,4 @@ once_cell = "1.8" jemalloc-ctl = { package = "tikv-jemalloc-ctl", version = "0.4.2" } jemalloc-sys = { package = "tikv-jemalloc-sys", version = "0.4.2" } errno = "*" +tracing = { version = "0.1", features = ["attributes"] } diff --git a/crates/rpc-server/src/registry.rs b/crates/rpc-server/src/registry.rs index b0c03f839..2c5e2272d 100644 --- a/crates/rpc-server/src/registry.rs +++ b/crates/rpc-server/src/registry.rs @@ -46,6 +46,7 @@ use std::{ time::{Duration, Instant}, }; use tokio::sync::Mutex; +use tracing::instrument; static PROFILER_GUARD: Lazy>> = Lazy::new(|| tokio::sync::Mutex::new(None)); @@ -354,6 +355,7 @@ struct RequestSubmitter { store: Store, } +#[instrument(skip_all, fields(req_kind = req.kind()))] fn req_to_entry( fee_config: &FeeConfig, generator: Arc, @@ -735,6 +737,7 @@ async fn get_transaction_receipt( .map(Into::into)) } +#[instrument(skip_all)] async fn execute_l2transaction( Params((l2tx,)): Params<(JsonBytes,)>, ctx: Data, @@ -812,6 +815,7 @@ enum ExecuteRawL2TransactionParams { Number((JsonBytes, Option)), } +#[instrument(skip_all)] async fn execute_raw_l2transaction( Params(params): Params, mem_pool_config: Data, @@ -913,6 +917,7 @@ async fn execute_raw_l2transaction( Ok(run_result.into()) } +#[instrument(skip_all)] async fn submit_l2transaction( Params((l2tx,)): Params<(JsonBytes,)>, submit_tx: Data>, @@ -987,6 +992,7 @@ async fn submit_l2transaction( Ok(tx_hash) } +#[instrument(skip_all)] async fn submit_withdrawal_request( Params((withdrawal_request,)): Params<(JsonBytes,)>, generator: Data, diff --git a/crates/rpc-ws-server/Cargo.toml b/crates/rpc-ws-server/Cargo.toml index 9d6b6f6a8..a03d4c295 100644 --- a/crates/rpc-ws-server/Cargo.toml +++ b/crates/rpc-ws-server/Cargo.toml @@ -24,3 +24,4 @@ gw-types = { path = "../types" } tokio = "1.15" futures = "0.3" async-channel = "1.4" +tracing = { version = "0.1", features = ["attributes"] } diff --git a/crates/rpc-ws-server/src/notify_controller.rs b/crates/rpc-ws-server/src/notify_controller.rs index 72fdc5e8b..2e69ba392 100644 --- a/crates/rpc-ws-server/src/notify_controller.rs +++ b/crates/rpc-ws-server/src/notify_controller.rs @@ -4,6 +4,7 @@ use futures::{FutureExt, StreamExt}; use gw_types::offchain::ErrorTxReceipt; use std::collections::HashMap; use std::sync::Arc; +use tracing::instrument; pub const SIGNAL_CHANNEL_SIZE: usize = 1; pub const REGISTER_CHANNEL_SIZE: usize = 2; @@ -146,6 +147,7 @@ impl NotifyController { Request::call(&self.subscribe_err_receipt_tx, name.to_string()).await } + #[instrument(skip_all)] pub fn notify_new_error_tx_receipt(&self, error_tx_receipt: ErrorTxReceipt) { let err_receipt = Arc::new(error_tx_receipt); if let Err(err) = self.err_receipt_tx.try_send(Arc::clone(&err_receipt)) { diff --git a/crates/tools/src/generate_config.rs b/crates/tools/src/generate_config.rs index 5e49c48e5..df66c9831 100644 --- a/crates/tools/src/generate_config.rs +++ b/crates/tools/src/generate_config.rs @@ -248,6 +248,7 @@ pub async fn generate_node_config(args: GenerateNodeConfigArgs<'_>) -> Result Result<()> { if self.latest_block < receipt.block_number { self.latest_block = receipt.block_number;