Skip to content

Commit

Permalink
chore: EigenDA V8 dep bump - bump eigenda to incorporate tls disperse…
Browse files Browse the repository at this point in the history
…r read client fix && add linting
  • Loading branch information
EthenNotEthan committed Aug 20, 2024
1 parent 0be34cc commit 77b8796
Show file tree
Hide file tree
Showing 28 changed files with 424 additions and 265 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: hygeiene

on:
push:
branches: [ "master", "development" ]
pull_request:
branches: [ "master", "development" ]

jobs:
golangci:
# Linting job
# https://github.com/golangci/golangci-lint-action
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: v1.52.1
226 changes: 226 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,226 @@
run:
# Analysis timeout, e.g. 30s, 5m.
# Default: 1m
timeout: 5m

# https://github.com/golangci/golangci-lint/blob/master/.golangci.reference.yml
linters-settings:
cyclop:
# The maximal code complexity to report.
# Default: 10
max-complexity: 30
# The maximal average package complexity.
# If it's higher than 0.0 (float) the check is enabled
# Default: 0.0
package-average: 20.0

errcheck:
# Report about not checking of errors in type assertions: `a := b.(MyStruct)`.
# Default: false
check-type-assertions: true

exhaustive:
# Program elements to check for exhaustiveness.
# Default: [ switch ]
check:
- switch
- map

exhaustruct:
# List of regular expressions to exclude struct packages and names from check.
# Default: []
exclude:
# std libs
- "^os/exec.Cmd$"
# public libs
- "^github.com/stretchr/testify/mock.Mock$"

funlen:
# Assert a maximum number of lines for a function.
# Default: 60
lines: 150
# Assert a maximum number of statements in a function.
# Default: 40
statements: 60

gocognit:
# Minimal code complexity to report.
# Default: 30
min-complexity: 35

gocritic:
# Settings passed to gocritic.
# The settings key is the name of a supported gocritic checker.
# The list of supported checkers can be find in https://go-critic.github.io/overview.
settings:
captLocal:
# Whether to restrict checker to params only.
# Default: true
paramsOnly: false
underef:
# Whether to skip (*x).method() calls where x is a pointer receiver.
# Default: true
skipRecvDeref: false

# gomnd:
# # List of function regex patterns to exclude from analysis.
# # Default: []
# ignored-functions:
# -
gomodguard:
blocked:
# List of blocked modules.
# Default: []
modules:
-
govet:
# Enable all analyzers.
# Default: false
enable-all: true
# Disable analyzers by name.
# Run `go tool vet help` to see all analyzers.
# Default: []
disable:
- fieldalignment # too strict
# Settings per analyzer.
settings:
shadow:
# Whether to be strict about shadowing; can be noisy.
# Default: false
strict: true

nakedret:
# Make an issue if func has more lines of code than this setting, and it has naked returns.
# Default: 30
max-func-lines: 0

nolintlint:
# Exclude following linters from requiring an explanation.
# Default: []
allow-no-explanation: [ funlen, gocognit, lll, whitespace ]
# Enable to require an explanation of nonzero length after each nolint directive.
# Default: false
require-explanation: true
# Enable to require nolint directives to mention the specific linter being suppressed.
# Default: false
require-specific: true

tenv:
# The option `all` will run against whole test files (`_test.go`) regardless of method/function signatures.
# Otherwise, only methods that take `*testing.T`, `*testing.B`, and `testing.TB` as arguments are checked.
# Default: false
all: true


linters:
disable-all: true
enable:
## enabled by default
- errcheck # checking for unchecked errors, these unchecked errors can be critical bugs in some cases
- gosimple # specializes in simplifying a code
- ineffassign # detects when assignments to existing variables are not used
- staticcheck # is a go vet on steroids, applying a ton of static analysis checks
- typecheck # like the front-end of a Go compiler, parses and type-checks Go code
- unused # checks for unused constants, variables, functions and types
## disabled by default
- asasalint # checks for pass []any as any in variadic func(...any)
- asciicheck # checks that your code does not contain non-ASCII identifiers
- bidichk # checks for dangerous unicode character sequences
- bodyclose # checks whether HTTP response body is closed successfully
- cyclop # checks function and package cyclomatic complexity
- dupl # tool for code clone detection
- durationcheck # checks for two durations multiplied together
- errname # checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error
- errorlint # finds code that will cause problems with the error wrapping scheme introduced in Go 1.13
- execinquery # checks query string in Query function which reads your Go src files and warning it finds
- exhaustive # checks exhaustiveness of enum switch statements
- exportloopref # checks for pointers to enclosing loop variables
- forbidigo # forbids identifiers
- funlen # tool for detection of long functions
- gocheckcompilerdirectives # validates go compiler directive comments (//go:)
# - gochecknoinits # checks that no init functions are present in Go code
- gocognit # computes and checks the cognitive complexity of functions
- goconst # finds repeated strings that could be replaced by a constant
- gocritic # provides diagnostics that check for bugs, performance and style issues
- gocyclo # computes and checks the cyclomatic complexity of functions
- goimports # in addition to fixing imports, goimports also formats your code in the same style as gofmt
# - gomnd # detects magic numbers
- gofmt
- gomodguard # allow and block lists linter for direct Go module dependencies. This is different from depguard where there are different block types for example version constraints and module recommendations
- goprintffuncname # checks that printf-like functions are named with f at the end
- gosec # inspects source code for security problems
# - lll # reports long lines
- loggercheck # checks key value pairs for common logger libraries (kitlog,klog,logr,zap)
- makezero # finds slice declarations with non-zero initial length
- misspell # Ensures real english is used within strings
- nakedret # finds naked returns in functions greater than a specified function length
- nestif # reports deeply nested if statements
- nilerr # finds the code that returns nil even if it checks that the error is not nil
- nilnil # checks that there is no simultaneous return of nil error and an invalid value
- noctx # finds sending http request without context.Context
- nolintlint # reports ill-formed or insufficient nolint directives
- nonamedreturns # reports all named returns
- nosprintfhostport # checks for misuse of Sprintf to construct a host with port in a URL
- predeclared # finds code that shadows one of Go's predeclared identifiers
- promlinter # checks Prometheus metrics naming via promlint
- reassign # checks that package variables are not reassigned
- revive # fast, configurable, extensible, flexible, and beautiful linter for Go, drop-in replacement of golint
- rowserrcheck # checks whether Err of rows is checked successfully
- sqlclosecheck # checks that sql.Rows and sql.Stmt are closed
- stylecheck # is a replacement for golint
- tenv # detects using os.Setenv instead of t.Setenv since Go1.17
- testableexamples # checks if examples are testable (have an expected output)
- testpackage # makes you use a separate _test package
- tparallel # detects inappropriate usage of t.Parallel() method in your Go test codes
- unconvert # removes unnecessary type conversions
- unparam # reports unused function parameters
- usestdlibvars # detects the possibility to use variables/constants from the Go standard library
- wastedassign # finds wasted assignment statements
- whitespace # detects leading and trailing whitespace

## May want to enable
#- - gochecknoglobals # checks that no global variables exist
#- - govet # reports suspicious constructs, such as Printf calls whose arguments do not align with the format string
#- - gomoddirectives # manages the use of 'replace', 'retract', and 'excludes' directives in go.mod
#- - godot # checks if comments end in a period
#- decorder # checks declaration order and count of types, constants, variables and functions
#- exhaustruct # [highly recommend to enable] checks if all structure fields are initialized
#- gci # controls golang package import order and makes it always deterministic
#- ginkgolinter # [if you use ginkgo/gomega] enforces standards of using ginkgo and gomega
#- godox # detects FIXME, TODO and other comment keywords
#- goheader # checks is file header matches to pattern
#- interfacebloat # checks the number of methods inside an interface
#- ireturn # accept interfaces, return concrete types
#- prealloc # [premature optimization, but can be used in some cases] finds slice declarations that could potentially be preallocated
#- varnamelen # [great idea, but too many false positives] checks that the length of a variable's name matches its scope
#- wrapcheck # checks that errors returned from external packages are wrapped

issues:
# Maximum count of issues with the same text.
# Set to 0 to disable.
# Default: 3
max-same-issues: 50

exclude-rules:
- source: "(noinspection|TODO)"
linters: [ godot ]
- source: "// noinspection"
linters:
- gocritic
- unparam

- path: "_test\\.go"
linters:
- gocognit
- govet
- testpackage
- bodyclose
- dupl
- funlen
- goconst
- gosec
- noctx
- wrapcheck
- lll
- whitespace

6 changes: 3 additions & 3 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func New(cfg *Config) ProxyClient {
// when integration testing
func (c *client) Health() error {
url := c.cfg.URL + "/health"
req, err := http.NewRequest(http.MethodGet, url, nil)
req, err := http.NewRequestWithContext(context.Background(), http.MethodGet, url, nil)
if err != nil {
return err
}
Expand All @@ -48,6 +48,7 @@ func (c *client) Health() error {
if err != nil {
return err
}
defer resp.Body.Close()

if resp.StatusCode != http.StatusOK {
return fmt.Errorf("received bad status code: %d", resp.StatusCode)
Expand All @@ -62,7 +63,7 @@ func (c *client) GetData(ctx context.Context, comm []byte) ([]byte, error) {

req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
if err != nil {
return nil, fmt.Errorf("failed to construct http request: %e", err)
return nil, fmt.Errorf("failed to construct http request: %w", err)
}

req.Header.Set("Content-Type", "application/octet-stream")
Expand All @@ -83,7 +84,6 @@ func (c *client) GetData(ctx context.Context, comm []byte) ([]byte, error) {
}

return b, nil

}

// SetData writes raw byte data to DA and returns the respective certificate
Expand Down
6 changes: 3 additions & 3 deletions cmd/server/entrypoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@ func StartProxySvr(cliCtx *cli.Context) error {

log.Info("Initializing EigenDA proxy server...")

daRouter, err := server.LoadStoreRouter(cfg, ctx, log)
daRouter, err := server.LoadStoreRouter(ctx, cfg, log)
if err != nil {
return fmt.Errorf("failed to create store: %w", err)
}
server := server.NewServer(cliCtx.String(server.ListenAddrFlagName), cliCtx.Int(server.PortFlagName), daRouter, log, m)

if err := server.Start(); err != nil {
return fmt.Errorf("failed to start the DA server")
} else {
log.Info("Started EigenDA proxy server")
}

log.Info("Started EigenDA proxy server")

defer func() {
if err := server.Stop(); err != nil {
log.Error("failed to stop DA server", "err", err)
Expand Down
1 change: 0 additions & 1 deletion cmd/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,4 @@ func main() {
if err != nil {
log.Crit("Application failed", "message", err)
}

}
2 changes: 0 additions & 2 deletions commitments/mode.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ func StringToDecodedCommitment(key string, c CommitmentMode) ([]byte, error) {
}

func EncodeCommitment(b []byte, c CommitmentMode) ([]byte, error) {

switch c {
case OptimismGeneric:
return Keccak256Commitment(b).Encode(), nil
Expand All @@ -70,7 +69,6 @@ func EncodeCommitment(b []byte, c CommitmentMode) ([]byte, error) {

case SimpleCommitmentMode:
return NewV0CertCommitment(b).Encode(), nil

}

return nil, fmt.Errorf("unknown commitment mode")
Expand Down
7 changes: 4 additions & 3 deletions commitments/op.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func DecodeGenericCommitment(commitment []byte) (GenericCommitment, error) {
if len(commitment) == 0 {
return nil, ErrInvalidCommitment
}
return commitment[:], nil
return commitment, nil
}

// CommitmentType returns the commitment type of Generic Commitment.
Expand All @@ -141,7 +141,8 @@ func (c GenericCommitment) Encode() []byte {
return append([]byte{byte(GenericCommitmentType)}, c...)
}

// Verify always returns true for GenericCommitment because the DA Server must validate the data before returning it to the op-node.
func (c GenericCommitment) Verify(input []byte) error {
// Verify always returns true for GenericCommitment because the DA Server
// must validate the data before returning it to the op-node.
func (c GenericCommitment) Verify(_ []byte) error {
return nil
}
Loading

0 comments on commit 77b8796

Please sign in to comment.