-
Notifications
You must be signed in to change notification settings - Fork 112
Conversation
Merge upstream
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 for addressing my comments.
I am ready to approve this if it is updated. |
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. Maybe @skylenet can check also vendoring dependencies changes?
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 work, I left some comments.
api/api.go
Outdated
@@ -185,15 +191,17 @@ type API struct { | |||
feed *feed.Handler | |||
fileStore *storage.FileStore | |||
dns Resolver | |||
rns Resolver |
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.
I think it would be great to leave a comment there, explaining what rns is/does. Even better if you can also create those comments for all other fields, but that is not necessary for this 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.
Added a note on the resolvers.
The rest could be added in another PR.
api/api.go
Outdated
@@ -225,6 +233,20 @@ func (a *API) Store(ctx context.Context, data io.Reader, size int64, toEncrypt b | |||
// Resolve a name into a content-addressed hash | |||
// where address could be an ENS name, or a content addressed hash |
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.
Update 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.
Fixed
@@ -244,6 +266,14 @@ func (a *API) Resolve(ctx context.Context, address string) (storage.Address, err | |||
return resolved[:], nil | |||
} | |||
|
|||
func tld(address string) (tld string) { | |||
splitAddress := strings.Split(address, ".") |
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.
What if an address has multiple dots?
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 only retrieves the last portion of the address.
For example mydomain.subdomain.rsk
will return rsk as the TLD which is the expected functionality in order to resolve the name correctly.
func newRSKTestResolveValidator(addr string) *testResolveValidator { | ||
r := &testResolveValidator{} | ||
if addr == "swarm.rsk" { | ||
hash := common.HexToHash("88ced8ba8e9396672840b47e332b33d6679d9962d80cf340d3cf615db23d4e07") |
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.
Where does this hash come from?
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 content hash is a hash of a test image, we used it in a test domain, but the actual resolver is mocked right now, this avoids coupling between the rns resolution in Swarm and the actual resolver.
The resolver has its own test in the library that tests the concrete implementation.
// TestRNSResolve tests resolving content from RNS addresses | ||
func TestRNSResolve(t *testing.T) { | ||
rnsAddr := "swarm.rsk" | ||
resolvedContent := "88ced8ba8e9396672840b47e332b33d6679d9962d80cf340d3cf615db23d4e07" |
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.
Idem. Where does this hash come from?
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.
Idem as above
|
||
// Resolve returns a resolver function | ||
func (f ResolverFunc) Resolve(domain string) (common.Hash, error) { return f(domain) } | ||
|
||
// Resolver interface resolve a domain name to a hash using ENS |
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.
Update 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.
Fixed
@@ -75,6 +77,7 @@ type Swarm struct { | |||
config *api.Config // swarm configuration | |||
api *api.API // high level api layer (fs/manifest) | |||
dns api.Resolver // DNS registrar |
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.
What is the difference between ens and dns?
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.
dns is the wrapper, for resolving multiple tld resolvers, it applies for ens but could be used for other resolvers.
on the contrary rns only resolver rsk domains with one tld.
this could be addressed in this issue #1991
swarm.go
Outdated
// parseRnsAPIAddress parses string according to format | ||
// [contract-addr@]url and returns RNSClientConfig structure | ||
// with endpoint and contract address | ||
func parseRnsAPIAddress(s string) (endpoint string, addr common.Address) { |
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 far as I can see, this function is exactly the same as parseEnsAPIAddress. I think it would be better to refactor those to avoid code multiplication
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.
I agree there is code duplication.
Fixed refactored for parseResolverAPIAddress
I just tried to do a |
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.
I would like to block this PR to be merged to master before we address some issues that we discovered in 0.5.3 by making a bugfix release. I will unblock as soon as we are done with the release, hopefully tomorrow. Thanks for understanding.
This PR adds the functionality to resolve
.rsk
addresses as content hashes for Swarm.How it works
It works in a similar manner to ENS resolution—in fact, it uses a similar service called RIF Name Service (or RNS for short).
geth
, but rather a go library which is included in thevendor
folder.github.com/rnsdomains/rns-go-lib
.rns-api
flag is added, with a format of[contract-addr@]url
in order to activate RNS resolution.contract-addr
is the address of the RNS resolver contract to use.url
is the network endpoint.the test includes themarcelosdomain.rsk
URI while we securetest.rsk
(tagging @vojtechsimetka for this one)Vendoring
There seems to be quite a few changes to
vendor
. While all the tests pass, @santicomp2014 and I are a bit suspicious of the changes togo.mod
.For the record, our steps were:
go.mod
,go.sum
andvendor
files and folders as found inmaster
.go get github.com/rnsdomains/rns-go-lib
make vendor
In particular, we aren't sure why some lines from
go.mod
are being deleted.tagging @janos for this one to see if it's possible to verify these steps were correct.