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

Wrapper storage package #4453

Merged
merged 10 commits into from
Sep 15, 2022
Merged

Conversation

AdoAdoAdo
Copy link
Contributor

@AdoAdoAdo AdoAdoAdo commented Sep 12, 2022

Description of the reasoning behind the pull request

  • Refactoring dependencies to elrond-go-storage repo

Proposed Changes

  • Move all changes to a single storage adapter package
  • Move back to elrond-go the path manager and directory handler

@codecov-commenter
Copy link

codecov-commenter commented Sep 12, 2022

Codecov Report

❗ No coverage uploaded for pull request base (feat/elrond-go-storage@3dd2132). Click here to learn what that means.
The diff coverage is n/a.

@@                    Coverage Diff                    @@
##             feat/elrond-go-storage    #4453   +/-   ##
=========================================================
  Coverage                          ?   73.04%           
=========================================================
  Files                             ?      638           
  Lines                             ?    83548           
  Branches                          ?        0           
=========================================================
  Hits                              ?    61031           
  Misses                            ?    17763           
  Partials                          ?     4754           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@AdoAdoAdo AdoAdoAdo marked this pull request as ready for review September 13, 2022 15:00
@iulianpascalau iulianpascalau self-requested a review September 13, 2022 15:05
@ssd04 ssd04 self-requested a review September 13, 2022 19:21
@AdoAdoAdo AdoAdoAdo self-assigned this Sep 14, 2022
@sstanculeanu sstanculeanu self-requested a review September 14, 2022 07:48
@@ -98,7 +98,7 @@ func NewDelayedBlockBroadcaster(args *ArgsDelayedBlockBroadcaster) (*delayedBloc
return nil, spos.ErrNilAlarmScheduler
}

cacheHeaders, err := lrucache.NewCache(sizeHeadersCache)
cacheHeaders, err := cache.NewLRUCache(sizeHeadersCache)
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

if errClose != nil {
errMsg = errClose.Error()
}
panic(fmt.Sprintf("cannot close file: %s", errMsg))
Copy link
Contributor

Choose a reason for hiding this comment

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

I see this is old code, I think this line needs to be moved on L235, otherwise it will always panic

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -137,9 +136,9 @@ func createTestBlockChain() data.ChainHandler {
}

func createMemUnit() storage.Storer {
cache, _ := storageUnit.NewCache(storageUnit.CacheConfig{Type: storageUnit.LRUCache, Capacity: 10, Shards: 1, SizeInBytes: 0})
suCache, _ := storageunit.NewCache(storageunit.CacheConfig{Type: storageunit.LRUCache, Capacity: 10, Shards: 1, SizeInBytes: 0})
Copy link
Contributor

Choose a reason for hiding this comment

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

usually I name these variables something like cacheInstance in order to have a different name with the package


// NewLevelDB is a constructor for the leveldb persister
// It creates the files in the location given as parameter
func NewLevelDB(path string, batchDelaySeconds int, maxBatchSize int, maxOpenFiles int) (s *LevelDB, err error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

in this case only, where we have method factories we might have had the returning parameter of type leveldb.DB rather than the alias. Can be left as it is, is just a suggestion to keep the type aliases number as low as possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

right, removed

import "github.com/ElrondNetwork/elrond-go-storage/storageUnit"

const (
LRUCache = storageUnit.LRUCache
Copy link
Contributor

Choose a reason for hiding this comment

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

comments on exported items?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -77,6 +70,30 @@ var ErrNilNodeTypeProvider = errors.New("nil node type provider")
// ErrNilOldDataCleanerProvider signals that a nil old data cleaner provider has been provided
var ErrNilOldDataCleanerProvider = errors.New("nil old data cleaner provider")

// ErrNilCacher is raised when a nil cacher is provided
Copy link
Collaborator

Choose a reason for hiding this comment

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

not used anywhere

// IsNotFoundInStorageErr returns whether an error is a "not found in storage" error.
// Currently, "item not found" storage errors are untyped (thus not distinguishable from others). E.g. see "pruningStorer.go".
// As a workaround, we test the error message for a match.
func IsNotFoundInStorageErr(err error) bool {
Copy link
Collaborator

Choose a reason for hiding this comment

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

not used

)

// MaxRetriesToCreateDB represents the maximum number of times to try to create DB if it failed
const MaxRetriesToCreateDB = 10
Copy link
Collaborator

@sstanculeanu sstanculeanu Sep 14, 2022

Choose a reason for hiding this comment

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

as this is used only in the storage package and it also exists in elrond-go-storage, why not use the one from elrond-go-storage repo? this way we avoid forgetting to update one of them in one of the repos

same for SleepTimeBetweenCreateDBRetries

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the constants from elrond-go-storage were removed:
https://github.com/ElrondNetwork/elrond-go-storage/pull/4/files

Copy link
Collaborator

@sstanculeanu sstanculeanu Sep 14, 2022

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, right, forgot I moved these there.
Referenced for now the ones in storageUnit, but this will need to be refactored in a different PR so that we allow the consumer of the storage-repo to give these constants as arguments on creation instead.

Copy link
Contributor

@ssd04 ssd04 left a comment

Choose a reason for hiding this comment

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

  • it looks like some of the interfaces in storage/interface.go are not being used like SerializedStoredData, LRUCacheHandler, ForEachItem, maybe we can remove them
  • also others like Cacher seems to be duplicated with storage repo, maybe use an alias?

Copy link
Contributor

@gabi-vuls gabi-vuls left a comment

Choose a reason for hiding this comment

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

System test passed.

@gabi-vuls gabi-vuls merged commit 013b2cf into feat/elrond-go-storage Sep 15, 2022
@gabi-vuls gabi-vuls deleted the wrapper-storage-package branch September 15, 2022 07:37
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