From e1b34d7389908c6ac6ea7494305956dcc1951917 Mon Sep 17 00:00:00 2001 From: Jim McDonald Date: Sat, 27 Apr 2024 16:47:46 +0100 Subject: [PATCH] Additional linting rules. --- .golangci.yml | 79 ++++++++-- core/stores.go | 6 + go.mod | 66 ++++----- go.sum | 140 +++++++++--------- main.go | 125 +++++++++------- metrics.go | 1 + rules/mock/createaccount.go | 2 +- rules/mock/denying.go | 28 ++-- rules/mock/failing.go | 28 ++-- rules/mock/listaccounts.go | 2 +- rules/mock/lockaccount.go | 2 +- rules/mock/lockwallet.go | 2 +- rules/mock/service.go | 2 +- rules/mock/sign.go | 2 +- rules/mock/signbeaconattestation.go | 2 +- rules/mock/signbeaconattestations.go | 2 +- rules/mock/signbeaconproposal.go | 2 +- rules/mock/slashingprotection.go | 6 +- rules/mock/unlockaccount.go | 2 +- rules/mock/unlockwallet.go | 2 +- rules/standard/createaccount.go | 2 +- rules/standard/listaccounts.go | 2 +- rules/standard/lockaccount.go | 2 +- rules/standard/lockwallet.go | 2 +- rules/standard/service.go | 1 + rules/standard/signbeaconattestation.go | 13 +- rules/standard/signbeaconattestations.go | 13 +- rules/standard/signbeaconproposal.go | 16 +- rules/standard/slashingprotection.go | 1 + rules/standard/storage.go | 5 + rules/standard/unlockaccount.go | 2 +- rules/standard/unlockwallet.go | 2 +- services/accountmanager/mock/service.go | 6 +- services/accountmanager/standard/generate.go | 1 + services/accountmanager/standard/helpers.go | 1 + services/accountmanager/standard/lock.go | 1 + services/accountmanager/standard/monitor.go | 2 +- .../accountmanager/standard/parameters.go | 20 +-- services/accountmanager/standard/unlock.go | 1 + .../grpc/handlers/accountmanager/generate.go | 1 + .../handlers/accountmanager/parameters.go | 8 +- services/api/grpc/handlers/helpers.go | 1 + .../api/grpc/handlers/lister/listaccounts.go | 1 + .../api/grpc/handlers/lister/parameters.go | 4 +- services/api/grpc/handlers/receiver/abort.go | 5 +- services/api/grpc/handlers/receiver/commit.go | 3 +- .../api/grpc/handlers/receiver/contribute.go | 8 +- .../api/grpc/handlers/receiver/execute.go | 3 +- .../api/grpc/handlers/receiver/helpers.go | 1 + .../api/grpc/handlers/receiver/parameters.go | 8 +- .../api/grpc/handlers/receiver/prepare.go | 3 +- .../api/grpc/handlers/signer/multisign.go | 5 + .../api/grpc/handlers/signer/parameters.go | 4 +- services/api/grpc/handlers/signer/sign.go | 1 + .../handlers/signer/signbeaconattestation.go | 1 + .../handlers/signer/signbeaconattestations.go | 6 + .../handlers/signer/signbeaconproposal.go | 5 + .../api/grpc/handlers/walletmanager/lock.go | 1 + .../grpc/handlers/walletmanager/parameters.go | 8 +- .../api/grpc/handlers/walletmanager/unlock.go | 1 + services/api/grpc/interceptors/clientinfo.go | 3 +- services/api/grpc/interceptors/reqid.go | 2 +- services/api/grpc/interceptors/sourceip.go | 3 +- services/api/grpc/parameters.go | 24 +-- services/api/grpc/service.go | 9 +- services/api/service.go | 2 +- services/checker/mock/service.go | 1 + services/checker/permissions.go | 1 + services/checker/static/service.go | 1 + services/fetcher/mem/service.go | 2 + services/lister/mock/service.go | 2 +- services/lister/standard/helpers.go | 1 + services/lister/standard/listaccounts.go | 13 +- services/lister/standard/monitor.go | 2 +- services/lister/standard/parameters.go | 12 +- services/metrics/prometheus/accountmanager.go | 1 + services/metrics/prometheus/checker.go | 1 + services/metrics/prometheus/lister.go | 1 + services/metrics/prometheus/service.go | 2 +- services/metrics/prometheus/signer.go | 1 + services/metrics/prometheus/walletmanager.go | 1 + services/metrics/service.go | 18 +-- services/peers/static/service.go | 3 + services/process/standard/crypto.go | 1 + services/process/standard/generate.go | 28 ++-- services/process/standard/helpers.go | 1 + services/process/standard/parameters.go | 20 +-- services/process/standard/service.go | 36 +++-- services/ruler/golang/parameters.go | 8 +- services/ruler/golang/runner.go | 11 +- services/ruler/golang/runner_test.go | 6 +- services/ruler/service.go | 2 +- services/sender/grpc/service.go | 38 +++-- services/sender/mock/service.go | 5 + services/signer/mock/service.go | 11 +- services/signer/standard/helpers.go | 2 + services/signer/standard/monitor.go | 2 +- services/signer/standard/multisign.go | 20 ++- services/signer/standard/parameters.go | 16 +- .../signer/standard/signbeaconattestation.go | 1 + .../signer/standard/signbeaconattestations.go | 22 ++- .../signer/standard/signbeaconproposal.go | 1 + services/signer/standard/signgeneric.go | 11 ++ services/signer/standard/util.go | 2 + services/unlocker/local/metrics.go | 2 + services/unlocker/local/service.go | 3 + services/walletmanager/mock/service.go | 4 +- services/walletmanager/standard/helpers.go | 1 + services/walletmanager/standard/lock.go | 1 + services/walletmanager/standard/monitor.go | 2 +- services/walletmanager/standard/parameters.go | 16 +- services/walletmanager/standard/unlock.go | 1 + slashingprotection.go | 5 +- testing/daemon/daemon.go | 12 +- testing/logger/capture.go | 1 + testing/mock/account.go | 9 +- testing/mock/net.go | 1 + testing/mock/wallet.go | 11 +- testing/resources/certs.go | 1 + tracing.go | 18 ++- util/bls.go | 1 + util/commit.go | 2 +- util/loggers/badger.go | 9 +- util/loggers/grpcloggerv2.go | 24 +-- util/loggers/jaeger.go | 2 +- util/logging.go | 1 + util/majordomo.go | 1 + util/path.go | 1 + util/scatter.go | 5 +- util/scatter_benchmark_test.go | 2 +- util/scatter_test.go | 6 +- 131 files changed, 719 insertions(+), 445 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 3ba40bf..2237647 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -4,6 +4,16 @@ # This file is not a configuration example, # it contains the exhaustive configuration with explanations of the options. +issues: + # Which files to exclude: they will be analyzed, but issues from them won't be reported. + # There is no need to include all autogenerated files, + # we confidently recognize autogenerated files. + # If it's not, please let us know. + # "/" will be replaced by current OS file path separator to properly work on Windows. + # Default: [] + exclude-files: + - ".*_ssz\\.go$" + # Options for analysis running. run: # The default concurrency value is the number of available CPU. @@ -39,15 +49,6 @@ run: # Default: true # skip-dirs-use-default: false - # Which files to skip: they will be analyzed, but issues from them won't be reported. - # Default value is empty list, - # but there is no need to include all autogenerated files, - # we confidently recognize autogenerated files. - # If it's not please let us know. - # "/" will be replaced by current OS file path separator to properly work on Windows. - skip-files: - - ".*_ssz\\.go$" - # If set we pass it to "go list -mod={option}". From "go help modules": # If invoked with -mod=readonly, the go command is disallowed from the implicit # automatic updating of go.mod described above. Instead, it fails when any changes @@ -68,7 +69,7 @@ run: # Define the Go version limit. # Mainly related to generics support since go1.18. # Default: use Go version from the go.mod file, fallback on the env var `GOVERSION`, fallback on 1.18 - go: '1.19' + # go: '1.19' # output configuration options @@ -108,6 +109,61 @@ linters-settings: lll: line-length: 132 + nlreturn: + # Allow three-line blocks without requiring a newline. + block-size: 3 + + revive: + ignore-generated-header: true + severity: error + confidence: 0.1 + errorCode: 0 + warningCode: 0 + rules: + - name: atomic + - name: blank-imports + - name: comment-spacings + - name: confusing-results + - name: constant-logical-expr + - name: context-as-argument + - name: context-keys-type + - name: datarace + - name: defer + - name: dot-imports + - name: duplicated-imports + - name: early-return + - name: error-strings + - name: errorf + - name: exported + - name: file-header + - name: identical-branches + - name: import-alias-naming + - name: import-shadowing + - name: increment-decrement + - name: indent-error-flow + - name: modifies-value-receiver + - name: range-val-address + - name: range-val-in-closure + - name: range + - name: receiver-naming + - name: string-of-int + - name: superfluous-else + - name: time-equal + - name: time-naming + - name: unchecked-type-assertion + - name: unhandled-error + arguments: + - "fmt.Fprint" + - "fmt.Fprintf" + - "fmt.Fprintln" + - name: unnecessary-stmt + - name: unused-parameter + - name: unused-receiver + - name: use-any + - name: useless-break + - name: var-naming + - name: waitgroup-by-value + stylecheck: checks: [ "all", "-ST1000" ] @@ -135,7 +191,6 @@ linters: - funlen - gci - gochecknoglobals - - gochecknoinits - gocognit - goerr113 - golint @@ -146,8 +201,6 @@ linters: - lll - maintidx - maligned - - nilnil - - nlreturn - nosnakecase - perfsprint - scopelint diff --git a/core/stores.go b/core/stores.go index 24d0764..a71135b 100644 --- a/core/stores.go +++ b/core/stores.go @@ -60,6 +60,7 @@ type S3StoreCredentials struct { func InitStores(ctx context.Context, majordomo majordomo.Service, storeDefinitions []*Store) ([]e2wtypes.Store, error) { if len(storeDefinitions) == 0 { log.Warn().Msg("No stores configured; using default") + return initDefaultStores(), nil } res := make([]e2wtypes.Store, 0, len(storeDefinitions)) @@ -89,6 +90,7 @@ func InitStores(ctx context.Context, majordomo majordomo.Service, storeDefinitio res = append(res, store) } + return res, nil } @@ -113,6 +115,7 @@ func initFilesystemStore(ctx context.Context, opts = append(opts, filesystem.WithLocation(storeDefinition.Location)) } store := filesystem.New(opts...) + return store, nil } @@ -156,6 +159,7 @@ func initS3Store(ctx context.Context, if err != nil { return nil, err } + return store, nil } @@ -166,6 +170,7 @@ func initScratchStore(_ context.Context, log.Trace().Str("name", storeDefinition.Name).Msg("Adding scratch store") store := scratch.New() + return store } @@ -173,5 +178,6 @@ func initScratchStore(_ context.Context, func initDefaultStores() []e2wtypes.Store { res := make([]e2wtypes.Store, 1) res[0] = filesystem.New() + return res } diff --git a/go.mod b/go.mod index 5475d6d..0438d84 100644 --- a/go.mod +++ b/go.mod @@ -5,13 +5,13 @@ go 1.21 toolchain go1.21.6 require ( - github.com/attestantio/go-eth2-client v0.21.1 - github.com/aws/aws-sdk-go v1.51.12 + github.com/attestantio/go-eth2-client v0.21.3 + github.com/aws/aws-sdk-go v1.51.29 github.com/dgraph-io/badger/v2 v2.2007.4 github.com/ferranbt/fastssz v0.1.3 github.com/google/uuid v1.6.0 github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 - github.com/herumi/bls-eth-go-binary v1.34.2 + github.com/herumi/bls-eth-go-binary v1.35.0 github.com/jackc/puddle v1.3.0 github.com/mitchellh/go-homedir v1.1.0 github.com/opentracing/opentracing-go v1.2.0 @@ -34,25 +34,26 @@ require ( github.com/wealdtech/go-eth2-wallet-store-scratch v1.7.2 github.com/wealdtech/go-eth2-wallet-types/v2 v2.11.0 github.com/wealdtech/go-majordomo v1.1.1 - go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 - go.opentelemetry.io/otel v1.24.0 - go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.24.0 - go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.24.0 - go.opentelemetry.io/otel/sdk v1.24.0 - go.opentelemetry.io/otel/trace v1.24.0 - google.golang.org/grpc v1.62.1 + go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.51.0 + go.opentelemetry.io/otel v1.26.0 + go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.26.0 + go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.26.0 + go.opentelemetry.io/otel/sdk v1.26.0 + go.opentelemetry.io/otel/trace v1.26.0 + google.golang.org/grpc v1.63.2 google.golang.org/protobuf v1.33.0 ) require ( - cloud.google.com/go/compute v1.25.1 // indirect - cloud.google.com/go/compute/metadata v0.2.3 // indirect + cloud.google.com/go/auth v0.3.0 // indirect + cloud.google.com/go/auth/oauth2adapt v0.2.2 // indirect + cloud.google.com/go/compute/metadata v0.3.0 // indirect cloud.google.com/go/iam v1.1.7 // indirect cloud.google.com/go/secretmanager v1.12.0 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/cenkalti/backoff/v4 v4.3.0 // indirect github.com/cespare/xxhash v1.1.0 // indirect - github.com/cespare/xxhash/v2 v2.2.0 // indirect + github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/dgraph-io/ristretto v0.1.1 // indirect github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect @@ -63,7 +64,7 @@ require ( github.com/go-logr/logr v1.4.1 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/goccy/go-yaml v1.11.3 // indirect - github.com/golang/glog v1.2.0 // indirect + github.com/golang/glog v1.2.1 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.4 // indirect github.com/golang/snappy v0.0.4 // indirect @@ -73,18 +74,18 @@ require ( github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 // indirect github.com/hashicorp/hcl v1.0.0 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect - github.com/klauspost/compress v1.17.7 // indirect + github.com/klauspost/compress v1.17.8 // indirect github.com/klauspost/cpuid/v2 v2.2.7 // indirect github.com/magiconair/properties v1.8.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/minio/sha256-simd v1.0.1 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect - github.com/pelletier/go-toml/v2 v2.2.0 // indirect + github.com/pelletier/go-toml/v2 v2.2.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect - github.com/prometheus/client_model v0.6.0 // indirect - github.com/prometheus/common v0.51.1 // indirect - github.com/prometheus/procfs v0.13.0 // indirect + github.com/prometheus/client_model v0.6.1 // indirect + github.com/prometheus/common v0.53.0 // indirect + github.com/prometheus/procfs v0.14.0 // indirect github.com/prysmaticlabs/go-bitfield v0.0.0-20240328144219-a1caa50c3a1e // indirect github.com/sagikazarmark/locafero v0.4.0 // indirect github.com/sagikazarmark/slog-shim v0.1.0 // indirect @@ -97,24 +98,23 @@ require ( github.com/wealdtech/go-eth2-util v1.8.2 // indirect github.com/wealdtech/go-indexer v1.1.0 // indirect go.opencensus.io v0.24.0 // indirect - go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect - go.opentelemetry.io/otel/metric v1.24.0 // indirect - go.opentelemetry.io/proto/otlp v1.1.0 // indirect + go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.51.0 // indirect + go.opentelemetry.io/otel/metric v1.26.0 // indirect + go.opentelemetry.io/proto/otlp v1.2.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.21.0 // indirect - golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8 // indirect - golang.org/x/net v0.22.0 // indirect - golang.org/x/oauth2 v0.18.0 // indirect - golang.org/x/sync v0.6.0 // indirect - golang.org/x/sys v0.18.0 // indirect + golang.org/x/crypto v0.22.0 // indirect + golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f // indirect + golang.org/x/net v0.24.0 // indirect + golang.org/x/oauth2 v0.19.0 // indirect + golang.org/x/sync v0.7.0 // indirect + golang.org/x/sys v0.19.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/time v0.5.0 // indirect golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect - google.golang.org/api v0.172.0 // indirect - google.golang.org/appengine v1.6.8 // indirect - google.golang.org/genproto v0.0.0-20240401170217-c3f982113cda // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20240401170217-c3f982113cda // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda // indirect + google.golang.org/api v0.176.1 // indirect + google.golang.org/genproto v0.0.0-20240415180920-8c6c420018be // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20240415180920-8c6c420018be // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240415180920-8c6c420018be // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum index 2231dd3..7376ccb 100644 --- a/go.sum +++ b/go.sum @@ -32,6 +32,10 @@ cloud.google.com/go v0.102.1/go.mod h1:XZ77E9qnTEnrgEOvr4xzfdX5TRo7fB4T2F4O6+34h cloud.google.com/go v0.103.0/go.mod h1:vwLx1nqLrzLX/fpwSMOXmFIqBOyHsvHbnAdbGSJ+mKk= cloud.google.com/go v0.112.2 h1:ZaGT6LiG7dBzi6zNOvVZwacaXlmf3lRqnC4DQzqyRQw= cloud.google.com/go v0.112.2/go.mod h1:iEqjp//KquGIJV/m+Pk3xecgKNhV+ry+vVTsy4TbDms= +cloud.google.com/go/auth v0.3.0 h1:PRyzEpGfx/Z9e8+lHsbkoUVXD0gnu4MNmm7Gp8TQNIs= +cloud.google.com/go/auth v0.3.0/go.mod h1:lBv6NKTWp8E3LPzmO1TbiiRKc4drLOfHsgmlH9ogv5w= +cloud.google.com/go/auth/oauth2adapt v0.2.2 h1:+TTV8aXpjeChS9M+aTtN/TjdQnzJvmzKFt//oWu7HX4= +cloud.google.com/go/auth/oauth2adapt v0.2.2/go.mod h1:wcYjgpZI9+Yu7LyYBg4pqSiaRkfEK3GQcpb7C/uyF1Q= cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= @@ -44,10 +48,8 @@ cloud.google.com/go/compute v1.5.0/go.mod h1:9SMHyhJlzhlkJqrPAc839t2BZFTSk6Jdj6m cloud.google.com/go/compute v1.6.0/go.mod h1:T29tfhtVbq1wvAPo0E3+7vhgmkOYeXjhFvz/FMzPu0s= cloud.google.com/go/compute v1.6.1/go.mod h1:g85FgpzFvNULZ+S8AYq87axRKuf2Kh7deLqV/jJ3thU= cloud.google.com/go/compute v1.7.0/go.mod h1:435lt8av5oL9P3fv1OEzSbSUe+ybHXGMPQHHZWZxy9U= -cloud.google.com/go/compute v1.25.1 h1:ZRpHJedLtTpKgr3RV1Fx23NuaAEN1Zfx9hw1u4aJdjU= -cloud.google.com/go/compute v1.25.1/go.mod h1:oopOIR53ly6viBYxaDhBfJwzUAxf1zE//uf3IB011ls= -cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY= -cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA= +cloud.google.com/go/compute/metadata v0.3.0 h1:Tz+eQXMEqDIKRsmY3cHTL6FVaynIjX2QxYC4trgAKZc= +cloud.google.com/go/compute/metadata v0.3.0/go.mod h1:zFmK7XCadkQkj6TtorcaGlCW1hT1fIilQDwofLpJ20k= cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= cloud.google.com/go/iam v0.3.0/go.mod h1:XzJPvDayI+9zsASAFO68Hk07u3z+f+JrT2xXNdp4bnY= @@ -74,11 +76,11 @@ github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= -github.com/attestantio/go-eth2-client v0.21.1 h1:yvsMd/azPUbxiJzWZhgqfOJJRNF1zLvAJpcBXTHzyh8= -github.com/attestantio/go-eth2-client v0.21.1/go.mod h1:Tb412NpzhsC0sbtpXS4D51y5se6nDkWAi6amsJrqX9c= +github.com/attestantio/go-eth2-client v0.21.3 h1:m4Tzgb5AZkcjvtpmeZSiFireIhdZVK/fSAntJKAH8qM= +github.com/attestantio/go-eth2-client v0.21.3/go.mod h1:vhb0ZoQ6bz0kkoyxVbHDRrZTOJbwlY6udFkwfwrJZTE= github.com/aws/aws-sdk-go v1.44.81/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX4oIKwKHZo= -github.com/aws/aws-sdk-go v1.51.12 h1:DvuhIHZXwnjaR1/Gu19gUe1EGPw4J0qSJw4Qs/5PA8g= -github.com/aws/aws-sdk-go v1.51.12/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= +github.com/aws/aws-sdk-go v1.51.29 h1:18I5kjEcbyJOH4l2EjQyJJG6v3uPjrzwG0uiSD3vJEM= +github.com/aws/aws-sdk-go v1.51.29/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= @@ -88,8 +90,8 @@ github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= -github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= +github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= @@ -169,8 +171,8 @@ github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5x github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/glog v1.2.0 h1:uCdmnmatrKCgMBlM4rMuJZWOkPDqdbZPnrMXDY4gI68= -github.com/golang/glog v1.2.0/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w= +github.com/golang/glog v1.2.1 h1:OptwRhECazUx5ix5TTWC3EZhsZEHWcYWY4FQHTIubm4= +github.com/golang/glog v1.2.1/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -273,8 +275,8 @@ github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= -github.com/herumi/bls-eth-go-binary v1.34.2 h1:yRZQ2r0yE88HYX3nBUvLlw6UEaJQK2iu2JsTkv1/78M= -github.com/herumi/bls-eth-go-binary v1.34.2/go.mod h1:luAnRm3OsMQeokhGzpYmc0ZKwawY7o87PUEP11Z7r7U= +github.com/herumi/bls-eth-go-binary v1.35.0 h1:4CgrKurBK4g0ZMKBdHq5CwK9slYe7Ei+HF+/n6RSkOI= +github.com/herumi/bls-eth-go-binary v1.35.0/go.mod h1:luAnRm3OsMQeokhGzpYmc0ZKwawY7o87PUEP11Z7r7U= github.com/huandu/go-clone v1.6.0 h1:HMo5uvg4wgfiy5FoGOqlFLQED/VGRm2D9Pi8g1FXPGc= github.com/huandu/go-clone v1.6.0/go.mod h1:ReGivhG6op3GYr+UY3lS6mxjKp7MIGTknuU5TbTVaXE= github.com/huandu/go-clone/generic v1.6.0 h1:Wgmt/fUZ28r16F2Y3APotFD59sHk1p78K0XLdbUYN5U= @@ -293,8 +295,8 @@ github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/X github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.12.3/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= -github.com/klauspost/compress v1.17.7 h1:ehO88t2UGzQK66LMdE8tibEd1ErmzZjNEqWkjLAKQQg= -github.com/klauspost/compress v1.17.7/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= +github.com/klauspost/compress v1.17.8 h1:YcnTYrq7MikUT7k0Yb5eceMmALQPYBW/Xltxn0NAMnU= +github.com/klauspost/compress v1.17.8/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM= github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= @@ -329,8 +331,8 @@ github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFSt github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs= github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= -github.com/pelletier/go-toml/v2 v2.2.0 h1:QLgLl2yMN7N+ruc31VynXs1vhMZa7CeHHejIeBAsoHo= -github.com/pelletier/go-toml/v2 v2.2.0/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs= +github.com/pelletier/go-toml/v2 v2.2.1 h1:9TA9+T8+8CUCO2+WYnDLCgrYi9+omqKXyjDtosvtEhg= +github.com/pelletier/go-toml/v2 v2.2.1/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -340,12 +342,12 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH github.com/prometheus/client_golang v1.19.0 h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7kmXYlnfbA6JU= github.com/prometheus/client_golang v1.19.0/go.mod h1:ZRM9uEAypZakd+q/x7+gmsvXdURP+DABIEIjnmDdp+k= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.6.0 h1:k1v3CzpSRUTrKMppY35TLwPvxHqBu0bYgxZzqGIgaos= -github.com/prometheus/client_model v0.6.0/go.mod h1:NTQHnmxFpouOD0DpvP4XujX3CdOAGQPoaGhyTchlyt8= -github.com/prometheus/common v0.51.1 h1:eIjN50Bwglz6a/c3hAgSMcofL3nD+nFQkV6Dd4DsQCw= -github.com/prometheus/common v0.51.1/go.mod h1:lrWtQx+iDfn2mbH5GUzlH9TSHyfZpHkSiG1W7y3sF2Q= -github.com/prometheus/procfs v0.13.0 h1:GqzLlQyfsPbaEHaQkO7tbDlriv/4o5Hudv6OXHGKX7o= -github.com/prometheus/procfs v0.13.0/go.mod h1:cd4PFCR54QLnGKPaKGA6l+cfuNXtht43ZKY6tow0Y1g= +github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= +github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= +github.com/prometheus/common v0.53.0 h1:U2pL9w9nmJwJDa4qqLQ3ZaePJ6ZTwt7cMD3AG3+aLCE= +github.com/prometheus/common v0.53.0/go.mod h1:BrxBKv3FWBIGXw89Mg1AeBq7FSyRzXWI3l3e7W3RN5U= +github.com/prometheus/procfs v0.14.0 h1:Lw4VdGGoKEZilJsayHf0B+9YgLGREba2C6xr+Fdfq6s= +github.com/prometheus/procfs v0.14.0/go.mod h1:XL+Iwz8k8ZabyZfMFHPiilCniixqQarAy5Mu67pHlNQ= github.com/prysmaticlabs/go-bitfield v0.0.0-20240328144219-a1caa50c3a1e h1:ATgOe+abbzfx9kCPeXIW4fiWyDdxlwHw07j8UGhdTd4= github.com/prysmaticlabs/go-bitfield v0.0.0-20240328144219-a1caa50c3a1e/go.mod h1:wmuf/mdK4VMD+jA9ThwcUKjg3a2XWM9cVfFYjDyY4j4= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= @@ -446,7 +448,6 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= @@ -456,25 +457,25 @@ go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= -go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 h1:4Pp6oUg3+e/6M4C0A/3kJ2VYa++dsWVTtGgLVj5xtHg= -go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0/go.mod h1:Mjt1i1INqiaoZOMGR1RIUJN+i3ChKoFRqzrRQhlkbs0= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 h1:jq9TW8u3so/bN+JPT166wjOI6/vQPF6Xe7nMNIltagk= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0/go.mod h1:p8pYQP+m5XfbZm9fxtSKAbM6oIllS7s2AfxrChvc7iw= -go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo= -go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo= -go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.24.0 h1:t6wl9SPayj+c7lEIFgm4ooDBZVb01IhLB4InpomhRw8= -go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.24.0/go.mod h1:iSDOcsnSA5INXzZtwaBPrKp/lWu/V14Dd+llD0oI2EA= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.24.0 h1:Mw5xcxMwlqoJd97vwPxA8isEaIoxsta9/Q51+TTJLGE= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.24.0/go.mod h1:CQNu9bj7o7mC6U7+CA/schKEYakYXWr79ucDHTMGhCM= -go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI= -go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco= -go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucgoDw= -go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg= -go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= -go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= +go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.51.0 h1:A3SayB3rNyt+1S6qpI9mHPkeHTZbD7XILEqWnYZb2l0= +go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.51.0/go.mod h1:27iA5uvhuRNmalO+iEUdVn5ZMj2qy10Mm+XRIpRmyuU= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.51.0 h1:Xs2Ncz0gNihqu9iosIZ5SkBbWo5T8JhhLJFMQL1qmLI= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.51.0/go.mod h1:vy+2G/6NvVMpwGX/NyLqcC41fxepnuKHk16E6IZUcJc= +go.opentelemetry.io/otel v1.26.0 h1:LQwgL5s/1W7YiiRwxf03QGnWLb2HW4pLiAhaA5cZXBs= +go.opentelemetry.io/otel v1.26.0/go.mod h1:UmLkJHUAidDval2EICqBMbnAd0/m2vmpf/dAM+fvFs4= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.26.0 h1:1u/AyyOqAWzy+SkPxDpahCNZParHV8Vid1RnI2clyDE= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.26.0/go.mod h1:z46paqbJ9l7c9fIPCXTqTGwhQZ5XoTIsfeFYWboizjs= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.26.0 h1:Waw9Wfpo/IXzOI8bCB7DIk+0JZcqqsyn1JFnAc+iam8= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.26.0/go.mod h1:wnJIG4fOqyynOnnQF/eQb4/16VlX2EJAHhHgqIqWfAo= +go.opentelemetry.io/otel/metric v1.26.0 h1:7S39CLuY5Jgg9CrnA9HHiEjGMF/X2VHvoXGgSllRz30= +go.opentelemetry.io/otel/metric v1.26.0/go.mod h1:SY+rHOI4cEawI9a7N1A4nIg/nTQXe1ccCNWYOJUrpX4= +go.opentelemetry.io/otel/sdk v1.26.0 h1:Y7bumHf5tAiDlRYFmGqetNcLaVUZmh4iYfmGxtmz7F8= +go.opentelemetry.io/otel/sdk v1.26.0/go.mod h1:0p8MXpqLeJ0pzcszQQN4F0S5FVjBLgypeGSngLsmirs= +go.opentelemetry.io/otel/trace v1.26.0 h1:1ieeAUb4y0TE26jUFrCIXKpTuVK7uJGN9/Z/2LP5sQA= +go.opentelemetry.io/otel/trace v1.26.0/go.mod h1:4iDxvGDQuUkHve82hJJ8UqrwswHYsZuWCBllGV2U2y0= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= -go.opentelemetry.io/proto/otlp v1.1.0 h1:2Di21piLrCqJ3U3eXGCTPHE9R8Nh+0uglSnOyxikMeI= -go.opentelemetry.io/proto/otlp v1.1.0/go.mod h1:GpBHCBWiqvVLDqmHZsoMM3C5ySeKTC7ej/RNTae6MdY= +go.opentelemetry.io/proto/otlp v1.2.0 h1:pVeZGk7nXDC9O2hncA6nHldxEjm6LByfA2aN8IOkz94= +go.opentelemetry.io/proto/otlp v1.2.0/go.mod h1:gGpR8txAl5M03pDhMC79G6SdqNV26naRm/KDsgaHD8A= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= @@ -489,9 +490,8 @@ golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= -golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= +golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30= +golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -502,8 +502,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8 h1:aAcj0Da7eBAtrTp03QXWvm88pSyOt+UgdZw2BFZ+lEw= -golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8/go.mod h1:CQ1k9gNrJ50XIzaKCRR2hssIjF07kZFEiieALBM/ARQ= +golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f h1:99ci1mjWVBWwJiEKYY6jWa4d2nTQVIEhZIptnrVb1XY= +golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f/go.mod h1:/lliqkxwWAhPjf5oSOIJup2XcqJaw8RGS6k3TGEc7GI= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -529,7 +529,6 @@ golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -573,9 +572,8 @@ golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su golang.org/x/net v0.0.0-20220607020251-c690dde0001d/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.0.0-20220617184016-355a448f1bc9/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc= -golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= +golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w= +golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -597,8 +595,8 @@ golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a/go.mod h1:DAh4E804XQdzx2j golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= golang.org/x/oauth2 v0.0.0-20220608161450-d0670ef3b1eb/go.mod h1:jaDAt6Dkxork7LmZnYtzbRWj0W47D86a3TGe0YHBvmE= golang.org/x/oauth2 v0.0.0-20220622183110-fd043fe589d2/go.mod h1:jaDAt6Dkxork7LmZnYtzbRWj0W47D86a3TGe0YHBvmE= -golang.org/x/oauth2 v0.18.0 h1:09qnuIAgzdx1XplqJvW6CQqMCtGZykZWcXzPMPUusvI= -golang.org/x/oauth2 v0.18.0/go.mod h1:Wf7knwG0MPoWIMMBgFlEaSUDaKskp0dCfrlJRJXbBi8= +golang.org/x/oauth2 v0.19.0 h1:9+E/EZBCbTLNrbN35fHv/a/d/mOBatymz1zbtQrXpIg= +golang.org/x/oauth2 v0.19.0/go.mod h1:vYi7skDa1x015PmRRYZ7+s1cWyPgrPiSYRe4rnsexc8= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -611,9 +609,8 @@ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= -golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= +golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -679,15 +676,14 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220610221304-9f5ed59c137d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220624220833-87e55d714810/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220818161305-2296e01440c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= -golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= +golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -699,7 +695,6 @@ golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -761,7 +756,6 @@ golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 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= @@ -813,8 +807,8 @@ google.golang.org/api v0.84.0/go.mod h1:NTsGnUFJMYROtiquksZHBWtHfeMC7iYthki7Eq3p google.golang.org/api v0.85.0/go.mod h1:AqZf8Ep9uZ2pyTvgL+x0D3Zt0eoT9b5E8fmzfu6FO2g= google.golang.org/api v0.86.0/go.mod h1:+Sem1dnrKlrXMR/X0bPnMWyluQe4RsNoYfmNLhOIkzw= google.golang.org/api v0.93.0/go.mod h1:+Sem1dnrKlrXMR/X0bPnMWyluQe4RsNoYfmNLhOIkzw= -google.golang.org/api v0.172.0 h1:/1OcMZGPmW1rX2LCu2CmGUD1KXK1+pfzxotxyRUCCdk= -google.golang.org/api v0.172.0/go.mod h1:+fJZq6QXWfa9pXhnIzsjx4yI22d4aI9ZpLb58gvXjis= +google.golang.org/api v0.176.1 h1:DJSXnV6An+NhJ1J+GWtoF2nHEuqB1VNoTfnIbjNvwD4= +google.golang.org/api v0.176.1/go.mod h1:j2MaSDYcvYV1lkZ1+SMW4IeF90SrEyFA+tluDYWRrFg= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= @@ -822,8 +816,6 @@ google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM= -google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= @@ -907,12 +899,12 @@ google.golang.org/genproto v0.0.0-20220617124728-180714bec0ad/go.mod h1:KEWEmljW google.golang.org/genproto v0.0.0-20220624142145-8cd45d7dbd1f/go.mod h1:KEWEmljWE5zPzLBa/oHl6DaEt9LmfH6WtH1OHIvleBA= google.golang.org/genproto v0.0.0-20220628213854-d9e0b6570c03/go.mod h1:KEWEmljWE5zPzLBa/oHl6DaEt9LmfH6WtH1OHIvleBA= google.golang.org/genproto v0.0.0-20220819174105-e9f053255caa/go.mod h1:dbqgFATTzChvnt+ujMdZwITVAJHFtfyN1qUhDqEiIlk= -google.golang.org/genproto v0.0.0-20240401170217-c3f982113cda h1:wu/KJm9KJwpfHWhkkZGohVC6KRrc1oJNr4jwtQMOQXw= -google.golang.org/genproto v0.0.0-20240401170217-c3f982113cda/go.mod h1:g2LLCvCeCSir/JJSWosk19BR4NVxGqHUC6rxIRsd7Aw= -google.golang.org/genproto/googleapis/api v0.0.0-20240401170217-c3f982113cda h1:b6F6WIV4xHHD0FA4oIyzU6mHWg2WI2X1RBehwa5QN38= -google.golang.org/genproto/googleapis/api v0.0.0-20240401170217-c3f982113cda/go.mod h1:AHcE/gZH76Bk/ROZhQphlRoWo5xKDEtz3eVEO1LfA8c= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda h1:LI5DOvAxUPMv/50agcLLoo+AdWc1irS9Rzz4vPuD1V4= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY= +google.golang.org/genproto v0.0.0-20240415180920-8c6c420018be h1:g4aX8SUFA8V5F4LrSY5EclyGYw1OZN4HS1jTyjB9ZDc= +google.golang.org/genproto v0.0.0-20240415180920-8c6c420018be/go.mod h1:FeSdT5fk+lkxatqJP38MsUicGqHax5cLtmy/6TAuxO4= +google.golang.org/genproto/googleapis/api v0.0.0-20240415180920-8c6c420018be h1:Zz7rLWqp0ApfsR/l7+zSHhY3PMiH2xqgxlfYfAfNpoU= +google.golang.org/genproto/googleapis/api v0.0.0-20240415180920-8c6c420018be/go.mod h1:dvdCTIoAGbkWbcIKBniID56/7XHTt6WfxXNMxuziJ+w= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240415180920-8c6c420018be h1:LG9vZxsWGOmUKieR8wPAUR3u3MpnYFQZROPIMaXh7/A= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240415180920-8c6c420018be/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= @@ -945,8 +937,8 @@ google.golang.org/grpc v1.46.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACu google.golang.org/grpc v1.46.2/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= google.golang.org/grpc v1.47.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= -google.golang.org/grpc v1.62.1 h1:B4n+nfKzOICUXMgyrNd19h/I9oH0L1pizfk1d4zSgTk= -google.golang.org/grpc v1.62.1/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE= +google.golang.org/grpc v1.63.2 h1:MUeiw1B2maTVZthpU5xvASfTh3LDbxHd6IJ6QQVU+xM= +google.golang.org/grpc v1.63.2/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= 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= diff --git a/main.go b/main.go index e55accc..4823ecd 100644 --- a/main.go +++ b/main.go @@ -77,12 +77,12 @@ func main() { zerologger.Fatal().Err(err).Msg("Failed to fetch configuration") } - majordomo, err := util.InitMajordomo(ctx) + majordomoSvc, err := util.InitMajordomo(ctx) if err != nil { log.Fatal().Err(err).Msg("Failed to initialise majordomo") } - exit, exitCode := runCommands(ctx, majordomo) + exit, exitCode := runCommands(ctx, majordomoSvc) if exit { os.Exit(exitCode) } @@ -100,7 +100,7 @@ func main() { initProfiling() - if err := initTracing(ctx, majordomo); err != nil { + if err := initTracing(ctx, majordomoSvc); err != nil { log.Error().Err(err).Msg("Failed to initialise tracing") return } @@ -124,7 +124,7 @@ func main() { setRelease(ctx, ReleaseVersion) setReady(ctx, false) - err = startServices(ctx, majordomo, monitor) + err = startServices(ctx, majordomoSvc, monitor) if err != nil { log.Error().Err(err).Msg("Failed to initialise services") return @@ -232,18 +232,19 @@ func initProfiling() { } } -func runCommands(ctx context.Context, majordomo majordomo.Service) (bool, int) { +func runCommands(ctx context.Context, majordomoSvc majordomo.Service) (bool, int) { if viper.GetBool("version") { fmt.Fprintf(os.Stdout, "%s\n", ReleaseVersion) return true, 0 } if viper.GetBool("show-certificates") { - err := cmd.ShowCertificates(ctx, majordomo) + err := cmd.ShowCertificates(ctx, majordomoSvc) if err != nil { fmt.Fprintf(os.Stderr, "show-certificates failed: %v\n", err) return true, 1 } + return true, 0 } @@ -261,6 +262,7 @@ func runCommands(ctx context.Context, majordomo majordomo.Service) (bool, int) { } } checker.DumpPermissions(permissions) + return true, 0 } @@ -276,44 +278,44 @@ func runCommands(ctx context.Context, majordomo majordomo.Service) (bool, int) { return false, 0 } -func startServices(ctx context.Context, majordomo majordomo.Service, monitor metrics.Service) error { +func startServices(ctx context.Context, majordomoSvc majordomo.Service, monitor metrics.Service) error { var err error - stores, err := initStores(ctx, majordomo) + stores, err := initStores(ctx, majordomoSvc) if err != nil { return err } - unlocker, err := startUnlocker(ctx, majordomo, monitor) + unlockerSvc, err := startUnlocker(ctx, majordomoSvc, monitor) if err != nil { return errors.Wrap(err, "failed to initialise local unlocker") } - checker, err := startChecker(ctx, monitor) + checkerSvc, err := startChecker(ctx, monitor) if err != nil { return errors.Wrap(err, "failed to start permissions checker") } // Set up the fetcher. - fetcher, err := startFetcher(ctx, stores, monitor) + fetcherSvc, err := startFetcher(ctx, stores, monitor) if err != nil { return errors.Wrap(err, "failed to initialise account fetcher") } // Set up the locker. - locker, err := startLocker(ctx, monitor) + lockerSvc, err := startLocker(ctx, monitor) if err != nil { return errors.Wrap(err, "failed to set up locker service") } // Set up the ruler. - ruler, err := startRuler(ctx, locker, monitor) + rulerSvc, err := startRuler(ctx, lockerSvc, monitor) if err != nil { return errors.Wrap(err, "failed to set up ruler service") } // Set up the lister. - lister, err := startLister(ctx, monitor, fetcher, checker, ruler) + listerSvc, err := startLister(ctx, monitor, fetcherSvc, checkerSvc, rulerSvc) if err != nil { return errors.Wrap(err, "failed to initialise lister") } @@ -326,16 +328,16 @@ func startServices(ctx context.Context, majordomo majordomo.Service, monitor met signer, err := standardsigner.New(ctx, standardsigner.WithLogLevel(util.LogLevel("signer")), standardsigner.WithMonitor(signerMonitor), - standardsigner.WithUnlocker(unlocker), - standardsigner.WithChecker(checker), - standardsigner.WithFetcher(fetcher), - standardsigner.WithRuler(ruler), + standardsigner.WithUnlocker(unlockerSvc), + standardsigner.WithChecker(checkerSvc), + standardsigner.WithFetcher(fetcherSvc), + standardsigner.WithRuler(rulerSvc), ) if err != nil { return errors.Wrap(err, "failed to create signer service") } - peers, err := startPeers(ctx, monitor) + peersSvc, err := startPeers(ctx, monitor) if err != nil { return errors.Wrap(err, "failed to start peers service") } @@ -344,17 +346,17 @@ func startServices(ctx context.Context, majordomo majordomo.Service, monitor met if monitor, isMonitor := monitor.(metrics.SenderMonitor); isMonitor { senderMonitor = monitor } - certPEMBlock, err := majordomo.Fetch(ctx, viper.GetString("certificates.server-cert")) + certPEMBlock, err := majordomoSvc.Fetch(ctx, viper.GetString("certificates.server-cert")) if err != nil { return errors.Wrap(err, fmt.Sprintf("failed to obtain server certificate from %s", viper.GetString("certificates.server-cert"))) } - keyPEMBlock, err := majordomo.Fetch(ctx, viper.GetString("certificates.server-key")) + keyPEMBlock, err := majordomoSvc.Fetch(ctx, viper.GetString("certificates.server-key")) if err != nil { return errors.Wrap(err, fmt.Sprintf("failed to obtain server key from %s", viper.GetString("certificates.server-key"))) } var caPEMBlock []byte if viper.GetString("certificates.ca-cert") != "" { - caPEMBlock, err = majordomo.Fetch(ctx, viper.GetString("certificates.ca-cert")) + caPEMBlock, err = majordomoSvc.Fetch(ctx, viper.GetString("certificates.ca-cert")) if err != nil { return errors.Wrap(err, fmt.Sprintf("failed to obtain CA certificate from %s", viper.GetString("certificates.ca-cert"))) } @@ -392,7 +394,7 @@ func startServices(ctx context.Context, majordomo majordomo.Service, monitor met var generationPassphrase []byte if viper.GetString("process.generation-passphrase") != "" { - generationPassphrase, err = majordomo.Fetch(ctx, viper.GetString("process.generation-passphrase")) + generationPassphrase, err = majordomoSvc.Fetch(ctx, viper.GetString("process.generation-passphrase")) if err != nil { return errors.Wrap(err, "failed to obtain account generation passphrase for process") } @@ -401,11 +403,11 @@ func startServices(ctx context.Context, majordomo majordomo.Service, monitor met process, err := standardprocess.New(ctx, standardprocess.WithLogLevel(util.LogLevel("process")), standardprocess.WithMonitor(processMonitor), - standardprocess.WithChecker(checker), - standardprocess.WithFetcher(fetcher), - standardprocess.WithUnlocker(unlocker), + standardprocess.WithChecker(checkerSvc), + standardprocess.WithFetcher(fetcherSvc), + standardprocess.WithUnlocker(unlockerSvc), standardprocess.WithSender(sender), - standardprocess.WithPeers(peers), + standardprocess.WithPeers(peersSvc), standardprocess.WithID(serverID), standardprocess.WithStores(stores), standardprocess.WithGenerationPassphrase(generationPassphrase), @@ -422,10 +424,10 @@ func startServices(ctx context.Context, majordomo majordomo.Service, monitor met accountManager, err := standardaccountmanager.New(ctx, standardaccountmanager.WithLogLevel(util.LogLevel("accountmanager")), standardaccountmanager.WithMonitor(accountManagerMonitor), - standardaccountmanager.WithUnlocker(unlocker), - standardaccountmanager.WithChecker(checker), - standardaccountmanager.WithFetcher(fetcher), - standardaccountmanager.WithRuler(ruler), + standardaccountmanager.WithUnlocker(unlockerSvc), + standardaccountmanager.WithChecker(checkerSvc), + standardaccountmanager.WithFetcher(fetcherSvc), + standardaccountmanager.WithRuler(rulerSvc), standardaccountmanager.WithProcess(process), ) if err != nil { @@ -439,10 +441,10 @@ func startServices(ctx context.Context, majordomo majordomo.Service, monitor met walletManager, err := standardwalletmanager.New(ctx, standardwalletmanager.WithLogLevel(util.LogLevel("walletmanager")), standardwalletmanager.WithMonitor(walletManagerMonitor), - standardwalletmanager.WithUnlocker(unlocker), - standardwalletmanager.WithChecker(checker), - standardwalletmanager.WithFetcher(fetcher), - standardwalletmanager.WithRuler(ruler), + standardwalletmanager.WithUnlocker(unlockerSvc), + standardwalletmanager.WithChecker(checkerSvc), + standardwalletmanager.WithFetcher(fetcherSvc), + standardwalletmanager.WithRuler(rulerSvc), ) if err != nil { return errors.Wrap(err, "failed to create wallet manager service") @@ -457,11 +459,11 @@ func startServices(ctx context.Context, majordomo majordomo.Service, monitor met grpcapi.WithLogLevel(util.LogLevel("api")), grpcapi.WithMonitor(apiMonitor), grpcapi.WithSigner(signer), - grpcapi.WithLister(lister), + grpcapi.WithLister(listerSvc), grpcapi.WithProcess(process), grpcapi.WithAccountManager(accountManager), grpcapi.WithWalletManager(walletManager), - grpcapi.WithPeers(peers), + grpcapi.WithPeers(peersSvc), grpcapi.WithName(viper.GetString("server.name")), grpcapi.WithID(serverID), grpcapi.WithServerCert(certPEMBlock), @@ -491,6 +493,7 @@ func startMonitor(ctx context.Context) (metrics.Service, error) { return nil, errors.Wrap(err, "failed to start metrics service") } } + return monitor, nil } @@ -518,26 +521,33 @@ func initRules(ctx context.Context) (rules.Service, error) { ) } -func initStores(ctx context.Context, majordomo majordomo.Service) ([]e2wtypes.Store, error) { +func initStores(ctx context.Context, majordomoSvc majordomo.Service) ([]e2wtypes.Store, error) { storesCfg := &core.Stores{} if err := viper.Unmarshal(storesCfg); err != nil { return nil, errors.Wrap(err, "failed to obtain stores configuration") } - stores, err := core.InitStores(ctx, majordomo, storesCfg.Stores) + stores, err := core.InitStores(ctx, majordomoSvc, storesCfg.Stores) if err != nil { return nil, errors.Wrap(err, "failed to initialise stores") } if len(stores) == 0 { return nil, errors.New("no stores") } + return stores, nil } -func startUnlocker(ctx context.Context, majordomo majordomo.Service, monitor metrics.Service) (unlocker.Service, error) { +func startUnlocker(ctx context.Context, + majordomoSvc majordomo.Service, + monitor metrics.Service, +) ( + unlocker.Service, + error, +) { // Set up the unlocker. walletPassphrases := make([]string, 0) for _, key := range viper.GetStringSlice("unlocker.wallet-passphrases") { - value, err := majordomo.Fetch(ctx, key) + value, err := majordomoSvc.Fetch(ctx, key) if err != nil { return nil, errors.Wrap(err, "failed to obtain wallet passphrase for unlocker") } @@ -545,12 +555,13 @@ func startUnlocker(ctx context.Context, majordomo majordomo.Service, monitor met } accountPassphrases := make([]string, 0) for _, key := range viper.GetStringSlice("unlocker.account-passphrases") { - value, err := majordomo.Fetch(ctx, key) + value, err := majordomoSvc.Fetch(ctx, key) if err != nil { return nil, errors.Wrap(err, "failed to obtain account passphrase for unlocker") } accountPassphrases = append(accountPassphrases, string(value)) } + return localunlocker.New(ctx, localunlocker.WithLogLevel(util.LogLevel("unlocker")), localunlocker.WithMonitor(monitor), @@ -577,6 +588,7 @@ func startChecker(ctx context.Context, monitor metrics.Service) (checker.Service if monitor, isMonitor := monitor.(metrics.CheckerMonitor); isMonitor { checkerMonitor = monitor } + return staticchecker.New(ctx, staticchecker.WithLogLevel(util.LogLevel("checker")), staticchecker.WithMonitor(checkerMonitor), @@ -589,6 +601,7 @@ func startFetcher(ctx context.Context, stores []e2wtypes.Store, monitor metrics. if monitor, isMonitor := monitor.(metrics.FetcherMonitor); isMonitor { fetcherMonitor = monitor } + return memfetcher.New(ctx, memfetcher.WithLogLevel(util.LogLevel("fetcher")), memfetcher.WithMonitor(fetcherMonitor), @@ -601,14 +614,15 @@ func startLocker(ctx context.Context, monitor metrics.Service) (locker.Service, if monitor, isMonitor := monitor.(metrics.LockerMonitor); isMonitor { lockerMonitor = monitor } + return syncmaplocker.New(ctx, syncmaplocker.WithLogLevel(util.LogLevel("locker")), syncmaplocker.WithMonitor(lockerMonitor), ) } -func startRuler(ctx context.Context, locker locker.Service, monitor metrics.Service) (ruler.Service, error) { - rules, err := initRules(ctx) +func startRuler(ctx context.Context, lockerSvc locker.Service, monitor metrics.Service) (ruler.Service, error) { + rulesSvc, err := initRules(ctx) if err != nil { return nil, errors.Wrap(err, "failed to set up rules") } @@ -616,11 +630,12 @@ func startRuler(ctx context.Context, locker locker.Service, monitor metrics.Serv if monitor, isMonitor := monitor.(metrics.RulerMonitor); isMonitor { rulerMonitor = monitor } + return goruler.New(ctx, goruler.WithLogLevel(util.LogLevel("ruler")), goruler.WithMonitor(rulerMonitor), - goruler.WithLocker(locker), - goruler.WithRules(rules), + goruler.WithLocker(lockerSvc), + goruler.WithRules(rulesSvc), ) } @@ -639,6 +654,7 @@ func startPeers(ctx context.Context, monitor metrics.Service) (peers.Service, er if monitor, isMonitor := monitor.(metrics.PeersMonitor); isMonitor { peersMonitor = monitor } + return staticpeers.New(ctx, staticpeers.WithLogLevel(util.LogLevel("peers")), staticpeers.WithMonitor(peersMonitor), @@ -646,16 +662,25 @@ func startPeers(ctx context.Context, monitor metrics.Service) (peers.Service, er ) } -func startLister(ctx context.Context, monitor metrics.Service, fetcher fetcher.Service, checker checker.Service, ruler ruler.Service) (lister.Service, error) { +func startLister(ctx context.Context, + monitor metrics.Service, + fetcherSvc fetcher.Service, + checkerSvc checker.Service, + rulerSvc ruler.Service, +) ( + lister.Service, + error, +) { var listerMonitor metrics.ListerMonitor if monitor, isMonitor := monitor.(metrics.ListerMonitor); isMonitor { listerMonitor = monitor } + return standardlister.New(ctx, standardlister.WithLogLevel(util.LogLevel("lister")), standardlister.WithMonitor(listerMonitor), - standardlister.WithFetcher(fetcher), - standardlister.WithChecker(checker), - standardlister.WithRuler(ruler), + standardlister.WithFetcher(fetcherSvc), + standardlister.WithChecker(checkerSvc), + standardlister.WithRuler(rulerSvc), ) } diff --git a/metrics.go b/metrics.go index 138879f..899e674 100644 --- a/metrics.go +++ b/metrics.go @@ -43,6 +43,7 @@ func registerMetrics(ctx context.Context, monitor metrics.Service) error { case "null": log.Debug().Msg("no metrics will be generated for this module") } + return nil } diff --git a/rules/mock/createaccount.go b/rules/mock/createaccount.go index 924d89d..e489fce 100644 --- a/rules/mock/createaccount.go +++ b/rules/mock/createaccount.go @@ -20,6 +20,6 @@ import ( ) // OnCreateAccount is called when a request to create an account needs to be approved. -func (s *Service) OnCreateAccount(_ context.Context, _ *rules.ReqMetadata, _ *rules.CreateAccountData) rules.Result { +func (*Service) OnCreateAccount(_ context.Context, _ *rules.ReqMetadata, _ *rules.CreateAccountData) rules.Result { return rules.APPROVED } diff --git a/rules/mock/denying.go b/rules/mock/denying.go index 120560c..3e781ca 100644 --- a/rules/mock/denying.go +++ b/rules/mock/denying.go @@ -27,37 +27,37 @@ func NewDenying() rules.Service { } // Name provides the name of the service. -func (s *denyingService) Name() string { +func (*denyingService) Name() string { return "denying" } // OnCreateAccount is called when a request to create an account needs to be approved. -func (s *denyingService) OnCreateAccount(_ context.Context, _ *rules.ReqMetadata, _ *rules.CreateAccountData) rules.Result { +func (*denyingService) OnCreateAccount(_ context.Context, _ *rules.ReqMetadata, _ *rules.CreateAccountData) rules.Result { return rules.DENIED } // OnListAccounts is called when a request to list accounts needs to be approved. -func (s *denyingService) OnListAccounts(_ context.Context, _ *rules.ReqMetadata, _ *rules.AccessAccountData) rules.Result { +func (*denyingService) OnListAccounts(_ context.Context, _ *rules.ReqMetadata, _ *rules.AccessAccountData) rules.Result { return rules.DENIED } // OnLockAccount is called when a request to lock an account needs to be approved. -func (s *denyingService) OnLockAccount(_ context.Context, _ *rules.ReqMetadata, _ *rules.LockAccountData) rules.Result { +func (*denyingService) OnLockAccount(_ context.Context, _ *rules.ReqMetadata, _ *rules.LockAccountData) rules.Result { return rules.DENIED } // OnLockWallet is called when a request to lock a wallet needs to be approved. -func (s *denyingService) OnLockWallet(_ context.Context, _ *rules.ReqMetadata, _ *rules.LockWalletData) rules.Result { +func (*denyingService) OnLockWallet(_ context.Context, _ *rules.ReqMetadata, _ *rules.LockWalletData) rules.Result { return rules.DENIED } // OnSignBeaconAttestation is called when a request to sign a beacon block attestation needs to be approved. -func (s *denyingService) OnSignBeaconAttestation(_ context.Context, _ *rules.ReqMetadata, _ *rules.SignBeaconAttestationData) rules.Result { +func (*denyingService) OnSignBeaconAttestation(_ context.Context, _ *rules.ReqMetadata, _ *rules.SignBeaconAttestationData) rules.Result { return rules.DENIED } // OnSignBeaconAttestations is called when a request to sign multiple beacon block attestations needs to be approved. -func (s *denyingService) OnSignBeaconAttestations(_ context.Context, +func (*denyingService) OnSignBeaconAttestations(_ context.Context, _ []*rules.ReqMetadata, req []*rules.SignBeaconAttestationData, ) []rules.Result { @@ -70,31 +70,31 @@ func (s *denyingService) OnSignBeaconAttestations(_ context.Context, } // OnSignBeaconProposal is called when a request to sign a beacon block proposal needs to be approved. -func (s *denyingService) OnSignBeaconProposal(_ context.Context, _ *rules.ReqMetadata, _ *rules.SignBeaconProposalData) rules.Result { +func (*denyingService) OnSignBeaconProposal(_ context.Context, _ *rules.ReqMetadata, _ *rules.SignBeaconProposalData) rules.Result { return rules.DENIED } // OnSign is called when a request to sign generic data needs to be approved. -func (s *denyingService) OnSign(_ context.Context, _ *rules.ReqMetadata, _ *rules.SignData) rules.Result { +func (*denyingService) OnSign(_ context.Context, _ *rules.ReqMetadata, _ *rules.SignData) rules.Result { return rules.DENIED } // ExportSlashingProtection exports the slashing protection data. -func (s *denyingService) ExportSlashingProtection(_ context.Context) (map[[48]byte]*rules.SlashingProtection, error) { - return nil, nil +func (*denyingService) ExportSlashingProtection(_ context.Context) (map[[48]byte]*rules.SlashingProtection, error) { + return make(map[[48]byte]*rules.SlashingProtection), nil } // ImportSlashingProtection impports the slashing protection data. -func (s *denyingService) ImportSlashingProtection(_ context.Context, _ map[[48]byte]*rules.SlashingProtection) error { +func (*denyingService) ImportSlashingProtection(_ context.Context, _ map[[48]byte]*rules.SlashingProtection) error { return nil } // OnUnlockAccount is called when a request to unlock an account needs to be approved. -func (s *denyingService) OnUnlockAccount(_ context.Context, _ *rules.ReqMetadata, _ *rules.UnlockAccountData) rules.Result { +func (*denyingService) OnUnlockAccount(_ context.Context, _ *rules.ReqMetadata, _ *rules.UnlockAccountData) rules.Result { return rules.DENIED } // OnUnlockWallet is called when a request to unlock a wallet needs to be approved. -func (s *denyingService) OnUnlockWallet(_ context.Context, _ *rules.ReqMetadata, _ *rules.UnlockWalletData) rules.Result { +func (*denyingService) OnUnlockWallet(_ context.Context, _ *rules.ReqMetadata, _ *rules.UnlockWalletData) rules.Result { return rules.DENIED } diff --git a/rules/mock/failing.go b/rules/mock/failing.go index 4f4f91d..9f063ba 100644 --- a/rules/mock/failing.go +++ b/rules/mock/failing.go @@ -27,37 +27,37 @@ func NewFailing() rules.Service { } // Name provides the name of the service. -func (s *failingService) Name() string { +func (*failingService) Name() string { return "failing" } // OnCreateAccount is called when a request to create an account needs to be approved. -func (s *failingService) OnCreateAccount(_ context.Context, _ *rules.ReqMetadata, _ *rules.CreateAccountData) rules.Result { +func (*failingService) OnCreateAccount(_ context.Context, _ *rules.ReqMetadata, _ *rules.CreateAccountData) rules.Result { return rules.FAILED } // OnListAccounts is called when a request to list accounts needs to be approved. -func (s *failingService) OnListAccounts(_ context.Context, _ *rules.ReqMetadata, _ *rules.AccessAccountData) rules.Result { +func (*failingService) OnListAccounts(_ context.Context, _ *rules.ReqMetadata, _ *rules.AccessAccountData) rules.Result { return rules.FAILED } // OnLockAccount is called when a request to lock an account needs to be approved. -func (s *failingService) OnLockAccount(_ context.Context, _ *rules.ReqMetadata, _ *rules.LockAccountData) rules.Result { +func (*failingService) OnLockAccount(_ context.Context, _ *rules.ReqMetadata, _ *rules.LockAccountData) rules.Result { return rules.FAILED } // OnLockWallet is called when a request to lock a wallet needs to be approved. -func (s *failingService) OnLockWallet(_ context.Context, _ *rules.ReqMetadata, _ *rules.LockWalletData) rules.Result { +func (*failingService) OnLockWallet(_ context.Context, _ *rules.ReqMetadata, _ *rules.LockWalletData) rules.Result { return rules.FAILED } // OnSignBeaconAttestation is called when a request to sign a beacon block attestation needs to be approved. -func (s *failingService) OnSignBeaconAttestation(_ context.Context, _ *rules.ReqMetadata, _ *rules.SignBeaconAttestationData) rules.Result { +func (*failingService) OnSignBeaconAttestation(_ context.Context, _ *rules.ReqMetadata, _ *rules.SignBeaconAttestationData) rules.Result { return rules.FAILED } // OnSignBeaconAttestations is called when a request to sign multiple beacon block attestations needs to be approved. -func (s *failingService) OnSignBeaconAttestations(_ context.Context, +func (*failingService) OnSignBeaconAttestations(_ context.Context, _ []*rules.ReqMetadata, req []*rules.SignBeaconAttestationData, ) []rules.Result { @@ -70,31 +70,31 @@ func (s *failingService) OnSignBeaconAttestations(_ context.Context, } // OnSignBeaconProposal is called when a request to sign a beacon block proposal needs to be approved. -func (s *failingService) OnSignBeaconProposal(_ context.Context, _ *rules.ReqMetadata, _ *rules.SignBeaconProposalData) rules.Result { +func (*failingService) OnSignBeaconProposal(_ context.Context, _ *rules.ReqMetadata, _ *rules.SignBeaconProposalData) rules.Result { return rules.FAILED } // OnSign is called when a request to sign generic data needs to be approved. -func (s *failingService) OnSign(_ context.Context, _ *rules.ReqMetadata, _ *rules.SignData) rules.Result { +func (*failingService) OnSign(_ context.Context, _ *rules.ReqMetadata, _ *rules.SignData) rules.Result { return rules.FAILED } // ExportSlashingProtection exports the slashing protection data. -func (s *failingService) ExportSlashingProtection(_ context.Context) (map[[48]byte]*rules.SlashingProtection, error) { - return nil, nil +func (*failingService) ExportSlashingProtection(_ context.Context) (map[[48]byte]*rules.SlashingProtection, error) { + return make(map[[48]byte]*rules.SlashingProtection), nil } // ImportSlashingProtection impports the slashing protection data. -func (s *failingService) ImportSlashingProtection(_ context.Context, _ map[[48]byte]*rules.SlashingProtection) error { +func (*failingService) ImportSlashingProtection(_ context.Context, _ map[[48]byte]*rules.SlashingProtection) error { return nil } // OnUnlockAccount is called when a request to unlock an account needs to be approved. -func (s *failingService) OnUnlockAccount(_ context.Context, _ *rules.ReqMetadata, _ *rules.UnlockAccountData) rules.Result { +func (*failingService) OnUnlockAccount(_ context.Context, _ *rules.ReqMetadata, _ *rules.UnlockAccountData) rules.Result { return rules.FAILED } // OnUnlockWallet is called when a request to unlock a wallet needs to be approved. -func (s *failingService) OnUnlockWallet(_ context.Context, _ *rules.ReqMetadata, _ *rules.UnlockWalletData) rules.Result { +func (*failingService) OnUnlockWallet(_ context.Context, _ *rules.ReqMetadata, _ *rules.UnlockWalletData) rules.Result { return rules.FAILED } diff --git a/rules/mock/listaccounts.go b/rules/mock/listaccounts.go index 33309e8..c26bbea 100644 --- a/rules/mock/listaccounts.go +++ b/rules/mock/listaccounts.go @@ -20,6 +20,6 @@ import ( ) // OnListAccounts is called when a request to list accounts needs to be approved. -func (s *Service) OnListAccounts(_ context.Context, _ *rules.ReqMetadata, _ *rules.AccessAccountData) rules.Result { +func (*Service) OnListAccounts(_ context.Context, _ *rules.ReqMetadata, _ *rules.AccessAccountData) rules.Result { return rules.APPROVED } diff --git a/rules/mock/lockaccount.go b/rules/mock/lockaccount.go index 62407cc..9bce810 100644 --- a/rules/mock/lockaccount.go +++ b/rules/mock/lockaccount.go @@ -20,6 +20,6 @@ import ( ) // OnLockAccount is called when a request to lock an account needs to be approved. -func (s *Service) OnLockAccount(_ context.Context, _ *rules.ReqMetadata, _ *rules.LockAccountData) rules.Result { +func (*Service) OnLockAccount(_ context.Context, _ *rules.ReqMetadata, _ *rules.LockAccountData) rules.Result { return rules.APPROVED } diff --git a/rules/mock/lockwallet.go b/rules/mock/lockwallet.go index cecc66d..3be694e 100644 --- a/rules/mock/lockwallet.go +++ b/rules/mock/lockwallet.go @@ -20,6 +20,6 @@ import ( ) // OnLockWallet is called when a request to lock a wallet needs to be approved. -func (s *Service) OnLockWallet(_ context.Context, _ *rules.ReqMetadata, _ *rules.LockWalletData) rules.Result { +func (*Service) OnLockWallet(_ context.Context, _ *rules.ReqMetadata, _ *rules.LockWalletData) rules.Result { return rules.APPROVED } diff --git a/rules/mock/service.go b/rules/mock/service.go index ba66fb5..ab7a91a 100644 --- a/rules/mock/service.go +++ b/rules/mock/service.go @@ -22,6 +22,6 @@ func New() *Service { } // Name provides the name of the service. -func (s *Service) Name() string { +func (*Service) Name() string { return "mock" } diff --git a/rules/mock/sign.go b/rules/mock/sign.go index 2545095..3bcc447 100644 --- a/rules/mock/sign.go +++ b/rules/mock/sign.go @@ -20,6 +20,6 @@ import ( ) // OnSign is called when a request to sign generic data needs to be approved. -func (s *Service) OnSign(_ context.Context, _ *rules.ReqMetadata, _ *rules.SignData) rules.Result { +func (*Service) OnSign(_ context.Context, _ *rules.ReqMetadata, _ *rules.SignData) rules.Result { return rules.APPROVED } diff --git a/rules/mock/signbeaconattestation.go b/rules/mock/signbeaconattestation.go index 29c6cc2..85edcb2 100644 --- a/rules/mock/signbeaconattestation.go +++ b/rules/mock/signbeaconattestation.go @@ -20,6 +20,6 @@ import ( ) // OnSignBeaconAttestation is called when a request to sign a beacon block attestation needs to be approved. -func (s *Service) OnSignBeaconAttestation(_ context.Context, _ *rules.ReqMetadata, _ *rules.SignBeaconAttestationData) rules.Result { +func (*Service) OnSignBeaconAttestation(_ context.Context, _ *rules.ReqMetadata, _ *rules.SignBeaconAttestationData) rules.Result { return rules.APPROVED } diff --git a/rules/mock/signbeaconattestations.go b/rules/mock/signbeaconattestations.go index 4a22acd..a4bb202 100644 --- a/rules/mock/signbeaconattestations.go +++ b/rules/mock/signbeaconattestations.go @@ -20,7 +20,7 @@ import ( ) // OnSignBeaconAttestations is called when a request to sign multiple beacon block attestations needs to be approved. -func (s *Service) OnSignBeaconAttestations(_ context.Context, +func (*Service) OnSignBeaconAttestations(_ context.Context, _ []*rules.ReqMetadata, req []*rules.SignBeaconAttestationData, ) []rules.Result { diff --git a/rules/mock/signbeaconproposal.go b/rules/mock/signbeaconproposal.go index 730ca89..61c6c57 100644 --- a/rules/mock/signbeaconproposal.go +++ b/rules/mock/signbeaconproposal.go @@ -20,6 +20,6 @@ import ( ) // OnSignBeaconProposal is called when a request to sign a beacon block proposal needs to be approved. -func (s *Service) OnSignBeaconProposal(_ context.Context, _ *rules.ReqMetadata, _ *rules.SignBeaconProposalData) rules.Result { +func (*Service) OnSignBeaconProposal(_ context.Context, _ *rules.ReqMetadata, _ *rules.SignBeaconProposalData) rules.Result { return rules.APPROVED } diff --git a/rules/mock/slashingprotection.go b/rules/mock/slashingprotection.go index e2df6bd..62ab7ef 100644 --- a/rules/mock/slashingprotection.go +++ b/rules/mock/slashingprotection.go @@ -20,11 +20,11 @@ import ( ) // ExportSlashingProtection exports the slashing protection data. -func (s *Service) ExportSlashingProtection(_ context.Context) (map[[48]byte]*rules.SlashingProtection, error) { - return nil, nil +func (*Service) ExportSlashingProtection(_ context.Context) (map[[48]byte]*rules.SlashingProtection, error) { + return make(map[[48]byte]*rules.SlashingProtection), nil } // ImportSlashingProtection impports the slashing protection data. -func (s *Service) ImportSlashingProtection(_ context.Context, _ map[[48]byte]*rules.SlashingProtection) error { +func (*Service) ImportSlashingProtection(_ context.Context, _ map[[48]byte]*rules.SlashingProtection) error { return nil } diff --git a/rules/mock/unlockaccount.go b/rules/mock/unlockaccount.go index 750ca46..d7019e9 100644 --- a/rules/mock/unlockaccount.go +++ b/rules/mock/unlockaccount.go @@ -20,6 +20,6 @@ import ( ) // OnUnlockAccount is called when a request to unlock an account needs to be approved. -func (s *Service) OnUnlockAccount(_ context.Context, _ *rules.ReqMetadata, _ *rules.UnlockAccountData) rules.Result { +func (*Service) OnUnlockAccount(_ context.Context, _ *rules.ReqMetadata, _ *rules.UnlockAccountData) rules.Result { return rules.APPROVED } diff --git a/rules/mock/unlockwallet.go b/rules/mock/unlockwallet.go index 1da4287..aaee219 100644 --- a/rules/mock/unlockwallet.go +++ b/rules/mock/unlockwallet.go @@ -20,6 +20,6 @@ import ( ) // OnUnlockWallet is called when a request to unlock a wallet needs to be approved. -func (s *Service) OnUnlockWallet(_ context.Context, _ *rules.ReqMetadata, _ *rules.UnlockWalletData) rules.Result { +func (*Service) OnUnlockWallet(_ context.Context, _ *rules.ReqMetadata, _ *rules.UnlockWalletData) rules.Result { return rules.APPROVED } diff --git a/rules/standard/createaccount.go b/rules/standard/createaccount.go index e8d44c8..744bbd8 100644 --- a/rules/standard/createaccount.go +++ b/rules/standard/createaccount.go @@ -21,7 +21,7 @@ import ( ) // OnCreateAccount is called when a request to create an account needs to be approved. -func (s *Service) OnCreateAccount(ctx context.Context, _ *rules.ReqMetadata, _ *rules.CreateAccountData) rules.Result { +func (*Service) OnCreateAccount(ctx context.Context, _ *rules.ReqMetadata, _ *rules.CreateAccountData) rules.Result { span, _ := opentracing.StartSpanFromContext(ctx, "rules.OnCreateAccount") defer span.Finish() diff --git a/rules/standard/listaccounts.go b/rules/standard/listaccounts.go index 0ebbb16..0e20876 100644 --- a/rules/standard/listaccounts.go +++ b/rules/standard/listaccounts.go @@ -21,7 +21,7 @@ import ( ) // OnListAccounts is called when a request to list accounts needs to be approved. -func (s *Service) OnListAccounts(ctx context.Context, _ *rules.ReqMetadata, _ *rules.AccessAccountData) rules.Result { +func (*Service) OnListAccounts(ctx context.Context, _ *rules.ReqMetadata, _ *rules.AccessAccountData) rules.Result { span, _ := opentracing.StartSpanFromContext(ctx, "rules.OnListAccounts") defer span.Finish() diff --git a/rules/standard/lockaccount.go b/rules/standard/lockaccount.go index 0f14bd0..b5b152a 100644 --- a/rules/standard/lockaccount.go +++ b/rules/standard/lockaccount.go @@ -21,7 +21,7 @@ import ( ) // OnLockAccount is called when a request to lock an account needs to be approved. -func (s *Service) OnLockAccount(ctx context.Context, _ *rules.ReqMetadata, _ *rules.LockAccountData) rules.Result { +func (*Service) OnLockAccount(ctx context.Context, _ *rules.ReqMetadata, _ *rules.LockAccountData) rules.Result { span, _ := opentracing.StartSpanFromContext(ctx, "rules.OnLockAccount") defer span.Finish() diff --git a/rules/standard/lockwallet.go b/rules/standard/lockwallet.go index 7934fbe..ca5407b 100644 --- a/rules/standard/lockwallet.go +++ b/rules/standard/lockwallet.go @@ -21,7 +21,7 @@ import ( ) // OnLockWallet is called when a request to lock a wallet needs to be approved. -func (s *Service) OnLockWallet(ctx context.Context, _ *rules.ReqMetadata, _ *rules.LockWalletData) rules.Result { +func (*Service) OnLockWallet(ctx context.Context, _ *rules.ReqMetadata, _ *rules.LockWalletData) rules.Result { span, _ := opentracing.StartSpanFromContext(ctx, "rules.OnLockWallet") defer span.Finish() diff --git a/rules/standard/service.go b/rules/standard/service.go index 5f76f16..a2ba8ed 100644 --- a/rules/standard/service.go +++ b/rules/standard/service.go @@ -71,6 +71,7 @@ func (s *Service) Close(ctx context.Context) error { if s.store.gcTicker != nil { s.store.gcTicker.Stop() } + return s.store.Close(ctx) } diff --git a/rules/standard/signbeaconattestation.go b/rules/standard/signbeaconattestation.go index 8570fa4..972c0ef 100644 --- a/rules/standard/signbeaconattestation.go +++ b/rules/standard/signbeaconattestation.go @@ -42,6 +42,7 @@ func (s *signBeaconAttestationState) Encode() []byte { // Target epoch. binary.LittleEndian.PutUint64(data[9:17], uint64(s.TargetEpoch)) } + return data } @@ -61,6 +62,7 @@ func (s *signBeaconAttestationState) Decode(data []byte) error { default: err = gob.NewDecoder(bytes.NewBuffer(data)).Decode(s) } + return err } @@ -99,13 +101,12 @@ func (s *Service) fetchSignBeaconAttestationState(ctx context.Context, pubKey [] copy(key[len(pubKey):], actionSignBeaconAttestation) data, err := s.store.Fetch(ctx, key) if err != nil { - if err.Error() == "not found" { - // No values; set them to -1. - state.SourceEpoch = -1 - state.TargetEpoch = -1 - } else { + if err.Error() != "not found" { return nil, err } + // No values; set them to -1. + state.SourceEpoch = -1 + state.TargetEpoch = -1 } else { err := state.Decode(data) if err != nil { @@ -113,6 +114,7 @@ func (s *Service) fetchSignBeaconAttestationState(ctx context.Context, pubKey [] } } log.Trace().Int64("source_epoch", state.SourceEpoch).Int64("target_epoch", state.TargetEpoch).Msg("Returning attestation state from store") + return state, nil } @@ -127,5 +129,6 @@ func (s *Service) storeSignBeaconAttestationState(ctx context.Context, pubKey [] } log.Trace().Int64("source_epoch", state.SourceEpoch).Int64("target_epoch", state.TargetEpoch).Msg("Stored attestation state to store") + return nil } diff --git a/rules/standard/signbeaconattestations.go b/rules/standard/signbeaconattestations.go index f031ce8..5a50815 100644 --- a/rules/standard/signbeaconattestations.go +++ b/rules/standard/signbeaconattestations.go @@ -41,6 +41,7 @@ func (s *Service) OnSignBeaconAttestations(ctx context.Context, for i := range res { res[i] = rules.FAILED } + return res } @@ -48,6 +49,7 @@ func (s *Service) OnSignBeaconAttestations(ctx context.Context, if metadata[i] == nil { log.Error().Int("index", i).Msg("Nil metadata entry") res[i] = rules.FAILED + return res } } @@ -56,16 +58,19 @@ func (s *Service) OnSignBeaconAttestations(ctx context.Context, if req[i] == nil { log.Error().Int("index", i).Msg("Nil req entry") res[i] = rules.FAILED + return res } if req[i].Source == nil { log.Error().Int("index", i).Msg("Nil req source") res[i] = rules.FAILED + return res } if req[i].Target == nil { log.Error().Int("index", i).Msg("Nil req target") res[i] = rules.FAILED + return res } } @@ -82,6 +87,7 @@ func (s *Service) OnSignBeaconAttestations(ctx context.Context, for i := range res { res[i] = rules.FAILED } + return res } log.Trace().Dur("elapsed", time.Since(started)).Msg("Fetched states") @@ -98,6 +104,7 @@ func (s *Service) OnSignBeaconAttestations(ctx context.Context, for i := range res { res[i] = rules.FAILED } + return res } log.Trace().Dur("elapsed", time.Since(started)).Msg("Stored states") @@ -118,12 +125,13 @@ func (s *Service) fetchSignBeaconAttestationStates(ctx context.Context, pubKeys return states, nil } -func (s *Service) runSignBeaconAttestationChecks(_ context.Context, metadata *rules.ReqMetadata, req *rules.SignBeaconAttestationData, state *signBeaconAttestationState) rules.Result { +func (*Service) runSignBeaconAttestationChecks(_ context.Context, metadata *rules.ReqMetadata, req *rules.SignBeaconAttestationData, state *signBeaconAttestationState) rules.Result { log := log.With().Str("client", metadata.Client).Str("account", metadata.Account).Str("rule", "sign beacon attestation").Logger() // The request must have the appropriate domain. if !bytes.Equal(req.Domain[0:4], e2types.DomainBeaconAttester[:]) { log.Warn().Str("domain", fmt.Sprintf("%#x", req.Domain)).Msg("Not approving non-beacon attestation due to incorrect domain") + return rules.DENIED } @@ -136,6 +144,7 @@ func (s *Service) runSignBeaconAttestationChecks(_ context.Context, metadata *ru Uint64("sourceEpoch", sourceEpoch). Uint64("targetEpoch", targetEpoch). Msg("Request target epoch equal to or lower than request source epoch") + return rules.DENIED } @@ -146,6 +155,7 @@ func (s *Service) runSignBeaconAttestationChecks(_ context.Context, metadata *ru Int64("previousTargetEpoch", state.TargetEpoch). Uint64("targetEpoch", targetEpoch). Msg("Request target epoch equal to or lower than previous signed target epoch") + return rules.DENIED } } @@ -157,6 +167,7 @@ func (s *Service) runSignBeaconAttestationChecks(_ context.Context, metadata *ru Int64("previousSourceEpoch", state.SourceEpoch). Uint64("sourceEpoch", sourceEpoch). Msg("Request source epoch lower than previous signed source epoch") + return rules.DENIED } } diff --git a/rules/standard/signbeaconproposal.go b/rules/standard/signbeaconproposal.go index 0c29551..ca8a529 100644 --- a/rules/standard/signbeaconproposal.go +++ b/rules/standard/signbeaconproposal.go @@ -40,6 +40,7 @@ func (s *signBeaconProposalState) Encode() []byte { // Slot. binary.LittleEndian.PutUint64(data[1:9], uint64(s.Slot)) } + return data } @@ -58,6 +59,7 @@ func (s *signBeaconProposalState) Decode(data []byte) error { default: err = gob.NewDecoder(bytes.NewBuffer(data)).Decode(s) } + return err } @@ -70,6 +72,7 @@ func (s *Service) OnSignBeaconProposal(ctx context.Context, metadata *rules.ReqM // The request must have the appropriate domain. if !bytes.Equal(req.Domain[0:4], e2types.DomainBeaconProposer[:]) { log.Warn().Msg("Not approving non-beacon proposal due to incorrect domain") + return rules.DENIED } @@ -77,6 +80,7 @@ func (s *Service) OnSignBeaconProposal(ctx context.Context, metadata *rules.ReqM state, err := s.fetchSignBeaconProposalState(ctx, metadata.PubKey) if err != nil { log.Error().Err(err).Msg("Failed to fetch state for beacon proposal") + return rules.FAILED } slot := req.Slot @@ -88,6 +92,7 @@ func (s *Service) OnSignBeaconProposal(ctx context.Context, metadata *rules.ReqM Int64("previousSlot", state.Slot). Uint64("slot", slot). Msg("Request slot equal to or lower than previous signed slot") + return rules.DENIED } } @@ -95,6 +100,7 @@ func (s *Service) OnSignBeaconProposal(ctx context.Context, metadata *rules.ReqM state.Slot = int64(slot) if err = s.storeSignBeaconProposalState(ctx, metadata.PubKey, state); err != nil { log.Error().Err(err).Msg("Failed to store state for beacon proposal") + return rules.FAILED } @@ -108,19 +114,20 @@ func (s *Service) fetchSignBeaconProposalState(ctx context.Context, pubKey []byt copy(key[len(pubKey):], actionSignBeaconProposal) data, err := s.store.Fetch(ctx, key) if err != nil { - if err.Error() == "not found" { - // No value; set it to -1. - state.Slot = -1 - } else { + if err.Error() != "not found" { return nil, err } + // No value; set it to -1. + state.Slot = -1 } else { err = state.Decode(data) if err != nil { return nil, errors.Wrap(err, "failed to decode state") } } + log.Trace().Int64("slot", state.Slot).Msg("Returning proposal state from store") + return state, nil } @@ -135,5 +142,6 @@ func (s *Service) storeSignBeaconProposalState(ctx context.Context, pubKey []byt } log.Trace().Int64("slot", state.Slot).Msg("Stored proposal state to store") + return nil } diff --git a/rules/standard/slashingprotection.go b/rules/standard/slashingprotection.go index aeffd56..bec5018 100644 --- a/rules/standard/slashingprotection.go +++ b/rules/standard/slashingprotection.go @@ -92,5 +92,6 @@ func (s *Service) ImportSlashingProtection(ctx context.Context, protection map[[ } } } + return nil } diff --git a/rules/standard/storage.go b/rules/standard/storage.go index c128005..1d9c52d 100644 --- a/rules/standard/storage.go +++ b/rules/standard/storage.go @@ -100,17 +100,20 @@ func (s *Store) FetchAll(_ context.Context) (map[[49]byte][]byte, error) { value := make([]byte, len(v)) copy(value, v) items[key] = value + return nil }) if err != nil { return err } } + return nil }) if err != nil { return nil, err } + return items, nil } @@ -134,6 +137,7 @@ func (s *Store) Fetch(ctx context.Context, key []byte) ([]byte, error) { err = item.Value(func(val []byte) error { value = make([]byte, len(val)) copy(value, val) + return nil }) if err != nil { @@ -145,6 +149,7 @@ func (s *Store) Fetch(ctx context.Context, key []byte) ([]byte, error) { if err != nil { return nil, err } + return value, nil } diff --git a/rules/standard/unlockaccount.go b/rules/standard/unlockaccount.go index 3815694..d369094 100644 --- a/rules/standard/unlockaccount.go +++ b/rules/standard/unlockaccount.go @@ -21,7 +21,7 @@ import ( ) // OnUnlockAccount is called when a request to unlock an account needs to be approved. -func (s *Service) OnUnlockAccount(ctx context.Context, _ *rules.ReqMetadata, _ *rules.UnlockAccountData) rules.Result { +func (*Service) OnUnlockAccount(ctx context.Context, _ *rules.ReqMetadata, _ *rules.UnlockAccountData) rules.Result { span, _ := opentracing.StartSpanFromContext(ctx, "rules.OnUnlockAccount") defer span.Finish() diff --git a/rules/standard/unlockwallet.go b/rules/standard/unlockwallet.go index 7c044d5..dbadd53 100644 --- a/rules/standard/unlockwallet.go +++ b/rules/standard/unlockwallet.go @@ -21,7 +21,7 @@ import ( ) // OnUnlockWallet is called when a request to unlock a wallet needs to be approved. -func (s *Service) OnUnlockWallet(ctx context.Context, _ *rules.ReqMetadata, _ *rules.UnlockWalletData) rules.Result { +func (*Service) OnUnlockWallet(ctx context.Context, _ *rules.ReqMetadata, _ *rules.UnlockWalletData) rules.Result { span, _ := opentracing.StartSpanFromContext(ctx, "rules.OnUnlockWallet") defer span.Finish() diff --git a/services/accountmanager/mock/service.go b/services/accountmanager/mock/service.go index fee0319..49cdddb 100644 --- a/services/accountmanager/mock/service.go +++ b/services/accountmanager/mock/service.go @@ -29,7 +29,7 @@ func New() *Service { } // Generate generates a new account. -func (s *Service) Generate(_ context.Context, +func (*Service) Generate(_ context.Context, _ *checker.Credentials, _ string, _ []byte, @@ -58,7 +58,7 @@ func (s *Service) Generate(_ context.Context, } // Unlock unlocks an account. -func (s *Service) Unlock(_ context.Context, +func (*Service) Unlock(_ context.Context, _ *checker.Credentials, _ string, _ []byte, @@ -70,7 +70,7 @@ func (s *Service) Unlock(_ context.Context, } // Lock locks an account. -func (s *Service) Lock(_ context.Context, +func (*Service) Lock(_ context.Context, _ *checker.Credentials, _ string, ) ( diff --git a/services/accountmanager/standard/generate.go b/services/accountmanager/standard/generate.go index 772708b..b231450 100644 --- a/services/accountmanager/standard/generate.go +++ b/services/accountmanager/standard/generate.go @@ -105,5 +105,6 @@ func (s *Service) Generate(ctx context.Context, } s.monitor.AccountManagerCompleted(started, "generate", core.ResultSucceeded) + return core.ResultSucceeded, pubKey, endpoints, nil } diff --git a/services/accountmanager/standard/helpers.go b/services/accountmanager/standard/helpers.go index 24129f2..abcc290 100644 --- a/services/accountmanager/standard/helpers.go +++ b/services/accountmanager/standard/helpers.go @@ -69,5 +69,6 @@ func (s *Service) checkAccess(ctx context.Context, credentials *checker.Credenti if s.checker.Check(ctx, credentials, accountName, action) { return core.ResultSucceeded } + return core.ResultDenied } diff --git a/services/accountmanager/standard/lock.go b/services/accountmanager/standard/lock.go index 024824f..ca1c1af 100644 --- a/services/accountmanager/standard/lock.go +++ b/services/accountmanager/standard/lock.go @@ -99,5 +99,6 @@ func (s *Service) Lock(ctx context.Context, log.Trace().Str("result", "succeeded").Msg("Success") s.monitor.AccountManagerCompleted(started, "lock", core.ResultSucceeded) + return core.ResultSucceeded, nil } diff --git a/services/accountmanager/standard/monitor.go b/services/accountmanager/standard/monitor.go index 73c6d65..f4eeae6 100644 --- a/services/accountmanager/standard/monitor.go +++ b/services/accountmanager/standard/monitor.go @@ -24,5 +24,5 @@ import ( type noopMonitor struct{} // AccountManagerCompleted is called when an account manager process has completed. -func (n *noopMonitor) AccountManagerCompleted(_ time.Time, _ string, _ core.Result) { +func (*noopMonitor) AccountManagerCompleted(_ time.Time, _ string, _ core.Result) { } diff --git a/services/accountmanager/standard/parameters.go b/services/accountmanager/standard/parameters.go index 1826cba..5bb5cb4 100644 --- a/services/accountmanager/standard/parameters.go +++ b/services/accountmanager/standard/parameters.go @@ -60,37 +60,37 @@ func WithMonitor(monitor metrics.AccountManagerMonitor) Parameter { } // WithChecker sets the access checker for this module. -func WithChecker(checker checker.Service) Parameter { +func WithChecker(service checker.Service) Parameter { return parameterFunc(func(p *parameters) { - p.checker = checker + p.checker = service }) } // WithRuler sets the ruler for this module. -func WithRuler(ruler ruler.Service) Parameter { +func WithRuler(service ruler.Service) Parameter { return parameterFunc(func(p *parameters) { - p.ruler = ruler + p.ruler = service }) } // WithUnlocker sets the account unlocker for this module. -func WithUnlocker(unlocker unlocker.Service) Parameter { +func WithUnlocker(service unlocker.Service) Parameter { return parameterFunc(func(p *parameters) { - p.unlocker = unlocker + p.unlocker = service }) } // WithProcess sets the process manager for this module. -func WithProcess(process process.Service) Parameter { +func WithProcess(service process.Service) Parameter { return parameterFunc(func(p *parameters) { - p.process = process + p.process = service }) } // WithFetcher sets the account fetcher for this module. -func WithFetcher(fetcher fetcher.Service) Parameter { +func WithFetcher(service fetcher.Service) Parameter { return parameterFunc(func(p *parameters) { - p.fetcher = fetcher + p.fetcher = service }) } diff --git a/services/accountmanager/standard/unlock.go b/services/accountmanager/standard/unlock.go index 9af29d5..aad3fab 100644 --- a/services/accountmanager/standard/unlock.go +++ b/services/accountmanager/standard/unlock.go @@ -97,5 +97,6 @@ func (s *Service) Unlock(ctx context.Context, log.Trace().Str("result", "succeeded").Msg("Success") s.monitor.AccountManagerCompleted(started, "unlock", core.ResultSucceeded) + return core.ResultSucceeded, nil } diff --git a/services/api/grpc/handlers/accountmanager/generate.go b/services/api/grpc/handlers/accountmanager/generate.go index 037d90d..c9567df 100644 --- a/services/api/grpc/handlers/accountmanager/generate.go +++ b/services/api/grpc/handlers/accountmanager/generate.go @@ -42,6 +42,7 @@ func (h *Handler) Generate(ctx context.Context, req *pb.GenerateRequest) (*pb.Ge log.Error().Err(err).Msg("Generate attempt resulted in error") res.State = pb.ResponseState_FAILED res.Message = err.Error() + return res, nil } diff --git a/services/api/grpc/handlers/accountmanager/parameters.go b/services/api/grpc/handlers/accountmanager/parameters.go index fc3cb55..bf4a4b0 100644 --- a/services/api/grpc/handlers/accountmanager/parameters.go +++ b/services/api/grpc/handlers/accountmanager/parameters.go @@ -46,16 +46,16 @@ func WithLogLevel(logLevel zerolog.Level) Parameter { } // WithAccountManager sets the account manager service for the module. -func WithAccountManager(accountManager accountmanager.Service) Parameter { +func WithAccountManager(service accountmanager.Service) Parameter { return parameterFunc(func(p *parameters) { - p.accountManager = accountManager + p.accountManager = service }) } // WithProcess sets the process service for the module. -func WithProcess(process process.Service) Parameter { +func WithProcess(service process.Service) Parameter { return parameterFunc(func(p *parameters) { - p.process = process + p.process = service }) } diff --git a/services/api/grpc/handlers/helpers.go b/services/api/grpc/handlers/helpers.go index 1b19385..3a15c68 100644 --- a/services/api/grpc/handlers/helpers.go +++ b/services/api/grpc/handlers/helpers.go @@ -33,5 +33,6 @@ func GenerateCredentials(ctx context.Context) *checker.Credentials { if ip, ok := ctx.Value(&interceptors.ExternalIP{}).(string); ok { res.IP = ip } + return res } diff --git a/services/api/grpc/handlers/lister/listaccounts.go b/services/api/grpc/handlers/lister/listaccounts.go index afc04da..258c2b7 100644 --- a/services/api/grpc/handlers/lister/listaccounts.go +++ b/services/api/grpc/handlers/lister/listaccounts.go @@ -105,5 +105,6 @@ func (h *Handler) ListAccounts(ctx context.Context, req *pb.ListAccountsRequest) res.State = pb.ResponseState_SUCCEEDED log.Trace().Int("accounts", len(res.GetAccounts())).Int("distributedAccounts", len(res.GetDistributedAccounts())).Msg("Success") + return res, nil } diff --git a/services/api/grpc/handlers/lister/parameters.go b/services/api/grpc/handlers/lister/parameters.go index 6896709..b2fcdd0 100644 --- a/services/api/grpc/handlers/lister/parameters.go +++ b/services/api/grpc/handlers/lister/parameters.go @@ -44,9 +44,9 @@ func WithLogLevel(logLevel zerolog.Level) Parameter { } // WithLister sets the lister service for the module. -func WithLister(lister lister.Service) Parameter { +func WithLister(service lister.Service) Parameter { return parameterFunc(func(p *parameters) { - p.lister = lister + p.lister = service }) } diff --git a/services/api/grpc/handlers/receiver/abort.go b/services/api/grpc/handlers/receiver/abort.go index 3e4bdd1..e32913e 100644 --- a/services/api/grpc/handlers/receiver/abort.go +++ b/services/api/grpc/handlers/receiver/abort.go @@ -27,15 +27,16 @@ func (h *Handler) Abort(ctx context.Context, req *pb.AbortRequest) (*emptypb.Emp senderID := h.senderID(ctx) if senderID == 0 { log.Warn().Interface("client", ctx.Value(&interceptors.ClientName{})).Msg("Failed to obtain participant ID of sender") - return nil, errors.New("Unknown sender") + return nil, errors.New("unknown sender") } log.Debug().Uint64("sender_id", senderID).Msg("Aborting as per request from sender") if err := h.process.OnAbort(ctx, senderID, req.GetAccount()); err != nil { log.Error().Err(err).Msg("Failed to abort distributed key generation") - return nil, errors.New("Failed") + return nil, errors.New("failed") } log.Trace().Msg("Completed abort successfully") + return &emptypb.Empty{}, nil } diff --git a/services/api/grpc/handlers/receiver/commit.go b/services/api/grpc/handlers/receiver/commit.go index 487e355..29f2dad 100644 --- a/services/api/grpc/handlers/receiver/commit.go +++ b/services/api/grpc/handlers/receiver/commit.go @@ -26,7 +26,7 @@ func (h *Handler) Commit(ctx context.Context, req *pb.CommitRequest) (*pb.Commit senderID := h.senderID(ctx) if senderID == 0 { log.Warn().Interface("client", ctx.Value(&interceptors.ClientName{})).Msg("Failed to obtain participant ID of sender") - return nil, errors.New("Unknown sender") + return nil, errors.New("unknown sender") } log.Trace().Uint64("sender_id", senderID).Msg("Committing as per request from sender") @@ -42,5 +42,6 @@ func (h *Handler) Commit(ctx context.Context, req *pb.CommitRequest) (*pb.Commit } log.Trace().Msg("Completed commit successfully") + return res, nil } diff --git a/services/api/grpc/handlers/receiver/contribute.go b/services/api/grpc/handlers/receiver/contribute.go index e8b5ed9..edadef9 100644 --- a/services/api/grpc/handlers/receiver/contribute.go +++ b/services/api/grpc/handlers/receiver/contribute.go @@ -27,7 +27,7 @@ func (h *Handler) Contribute(ctx context.Context, req *pb.ContributeRequest) (*p senderID := h.senderID(ctx) if senderID == 0 { log.Warn().Interface("client", ctx.Value(&interceptors.ClientName{})).Msg("Failed to obtain participant ID of sender") - return nil, errors.New("Unknown sender") + return nil, errors.New("unknown sender") } log := log.With().Str("account", req.GetAccount()).Uint64("peer", senderID).Logger() @@ -35,14 +35,14 @@ func (h *Handler) Contribute(ctx context.Context, req *pb.ContributeRequest) (*p secret := bls.SecretKey{} if err := secret.Deserialize(req.GetSecret()); err != nil { log.Warn().Err(err).Msg("Received secret key is invalid") - return nil, errors.New("Invalid secret key") + return nil, errors.New("invalid secret key") } vVec := make([]bls.PublicKey, len(req.GetVerificationVector())) for i, key := range req.GetVerificationVector() { vVec[i] = bls.PublicKey{} if err := vVec[i].Deserialize(key); err != nil { log.Warn().Err(err).Msg("Received verification vector is invalid") - return nil, errors.Wrap(err, "Invalid verification vector") + return nil, errors.Wrap(err, "invalid verification vector") } } log.Trace().Msg("Received valid contribution") @@ -50,7 +50,7 @@ func (h *Handler) Contribute(ctx context.Context, req *pb.ContributeRequest) (*p retSecret, retVVec, err := h.process.OnContribute(ctx, senderID, req.GetAccount(), secret, vVec) if err != nil { log.Error().Err(err).Msg("Handle/generate contribution failed") - return nil, errors.Wrap(err, "Failed to handle contribution") + return nil, errors.Wrap(err, "failed to handle contribution") } resVVec := make([][]byte, len(retVVec)) diff --git a/services/api/grpc/handlers/receiver/execute.go b/services/api/grpc/handlers/receiver/execute.go index b0b3365..70a12ad 100644 --- a/services/api/grpc/handlers/receiver/execute.go +++ b/services/api/grpc/handlers/receiver/execute.go @@ -27,7 +27,7 @@ func (h *Handler) Execute(ctx context.Context, req *pb.ExecuteRequest) (*emptypb senderID := h.senderID(ctx) if senderID == 0 { log.Warn().Interface("client", ctx.Value(&interceptors.ClientName{})).Msg("Failed to obtain participant ID of sender") - return nil, errors.New("Unknown sender") + return nil, errors.New("unknown sender") } log.Trace().Uint64("sender_id", senderID).Msg("Executing as per request from sender") @@ -38,5 +38,6 @@ func (h *Handler) Execute(ctx context.Context, req *pb.ExecuteRequest) (*emptypb } log.Trace().Msg("Completed execution successfully") + return &emptypb.Empty{}, nil } diff --git a/services/api/grpc/handlers/receiver/helpers.go b/services/api/grpc/handlers/receiver/helpers.go index 382d96e..807362a 100644 --- a/services/api/grpc/handlers/receiver/helpers.go +++ b/services/api/grpc/handlers/receiver/helpers.go @@ -29,5 +29,6 @@ func (h *Handler) senderID(ctx context.Context) uint64 { } } } + return senderID } diff --git a/services/api/grpc/handlers/receiver/parameters.go b/services/api/grpc/handlers/receiver/parameters.go index 71e74e5..ff94e6d 100644 --- a/services/api/grpc/handlers/receiver/parameters.go +++ b/services/api/grpc/handlers/receiver/parameters.go @@ -46,16 +46,16 @@ func WithLogLevel(logLevel zerolog.Level) Parameter { } // WithPeers sets the peers service for the handler. -func WithPeers(peers peers.Service) Parameter { +func WithPeers(service peers.Service) Parameter { return parameterFunc(func(p *parameters) { - p.peers = peers + p.peers = service }) } // WithProcess sets the process service for the handler. -func WithProcess(process process.Service) Parameter { +func WithProcess(service process.Service) Parameter { return parameterFunc(func(p *parameters) { - p.process = process + p.process = service }) } diff --git a/services/api/grpc/handlers/receiver/prepare.go b/services/api/grpc/handlers/receiver/prepare.go index ffe8267..fe644dc 100644 --- a/services/api/grpc/handlers/receiver/prepare.go +++ b/services/api/grpc/handlers/receiver/prepare.go @@ -44,9 +44,10 @@ func (h *Handler) Prepare(ctx context.Context, req *pb.PrepareRequest) (*emptypb err := h.process.OnPrepare(ctx, senderID, req.GetAccount(), req.GetPassphrase(), req.GetThreshold(), participants) if err != nil { log.Error().Err(err).Msg("Failed to prepare for distributed key generation") - return nil, errors.New("Failed to prepare") + return nil, errors.New("failed to prepare") } log.Trace().Msg("Completed preparation successfully") + return &emptypb.Empty{}, nil } diff --git a/services/api/grpc/handlers/signer/multisign.go b/services/api/grpc/handlers/signer/multisign.go index 1c7c92f..4e593ee 100644 --- a/services/api/grpc/handlers/signer/multisign.go +++ b/services/api/grpc/handlers/signer/multisign.go @@ -31,12 +31,14 @@ func (h *Handler) Multisign(ctx context.Context, req *pb.MultisignRequest) (*pb. log.Warn().Str("result", "denied").Msg("Request not specified") res.Responses = make([]*pb.SignResponse, 1) res.Responses[0] = &pb.SignResponse{State: pb.ResponseState_DENIED} + return res, nil } if len(req.GetRequests()) == 0 { log.Warn().Str("result", "denied").Msg("Request empty") res.Responses = make([]*pb.SignResponse, 1) res.Responses[0] = &pb.SignResponse{State: pb.ResponseState_DENIED} + return res, nil } @@ -49,16 +51,19 @@ func (h *Handler) Multisign(ctx context.Context, req *pb.MultisignRequest) (*pb. if request == nil { log.Warn().Str("result", "denied").Msg("Request nil") res.Responses[i].State = pb.ResponseState_FAILED + return res, nil } if request.GetData() == nil { log.Warn().Str("result", "denied").Msg("Request data not specified") res.Responses[i].State = pb.ResponseState_DENIED + return res, nil } if request.GetDomain() == nil { log.Warn().Str("result", "denied").Msg("Request domain not specified") res.Responses[i].State = pb.ResponseState_DENIED + return res, nil } } diff --git a/services/api/grpc/handlers/signer/parameters.go b/services/api/grpc/handlers/signer/parameters.go index 8e9b376..29e8e1d 100644 --- a/services/api/grpc/handlers/signer/parameters.go +++ b/services/api/grpc/handlers/signer/parameters.go @@ -44,9 +44,9 @@ func WithLogLevel(logLevel zerolog.Level) Parameter { } // WithSigner sets the signer service for the module. -func WithSigner(signer signer.Service) Parameter { +func WithSigner(service signer.Service) Parameter { return parameterFunc(func(p *parameters) { - p.signer = signer + p.signer = service }) } diff --git a/services/api/grpc/handlers/signer/sign.go b/services/api/grpc/handlers/signer/sign.go index 7a0cedd..0ea8e20 100644 --- a/services/api/grpc/handlers/signer/sign.go +++ b/services/api/grpc/handlers/signer/sign.go @@ -62,5 +62,6 @@ func (h *Handler) Sign(ctx context.Context, req *pb.SignRequest) (*pb.SignRespon } log.Trace().Str("result", "succeeded").Msg("Success") + return res, nil } diff --git a/services/api/grpc/handlers/signer/signbeaconattestation.go b/services/api/grpc/handlers/signer/signbeaconattestation.go index f4c9f02..4879420 100644 --- a/services/api/grpc/handlers/signer/signbeaconattestation.go +++ b/services/api/grpc/handlers/signer/signbeaconattestation.go @@ -88,5 +88,6 @@ func (h *Handler) SignBeaconAttestation(ctx context.Context, req *pb.SignBeaconA } log.Trace().Str("result", "succeeded").Msg("Success") + return res, nil } diff --git a/services/api/grpc/handlers/signer/signbeaconattestations.go b/services/api/grpc/handlers/signer/signbeaconattestations.go index f8bbcc2..f092888 100644 --- a/services/api/grpc/handlers/signer/signbeaconattestations.go +++ b/services/api/grpc/handlers/signer/signbeaconattestations.go @@ -31,12 +31,14 @@ func (h *Handler) SignBeaconAttestations(ctx context.Context, req *pb.SignBeacon log.Warn().Str("result", "denied").Msg("Request not specified") res.Responses = make([]*pb.SignResponse, 1) res.Responses[0] = &pb.SignResponse{State: pb.ResponseState_DENIED} + return res, nil } if len(req.GetRequests()) == 0 { log.Warn().Str("result", "denied").Msg("Request empty") res.Responses = make([]*pb.SignResponse, 1) res.Responses[0] = &pb.SignResponse{State: pb.ResponseState_DENIED} + return res, nil } @@ -49,21 +51,25 @@ func (h *Handler) SignBeaconAttestations(ctx context.Context, req *pb.SignBeacon if request == nil { log.Warn().Str("result", "denied").Msg("Request nil") res.Responses[i].State = pb.ResponseState_FAILED + return res, nil } if request.GetData() == nil { log.Warn().Str("result", "denied").Msg("Request missing data") res.Responses[i].State = pb.ResponseState_DENIED + return res, nil } if request.GetData().GetSource() == nil { log.Warn().Str("result", "denied").Msg("Request source checkpoint not specified") res.Responses[i].State = pb.ResponseState_DENIED + return res, nil } if request.GetData().GetTarget() == nil { log.Warn().Str("result", "denied").Msg("Request target checkpoint not specified") res.Responses[i].State = pb.ResponseState_DENIED + return res, nil } } diff --git a/services/api/grpc/handlers/signer/signbeaconproposal.go b/services/api/grpc/handlers/signer/signbeaconproposal.go index 2431cbc..c7a3c45 100644 --- a/services/api/grpc/handlers/signer/signbeaconproposal.go +++ b/services/api/grpc/handlers/signer/signbeaconproposal.go @@ -31,21 +31,25 @@ func (h *Handler) SignBeaconProposal(ctx context.Context, req *pb.SignBeaconProp if req == nil { log.Warn().Str("result", "denied").Msg("Request not specified") res.State = pb.ResponseState_DENIED + return res, nil } if req.GetData() == nil { log.Warn().Str("result", "denied").Msg("Request data not specified") res.State = pb.ResponseState_DENIED + return res, nil } if req.GetAccount() == "" && req.GetPublicKey() == nil { log.Warn().Str("result", "denied").Msg("Neither accout nor public key specified") res.State = pb.ResponseState_DENIED + return res, nil } if !strings.Contains(req.GetAccount(), "/") { log.Warn().Str("result", "denied").Msg("Invalid account specified") res.State = pb.ResponseState_DENIED + return res, nil } @@ -71,5 +75,6 @@ func (h *Handler) SignBeaconProposal(ctx context.Context, req *pb.SignBeaconProp } log.Trace().Str("result", "succeeded").Msg("Success") + return res, nil } diff --git a/services/api/grpc/handlers/walletmanager/lock.go b/services/api/grpc/handlers/walletmanager/lock.go index 36ab7ec..a714ff9 100644 --- a/services/api/grpc/handlers/walletmanager/lock.go +++ b/services/api/grpc/handlers/walletmanager/lock.go @@ -48,5 +48,6 @@ func (h *Handler) Lock(ctx context.Context, req *pb.LockWalletRequest) (*pb.Lock res.State = pb.ResponseState_UNKNOWN } } + return res, nil } diff --git a/services/api/grpc/handlers/walletmanager/parameters.go b/services/api/grpc/handlers/walletmanager/parameters.go index 130331e..fb089d6 100644 --- a/services/api/grpc/handlers/walletmanager/parameters.go +++ b/services/api/grpc/handlers/walletmanager/parameters.go @@ -46,16 +46,16 @@ func WithLogLevel(logLevel zerolog.Level) Parameter { } // WithWalletManager sets the wallet manager service for the module. -func WithWalletManager(walletManager walletmanager.Service) Parameter { +func WithWalletManager(service walletmanager.Service) Parameter { return parameterFunc(func(p *parameters) { - p.walletManager = walletManager + p.walletManager = service }) } // WithProcess sets the process service for the module. -func WithProcess(process process.Service) Parameter { +func WithProcess(service process.Service) Parameter { return parameterFunc(func(p *parameters) { - p.process = process + p.process = service }) } diff --git a/services/api/grpc/handlers/walletmanager/unlock.go b/services/api/grpc/handlers/walletmanager/unlock.go index 68fa66b..98e3ce8 100644 --- a/services/api/grpc/handlers/walletmanager/unlock.go +++ b/services/api/grpc/handlers/walletmanager/unlock.go @@ -48,5 +48,6 @@ func (h *Handler) Unlock(ctx context.Context, req *pb.UnlockWalletRequest) (*pb. res.State = pb.ResponseState_UNKNOWN } } + return res, nil } diff --git a/services/api/grpc/interceptors/clientinfo.go b/services/api/grpc/interceptors/clientinfo.go index d316e2a..0cb7255 100644 --- a/services/api/grpc/interceptors/clientinfo.go +++ b/services/api/grpc/interceptors/clientinfo.go @@ -28,7 +28,7 @@ type ClientName struct{} // ClientInfoInterceptor adds the client certificate common name to incoming requests. func ClientInfoInterceptor() grpc.UnaryServerInterceptor { - return func(ctx context.Context, req interface{}, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { + return func(ctx context.Context, req any, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error) { grpcPeer, ok := peer.FromContext(ctx) if !ok { return nil, status.Error(codes.Internal, "Failure") @@ -43,6 +43,7 @@ func ClientInfoInterceptor() grpc.UnaryServerInterceptor { newCtx = context.WithValue(ctx, &ClientName{}, peerCert.Subject.CommonName) } } + return handler(newCtx, req) } } diff --git a/services/api/grpc/interceptors/reqid.go b/services/api/grpc/interceptors/reqid.go index bc47a34..5407234 100644 --- a/services/api/grpc/interceptors/reqid.go +++ b/services/api/grpc/interceptors/reqid.go @@ -26,7 +26,7 @@ type RequestID struct{} // RequestIDInterceptor adds a request ID to incoming requests. func RequestIDInterceptor() grpc.UnaryServerInterceptor { - return func(ctx context.Context, req interface{}, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { + return func(ctx context.Context, req any, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error) { // #nosec G404 newCtx := context.WithValue(ctx, &RequestID{}, fmt.Sprintf("%02x", rand.Int31())) return handler(newCtx, req) diff --git a/services/api/grpc/interceptors/sourceip.go b/services/api/grpc/interceptors/sourceip.go index fd52df8..87da093 100644 --- a/services/api/grpc/interceptors/sourceip.go +++ b/services/api/grpc/interceptors/sourceip.go @@ -28,7 +28,7 @@ type ExternalIP struct{} // SourceIPInterceptor adds the source IP address to incoming requests. func SourceIPInterceptor() grpc.UnaryServerInterceptor { - return func(ctx context.Context, req interface{}, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { + return func(ctx context.Context, req any, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error) { grpcPeer, ok := peer.FromContext(ctx) if !ok { return nil, status.Error(codes.Internal, "Failure") @@ -39,6 +39,7 @@ func SourceIPInterceptor() grpc.UnaryServerInterceptor { } newCtx := context.WithValue(ctx, &ExternalIP{}, tcpAddr.IP.String()) + return handler(newCtx, req) } } diff --git a/services/api/grpc/parameters.go b/services/api/grpc/parameters.go index 06cfcae..b1df6ec 100644 --- a/services/api/grpc/parameters.go +++ b/services/api/grpc/parameters.go @@ -68,44 +68,44 @@ func WithMonitor(monitor metrics.APIMonitor) Parameter { } // WithLister sets the lister for this module. -func WithLister(lister lister.Service) Parameter { +func WithLister(service lister.Service) Parameter { return parameterFunc(func(p *parameters) { - p.lister = lister + p.lister = service }) } // WithProcess sets the process for this module. -func WithProcess(process process.Service) Parameter { +func WithProcess(service process.Service) Parameter { return parameterFunc(func(p *parameters) { - p.process = process + p.process = service }) } // WithSigner sets the signer for this module. -func WithSigner(signer signer.Service) Parameter { +func WithSigner(service signer.Service) Parameter { return parameterFunc(func(p *parameters) { - p.signer = signer + p.signer = service }) } // WithPeers sets the peers for this module. -func WithPeers(peers peers.Service) Parameter { +func WithPeers(service peers.Service) Parameter { return parameterFunc(func(p *parameters) { - p.peers = peers + p.peers = service }) } // WithWalletManager sets the wallet manager for this module. -func WithWalletManager(walletManager walletmanager.Service) Parameter { +func WithWalletManager(service walletmanager.Service) Parameter { return parameterFunc(func(p *parameters) { - p.walletManager = walletManager + p.walletManager = service }) } // WithAccountManager sets the account manager for this module. -func WithAccountManager(accountManager accountmanager.Service) Parameter { +func WithAccountManager(service accountmanager.Service) Parameter { return parameterFunc(func(p *parameters) { - p.accountManager = accountManager + p.accountManager = service }) } diff --git a/services/api/grpc/service.go b/services/api/grpc/service.go index b4e0057..8ca8bcd 100644 --- a/services/api/grpc/service.go +++ b/services/api/grpc/service.go @@ -27,8 +27,8 @@ import ( "github.com/attestantio/dirk/services/api/grpc/interceptors" "github.com/attestantio/dirk/services/metrics" "github.com/attestantio/dirk/util/loggers" - grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware" - grpc_ctxtags "github.com/grpc-ecosystem/go-grpc-middleware/tags" + grpcmiddleware "github.com/grpc-ecosystem/go-grpc-middleware" + grpcctxtags "github.com/grpc-ecosystem/go-grpc-middleware/tags" "github.com/pkg/errors" "github.com/rs/zerolog" zerologger "github.com/rs/zerolog/log" @@ -139,8 +139,8 @@ func (s *Service) createServer(name string, certPEMBlock []byte, keyPEMBlock []b grpcOpts := []grpc.ServerOption{ grpc.StatsHandler(otelgrpc.NewServerHandler()), grpc.UnaryInterceptor( - grpc_middleware.ChainUnaryServer( - grpc_ctxtags.UnaryServerInterceptor(grpc_ctxtags.WithFieldExtractor(grpc_ctxtags.CodeGenRequestFieldExtractor)), + grpcmiddleware.ChainUnaryServer( + grpcctxtags.UnaryServerInterceptor(grpcctxtags.WithFieldExtractor(grpcctxtags.CodeGenRequestFieldExtractor)), interceptors.RequestIDInterceptor(), interceptors.SourceIPInterceptor(), interceptors.ClientInfoInterceptor(), @@ -189,5 +189,6 @@ func (s *Service) serve(listenAddress string) error { log.Error().Err(err).Msg("Could not start GRPC server") } }() + return nil } diff --git a/services/api/service.go b/services/api/service.go index 528700e..64675bd 100644 --- a/services/api/service.go +++ b/services/api/service.go @@ -14,4 +14,4 @@ package service // Service is the API service. -type Service interface{} +type Service any diff --git a/services/checker/mock/service.go b/services/checker/mock/service.go index 8ae83a4..b1acd1a 100644 --- a/services/checker/mock/service.go +++ b/services/checker/mock/service.go @@ -41,6 +41,7 @@ func New(logLevel zerolog.Level) (checker.Service, error) { }, }, } + return static.New(context.Background(), static.WithLogLevel(logLevel), static.WithPermissions(permissions), diff --git a/services/checker/permissions.go b/services/checker/permissions.go index 151b432..016535e 100644 --- a/services/checker/permissions.go +++ b/services/checker/permissions.go @@ -30,6 +30,7 @@ func DumpPermissions(perms map[string][]*Permissions) { for client, perms := range perms { if client == "" { fmt.Fprintf(os.Stdout, "ERROR: client does not have a name\n") + continue } fmt.Fprintf(os.Stdout, "Permissions for %q:\n", client) diff --git a/services/checker/static/service.go b/services/checker/static/service.go index 15ffec3..aedf560 100644 --- a/services/checker/static/service.go +++ b/services/checker/static/service.go @@ -116,5 +116,6 @@ func (s *Service) Check(_ context.Context, credentials *checker.Credentials, acc } log.Trace().Str("result", "denied").Msg("No matching rules") + return false } diff --git a/services/fetcher/mem/service.go b/services/fetcher/mem/service.go index ad06ea4..5de1461 100644 --- a/services/fetcher/mem/service.go +++ b/services/fetcher/mem/service.go @@ -260,6 +260,7 @@ func populateCaches(ctx context.Context, if err != nil { return nil, nil, nil, err } + return wallets, walletAccounts, pubKeyPaths, nil } @@ -296,5 +297,6 @@ func walletFromBytes(ctx context.Context, data []byte, store e2wtypes.Store, enc default: return nil, fmt.Errorf("unsupported wallet type %q", info.Type) } + return wallet, err } diff --git a/services/lister/mock/service.go b/services/lister/mock/service.go index a5692b3..a7eed8a 100644 --- a/services/lister/mock/service.go +++ b/services/lister/mock/service.go @@ -30,7 +30,7 @@ func New() *Service { } // ListAccounts lists accessible accounts given by the paths. -func (s *Service) ListAccounts(_ context.Context, +func (*Service) ListAccounts(_ context.Context, _ *checker.Credentials, _ []string, ) ( diff --git a/services/lister/standard/helpers.go b/services/lister/standard/helpers.go index bfbdb55..670d6e0 100644 --- a/services/lister/standard/helpers.go +++ b/services/lister/standard/helpers.go @@ -29,5 +29,6 @@ func (s *Service) checkAccess(ctx context.Context, credentials *checker.Credenti if s.checker.Check(ctx, credentials, accountName, action) { return core.ResultSucceeded } + return core.ResultDenied } diff --git a/services/lister/standard/listaccounts.go b/services/lister/standard/listaccounts.go index a0f22b2..414d48b 100644 --- a/services/lister/standard/listaccounts.go +++ b/services/lister/standard/listaccounts.go @@ -24,7 +24,7 @@ import ( "github.com/attestantio/dirk/rules" "github.com/attestantio/dirk/services/checker" "github.com/attestantio/dirk/services/ruler" - wallet "github.com/wealdtech/go-eth2-wallet" + e2wallet "github.com/wealdtech/go-eth2-wallet" e2wtypes "github.com/wealdtech/go-eth2-wallet-types/v2" "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/attribute" @@ -39,6 +39,7 @@ func (s *Service) ListAccounts(ctx context.Context, credentials *checker.Credent if credentials == nil { log.Error().Msg("No credentials supplied") + return core.ResultFailed, nil } span.SetAttributes(attribute.String("client", credentials.Client)) @@ -53,13 +54,15 @@ func (s *Service) ListAccounts(ctx context.Context, credentials *checker.Credent accounts := make([]e2wtypes.Account, 0) for _, path := range paths { log := log.With().Str("path", path).Logger() - walletName, accountPath, err := wallet.WalletAndAccountNames(path) + walletName, accountPath, err := e2wallet.WalletAndAccountNames(path) if err != nil { log.Warn().Err(err).Msg("Failed to obtain wallet and account names from path") + continue } if walletName == "" { log.Warn().Msg("Empty wallet in path") + continue } @@ -74,6 +77,7 @@ func (s *Service) ListAccounts(ctx context.Context, credentials *checker.Credent accountRegex, err = regexp.Compile(accountPath) if err != nil { log.Warn().Err(err).Msg("Invalid account regular expression") + continue } } @@ -81,12 +85,14 @@ func (s *Service) ListAccounts(ctx context.Context, credentials *checker.Credent wallet, err := s.fetcher.FetchWallet(ctx, path) if err != nil { log.Debug().Err(err).Msg("Failed to obtain wallet") + continue } walletAccounts, err := s.fetcher.FetchAccounts(ctx, wallet.Name()) if err != nil { log.Debug().Err(err).Msg("Failed to obtain accounts") + continue } @@ -98,6 +104,7 @@ func (s *Service) ListAccounts(ctx context.Context, credentials *checker.Credent checkRes := s.checkAccess(ctx, credentials, accountName, ruler.ActionAccessAccount) if checkRes != core.ResultSucceeded { log.Debug().Msg("Access refused") + continue } log.Trace().Msg("Access allowed") @@ -107,6 +114,7 @@ func (s *Service) ListAccounts(ctx context.Context, credentials *checker.Credent pubKeyProvider, isProvider := walletAccount.(e2wtypes.AccountPublicKeyProvider) if !isProvider { log.Warn().Msg("No public key available") + continue } pubKey = pubKeyProvider.PublicKey().Marshal() @@ -142,5 +150,6 @@ func (s *Service) ListAccounts(ctx context.Context, credentials *checker.Credent log.Trace().Str("result", "succeeded").Dur("elapsed", time.Since(started)).Int("accounts", len(accounts)).Msg("Success") span.AddEvent("Obtained all accounts", trace.WithAttributes(attribute.Int("accounts", len(accounts)))) s.monitor.ListAccountsCompleted(started) + return core.ResultSucceeded, accounts } diff --git a/services/lister/standard/monitor.go b/services/lister/standard/monitor.go index fb88c04..72d82ba 100644 --- a/services/lister/standard/monitor.go +++ b/services/lister/standard/monitor.go @@ -20,4 +20,4 @@ import "time" type noopMonitor struct{} // ListAccountsCompleted is called when a request for accounts has completed. -func (n *noopMonitor) ListAccountsCompleted(_ time.Time) {} +func (*noopMonitor) ListAccountsCompleted(_ time.Time) {} diff --git a/services/lister/standard/parameters.go b/services/lister/standard/parameters.go index d1e1e95..5b47f42 100644 --- a/services/lister/standard/parameters.go +++ b/services/lister/standard/parameters.go @@ -56,23 +56,23 @@ func WithMonitor(monitor metrics.ListerMonitor) Parameter { } // WithChecker sets the access checker for this module. -func WithChecker(checker checker.Service) Parameter { +func WithChecker(service checker.Service) Parameter { return parameterFunc(func(p *parameters) { - p.checker = checker + p.checker = service }) } // WithRuler sets the ruler for this module. -func WithRuler(ruler ruler.Service) Parameter { +func WithRuler(service ruler.Service) Parameter { return parameterFunc(func(p *parameters) { - p.ruler = ruler + p.ruler = service }) } // WithFetcher sets the account fetcher for this module. -func WithFetcher(fetcher fetcher.Service) Parameter { +func WithFetcher(service fetcher.Service) Parameter { return parameterFunc(func(p *parameters) { - p.fetcher = fetcher + p.fetcher = service }) } diff --git a/services/metrics/prometheus/accountmanager.go b/services/metrics/prometheus/accountmanager.go index 5cddd9f..77c143e 100644 --- a/services/metrics/prometheus/accountmanager.go +++ b/services/metrics/prometheus/accountmanager.go @@ -42,6 +42,7 @@ func (s *Service) setupAccountManagerMetrics() error { Name: "requests_total", Help: "The number of account manager requests.", }, []string{"request", "result"}) + return prometheus.Register(s.accountManagerRequests) } diff --git a/services/metrics/prometheus/checker.go b/services/metrics/prometheus/checker.go index 693acb4..291bf3c 100644 --- a/services/metrics/prometheus/checker.go +++ b/services/metrics/prometheus/checker.go @@ -24,6 +24,7 @@ func (s *Service) setupCheckerMetrics() error { Name: "permissions", Help: "The clients with permissions configured.", }, []string{"client"}) + return prometheus.Register(s.checkerPermissions) } diff --git a/services/metrics/prometheus/lister.go b/services/metrics/prometheus/lister.go index 9086115..c433989 100644 --- a/services/metrics/prometheus/lister.go +++ b/services/metrics/prometheus/lister.go @@ -40,6 +40,7 @@ func (s *Service) setupListerMetrics() error { Name: "requests_total", Help: "The number of account list requests.", }, []string{"result"}) + return prometheus.Register(s.listerRequests) } diff --git a/services/metrics/prometheus/service.go b/services/metrics/prometheus/service.go index 9d3f33e..1a62d62 100644 --- a/services/metrics/prometheus/service.go +++ b/services/metrics/prometheus/service.go @@ -91,6 +91,6 @@ func New(_ context.Context, params ...Parameter) (*Service, error) { } // Presenter returns the presenter for the events. -func (s *Service) Presenter() string { +func (*Service) Presenter() string { return "prometheus" } diff --git a/services/metrics/prometheus/signer.go b/services/metrics/prometheus/signer.go index 83ad40a..d106b8a 100644 --- a/services/metrics/prometheus/signer.go +++ b/services/metrics/prometheus/signer.go @@ -42,6 +42,7 @@ func (s *Service) setupSignerMetrics() error { Name: "requests_total", Help: "The number of sign requests.", }, []string{"request", "result"}) + return prometheus.Register(s.signerRequests) } diff --git a/services/metrics/prometheus/walletmanager.go b/services/metrics/prometheus/walletmanager.go index fe185bb..964d940 100644 --- a/services/metrics/prometheus/walletmanager.go +++ b/services/metrics/prometheus/walletmanager.go @@ -42,6 +42,7 @@ func (s *Service) setupWalletManagerMetrics() error { Name: "requests_total", Help: "The number of wallet manager requests.", }, []string{"request", "result"}) + return prometheus.Register(s.walletManagerRequests) } diff --git a/services/metrics/service.go b/services/metrics/service.go index cc6794e..84dd968 100644 --- a/services/metrics/service.go +++ b/services/metrics/service.go @@ -39,28 +39,28 @@ type SignerMonitor interface { } // FetcherMonitor monitors the fetcher service. -type FetcherMonitor interface{} +type FetcherMonitor any // LockerMonitor monitors the locker service. -type LockerMonitor interface{} +type LockerMonitor any // RulerMonitor monitors the ruler service. -type RulerMonitor interface{} +type RulerMonitor any // APIMonitor monitors the API service. -type APIMonitor interface{} +type APIMonitor any // PeersMonitor monitors the dirk peers service. -type PeersMonitor interface{} +type PeersMonitor any // ProcessMonitor monitors the process service. -type ProcessMonitor interface{} +type ProcessMonitor any // SenderMonitor monitors the sender service. -type SenderMonitor interface{} +type SenderMonitor any // ReceiverMonitor monitors the receiver service. -type ReceiverMonitor interface{} +type ReceiverMonitor any // ListerMonitor monitors the account lister service. type ListerMonitor interface { @@ -81,4 +81,4 @@ type WalletManagerMonitor interface { } // ConfidantMonitor monitors the confidant service. -type ConfidantMonitor interface{} +type ConfidantMonitor any diff --git a/services/peers/static/service.go b/services/peers/static/service.go index c3fd0d4..5a1ca2a 100644 --- a/services/peers/static/service.go +++ b/services/peers/static/service.go @@ -89,6 +89,7 @@ func (s *Service) Peer(id uint64) (*core.Endpoint, error) { if !exists { return nil, ErrNotFound } + return &core.Endpoint{ ID: peer.ID, Name: peer.Name, @@ -106,6 +107,7 @@ func (s *Service) All() map[uint64]*core.Endpoint { Port: peer.Port, } } + return res } @@ -128,5 +130,6 @@ func (s *Service) Suitable(threshold uint32) ([]*core.Endpoint, error) { if suitable < threshold { return nil, errors.New("not enough suitable peers") } + return res, nil } diff --git a/services/process/standard/crypto.go b/services/process/standard/crypto.go index f322b45..4b66e0f 100644 --- a/services/process/standard/crypto.go +++ b/services/process/standard/crypto.go @@ -113,5 +113,6 @@ func verifyContribution(id uint64, secretShare bls.SecretKey, vVec []bls.PublicK if err := vVecKey.Set(vVec, util.BLSID(id)); err != nil { return false } + return secretShare.GetPublicKey().IsEqual(&vVecKey) } diff --git a/services/process/standard/generate.go b/services/process/standard/generate.go index 9c42d10..242d39e 100644 --- a/services/process/standard/generate.go +++ b/services/process/standard/generate.go @@ -27,7 +27,7 @@ import ( "github.com/herumi/bls-eth-go-binary/bls" "github.com/opentracing/opentracing-go" "github.com/pkg/errors" - wallet "github.com/wealdtech/go-eth2-wallet" + e2wallet "github.com/wealdtech/go-eth2-wallet" e2wtypes "github.com/wealdtech/go-eth2-wallet-types/v2" ) @@ -55,12 +55,12 @@ func (s *Service) OnGenerate(ctx context.Context, log := log.With().Str("account", account).Logger() // Ensure we don't already have this account. - walletName, accountName, err := wallet.WalletAndAccountNames(account) + walletName, accountName, err := e2wallet.WalletAndAccountNames(account) if err != nil { log.Warn().Msg("Invalid account supplied") return nil, nil, errors.Wrap(err, "invalid account") } - wallet, err := wallet.OpenWallet(walletName, wallet.WithStore(s.stores[0])) + wallet, err := e2wallet.OpenWallet(walletName, e2wallet.WithStore(s.stores[0])) if err != nil { log.Warn().Err(err).Msg("Unknown wallet supplied") return nil, nil, errors.Wrap(err, "unknown wallet") @@ -90,12 +90,21 @@ func (s *Service) OnGenerate(ctx context.Context, log.Error().Err(err).Msg("Failed to generate account") return nil, nil, errors.New("failed account generation") } + return pubKey, nil, err } + return s.generateDistributed(ctx, wallet, account, passphrase, signingThreshold, numParticipants) } -func (s *Service) generate(ctx context.Context, wallet e2wtypes.Wallet, accountName string, passphrase []byte) ([]byte, error) { +func (s *Service) generate(ctx context.Context, + wallet e2wtypes.Wallet, + accountName string, + passphrase []byte, +) ( + []byte, + error, +) { span, ctx := opentracing.StartSpanFromContext(ctx, "services.process.generate") defer span.Finish() @@ -222,7 +231,7 @@ func (s *Service) generateDistributed(ctx context.Context, wallet e2wtypes.Walle for i := range pubKeys { if !bytes.Equal(pubKeys[i], pubKeys[(i+1)%len(pubKeys)]) { log.Error().Msg("pubkey mismatch") - return nil, nil, errors.New("Invalid generation") + return nil, nil, errors.New("invalid generation") } } @@ -232,7 +241,7 @@ func (s *Service) generateDistributed(ctx context.Context, wallet e2wtypes.Walle pubKey := bls.PublicKey{} if err := pubKey.Deserialize(pubKeys[0]); err != nil { log.Error().Err(err).Msg("Failed to deserialize public key") - return nil, nil, errors.New("Invalid generation") + return nil, nil, errors.New("invalid generation") } compositeSig := bls.Sign{} for i := 0; i < len(participants)+1-int(signingThreshold); i++ { @@ -241,19 +250,20 @@ func (s *Service) generateDistributed(ctx context.Context, wallet e2wtypes.Walle sigs[j] = bls.Sign{} if err := sigs[j].Deserialize(confirmationSigs[i+j]); err != nil { log.Error().Err(err).Msg("Failed to deserialize confirmation signature") - return nil, nil, errors.New("Invalid generation") + return nil, nil, errors.New("invalid generation") } } if err := compositeSig.Recover(sigs, ids); err != nil { log.Error().Err(err).Msg("Failed to recover composite signature") - return nil, nil, errors.New("Invalid generation") + return nil, nil, errors.New("invalid generation") } if !compositeSig.VerifyByte(&pubKey, confirmationData) { log.Error().Err(err).Msg("Failed to confirm composite signature") - return nil, nil, errors.New("Invalid generation") + return nil, nil, errors.New("invalid generation") } } log.Trace().Str("account", account).Str("pubKey", fmt.Sprintf("%x", pubKeys[0])).Msg("Generated account") + return pubKeys[0], participants, nil } diff --git a/services/process/standard/helpers.go b/services/process/standard/helpers.go index 8b47e3d..e0f2a31 100644 --- a/services/process/standard/helpers.go +++ b/services/process/standard/helpers.go @@ -29,5 +29,6 @@ func (s *Service) checkAccess(ctx context.Context, credentials *checker.Credenti if s.checkerSvc.Check(ctx, credentials, accountName, action) { return core.ResultSucceeded } + return core.ResultDenied } diff --git a/services/process/standard/parameters.go b/services/process/standard/parameters.go index 96e4fa3..a9e4e79 100644 --- a/services/process/standard/parameters.go +++ b/services/process/standard/parameters.go @@ -69,30 +69,30 @@ func WithMonitor(monitor metrics.ProcessMonitor) Parameter { } // WithChecker sets the checker for this module. -func WithChecker(checker checker.Service) Parameter { +func WithChecker(service checker.Service) Parameter { return parameterFunc(func(p *parameters) { - p.checker = checker + p.checker = service }) } // WithFetcher sets the account fetcher for this module. -func WithFetcher(fetcher fetcher.Service) Parameter { +func WithFetcher(service fetcher.Service) Parameter { return parameterFunc(func(p *parameters) { - p.fetcher = fetcher + p.fetcher = service }) } // WithSender sets the sender for this module. -func WithSender(sender sender.Service) Parameter { +func WithSender(service sender.Service) Parameter { return parameterFunc(func(p *parameters) { - p.sender = sender + p.sender = service }) } // WithUnlocker sets the unlocker for this module. -func WithUnlocker(unlocker unlocker.Service) Parameter { +func WithUnlocker(service unlocker.Service) Parameter { return parameterFunc(func(p *parameters) { - p.unlocker = unlocker + p.unlocker = service }) } @@ -104,9 +104,9 @@ func WithEncryptor(encryptor e2wtypes.Encryptor) Parameter { } // WithPeers sets the peers for this module. -func WithPeers(peers peers.Service) Parameter { +func WithPeers(service peers.Service) Parameter { return parameterFunc(func(p *parameters) { - p.peers = peers + p.peers = service }) } diff --git a/services/process/standard/service.go b/services/process/standard/service.go index dfb6ae7..6c815c2 100644 --- a/services/process/standard/service.go +++ b/services/process/standard/service.go @@ -87,7 +87,7 @@ func New(_ context.Context, params ...Parameter) (*Service, error) { // OnPrepare is called when we receive a request from the given participant to prepare for DKG. func (s *Service) OnPrepare(ctx context.Context, - sender uint64, + senderID uint64, account string, passphrase []byte, threshold uint32, @@ -95,13 +95,13 @@ func (s *Service) OnPrepare(ctx context.Context, ) error { span, ctx := opentracing.StartSpanFromContext(ctx, "services.process.OnPrepare") defer span.Finish() - log.Trace().Uint64("sender_id", sender).Str("account", account).Msg("Preparing for distributed key generation") + log.Trace().Uint64("sender_id", senderID).Str("account", account).Msg("Preparing for distributed key generation") s.generationsMu.Lock() defer s.generationsMu.Unlock() if _, err := s.getGeneration(ctx, account); err == nil { - log.Debug().Uint64("sender_id", sender).Str("account", account).Msg("Already in progress") + log.Debug().Uint64("sender_id", senderID).Str("account", account).Msg("Already in progress") return ErrInProgress } @@ -117,7 +117,7 @@ func (s *Service) OnPrepare(ctx context.Context, } if err := s.contribution(ctx, s.generations[account]); err != nil { - log.Debug().Uint64("sender_id", sender).Str("account", account).Msg("Failed to generate our own contribution") + log.Debug().Uint64("sender_id", senderID).Str("account", account).Msg("Failed to generate our own contribution") return errors.Wrap(err, "failed to generate own contribution") } @@ -125,10 +125,10 @@ func (s *Service) OnPrepare(ctx context.Context, } // OnExecute is called when we receive a request from the given participant to execute the given DKG. -func (s *Service) OnExecute(ctx context.Context, sender uint64, account string) error { +func (s *Service) OnExecute(ctx context.Context, senderID uint64, account string) error { span, ctx := opentracing.StartSpanFromContext(ctx, "services.process.OnExecute") defer span.Finish() - log.Trace().Uint64("sender", sender).Str("account", account).Msg("Executing") + log.Trace().Uint64("sender", senderID).Str("account", account).Msg("Executing") s.generationsMu.Lock() defer s.generationsMu.Unlock() @@ -138,6 +138,7 @@ func (s *Service) OnExecute(ctx context.Context, sender uint64, account string) if errors.Is(err, ErrNotFound) { return ErrNotInProgress } + return err } @@ -166,6 +167,7 @@ func (s *Service) OnExecute(ctx context.Context, sender uint64, account string) generation.sharedVVecs[id] = recipientVVec } } + return nil } @@ -245,6 +247,7 @@ func (s *Service) OnCommit(ctx context.Context, _ uint64, account string, confir sig := privateKey.SignByte(confirmationData) delete(s.generations, account) + return aggregateVVec[0].Serialize(), sig.Serialize(), nil } @@ -267,7 +270,16 @@ func (s *Service) OnAbort(ctx context.Context, _ uint64, account string) error { } // OnContribute is called when we need to swap contributions with another participant. -func (s *Service) OnContribute(ctx context.Context, sender uint64, account string, secret bls.SecretKey, vVec []bls.PublicKey) (bls.SecretKey, []bls.PublicKey, error) { +func (s *Service) OnContribute(ctx context.Context, + senderID uint64, + account string, + secret bls.SecretKey, + vVec []bls.PublicKey, +) ( + bls.SecretKey, + []bls.PublicKey, + error, +) { span, ctx := opentracing.StartSpanFromContext(ctx, "services.process.OnContribute") defer span.Finish() @@ -280,16 +292,16 @@ func (s *Service) OnContribute(ctx context.Context, sender uint64, account strin } if !verifyContribution(generation.id, secret, vVec) { - log.Warn().Uint64("sender", sender).Str("account", account).Msg("Received invalid contribution") - return bls.SecretKey{}, nil, fmt.Errorf("invalid contribution from %d", sender) + log.Warn().Uint64("sender", senderID).Str("account", account).Msg("Received invalid contribution") + return bls.SecretKey{}, nil, fmt.Errorf("invalid contribution from %d", senderID) } // Store the contributed information. - generation.sharedSecrets[sender] = secret - generation.sharedVVecs[sender] = vVec + generation.sharedSecrets[senderID] = secret + generation.sharedVVecs[senderID] = vVec // We return our unique generated secret for the sender, and our own verification vector. - return generation.distributionSecrets[sender], generation.sharedVVecs[generation.id], nil + return generation.distributionSecrets[senderID], generation.sharedVVecs[generation.id], nil } func (s *Service) storeDistributedKey(ctx context.Context, diff --git a/services/ruler/golang/parameters.go b/services/ruler/golang/parameters.go index 11e66dd..52b8a75 100644 --- a/services/ruler/golang/parameters.go +++ b/services/ruler/golang/parameters.go @@ -54,16 +54,16 @@ func WithMonitor(monitor metrics.RulerMonitor) Parameter { } // WithLocker sets the locker for this module. -func WithLocker(locker locker.Service) Parameter { +func WithLocker(service locker.Service) Parameter { return parameterFunc(func(p *parameters) { - p.locker = locker + p.locker = service }) } // WithRules sets the rules for this module. -func WithRules(rules rules.Service) Parameter { +func WithRules(service rules.Service) Parameter { return parameterFunc(func(p *parameters) { - p.rules = rules + p.rules = service }) } diff --git a/services/ruler/golang/runner.go b/services/ruler/golang/runner.go index 2459637..aa2754f 100644 --- a/services/ruler/golang/runner.go +++ b/services/ruler/golang/runner.go @@ -88,6 +88,7 @@ func (s *Service) RunRules(ctx context.Context, var lockKey [48]byte copy(lockKey[:], rulesData[i].PubKey) s.locker.Lock(lockKey) + //nolint:revive defer s.locker.Unlock(lockKey) } s.locker.PostLock() @@ -112,7 +113,7 @@ func (s *Service) runRules(ctx context.Context, for i := range rulesData { results[i] = rules.UNKNOWN } - _, err := util.Scatter(len(rulesData), func(offset int, entries int, _ *sync.RWMutex) (interface{}, error) { + _, err := util.Scatter(len(rulesData), func(offset int, entries int, _ *sync.RWMutex) (any, error) { for i := offset; i < offset+entries; i++ { if rulesData[i] == nil { continue @@ -213,7 +214,8 @@ func (s *Service) runRules(ctx context.Context, results[i] = rules.FAILED } } - return nil, nil + + return make([]*util.ScatterResult, 0), nil }) if err != nil { log.Error().Err(err).Msg("Failed to scatter rules") @@ -235,7 +237,7 @@ func (s *Service) runRulesForMultipleBeaconAttestations(ctx context.Context, metadatas := make([]*rules.ReqMetadata, len(rulesData)) reqData := make([]*rules.SignBeaconAttestationData, len(rulesData)) - _, err := util.Scatter(len(rulesData), func(offset int, entries int, _ *sync.RWMutex) (interface{}, error) { + _, err := util.Scatter(len(rulesData), func(offset int, entries int, _ *sync.RWMutex) (any, error) { for i := offset; i < offset+entries; i++ { if rulesData[i].AccountName == "" { log.Warn().Msg("Missing account") @@ -262,7 +264,8 @@ func (s *Service) runRulesForMultipleBeaconAttestations(ctx context.Context, } reqData[i] = data } - return nil, nil + + return make([]*util.ScatterResult, 0), nil }) if err != nil { log.Error().Err(err).Msg("Failed to scatter signing preparation") diff --git a/services/ruler/golang/runner_test.go b/services/ruler/golang/runner_test.go index 1ca01bf..dc5a453 100644 --- a/services/ruler/golang/runner_test.go +++ b/services/ruler/golang/runner_test.go @@ -1247,7 +1247,7 @@ func TestRunRulesSignBeaconAttestationSoak(t *testing.T) { } // Run simultaneously (as near as we can manage). var wg sync.WaitGroup - starter := make(chan interface{}) + starter := make(chan any) for i := 0; i < p; i++ { wg.Add(1) go func(index int) { @@ -1349,7 +1349,7 @@ func TestRunRulesSignBeaconAttestationsSoak(t *testing.T) { } // Run simultaneously (as near as we can manage). var wg sync.WaitGroup - starter := make(chan interface{}) + starter := make(chan any) for i := 0; i < p; i++ { wg.Add(1) go func(i int) { @@ -1439,7 +1439,7 @@ func TestRunRulesSignBeaconProposalSoak(t *testing.T) { } // Run simultaneously (as near as we can manage). var wg sync.WaitGroup - starter := make(chan interface{}) + starter := make(chan any) for i := 0; i < p; i++ { wg.Add(1) go func(index int) { diff --git a/services/ruler/service.go b/services/ruler/service.go index 65b12d6..231fa34 100644 --- a/services/ruler/service.go +++ b/services/ruler/service.go @@ -46,7 +46,7 @@ type RulesData struct { WalletName string AccountName string PubKey []byte - Data interface{} + Data any } // Service provides an interface to check requests against a rules engine. diff --git a/services/sender/grpc/service.go b/services/sender/grpc/service.go index c394b93..9a54e52 100644 --- a/services/sender/grpc/service.go +++ b/services/sender/grpc/service.go @@ -54,16 +54,17 @@ func New(ctx context.Context, params ...Parameter) (*Service, error) { log = log.Level(parameters.logLevel) } - credentials, err := composeCredentials(ctx, parameters.serverCert, parameters.serverKey, parameters.caCert) + transportCredentials, err := composeCredentials(ctx, parameters.serverCert, parameters.serverKey, parameters.caCert) if err != nil { return nil, errors.Wrap(err, "failed to compose client credentials") } service := &Service{ name: parameters.name, - credentials: credentials, + credentials: transportCredentials, connectionPools: make(map[string]*puddle.Pool), } + return service, nil } @@ -77,7 +78,7 @@ func (s *Service) Prepare(ctx context.Context, ) error { connResource, err := s.obtainConnection(ctx, peer.ConnectAddress()) if err != nil { - return errors.Wrap(err, "Failed to obtain connection for Prepare()") + return errors.Wrap(err, "failed to obtain connection for Prepare()") } defer connResource.Release() client := pb.NewDKGClient(connResource.Value().(*grpc.ClientConn)) @@ -97,8 +98,9 @@ func (s *Service) Prepare(ctx context.Context, Participants: pbParticipants, } if _, err := client.Prepare(ctx, req); err != nil { - return errors.Wrap(err, "Failed to call Prepare()") + return errors.Wrap(err, "failed to call Prepare()") } + return nil } @@ -106,7 +108,7 @@ func (s *Service) Prepare(ctx context.Context, func (s *Service) Execute(ctx context.Context, peer *core.Endpoint, account string) error { connResource, err := s.obtainConnection(ctx, peer.ConnectAddress()) if err != nil { - return errors.Wrap(err, "Failed to obtain connection for Execute()") + return errors.Wrap(err, "failed to obtain connection for Execute()") } defer connResource.Release() client := pb.NewDKGClient(connResource.Value().(*grpc.ClientConn)) @@ -115,8 +117,9 @@ func (s *Service) Execute(ctx context.Context, peer *core.Endpoint, account stri Account: account, } if _, err := client.Execute(ctx, req); err != nil { - return errors.Wrap(err, "Failed to call Execute()") + return errors.Wrap(err, "failed to call Execute()") } + return nil } @@ -124,7 +127,7 @@ func (s *Service) Execute(ctx context.Context, peer *core.Endpoint, account stri func (s *Service) Commit(ctx context.Context, peer *core.Endpoint, account string, confirmationData []byte) ([]byte, []byte, error) { connResource, err := s.obtainConnection(ctx, peer.ConnectAddress()) if err != nil { - return nil, nil, errors.Wrap(err, "Failed to obtain connection for Commit()") + return nil, nil, errors.Wrap(err, "failed to obtain connection for Commit()") } defer connResource.Release() client := pb.NewDKGClient(connResource.Value().(*grpc.ClientConn)) @@ -135,8 +138,9 @@ func (s *Service) Commit(ctx context.Context, peer *core.Endpoint, account strin } res, err := client.Commit(ctx, req) if err != nil { - return nil, nil, errors.Wrap(err, "Failed to call Commit()") + return nil, nil, errors.Wrap(err, "failed to call Commit()") } + return res.GetPublicKey(), res.GetConfirmationSignature(), nil } @@ -144,7 +148,7 @@ func (s *Service) Commit(ctx context.Context, peer *core.Endpoint, account strin func (s *Service) Abort(ctx context.Context, peer *core.Endpoint, account string) error { connResource, err := s.obtainConnection(ctx, peer.ConnectAddress()) if err != nil { - return errors.Wrap(err, "Failed to obtain connection for Execute()") + return errors.Wrap(err, "failed to obtain connection for Execute()") } defer connResource.Release() client := pb.NewDKGClient(connResource.Value().(*grpc.ClientConn)) @@ -153,8 +157,9 @@ func (s *Service) Abort(ctx context.Context, peer *core.Endpoint, account string Account: account, } if _, err := client.Abort(ctx, req); err != nil { - return errors.Wrap(err, "Failed to call Abort()") + return errors.Wrap(err, "failed to call Abort()") } + return nil } @@ -162,7 +167,7 @@ func (s *Service) Abort(ctx context.Context, peer *core.Endpoint, account string func (s *Service) SendContribution(ctx context.Context, peer *core.Endpoint, account string, distributionSecret bls.SecretKey, verificationVector []bls.PublicKey) (bls.SecretKey, []bls.PublicKey, error) { connResource, err := s.obtainConnection(ctx, peer.ConnectAddress()) if err != nil { - return bls.SecretKey{}, nil, errors.Wrap(err, "Failed to obtain connection for SendContribution()") + return bls.SecretKey{}, nil, errors.Wrap(err, "failed to obtain connection for SendContribution()") } defer connResource.Release() client := pb.NewDKGClient(connResource.Value().(*grpc.ClientConn)) @@ -178,18 +183,18 @@ func (s *Service) SendContribution(ctx context.Context, peer *core.Endpoint, acc } res, err := client.Contribute(ctx, req) if err != nil { - return bls.SecretKey{}, nil, errors.Wrap(err, "Failed to call Contribute()") + return bls.SecretKey{}, nil, errors.Wrap(err, "failed to call Contribute()") } resSecret := bls.SecretKey{} if err := resSecret.Deserialize(res.GetSecret()); err != nil { - return bls.SecretKey{}, nil, errors.Wrap(err, "Returned invalid secret key") + return bls.SecretKey{}, nil, errors.Wrap(err, "returned invalid secret key") } resVVec := make([]bls.PublicKey, len(res.GetVerificationVector())) for i, key := range res.GetVerificationVector() { resVVec[i] = bls.PublicKey{} if err := resVVec[i].Deserialize(key); err != nil { - return bls.SecretKey{}, nil, errors.Wrap(err, "Returned invalid verification vector") + return bls.SecretKey{}, nil, errors.Wrap(err, "returned invalid verification vector") } } @@ -222,12 +227,12 @@ func (s *Service) obtainConnection(_ context.Context, address string) (*puddle.R s.connectionPoolsMutex.Lock() pool, exists := s.connectionPools[address] if !exists { - constructor := func(_ context.Context) (interface{}, error) { + constructor := func(_ context.Context) (any, error) { return grpc.Dial(address, []grpc.DialOption{ grpc.WithTransportCredentials(s.credentials), }...) } - destructor := func(val interface{}) { + destructor := func(val any) { if err := val.(*grpc.ClientConn).Close(); err != nil { log.Warn().Err(err).Msg("Failed to close client connection") } @@ -242,5 +247,6 @@ func (s *Service) obtainConnection(_ context.Context, address string) (*puddle.R if err != nil { return nil, err } + return res, nil } diff --git a/services/sender/mock/service.go b/services/sender/mock/service.go index ef671df..ce61b39 100644 --- a/services/sender/mock/service.go +++ b/services/sender/mock/service.go @@ -40,6 +40,7 @@ func (s *Service) Prepare(ctx context.Context, recipient *core.Endpoint, account if !exists { return fmt.Errorf("unknown mock process %d", recipient.ID) } + return process.OnPrepare(ctx, s.id, account, passphrase, threshold, participants) } @@ -49,6 +50,7 @@ func (s *Service) Execute(ctx context.Context, recipient *core.Endpoint, account if !exists { return fmt.Errorf("unknown mock process %d", recipient.ID) } + return process.OnExecute(ctx, s.id, account) } @@ -58,6 +60,7 @@ func (s *Service) Commit(ctx context.Context, recipient *core.Endpoint, account if !exists { return nil, nil, fmt.Errorf("unknown mock process %d", recipient.ID) } + return process.OnCommit(ctx, s.id, account, confirmationData) } @@ -67,6 +70,7 @@ func (s *Service) Abort(ctx context.Context, recipient *core.Endpoint, account s if !exists { return fmt.Errorf("unknown mock process %d", recipient.ID) } + return process.OnAbort(ctx, s.id, account) } @@ -76,5 +80,6 @@ func (s *Service) SendContribution(ctx context.Context, recipient *core.Endpoint if !exists { return bls.SecretKey{}, nil, fmt.Errorf("unknown mock process %d", recipient.ID) } + return process.OnContribute(ctx, s.id, account, distributionSecret, verificationVector) } diff --git a/services/signer/mock/service.go b/services/signer/mock/service.go index e4b98d6..4549877 100644 --- a/services/signer/mock/service.go +++ b/services/signer/mock/service.go @@ -30,7 +30,7 @@ func New() *Service { } // SignGeneric signs generic data. -func (s *Service) SignGeneric(_ context.Context, +func (*Service) SignGeneric(_ context.Context, _ *checker.Credentials, _ string, _ []byte, @@ -50,7 +50,7 @@ func (s *Service) SignGeneric(_ context.Context, } // Multisign signs multiple generic data. -func (s *Service) Multisign(_ context.Context, +func (*Service) Multisign(_ context.Context, _ *checker.Credentials, _ []string, _ [][]byte, @@ -70,7 +70,7 @@ func (s *Service) Multisign(_ context.Context, } // SignBeaconAttestation signs a beacon attestation. -func (s *Service) SignBeaconAttestation(_ context.Context, +func (*Service) SignBeaconAttestation(_ context.Context, _ *checker.Credentials, _ string, _ []byte, @@ -90,7 +90,7 @@ func (s *Service) SignBeaconAttestation(_ context.Context, } // SignBeaconAttestations signs multiple beacon attestations. -func (s *Service) SignBeaconAttestations(_ context.Context, +func (*Service) SignBeaconAttestations(_ context.Context, _ *checker.Credentials, _ []string, _ [][]byte, @@ -112,11 +112,12 @@ func (s *Service) SignBeaconAttestations(_ context.Context, 0xf9, 0x57, 0x50, 0xd9, 0x0e, 0x92, 0xb1, 0xef, 0x8a, 0x53, 0xd6, 0x3b, 0x3d, 0xf1, 0x91, 0x5a, } } + return results, signatures } // SignBeaconProposal signs a proposal for a beacon block. -func (s *Service) SignBeaconProposal(_ context.Context, +func (*Service) SignBeaconProposal(_ context.Context, _ *checker.Credentials, _ string, _ []byte, diff --git a/services/signer/standard/helpers.go b/services/signer/standard/helpers.go index 8662ea5..0e2b36b 100644 --- a/services/signer/standard/helpers.go +++ b/services/signer/standard/helpers.go @@ -80,6 +80,7 @@ func (s *Service) checkAccess(ctx context.Context, credentials *checker.Credenti if s.checker.Check(ctx, credentials, accountName, action) { return core.ResultSucceeded } + return core.ResultDenied } @@ -125,5 +126,6 @@ func (s *Service) unlockAccount(ctx context.Context, wallet e2wtypes.Wallet, acc } log.Trace().Str("result", "succeeded").Msg("Account is unlocked") + return core.ResultSucceeded } diff --git a/services/signer/standard/monitor.go b/services/signer/standard/monitor.go index 0333d7f..afe5442 100644 --- a/services/signer/standard/monitor.go +++ b/services/signer/standard/monitor.go @@ -24,4 +24,4 @@ import ( type noopMonitor struct{} // SignCompleted is called when a siging process has completed. -func (n *noopMonitor) SignCompleted(_ time.Time, _ string, _ core.Result) {} +func (*noopMonitor) SignCompleted(_ time.Time, _ string, _ core.Result) {} diff --git a/services/signer/standard/multisign.go b/services/signer/standard/multisign.go index b6ede30..befa212 100644 --- a/services/signer/standard/multisign.go +++ b/services/signer/standard/multisign.go @@ -50,6 +50,7 @@ func (s *Service) Multisign(ctx context.Context, s.monitor.SignCompleted(started, "generic", core.ResultDenied) results := make([]core.Result, 1) results[0] = core.ResultDenied + return results, nil } @@ -63,6 +64,7 @@ func (s *Service) Multisign(ctx context.Context, for i := range results { results[i] = core.ResultDenied } + return results, nil } span.SetAttributes(attribute.String("client", credentials.Client)) @@ -81,6 +83,7 @@ func (s *Service) Multisign(ctx context.Context, log.Warn().Err(err).Str("result", "denied").Msg("Check failed") s.monitor.SignCompleted(started, "generic", core.ResultDenied) results[i] = core.ResultDenied + return results, nil } @@ -106,7 +109,7 @@ func (s *Service) Multisign(ctx context.Context, span.SetAttributes(attribute.Int("requests", entries)) rulesData := make([]*ruler.RulesData, entries) accounts := make([]e2wtypes.Account, entries) - _, err := util.Scatter(entries, func(offset int, entries int, _ *sync.RWMutex) (interface{}, error) { + _, err := util.Scatter(entries, func(offset int, entries int, _ *sync.RWMutex) (any, error) { for i := offset; i < offset+entries; i++ { var pubKey []byte if len(pubKeys) > i { @@ -122,6 +125,7 @@ func (s *Service) Multisign(ctx context.Context, if checkRes != core.ResultSucceeded { s.monitor.SignCompleted(started, "generic", checkRes) results[i] = checkRes + continue } rulesData[i] = &ruler.RulesData{ @@ -132,7 +136,8 @@ func (s *Service) Multisign(ctx context.Context, } accounts[i] = account } - return nil, nil + + return make([]*util.ScatterResult, 0), nil }) if err != nil { log.Error().Err(err).Str("result", "failed").Msg("Failed to scatter check") @@ -150,23 +155,26 @@ func (s *Service) Multisign(ctx context.Context, log.Trace().Dur("elapsed", time.Since(started)).Msg("Completed rules") // Carry out the signing. - _, err = util.Scatter(len(rulesResults), func(offset int, entries int, _ *sync.RWMutex) (interface{}, error) { + _, err = util.Scatter(len(rulesResults), func(offset int, entries int, _ *sync.RWMutex) (any, error) { for i := offset; i < offset+entries; i++ { switch rulesResults[i] { case rules.UNKNOWN: log.Debug().Str("result", "failed").Msg("Unknown result from rules") s.monitor.SignCompleted(started, "generic", core.ResultFailed) results[i] = core.ResultFailed + continue case rules.DENIED: log.Debug().Str("result", "denied").Msg("Denied by rules") s.monitor.SignCompleted(started, "generic", core.ResultDenied) results[i] = core.ResultDenied + continue case rules.FAILED: log.Error().Str("result", "failed").Msg("Rules check failed") s.monitor.SignCompleted(started, "generic", core.ResultFailed) results[i] = core.ResultFailed + continue case rules.APPROVED: // Nothing to do. @@ -177,6 +185,7 @@ func (s *Service) Multisign(ctx context.Context, log.Error().Err(err).Str("result", "failed").Msg("Failed to generate signing root") s.monitor.SignCompleted(started, "generic", core.ResultFailed) results[i] = core.ResultFailed + continue } @@ -186,6 +195,7 @@ func (s *Service) Multisign(ctx context.Context, log.Error().Err(err).Str("result", "failed").Msg("Failed to sign") s.monitor.SignCompleted(started, "generic", core.ResultFailed) results[i] = core.ResultFailed + continue } @@ -194,7 +204,8 @@ func (s *Service) Multisign(ctx context.Context, results[i] = core.ResultSucceeded signatures[i] = signature } - return nil, nil + + return make([]*util.ScatterResult, 0), nil }) if err != nil { log.Error().Err(err).Str("result", "failed").Msg("Failed to scatter sign") @@ -214,5 +225,6 @@ func checkSignData(data *rules.SignData) error { if data.Domain == nil { return errors.New("request missing domain") } + return nil } diff --git a/services/signer/standard/parameters.go b/services/signer/standard/parameters.go index 2c4a65f..5b24b8a 100644 --- a/services/signer/standard/parameters.go +++ b/services/signer/standard/parameters.go @@ -58,30 +58,30 @@ func WithMonitor(monitor metrics.SignerMonitor) Parameter { } // WithChecker sets the access checker for this module. -func WithChecker(checker checker.Service) Parameter { +func WithChecker(service checker.Service) Parameter { return parameterFunc(func(p *parameters) { - p.checker = checker + p.checker = service }) } // WithRuler sets the ruler for this module. -func WithRuler(ruler ruler.Service) Parameter { +func WithRuler(service ruler.Service) Parameter { return parameterFunc(func(p *parameters) { - p.ruler = ruler + p.ruler = service }) } // WithUnlocker sets the account unlocker for this module. -func WithUnlocker(unlocker unlocker.Service) Parameter { +func WithUnlocker(service unlocker.Service) Parameter { return parameterFunc(func(p *parameters) { - p.unlocker = unlocker + p.unlocker = service }) } // WithFetcher sets the account fetcher for this module. -func WithFetcher(fetcher fetcher.Service) Parameter { +func WithFetcher(service fetcher.Service) Parameter { return parameterFunc(func(p *parameters) { - p.fetcher = fetcher + p.fetcher = service }) } diff --git a/services/signer/standard/signbeaconattestation.go b/services/signer/standard/signbeaconattestation.go index 698f583..5083510 100644 --- a/services/signer/standard/signbeaconattestation.go +++ b/services/signer/standard/signbeaconattestation.go @@ -178,5 +178,6 @@ func (s *Service) SignBeaconAttestation( log.Trace().Str("result", "succeeded").Msg("Success") s.monitor.SignCompleted(started, "attestation", core.ResultSucceeded) + return core.ResultSucceeded, signature } diff --git a/services/signer/standard/signbeaconattestations.go b/services/signer/standard/signbeaconattestations.go index d9af906..180c4a0 100644 --- a/services/signer/standard/signbeaconattestations.go +++ b/services/signer/standard/signbeaconattestations.go @@ -52,6 +52,7 @@ func (s *Service) SignBeaconAttestations( s.monitor.SignCompleted(started, "attestation", core.ResultDenied) results := make([]core.Result, 1) results[0] = core.ResultDenied + return results, nil } @@ -65,6 +66,7 @@ func (s *Service) SignBeaconAttestations( for i := range results { results[i] = core.ResultDenied } + return results, nil } span.SetAttributes(attribute.String("client", credentials.Client)) @@ -80,6 +82,7 @@ func (s *Service) SignBeaconAttestations( if err := s.checkAttestationsData(data, accountNames, pubKeys, results); err != nil { log.Warn().Str("result", "denied").Msgf("Attestations data check failed: %s", err.Error()) s.monitor.SignCompleted(started, "attestation", core.ResultDenied) + return results, nil } @@ -93,7 +96,7 @@ func (s *Service) SignBeaconAttestations( span.SetAttributes(attribute.Int("requests", entries)) rulesData := make([]*ruler.RulesData, entries) accounts := make([]e2wtypes.Account, entries) - _, err := util.Scatter(entries, func(offset int, entries int, _ *sync.RWMutex) (interface{}, error) { + _, err := util.Scatter(entries, func(offset int, entries int, _ *sync.RWMutex) (any, error) { for i := offset; i < offset+entries; i++ { var pubKey []byte if len(pubKeys) > i { @@ -109,6 +112,7 @@ func (s *Service) SignBeaconAttestations( if checkRes != core.ResultSucceeded { s.monitor.SignCompleted(started, "attestation", checkRes) results[i] = checkRes + continue } rulesData[i] = &ruler.RulesData{ @@ -119,7 +123,8 @@ func (s *Service) SignBeaconAttestations( } accounts[i] = account } - return nil, nil + + return make([]*util.ScatterResult, 0), nil }) if err != nil { log.Error().Err(err).Str("result", "failed").Msg("Failed to scatter check") @@ -127,6 +132,7 @@ func (s *Service) SignBeaconAttestations( for i := range results { if results[i] != core.ResultUnknown && results[i] != core.ResultSucceeded { s.monitor.SignCompleted(started, "generic", results[i]) + return results, nil } } @@ -137,23 +143,26 @@ func (s *Service) SignBeaconAttestations( log.Trace().Dur("elapsed", time.Since(started)).Msg("Completed rules") // Carry out the signing. - _, err = util.Scatter(len(rulesResults), func(offset int, entries int, _ *sync.RWMutex) (interface{}, error) { + _, err = util.Scatter(len(rulesResults), func(offset int, entries int, _ *sync.RWMutex) (any, error) { for i := offset; i < offset+entries; i++ { switch rulesResults[i] { case rules.UNKNOWN: log.Debug().Int("index", i).Str("result", "failed").Msg("Unknown result from rules") s.monitor.SignCompleted(started, "attestation", core.ResultFailed) results[i] = core.ResultFailed + continue case rules.DENIED: log.Debug().Int("index", i).Str("result", "denied").Msg("Denied by rules") s.monitor.SignCompleted(started, "attestation", core.ResultDenied) results[i] = core.ResultDenied + continue case rules.FAILED: log.Error().Int("index", i).Str("result", "failed").Msg("Rules check failed") s.monitor.SignCompleted(started, "attestation", core.ResultFailed) results[i] = core.ResultFailed + continue case rules.APPROVED: // Nothing to do. @@ -178,6 +187,7 @@ func (s *Service) SignBeaconAttestations( log.Error().Err(err).Str("result", "failed").Msg("Failed to generate data root") s.monitor.SignCompleted(started, "attestation", core.ResultFailed) results[i] = core.ResultFailed + continue } signingRoot, err := generateSigningRoot(ctx, dataRoot[:], data[i].Domain) @@ -185,6 +195,7 @@ func (s *Service) SignBeaconAttestations( log.Error().Err(err).Str("result", "failed").Msg("Failed to generate signing root") s.monitor.SignCompleted(started, "attestation", core.ResultFailed) results[i] = core.ResultFailed + continue } @@ -194,6 +205,7 @@ func (s *Service) SignBeaconAttestations( log.Error().Err(err).Str("result", "failed").Msg("Failed to sign") s.monitor.SignCompleted(started, "attestation", core.ResultFailed) results[i] = core.ResultFailed + continue } @@ -202,7 +214,8 @@ func (s *Service) SignBeaconAttestations( results[i] = core.ResultSucceeded signatures[i] = signature } - return nil, nil + + return make([]*util.ScatterResult, 0), nil }) if err != nil { log.Error().Err(err).Str("result", "failed").Msg("Failed to scatter sign") @@ -268,5 +281,6 @@ func (*Service) checkAttestationsData(data []*rules.SignBeaconAttestationData, e.Msg("Data to sign") } } + return nil } diff --git a/services/signer/standard/signbeaconproposal.go b/services/signer/standard/signbeaconproposal.go index da92a04..6d6afd9 100644 --- a/services/signer/standard/signbeaconproposal.go +++ b/services/signer/standard/signbeaconproposal.go @@ -165,5 +165,6 @@ func (s *Service) SignBeaconProposal( log.Trace().Str("result", "succeeded").Msg("Success") s.monitor.SignCompleted(started, "proposal", core.ResultSucceeded) + return core.ResultSucceeded, signature } diff --git a/services/signer/standard/signgeneric.go b/services/signer/standard/signgeneric.go index d1fe5d4..22b760d 100644 --- a/services/signer/standard/signgeneric.go +++ b/services/signer/standard/signgeneric.go @@ -44,6 +44,7 @@ func (s *Service) SignGeneric( if credentials == nil { log.Error().Msg("No credentials supplied") + return core.ResultFailed, nil } span.SetAttributes(attribute.String("client", credentials.Client)) @@ -60,18 +61,21 @@ func (s *Service) SignGeneric( log.Warn().Str("result", "denied").Msg("Request empty") span.SetStatus(codes.Error, "Request empty") s.monitor.SignCompleted(started, "generic", core.ResultDenied) + return core.ResultDenied, nil } if data.Data == nil { log.Warn().Str("result", "denied").Msg("Request missing data") span.SetStatus(codes.Error, "Request missing data") s.monitor.SignCompleted(started, "generic", core.ResultDenied) + return core.ResultDenied, nil } if data.Domain == nil { log.Warn().Str("result", "denied").Msg("Request missing domain") span.SetStatus(codes.Error, "Request missing domain") s.monitor.SignCompleted(started, "generic", core.ResultDenied) + return core.ResultDenied, nil } @@ -91,6 +95,7 @@ func (s *Service) SignGeneric( if checkRes != core.ResultSucceeded { s.monitor.SignCompleted(started, "generic", checkRes) span.SetStatus(codes.Ok, "") + return checkRes, nil } accountName = fmt.Sprintf("%s/%s", wallet.Name(), account.Name()) @@ -112,16 +117,19 @@ func (s *Service) SignGeneric( s.monitor.SignCompleted(started, "generic", core.ResultDenied) span.SetStatus(codes.Ok, "") log.Debug().Str("result", "denied").Msg("Denied by rules") + return core.ResultDenied, nil case rules.FAILED: s.monitor.SignCompleted(started, "generic", core.ResultFailed) span.SetStatus(codes.Ok, "") log.Error().Str("result", "failed").Msg("Rules check failed") + return core.ResultFailed, nil case rules.UNKNOWN: s.monitor.SignCompleted(started, "generic", core.ResultFailed) span.SetStatus(codes.Ok, "") log.Error().Str("result", "failed").Msg("Rules check indeterminate result") + return core.ResultFailed, nil case rules.APPROVED: // Nothing to do. @@ -132,6 +140,7 @@ func (s *Service) SignGeneric( log.Error().Err(err).Str("result", "failed").Msg("Failed to generate signing root") span.SetStatus(codes.Error, "Failed to generate signing root") s.monitor.SignCompleted(started, "generic", core.ResultFailed) + return core.ResultFailed, nil } @@ -141,11 +150,13 @@ func (s *Service) SignGeneric( log.Error().Err(err).Str("result", "failed").Msg("Failed to sign") span.SetStatus(codes.Error, "Failed to sign") s.monitor.SignCompleted(started, "generic", core.ResultFailed) + return core.ResultFailed, nil } log.Trace().Str("result", "succeeded").Msg("Success") span.SetStatus(codes.Ok, "") s.monitor.SignCompleted(started, "generic", core.ResultSucceeded) + return core.ResultSucceeded, signature } diff --git a/services/signer/standard/util.go b/services/signer/standard/util.go index 5093401..58633d2 100644 --- a/services/signer/standard/util.go +++ b/services/signer/standard/util.go @@ -26,6 +26,7 @@ func generateSigningRoot(_ context.Context, root []byte, domain []byte) ([32]byt DataRoot: root, Domain: domain, } + return signingData.HashTreeRoot() } @@ -38,5 +39,6 @@ func signRoot(ctx context.Context, account e2wtypes.Account, root []byte) ([]byt if err != nil { return nil, err } + return signature.Marshal(), nil } diff --git a/services/unlocker/local/metrics.go b/services/unlocker/local/metrics.go index bfa1ee2..f8e9787 100644 --- a/services/unlocker/local/metrics.go +++ b/services/unlocker/local/metrics.go @@ -38,6 +38,7 @@ func registerMetrics(ctx context.Context, monitor metrics.Service) error { if monitor.Presenter() == "prometheus" { return registerPrometheusMetrics(ctx) } + return nil } @@ -66,6 +67,7 @@ func registerPrometheusMetrics(_ context.Context) error { 3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, 4.0, }, }) + return prometheus.Register(unlockAccountsTimer) } diff --git a/services/unlocker/local/service.go b/services/unlocker/local/service.go index dc91a07..9dc4387 100644 --- a/services/unlocker/local/service.go +++ b/services/unlocker/local/service.go @@ -78,6 +78,7 @@ func (s *Service) UnlockWallet(ctx context.Context, wallet e2wtypes.Wallet) (boo if err != nil { return false, err } + return true, nil } for _, passphrase := range s.walletPassphrases { @@ -85,6 +86,7 @@ func (s *Service) UnlockWallet(ctx context.Context, wallet e2wtypes.Wallet) (boo return true, nil } } + return false, nil } @@ -114,5 +116,6 @@ func (s *Service) UnlockAccount(ctx context.Context, wallet e2wtypes.Wallet, acc } monitorUnlockAccount(false, time.Since(started)) + return false, nil } diff --git a/services/walletmanager/mock/service.go b/services/walletmanager/mock/service.go index 383d31a..0ec430c 100644 --- a/services/walletmanager/mock/service.go +++ b/services/walletmanager/mock/service.go @@ -29,7 +29,7 @@ func New() *Service { } // Unlock unlocks a wallet. -func (s *Service) Unlock(_ context.Context, +func (*Service) Unlock(_ context.Context, _ *checker.Credentials, _ string, _ []byte, @@ -41,7 +41,7 @@ func (s *Service) Unlock(_ context.Context, } // Lock locks a wallet. -func (s *Service) Lock(_ context.Context, +func (*Service) Lock(_ context.Context, _ *checker.Credentials, _ string, ) ( diff --git a/services/walletmanager/standard/helpers.go b/services/walletmanager/standard/helpers.go index 7b699fd..0cdf2af 100644 --- a/services/walletmanager/standard/helpers.go +++ b/services/walletmanager/standard/helpers.go @@ -59,5 +59,6 @@ func (s *Service) checkAccess(ctx context.Context, credentials *checker.Credenti if s.checker.Check(ctx, credentials, accountName, action) { return core.ResultSucceeded } + return core.ResultDenied } diff --git a/services/walletmanager/standard/lock.go b/services/walletmanager/standard/lock.go index 5d75e37..82c46e8 100644 --- a/services/walletmanager/standard/lock.go +++ b/services/walletmanager/standard/lock.go @@ -96,5 +96,6 @@ func (s *Service) Lock(ctx context.Context, log.Trace().Str("result", "succeeded").Msg("Success") s.monitor.WalletManagerCompleted(started, "lock", core.ResultSucceeded) + return core.ResultSucceeded, nil } diff --git a/services/walletmanager/standard/monitor.go b/services/walletmanager/standard/monitor.go index 992ad65..5fe08ba 100644 --- a/services/walletmanager/standard/monitor.go +++ b/services/walletmanager/standard/monitor.go @@ -24,4 +24,4 @@ import ( type noopMonitor struct{} // WalletManagerCompleted is called when an wallet manager process has completed. -func (n *noopMonitor) WalletManagerCompleted(_ time.Time, _ string, _ core.Result) {} +func (*noopMonitor) WalletManagerCompleted(_ time.Time, _ string, _ core.Result) {} diff --git a/services/walletmanager/standard/parameters.go b/services/walletmanager/standard/parameters.go index b82c3e1..9f4327f 100644 --- a/services/walletmanager/standard/parameters.go +++ b/services/walletmanager/standard/parameters.go @@ -58,30 +58,30 @@ func WithMonitor(monitor metrics.WalletManagerMonitor) Parameter { } // WithChecker sets the access checker for this module. -func WithChecker(checker checker.Service) Parameter { +func WithChecker(service checker.Service) Parameter { return parameterFunc(func(p *parameters) { - p.checker = checker + p.checker = service }) } // WithRuler sets the ruler for this module. -func WithRuler(ruler ruler.Service) Parameter { +func WithRuler(service ruler.Service) Parameter { return parameterFunc(func(p *parameters) { - p.ruler = ruler + p.ruler = service }) } // WithUnlocker sets the account unlocker for this module. -func WithUnlocker(unlocker unlocker.Service) Parameter { +func WithUnlocker(service unlocker.Service) Parameter { return parameterFunc(func(p *parameters) { - p.unlocker = unlocker + p.unlocker = service }) } // WithFetcher sets the account fetcher for this module. -func WithFetcher(fetcher fetcher.Service) Parameter { +func WithFetcher(service fetcher.Service) Parameter { return parameterFunc(func(p *parameters) { - p.fetcher = fetcher + p.fetcher = service }) } diff --git a/services/walletmanager/standard/unlock.go b/services/walletmanager/standard/unlock.go index 7b18515..670bd1d 100644 --- a/services/walletmanager/standard/unlock.go +++ b/services/walletmanager/standard/unlock.go @@ -99,5 +99,6 @@ func (s *Service) Unlock(ctx context.Context, log.Trace().Str("result", "succeeded").Msg("Success") s.monitor.WalletManagerCompleted(started, "unlock", core.ResultSucceeded) + return core.ResultSucceeded, nil } diff --git a/slashingprotection.go b/slashingprotection.go index a9f6748..c7a9358 100644 --- a/slashingprotection.go +++ b/slashingprotection.go @@ -80,6 +80,7 @@ func exportSlashingProtection(ctx context.Context) int { } else { fmt.Fprintln(os.Stdout, string(data)) } + return 0 } @@ -98,11 +99,11 @@ func fetchSlashingProtection(ctx context.Context) (*SlashingProtection, error) { return nil, errors.New("genesis-validators-root must be 32 bytes") } - rules, err := initRules(ctx) + rulesSvc, err := initRules(ctx) if err != nil { return nil, errors.Wrap(err, "failed to set up rules") } - protection, err := rules.ExportSlashingProtection(ctx) + protection, err := rulesSvc.ExportSlashingProtection(ctx) if err != nil { return nil, errors.Wrap(err, "failed to obtain slashing protection") } diff --git a/testing/daemon/daemon.go b/testing/daemon/daemon.go index e1fdc4f..402c39e 100644 --- a/testing/daemon/daemon.go +++ b/testing/daemon/daemon.go @@ -213,7 +213,7 @@ func New(ctx context.Context, path string, id uint64, port uint32, peersMap map[ Operations: []string{"All"}, }, } - checker, err := staticchecker.New(ctx, + checkerSvc, err := staticchecker.New(ctx, staticchecker.WithPermissions(permissions), ) if err != nil { @@ -250,7 +250,7 @@ func New(ctx context.Context, path string, id uint64, port uint32, peersMap map[ lister, err := standardlister.New(ctx, standardlister.WithFetcher(fetcher), - standardlister.WithChecker(checker), + standardlister.WithChecker(checkerSvc), standardlister.WithRuler(ruler), ) if err != nil { @@ -259,7 +259,7 @@ func New(ctx context.Context, path string, id uint64, port uint32, peersMap map[ signer, err := standardsigner.New(ctx, standardsigner.WithUnlocker(unlocker), - standardsigner.WithChecker(checker), + standardsigner.WithChecker(checkerSvc), standardsigner.WithFetcher(fetcher), standardsigner.WithRuler(ruler), ) @@ -285,7 +285,7 @@ func New(ctx context.Context, path string, id uint64, port uint32, peersMap map[ } process, err := standardprocess.New(ctx, - standardprocess.WithChecker(checker), + standardprocess.WithChecker(checkerSvc), standardprocess.WithUnlocker(unlocker), standardprocess.WithSender(sender), standardprocess.WithFetcher(fetcher), @@ -301,7 +301,7 @@ func New(ctx context.Context, path string, id uint64, port uint32, peersMap map[ accountManager, err := standardaccountmanager.New(ctx, standardaccountmanager.WithUnlocker(unlocker), - standardaccountmanager.WithChecker(checker), + standardaccountmanager.WithChecker(checkerSvc), standardaccountmanager.WithFetcher(fetcher), standardaccountmanager.WithRuler(ruler), standardaccountmanager.WithProcess(process), @@ -312,7 +312,7 @@ func New(ctx context.Context, path string, id uint64, port uint32, peersMap map[ walletManager, err := standardwalletmanager.New(ctx, standardwalletmanager.WithUnlocker(unlocker), - standardwalletmanager.WithChecker(checker), + standardwalletmanager.WithChecker(checkerSvc), standardwalletmanager.WithFetcher(fetcher), standardwalletmanager.WithRuler(ruler), ) diff --git a/testing/logger/capture.go b/testing/logger/capture.go index d27d8f8..85544e7 100644 --- a/testing/logger/capture.go +++ b/testing/logger/capture.go @@ -37,6 +37,7 @@ func NewLogCapture() *LogCapture { entries: make([]string, 0), } zerologger.Logger = zerologger.Logger.Hook(c) + return c } diff --git a/testing/mock/account.go b/testing/mock/account.go index a16d8e8..39c761e 100644 --- a/testing/mock/account.go +++ b/testing/mock/account.go @@ -33,7 +33,7 @@ type Account struct { // NewAccount creates a new account. func NewAccount(name string, passphrase []byte) *Account { - uuid, err := uuid.NewRandom() + id, err := uuid.NewRandom() if err != nil { panic(err) } @@ -41,8 +41,9 @@ func NewAccount(name string, passphrase []byte) *Account { if err != nil { panic(err) } + return &Account{ - id: uuid, + id: id, privateKey: privateKey, name: name, passphrase: passphrase, @@ -66,7 +67,7 @@ func (a *Account) PublicKey() e2types.PublicKey { // Path provides the path for the account. // Can be empty if the account is not derived from a path. -func (a *Account) Path() string { +func (*Account) Path() string { return "" } @@ -82,6 +83,7 @@ func (a *Account) Unlock(_ context.Context, passphrase []byte) error { a.unlocked = true return nil } + return errors.New("invalid passphrase") } @@ -99,5 +101,6 @@ func (a *Account) Sign(ctx context.Context, data []byte) (e2types.Signature, err if !unlocked { return nil, errors.New("account is locked") } + return a.Sign(ctx, data) } diff --git a/testing/mock/net.go b/testing/mock/net.go index 375913c..3246286 100644 --- a/testing/mock/net.go +++ b/testing/mock/net.go @@ -18,6 +18,7 @@ import "github.com/attestantio/dirk/services/process" // Processes is a map of local process services. var Processes map[uint64]process.Service +//nolint:gochecknoinits func init() { Processes = make(map[uint64]process.Service) } diff --git a/testing/mock/wallet.go b/testing/mock/wallet.go index 319b1e9..d0c121e 100644 --- a/testing/mock/wallet.go +++ b/testing/mock/wallet.go @@ -28,12 +28,13 @@ type Wallet struct { // NewWallet creates a new wallet. func NewWallet(name string) *Wallet { - uuid, err := uuid.NewRandom() + id, err := uuid.NewRandom() if err != nil { panic(err) } + return &Wallet{ - id: uuid, + id: id, name: name, } } @@ -49,17 +50,17 @@ func (a *Wallet) Name() string { } // Type returns the type for the wallet. -func (a *Wallet) Type() string { +func (*Wallet) Type() string { return "mock" } // Version returns the version for the wallet. -func (a *Wallet) Version() uint { +func (*Wallet) Version() uint { return 1 } // Accounts returns the accounts in the wallet. -func (a *Wallet) Accounts(_ context.Context) <-chan e2wtypes.Account { +func (*Wallet) Accounts(_ context.Context) <-chan e2wtypes.Account { ch := make(chan e2wtypes.Account, 1024) close(ch) return ch diff --git a/testing/resources/certs.go b/testing/resources/certs.go index 0f171a4..c2618d5 100644 --- a/testing/resources/certs.go +++ b/testing/resources/certs.go @@ -574,5 +574,6 @@ func SetupCerts(base string) error { if err := os.WriteFile(filepath.Join(base, "client-test03.crt"), ClientTest03Crt, 0o600); err != nil { return err } + return os.WriteFile(filepath.Join(base, "client-test03.key"), ClientTest03Key, 0o600) } diff --git a/tracing.go b/tracing.go index b294b29..004fd8c 100644 --- a/tracing.go +++ b/tracing.go @@ -39,7 +39,7 @@ import ( ) // initTracing initialises the tracing system. -func initTracing(ctx context.Context, majordomo majordomo.Service) error { +func initTracing(ctx context.Context, majordomoSvc majordomo.Service) error { if viper.GetString("tracing.address") == "" { log.Debug().Msg("No tracing endpoint supplied; tracing not enabled") return nil @@ -51,7 +51,7 @@ func initTracing(ctx context.Context, majordomo majordomo.Service) error { } if viper.GetString("tracing.client-cert") != "" { log.Trace().Msg("Using TLS tracing connection") - creds, err := credentialsFromCerts(ctx, majordomo, "tracing") + creds, err := credentialsFromCerts(ctx, majordomoSvc, "tracing") if err != nil { return errors.Wrap(err, "invalid TLS credentials") } @@ -111,21 +111,27 @@ func initTracing(ctx context.Context, majordomo majordomo.Service) error { return nil } -func credentialsFromCerts(ctx context.Context, majordomo majordomo.Service, base string) (credentials.TransportCredentials, error) { +func credentialsFromCerts(ctx context.Context, + majordomoSvc majordomo.Service, + base string, +) ( + credentials.TransportCredentials, + error, +) { _, span := otel.Tracer("attestantio.vouch").Start(ctx, "credentialsFromCerts") defer span.End() - clientCert, err := majordomo.Fetch(ctx, viper.GetString(fmt.Sprintf("%s.client-cert", base))) + clientCert, err := majordomoSvc.Fetch(ctx, viper.GetString(fmt.Sprintf("%s.client-cert", base))) if err != nil { return nil, errors.Wrap(err, "failed to obtain server certificate") } - clientKey, err := majordomo.Fetch(ctx, viper.GetString(fmt.Sprintf("%s.client-key", base))) + clientKey, err := majordomoSvc.Fetch(ctx, viper.GetString(fmt.Sprintf("%s.client-key", base))) if err != nil { return nil, errors.Wrap(err, "failed to obtain server key") } var caCert []byte if viper.GetString(fmt.Sprintf("%s.ca-cert", base)) != "" { - caCert, err = majordomo.Fetch(ctx, viper.GetString(fmt.Sprintf("%s.ca-cert", base))) + caCert, err = majordomoSvc.Fetch(ctx, viper.GetString(fmt.Sprintf("%s.ca-cert", base))) if err != nil { return nil, errors.Wrap(err, "failed to obtain client CA certificate") } diff --git a/util/bls.go b/util/bls.go index 8dc5943..c1548db 100644 --- a/util/bls.go +++ b/util/bls.go @@ -27,5 +27,6 @@ func BLSID(id uint64) *bls.ID { if err := res.SetLittleEndian(buf[:]); err != nil { panic(err) } + return &res } diff --git a/util/commit.go b/util/commit.go index 6f100fa..ad65a2e 100644 --- a/util/commit.go +++ b/util/commit.go @@ -15,7 +15,7 @@ package util import "runtime/debug" -// CommitHah returns the commit hash of the build, if available. +// CommitHash returns the commit hash of the build, if available. func CommitHash() string { if info, ok := debug.ReadBuildInfo(); ok { for _, setting := range info.Settings { diff --git a/util/loggers/badger.go b/util/loggers/badger.go index b7a3643..cbee884 100644 --- a/util/loggers/badger.go +++ b/util/loggers/badger.go @@ -41,25 +41,26 @@ func NewBadgerLogger(log zerolog.Logger) *BadgerLogger { case zerolog.NoLevel, zerolog.Disabled: } log = log.With().Str("store", "badger").Logger() + return &BadgerLogger{log: log} } // Errorf logs to ERROR log. Arguments are handled in the manner of fmt.Printf. -func (l *BadgerLogger) Errorf(format string, args ...interface{}) { +func (l *BadgerLogger) Errorf(format string, args ...any) { l.log.Error().Msgf(strings.TrimSpace(format), args...) } // Warningf logs to WARNING log. Arguments are handled in the manner of fmt.Printf. -func (l *BadgerLogger) Warningf(format string, args ...interface{}) { +func (l *BadgerLogger) Warningf(format string, args ...any) { l.log.Warn().Msgf(strings.TrimSpace(format), args...) } // Infof logs to INFO log. Arguments are handled in the manner of fmt.Printf. -func (l *BadgerLogger) Infof(format string, args ...interface{}) { +func (l *BadgerLogger) Infof(format string, args ...any) { l.log.Info().Msgf(strings.TrimSpace(format), args...) } // Debugf logs to DEBUG log. Arguments are handled in the manner of fmt.Printf. -func (l *BadgerLogger) Debugf(format string, args ...interface{}) { +func (l *BadgerLogger) Debugf(format string, args ...any) { l.log.Debug().Msgf(strings.TrimSpace(format), args...) } diff --git a/util/loggers/grpcloggerv2.go b/util/loggers/grpcloggerv2.go index 8fdb432..791f76f 100644 --- a/util/loggers/grpcloggerv2.go +++ b/util/loggers/grpcloggerv2.go @@ -30,68 +30,68 @@ func NewGRPCLoggerV2(log zerolog.Logger) *GRPCLoggerV2 { } // Info logs to INFO log. Arguments are handled in the manner of fmt.Print. -func (l *GRPCLoggerV2) Info(args ...interface{}) { +func (l *GRPCLoggerV2) Info(args ...any) { l.log.Info().Msg(fmt.Sprint(args...)) } // Infoln logs to INFO log. Arguments are handled in the manner of fmt.Println. -func (l *GRPCLoggerV2) Infoln(args ...interface{}) { +func (l *GRPCLoggerV2) Infoln(args ...any) { l.Info(args...) } // Infof logs to INFO log. Arguments are handled in the manner of fmt.Printf. -func (l *GRPCLoggerV2) Infof(format string, args ...interface{}) { +func (l *GRPCLoggerV2) Infof(format string, args ...any) { l.log.Info().Msgf(format, args...) } // Warning logs to WARNING log. Arguments are handled in the manner of fmt.Print. -func (l *GRPCLoggerV2) Warning(args ...interface{}) { +func (l *GRPCLoggerV2) Warning(args ...any) { l.log.Warn().Msg(fmt.Sprint(args...)) } // Warningln logs to WARNING log. Arguments are handled in the manner of fmt.Println. -func (l *GRPCLoggerV2) Warningln(args ...interface{}) { +func (l *GRPCLoggerV2) Warningln(args ...any) { l.Warning(args...) } // Warningf logs to WARNING log. Arguments are handled in the manner of fmt.Printf. -func (l *GRPCLoggerV2) Warningf(format string, args ...interface{}) { +func (l *GRPCLoggerV2) Warningf(format string, args ...any) { l.log.Warn().Msgf(format, args...) } // Error logs to ERROR log. Arguments are handled in the manner of fmt.Print. -func (l *GRPCLoggerV2) Error(args ...interface{}) { +func (l *GRPCLoggerV2) Error(args ...any) { l.log.Error().Msg(fmt.Sprint(args...)) } // Errorln logs to ERROR log. Arguments are handled in the manner of fmt.Println. -func (l *GRPCLoggerV2) Errorln(args ...interface{}) { +func (l *GRPCLoggerV2) Errorln(args ...any) { l.Error(args...) } // Errorf logs to ERROR log. Arguments are handled in the manner of fmt.Printf. -func (l *GRPCLoggerV2) Errorf(format string, args ...interface{}) { +func (l *GRPCLoggerV2) Errorf(format string, args ...any) { l.log.Error().Msgf(format, args...) } // Fatal logs to ERROR log. Arguments are handled in the manner of fmt.Print. // gRPC ensures that all Fatal logs will exit with os.Exit(1). // Implementations may also call os.Exit() with a non-zero exit code. -func (l *GRPCLoggerV2) Fatal(args ...interface{}) { +func (l *GRPCLoggerV2) Fatal(args ...any) { l.log.Fatal().Msg(fmt.Sprint(args...)) } // Fatalln logs to ERROR log. Arguments are handled in the manner of fmt.Println. // gRPC ensures that all Fatal logs will exit with os.Exit(1). // Implementations may also call os.Exit() with a non-zero exit code. -func (l *GRPCLoggerV2) Fatalln(args ...interface{}) { +func (l *GRPCLoggerV2) Fatalln(args ...any) { l.Fatal(args...) } // Fatalf logs to ERROR log. Arguments are handled in the manner of fmt.Printf. // gRPC ensures that all Fatal logs will exit with os.Exit(1). // Implementations may also call os.Exit() with a non-zero exit code. -func (l *GRPCLoggerV2) Fatalf(format string, args ...interface{}) { +func (l *GRPCLoggerV2) Fatalf(format string, args ...any) { l.log.Fatal().Msgf(format, args...) } diff --git a/util/loggers/jaeger.go b/util/loggers/jaeger.go index 8813658..2129d6b 100644 --- a/util/loggers/jaeger.go +++ b/util/loggers/jaeger.go @@ -33,6 +33,6 @@ func (l *JaegerLogger) Error(msg string) { } // Infof logs information. -func (l *JaegerLogger) Infof(msg string, args ...interface{}) { +func (l *JaegerLogger) Infof(msg string, args ...any) { l.log.Info().Msgf(msg, args...) } diff --git a/util/logging.go b/util/logging.go index bbc0787..b5b53dd 100644 --- a/util/logging.go +++ b/util/logging.go @@ -37,6 +37,7 @@ func LogLevel(path string) zerolog.Level { if lastPeriod == -1 { return LogLevel("") } + return LogLevel(path[0:lastPeriod]) } diff --git a/util/majordomo.go b/util/majordomo.go index afafe8b..7c42822 100644 --- a/util/majordomo.go +++ b/util/majordomo.go @@ -27,6 +27,7 @@ import ( standardmajordomo "github.com/wealdtech/go-majordomo/standard" ) +// InitMajordomo sets up the Majordomo service. func InitMajordomo(ctx context.Context) (majordomo.Service, error) { majordomo, err := standardmajordomo.New(ctx, standardmajordomo.WithLogLevel(LogLevel("majordomo")), diff --git a/util/path.go b/util/path.go index 42de705..b32dc83 100644 --- a/util/path.go +++ b/util/path.go @@ -33,5 +33,6 @@ func ResolvePath(path string) string { } baseDir = homeDir } + return filepath.Join(baseDir, path) } diff --git a/util/scatter.go b/util/scatter.go index 937ff67..78ff46d 100644 --- a/util/scatter.go +++ b/util/scatter.go @@ -24,11 +24,11 @@ type ScatterResult struct { // Offset is the offset at which the worker started. Offset int // Extent is the user-defined result of running the scatter function. - Extent interface{} + Extent any } // Scatter scatters a computation across multiple goroutines, returning a set of per-worker results. -func Scatter(inputLen int, work func(int, int, *sync.RWMutex) (interface{}, error)) ([]*ScatterResult, error) { +func Scatter(inputLen int, work func(int, int, *sync.RWMutex) (any, error)) ([]*ScatterResult, error) { if inputLen <= 0 { return nil, errors.New("no data with which to work") } @@ -75,6 +75,7 @@ func Scatter(inputLen int, work func(int, int, *sync.RWMutex) (interface{}, erro // and can cause other workers to write to the closed channel. } } + return results, err } diff --git a/util/scatter_benchmark_test.go b/util/scatter_benchmark_test.go index f308f85..37cdc26 100644 --- a/util/scatter_benchmark_test.go +++ b/util/scatter_benchmark_test.go @@ -64,7 +64,7 @@ func BenchmarkHash(b *testing.B) { func BenchmarkHashMP(b *testing.B) { output := make([][]byte, len(input)) for i := 0; i < b.N; i++ { - workerResults, err := util.Scatter(len(input), func(offset int, entries int, _ *sync.RWMutex) (interface{}, error) { + workerResults, err := util.Scatter(len(input), func(offset int, entries int, _ *sync.RWMutex) (any, error) { return hash(input[offset : offset+entries]), nil }) require.NoError(b, err) diff --git a/util/scatter_test.go b/util/scatter_test.go index cbd7b7d..5d7fa8c 100644 --- a/util/scatter_test.go +++ b/util/scatter_test.go @@ -59,7 +59,7 @@ func TestDouble(t *testing.T) { inValues[i] = i } outValues := make([]int, test.inValues) - workerResults, err := util.Scatter(len(inValues), func(offset int, entries int, _ *sync.RWMutex) (interface{}, error) { + workerResults, err := util.Scatter(len(inValues), func(offset int, entries int, _ *sync.RWMutex) (any, error) { extent := make([]int, entries) for i := 0; i < entries; i++ { extent[i] = inValues[offset+i] * 2 @@ -85,7 +85,7 @@ func TestDouble(t *testing.T) { func TestMutex(t *testing.T) { totalRuns := 1048576 val := 0 - _, err := util.Scatter(totalRuns, func(offset int, entries int, mu *sync.RWMutex) (interface{}, error) { + _, err := util.Scatter(totalRuns, func(offset int, entries int, mu *sync.RWMutex) (any, error) { for i := 0; i < entries; i++ { mu.Lock() val++ @@ -100,7 +100,7 @@ func TestMutex(t *testing.T) { func TestError(t *testing.T) { totalRuns := 1024 val := 0 - _, err := util.Scatter(totalRuns, func(offset int, entries int, mu *sync.RWMutex) (interface{}, error) { + _, err := util.Scatter(totalRuns, func(offset int, entries int, mu *sync.RWMutex) (any, error) { for i := 0; i < entries; i++ { mu.Lock() val++