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

swarm: push tags integration - request flow #1347

Merged
merged 18 commits into from
May 5, 2019
Merged

Conversation

acud
Copy link
Member

@acud acud commented Apr 23, 2019

this pr integrates the push tags into the low level components that actually do the bead-counting.
supersedes #1318

https://hackmd.io/9eWxJ_MJS8i04onWg49UBA?both

coincidentally resolves #1364 and fixes #1350

@acud acud added the push-sync label Apr 23, 2019
@acud acud requested a review from zelig April 23, 2019 10:43
@acud acud self-assigned this Apr 23, 2019
@acud acud mentioned this pull request Apr 23, 2019
Copy link
Member

@janos janos left a comment

Choose a reason for hiding this comment

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

There are compilations errors in swarm/api/http/test_server.go and swarm/fuse/swarmfs_test.go.

cmd/swarm/swarm-smoke/upload_and_sync.go Outdated Show resolved Hide resolved
swarm/fuse/swarmfs_test.go Outdated Show resolved Hide resolved
@acud
Copy link
Member Author

acud commented Apr 23, 2019

I am aware of the linting and compilation errors. This is still WIP (but preliminary implementation is there).
As I've noted to @zelig, I have a bit of a problem with the original design, namely:

  1. the Tags.Inc method is not used since we need to pass around the Tag pointer anyway to the pyramid chunker
  2. As of such we don't really need this to be a sync.Map but just a normal map that points to Tag pointers
  3. I don't think we should pass the whole sync.Map to the chunker in order to do the increments. @janos @zelig WDYT?
  4. we can pass the pointer in the context but I don't think this is a nice solution. I think we should just pass the tag id in the context and propagate the concrete object wherever necessary

opinions?

@acud acud changed the title push tags integration [wip]push tags integration Apr 24, 2019
@@ -297,31 +300,6 @@ func (a *API) ResolveURI(ctx context.Context, uri *URI, credentials string) (sto
return addr, nil
}

// Put provides singleton manifest creation on top of FileStore store
func (a *API) Put(ctx context.Context, content string, contentType string, toEncrypt bool) (k storage.Address, wait func(context.Context) error, err error) {
Copy link
Member Author

Choose a reason for hiding this comment

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

this method was only used by tests. i think we should not export test helpers on public APIs. hence the functionality was removed from the API struct and duplicated wherever necessary

swarm/chunk/tags.go Outdated Show resolved Hide resolved
swarm/storage/filestore.go Outdated Show resolved Hide resolved
swarm/storage/hasherstore.go Outdated Show resolved Hide resolved
swarm/storage/hasherstore.go Outdated Show resolved Hide resolved
swarm/storage/pyramid.go Show resolved Hide resolved
swarm/api/http/server.go Show resolved Hide resolved
swarm/chunk/tag.go Show resolved Hide resolved
swarm/chunk/tag.go Show resolved Hide resolved
swarm/chunk/tags.go Outdated Show resolved Hide resolved
swarm/storage/hasherstore.go Outdated Show resolved Hide resolved
@zelig
Copy link
Member

zelig commented Apr 27, 2019

can we please work with incremental PRs? Again we cram eveything into this.
you said it is ready for review but all checks fail on travis
Comment exported functions and in general please explain what you are doing:

  • what is the unit for which a tag is defined
  • how do they get default names
  • what are we doing with reponse headers

My 2c:

  • First we should finish swarm/chunk: add tags #1341, putting all related changes there.
  • This PR should be only about creating and passing around tags, tag and the context
    and chunker and hasherstore calling increment
  • Following PR: integrate in the response

@acud
Copy link
Member Author

acud commented Apr 27, 2019

can we please work with incremental PRs? Again we cram eveything into this.

localstore integration was one PR, shed was one PR, new localstore was one PR (not integrated)

you said it is ready for review but all checks fail on travis

ready for review means i would have tagged it ready for review and removed the [wip]. i haven't but i told you it's coming along and you can give it a pass and see how its coming along.

First we should finish #1341, putting all related changes there.

There were two days between my last commit on that branch and the last review. Not sure what I was supposed to do in between.

@acud
Copy link
Member Author

acud commented Apr 27, 2019

Following PR: integrate in the response

while working on this i figured there's not much use to integrate this in the response, since we lose the ability to pipe the returned hash values from swarm up to other processes/machine readable format. that's why i changed the DoneSplit() signature to set an associated root hash once the splitting has been done. this at a later stage could be queried against bzz-tag:/<swarm hash> and there a UI or JSON would be returned as a result of the Accept header

@acud acud changed the base branch from add-tags-struct to swarm-rather-stable April 30, 2019 04:13
@acud acud force-pushed the tagz-count branch 2 times, most recently from 8dc9f72 to 4f92cac Compare April 30, 2019 04:32
swarm/chunk: address (some) PR comments

swarm/chunk: add seen field

swarm/chunk: change eta status call

swarm/chunk: address pr comments

swarm/chunk: address pr comments

swarm/chunk: address pr comments

swarm/chunk: remove ambiguity of total

swarm/api: wip add chunk totals

swarm/api: tag test-bed

swarm/api, swarm/chunk: wip rudimentary implementation for tag increments

swarm/api, swarm/storage: initial TestApiPut passes

swarm/api: remove logline

swarm: address PR comments

cmd, swarm: fix compilation errors

swarm/chunk: adjust test

swarm/chunk: adjust tests

swarm/chunk: pointers galore

swarm: fix tests and compilation

swarm/storage: change pyramid chunker append signature

swarm/api: make api tags private

swarm/api: add test for larger content

cmd, swarm: add test for http upload

swarm: remove deprecated and unused code, add swarm hash to DoneSplit signature

swarm/chunk: add marshalling for address field

swarm/api: add handle get tag handler, add tags for post raw

cmd/swarm: reinstate recursive flag

swarm/api: cleanup api test

swarm/api: cleanup api test

swarm/api/client: add client tag check to multipart upload

swarm/api/client: add more tag assertions to tests

swarm/api/http: test for correct tag size estimate according to Content-Length header

swarm/api/http: document test

swarm/api/http: uncomment test

swarm/storage: address pr comments

swarm/api: remove silly comment
@zelig zelig mentioned this pull request Apr 30, 2019
20 tasks
@acud
Copy link
Member Author

acud commented May 1, 2019

@zelig this is ready for review.
This PR addresses: creation of tags, passing them around, increments on store, seen, split, including tests that assert this. the bzz-tag frontend endpoint stub has been removed and will be deferred to a later PR.

Still left TODO:

  • Return the tag uid with a response header for dapps to track tags starting with the chunking phase
  • Integrate to localstore with an index that tracks the tag vectors per chunk on the push index. I don't see a way around this since we have to increment a single tag with SENT/SYNCED statuses
  • Rename chunk.State modes to the same convention as in http.StatusNotFound
  • Create the bzz-tag endpoint that will allow queries to return either a UI or JSON with the progress bars

@acud acud changed the title [wip]push tags integration swarm: push tags integration - request flow May 1, 2019
swarm/api/api_test.go Outdated Show resolved Hide resolved
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.

nice one , getting there:

  • STORED increment should be after Put returns
  • if tests fail, we need syncronisation, ie wait for correct numbers with timeout
  • checkTag should work on one Tag
  • test helpers should be DRY-ed
  • chunk count estimation should become exact chunk counting and tested

swarm/api/client/client.go Outdated Show resolved Hide resolved
swarm/api/client/client.go Outdated Show resolved Hide resolved
swarm/api/client/client_test.go Outdated Show resolved Hide resolved
swarm/api/client/client_test.go Outdated Show resolved Hide resolved
swarm/api/client/client_test.go Outdated Show resolved Hide resolved
swarm/api/http/server.go Outdated Show resolved Hide resolved
swarm/api/http/server_test.go Outdated Show resolved Hide resolved
swarm/network_test.go Show resolved Hide resolved
swarm/storage/hasherstore.go Outdated Show resolved Hide resolved
swarm/testutil/tag.go Outdated Show resolved Hide resolved
swarm/chunk/tags.go Outdated Show resolved Hide resolved
swarm/chunk/tags.go Outdated Show resolved Hide resolved
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.

swarm/api/http/server.go Outdated Show resolved Hide resolved
swarm/chunk/tag.go Outdated Show resolved Hide resolved
swarm/api/http/middleware.go Show resolved Hide resolved
swarm/chunk/tags_test.go Outdated Show resolved Hide resolved
swarm/chunk/tags_test.go Outdated Show resolved Hide resolved
swarm/storage/filestore.go Outdated Show resolved Hide resolved
@acud acud removed the in progress label May 5, 2019
@acud acud merged commit c966633 into swarm-rather-stable May 5, 2019
@acud acud deleted the tagz-count branch May 5, 2019 18:34
nonsense pushed a commit that referenced this pull request May 10, 2019
swarm/api: integrate tags to count chunks being split and stored
swarm/api/http: integrate tags in middleware for HTTP `POST` calls and assert chunks being calculated and counted correctly
swarm: remove deprecated and unused code, add swarm hash to DoneSplit signature, remove calls to the api client from the http package
nonsense pushed a commit that referenced this pull request May 10, 2019
swarm/api: integrate tags to count chunks being split and stored
swarm/api/http: integrate tags in middleware for HTTP `POST` calls and assert chunks being calculated and counted correctly
swarm: remove deprecated and unused code, add swarm hash to DoneSplit signature, remove calls to the api client from the http package
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.

3 participants