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: ADR-040: Implement RocksDB backend #9851

Merged
merged 19 commits into from
Oct 5, 2021

Conversation

roysc
Copy link
Contributor

@roysc roysc commented Aug 4, 2021

Description

Partially resolves: vulcanize#14

Implements a RocksDB-based backend for the DB interface introduced by #9573 and specified by ADR-040.


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
  • 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
  • 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)

@roysc
Copy link
Contributor Author

roysc commented Aug 4, 2021

Depends on #9573, so this will be a draft until that is merged.

@robert-zaremba robert-zaremba mentioned this pull request Aug 6, 2021
38 tasks
@roysc roysc marked this pull request as ready for review August 10, 2021 13:43
@roysc roysc force-pushed the roysc/adr-040-db-rocks branch 2 times, most recently from 7c37ce1 to 77f5053 Compare August 23, 2021 05:06
@roysc roysc force-pushed the roysc/adr-040-db-rocks branch from e5985c5 to 3b1df92 Compare August 31, 2021 10:39
@roysc
Copy link
Contributor Author

roysc commented Aug 31, 2021

Rebased and ready for review

Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

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

Nice work :)

db/go.mod Outdated Show resolved Hide resolved
go.mod Show resolved Hide resolved
db/rocksdb/db.go Outdated Show resolved Hide resolved
db/rocksdb/db.go Outdated Show resolved Hide resolved
db/rocksdb/db.go Outdated Show resolved Hide resolved
db/rocksdb/iterator.go Outdated Show resolved Hide resolved
db/rocksdb/iterator.go Show resolved Hide resolved
db/rocksdb/iterator.go Outdated Show resolved Hide resolved
db/rocksdb/iterator.go Outdated Show resolved Hide resolved
db/go.mod Outdated
)

replace github.com/tecbot/gorocksdb => github.com/roysc/gorocksdb v1.1.0 // v0.0.0-20210804143633-c0bf0b3635e5 // FIXME
Copy link
Member

Choose a reason for hiding this comment

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

would be good to add more context to the FIXME for the next person

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I had hoped there might be movement on their upstream repo before this was to be merged. That seems unlikely now.

Would it be better to have this point to a cosmos/gorocksdb fork before merging?

Copy link
Member

Choose a reason for hiding this comment

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

if you dont want to maintain it, this would be the best solution. @alexanderbez what you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean I honestly don't see us maintaining it -- they would diverge quickly I imagine. I'm actually concerned that it's not merged into the main upstream repo. Is there a reason for that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems to just be neglected, there's been no activity for almost two years. The PR adds some some simple bindings. I don't really mind using my fork, just not sure what the preference is on your end.

Copy link
Contributor

Choose a reason for hiding this comment

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

TBH, if a db backend has been neglected for that long, I'm very very apprehensive about supporting it. We can totally not support RocksDB.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just to be clear, this is an unofficial Go wrapper I'm talking about. The Rocks maintainers were pretty efficient about merging my PR to add the needed C bindings.

Copy link
Member

Choose a reason for hiding this comment

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

I think its fine, our default db currently, leveldb, is not maintained as well. I would prefer we create a fork in cosmos and add a downstream pr opening bot if anything changes upstream.

Copy link
Contributor

@alexanderbez alexanderbez Sep 22, 2021

Choose a reason for hiding this comment

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

The Rocks maintainers were pretty efficient about merging my PR to add the needed C bindings.

Then we should go with this. I do not feel comfortable maintaining support for physical backends that are not actively maintained, even if they're just wrappers.

Copy link
Contributor Author

@roysc roysc Sep 22, 2021

Choose a reason for hiding this comment

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

RocksDB doesn't provide Go bindings. The tecbot repo is the main third-party solution: https://github.com/facebook/rocksdb/blob/main/LANGUAGE-BINDINGS.md.

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.

part 1 of the review

db/dbtest/testcases.go Outdated Show resolved Hide resolved
db/dbtest/testcases.go Outdated Show resolved Hide resolved
)
// FIXME: gorocksdb bindings for OptimisticTransactionDB are not merged upstream, so we use a fork
// See https://github.com/tecbot/gorocksdb/pull/216
replace github.com/tecbot/gorocksdb => github.com/roysc/gorocksdb v1.1.0
Copy link
Collaborator

Choose a reason for hiding this comment

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

let's fork it into cosmos/gorocsdb. We did the same with keyring. @okwme , could you fork github.com/tecbot/gorocksdb in to cosmos?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Will be solved here: #10263

db/rocksdb/batch.go Outdated Show resolved Hide resolved
db/rocksdb/batch.go Outdated Show resolved Hide resolved
db/rocksdb/db.go Show resolved Hide resolved
db/rocksdb/db.go Outdated Show resolved Hide resolved
db/rocksdb/db.go Show resolved Hide resolved
db/rocksdb/db.go Outdated Show resolved Hide resolved
db/rocksdb/db.go Outdated Show resolved Hide resolved
@roysc
Copy link
Contributor Author

roysc commented Sep 23, 2021

Updated per reviews and merged master

@robert-zaremba robert-zaremba added the A:automerge Automatically merge PR once all prerequisites pass. label Sep 29, 2021
@robert-zaremba
Copy link
Collaborator

@roysc - could you merge master in your branch? Then we will be able to merge this.

@roysc roysc force-pushed the roysc/adr-040-db-rocks branch from 64d657f to 9cbf319 Compare October 5, 2021 15:13
@codecov
Copy link

codecov bot commented Oct 5, 2021

Codecov Report

Merging #9851 (64d657f) into master (9094794) will decrease coverage by 0.41%.
The diff coverage is n/a.

❗ Current head 64d657f differs from pull request most recent head 97f0c90. Consider uploading reports for the commit 97f0c90 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master    #9851      +/-   ##
==========================================
- Coverage   64.15%   63.73%   -0.42%     
==========================================
  Files         572      572              
  Lines       53983    53966      -17     
==========================================
- Hits        34632    34397     -235     
- Misses      17375    17612     +237     
+ Partials     1976     1957      -19     
Impacted Files Coverage Δ
x/bank/types/events.go 0.00% <0.00%> (-75.00%) ⬇️
x/distribution/abci.go 0.00% <0.00%> (-68.75%) ⬇️
x/staking/types/genesis.go 26.08% <0.00%> (-30.44%) ⬇️
x/evidence/abci.go 0.00% <0.00%> (-30.00%) ⬇️
x/staking/keeper/pool.go 61.53% <0.00%> (-25.65%) ⬇️
x/staking/keeper/hooks.go 36.00% <0.00%> (-20.00%) ⬇️
x/distribution/keeper/invariants.go 55.65% <0.00%> (-20.00%) ⬇️
x/mint/keeper/keeper.go 60.00% <0.00%> (-17.78%) ⬇️
x/auth/genesis.go 30.43% <0.00%> (-17.40%) ⬇️
x/staking/keeper/alias_functions.go 16.12% <0.00%> (-16.13%) ⬇️
... and 49 more

@roysc
Copy link
Contributor Author

roysc commented Oct 5, 2021

This has been updated with a DBConnection.Revert method and implementation, to allow the DB to roll back committed data that is part of the unsaved working version - this will be needed for the KV store to commit atomically to its decoupled buckets. Please review the top commits (2) when you get a chance @alexanderbez @robert-zaremba.

Revert implementations for Badger and Memdb can be added to #9892 or another PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:automerge Automatically merge PR once all prerequisites pass. C:Store
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Task: BadgerDB & RocksDB backends for the new cosmos-db interface
4 participants