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

Konradstaniec/add remote signer module #33

Merged
merged 8 commits into from
Nov 21, 2024

Conversation

KonradStaniec
Copy link
Collaborator

@KonradStaniec KonradStaniec commented Nov 20, 2024

  • Add remote signer to covenant-emulator repo
  • For now signer only have cosmos keyring from which it can retrieve private key
  • Signer should only accept signing request from covenant-emulator, as it does not do any validations

TODO: Wiring signer in covenant-emulator will be done in separate pr

Copy link
Member

@Lazar955 Lazar955 left a comment

Choose a reason for hiding this comment

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

Great job! Overall lgtm, some nits bellow. 🙌

@@ -0,0 +1,37 @@
FROM golang:1.22.3-alpine as builder
Copy link
Member

Choose a reason for hiding this comment

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

nit: let's use go 1.23


m.Start(metricsAddress, metrics.Registry)

// TODO: Add signal handling and gracefull shutdown
Copy link
Member

Choose a reason for hiding this comment

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

Let's start using context instead of chan and signal interrupts (see vigilante or benchmark repo). Can be done in separate PR

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

agree on that though I would to in separate pr 👍

Comment on lines 44 to 46
serverConfig, err := cfg.Server.Parse()

if err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
serverConfig, err := cfg.Server.Parse()
if err != nil {
serverConfig, err := cfg.Server.Parse()
if err != nil {

nit

Port int
}

func (cfg *MetricsConfig) Parse() (*ParsedMetricsConfig, error) {
Copy link
Member

Choose a reason for hiding this comment

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

why the need for both MetricsConfig and ParsedMetricsConfig?

Copy link
Member

Choose a reason for hiding this comment

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

We can just validate MatricsConfig

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah I am fan of using as many types as possible i.e when you do MetricsConfig.Validate() the information about the validation is lost to all of the consumers of MetricsConfig i.e whatever code receives MetricsConfig it does not know whether config was already validated or not. This information lives solely in the head of the developer.

With parsing, any code that receives ParsedMetricsConfig knows that config was already validated i.e information about validation is encoded into the type system.

MaxContentLength uint32
}

func (c *ServerConfig) Parse() (*ParsedServerConfig, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Same question for this one, why the need for 2 same structs

@@ -0,0 +1,29 @@
package tracing
Copy link
Member

Choose a reason for hiding this comment

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

👍

@@ -0,0 +1,29 @@
package signerapp
Copy link
Member

Choose a reason for hiding this comment

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

Inconsistency in filenames, should be: hardcodedprivkeyretriever.go

// return copy of the private key
bytes := r.privKey.Serialize()

newPrivKey, _ := btcec.PrivKeyFromBytes(bytes)
Copy link
Member

Choose a reason for hiding this comment

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

err handle

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

as above, btcec.PrivKeyFromBytes actually returns privateKey, publicKey tuple, no errors

@@ -0,0 +1,42 @@
package handlers
Copy link
Member

Choose a reason for hiding this comment

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

file name style

"net/http"
)

func ContentLengthMiddleware(maxBytes int64) func(http.Handler) http.Handler {
Copy link
Member

Choose a reason for hiding this comment

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

we can have middleware for setting content type to json as well

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

what do you mean ?

Copy link
Member

@gitferry gitferry left a comment

Choose a reason for hiding this comment

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

LGTM! Some future improvement could be reduce duplicate with covenant emulator


var dumpCfgCmd = &cobra.Command{
Use: "dump-cfg",
Short: "dumps default confiiguration file",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Short: "dumps default confiiguration file",
Short: "dumps default configuration file",

Comment on lines 23 to 25
// C:\Users\<username>\AppData\Local\tools on Windows
// ~/.tools on Linux
// ~/Library/Application Support/tools on MacOS
Copy link
Member

Choose a reason for hiding this comment

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

why tools?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

changed to signer (it was copy paste mistake 😅 )

Copy link
Member

Choose a reason for hiding this comment

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

seems duplicate to covenant-emulator/keyring/keyring.go

Copy link
Member

Choose a reason for hiding this comment

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

seems duplicate to covenant-emulator/keyring/keyringcontroller.go

Copy link
Member

Choose a reason for hiding this comment

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

this could be repo level utils

Comment on lines 3 to 4
# Version to build. Default is the Git HEAD.
ARG VERSION="HEAD"
Copy link
Contributor

Choose a reason for hiding this comment

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

version is not being used

@RafilxTenfen
Copy link
Contributor

Mixed feelings about having this as a submodule, during the discussion I misunderstood and thought it would be like just a separate package folder '-'

In my opinion, since the covenant-emulator is a public repo, this remote-signer could go into a new repo...
Besides that all the comments were already made, nice work 💯

@KonradStaniec
Copy link
Collaborator Author

Mixed feelings about having this as a submodule, during the discussion I misunderstood and thought it would be like just a separate package folder '-'

In my opinion, since the covenant-emulator is a public repo, this remote-signer could go into a new repo...
Besides that all the comments were already made, nice work 💯

tbh I am also a bit unsure whether this is best approach, but I really do not want to have yet another repo, especially for such small program (one endpoint and key store) . Also this makes it super clear that phase-2 covenant signer must work together with covenant-emulator.

Eitherway, if after some time we will feel this setup is slowing us down, we will just copy paste it to separate repo 😅

@KonradStaniec KonradStaniec merged commit 1717509 into main Nov 21, 2024
13 checks passed
@KonradStaniec KonradStaniec deleted the konradstaniec/add-remote-signer-module branch November 21, 2024 07:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants