Skip to content

Commit

Permalink
addressed comments
Browse files Browse the repository at this point in the history
  • Loading branch information
shrimalmadhur committed Nov 13, 2024
1 parent 3006ef0 commit 4077779
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 14 deletions.
5 changes: 4 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.21
toolchain go1.21.1

require (
github.com/Layr-Labs/cerberus-api v0.0.0-20241112163132-950ce31ba1ee
github.com/Layr-Labs/eigensdk-go v0.1.7-0.20240507215523-7e4891d5099a
github.com/aws/aws-sdk-go-v2 v1.26.1
github.com/aws/aws-sdk-go-v2/credentials v1.17.11
Expand Down Expand Up @@ -35,7 +36,7 @@ require (
go.uber.org/mock v0.4.0
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa
golang.org/x/sync v0.8.0
google.golang.org/grpc v1.65.0
google.golang.org/grpc v1.64.1
)

require (
Expand Down Expand Up @@ -103,6 +104,7 @@ require (
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-bexpr v0.1.10 // indirect
github.com/holiman/billy v0.0.0-20240216141850-2abb0c79d3c4 // indirect
Expand Down Expand Up @@ -149,6 +151,7 @@ require (
golang.org/x/arch v0.4.0 // indirect
golang.org/x/oauth2 v0.22.0 // indirect
golang.org/x/time v0.5.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240827150818-7e3bb234dfed // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
Expand Down
10 changes: 8 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ github.com/DataDog/zstd v1.5.2 h1:vUG4lAyuPCXO0TLbXvPv7EB7cNK1QV/luu55UHLrrn8=
github.com/DataDog/zstd v1.5.2/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw=
github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc=
github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE=
github.com/Layr-Labs/cerberus-api v0.0.0-20241112163132-950ce31ba1ee h1:aUOOI6lDb3mrAg0ClQPM+TUe0XkKcpP0Ddb9ZubciEA=
github.com/Layr-Labs/cerberus-api v0.0.0-20241112163132-950ce31ba1ee/go.mod h1:Lm4fhzy0S3P7GjerzuseGaBFVczsIKmEhIjcT52Hluo=
github.com/Layr-Labs/eigensdk-go v0.1.7-0.20240507215523-7e4891d5099a h1:L/UsJFw9M31FD/WgXTPFB0oxbq9Cu4Urea1xWPMQS7Y=
github.com/Layr-Labs/eigensdk-go v0.1.7-0.20240507215523-7e4891d5099a/go.mod h1:OF9lmS/57MKxS0xpSpX0qHZl0SKkDRpvJIvsGvMN1y8=
github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
Expand Down Expand Up @@ -280,6 +282,8 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 h1:asbCHRVmodnJTuQ3qamDwqVOIjwqUPTYmYuemVOx+Ys=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0/go.mod h1:ggCgvZ2r7uOoQjOyu2Y1NhHmEPPzzuhWgcza5M1Ji1I=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I=
github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
Expand Down Expand Up @@ -652,10 +656,12 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 h1:wKguEg1hsxI2/L3hUYrpo1RVi48K+uTyzKqprwLXsb8=
google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142/go.mod h1:d6be+8HhtEtucleCbxpPW9PA9XwISACu8nvpPqF0BVo=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240827150818-7e3bb234dfed h1:J6izYgfBXAI3xTKLgxzTmUltdYaLsuBxFCgDHWJ/eXg=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240827150818-7e3bb234dfed/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU=
google.golang.org/grpc v1.65.0 h1:bs/cUb4lp1G5iImFFd3u5ixQzweKizoZJAwBNLR42lc=
google.golang.org/grpc v1.65.0/go.mod h1:WgYC2ypjlB0EiQi6wdKixMqukr6lBc0Vo+oOgjrM5ZQ=
google.golang.org/grpc v1.64.1 h1:LKtvyfbX3UGVPFcGqJ9ItpVWW6oN/2XqTxfAnwRRXiA=
google.golang.org/grpc v1.64.1/go.mod h1:hiQF4LFZelK2WKaP6W0L92zGHtiQdZxk8CrSdvyjeP0=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
Expand Down
20 changes: 12 additions & 8 deletions node/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,12 @@ type Config struct {
UseSecureGrpc bool
ReachabilityPollIntervalSec uint64
DisableNodeInfoResources bool
BLSRemoteSignerUrl string
BLSPublicKeyHex string
BLSKeyPassword string
BLSSignerTLSCertFilePath string
UseBLSRemoteSigner bool

BLSRemoteSignerEnabled bool
BLSRemoteSignerUrl string
BLSPublicKeyHex string
BLSKeyPassword string
BLSSignerTLSCertFilePath string

EthClientConfig geth.EthClientConfig
LoggerConfig common.LoggerConfig
Expand Down Expand Up @@ -153,13 +154,16 @@ func NewConfig(ctx *cli.Context) (*Config, error) {
}

// check if BLS remote signer configuration is provided
useBLSRemoteSigner := ctx.GlobalString(flags.BLSRemoteSignerUrlFlag.Name) != "" && ctx.GlobalString(flags.BLSPublicKeyHexFlag.Name) != ""
blsRemoteSignerEnabled := ctx.GlobalBool(flags.BLSRemoteSignerEnabledFlag.Name)
if blsRemoteSignerEnabled && (ctx.GlobalString(flags.BLSRemoteSignerUrlFlag.Name) == "" || ctx.GlobalString(flags.BLSPublicKeyHexFlag.Name) == "") {
return nil, fmt.Errorf("BLS remote signer URL and Public Key Hex is required if BLS remote signer is enabled")
}

// Decrypt BLS key
var privateBls string
if !testMode {
// If remote signer fields are empty then try to read the BLS key from the file
if !useBLSRemoteSigner {
if !blsRemoteSignerEnabled {
kp, err := bls.ReadPrivateKeyFromFile(ctx.GlobalString(flags.BlsKeyFileFlag.Name), ctx.GlobalString(flags.BlsKeyPasswordFlag.Name))
if err != nil {
return nil, fmt.Errorf("could not read or decrypt the BLS private key: %v", err)
Expand Down Expand Up @@ -224,6 +228,6 @@ func NewConfig(ctx *cli.Context) (*Config, error) {
BLSPublicKeyHex: ctx.GlobalString(flags.BLSPublicKeyHexFlag.Name),
BLSKeyPassword: ctx.GlobalString(flags.BlsKeyPasswordFlag.Name),
BLSSignerTLSCertFilePath: ctx.GlobalString(flags.BLSSignerCertFileFlag.Name),
UseBLSRemoteSigner: useBLSRemoteSigner,
BLSRemoteSignerEnabled: blsRemoteSignerEnabled,
}, nil
}
8 changes: 8 additions & 0 deletions node/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,13 @@ var (
EnvVar: common.PrefixEnvVar(EnvVarPrefix, "DISABLE_NODE_INFO_RESOURCES"),
}

BLSRemoteSignerEnabledFlag = cli.BoolFlag{
Name: common.PrefixFlag(FlagPrefix, "bls-remote-signer-enabled"),
Usage: "Set to true to enable the BLS remote signer",
Required: false,
EnvVar: common.PrefixEnvVar(EnvVarPrefix, "BLS_REMOTE_SIGNER_ENABLED"),
}

BLSRemoteSignerUrlFlag = cli.StringFlag{
Name: common.PrefixFlag(FlagPrefix, "bls-remote-signer-url"),
Usage: "The URL of the BLS remote signer",
Expand Down Expand Up @@ -335,6 +342,7 @@ var optionalFlags = []cli.Flag{
DataApiUrlFlag,
DisableNodeInfoResourcesFlag,
EnableGnarkBundleEncodingFlag,
BLSRemoteSignerEnabledFlag,
BLSRemoteSignerUrlFlag,
BLSPublicKeyHexFlag,
BLSSignerCertFileFlag,
Expand Down
6 changes: 3 additions & 3 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ func (n *Node) ProcessBatch(ctx context.Context, header *core.BatchHeader, blobs

// Sign batch header hash if all validation checks pass and data items are written to database.
stageTimer = time.Now()
signature, err := n.GetSignature(ctx, batchHeaderHash)
signature, err := n.SignMessage(ctx, batchHeaderHash)
if err != nil {
return nil, fmt.Errorf("failed to sign batch: %w", err)
}
Expand All @@ -436,8 +436,8 @@ func (n *Node) ProcessBatch(ctx context.Context, header *core.BatchHeader, blobs
return signature, nil
}

func (n *Node) GetSignature(ctx context.Context, data [32]byte) (*core.Signature, error) {
if n.Config.UseBLSRemoteSigner {
func (n *Node) SignMessage(ctx context.Context, data [32]byte) (*core.Signature, error) {
if n.Config.BLSRemoteSignerEnabled {
sigResp, err := n.BLSSigner.SignGeneric(
ctx,
&blssignerV1.SignGenericRequest{
Expand Down

0 comments on commit 4077779

Please sign in to comment.