Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
- name: Run build
run: ./scripts/release.sh
if: steps.changed-files.outputs.any_changed == 'true'
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: "cronosd-tarball-${{ matrix.os }}"
path: "*.tar.gz"
Expand Down Expand Up @@ -119,7 +119,7 @@ jobs:
set +e
(git diff --no-ext-diff --exit-code)
echo "name=changed::$?" >> $GITHUB_OUTPUT
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
if: steps.changes.outputs.changed == 1
with:
name: gomod2nix.toml
Expand Down Expand Up @@ -162,7 +162,7 @@ jobs:
set +e
(git diff --no-ext-diff --exit-code)
echo "name=changed::$?" >> $GITHUB_OUTPUT
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
if: steps.changes.outputs.changed == 1
with:
name: contracts_out
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/sims.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Github API Request
id: request
uses: octokit/request-action@v2.0.0
uses: octokit/request-action@main
if: github.event_name == 'issue_comment'
with:
route: ${{ github.event.issue.pull_request.url }}
Expand Down Expand Up @@ -120,7 +120,7 @@ jobs:
echo ${{ job.status }} > status_build.txt
- name: Upload file status_build.txt as an artifact
if: github.event_name == 'issue_comment'
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: pass_status_build
path: status_build.txt
Expand All @@ -146,7 +146,7 @@ jobs:
echo ${{ job.status }} > status_install.txt
- name: Upload file status_install.txt as an artifact
if: github.event_name == 'issue_comment'
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: pass_status_install
path: status_install.txt
Expand Down Expand Up @@ -202,7 +202,7 @@ jobs:
echo ${{ job.status }} > status_sim1.txt
- name: Upload file status_sim1.txt as an artifact
if: github.event_name == 'issue_comment'
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: pass_status_sim1
path: status_sim1.txt
Expand Down Expand Up @@ -258,7 +258,7 @@ jobs:
echo ${{ job.status }} > status_sim2.txt
- name: Upload file status_sim2.txt as an artifact
if: github.event_name == 'issue_comment'
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: pass_status_sim2
path: status_sim2.txt
Expand Down Expand Up @@ -314,7 +314,7 @@ jobs:
echo ${{ job.status }} > status_sim3.txt
- name: Upload file status_sim3.txt as an artifact
if: github.event_name == 'issue_comment'
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: pass_status_sim3
path: status_sim3.txt
Expand Down Expand Up @@ -370,7 +370,7 @@ jobs:
echo ${{ job.status }} > status_sim4.txt
- name: Upload file status_sim4.txt as an artifact
if: github.event_name == 'issue_comment'
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: pass_status_sim4
path: status_sim4.txt
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
- name: 'Tar debug files'
if: failure()
run: tar cfz debug_files.tar.gz -C "${TMPDIR-/tmp}/pytest-of-runner" .
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
if: failure()
with:
name: debug-files
Expand All @@ -66,7 +66,7 @@ jobs:
if: steps.changed-files.outputs.only_changed == 'false'
run: |
nix profile install ./nix#go_1_22
go tool covdata textfmt -i=integration_tests/coverage -o profile.txt
go tool covdata textfmt -i=coverage -o profile.txt
- name: Upload coverage report
if: steps.changed-files.outputs.only_changed == 'false'
uses: codecov/codecov-action@v4
Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Changelog

## UNRELEASED

### Bug Fixes

* [#1720](https://github.com/crypto-org-chain/cronos/pull/1720) Include the fix of performance regression after upgrade in iavl.
* [#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.
* (versiondb) [#1751](https://github.com/crypto-org-chain/cronos/pull/1751) Add missing Destroy for read options to properly hold and release options reference.

### Improvements

* [#1747](https://github.com/crypto-org-chain/cronos/pull/1747) Skip batch initialization and flush when fixdata with dry-run.

*Nov 13, 2024*

## v1.3.4
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ TESTS_TO_RUN ?= all

run-integration-tests:
@make gen-bindings-contracts
@nix-shell ./integration_tests/shell.nix --run ./scripts/run-integration-tests
@./scripts/run-integration-tests

.PHONY: run-integration-tests

Expand Down
5 changes: 5 additions & 0 deletions integration_tests/cosmoscli.py
Original file line number Diff line number Diff line change
Expand Up @@ -1804,6 +1804,11 @@ def restore_versiondb(self, height, format=3, **kwargs):
**kwargs,
)

def changeset_fixdata(self, versiondb_dir, dry_run=False):
return self.raw(
"changeset", "fixdata", versiondb_dir, "--dry-run" if dry_run else None
)

def dump_snapshot(self, height, tarball, format=3):
return self.raw(
"snapshots", "dump", height, format, home=self.data_dir, output=tarball
Expand Down
1 change: 1 addition & 0 deletions integration_tests/pytest.ini
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[pytest]
addopts = --ignore=contracts
python_files = integration_tests/*.py
8 changes: 8 additions & 0 deletions integration_tests/test_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import shutil
import stat
import subprocess
import time
from contextlib import contextmanager
from datetime import datetime, timedelta
from pathlib import Path
Expand Down Expand Up @@ -274,6 +275,13 @@ def do_upgrade(
do_upgrade("v1.3", target4, gas_prices=gas_prices)
cli = c.cosmos_cli()

c.supervisorctl("stop", "cronos_777-1-node0")
time.sleep(3)
cli.changeset_fixdata(f"{c.base_dir}/node0/data/versiondb")
assert not cli.changeset_fixdata(f"{c.base_dir}/node0/data/versiondb", dry_run=True)
c.supervisorctl("start", "cronos_777-1-node0")
wait_for_port(ports.evmrpc_port(c.base_port(0)))

# check basic tx works
wait_for_port(ports.evmrpc_port(c.base_port(0)))
receipt = send_transaction(
Expand Down
4 changes: 2 additions & 2 deletions scripts/run-integration-tests
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ echo "build test contracts"
cd ../integration_tests/contracts
HUSKY_SKIP_INSTALL=1 npm install
npm run typechain
cd ..
cd ../..
TESTS_TO_RUN="${TESTS_TO_RUN:-all}"
if [[ "$TESTS_TO_RUN" == "all" ]]; then
echo "run all tests"
Expand All @@ -18,4 +18,4 @@ else
echo "run tests matching $TESTS_TO_RUN"
cmd="pytest -vv -s -m '$TESTS_TO_RUN'"
fi
nix-shell --run "$cmd"
nix-shell ./integration_tests/shell.nix --run "$cmd"
29 changes: 17 additions & 12 deletions versiondb/tsrocksdb/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,10 @@
}

func (s Store) GetAtVersionSlice(storeKey string, key []byte, version *int64) (*grocksdb.Slice, error) {
readOpts := newTSReadOptions(version)
defer readOpts.Destroy()
value, ts, err := s.db.GetCFWithTS(
newTSReadOptions(version),
readOpts,
s.cfHandle,
prependStoreKey(storeKey, key),
)
Expand Down Expand Up @@ -164,7 +166,9 @@
prefix := storePrefix(storeKey)
start, end = iterateWithPrefix(prefix, start, end)

itr := s.db.NewIteratorCF(newTSReadOptions(version), s.cfHandle)
readOpts := newTSReadOptions(version)
defer readOpts.Destroy()
itr := s.db.NewIteratorCF(readOpts, s.cfHandle)
return newRocksDBIterator(itr, prefix, start, end, reverse, s.skipVersionZero), nil
}

Expand Down Expand Up @@ -241,12 +245,10 @@
return err
}
}

if !dryRun {
return s.Flush()
if dryRun {
return nil

Check warning on line 249 in versiondb/tsrocksdb/store.go

View check run for this annotation

Codecov / codecov/patch

versiondb/tsrocksdb/store.go#L249

Added line #L249 was not covered by tests
}

return nil
return s.Flush()
}

// fixDataStore iterate the wrong data at version 0, parse the timestamp from the key and write it again.
Expand All @@ -256,8 +258,11 @@
return err
}

batch := grocksdb.NewWriteBatch()
defer batch.Destroy()
var batch *grocksdb.WriteBatch
if !dryRun {
batch = grocksdb.NewWriteBatch()
defer batch.Destroy()
}

prefix := storePrefix(storeName)
readOpts := grocksdb.NewDefaultReadOptions()
Expand All @@ -266,14 +271,14 @@
realKey := cloneAppend(prefix, pair.Key)

readOpts.SetTimestamp(pair.Timestamp)
oldValue, err := s.db.GetCF(readOpts, s.cfHandle, realKey)
oldValue, oldTimestamp, err := s.db.GetCFWithTS(readOpts, s.cfHandle, realKey)
if err != nil {
return err
}

clean := bytes.Equal(oldValue.Data(), pair.Value)
clean := bytes.Equal(oldValue.Data(), pair.Value) && bytes.Equal(oldTimestamp.Data(), pair.Timestamp)
oldValue.Free()

oldTimestamp.Free()
if clean {
continue
}
Expand Down
Loading