chore: remove expects in persistence task (#10031)

This commit is contained in:
Dan Cline
2024-08-02 17:01:14 -04:00
committed by GitHub
parent 721e732e46
commit 1290260da3
4 changed files with 162 additions and 159 deletions

202
Cargo.lock generated
View File

@ -74,7 +74,7 @@ dependencies = [
"getrandom 0.2.15",
"once_cell",
"version_check",
"zerocopy 0.7.35",
"zerocopy",
]
[[package]]
@ -109,9 +109,9 @@ checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f"
[[package]]
name = "alloy-chains"
version = "0.1.24"
version = "0.1.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "47ff94ce0f141c2671c23d02c7b88990dd432856639595c5d010663d017c2c58"
checksum = "1752d7d62e2665da650a36d84abbf239f812534475d51f072a49a533513b7cdd"
dependencies = [
"alloy-rlp",
"arbitrary",
@ -151,7 +151,7 @@ dependencies = [
"itoa",
"serde",
"serde_json",
"winnow 0.6.18",
"winnow 0.6.16",
]
[[package]]
@ -583,7 +583,7 @@ dependencies = [
"alloy-sol-macro-input",
"const-hex",
"heck 0.5.0",
"indexmap 2.3.0",
"indexmap 2.2.6",
"proc-macro-error",
"proc-macro2",
"quote",
@ -614,7 +614,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cbcba3ca07cf7975f15d871b721fb18031eec8bce51103907f6dcce00b255d98"
dependencies = [
"serde",
"winnow 0.6.18",
"winnow 0.6.16",
]
[[package]]
@ -1309,7 +1309,7 @@ dependencies = [
"bitflags 2.6.0",
"boa_interner",
"boa_macros",
"indexmap 2.3.0",
"indexmap 2.2.6",
"num-bigint",
"rustc-hash 2.0.0",
]
@ -1335,7 +1335,7 @@ dependencies = [
"fast-float",
"hashbrown 0.14.5",
"icu_normalizer",
"indexmap 2.3.0",
"indexmap 2.2.6",
"intrusive-collections",
"itertools 0.13.0",
"num-bigint",
@ -1381,7 +1381,7 @@ dependencies = [
"boa_gc",
"boa_macros",
"hashbrown 0.14.5",
"indexmap 2.3.0",
"indexmap 2.2.6",
"once_cell",
"phf",
"rustc-hash 2.0.0",
@ -1503,9 +1503,9 @@ checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c"
[[package]]
name = "bytemuck"
version = "1.16.3"
version = "1.16.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "102087e286b4677862ea56cf8fc58bb2cdfa8725c40ffb80fe3a008eb7f2fc83"
checksum = "b236fc92302c97ed75b38da1f4917b5cdda4984745740f153a5d3059e48d725e"
dependencies = [
"bytemuck_derive",
]
@ -1529,9 +1529,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
[[package]]
name = "bytes"
version = "1.7.0"
version = "1.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fca2be1d5c43812bae364ee3f30b3afcb7877cf59f4aeb94c66f313a41d2fac9"
checksum = "a12916984aab3fa6e39d655a33e09c0071eb36d6ab3aea5c2d78551f1df6d952"
dependencies = [
"serde",
]
@ -1605,9 +1605,9 @@ dependencies = [
[[package]]
name = "cc"
version = "1.1.7"
version = "1.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26a5c3fd7bfa1ce3897a3a3501d362b2d87b7f2583ebcb4a949ec25911025cbc"
checksum = "2aba8f4e9906c7ce3c73463f62a7f0c65183ada1a2d47e397cc8810827f9694f"
dependencies = [
"jobserver",
"libc",
@ -1708,9 +1708,9 @@ dependencies = [
[[package]]
name = "clap"
version = "4.5.13"
version = "4.5.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fbb260a053428790f3de475e304ff84cdbc4face759ea7a3e64c1edd938a7fc"
checksum = "35723e6a11662c2afb578bcf0b88bf6ea8e21282a953428f240574fcc3a2b5b3"
dependencies = [
"clap_builder",
"clap_derive",
@ -1718,9 +1718,9 @@ dependencies = [
[[package]]
name = "clap_builder"
version = "4.5.13"
version = "4.5.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "64b17d7ea74e9f833c7dbf2cbe4fb12ff26783eda4782a8975b72f895c9b4d99"
checksum = "49eb96cbfa7cfa35017b7cd548c75b14c3118c98b423041d70562665e07fb0fa"
dependencies = [
"anstream",
"anstyle",
@ -1730,9 +1730,9 @@ dependencies = [
[[package]]
name = "clap_derive"
version = "4.5.13"
version = "4.5.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "501d359d5f3dcaf6ecdeee48833ae73ec6e42723a1e52419c79abf9507eec0a0"
checksum = "5d029b67f89d30bbb547c89fd5161293c0aec155fc691d7924b64550662db93e"
dependencies = [
"heck 0.5.0",
"proc-macro2",
@ -2667,9 +2667,9 @@ dependencies = [
[[package]]
name = "enumn"
version = "0.1.14"
version = "0.1.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2f9ed6b3789237c8a0c1c505af1c7eb2c560df6186f01b098c3a1064ea532f38"
checksum = "6fd000fd6988e73bbe993ea3db9b1aa64906ab88766d654973924340c8cddb42"
dependencies = [
"proc-macro2",
"quote",
@ -3406,7 +3406,7 @@ dependencies = [
"futures-core",
"futures-sink",
"http",
"indexmap 2.3.0",
"indexmap 2.2.6",
"slab",
"tokio",
"tokio-util",
@ -3984,9 +3984,9 @@ dependencies = [
[[package]]
name = "indexmap"
version = "2.3.0"
version = "2.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "de3fc2e30ba82dd1b3911c8de1ffc143c74a914a14e99514d7637e3099df5ea0"
checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26"
dependencies = [
"equivalent",
"hashbrown 0.14.5",
@ -4006,7 +4006,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7c77a3ae7d4761b9c64d2c030f70746ceb8cfba32dce0325a56792e0a4816c31"
dependencies = [
"ahash",
"indexmap 2.3.0",
"indexmap 2.2.6",
"is-terminal",
"itoa",
"log",
@ -4178,9 +4178,9 @@ dependencies = [
[[package]]
name = "jsonrpsee"
version = "0.24.1"
version = "0.24.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1568257acc17d60cd19c61b8e2b068f0d706399bbf9ebf8afdb08f7fe824721f"
checksum = "0a1d83ae9ed70d8e3440db663e343a82f93913104744cd543bbcdd1dbc0e35d3"
dependencies = [
"jsonrpsee-client-transport",
"jsonrpsee-core",
@ -4196,9 +4196,9 @@ dependencies = [
[[package]]
name = "jsonrpsee-client-transport"
version = "0.24.1"
version = "0.24.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37f545bed6cf5cea796c1ef50ccb87a8fa613f36f2141ec85c56f3eefc03ae55"
checksum = "5be764c8b96cdcd2974655560a1c6542a366440d47c88114894cc20c24317815"
dependencies = [
"base64 0.22.1",
"futures-channel",
@ -4221,9 +4221,9 @@ dependencies = [
[[package]]
name = "jsonrpsee-core"
version = "0.24.1"
version = "0.24.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6e188cdec4745cfb6174608f10c3d8c6ea57e986b636b0d6de53aafef29c7ea"
checksum = "83b772fb8aa2b511eeed75f7e19d8e5fa57be7e8202249470bf26210727399c7"
dependencies = [
"async-trait",
"bytes",
@ -4248,9 +4248,9 @@ dependencies = [
[[package]]
name = "jsonrpsee-http-client"
version = "0.24.1"
version = "0.24.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e39c8c20007a1fbcdcfb76d771257529f78e7eea81e9de03c52f870e7b13351e"
checksum = "4d5f8f6ddb09312a9592ec9e21a3ccd6f61e51730d9d56321351eff971b0fe55"
dependencies = [
"async-trait",
"base64 0.22.1",
@ -4273,9 +4273,9 @@ dependencies = [
[[package]]
name = "jsonrpsee-proc-macros"
version = "0.24.1"
version = "0.24.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e7cae5320ea42b1f35ff792413330e206146e9ecb9cb6e7ffe12e167bd169ca"
checksum = "295d9b81496d1bef5bd34066d83c984388b6acb97620f468817bf46f67a1e9ab"
dependencies = [
"heck 0.5.0",
"proc-macro-crate",
@ -4286,9 +4286,9 @@ dependencies = [
[[package]]
name = "jsonrpsee-server"
version = "0.24.1"
version = "0.24.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ff967386dfa9e89ea6de6ee75ee0e87ee28fbff896e0282f646f47ce158a3ae3"
checksum = "85bf179199ad809157ceaab653f71cdb67f55d9e0093a6907c5765414a6b3bbb"
dependencies = [
"futures-util",
"http",
@ -4313,9 +4313,9 @@ dependencies = [
[[package]]
name = "jsonrpsee-types"
version = "0.24.1"
version = "0.24.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af7d734a4b0ae276b1e9e31572ab1f0f92d55797f0ca6b661afdd2266dc12756"
checksum = "98deeee954567f75632fa40666ac93a66d4f9f4ed4ca15bd6b7ed0720b53e761"
dependencies = [
"http",
"serde",
@ -4325,9 +4325,9 @@ dependencies = [
[[package]]
name = "jsonrpsee-wasm-client"
version = "0.24.1"
version = "0.24.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a3db6294ef23107961daf31901331dd672875424500f1aa2a6292f09275125d5"
checksum = "4c8a01468705cf6d326b8ba9c035e71abf5cc5e10948ba46e8af151386878398"
dependencies = [
"jsonrpsee-client-transport",
"jsonrpsee-core",
@ -4336,9 +4336,9 @@ dependencies = [
[[package]]
name = "jsonrpsee-ws-client"
version = "0.24.1"
version = "0.24.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "be6085716aa39842013cd74e3fe67cda8d3f509cc3917609430c9c28c6016535"
checksum = "385cf0a6103a9f64987cdf0f7c9d0b08e1d7183dd952820beffb3676e7df7787"
dependencies = [
"http",
"jsonrpsee-client-transport",
@ -4693,9 +4693,9 @@ checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24"
[[package]]
name = "lru"
version = "0.12.4"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37ee39891760e7d94734f6f63fedc29a2e4a152f836120753a72503f09fcf904"
checksum = "d3262e75e648fce39813cb56ac41f3c3e3f65217ebf3844d818d1f9398cfb0dc"
dependencies = [
"hashbrown 0.14.5",
]
@ -4780,7 +4780,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4f0c8427b39666bf970460908b213ec09b3b350f20c0c2eabcbba51704a08e6"
dependencies = [
"base64 0.22.1",
"indexmap 2.3.0",
"indexmap 2.2.6",
"metrics",
"metrics-util",
"quanta",
@ -4812,7 +4812,7 @@ dependencies = [
"crossbeam-epoch",
"crossbeam-utils",
"hashbrown 0.14.5",
"indexmap 2.3.0",
"indexmap 2.2.6",
"metrics",
"num_cpus",
"ordered-float",
@ -5156,18 +5156,18 @@ dependencies = [
[[package]]
name = "num_enum"
version = "0.7.3"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4e613fc340b2220f734a8595782c551f1250e969d87d3be1ae0579e8d4065179"
checksum = "02339744ee7253741199f897151b38e72257d13802d4ee837285cc2990a90845"
dependencies = [
"num_enum_derive",
]
[[package]]
name = "num_enum_derive"
version = "0.7.3"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56"
checksum = "681030a937600a36906c185595136d26abfebb4aa9c65701cefcaf8578bb982b"
dependencies = [
"proc-macro-crate",
"proc-macro2",
@ -5268,9 +5268,9 @@ checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d"
[[package]]
name = "ordered-float"
version = "4.2.2"
version = "4.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4a91171844676f8c7990ce64959210cd2eaef32c2612c50f9fae9f8aaa6065a6"
checksum = "19ff2cf528c6c03d9ed653d6c4ce1dc0582dc4af309790ad92f07c1cd551b0be"
dependencies = [
"num-traits",
]
@ -5640,12 +5640,9 @@ dependencies = [
[[package]]
name = "ppv-lite86"
version = "0.2.18"
version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dee4364d9f3b902ef14fab8a1ddffb783a1cb6b4bba3bfc1fa3922732c7de97f"
dependencies = [
"zerocopy 0.6.6",
]
checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
[[package]]
name = "predicates"
@ -7021,6 +7018,7 @@ dependencies = [
"reth-tasks",
"reth-tracing",
"reth-trie",
"thiserror",
"tokio",
"tracing",
]
@ -7426,7 +7424,7 @@ dependencies = [
"criterion",
"dashmap 6.0.1",
"derive_more",
"indexmap 2.3.0",
"indexmap 2.2.6",
"parking_lot 0.12.3",
"pprof",
"rand 0.8.5",
@ -9208,9 +9206,9 @@ checksum = "976295e77ce332211c0d24d92c0e83e50f5c5f046d11082cea19f3df13a3562d"
[[package]]
name = "rustls-platform-verifier"
version = "0.3.3"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "93bda3f493b9abe5b93b3e7e3ecde0df292f2bd28c0296b90586ee0055ff5123"
checksum = "3e3beb939bcd33c269f4bf946cc829fcd336370267c4a927ac0399c84a3151a1"
dependencies = [
"core-foundation",
"core-foundation-sys",
@ -9229,9 +9227,9 @@ dependencies = [
[[package]]
name = "rustls-platform-verifier-android"
version = "0.1.1"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f87165f0995f63a9fbeea62b64d10b4d9d8e78ec6d7d51fb2125fda7bb36788f"
checksum = "84e217e7fdc8466b5b35d30f8c0a30febd29173df4a3a0c2115d306b9c4117ad"
[[package]]
name = "rustls-webpki"
@ -9296,9 +9294,9 @@ dependencies = [
[[package]]
name = "scc"
version = "2.1.6"
version = "2.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05ccfb12511cdb770157ace92d7dda771e498445b78f9886e8cdbc5140a4eced"
checksum = "1fadf67e3cf23f8b11a6c8c48a16cb2437381503615acd91094ec7b4686a5a53"
dependencies = [
"sdd",
]
@ -9331,9 +9329,9 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
[[package]]
name = "sdd"
version = "2.1.0"
version = "1.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "177258b64c0faaa9ffd3c65cd3262c2bc7e2588dbbd9c1641d0346145c1bbda8"
checksum = "85f05a494052771fc5bd0619742363b5e24e5ad72ab3111ec2e27925b8edc5f3"
[[package]]
name = "sec1"
@ -9463,13 +9461,12 @@ dependencies = [
[[package]]
name = "serde_json"
version = "1.0.121"
version = "1.0.120"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ab380d7d9f22ef3f21ad3e6c1ebe8e4fc7a2000ccba2e4d71fc96f15b2cb609"
checksum = "4e0d21c9a8cae1235ad58a00c11cb40d4b1e5c784f1ef2c537876ed6ffd8b7c5"
dependencies = [
"indexmap 2.3.0",
"indexmap 2.2.6",
"itoa",
"memchr",
"ryu",
"serde",
]
@ -9516,7 +9513,7 @@ dependencies = [
"chrono",
"hex",
"indexmap 1.9.3",
"indexmap 2.3.0",
"indexmap 2.2.6",
"serde",
"serde_derive",
"serde_json",
@ -9542,7 +9539,7 @@ version = "0.9.34+deprecated"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47"
dependencies = [
"indexmap 2.3.0",
"indexmap 2.2.6",
"itoa",
"ryu",
"serde",
@ -9665,9 +9662,9 @@ dependencies = [
[[package]]
name = "signal-hook-mio"
version = "0.2.4"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34db1a06d485c9142248b7a054f034b349b212551f3dfd19c94d45a754a217cd"
checksum = "29ad2e15f37ec9a6cc544097b78a1ec90001e9f71b81338ca39f430adaca99af"
dependencies = [
"libc",
"mio 0.8.11",
@ -10336,21 +10333,21 @@ dependencies = [
[[package]]
name = "toml"
version = "0.8.19"
version = "0.8.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e"
checksum = "81967dd0dd2c1ab0bc3468bd7caecc32b8a4aa47d0c8c695d8c2b2108168d62c"
dependencies = [
"serde",
"serde_spanned",
"toml_datetime",
"toml_edit 0.22.20",
"toml_edit 0.22.17",
]
[[package]]
name = "toml_datetime"
version = "0.6.8"
version = "0.6.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41"
checksum = "f8fb9f64314842840f1d940ac544da178732128f1c78c21772e876579e0da1db"
dependencies = [
"serde",
]
@ -10361,22 +10358,22 @@ version = "0.21.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1"
dependencies = [
"indexmap 2.3.0",
"indexmap 2.2.6",
"toml_datetime",
"winnow 0.5.40",
]
[[package]]
name = "toml_edit"
version = "0.22.20"
version = "0.22.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d"
checksum = "8d9f8729f5aea9562aac1cc0441f5d6de3cff1ee0c5d67293eeca5eb36ee7c16"
dependencies = [
"indexmap 2.3.0",
"indexmap 2.2.6",
"serde",
"serde_spanned",
"toml_datetime",
"winnow 0.6.18",
"winnow 0.6.16",
]
[[package]]
@ -10627,9 +10624,9 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"
[[package]]
name = "trybuild"
version = "1.0.99"
version = "1.0.97"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "207aa50d36c4be8d8c6ea829478be44a372c6a77669937bb39c698e52f1491e8"
checksum = "5b1e5645f2ee8025c2f1d75e1138f2dd034d74e6ba54620f3c569ba2a2a1ea06"
dependencies = [
"glob",
"serde",
@ -11273,9 +11270,9 @@ dependencies = [
[[package]]
name = "winnow"
version = "0.6.18"
version = "0.6.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68a9bda4691f099d435ad181000724da8e5899daa10713c2d432552b9ccd3a6f"
checksum = "b480ae9340fc261e6be3e95a1ba86d54ae3f9171132a73ce8d4bbaf68339507c"
dependencies = [
"memchr",
]
@ -11373,34 +11370,13 @@ dependencies = [
"synstructure",
]
[[package]]
name = "zerocopy"
version = "0.6.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "854e949ac82d619ee9a14c66a1b674ac730422372ccb759ce0c39cabcf2bf8e6"
dependencies = [
"byteorder",
"zerocopy-derive 0.6.6",
]
[[package]]
name = "zerocopy"
version = "0.7.35"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0"
dependencies = [
"zerocopy-derive 0.7.35",
]
[[package]]
name = "zerocopy-derive"
version = "0.6.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "125139de3f6b9d625c39e2efdd73d41bdac468ccd556556440e322be0e1bbd91"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.72",
"zerocopy-derive",
]
[[package]]

View File

@ -38,6 +38,7 @@ reth-trie.workspace = true
# common
futures.workspace = true
tokio = { workspace = true, features = ["macros", "sync"] }
thiserror.workspace = true
# metrics
metrics.workspace = true

View File

@ -2,13 +2,15 @@
use reth_chain_state::ExecutedBlock;
use reth_db::Database;
use reth_errors::ProviderError;
use reth_primitives::{SealedBlock, B256};
use reth_provider::{writer::UnifiedStorageWriter, ProviderFactory, StaticFileProviderFactory};
use reth_prune::{Pruner, PrunerOutput};
use reth_prune::{Pruner, PrunerError, PrunerOutput};
use std::sync::{
mpsc::{Receiver, SendError, Sender},
Arc,
};
use thiserror::Error;
use tokio::sync::oneshot;
use tracing::debug;
@ -41,10 +43,10 @@ impl<DB: Database> PersistenceService<DB> {
/// Prunes block data before the given block hash according to the configured prune
/// configuration.
fn prune_before(&mut self, block_num: u64) -> PrunerOutput {
fn prune_before(&mut self, block_num: u64) -> Result<PrunerOutput, PrunerError> {
debug!(target: "tree::persistence", ?block_num, "Running pruner");
// TODO: doing this properly depends on pruner segment changes
self.pruner.run(block_num).expect("todo: handle errors")
self.pruner.run(block_num)
}
}
@ -54,43 +56,41 @@ where
{
/// This is the main loop, that will listen to database events and perform the requested
/// database actions
pub fn run(mut self) {
pub fn run(mut self) -> Result<(), PersistenceError> {
// If the receiver errors then senders have disconnected, so the loop should then end.
while let Ok(action) = self.incoming.recv() {
match action {
PersistenceAction::RemoveBlocksAbove((new_tip_num, sender)) => {
let provider_rw = self.provider.provider_rw().expect("todo: handle errors");
let provider_rw = self.provider.provider_rw()?;
let sf_provider = self.provider.static_file_provider();
UnifiedStorageWriter::from(&provider_rw, &sf_provider)
.remove_blocks_above(new_tip_num)
.expect("todo: handle errors");
UnifiedStorageWriter::commit_unwind(provider_rw, sf_provider)
.expect("todo: handle errors");
.remove_blocks_above(new_tip_num)?;
UnifiedStorageWriter::commit_unwind(provider_rw, sf_provider)?;
// we ignore the error because the caller may or may not care about the result
let _ = sender.send(());
}
PersistenceAction::SaveBlocks((blocks, sender)) => {
if blocks.is_empty() {
todo!("return error or something");
}
let last_block_hash = blocks.last().unwrap().block().hash();
let Some(last_block) = blocks.last() else {
let _ = sender.send(None);
continue
};
let provider_rw = self.provider.provider_rw().expect("todo: handle errors");
let last_block_hash = last_block.block().hash();
let provider_rw = self.provider.provider_rw()?;
let static_file_provider = self.provider.static_file_provider();
UnifiedStorageWriter::from(&provider_rw, &static_file_provider)
.save_blocks(&blocks)
.expect("todo: handle errors");
UnifiedStorageWriter::commit(provider_rw, static_file_provider)
.expect("todo: handle errors");
.save_blocks(&blocks)?;
UnifiedStorageWriter::commit(provider_rw, static_file_provider)?;
// we ignore the error because the caller may or may not care about the result
let _ = sender.send(last_block_hash);
let _ = sender.send(Some(last_block_hash));
}
PersistenceAction::PruneBefore((block_num, sender)) => {
let res = self.prune_before(block_num);
let res = self.prune_before(block_num)?;
// we ignore the error because the caller may or may not care about the result
let _ = sender.send(res);
@ -106,9 +106,22 @@ where
}
}
}
Ok(())
}
}
/// One of the errors that can happen when using the persistence service.
#[derive(Debug, Error)]
pub enum PersistenceError {
/// A pruner error
#[error(transparent)]
PrunerError(#[from] PrunerError),
/// A provider error
#[error(transparent)]
ProviderError(#[from] ProviderError),
}
/// A signal to the persistence service that part of the tree state can be persisted.
#[derive(Debug)]
pub enum PersistenceAction {
@ -117,7 +130,7 @@ pub enum PersistenceAction {
///
/// First, header, transaction, and receipt-related data should be written to static files.
/// Then the execution history-related data will be written to the database.
SaveBlocks((Vec<ExecutedBlock>, oneshot::Sender<B256>)),
SaveBlocks((Vec<ExecutedBlock>, oneshot::Sender<Option<B256>>)),
/// The given block has been added to the canonical chain, its transactions and headers will be
/// persisted for durability.
@ -186,31 +199,38 @@ impl PersistenceHandle {
/// This returns the latest hash that has been saved, allowing removal of that block and any
/// previous blocks from in-memory data structures. This value is returned in the receiver end
/// of the sender argument.
pub fn save_blocks(&self, blocks: Vec<ExecutedBlock>, tx: oneshot::Sender<B256>) {
if blocks.is_empty() {
let _ = tx.send(B256::default());
return;
}
///
/// If there are no blocks to persist, then `None` is sent in the sender.
pub fn save_blocks(
&self,
blocks: Vec<ExecutedBlock>,
tx: oneshot::Sender<Option<B256>>,
) -> Result<(), SendError<PersistenceAction>> {
self.send_action(PersistenceAction::SaveBlocks((blocks, tx)))
.expect("should be able to send");
}
/// Tells the persistence service to remove blocks above a certain block number. The removed
/// blocks are returned by the service.
pub async fn remove_blocks_above(&self, block_num: u64) {
let (tx, rx) = oneshot::channel();
///
/// When the operation completes, `()` is returned in the receiver end of the sender argument.
pub fn remove_blocks_above(
&self,
block_num: u64,
tx: oneshot::Sender<()>,
) -> Result<(), SendError<PersistenceAction>> {
self.send_action(PersistenceAction::RemoveBlocksAbove((block_num, tx)))
.expect("should be able to send");
rx.await.expect("todo: err handling")
}
/// Tells the persistence service to remove block data before the given hash, according to the
/// configured prune config.
pub async fn prune_before(&self, block_num: u64) -> PrunerOutput {
let (tx, rx) = oneshot::channel();
///
/// The resulting [`PrunerOutput`] is returned in the receiver end of the sender argument.
pub fn prune_before(
&self,
block_num: u64,
tx: oneshot::Sender<PrunerOutput>,
) -> Result<(), SendError<PersistenceAction>> {
self.send_action(PersistenceAction::PruneBefore((block_num, tx)))
.expect("should be able to send");
rx.await.expect("todo: err handling")
}
}
@ -249,10 +269,10 @@ mod tests {
let blocks = vec![];
let (tx, rx) = oneshot::channel();
persistence_handle.save_blocks(blocks, tx);
persistence_handle.save_blocks(blocks, tx).unwrap();
let hash = rx.await.unwrap();
assert_eq!(hash, B256::default());
assert_eq!(hash, None);
}
#[tokio::test]
@ -268,9 +288,9 @@ mod tests {
let blocks = vec![executed];
let (tx, rx) = oneshot::channel();
persistence_handle.save_blocks(blocks, tx);
persistence_handle.save_blocks(blocks, tx).unwrap();
let actual_hash = rx.await.unwrap();
let actual_hash = rx.await.unwrap().unwrap();
assert_eq!(block_hash, actual_hash);
}
@ -284,9 +304,9 @@ mod tests {
let last_hash = blocks.last().unwrap().block().hash();
let (tx, rx) = oneshot::channel();
persistence_handle.save_blocks(blocks, tx);
persistence_handle.save_blocks(blocks, tx).unwrap();
let actual_hash = rx.await.unwrap();
let actual_hash = rx.await.unwrap().unwrap();
assert_eq!(last_hash, actual_hash);
}
@ -302,9 +322,9 @@ mod tests {
let last_hash = blocks.last().unwrap().block().hash();
let (tx, rx) = oneshot::channel();
persistence_handle.save_blocks(blocks, tx);
persistence_handle.save_blocks(blocks, tx).unwrap();
let actual_hash = rx.await.unwrap();
let actual_hash = rx.await.unwrap().unwrap();
assert_eq!(last_hash, actual_hash);
}
}

View File

@ -551,7 +551,7 @@ where
let blocks_to_persist = self.get_canonical_blocks_to_persist();
if !blocks_to_persist.is_empty() {
let (tx, rx) = oneshot::channel();
self.persistence.save_blocks(blocks_to_persist, tx);
let _ = self.persistence.save_blocks(blocks_to_persist, tx);
self.persistence_state.start(rx);
} else {
debug!(target: "engine", "Returned empty set of blocks to persist");
@ -568,6 +568,12 @@ where
// Check if persistence has completed
match rx.try_recv() {
Ok(last_persisted_block_hash) => {
let Some(last_persisted_block_hash) = last_persisted_block_hash else {
// if this happened, then we persisted no blocks because we sent an empty
// vec of blocks
warn!(target: "engine", "Persistence task completed but did not persist any blocks");
return
};
if let Some(block) =
self.state.tree_state.block_by_hash(last_persisted_block_hash)
{
@ -1845,7 +1851,7 @@ pub struct PersistenceState {
last_persisted_block_hash: B256,
/// Receiver end of channel where the result of the persistence task will be
/// sent when done. A None value means there's no persistence task in progress.
rx: Option<oneshot::Receiver<B256>>,
rx: Option<oneshot::Receiver<Option<B256>>>,
/// The last persisted block number.
///
/// This tracks the chain height that is persisted on disk
@ -1860,7 +1866,7 @@ impl PersistenceState {
}
/// Sets state for a started persistence task.
fn start(&mut self, rx: oneshot::Receiver<B256>) {
fn start(&mut self, rx: oneshot::Receiver<Option<B256>>) {
self.rx = Some(rx);
}