From af0bd9c1da2d46a32e3aa8ef4a601096ee31775b Mon Sep 17 00:00:00 2001 From: mmsqe Date: Fri, 28 Jun 2024 16:25:47 +0800 Subject: [PATCH] Problem: memory leak in versiondb (backport: #1491) (#1493) * Problem: no free slice data in HasAtVersion * run test_tx_inclusion * less upgrade test --- CHANGELOG.md | 22 +++++++++++++++++-- .../configs/upgrade-test-package.nix | 5 +---- integration_tests/test_basic.py | 1 + integration_tests/test_upgrade.py | 5 ----- versiondb/tsrocksdb/store.go | 1 + 5 files changed, 23 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 947b6646be..88ba851cdf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,26 @@ ## UNRELEASED +### Improvements + +* (versiondb) [#1491](https://github.com/crypto-org-chain/cronos/pull/1491) Free slice data in HasAtVersion. + +*Jun 18, 2024* + +## v1.3.0-rc2 + +### Improvements + +* (rpc) [#1467](https://github.com/crypto-org-chain/cronos/pull/1467) Avoid unnecessary tx decode in tx listener. + +### Bug Fixes + +* [#1466](https://github.com/crypto-org-chain/cronos/pull/1466) Fix handling of pending transactions related APIs. + +*May 21, 2024* + +## v1.3.0-rc1 + ### State Machine Breaking * [#1407](https://github.com/crypto-org-chain/cronos/pull/1407) Add end-to-end encryption module. @@ -12,13 +32,11 @@ * (e2ee)[#1415](https://github.com/crypto-org-chain/cronos/pull/1415) Add batch keys query for e2ee module. * (e2ee)[#1421](https://github.com/crypto-org-chain/cronos/pull/1421) Validate e2ee key when register. * [#1437](https://github.com/crypto-org-chain/cronos/pull/1437) Update cometbft and cosmos-sdk dependencies. -* (rpc) [#1467](https://github.com/crypto-org-chain/cronos/pull/1467) Avoid unnecessary tx decode in tx listener. ### Bug Fixes * (rpc) [#1444](https://github.com/crypto-org-chain/cronos/pull/1444) Avoid nil pointer error when query blocks before feemarket module gets enabled. * [#1439](https://github.com/crypto-org-chain/cronos/pull/1439) Add back default prepare proposal logic. -* [#1466](https://github.com/crypto-org-chain/cronos/pull/1466) Fix handling of pending transactions related APIs. *May 3, 2024* diff --git a/integration_tests/configs/upgrade-test-package.nix b/integration_tests/configs/upgrade-test-package.nix index 912d546f67..e60cebd3c0 100644 --- a/integration_tests/configs/upgrade-test-package.nix +++ b/integration_tests/configs/upgrade-test-package.nix @@ -7,8 +7,6 @@ let shortRev = builtins.substring 0 7 rev; }; }).defaultNix; - # v0.6.10 - releasedGenesis = import (builtins.fetchTarball "https://github.com/crypto-org-chain/cronos/archive/v0.6.10.tar.gz") { }; # v0.7.0 released_0 = (fetchFlake "crypto-org-chain/cronos" "799ac47e293403bd57580d2ff96bb8d9851c3cde").default; # v0.8.0 @@ -20,8 +18,7 @@ let current = pkgs.callPackage ../../. { }; in pkgs.linkFarm "upgrade-test-package" [ - { name = "genesis"; path = releasedGenesis; } - { name = "v0.7.0"; path = released_0; } + { name = "genesis"; path = released_0; } { name = "v0.7.0-hotfix"; path = released_1; } { name = "v1.0.0"; path = released_2; } { name = "v1.1.0"; path = released_3; } diff --git a/integration_tests/test_basic.py b/integration_tests/test_basic.py index d558016bfa..0e6c3c71ac 100644 --- a/integration_tests/test_basic.py +++ b/integration_tests/test_basic.py @@ -868,6 +868,7 @@ def test_contract(cronos): origin_cmd = None +@pytest.mark.unmarked @pytest.mark.parametrize("max_gas_wanted", [80000000, 40000000, 25000000, 500000, None]) def test_tx_inclusion(cronos, max_gas_wanted): """ diff --git a/integration_tests/test_upgrade.py b/integration_tests/test_upgrade.py index 8be0eb1474..723dd88fd9 100644 --- a/integration_tests/test_upgrade.py +++ b/integration_tests/test_upgrade.py @@ -195,11 +195,6 @@ def do_upgrade( wait_for_block(c.cosmos_cli(), target + 2, timeout=480) wait_for_port(ports.rpc_port(c.base_port(0))) - target0 = cli.block_height() + 15 - print("upgrade v0.7.0 height", target0) - do_upgrade("v0.7.0", target0, "block", method="submit-proposal") - cli = c.cosmos_cli() - target1 = cli.block_height() + 15 print("upgrade v0.8.0 height", target1) gas_prices = "5000000000000basetcro" diff --git a/versiondb/tsrocksdb/store.go b/versiondb/tsrocksdb/store.go index be34c74632..7d4176c5d0 100644 --- a/versiondb/tsrocksdb/store.go +++ b/versiondb/tsrocksdb/store.go @@ -108,6 +108,7 @@ func (s Store) HasAtVersion(storeKey string, key []byte, version *int64) (bool, if err != nil { return false, err } + defer slice.Free() return slice.Exists(), nil }