diff --git a/.cz.yaml b/.cz.yaml new file mode 100644 index 00000000..5909d5da --- /dev/null +++ b/.cz.yaml @@ -0,0 +1,8 @@ +--- +commitizen: + major_version_zero: true + name: cz_gitmoji + tag_format: v$version + update_changelog_on_bump: true + version: 0.11.21 + version_scheme: semver diff --git a/.gitignore b/.gitignore index deaf6354..f8da1d1a 100644 --- a/.gitignore +++ b/.gitignore @@ -19,4 +19,4 @@ docker/pgadmin node_trace.* internal/bin conf.*.private -.idea \ No newline at end of file +.idea diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..96ed4e7c --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,43 @@ +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.6.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-json + - id: check-added-large-files + - id: check-shebang-scripts-are-executable + - id: detect-private-key + - id: forbid-submodules + - id: mixed-line-ending + + - repo: https://github.com/TekWizely/pre-commit-golang + rev: v1.0.0-rc.1 + hooks: + - id: go-fmt + - id: go-mod-tidy + - id: go-imports + - id: golangci-lint-repo-mod + + - repo: https://github.com/adrienverge/yamllint + rev: v1.35.1 + hooks: + - id: yamllint + + - repo: https://github.com/commitizen-tools/commitizen + rev: v3.21.3 + hooks: + - id: commitizen + additional_dependencies: + - "cz-conventional-gitmoji" + - id: commitizen-branch + additional_dependencies: + - "cz-conventional-gitmoji" + stages: [push] + + - repo: https://github.com/ljnsn/cz-conventional-gitmoji + rev: v0.2.4 + hooks: + - id: conventional-gitmoji diff --git a/.yamllint.yaml b/.yamllint.yaml new file mode 100644 index 00000000..9a64ca83 --- /dev/null +++ b/.yamllint.yaml @@ -0,0 +1,18 @@ +extends: relaxed + +yaml-files: + - '*.yaml' + - '*.yaml.template' + - '*.yml' + - '.yamllint' + +ignore: + - k8s/charts/unchained-worker/* + - '*.private/*' + - '*.private.yaml' + +rules: + indentation: + spaces: 2 + + line-length: disable diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a7548c75..5538770e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,30 +1,42 @@ # Contributing to Unchained -Thank you for your interest in contributing to Unchained! We value your contributions and want to make sure the process is easy and beneficial for everyone involved. Please take a moment to read these guidelines to ensure a smooth contribution process. +Thank you for your interest in contributing to Unchained! We value your +contributions and want to make sure the process is easy and beneficial for +everyone involved. Please take a moment to read these guidelines to ensure a +smooth contribution process. ## Contribution Guidelines ### 1. Contributor License Agreement (CLA) -Before your contributions can be accepted, you must sign a Contributor License Agreement (CLA). This is a simple process that happens when you make your first pull request (PR). +Before your contributions can be accepted, you must sign a Contributor License +Agreement (CLA). This is a simple process that happens when you make your first +pull request (PR). ### 2. Forking and Branching Strategy -- **External Contributors**: Please fork the repository and submit your changes via a pull request from your fork. -- **Internal Contributors**: You should push your branches directly to the main project repository. +- **External Contributors**: Please fork the repository and submit your changes + via a pull request from your fork. +- **Internal Contributors**: You should push your branches directly to the main + project repository. ### 3. Issues and Pull Requests -- **Creating Issues**: Always create a GitHub issue before starting work on a pull request. Search for existing issues to avoid duplicates and check if someone else is already working on it. -- **Naming Branches**: Use semantic and meaningful branch names to make it clear what your contribution entails. Here are some good and bad examples: +- **Creating Issues**: Always create a GitHub issue before starting work on a + pull request. Search for existing issues to avoid duplicates and check if + someone else is already working on it. +- **Naming Branches**: Use semantic and meaningful branch names to make it clear + what your contribution entails. Here are some good and bad examples: **Good Examples** + - `add-{x}-to-{y}-{issue-number}` - `fix-{x}-in-{y}-{issue-number}` - `feature-{xyz}-{issue-number}` - `test-{xyz}-{issue-number}` **Bad Examples** + - `bugfix` - `potatoes` - `mybranch` @@ -32,21 +44,43 @@ Before your contributions can be accepted, you must sign a Contributor License A ### 4. Coding Standards -- **Documentation**: Your code must be well-documented and commented. Aim for clarity and simplicity; your code should be easily understandable without relying solely on comments. -- **Naming Conventions**: Use descriptive and appropriate names for variables, functions, and branches to clearly convey their purpose. -- **Pull Request Details**: Ensure your pull requests and issues clearly describe what you're trying to achieve. This helps reviewers understand your intentions and the impact of your contributions. +- **Documentation**: Your code must be well-documented and commented. Aim for + clarity and simplicity; your code should be easily understandable without + relying solely on comments. +- **Naming Conventions**: Use descriptive and appropriate names for variables, + functions, and branches to clearly convey their purpose. +- **Pull Request Details**: Ensure your pull requests and issues clearly + describe what you're trying to achieve. This helps reviewers understand your + intentions and the impact of your contributions. ### 5. Pull Request Process - Your PR should always target the `develop` branch. -- If the `develop` branch is updated before your PR is merged, you must rebase your commits to keep the history clean and avoid merge conflicts. +- If the `develop` branch is updated before your PR is merged, you must rebase + your commits to keep the history clean and avoid merge conflicts. + +### 6. Commit Messages and Pull Requests + +We use commitizen for commit and changelog management. You'll need the following +tools to get started: + +- [Pre-commit](https://pre-commit.com/): Used for various pre-commit checks + including commit message lint checks. +- [Commitizen](https://commitizen-tools.github.io): Used for creating commit + messages and maintaining a logfile. +- [Golangci-lint](https://golangci-lint.run/): Used for Golang lint checks. -### 6. Commit Messages +You'll need to run the following command to setup the pre-commit hooks: -Commit messages should be descriptive and meaningful, helping to explain why and what you have done without needing to look at the source code directly. Please avoid using emojis and stick to ASCII readable characters to ensure clarity and compatibility. +```sh +pre-commit install --install-hooks --hook-type commit-msg --hook-type pre-push +``` ## Conclusion -Following these guidelines helps us maintain a high standard of quality for our project and makes the contribution process more efficient and effective. We look forward to your contributions and are excited to see what we can achieve together in Unchained! +Following these guidelines helps us maintain a high standard of quality for our +project and makes the contribution process more efficient and effective. We look +forward to your contributions and are excited to see what we can achieve +together in Unchained! Thank you for contributing! diff --git a/LICENSE b/LICENSE index 0302ff30..a5031859 100644 --- a/LICENSE +++ b/LICENSE @@ -12,14 +12,14 @@ Additional Use Grant: You are granted the right to use the Licensed Work as-is, on private networks. The intent is to ensure the Licensed Work's application remains within its intended network ecosystem. - + You may operate the Licensed Work on private networks for non-commercial purposes only. Permissible non-commercial uses include, but are not limited to, research, personal network use, and academic purposes. This clause is to facilitate access to the Licensed Work for non-profit and developmental activities. - + Additionally, entities with an annual revenue of less than 100,000 CHF are granted the right to operate the Licensed Work on private networks for their internal business @@ -28,7 +28,7 @@ Additional Use Grant: You are granted the right to use the Licensed Work as-is, Licensed Work for their growth and innovation, without the immediate financial burden of acquiring a commercial license. - + Operating the Licensed Work on private networks for commercial purposes, outside of the aforementioned exception, is prohibited unless a separate commercial @@ -125,4 +125,4 @@ other recipients of the licensed work to be provided by Licensor: 3. To specify a Change Date. -4. Not to modify this License in any other way. \ No newline at end of file +4. Not to modify this License in any other way. diff --git a/conf.standalone.yaml.template b/conf.standalone.yaml.template index 8b4292f9..64fdccc8 100644 --- a/conf.standalone.yaml.template +++ b/conf.standalone.yaml.template @@ -13,7 +13,7 @@ rpc: - wss://ethereum.publicnode.com - https://eth.rpc.blxrbdn.com - - name: arbitrum: + - name: arbitrum nodes: - https://arbitrum-one.publicnode.com - https://arbitrum.llamarpc.com diff --git a/docker/grafana/dashboard.yaml b/docker/grafana/dashboard.yaml index 0a6c1347..50614d41 100644 --- a/docker/grafana/dashboard.yaml +++ b/docker/grafana/dashboard.yaml @@ -11,4 +11,4 @@ providers: allowUiUpdates: false options: path: /var/lib/grafana/dashboards - foldersFromFilesStructure: true \ No newline at end of file + foldersFromFilesStructure: true diff --git a/internal/Makefile b/internal/Makefile index 217c72c2..a096e465 100644 --- a/internal/Makefile +++ b/internal/Makefile @@ -40,4 +40,3 @@ imports: fmt: go fmt ./... - diff --git a/internal/cmd/broker.go b/internal/cmd/broker.go index 9421354e..34cacebf 100644 --- a/internal/cmd/broker.go +++ b/internal/cmd/broker.go @@ -30,7 +30,11 @@ var brokerCmd = &cobra.Command{ panic(err) } - ethereum.InitClientIdentity() + err = ethereum.InitClientIdentity() + if err != nil { + panic(err) + } + bls.InitClientIdentity() ethRPC := ethereum.New() diff --git a/internal/cmd/consumer.go b/internal/cmd/consumer.go index 2a46df05..d63d6ce1 100644 --- a/internal/cmd/consumer.go +++ b/internal/cmd/consumer.go @@ -42,7 +42,11 @@ var consumerCmd = &cobra.Command{ panic(err) } - ethereum.InitClientIdentity() + err = ethereum.InitClientIdentity() + if err != nil { + panic(err) + } + bls.InitClientIdentity() ethRPC := ethereum.New() diff --git a/internal/cmd/worker.go b/internal/cmd/worker.go index 789ef63c..fbc20ea3 100644 --- a/internal/cmd/worker.go +++ b/internal/cmd/worker.go @@ -40,7 +40,11 @@ var workerCmd = &cobra.Command{ panic(err) } - ethereum.InitClientIdentity() + err = ethereum.InitClientIdentity() + if err != nil { + panic(err) + } + bls.InitClientIdentity() ethRPC := ethereum.New() diff --git a/internal/config/config.go b/internal/config/config.go index b89bc48e..2527d277 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -20,7 +20,7 @@ func Load(configPath, secretPath string) error { } if secretPath == "" { - secretPath = "./secrets.yaml" + secretPath = "./secrets.yaml" // #nosec G101 } SecretFilePath = secretPath diff --git a/internal/config/model.go b/internal/config/model.go index f33ca41a..078e815a 100644 --- a/internal/config/model.go +++ b/internal/config/model.go @@ -55,7 +55,7 @@ type Token struct { } type ProofOfStake struct { - Chain string `env:"POS_CHAIN" env-default:"arbitrumSepolia" yaml:"chain"` + Chain string `env:"POS_CHAIN" env-default:"arbitrumSepolia" yaml:"chain"` Address string `env:"POS_ADDRESS" env-default:"0x965e364987356785b7E89e2Fe7B70f5E5107332d" yaml:"address"` Base int64 `env:"POS_BASE" env-default:"1" yaml:"base"` } diff --git a/internal/ethereum/signer.go b/internal/ethereum/signer.go index 565baefe..52624fe5 100644 --- a/internal/ethereum/signer.go +++ b/internal/ethereum/signer.go @@ -35,7 +35,6 @@ func saveConfig() error { } func InitClientIdentity() error { - var privateKey *ecdsa.PrivateKey var err error var privateKeyRegenerated bool diff --git a/k8s/charts/unchained-worker/templates/configmap.yaml b/k8s/charts/unchained-worker/templates/configmap.yaml index fad56543..c85427f7 100644 --- a/k8s/charts/unchained-worker/templates/configmap.yaml +++ b/k8s/charts/unchained-worker/templates/configmap.yaml @@ -10,7 +10,7 @@ data: plugins: uniswap: rpc: - ethereum: + ethereum: - https://ethereum.publicnode.com - https://eth.llamarpc.com - wss://ethereum.publicnode.com diff --git a/k8s/charts/unchained-worker/templates/statefulset.yaml b/k8s/charts/unchained-worker/templates/statefulset.yaml index adc0419c..b32236c3 100644 --- a/k8s/charts/unchained-worker/templates/statefulset.yaml +++ b/k8s/charts/unchained-worker/templates/statefulset.yaml @@ -86,7 +86,7 @@ spec: - metadata: name: data spec: - accessModes: + accessModes: - ReadWriteOnce resources: requests: diff --git a/k8s/charts/unchained-worker/values.yaml b/k8s/charts/unchained-worker/values.yaml index 6865a803..051ee5d8 100644 --- a/k8s/charts/unchained-worker/values.yaml +++ b/k8s/charts/unchained-worker/values.yaml @@ -7,7 +7,7 @@ podManagementPolicy: "Parallel" #podManagementPolicy: "OrderedReady" image: - repository: ghcr.io/kenshitech/unchained + repository: ghcr.io/kenshitech/unchained pullPolicy: Always # Overrides the image tag whose default is the chart appVersion. tag: "latest" diff --git a/zk/go.mod b/zk/go.mod index e9f375a4..4e2f9c34 100644 --- a/zk/go.mod +++ b/zk/go.mod @@ -2,12 +2,16 @@ module unchained-zk go 1.21.5 +require ( + github.com/consensys/gnark v0.9.1 + github.com/consensys/gnark-crypto v0.12.2-0.20231013160410-1f65e75b6dfb + github.com/urfave/cli/v2 v2.26.0 +) + require ( github.com/bits-and-blooms/bitset v1.8.0 // indirect github.com/blang/semver/v4 v4.0.0 // indirect github.com/consensys/bavard v0.1.13 // indirect - github.com/consensys/gnark v0.9.1 // indirect - github.com/consensys/gnark-crypto v0.12.2-0.20231013160410-1f65e75b6dfb // indirect github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/fxamacker/cbor/v2 v2.5.0 // indirect @@ -19,7 +23,6 @@ require ( github.com/rs/zerolog v1.30.0 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/stretchr/testify v1.8.4 // indirect - github.com/urfave/cli/v2 v2.26.0 // indirect github.com/x448/float16 v0.8.4 // indirect github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect golang.org/x/crypto v0.12.0 // indirect diff --git a/zk/go.sum b/zk/go.sum index de78b431..3b7ae188 100644 --- a/zk/go.sum +++ b/zk/go.sum @@ -16,9 +16,17 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/fxamacker/cbor/v2 v2.5.0 h1:oHsG0V/Q6E/wqTS2O1Cozzsy69nqCiguo5Q1a1ADivE= github.com/fxamacker/cbor/v2 v2.5.0/go.mod h1:TA1xS00nchWmaBnEIxPSE5oHLuJBAVvqrtAnWBwBCVo= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/pprof v0.0.0-20230817174616-7a8ec2ada47b h1:h9U78+dx9a4BKdQkBBos92HalKpaGKHrp+3Uo6yTodo= github.com/google/pprof v0.0.0-20230817174616-7a8ec2ada47b/go.mod h1:czg5+yv1E0ZGTi6S6vVK1mke0fV+FaUhNGcd6VRS9Ik= github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c= +github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= @@ -32,6 +40,8 @@ github.com/mmcloughlin/profile v0.1.1/go.mod h1:IhHD7q1ooxgwTgjxQYkACGA77oFTDdFV github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= +github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/rs/zerolog v1.30.0 h1:SymVODrcRsaRaSInD9yQtKbtWqwsfoPcRff/oRXLj4c= github.com/rs/zerolog v1.30.0/go.mod h1:/tk+P47gFdPXq4QYjvCmT5/Gsug2nagsFWBWhAiSi1w= @@ -49,7 +59,8 @@ golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk= golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 h1:m64FZMko/V45gv0bNmrNYoDEq8U5YUhetc9cBWKS1TQ= golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63/go.mod h1:0v4NqG35kSWCMzLaMeX+IQrlSnVE/bqGSyC2cz/9Le8= -golang.org/x/sys v0.0.0-20201101102859-da207088b7d1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= +golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -57,6 +68,10 @@ golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= rsc.io/tmplfunc v0.0.3 h1:53XFQh69AfOa8Tw0Jm7t+GV7KZhOi6jzsCzTtKbMvzU=