Skip to content

Commit

Permalink
feat: add postgres db to store keys metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
shrimalmadhur committed Jan 7, 2025
1 parent d5b380b commit 8c6c148
Show file tree
Hide file tree
Showing 25 changed files with 963 additions and 47 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.env
**/.env
data/
bin/
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,8 @@ tests: ## runs all tests
.PHONY: docker
docker: ## runs docker build
docker build -t $(APP_NAME):latest .

.PHONY: migrate
migrate: ## runs database migrations
go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest
migrate -path internal/database/migrations/ -database "postgres://user:password@localhost:5432/cerberus?sslmode=disable" --verbose up
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Remote Signer Implementation of cerberus-api
This is a remote signer which supports BLS signatures on the BN254 curve.

## Disclaimer
🚧 Cerberus is under active development and has not been audited. Cerberus is rapidly being upgraded, features may be added, removed or otherwise improved or modified and interfaces will have breaking changes. Cerberus should be used only for testing purposes and not in production. Cerberus is provided "as is" and Eigen Labs, Inc. does not guarantee its functionality or provide support for its use in production. 🚧

<!-- TOC -->
* [Remote Signer Implementation of cerberus-api](#remote-signer-implementation-of-cerberus-api)
* [Installation](#installation)
Expand Down
11 changes: 10 additions & 1 deletion cmd/cerberus/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@ var (
Usage: "Project ID for Google Cloud Platform",
EnvVars: []string{"GCP_PROJECT_ID"},
}

postgresDatabaseURLFlag = &cli.StringFlag{
Name: "postgres-database-url",
Usage: "Postgres database URL",
Value: "postgres://user:password@localhost:5432/cerberus?sslmode=disable",
EnvVars: []string{"POSTGRES_DATABASE_URL"},
}
)

func main() {
Expand Down Expand Up @@ -143,6 +150,7 @@ func main() {
awsAccessKeyIDFlag,
awsSecretAccessKeyFlag,
gcpProjectIDFlag,
postgresDatabaseURLFlag,
}
sort.Sort(cli.FlagsByName(app.Flags))

Expand Down Expand Up @@ -172,7 +180,7 @@ func start(c *cli.Context) error {
awsAccessKeyID := c.String(awsAccessKeyIDFlag.Name)
awsSecretAccessKey := c.String(awsSecretAccessKeyFlag.Name)
gcpProjectID := c.String(gcpProjectIDFlag.Name)

postgresDatabaseURL := c.String(postgresDatabaseURLFlag.Name)
cfg := &configuration.Configuration{
KeystoreDir: keystoreDir,
GrpcPort: grpcPort,
Expand All @@ -186,6 +194,7 @@ func start(c *cli.Context) error {
AWSAccessKeyID: awsAccessKeyID,
AWSSecretAccessKey: awsSecretAccessKey,
GCPProjectID: gcpProjectID,
PostgresDatabaseURL: postgresDatabaseURL,
}

if err := cfg.Validate(); err != nil {
Expand Down
50 changes: 47 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
module github.com/Layr-Labs/cerberus

go 1.21
go 1.22.0

toolchain go1.21.11
toolchain go1.22.3

replace github.com/Layr-Labs/cerberus-api => ../cerberus-api

require (
cloud.google.com/go/secretmanager v1.14.2
github.com/Layr-Labs/bn254-keystore-go v0.0.0-20241118175331-3ceaf682f032
github.com/Layr-Labs/bn254-keystore-go v0.0.0-20250107020618-26bd412fae87
github.com/Layr-Labs/cerberus-api v0.0.1
github.com/aws/aws-sdk-go-v2 v1.32.5
github.com/aws/aws-sdk-go-v2/config v1.28.5
Expand All @@ -20,6 +22,47 @@ require (
google.golang.org/grpc v1.67.1
)

require (
dario.cat/mergo v1.0.0 // indirect
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/containerd/containerd v1.7.18 // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/containerd/platforms v0.2.1 // indirect
github.com/cpuguy83/dockercfg v0.3.2 // indirect
github.com/distribution/reference v0.6.0 // indirect
github.com/docker/docker v27.2.0+incompatible // indirect
github.com/docker/go-connections v0.5.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-migrate/migrate/v4 v4.18.1 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/moby/docker-image-spec v1.3.1 // indirect
github.com/moby/patternmatcher v0.6.0 // indirect
github.com/moby/sys/sequential v0.5.0 // indirect
github.com/moby/sys/user v0.1.0 // indirect
github.com/moby/term v0.5.0 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
github.com/shirou/gopsutil/v3 v3.23.12 // indirect
github.com/shoenig/go-m1cpu v0.1.6 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/testcontainers/testcontainers-go v0.34.0 // indirect
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/yusufpapurcu/wmi v1.2.3 // indirect
go.uber.org/atomic v1.7.0 // indirect
)

require (
cloud.google.com/go/auth v0.9.9 // indirect
cloud.google.com/go/auth/oauth2adapt v0.2.4 // indirect
Expand Down Expand Up @@ -50,6 +93,7 @@ require (
github.com/googleapis/gax-go/v2 v2.13.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/lib/pq v1.10.9
github.com/mmcloughlin/addchain v0.4.0 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
Expand Down
Loading

0 comments on commit 8c6c148

Please sign in to comment.