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

feat(types): Deprecate the DBBackend variable in favor of new app-db-backend config entry #11188

Merged
merged 50 commits into from
Mar 18, 2022

Conversation

dwedul-figure
Copy link
Collaborator

@dwedul-figure dwedul-figure commented Feb 14, 2022

Description

Closes: #10948

This PR deprecates the types.DBBackend variable and types.NewLevelDB function. It replaces them with a new app.toml config entry: app-db-backend and the dbm.NewDB function from github.com/tendermint/tm-db. Uses of NewLevelDB were replaced with calls to NewDB and the db backend value comes from the tendermint config db-backend entry. The simapp stuff doesn't have the tendermint or app configs, so a DBBackend sim config field and db-backend flag was added in order to know the db backend value to use for them.


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change N/A
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules N/A
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification N/A
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

server/mock/app.go Outdated Show resolved Hide resolved
@dwedul-figure dwedul-figure changed the title Dwedul/10948 remove dbbackend var feat:Dwedul/10948 remove dbbackend var Feb 14, 2022
CHANGELOG.md Outdated Show resolved Hide resolved
@dwedul-figure dwedul-figure changed the title feat:Dwedul/10948 remove dbbackend var feat(types): Deprecate the DBBackend variable in favor of the Tendermint Config's db-backend value. Feb 14, 2022
Copy link
Member

@tac0turtle tac0turtle left a comment

Choose a reason for hiding this comment

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

love this cleanup, in the future we should migrate off of tendermints config since the supported data bases may diverge.

@dwedul-figure dwedul-figure changed the title feat(types): Deprecate the DBBackend variable in favor of the Tendermint Config's db-backend value. feat(types): Deprecate the DBBackend variable in favor of new app-db-backend config entry Mar 2, 2022
@github-actions github-actions bot removed the T: CI label Mar 2, 2022
@github-actions github-actions bot added the T: CI label Mar 2, 2022
@amaury1093
Copy link
Contributor

@alexanderbez and @robert-zaremba do you think you'll be able to have another look at this?

@robert-zaremba robert-zaremba modified the milestones: v0.44.6, v0.46 Mar 17, 2022
@robert-zaremba robert-zaremba mentioned this pull request Mar 17, 2022
56 tasks
Copy link
Collaborator

@robert-zaremba robert-zaremba left a comment

Choose a reason for hiding this comment

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

lgtm

@robert-zaremba robert-zaremba mentioned this pull request Mar 18, 2022
4 tasks
@robert-zaremba robert-zaremba merged commit 16e5d1a into master Mar 18, 2022
@robert-zaremba robert-zaremba deleted the dwedul/10948-remove-dbbackend-var branch March 18, 2022 09:26
Comment on lines +20 to +22
- uses: actions/setup-go@v3
with:
go-version: 1.17

Choose a reason for hiding this comment

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

This duplicates the actions/setup-go@v3 step below?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yup. I'd guess it was a bad merge on my part (added both by me in my branch and then later in main).

I created #11420 to remove one of the entries.

@08d2
Copy link
Contributor

08d2 commented Jul 21, 2022

Iteration over a map in golang is nondeterministic

Of course. Maps are, by definition, un-ordered. This is fundamental knowledge.

That check exists as a direct result of such problems; it isn't nonsense.

Any code which relies on deterministic ordering of map iteration is buggy, absolutely. That doesn't mean it's appropriate to prevent map iteration altogether. It would be like preventing the use of negative indices in slice expressions, because that can produce out-of-bounds errors. Or preventing dereferencing of pointers, because that can produce nil pointer exceptions. The cure, here, is worse than the disease.

larry0x pushed a commit to larry0x/cosmos-sdk that referenced this pull request May 22, 2023
…backend config entry (cosmos#11188)

* [10948]: Add changelog entry.

* [10948]: Deprecate the types.DBBackend variable and the NewLevelDB function. Create a NewDB function to replace them.

* [10948]: Add a DBBackend string to the simulation config and a flag for setting it. Update the simulation setup to use that instead of the compile-time DBBackend variable.

* [10948]: Update the mock app creator to use the NewDB function. Not sure what to do about the db backend in that case though.

* [10948]: Update changelog to reflect new db-backend field name.

* [10948]: Use the tendermint db-backend type for the snapshot db.

* [10948]: Update the last use of NewLevelDB by adding a parameter to openDB and uppdating calls to that to provide the db type to use.

* [10948]: Upddate the NewDB function to also have a default db backend type if an empty string is provided there.

* [10948]: Remove the new TODO in mock.NewApp. After looking through it's uses, there doesn't seem to be any desire to change it, and there's no easy way to communicate it.

* [10948]: Enhance the NewDB defer function to also add info to any err that is being returned.

* [10948]: Add some unit tests for NewDB.

* [10948]: Lint fixes.

* [10948]: Add a changelog entry to the deprecated section.

* [10948]: Update the makefile to no longer set the types.DBBackend value.

* [10948]: Use memdb for the mock app instead of goleveldb. I know it was a goleveldb before, but for a mock app, a memdb feels like a better choice (assuming 'mock' and 'mem' mean what I assume they mean).

* [10948]: Fix the store benchmark tests (had some index-out-of-range issues).

* [10948]: Fix cachekv store bench test calling iter.Key() before checking iter.Valid().

* [10948]: Remove the panic recovery from types.NewDB since dbm.NewDB returns an error now (it didn't originally, when NewLevelDB was first written).

* [10948]: Add changlog entry indicationg an API breaking change due to the DBBackend change.

* [10948]: Get rid of the types.NewDB function in favor of just using the tm-db version of it.

* [10948]: Fix Update the codeql-analysis github action to use go v1.17.

* [10948]: Add config file option for the app db backend type.

* [10948]: Adjust the comment on the app-db-backend config entry to clarify fallback behavior.

* [10948]: Add a default of GoLevelDBBackend to GetAppDBBackend. The old DBBackend variable defaulted to that, and some unit tests assume that behavior still exists.

* [10948]: Add the missing quotes around the app-db-backend value.

* [10948]: Small tweak to the changelog's deprecated entry.

* Add the go version declaration back into the codeql-analysis github action.

* [10948]: Update new use of openDB.

* [10948]: Put a brief delay after closing the test network. Hopefully that helps with address-in-use and non-empty directory errors.

Co-authored-by: Marko <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Use Tendermint db-backend config value instead of compile-time DBBackend value
7 participants