-
Notifications
You must be signed in to change notification settings - Fork 2
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
Conversation
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.
Great job! Overall lgtm, some nits bellow. 🙌
covenant-signer/Dockerfile
Outdated
@@ -0,0 +1,37 @@ | |||
FROM golang:1.22.3-alpine as builder |
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.
nit: let's use go 1.23
|
||
m.Start(metricsAddress, metrics.Registry) | ||
|
||
// TODO: Add signal handling and gracefull shutdown |
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.
Let's start using context instead of chan
and signal interrupts (see vigilante or benchmark repo). Can be done in separate 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.
agree on that though I would to in separate pr 👍
covenant-signer/config/config.go
Outdated
serverConfig, err := cfg.Server.Parse() | ||
|
||
if err != 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.
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) { |
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.
why the need for both MetricsConfig and ParsedMetricsConfig?
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.
We can just validate MatricsConfig
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.
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) { |
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.
Same question for this one, why the need for 2 same structs
@@ -0,0 +1,29 @@ | |||
package tracing |
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.
👍
@@ -0,0 +1,29 @@ | |||
package signerapp |
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.
Inconsistency in filenames, should be: hardcodedprivkeyretriever.go
// return copy of the private key | ||
bytes := r.privKey.Serialize() | ||
|
||
newPrivKey, _ := btcec.PrivKeyFromBytes(bytes) |
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.
err handle
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 above, btcec.PrivKeyFromBytes
actually returns privateKey, publicKey tuple, no errors
@@ -0,0 +1,42 @@ | |||
package handlers |
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.
file name style
"net/http" | ||
) | ||
|
||
func ContentLengthMiddleware(maxBytes int64) func(http.Handler) http.Handler { |
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.
we can have middleware for setting content type to json as well
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 do you mean ?
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! Some future improvement could be reduce duplicate with covenant emulator
|
||
var dumpCfgCmd = &cobra.Command{ | ||
Use: "dump-cfg", | ||
Short: "dumps default confiiguration 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.
Short: "dumps default confiiguration file", | |
Short: "dumps default configuration file", |
covenant-signer/cmd/root.go
Outdated
// C:\Users\<username>\AppData\Local\tools on Windows | ||
// ~/.tools on Linux | ||
// ~/Library/Application Support/tools on MacOS |
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.
why tools?
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.
changed to signer
(it was copy paste mistake 😅 )
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.
seems duplicate to covenant-emulator/keyring/keyring.go
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.
seems duplicate to covenant-emulator/keyring/keyringcontroller.go
covenant-signer/utils/btc.go
Outdated
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 could be repo level utils
covenant-signer/Dockerfile
Outdated
# Version to build. Default is the Git HEAD. | ||
ARG VERSION="HEAD" |
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.
version is not being used
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... |
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 😅 |
TODO: Wiring signer in covenant-emulator will be done in separate pr