From e4eb72cef706795c37fabbbc9f4eb5d0ffa71d0f Mon Sep 17 00:00:00 2001 From: mmsqe Date: Mon, 5 May 2025 11:40:40 +0800 Subject: [PATCH 1/2] Problem: non-empty data from being cleared during restoration from versiondb --- CHANGELOG.md | 4 ++++ integration_tests/test_basic.py | 1 + versiondb/client/restore.go | 10 ++++++---- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 466b96afd7..66850fe396 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ * [#1779](https://github.com/crypto-org-chain/cronos/pull/1779) Upgrade rocksdb to `v9.11.2`. +### Bug Fixes + +* [#1801](https://github.com/crypto-org-chain/cronos/pull/1801) Avoid non-empty data from being cleared during restoration from versiondb. + *Apr 9, 2025* ## v1.4.6 diff --git a/integration_tests/test_basic.py b/integration_tests/test_basic.py index 7775a28e22..3f6b315c37 100644 --- a/integration_tests/test_basic.py +++ b/integration_tests/test_basic.py @@ -404,6 +404,7 @@ def test_local_statesync(cronos, tmp_path_factory): wait_for_new_blocks(cli, 2) # check grpc works print("distribution", cli.distribution_community(height=height)) + print("balances", cli.balances(ADDRS["validator"])) with pytest.raises(Exception) as exc_info: cli.distribution_community(height=height - 1) diff --git a/versiondb/client/restore.go b/versiondb/client/restore.go index 1572d49600..57d2ecbe51 100644 --- a/versiondb/client/restore.go +++ b/versiondb/client/restore.go @@ -107,10 +107,12 @@ loop: return fmt.Errorf("node height %v cannot exceed %v", item.IAVL.Height, math.MaxInt8) } - ch <- versiondb.ImportEntry{ - StoreKey: storeKey, - Key: item.IAVL.Key, - Value: item.IAVL.Value, + if len(item.IAVL.Value) > 0 { + ch <- versiondb.ImportEntry{ + StoreKey: storeKey, + Key: item.IAVL.Key, + Value: item.IAVL.Value, + } } default: break loop From a88e4a7c3951558ca06c189fa9e254819620463e Mon Sep 17 00:00:00 2001 From: mmsqe Date: Mon, 5 May 2025 11:54:51 +0800 Subject: [PATCH 2/2] fix test --- integration_tests/test_basic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration_tests/test_basic.py b/integration_tests/test_basic.py index 3f6b315c37..d618d7957c 100644 --- a/integration_tests/test_basic.py +++ b/integration_tests/test_basic.py @@ -404,7 +404,7 @@ def test_local_statesync(cronos, tmp_path_factory): wait_for_new_blocks(cli, 2) # check grpc works print("distribution", cli.distribution_community(height=height)) - print("balances", cli.balances(ADDRS["validator"])) + print("balances", cli.balances(cli0.address("validator"))) with pytest.raises(Exception) as exc_info: cli.distribution_community(height=height - 1)