diff --git a/go.mod b/go.mod index 0a965ac9a9..07d94e5f6c 100644 --- a/go.mod +++ b/go.mod @@ -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 @@ -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 ( @@ -105,6 +106,7 @@ require ( github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus v1.0.1 // indirect github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.1.0 // 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 @@ -151,6 +153,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 diff --git a/go.sum b/go.sum index 9a22d2b89f..4e6bf022c9 100644 --- a/go.sum +++ b/go.sum @@ -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= @@ -285,6 +287,8 @@ github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus v1.0.1 h1:qnpS github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus v1.0.1/go.mod h1:lXGCsh6c22WGtjr+qGHj1otzZpV/1kwTMAqkwZsnWRU= github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.1.0 h1:pRhl55Yx1eC7BZ1N+BBWwnKaMyD8uC+34TLdndZMAKk= github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.1.0/go.mod h1:XKMd7iuf/RGPSMJ/U4HP0zS2Z9Fh8Ps9a+6X26m/tmI= +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= @@ -660,10 +664,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= diff --git a/node/config.go b/node/config.go index 6a4d690f92..92c7ad47bf 100644 --- a/node/config.go +++ b/node/config.go @@ -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 @@ -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) @@ -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 } diff --git a/node/flags/flags.go b/node/flags/flags.go index 483a1de7ef..210792eb0e 100644 --- a/node/flags/flags.go +++ b/node/flags/flags.go @@ -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", @@ -335,6 +342,7 @@ var optionalFlags = []cli.Flag{ DataApiUrlFlag, DisableNodeInfoResourcesFlag, EnableGnarkBundleEncodingFlag, + BLSRemoteSignerEnabledFlag, BLSRemoteSignerUrlFlag, BLSPublicKeyHexFlag, BLSSignerCertFileFlag, diff --git a/node/node.go b/node/node.go index bfaa81bc80..46ab96ff0b 100644 --- a/node/node.go +++ b/node/node.go @@ -435,7 +435,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) } @@ -447,8 +447,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{