Skip to content
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

Merged
merged 32 commits into from
Apr 20, 2022
Merged

Conversation

Toktar
Copy link
Contributor

@Toktar Toktar commented Mar 25, 2022

No description provided.

@Toktar Toktar marked this pull request as draft March 25, 2022 10:31
main.go Outdated
requestService := services.NewRequestService(ledgerService)

// Routes
e.GET("/identifier/:did", func(c echo.Context) error {
Copy link
Contributor

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

Copy link
Contributor

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"))
Copy link
Contributor

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.

Copy link
Contributor

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 Show resolved Hide resolved
services/request_service.go Outdated Show resolved Hide resolved
Signed-off-by: Andrew Nikitin <andrew.nikitin@cheqd.io>
Copy link
Contributor

@ankurdotb ankurdotb left a 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
Copy link
Contributor

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 {
Copy link
Contributor

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"))
Copy link
Contributor

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
Comment on lines 87 to 95
var cfg Config
decoder := yaml.NewDecoder(f)
err = decoder.Decode(&cfg)
if err != nil {
return Config{}, err
}

return cfg, nil
}
Copy link
Contributor

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?

Copy link
Contributor

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),
}
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Toktar Toktar marked this pull request as ready for review April 14, 2022 13:22
Andrew Nikitin added 10 commits April 14, 2022 17:21
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))
Copy link

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))

Copy link
Contributor

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

Comment on lines 6 to 7
build:
dockerfile: Dockerfile
Copy link

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: .

Copy link
Contributor

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

Copy link

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.

Copy link
Contributor

@askolesov askolesov left a 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.

go.mod Outdated Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
services/ledger_service.go Show resolved Hide resolved
services/request_service.go Outdated Show resolved Hide resolved
services/request_service.go Outdated Show resolved Hide resolved
services/request_service.go Outdated Show resolved Hide resolved
types/resolution_metadata.go Show resolved Hide resolved
@askolesov askolesov self-requested a review April 19, 2022 12:05
Copy link
Contributor

@askolesov askolesov left a 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:

  1. Running as a root in docker is a security issue.
  2. Should we allow DIDUrls?

Cool tests btw!

.github/workflows/build.yml Outdated Show resolved Hide resolved
docker/Dockerfile Outdated Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
services/ledger_service.go Show resolved Hide resolved
services/request_service.go Outdated Show resolved Hide resolved
Copy link
Contributor

@askolesov askolesov left a 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

@Toktar Toktar merged commit f54ec2f into main Apr 20, 2022
@askolesov askolesov deleted the dev-1074-did-resolver branch May 13, 2022 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants