From fa8252e430cdb97ca279ff0102ebf178c3718d70 Mon Sep 17 00:00:00 2001 From: Nikolay Kurtov Date: Wed, 15 Mar 2023 12:47:20 +0100 Subject: [PATCH 1/2] fix: State Sync no longer corrupts the DB. If a node gets stopped during State Sync then it fails to start due to an `unwrap()` on `send_network_chain_info()`. The state of the DB itself is fine. This PR makes the node gracefully handle that scenario and State Sync can safely resume and complete. --- chain/client/src/client.rs | 2 +- chain/client/src/client_actor.rs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/chain/client/src/client.rs b/chain/client/src/client.rs index cd9373afe07..60abc3ef7bc 100644 --- a/chain/client/src/client.rs +++ b/chain/client/src/client.rs @@ -1454,7 +1454,7 @@ impl Client { // send_network_chain_info should be called whenever the chain head changes. // See send_network_chain_info() for more details. if let Err(err) = self.send_network_chain_info() { - error!(target:"client","Failed to update network chain info: {err}"); + error!(target: "client", ?err, "Failed to update network chain info"); } } diff --git a/chain/client/src/client_actor.rs b/chain/client/src/client_actor.rs index 382f1e5bc10..bc39e8fba1f 100644 --- a/chain/client/src/client_actor.rs +++ b/chain/client/src/client_actor.rs @@ -255,7 +255,9 @@ impl Actor for ClientActor { // Start catchup job. self.catchup(ctx); - self.client.send_network_chain_info().unwrap(); + if let Err(err) = self.client.send_network_chain_info() { + error!(target: "client", ?err, "Failed to update network chain info"); + } } } From 6ca775b1acbae88a765823c1ff733ad6a5e0c397 Mon Sep 17 00:00:00 2001 From: Nikolay Kurtov Date: Wed, 15 Mar 2023 12:54:48 +0100 Subject: [PATCH 2/2] Changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 044ca48c442..1818d922c64 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ * Experimental option to dump state of every epoch to external storage. [#8661](https://github.com/near/nearcore/pull/8661) * State-viewer tool to dump and apply state changes from/to a range of blocks [#8628](https://github.com/near/nearcore/pull/8628) +* Node can restart if State Sync gets interrupted [#8732](https://github.com/near/nearcore/pull/8732) ## 1.32.0