Skip to content

Commit

Permalink
Cleaned batch struct and created a dedicated settlement batch struct …
Browse files Browse the repository at this point in the history
…+ added linters and cleaned repo accordingly. (dymensionxyz#31)
  • Loading branch information
omritoptix authored Jul 28, 2022
1 parent df59a6a commit 6c4dd38
Show file tree
Hide file tree
Showing 13 changed files with 218 additions and 319 deletions.
2 changes: 1 addition & 1 deletion block/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ func (m *Manager) submitBlockToDA(ctx context.Context, block *types.Block) error
}

if !submitted {
return fmt.Errorf("Failed to submit block to DA layer after %d attempts", maxSubmitAttempts)
return fmt.Errorf("failed to submit block to DA layer after %d attempts", maxSubmitAttempts)
}

m.HeaderOutCh <- &block.Header
Expand Down
142 changes: 132 additions & 10 deletions contrib/githooks/pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,142 @@
repos:
# ==========================================================================
# Golang Pre-Commit Hooks | https://github.com/tekwizely/pre-commit-golang
#
# Visit the project home page to learn more about the available Hooks,
# including useful arguments you might want to pass into them.
#
# File-Based Hooks:
# Run against matching staged files individually.
#
# Module-Based Hooks:
# Run against module root folders containing matching staged files.
#
# Package-Based Hooks:
# Run against folders containing one or more staged files.
#
# Repo-Based Hooks:
# Run against the entire repo.
# The hooks only run once (if any matching files are staged),
# and are NOT provided the list of staged files,
#
# My-Cmd-* Hooks
# Allow you to invoke custom tools in varous contexts.
# Can be useful if your favorite tool(s) are not built-in (yet)
#
# Hook Suffixes
# Hooks have suffixes in their name that indicate their targets:
#
# +-----------+--------------+
# | Suffix | Target |
# |-----------+--------------+
# | <none> | Files |
# | -mod | Module |
# | -pkg | Package |
# | -repo | Repo Root |
# | -repo-mod | All Modules |
# | -repo-pkg | All Packages |
# +-----------+--------------+
#
# ! Multiple Hook Invocations
# ! Due to OS command-line-length limits, Pre-Commit can invoke a hook
# ! multiple times if a large number of files are staged.
# ! For file and repo-based hooks, this isn't an issue, but for module
# ! and package-based hooks, there is a potential for the hook to run
# ! against the same module or package multiple times, duplicating any
# ! errors or warnings.
#
# Useful Hook Parameters:
# - id: hook-id
# args: [arg1, arg2, ..., '--'] # Pass options ('--' is optional)
# always_run: true # Run even if no matching files staged
# alias: hook-alias # Create an alias
#
# Passing Options To Hooks:
# If your options contain a reference to an existing file, then you will
# need to use a trailing '--' argument to separate the hook options from
# the modified-file list that Pre-Commit passes into the hook.
# NOTE: For repo-based hooks, '--' is not needed.
#
# Always Run:
# By default, hooks ONLY run when matching file types are staged.
# When configured to "always_run", a hook is executed as if EVERY matching
# file were staged.
#
# Aliases:
# Consider adding aliases to longer-named hooks for easier CLI usage.
# ==========================================================================
- repo: https://github.com/tekwizely/pre-commit-golang
rev: master
hooks:
#
# Go Build
#
- id: go-build-mod
- id: go-build-repo-mod
#
# Go Mod Tidy
#
# - id: go-mod-tidy
# - id: go-mod-tidy-repo
#
# Go Test
#
- id: go-test-mod
- id: go-test-repo-mod
# #
# Go Vet
#
- id: go-vet-mod
- id: go-vet-repo-mod
#
# GoSec
#
- id: go-sec-mod
- id: go-sec-repo-mod
#
# StaticCheck
#
- id: go-staticcheck-mod
- id: go-staticcheck-repo-mod
#
# StructSlop
#
- id: go-structslop-mod
- id: go-structslop-repo-mod
#
# Formatters
#
- id: go-fmt
- id: go-imports # replaces go-fmt
- id: go-returns # replaces go-imports & go-fmt
#
# GolangCI-Lint
# - Fast Multi-Linter
# - Can be configured to replace MOST other hooks
# - Supports repo config file for configuration
# - https://github.com/golangci/golangci-lint
#
- id: golangci-lint-mod
- id: golangci-lint-repo-mod
#
# # Invoking Custom Go Tools
# # - Configured *entirely* through the `args` attribute, ie:
# # args: [ go, test, ./... ]
# # - Use the `name` attribute to provide better messaging when the hook runs
# # - Use the `alias` attribute to be able invoke your hook via `pre-commit run`
# #
# - id: my-cmd
# - id: my-cmd-mod
# - id: my-cmd-pkg
# - id: my-cmd-repo
# - id: my-cmd-repo-mod
# - id: my-cmd-repo-pkg
- repo: https://github.com/dnephin/pre-commit-golang
rev: master
hooks:
- id: go-fmt
- id: go-vet
- id: go-lint
- id: go-imports
- id: go-cyclo
args: [-over=15]
- id: validate-toml
- id: no-go-testing
- id: golangci-lint
- id: go-critic
- id: go-unit-tests
- id: go-build
- id: go-mod-tidy
- repo: https://github.com/jumanjihouse/pre-commit-hooks
rev: master
hooks:
Expand Down
2 changes: 1 addition & 1 deletion da/mock/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,6 @@ func getKey(daHeight uint64, height uint64) []byte {
}

func (m *DataAvailabilityLayerClient) updateDAHeight() {
blockStep := rand.Uint64()%10 + 1
blockStep := rand.Uint64()%10 + 1 //#nosec
atomic.AddUint64(&m.daHeight, blockStep)
}
15 changes: 9 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ require (
github.com/stretchr/testify v1.8.0
github.com/tendermint/tendermint v0.34.14
go.uber.org/multierr v1.8.0
golang.org/x/net v0.0.0-20220520000938-2e3eb7b945c2
golang.org/x/net v0.0.0-20220722155237-a158d28d115b
google.golang.org/grpc v1.46.2
google.golang.org/protobuf v1.28.0
)
Expand All @@ -41,6 +41,7 @@ require (
github.com/containerd/cgroups v1.0.3 // indirect
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
github.com/cosmos/go-bip39 v1.0.0 // indirect
github.com/dave/dst v0.26.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c // indirect
github.com/dgraph-io/badger/v2 v2.2007.2 // indirect
Expand Down Expand Up @@ -148,6 +149,7 @@ require (
github.com/onsi/gomega v1.16.0 // indirect
github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/orijtech/structslop v0.0.6 // indirect
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.1 // indirect
Expand All @@ -168,6 +170,7 @@ require (
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/sqs/goreturns v0.0.0-20181028201513-538ac6014518 // indirect
github.com/stretchr/objx v0.4.0 // indirect
github.com/subosito/gotenv v1.3.0 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20200815110645-5c35d600f0ca // indirect
Expand All @@ -181,12 +184,12 @@ require (
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/zap v1.21.0 // indirect
golang.org/x/crypto v0.0.0-20220518034528-6f7dac969898 // indirect
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c // indirect
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 // indirect
golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/tools v0.1.10 // indirect
golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df // indirect
golang.org/x/tools v0.1.12 // indirect
golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f // indirect
google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd // indirect
gopkg.in/ini.v1 v1.66.4 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
Expand Down
Loading

0 comments on commit 6c4dd38

Please sign in to comment.