Skip to content

Commit 873900d

Browse files
authored
Problem: recent fixdata fixes are not included (#1749)
* Problem: miss diff info when assert from test utils (#1745) * Problem: miss diff info when assert from test utils * align rootdir * fix upload * Problem: batch initialization when fixdata with dry-run is unnecessary (#1747) * Problem: need batch initialization run fixdata with dry-run * mod tidy * skip flush * Problem: need run fixdata multiple times when no timestamp checking query with GetCFWithTS to compare both timestamp and key
1 parent 24a0fcf commit 873900d

File tree

8 files changed

+29
-12
lines changed

8 files changed

+29
-12
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ jobs:
6565
if: steps.changed-files.outputs.only_changed == 'false'
6666
run: |
6767
nix profile install ./nix#go_1_22
68-
go tool covdata textfmt -i=integration_tests/coverage -o profile.txt
68+
go tool covdata textfmt -i=coverage -o profile.txt
6969
- name: Upload coverage report
7070
if: steps.changed-files.outputs.only_changed == 'false'
7171
uses: codecov/codecov-action@v4

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Changelog
22

3+
## UNRELEASED
4+
5+
### Bug Fixes
6+
7+
* [#1748](https://github.com/crypto-org-chain/cronos/pull/1748) Query with GetCFWithTS to compare both timestamp and key to avoid run fixdata multiple times.
8+
9+
### Improvements
10+
11+
* [#1747](https://github.com/crypto-org-chain/cronos/pull/1747) Skip batch initialization and flush when fixdata with dry-run.
12+
313
*Feb 3, 2025*
414

515
## v1.4.3
@@ -31,6 +41,7 @@
3141
### Improvements
3242

3343
* [#1712](https://github.com/crypto-org-chain/cronos/pull/1712) Upgrade rocksdb to `v9.8.4`.
44+
* [#1747](https://github.com/crypto-org-chain/cronos/pull/1747) Skip batch initialization and flush when fixdata with dry-run.
3445

3546
*Dec 2, 2024*
3647

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ TESTS_TO_RUN ?= all
240240

241241
run-integration-tests:
242242
@make gen-bindings-contracts
243-
@nix-shell ./integration_tests/shell.nix --run ./scripts/run-integration-tests
243+
@./scripts/run-integration-tests
244244

245245
.PHONY: run-integration-tests
246246

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ require (
5656
cloud.google.com/go/storage v1.41.0 // indirect
5757
cosmossdk.io/collections v0.4.0 // indirect
5858
cosmossdk.io/depinject v1.0.0 // indirect
59-
cosmossdk.io/x/tx v0.13.6-0.20241003112805-ff8789a02871 // indirect
59+
cosmossdk.io/x/tx v0.13.7 // indirect
6060
filippo.io/edwards25519 v1.1.0 // indirect
6161
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
6262
github.com/DataDog/datadog-go v4.8.3+incompatible // indirect

gomod2nix.toml

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

integration_tests/pytest.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
[pytest]
22
addopts = --ignore=contracts
3+
python_files = integration_tests/*.py

scripts/run-integration-tests

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ echo "build test contracts"
99
cd ../integration_tests/contracts
1010
HUSKY_SKIP_INSTALL=1 npm install
1111
npm run typechain
12-
cd ..
12+
cd ../..
1313
TESTS_TO_RUN="${TESTS_TO_RUN:-all}"
1414
if [[ "$TESTS_TO_RUN" == "all" ]]; then
1515
echo "run all tests"
@@ -18,4 +18,4 @@ else
1818
echo "run tests matching $TESTS_TO_RUN"
1919
cmd="pytest -vv -s --session-timeout=1800 --timeout=1800 -m '$TESTS_TO_RUN'"
2020
fi
21-
nix-shell --run "$cmd"
21+
nix-shell ./integration_tests/shell.nix --run "$cmd"

versiondb/tsrocksdb/store.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,9 @@ func (s Store) FixData(storeNames []string, dryRun bool) error {
241241
return err
242242
}
243243
}
244-
244+
if dryRun {
245+
return nil
246+
}
245247
return s.Flush()
246248
}
247249

@@ -252,8 +254,11 @@ func (s Store) fixDataStore(storeName string, dryRun bool) error {
252254
return err
253255
}
254256

255-
batch := grocksdb.NewWriteBatch()
256-
defer batch.Destroy()
257+
var batch *grocksdb.WriteBatch
258+
if !dryRun {
259+
batch = grocksdb.NewWriteBatch()
260+
defer batch.Destroy()
261+
}
257262

258263
prefix := storePrefix(storeName)
259264
readOpts := grocksdb.NewDefaultReadOptions()
@@ -262,14 +267,14 @@ func (s Store) fixDataStore(storeName string, dryRun bool) error {
262267
realKey := cloneAppend(prefix, pair.Key)
263268

264269
readOpts.SetTimestamp(pair.Timestamp)
265-
oldValue, err := s.db.GetCF(readOpts, s.cfHandle, realKey)
270+
oldValue, oldTimestamp, err := s.db.GetCFWithTS(readOpts, s.cfHandle, realKey)
266271
if err != nil {
267272
return err
268273
}
269274

270-
clean := bytes.Equal(oldValue.Data(), pair.Value)
275+
clean := bytes.Equal(oldValue.Data(), pair.Value) && bytes.Equal(oldTimestamp.Data(), pair.Timestamp)
271276
oldValue.Free()
272-
277+
oldTimestamp.Free()
273278
if clean {
274279
continue
275280
}

0 commit comments

Comments
 (0)