Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tool to read tip of state db #3659

Merged
merged 2 commits into from
Oct 12, 2022
Merged

tool to read tip of state db #3659

merged 2 commits into from
Oct 12, 2022

Conversation

CoderZhi
Copy link
Collaborator

Create a tool to read tip of state db

Fixes #(issue)

Type of change

Please delete options that are not relevant.

  • [] Bug fix (non-breaking change which fixes an issue)
  • [] New feature (non-breaking change which adds functionality)
  • [] Code refactor or improvement
  • [] Breaking change (fix or feature that would cause a new or changed behavior of existing functionality)
  • [] This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • [] make test
  • [] fullsync
  • [] Other test (please specify)

Test Configuration:

  • Firmware version:
  • Hardware:
  • Toolchain:
  • SDK:

Checklist:

  • [] My code follows the style guidelines of this project
  • [] I have performed a self-review of my code
  • [] I have commented my code, particularly in hard-to-understand areas
  • [] I have made corresponding changes to the documentation
  • [] My changes generate no new warnings
  • [] I have added tests that prove my fix is effective or that my feature works
  • [] New and existing unit tests pass locally with my changes
  • [] Any dependent changes have been merged and published in downstream modules

@CoderZhi CoderZhi requested a review from a team as a code owner October 11, 2022 03:38
@codecov
Copy link

codecov bot commented Oct 11, 2022

Codecov Report

Merging #3659 (5afbd26) into master (e9732a1) will decrease coverage by 0.25%.
The diff coverage is 82.11%.

❗ Current head 5afbd26 differs from pull request most recent head a632409. Consider uploading reports for the commit a632409 to get more accurate results

@@            Coverage Diff             @@
##           master    #3659      +/-   ##
==========================================
- Coverage   74.95%   74.69%   -0.26%     
==========================================
  Files         269      266       -3     
  Lines       23819    23754      -65     
==========================================
- Hits        17854    17744     -110     
- Misses       5039     5083      +44     
- Partials      926      927       +1     
Impacted Files Coverage Δ
db/config.go 100.00% <ø> (ø)
db/trie/mptrie/node.go 100.00% <ø> (ø)
ioctl/newcmd/action/action.go 79.62% <ø> (+0.09%) ⬆️
ioctl/newcmd/node/nodedelegate.go 70.19% <0.00%> (-0.95%) ⬇️
ioctl/newcmd/node/nodeprobationlist.go 90.90% <0.00%> (-4.33%) ⬇️
action/protocol/execution/evm/evm.go 44.57% <26.66%> (-0.86%) ⬇️
db/trie/mptrie/hashnode.go 36.36% <41.17%> (-54.55%) ⬇️
db/trie/mptrie/merklepatriciatrie.go 78.73% <46.80%> (-12.70%) ⬇️
db/db_bolt.go 72.13% <50.00%> (-0.39%) ⬇️
db/trie/mptrie/leafiterator.go 62.06% <50.00%> (ø)
... and 20 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@millken
Copy link
Contributor

millken commented Oct 11, 2022

Don't do this, DB should be opened in read-only mode
https://github.com/etcd-io/bbolt/blob/fd5535f71f488dda0915f610b6ca8c77c9ca2c59/db.go#L223-L234

	// Lock file so that other processes using Bolt in read-write mode cannot
	// use the database  at the same time. This would cause corruption since
	// the two processes would write meta pages and free pages separately.
	// The database file is locked exclusively (only one process can grab the lock)
	// if !options.ReadOnly.
	// The database file is locked using the shared lock (more than one process may
	// hold a lock at the same time) otherwise (options.ReadOnly is set).

@sonarcloud
Copy link

sonarcloud bot commented Oct 11, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

if err != nil {
log.S().Panic("failed to new config.", zap.Error(err))
}
store, err := db.CreateKVStore(cfg.DB, cfg.Chain.TrieDBPath)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add new func db.CreateKVStoreWithOption, and use readonly option open the DB

@millken millken merged commit 1e18856 into master Oct 12, 2022
@millken millken deleted the readtip branch October 12, 2022 00:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants