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

Transient Stores and Store Refactor #1481

Merged
merged 1 commit into from
Jul 27, 2018
Merged

Conversation

mossid
Copy link
Contributor

@mossid mossid commented Jun 29, 2018

  • Updated all relevant documentation in docs
  • Updated all code comments where relevant
  • Wrote tests
  • Updated CHANGELOG.md
  • Updated Gaia/Examples
  • Squashed all commits, uses message "Merge pull request #XYZ: [title]" (coding standards)
  • Added appropriate labels to PR (ex. wip, ready-for-review, docs)

Closes: #1326

@mossid mossid added the wip label Jun 29, 2018
@mossid mossid requested a review from ebuchman as a code owner June 29, 2018 23:34
@mossid mossid force-pushed the joon/1326-transient-store branch from c6fb76e to b8660aa Compare June 30, 2018 00:07
@codecov
Copy link

codecov bot commented Jun 30, 2018

Codecov Report

Merging #1481 into develop will increase coverage by 0.02%.
The diff coverage is 75%.

@@             Coverage Diff             @@
##           develop    #1481      +/-   ##
===========================================
+ Coverage    63.42%   63.45%   +0.02%     
===========================================
  Files          117      118       +1     
  Lines         6940     6972      +32     
===========================================
+ Hits          4402     4424      +22     
- Misses        2283     2292       +9     
- Partials       255      256       +1

// Commits each store and returns a new commitInfo.
func commitStores(version int64, storeMap map[StoreKey]CommitStore) commitInfo {
storeInfos := make([]storeInfo, 0, len(storeMap))
storeInfos := make([]storeInfo, 0, len(storeMap)/2)
Copy link
Contributor

Choose a reason for hiding this comment

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

should be len(storeMap)/2*2

@mossid mossid force-pushed the joon/1326-transient-store branch from 224579d to bd0f7e2 Compare June 30, 2018 03:11
@mossid mossid force-pushed the joon/1326-transient-store branch from bd0f7e2 to c183fc9 Compare June 30, 2018 03:30
@mossid mossid force-pushed the joon/1326-transient-store branch from c183fc9 to daed85e Compare June 30, 2018 03:34
mossid added a commit that referenced this pull request Jun 30, 2018
move gasconfig to types, make GetKVStoreWithGas take GasConfig

fix lint

modify transientstore

in progress

add test for transientstore

fix errors

fix test

fix errors and lint

last fix
@mossid mossid force-pushed the joon/1326-transient-store branch from daed85e to e3de3e0 Compare July 3, 2018 00:47
@mossid mossid force-pushed the joon/1326-transient-store branch from e3de3e0 to 8f00ab4 Compare July 3, 2018 00:48
@mossid mossid force-pushed the joon/1326-transient-store branch from 8f00ab4 to 31786cc Compare July 3, 2018 01:05
mossid added a commit that referenced this pull request Jul 3, 2018
in progress

in progress

fix all keeper/handler/types, start working on test

finalize rebase

fixing clients

add linear_cli.go, refactor relayer cli

fix examples

add wire, msg naming format, fix examples

in progress

in progress

add client/store
@mossid mossid force-pushed the joon/1326-transient-store branch from 31786cc to 39509c7 Compare July 4, 2018 04:32
mossid added a commit that referenced this pull request Jul 4, 2018
move gasconfig to types, make GetKVStoreWithGas take GasConfig

fix lint

modify transientstore

in progress

add test for transientstore

fix errors

fix test

fix errors and lint

last fix

in progress

move transient to KVStore

fix syntax errors

finalize rebase

remove NewMemDBStoreAdapter for lint
@mossid mossid changed the base branch from develop to unstable July 4, 2018 04:32
@mossid mossid changed the title WIP: Transient Stores Transient Stores and Store Refactor Jul 4, 2018
@mossid
Copy link
Contributor Author

mossid commented Jul 4, 2018

In this PR every operation that is applied to a KVStore has become methods of KVStore, including Transient(), Gas(), Prefix(). With this, we don't have to make complex methods on RootMultiStore to cover the possibilities. One problem here is that Transient() is meaningful on only commitstores so Transient() actually have to be in CommitKVStore. But while trying to do it, I found Context is based on MultiStore and CommitMultiStore. Since the only base layer KVStore we have that does not implement Commiter is dbStoreAdapter, I just make it panic on Transient. It should be fixed later.

@cwgoes cwgoes changed the base branch from unstable to develop July 4, 2018 19:26
@mossid
Copy link
Contributor Author

mossid commented Jul 4, 2018

Ready for review.

@@ -73,7 +73,12 @@ func (cms cacheMultiStore) GetKVStore(key StoreKey) KVStore {
return cms.stores[key].(KVStore)
}

// Implements Multistore.
func (cms cacheMultiStore) GetTransientStore(key StoreKey) KVStore {
return cms.stores[key].(KVStore)
Copy link
Member

Choose a reason for hiding this comment

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

is this supposed to be identical to GetKVStore?

@mossid mossid force-pushed the joon/1326-transient-store branch from 39509c7 to a8a1acf Compare July 5, 2018 22:45
mossid added a commit that referenced this pull request Jul 20, 2018
move gasconfig to types, make GetKVStoreWithGas take GasConfig

fix lint

modify transientstore

in progress

add test for transientstore

fix errors

fix test

fix errors and lint

last fix

in progress

move transient to KVStore

fix syntax errors

finalize rebase

remove NewMemDBStoreAdapter for lint

apply requests

apply requests

apply requests

add CHANGELOG

add tests

fix getter

in progress

finalize rebase

fix lint

partially apply requests

assert -> require

apply requests

fix test

Changelog => Pending

add TransientStoreKey

fix lint
mossid added a commit that referenced this pull request Jul 20, 2018
in progress

in progress

fix all keeper/handler/types, start working on test

finalize rebase

fixing clients

add linear_cli.go, refactor relayer cli

fix examples

add wire, msg naming format, fix examples

in progress

in progress

add client/store

in progress

in progress

cleanup

finalize cleanup

fix errors

refactor ibc
@mossid mossid force-pushed the joon/1326-transient-store branch from bff248e to 57ab2b3 Compare July 23, 2018 22:19
@mossid mossid force-pushed the joon/1326-transient-store branch from 57ab2b3 to f27d375 Compare July 23, 2018 22:20
mossid added a commit that referenced this pull request Jul 23, 2018
move gasconfig to types, make GetKVStoreWithGas take GasConfig

fix lint

modify transientstore

in progress

add test for transientstore

fix errors

fix test

fix errors and lint

last fix

in progress

move transient to KVStore

fix syntax errors

finalize rebase

remove NewMemDBStoreAdapter for lint

apply requests

apply requests

apply requests

add CHANGELOG

add tests

fix getter

in progress

finalize rebase

fix lint

partially apply requests

assert -> require

apply requests

fix test

Changelog => Pending

add TransientStoreKey

fix lint

fix lint
@mossid mossid force-pushed the joon/1326-transient-store branch from f27d375 to 0cafe33 Compare July 24, 2018 00:05
@mossid mossid force-pushed the joon/1326-transient-store branch from 0cafe33 to 2c7a8b5 Compare July 24, 2018 00:08
@mossid mossid force-pushed the joon/1326-transient-store branch from 2c7a8b5 to f76e8a7 Compare July 24, 2018 00:21
@mossid mossid force-pushed the joon/1326-transient-store branch from f76e8a7 to 0936344 Compare July 24, 2018 00:28
@mossid mossid force-pushed the joon/1326-transient-store branch from 0936344 to 78164f7 Compare July 24, 2018 05:16
mossid added a commit that referenced this pull request Jul 24, 2018
move gasconfig to types, make GetKVStoreWithGas take GasConfig

fix lint

modify transientstore

in progress

add test for transientstore

fix errors

fix test

fix errors and lint

last fix

in progress

move transient to KVStore

fix syntax errors

finalize rebase

remove NewMemDBStoreAdapter for lint

apply requests

apply requests

apply requests

add CHANGELOG

add tests

fix getter

in progress

finalize rebase

fix lint

partially apply requests

assert -> require

apply requests

fix test

Changelog => Pending

add TransientStoreKey

fix lint

fix lint

refactor *Store from context, add ReadKVStore

delete immutablestore

fix KVStore

fix TransientStore

remove StoreGetter

fix errors
Copy link
Contributor

@cwgoes cwgoes left a comment

Choose a reason for hiding this comment

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

utACK, another review would be good

@alexanderbez
Copy link
Contributor

I'll take a look @cwgoes

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.

I left some general feedback, but nothing that would withstand a merge/approval.

PENDING.md Outdated
@@ -30,6 +30,7 @@ FEATURES
* [baseapp] Initialize validator set on ResponseInitChain
* [cosmos-sdk-cli] Added support for cosmos-sdk-cli tool under cosmos-sdk/cmd
* This allows SDK users to initialize a new project repository.
* [store] Add transient store
Copy link
Contributor

Choose a reason for hiding this comment

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

@cwgoes is the convention to also link the PR # here? I think that'll be helpful in the CHANGELOG

types/gas.go Outdated

// Default gas config for TransientStores
func TransientGasConfig() GasConfig {
// TODO: reduce the gas cost in transient store
Copy link
Contributor

Choose a reason for hiding this comment

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

To go along with the TODO, why not just return DefaultGasConfig() for now as the values are identical?


// Implements CommitStore
func (ts *transientStore) SetPruning(pruning PruningStrategy) {
// Do nothing
Copy link
Contributor

Choose a reason for hiding this comment

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

Dont think we need this redundant comment 👍

@@ -440,6 +440,10 @@ func commitStores(version int64, storeMap map[StoreKey]CommitStore) commitInfo {
// Commit
commitID := store.Commit()

if commitID.IsZero() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Was this ever addressed? It does indeed seem that the TransientStore always returns zero. I can't think of a case where other commits would result in zero, but at least it'd be helpful to add a comment here 👍

Could we leverage GetStoreType here instead?

@@ -322,10 +319,23 @@ func (rs *rootMultiStore) loadCommitStoreFromParams(id CommitID, params storePar
// TODO: id?
// return NewCommitMultiStore(db, id)
case sdk.StoreTypeIAVL:
_, ok := key.(*sdk.KVStoreKey)
Copy link
Contributor

Choose a reason for hiding this comment

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

Definitely out of scope of this PR, but I really think we should avoid using named return variables in large and/or complex functions/methods.

move gasconfig to types, make GetKVStoreWithGas take GasConfig

fix lint

modify transientstore

in progress

add test for transientstore

fix errors

fix test

fix errors and lint

last fix

in progress

move transient to KVStore

fix syntax errors

finalize rebase

remove NewMemDBStoreAdapter for lint

apply requests

apply requests

apply requests

add CHANGELOG

add tests

fix getter

in progress

finalize rebase

fix lint

partially apply requests

assert -> require

apply requests

fix test

Changelog => Pending

add TransientStoreKey

fix lint

fix lint

refactor *Store from context, add ReadKVStore

delete immutablestore

fix KVStore

fix TransientStore

remove StoreGetter

fix errors

apply requests

fix unused CommitStoreLoader error
@mossid mossid force-pushed the joon/1326-transient-store branch from 17c5021 to f9f8445 Compare July 27, 2018 00:33
@cwgoes cwgoes merged commit d46140a into develop Jul 27, 2018
@cwgoes cwgoes deleted the joon/1326-transient-store branch July 27, 2018 01:24
mossid added a commit that referenced this pull request Aug 30, 2018
in progress

in progress

fix all keeper/handler/types, start working on test

finalize rebase

fixing clients

add linear_cli.go, refactor relayer cli

fix examples

add wire, msg naming format, fix examples

in progress

in progress

add client/store

in progress

in progress

cleanup

finalize cleanup

fix errors

refactor ibc
mossid added a commit that referenced this pull request Sep 20, 2018
in progress

in progress

fix all keeper/handler/types, start working on test

finalize rebase

fixing clients

add linear_cli.go, refactor relayer cli

fix examples

add wire, msg naming format, fix examples

in progress

in progress

add client/store

in progress

in progress

cleanup

finalize cleanup

fix errors

refactor ibc
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.

6 participants