-
Notifications
You must be signed in to change notification settings - Fork 110
api, cmd, prod, pss, swarm: get publisher and query feed for chunk repair request #2175
Conversation
…ookup and DummyHandler.GetContent funcs prod: change NewRecoveryHook and getPinners funcs handler params to FeedsHandler type
… comment feed package funcs
storage/netstore.go
Outdated
@@ -99,7 +99,7 @@ type NetStore struct { | |||
requestGroup singleflight.Group | |||
RemoteGet RemoteGetFunc | |||
logger log.Logger | |||
recoveryCallback func(ctx context.Context, chunkAddress chunk.Address) error // this is the function callback when a chunk failed to be retrieved | |||
recoveryCallback func(ctx context.Context, chunkAddress chunk.Address, publisher string) error // this is the callback to be executed when a chunk fails to be retrieved |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
publisher
may not be a param here, but rather extracted from ctx
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it makes sense to extract from context within the recovery function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed this param, expecting code to be pushed to extract this data from ctx
storage/netstore.go
Outdated
@@ -167,7 +167,7 @@ func (n *NetStore) Close() error { | |||
} | |||
|
|||
// WithRecoveryCallback allows injecting a callback func on the NetStore struct | |||
func (n *NetStore) WithRecoveryCallback(f func(ctx context.Context, chunkAddress chunk.Address) error) *NetStore { | |||
func (n *NetStore) WithRecoveryCallback(f func(ctx context.Context, chunkAddress chunk.Address, publisher string) error) *NetStore { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see previous comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resolution here
pss/trojan/message.go
Outdated
@@ -45,6 +45,12 @@ const MaxPayloadSize = 4030 | |||
|
|||
var hashFunc = storage.MakeHashFunc(storage.BMTHash) | |||
|
|||
// RecoveryTopicText is the string used to construct the RecoveryTopic var | |||
const RecoveryTopicText = "RECOVERY" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need a separate string here as a const
in order to build a feed.Topic
var in the getPinners
function (which is not of the trojan.Topic
type)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should not be here. trojan pkg not supposed to know about recovery
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, moved this to prod
storage/feed/handler.go
Outdated
@@ -31,6 +31,13 @@ import ( | |||
"github.com/ethersphere/swarm/storage/feed/lookup" | |||
) | |||
|
|||
// GenericHandler is an interface which specifies funcs any feeds handler should use | |||
type GenericHandler interface { | |||
Lookup(ctx context.Context, query *Query) (*cacheEntry, error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the signature as originally defined in the feeds
package.
it seems strange to me that the cacheEntry
type is not exported, since it is returned in the Lookup
function, which is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point
prod/prod.go
Outdated
// get feed user from publisher | ||
publisherBytes, err := hex.DecodeString(publisher) | ||
if err != nil { | ||
return nil, ErrPublisher | ||
} | ||
pubKey, err := crypto.DecompressPubkey(publisherBytes) | ||
if err != nil { | ||
return nil, ErrPubKey | ||
} | ||
addr := crypto.PubkeyToAddress(*pubKey) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not entirely sure these are the steps to go from an (assumed) byte string as the publisher, to the actual User
address for the feed.
as clarification: this code was adapted from api/act.go:245
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good but this should defo be done only once instead of publisher, the derived ether address should be put in the context value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed, registered in #2181
prod/prod.go
Outdated
// TODO: monitor return should | ||
if _, err := send(ctx, targets, topic, payload); err != nil { | ||
// TODO: returned monitor should be made use of | ||
if _, err := send(ctx, targets, trojan.RecoveryTopic, payload); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, we need the monitor here, I would block this until either parent context is done or monitor shows synced request
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be done in #2171
added PRs #2178 and #2179 for this. thank you for the very appropriate suggestion |
… publish flag for swarm up command, added header publisher for uploadTar, replace prod with context publisher, updated tests to reflect these changes
…ing-feeds # Conflicts: # prod/prod.go # pss/pss_test.go
new related issue: #2180 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
quick overview of the stuff @zelig has not commented on
new related issue: #2181 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
linter passes, so do tests, and all outstanding issues are documented.
GEFM, but i can't actually approve because i am the author of the PR 😂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Addressed all points, this PR has generated some secondary issues:
Some are improvements and will be dealt with to improve the overall design
- add fallback content recovery publisher #2182
- remove redundancy in target extraction from publisher #2181
- add publisher info when using gateway #2180
- optimize global pinning recovery request frequency #2177
- calibrate ideal wait time for chunk re-retrieval #2172
- use monitors when requesting globally pinned chunks #2171
I'm happy how the iteration worked out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks perfect
const RecoveryTopicText = "RECOVERY" | ||
|
||
// RecoveryTopic is the topic used for repairing globally pinned chunks | ||
var RecoveryTopic = trojan.NewTopic("RECOVERY") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here use RecoveryTopicText
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whoops, this was left behind when i split the code into 2 more PRs.
fixed in the main branch, thanks
Topic: topic, | ||
User: addr, | ||
} | ||
query := feed.NewQueryLatest(&fd, lookup.NoClue) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this always lookup.NoClue
? does it not store latest. state to be. used as hint?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as of now, we do not have any idea when the last update to the feed happened, so this is why NoClue
is used.
but i have added a note to #2181, we can further optimize it this way i think.
thanks
This PR is a WIP for the following task:
from issue #2161.
Implementation overview
NewRecoveryHook
constructor func now also receives a feeds handler as a param, so the actual recovery hook can use it for feeds.NewSwarm
function.prod.getPinners
func now extracts apublisher
string from thectx
param, gets the content from a feed using the address derived from the publisher, and unmarshals the content feed as targets to construct the trojan chunk.publisher
flag forswarm up
to register the publisher in the file manifestTasks