Conversation
Merge upstream
janos
left a comment
There was a problem hiding this comment.
Thanks for addressing my comments.
|
I am ready to approve this if it is updated. |
Eknir
left a comment
There was a problem hiding this comment.
Good work, I left some comments.
api/api.go
Outdated
| feed *feed.Handler | ||
| fileStore *storage.FileStore | ||
| dns Resolver | ||
| rns Resolver |
There was a problem hiding this comment.
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.
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 | |||
| } | ||
|
|
||
| func tld(address string) (tld string) { | ||
| splitAddress := strings.Split(address, ".") |
There was a problem hiding this comment.
What if an address has multiple dots?
There was a problem hiding this comment.
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.
Where does this hash come from?
There was a problem hiding this comment.
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.
Idem. Where does this hash come from?
| // 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 |
| @@ -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.
What is the difference between ens and dns?
There was a problem hiding this comment.
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.
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.
I agree there is code duplication.
Fixed refactored for parseResolverAPIAddress
I just tried to do a |
janos
left a comment
There was a problem hiding this comment.
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
.rskaddresses 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 thevendorfolder.github.com/rnsdomains/rns-go-lib.rns-apiflag is added, with a format of[contract-addr@]urlin order to activate RNS resolution.contract-addris the address of the RNS resolver contract to use.urlis the network endpoint.the test includes themarcelosdomain.rskURI 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.sumandvendorfiles and folders as found inmaster.go get github.com/rnsdomains/rns-go-libmake vendorIn particular, we aren't sure why some lines from
go.modare being deleted.tagging @janos for this one to see if it's possible to verify these steps were correct.