Skip to content
This repository has been archived by the owner on Aug 2, 2021. It is now read-only.

Localstore integration #1282

Closed
wants to merge 46 commits into from
Closed

Localstore integration #1282

wants to merge 46 commits into from

Conversation

janos
Copy link
Member

@janos janos commented Mar 5, 2019

This PR replaces LDBStore with new localstore DB in all parts of the code.

Work needed to be done is migration from legacy data store #1297 and logging and tracing in localstore package. Beside this missing parts, this PR should provide a functional swarm node starting from a blank database.

@janos janos self-assigned this Mar 5, 2019
@janos
Copy link
Member Author

janos commented Mar 5, 2019

PR ethereum/go-ethereum#19215 was opened by mistake on ethereum, which can be reused if this PR is accepted.

Copy link
Member

@zelig zelig left a comment

Choose a reason for hiding this comment

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

would it not make sense to split this PR and extract the Has/shed related changes?

swarm/storage/localstore/mode_has.go Outdated Show resolved Hide resolved
swarm/storage/localstore/localstore.go Show resolved Hide resolved
@janos
Copy link
Member Author

janos commented Mar 6, 2019

would it not make sense to split this PR and extract the Has/shed related changes?

Yes, I will create a new PR, Has is pretty isolated change.

@@ -135,13 +135,10 @@ func dbImport(ctx *cli.Context) {
log.Info(fmt.Sprintf("successfully imported %d chunks", count))
}

func openLDBStore(path string, basekey []byte) (*storage.LDBStore, error) {
func openLDBStore(path string, basekey []byte) (*localstore.DB, error) {
Copy link
Member

Choose a reason for hiding this comment

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

could this not be in the localstore pkg as one of the constructors?

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, I am not sure that we need it. It only checks if goleveldb data is present in a directory. Is it really necessary to have that check for export and import?

swarm/network/stream/common_test.go Outdated Show resolved Hide resolved
swarm/network/stream/common_test.go Show resolved Hide resolved
swarm/storage/localstore/subscription_pull.go Outdated Show resolved Hide resolved
@janos janos requested review from acud March 26, 2019 12:52
@janos
Copy link
Member Author

janos commented Mar 26, 2019

I am blocking this PR as it presents much more problems then improvements.

From gitter https://gitter.im/ethersphere/hq?at=5c9a376081b15c5e4b8ca43a:

Elad @justelad 15:29
right now i have made so little progress since localstore is, at the moment, some freak mutant hybrid of the old localstore and the new localstore

Please, do not review this PR until an alternative solution is presented.

if peerPO > po {
mode = chunk.ModePutRequest
} else {
mode = chunk.ModePutSync
Copy link
Member

Choose a reason for hiding this comment

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

@justelad

  1. no its not generating more redundancy the rest i dont understand
  2. it is easy to construct test cases. this is about correctness

} else {
depth := d.kad.NeighbourhoodDepth()
// is the chunk within our area of responsibility?
if po < depth {
Copy link
Member

Choose a reason for hiding this comment

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

if po >= depth || peerPO < po {
         mode = chunk.ModePutSync
} else {
         mode = chunk.ModePutRequest
}
```

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, this is more compact representation. I thought that the current one was easier to reason about, but this is good with a comment, as well.

Copy link
Member

Choose a reason for hiding this comment

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

that is good but you got the comparison wrong, note
po >= depth -> sync

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks Viktor.

@janos
Copy link
Member Author

janos commented Mar 29, 2019

Thanks for reviews. @holisticode I have set this PR ready for review, again. Before this gets merged, maybe we should decide about the migration PR that @justelad is working on. If this PR is merged, and released without the migration part, users will not have an option to keep their existing data.

// create a pull syncing triggers used by SubscribePull function
db.pullTriggers = make(map[uint8][]chan struct{})
// push index contains as yet unsynced chunks
db.pushIndex, err = db.shed.NewIndex("StoredTimestamp|Hash->nil", shed.IndexFuncs{
db.pushIndex, err = db.shed.NewIndex("StoreTimestamp|Hash->Tags", shed.IndexFuncs{
Copy link
Member Author

Choose a reason for hiding this comment

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

@zelig @justelad do we need to revert this index not to have Tags and remove tags from shed Item?

Copy link
Member

Choose a reason for hiding this comment

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

@janos we definitely need a way to persist tags and I think that this is the correct place to do so. If anything, tags should be removed from chunk.Chunk

Copy link
Member Author

Choose a reason for hiding this comment

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

chunk.Chunk does not have reference to Tags, currently. Are you referring to shed.Item or some other code?

@janos
Copy link
Member Author

janos commented Mar 29, 2019

@zelig @justelad I have added a check if chunk is already stored 2e24e99

@@ -141,13 +141,13 @@ func netStoreAndDeliveryWithAddr(ctx *adapters.ServiceContext, bucket *sync.Map,

cleanup := func() {
netStore.Close()
os.RemoveAll(datadir)
localStoreCleanup()
Copy link
Contributor

Choose a reason for hiding this comment

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

why not localStore.Close() too?

Copy link
Member Author

Choose a reason for hiding this comment

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

netStore.Close() is calling localstore.Close()

teardown := func() {
streamer.Close()
intervalsStore.Close()
netStore.Close()
removeDataDir()
Copy link
Contributor

Choose a reason for hiding this comment

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

localStore.Close()?

Copy link
Member Author

Choose a reason for hiding this comment

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

netStore.Close() is calling localstore.Close()

acud added 4 commits April 8, 2019 20:53
…ean on chunk exists (#1330)

* swarm/chunk, swarm/storage: change chunk store interface to return bool on item exists

* swarm/storage: adjust put test to cover `exists` param

* swarm/storage/localstore: fix test assertions
@nonsense
Copy link
Contributor

@janos I think we can close this. I think we should consider this merged, since it is in the swarm-rather-stable branch, and we just need to decide on specific timing regarding releasing it.

@janos
Copy link
Member Author

janos commented Apr 11, 2019

Yes, thanks, Anton. Closing this PR since it is merged into https://github.com/ethersphere/go-ethereum/tree/swarm-rather-stable branch.

@janos janos closed this Apr 11, 2019
@acud acud deleted the localstore-storage-integration branch May 5, 2019 18:36
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants