-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DEV-1074: Add DID resolution implementation #1
Conversation
main.go
Outdated
requestService := services.NewRequestService(ledgerService) | ||
|
||
// Routes | ||
e.GET("/identifier/:did", func(c echo.Context) 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.
Should we create a const variable here? Or maybe as a config parameter
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.
The recommended way of doing this in Echo is to define a list of routes as a JSON file. https://echo.labstack.com/guide/routing/#list-routes
This keeps things extensible
main.go
Outdated
}) | ||
|
||
// Start server | ||
e.Logger.Fatal(e.Start(":1313")) |
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 guess this value is a port number, maybe the same issue? Config parameter or const.
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 I agree: define what backends you need to connect to and what ports you expose using Docker compose.
Signed-off-by: Andrew Nikitin <andrew.nikitin@cheqd.io>
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.
@anikitinDSR Could you please bring in the Universal Resolver Driver folders in here as well and start incorporating that in?
config.yml
Outdated
@@ -0,0 +1,4 @@ | |||
networks: | |||
mainnet: rpc.cheqd.net:443 | |||
testnet: 127.0.0.1:9090 |
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.
Testnet will be grpc.cheqd.network:443
main.go
Outdated
requestService := services.NewRequestService(ledgerService) | ||
|
||
// Routes | ||
e.GET("/identifier/:did", func(c echo.Context) 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.
The recommended way of doing this in Echo is to define a list of routes as a JSON file. https://echo.labstack.com/guide/routing/#list-routes
This keeps things extensible
main.go
Outdated
}) | ||
|
||
// Start server | ||
e.Logger.Fatal(e.Start(":1313")) |
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 I agree: define what backends you need to connect to and what ports you expose using Docker compose.
main.go
Outdated
var cfg Config | ||
decoder := yaml.NewDecoder(f) | ||
err = decoder.Decode(&cfg) | ||
if err != nil { | ||
return Config{}, err | ||
} | ||
|
||
return cfg, 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.
Maybe do this in Docker? Do you need it internally?
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.
config.yml
will be passed from docker-compose as a config
parameter.
contentType, | ||
resolutionError, | ||
time.Now().UTC().Format(time.RFC3339), | ||
} |
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 XMLDatetime, not sure of this output will be that or not
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, it is XMLDatetime
I used the same way for Cheqd Node: https://github.com/cheqd/cheqd-node/blob/9e07d8e61b304eb0883c2bdfce63fc1b4a23a381/x/cheqd/types/stateValue.go#L35
…1074-dokerfile Signed-off-by: Andrew Nikitin <andrew.nikitin@cheqd.io>
Signed-off-by: Andrew Nikitin <andrew.nikitin@cheqd.io>
[DEV-1074] Make a dockerfile for did-resolver
…1074-did-resolver
Signed-off-by: Andrew Nikitin <andrew.nikitin@cheqd.io>
Signed-off-by: Andrew Nikitin <andrew.nikitin@cheqd.io>
…1074-dokerfile Signed-off-by: Andrew Nikitin <andrew.nikitin@cheqd.io>
Signed-off-by: Andrew Nikitin <andrew.nikitin@cheqd.io>
Signed-off-by: Andrew Nikitin <andrew.nikitin@cheqd.io>
Signed-off-by: Andrew Nikitin <andrew.nikitin@cheqd.io>
Signed-off-by: Andrew Nikitin <andrew.nikitin@cheqd.io>
Signed-off-by: Andrew Nikitin <andrew.nikitin@cheqd.io>
Signed-off-by: Andrew Nikitin <andrew.nikitin@cheqd.io>
Signed-off-by: Andrew Nikitin <andrew.nikitin@cheqd.io>
main.go
Outdated
}) | ||
|
||
// Start server | ||
e.Logger.Fatal(e.Start(*didResolutionPort)) |
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.
Can we add an IP to listen on? This will remove the need of having a reverse proxy server to serve the traffic?
What I mean is this:
e.Logger.Fatal(e.Start("0.0.0.0"+*didResolutionPort))
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.
And let's put this value into config as well
docker-compose.yml
Outdated
build: | ||
dockerfile: Dockerfile |
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.
The docker-compose doesn't seem to work, since we need a context field here. I don't think we need to explicitly define which Dockerfile to use, since it uses the default Dockerfile name, and that should be the only one we're gonna use.
I think this is all we need:
build: .
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.
Hey! Does this changes cover you request?
https://github.com/cheqd/cheqd-did-resolver/pull/3/files
Especially about docker-compose file
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'm not so good with Docker Swarm. I think that docker-compose, by default, doesn't support copying/mounting files into containers. Maybe handling this through the COPY command in the Dockerfile is not so bad in this case, since we can update the image when something changes.
Alternatively, maybe we could set fixed values to the network endpoints, and use env vars to overwrite them? It gets much easier to overwrite values like this during the deployment process.
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 job! Thanks. The only more thing is I wouldn't leave commented pieces of code. Great work anyway.
[DEV-1074] Dockerfile improvements
…1074-did-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.
Thanks for the changes. Few things from me:
- Running as a root in docker is a security issue.
- Should we allow DIDUrls?
Cool tests btw!
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 the edits! LGTM
No description provided.