diff --git a/.github/workflows/docker_image.yml b/.github/workflows/docker_image.yml deleted file mode 100644 index 13209f65d7..0000000000 --- a/.github/workflows/docker_image.yml +++ /dev/null @@ -1,79 +0,0 @@ -# SPDX-License-Identifier: BUSL-1.1 -# -# Copyright (C) 2023, Berachain Foundation. All rights reserved. -# Use of this software is govered by the Business Source License included -# in the LICENSE file of this repository and at www.mariadb.com/bsl11. -# -# ANY USE OF THE LICENSED WORK IN VIOLATION OF THIS LICENSE WILL AUTOMATICALLY -# TERMINATE YOUR RIGHTS UNDER THIS LICENSE FOR THE CURRENT AND ALL OTHER -# VERSIONS OF THE LICENSED WORK. -# -# THIS LICENSE DOES NOT GRANT YOU ANY RIGHT IN ANY TRADEMARK OR LOGO OF -# LICENSOR OR ITS AFFILIATES (PROVIDED THAT YOU MAY USE A TRADEMARK OR LOGO OF -# LICENSOR AS EXPRESSLY REQUIRED BY THIS LICENSE). -# -# TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON -# AN “AS IS” BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, -# EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND -# TITLE. - -name: "docker-image" - -on: - push: - branches: - - "main" - -permissions: - contents: read - -jobs: - build-push-docker: - runs-on: polaris-linux-latest - steps: - - name: Checkout repo - uses: actions/checkout@v3 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v2 # More information on this action can be found below in the 'AWS Credentials' section - with: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - aws-region: us-east-2 - - - name: Login to Amazon ECR - id: login-ecr - uses: aws-actions/amazon-ecr-login@v2 - with: - mask-password: "true" - run: | - aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws/d4k0c7i3 - - - name: Build, tag, push amd64 docker image to Amazon ECR - env: - IMAGE_TAG: ${{ github.sha }} - GIT_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - docker build --platform linux/amd64 -f ./build/docker/beacond.Dockerfile -t beacond:v0.0.0 --build-arg GIT_TOKEN=$GIT_TOKEN --build-arg GOARCH=amd64 . - docker tag beacond:v0.0.0 public.ecr.aws/d4k0c7i3/beacond:amd64-$IMAGE_TAG - docker push public.ecr.aws/d4k0c7i3/beacond:amd64-$IMAGE_TAG - docker tag beacond:v0.0.0 public.ecr.aws/d4k0c7i3/beacond:amd64-latest - docker push public.ecr.aws/d4k0c7i3/beacond:amd64-latest - - - name: Build, tag, push arm64 docker image to Amazon ECR - env: - IMAGE_TAG: ${{ github.sha }} - GIT_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - docker buildx build --platform linux/arm64 -f ./build/docker/beacond.Dockerfile -t beacond:v0.0.0 --build-arg GIT_TOKEN=$GIT_TOKEN --build-arg GOARCH=arm64 . - docker tag beacond:v0.0.0 public.ecr.aws/d4k0c7i3/beacond:arm64-$IMAGE_TAG - docker push public.ecr.aws/d4k0c7i3/beacond:arm-$IMAGE_TAG - docker tag beacond:v0.0.0 public.ecr.aws/d4k0c7i3/beacond:arm64-latest - docker push public.ecr.aws/d4k0c7i3/beacond:arm-latest diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index de59ca61f0..2789954226 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -31,13 +31,16 @@ on: branches: - main +concurrency: + group: ci-${{ github.ref }}-tests + cancel-in-progress: true + jobs: ci: strategy: matrix: - args: ["build", "lint", "test-unit-race", "test-unit-cover"] + args: ["build", "lint", "gosec", "test-unit-cover"] os: [ubuntu-latest] - go-version: [1.21.6] runs-on: ${{ matrix.os }} steps: - name: Checkout @@ -45,44 +48,18 @@ jobs: - name: Install Foundry uses: foundry-rs/foundry-toolchain@v1 - name: Setup Golang - uses: actions/setup-go@v3 - with: - go-version: ${{ matrix.go-version }} - - name: Cache Golang Deps - uses: actions/cache@v3 + uses: actions/setup-go@v4 with: - path: | - ~/.cache/go-build - ~/go - key: ${{ runner.os }}-golang-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-golang- + go-version: 'stable' + check-latest: true - name: Run ${{ matrix.args }} run: | make ${{ matrix.args }} env: GOPATH: /home/runner/go - # - name: Archive code coverage results - # uses: actions/upload-artifact@v3 - # with: - # name: code-coverage-report - # path: coverage-${{ matrix.args }}.txt - # retention-days: 1 - # if: ${{ matrix.args == 'test-unit-cover' }} - - # TODO: Re-enable later. - # codecov: - # name: codecov(uploader, polaris-linux-latest) - # runs-on: polaris-linux-latest - # needs: ci - # steps: - # - name: Checkout - # uses: actions/checkout@v3 - # - name: Download code coverage results - # uses: actions/download-artifact@v2 - # with: - # name: code-coverage-report - # - name: Upload to Codecov - # uses: codecov/codecov-action@v2 - # with: - # token: ${{ secrets.CODECOV_TOKEN }} + - name: Upload to Codecov + uses: codecov/codecov-action@v2 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: ./coverage-${{ matrix.args }}.txt + if: ${{ matrix.args == 'test-unit-cover' }} \ No newline at end of file diff --git a/Makefile b/Makefile index 4666090657..36d67f2a12 100644 --- a/Makefile +++ b/Makefile @@ -243,26 +243,16 @@ start-besu: # unit # ################# -install-ginkgo: - @echo "Installing ginkgo..." - @go install github.com/onsi/ginkgo/v2/ginkgo@latest test-unit: - @$(MAKE) install-ginkgo forge-test + @$(MAKE) forge-test @echo "Running unit tests..." - @ginkgo -r --randomize-all --fail-on-pending -trace --skip .*e2e* ./... - -test-unit-race: - @$(MAKE) install-ginkgo forge-test - @echo "Running unit tests with race detection..." - @ginkgo --race -r --randomize-all --fail-on-pending -trace --skip .*e2e* ./... + go test ./... test-unit-cover: - @$(MAKE) install-ginkgo forge-test + @$(MAKE) forge-test @echo "Running unit tests with coverage..." - @ginkgo -r --randomize-all --fail-on-pending -trace --skip .*e2e* \ - --junit-report out.xml --cover --coverprofile "coverage-test-unit-cover.txt" --covermode atomic \ - ./... + go test -race -coverprofile=coverage-test-unit-cover.txt -covermode=atomic ./... ################# # forge # @@ -280,26 +270,7 @@ test-e2e: @$(MAKE) test-e2e-no-build test-e2e-no-build: - @$(MAKE) install-ginkgo @echo "Running e2e tests..." - @ginkgo -r --randomize-all --fail-on-pending -trace -timeout 30m ./e2e/precompile/... - -################# -# localnet # -################# - -test-localnet: - @$(MAKE) test-localnet-no-build - -test-localnet-no-build: - @$(MAKE) install-ginkgo - @echo "Running localnet tests..." - @ginkgo -r --randomize-all --fail-on-pending -trace -timeout 30m ./e2e/localnet/... - - -############################################################################### -### Formatting ### -############################################################################### ############################################################################### ### Linting ### @@ -309,8 +280,7 @@ format: @$(MAKE) license-fix buf-lint-fix forge-lint-fix golangci-fix lint: - @$(MAKE) license buf-lint forge-lint golangci gosec - + @$(MAKE) license buf-lint forge-lint golangci ################# # forge # @@ -374,12 +344,12 @@ license-fix: gosec-install: @echo "--> Installing gosec" - @go install github.com/securego/gosec/v2/cmd/gosec + @go install github.com/cosmos/gosec/v2/cmd/gosec gosec: @$(MAKE) gosec-install @echo "--> Running gosec" - @gosec -exclude-generated ./... + @gosec ./... ################# diff --git a/app/app.go b/app/app.go index f4ad3285a0..8eecbe14ea 100644 --- a/app/app.go +++ b/app/app.go @@ -188,9 +188,6 @@ func NewBeaconKitApp( /**** Module Options ****/ app.ModuleManager.RegisterInvariants(app.CrisisKeeper) - // RegisterUpgradeHandlers is used for registering any on-chain upgrades. - app.RegisterUpgradeHandlers() - // Load the app. if err = app.Load(loadLatest); err != nil { panic(err) diff --git a/app/beacond/cmd/root_test.go b/app/beacond/cmd/root_test.go index e13a8ca2fb..05e9c1e458 100644 --- a/app/beacond/cmd/root_test.go +++ b/app/beacond/cmd/root_test.go @@ -36,53 +36,46 @@ import ( testapp "github.com/itsdevbear/bolaris/app" "github.com/itsdevbear/bolaris/app/beacond/cmd" - - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" ) -func TestCmd(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "app/beacond/cmd") +func TestInitCommand(t *testing.T) { + rootCmd := cmd.NewRootCmd() + rootCmd.SetOut(os.NewFile(0, os.DevNull)) + rootCmd.SetArgs([]string{ + "init", // Test the init cmd + "BeaconApp-test", // Moniker + fmt.Sprintf("--%s=%s", cli.FlagOverwrite, "true"), // Overwrite genesis.json + }) + + err := svrcmd.Execute(rootCmd, "", testapp.DefaultNodeHome) + if err != nil { + t.Errorf("Expected no error, got %v", err) + } } -var _ = Describe("Init command", func() { - It("should initialize the app with given options", func() { - stdout := os.Stdout - defer func() { os.Stdout = stdout }() - os.Stdout = os.NewFile(0, os.DevNull) - rootCmd := cmd.NewRootCmd() - rootCmd.SetArgs([]string{ - "init", // Test the init cmd - "BeaconApp-test", // Moniker - fmt.Sprintf("--%s=%s", cli.FlagOverwrite, "true"), // Overwrite genesis.json - }) +func TestHomeFlagRegistration(t *testing.T) { + stdout := os.Stdout + defer func() { os.Stdout = stdout }() + os.Stdout = os.NewFile(0, os.DevNull) + homeDir := os.TempDir() - err := svrcmd.Execute(rootCmd, "", testapp.DefaultNodeHome) - Expect(err).ToNot(HaveOccurred()) + rootCmd := cmd.NewRootCmd() + rootCmd.SetArgs([]string{ + "query", + fmt.Sprintf("--%s", flags.FlagHome), + homeDir, }) -}) - -var _ = Describe("Home flag registration", func() { - It("should set home directory correctly", func() { - // Redirect standard out to null - stdout := os.Stdout - defer func() { os.Stdout = stdout }() - os.Stdout = os.NewFile(0, os.DevNull) - homeDir := os.TempDir() - rootCmd := cmd.NewRootCmd() - rootCmd.SetArgs([]string{ - "query", - fmt.Sprintf("--%s", flags.FlagHome), - homeDir, - }) + err := svrcmd.Execute(rootCmd, "", testapp.DefaultNodeHome) + if err != nil { + t.Errorf("Expected no error, got %v", err) + } - err := svrcmd.Execute(rootCmd, "", testapp.DefaultNodeHome) - Expect(err).ToNot(HaveOccurred()) - - result, err := rootCmd.Flags().GetString(flags.FlagHome) - Expect(err).ToNot(HaveOccurred()) - Expect(result).To(Equal(homeDir)) - }) -}) + result, err := rootCmd.Flags().GetString(flags.FlagHome) + if err != nil { + t.Errorf("Expected no error, got %v", err) + } + if result != homeDir { + t.Errorf("Expected homeDir to be %s, got %s", homeDir, result) + } +} diff --git a/app/contracts/main/main.go b/app/contracts/main/main.go index 259ee89152..47e8105060 100644 --- a/app/contracts/main/main.go +++ b/app/contracts/main/main.go @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT // -// # Copyright (c) 2023 Berachain Foundation +// Copyright (c) 2023 Berachain Foundation // // Permission is hereby granted, free of charge, to any person // obtaining a copy of this software and associated documentation diff --git a/app/contracts/staking.go b/app/contracts/staking.go index a2356d84de..4989f2f483 100644 --- a/app/contracts/staking.go +++ b/app/contracts/staking.go @@ -48,7 +48,10 @@ type StakingCallbacks struct { } func (s *StakingCallbacks) ABIEvents() map[string]abi.Event { - x, _ := StakingMetaData.GetAbi() + x, err := StakingMetaData.GetAbi() + if err != nil { + panic(err) + } return x.Events } diff --git a/app/export.go b/app/export.go index f6d830992d..f0b65e9531 100644 --- a/app/export.go +++ b/app/export.go @@ -112,7 +112,10 @@ func (app *BeaconApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs if err != nil { panic(err) } - _, _ = app.DistrKeeper.WithdrawValidatorCommission(ctx, valBz) + _, err = app.DistrKeeper.WithdrawValidatorCommission(ctx, valBz) + if err != nil { + panic(err) + } return false }); err != nil { panic(err) @@ -131,7 +134,10 @@ func (app *BeaconApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs delAddr := sdk.MustAccAddressFromBech32(delegation.DelegatorAddress) - _, _ = app.DistrKeeper.WithdrawDelegationRewards(ctx, delAddr, valAddr) + _, err = app.DistrKeeper.WithdrawDelegationRewards(ctx, delAddr, valAddr) + if err != nil { + panic(err) + } } // clear validator slash events diff --git a/app/upgrades.go b/app/upgrades.go deleted file mode 100644 index 456e7a36dd..0000000000 --- a/app/upgrades.go +++ /dev/null @@ -1,66 +0,0 @@ -// SPDX-License-Identifier: MIT -// -// Copyright (c) 2023 Berachain Foundation -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. - -package testapp - -import ( - "context" - - storetypes "cosmossdk.io/store/types" - upgradetypes "cosmossdk.io/x/upgrade/types" - - "github.com/cosmos/cosmos-sdk/types/module" -) - -// UpgradeName defines the on-chain upgrade name for the sample BeaconApp upgrade -// from v047 to v050. -// -// NOTE: This upgrade defines a reference implementation of what an upgrade -// could look like when an application is migrating from Cosmos SDK version -// v0.47.x to v0.50.x. -const UpgradeName = "v047-to-v050" - -func (app BeaconApp) RegisterUpgradeHandlers() { - app.UpgradeKeeper.SetUpgradeHandler( - UpgradeName, - func( - ctx context.Context, _ upgradetypes.Plan, fromVM module.VersionMap, - ) (module.VersionMap, error) { - return app.ModuleManager.RunMigrations(ctx, app.Configurator(), fromVM) - }, - ) - - upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk() - if err != nil { - panic(err) - } - - if upgradeInfo.Name == UpgradeName && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) { - storeUpgrades := storetypes.StoreUpgrades{} - - // configure store loader that checks if version == upgradeHeight and applies store upgrades - app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades)) - } -} diff --git a/async/dispatch/queues/concurrent.go b/async/dispatch/queues/concurrent.go index d02a014389..6975ea93d5 100644 --- a/async/dispatch/queues/concurrent.go +++ b/async/dispatch/queues/concurrent.go @@ -42,7 +42,7 @@ type ConcurrentQueue struct { // NewConcurrentDispatchQueue creates a new Queue and starts its worker goroutines. func NewConcurrentDispatchQueue(workerCount int) *ConcurrentQueue { q := &ConcurrentQueue{ - queue: make(chan WorkItem), + queue: make(chan WorkItem, 32), stopChan: make(chan struct{}), } @@ -113,6 +113,9 @@ func (q *ConcurrentQueue) Stop() { return } + // Wait for all tasks to complete + q.wg.Wait() + q.stopped = true // Close the queue channel to stop receiving new tasks @@ -120,7 +123,4 @@ func (q *ConcurrentQueue) Stop() { // Stop the workers close(q.stopChan) - - // Wait for all tasks to complete - q.wg.Wait() } diff --git a/async/dispatch/queues/concurrent_test.go b/async/dispatch/queues/concurrent_test.go index 0d8c502ad2..23143bc4b0 100644 --- a/async/dispatch/queues/concurrent_test.go +++ b/async/dispatch/queues/concurrent_test.go @@ -98,5 +98,6 @@ func TestDispatchQueueConcurrent_Stop(t *testing.T) { t.Errorf("Async function executed after Stop") }) + // This should be a no-op. q.Stop() } diff --git a/async/dispatch/queues/serial_test.go b/async/dispatch/queues/serial_test.go index 0c648f7474..f7969232f5 100644 --- a/async/dispatch/queues/serial_test.go +++ b/async/dispatch/queues/serial_test.go @@ -33,7 +33,7 @@ import ( "github.com/itsdevbear/bolaris/async/dispatch/queues" ) -func TestDispatchQueue(t *testing.T) { +func TestSerialDispatchQueue(t *testing.T) { q := queues.NewSerialDispatchQueue() // Test Async @@ -73,7 +73,7 @@ func TestDispatchQueue(t *testing.T) { q.Stop() } -func TestDispatchQueue_Stop(t *testing.T) { +func TestSerialDispatchQueue_Stop(t *testing.T) { q := queues.NewSerialDispatchQueue() // Add some items to the queue diff --git a/beacon/execution/forkchoice.go b/beacon/execution/forkchoice.go index 1a12ae685e..e3f9399e18 100644 --- a/beacon/execution/forkchoice.go +++ b/beacon/execution/forkchoice.go @@ -62,6 +62,7 @@ func (s *Service) notifyForkchoiceUpdate( // TODO: this withAttrs hack needs to be removed. if fcuConfig.BuildPayload { // TODO: handle versions properly. + //#nosec:G701 // won't realistically overflow. attrs, err = s.getPayloadAttributes(ctx, slot, uint64(time.Now().Unix())) if err != nil { s.Logger().Error("failed to get payload attributes in notifyForkchoiceUpdated", "error", err) diff --git a/beacon/execution/payload.go b/beacon/execution/payload.go index 5ad770523c..fc8c76bdae 100644 --- a/beacon/execution/payload.go +++ b/beacon/execution/payload.go @@ -27,7 +27,7 @@ package execution import ( "context" - "crypto/rand" + "crypto/rand" //#nosec:G702 // TODO: do randao properly. payloadattribute "github.com/prysmaticlabs/prysm/v4/consensus-types/payload-attribute" "github.com/prysmaticlabs/prysm/v4/consensus-types/primitives" diff --git a/beacon/initial-sync/service.go b/beacon/initial-sync/service.go index aab80b992c..b95091ed5b 100644 --- a/beacon/initial-sync/service.go +++ b/beacon/initial-sync/service.go @@ -101,8 +101,8 @@ func (s *Service) CheckSyncStatus(ctx context.Context) *BeaconSyncProgress { // We previously grabbed the beacon chain's view of what is finalized. We first ensure it // exists. If it exists on the chain, this is bullish. If it doesn't we need to forkchoice. - clFinalized, _ := s.ethClient.HeaderByHash(ctx, common.BytesToHash(finalHash[:])) - if clFinalized == nil { + clFinalized, err := s.ethClient.HeaderByHash(ctx, common.BytesToHash(finalHash[:])) + if clFinalized == nil || err != nil { // We need to fork choice to find the latest finalized block. This is trigger the execution // chain to start asking it's peers to help it sync and build the chain required for // the following forkchoice. diff --git a/beacon/logs/callback/callback.go b/beacon/logs/callback/callback.go index 275c2a86a6..2e45528bc7 100644 --- a/beacon/logs/callback/callback.go +++ b/beacon/logs/callback/callback.go @@ -22,7 +22,7 @@ package callback import ( "context" - "reflect" + "reflect" //#nosec:G702 // reflect is required for ABI parsing. "github.com/ethereum/go-ethereum/accounts/abi" evmv1 "github.com/itsdevbear/bolaris/types/evm/v1" diff --git a/beacon/logs/callback/helpers.go b/beacon/logs/callback/helpers.go index b7f3efa882..8bbc6f73e7 100644 --- a/beacon/logs/callback/helpers.go +++ b/beacon/logs/callback/helpers.go @@ -22,7 +22,7 @@ package callback import ( "errors" - "reflect" + "reflect" //#nosec:G702 // reflect is required for ABI parsing. "github.com/ethereum/go-ethereum/accounts/abi" ) diff --git a/beacon/logs/callback/method.go b/beacon/logs/callback/method.go index 5275f3cac1..73a2fc770b 100644 --- a/beacon/logs/callback/method.go +++ b/beacon/logs/callback/method.go @@ -22,7 +22,7 @@ package callback import ( "context" - "reflect" + "reflect" //#nosec:G702 // reflect is required for ABI parsing. "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" diff --git a/beacon/logs/callback/validation.go b/beacon/logs/callback/validation.go index 877c0b2895..ea9597b598 100644 --- a/beacon/logs/callback/validation.go +++ b/beacon/logs/callback/validation.go @@ -28,7 +28,7 @@ package callback import ( "errors" "fmt" - "reflect" + "reflect" //#nosec:G702 // reflect is required for ABI parsing. "github.com/ethereum/go-ethereum/common" ) diff --git a/build/tools/LICENSE b/build/tools/LICENSE deleted file mode 100644 index e9f8eb4ddf..0000000000 --- a/build/tools/LICENSE +++ /dev/null @@ -1,24 +0,0 @@ -SPDX-License-Identifier: MIT - -Copyright (c) 2023 Berachain Foundation - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/build/tools/LICENSE.header b/build/tools/LICENSE.header deleted file mode 100644 index e9f8eb4ddf..0000000000 --- a/build/tools/LICENSE.header +++ /dev/null @@ -1,24 +0,0 @@ -SPDX-License-Identifier: MIT - -Copyright (c) 2023 Berachain Foundation - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/build/tools/tools.go b/build/tools/tools.go index 51c77d1c44..f601cfd82d 100644 --- a/build/tools/tools.go +++ b/build/tools/tools.go @@ -41,8 +41,6 @@ import ( _ "github.com/ethereum/go-ethereum/rlp/rlpgen" _ "github.com/golangci/golangci-lint/cmd/golangci-lint" _ "github.com/google/addlicense" - _ "github.com/onsi/ginkgo/v2/ginkgo" _ "github.com/prysmaticlabs/fastssz/sszgen" - _ "github.com/securego/gosec/v2/cmd/gosec" _ "github.com/vektra/mockery/v2" ) diff --git a/codecov.yml b/codecov.yml index cfe451d1b2..596d3ac28c 100644 --- a/codecov.yml +++ b/codecov.yml @@ -27,7 +27,7 @@ coverage: status: project: default: - target: 45% + target: 0% patch: off comment: @@ -45,4 +45,4 @@ ignore: - "**/*.mock.go" - "**/proto" - "**/build" - - "**/cmd" + - "**/contracts" diff --git a/config/config_test.go b/config/config_test.go index e19c113504..cc627a2c4f 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -26,33 +26,47 @@ package config_test import ( + "testing" + "github.com/cosmos/cosmos-sdk/crypto/hd" sdk "github.com/cosmos/cosmos-sdk/types" sgconfig "github.com/itsdevbear/bolaris/config" - - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" ) -var _ = Describe("Configuration", func() { - It("should set CoinType", func() { +func TestConfiguration(t *testing.T) { + t.Run("should set CoinType", func(t *testing.T) { config := sdk.GetConfig() - Expect(int(config.GetCoinType())).To(Equal(sdk.CoinType)) - Expect(config.GetFullBIP44Path()).To(Equal(sdk.FullFundraiserPath)) + if int(config.GetCoinType()) != sdk.CoinType { + t.Errorf("expected CoinType %d, got %d", sdk.CoinType, config.GetCoinType()) + } + if config.GetFullBIP44Path() != sdk.FullFundraiserPath { + t.Errorf("expected FullBIP44Path %s, got %s", + sdk.FullFundraiserPath, config.GetFullBIP44Path()) + } sgconfig.SetupCosmosConfig() - Expect(int(config.GetCoinType())).To(Equal(int(60))) - Expect(config.GetCoinType()).To(Equal(sdk.GetConfig().GetCoinType())) - Expect(config.GetFullBIP44Path()).To(Equal(sdk.GetConfig().GetFullBIP44Path())) + if int(config.GetCoinType()) != 60 { + t.Errorf("expected CoinType %d, got %d", 60, config.GetCoinType()) + } + if config.GetCoinType() != sdk.GetConfig().GetCoinType() { + t.Errorf("expected CoinType %d, got %d", + sdk.GetConfig().GetCoinType(), config.GetCoinType()) + } + if config.GetFullBIP44Path() != sdk.GetConfig().GetFullBIP44Path() { + t.Errorf("expected FullBIP44Path %s, got %s", + sdk.GetConfig().GetFullBIP44Path(), config.GetFullBIP44Path()) + } }) - It("should generate HD path", func() { + t.Run("should generate HD path", func(t *testing.T) { params := *hd.NewFundraiserParams(0, 60, 0) hdPath := params.String() - Expect(hdPath).To(Equal("m/44'/60'/0'/0/0")) + if hdPath != "m/44'/60'/0'/0/0" { + t.Errorf("expected HD path %s, got %s", "m/44'/60'/0'/0/0", hdPath) + } }) -}) +} diff --git a/config/parser_test.go b/config/parser_test.go index aa0a7d4360..0927f4691b 100644 --- a/config/parser_test.go +++ b/config/parser_test.go @@ -32,85 +32,76 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/require" "github.com/itsdevbear/bolaris/config" "github.com/itsdevbear/bolaris/config/mocks" - - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" ) -func TestConfig(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "types/config") -} - -var _ = Describe("Parser", func() { +func TestParser(t *testing.T) { var parser *config.AppOptionsParser - var appOpts *mocks.AppOptions + var appOpts = new(mocks.AppOptions) - BeforeEach(func() { - appOpts = new(mocks.AppOptions) - parser = config.NewAppOptionsParser(appOpts) - }) + parser = config.NewAppOptionsParser(appOpts) - It("should set and retrieve a string option", func() { + t.Run("should set and retrieve a string option", func(t *testing.T) { value := "testValue" - runTest(appOpts, parser.GetString, value) + runTest(t, appOpts, parser.GetString, value) }) - It("should set and retrieve an integer option", func() { + t.Run("should set and retrieve an integer option", func(t *testing.T) { value := int(42) - runTest(appOpts, parser.GetInt, value) + runTest(t, appOpts, parser.GetInt, value) }) - It("should handle an int64 option", func() { + t.Run("should handle an int64 option", func(t *testing.T) { value := int64(42) - runTest(appOpts, parser.GetInt64, value) + runTest(t, appOpts, parser.GetInt64, value) }) - It("should set and retrieve a uint64 option", func() { + t.Run("should set and retrieve a uint64 option", func(t *testing.T) { value := uint64(42) - runTest(appOpts, parser.GetUint64, value) + runTest(t, appOpts, parser.GetUint64, value) }) - It("should set and retrieve a pointer to a uint64 option", func() { + t.Run("should set and retrieve a pointer to a uint64 option", func(t *testing.T) { value := uint64(42) - runTestWithOutput(appOpts, parser.GetUint64Ptr, "42", &value) + runTestWithOutput(t, appOpts, parser.GetUint64Ptr, "42", &value) }) - It("should set and retrieve a big.Int option", func() { + t.Run("should set and retrieve a big.Int option", func(t *testing.T) { value := new(big.Int).SetInt64(42) - runTestWithOutput(appOpts, parser.GetBigInt, "42", value) + runTestWithOutput(t, appOpts, parser.GetBigInt, "42", value) }) - It("should set and retrieve a float64 option", func() { + t.Run("should set and retrieve a float64 option", func(t *testing.T) { value := 3.14159 - runTest(appOpts, parser.GetFloat64, value) + runTest(t, appOpts, parser.GetFloat64, value) }) - It("should set and retrieve a boolean option", func() { + t.Run("should set and retrieve a boolean option", func(t *testing.T) { value := true - runTest(appOpts, parser.GetBool, value) + runTest(t, appOpts, parser.GetBool, value) }) - It("should set and retrieve a string slice option", func() { + t.Run("should set and retrieve a string slice option", func(t *testing.T) { value := []string{"apple", "banana", "cherry"} - runTest(appOpts, parser.GetStringSlice, value) + runTest(t, appOpts, parser.GetStringSlice, value) }) - It("should set and retrieve a time.Duration option", func() { + t.Run("should set and retrieve a time.Duration option", func(t *testing.T) { value := time.Second * 10 - runTest(appOpts, parser.GetTimeDuration, value) + runTest(t, appOpts, parser.GetTimeDuration, value) }) - It("should set and retrieve a common.Address option", func() { + t.Run("should set and retrieve a common.Address option", func(t *testing.T) { addressStr := "0x18df82c7e422a42d47345ed86b0e935e9718ebda" runTestWithOutput( - appOpts, parser.GetCommonAddress, addressStr, common.HexToAddress(addressStr)) + t, appOpts, parser.GetCommonAddress, addressStr, common.HexToAddress(addressStr)) }) - It("should set and retrieve a list of common.Address options", func() { + t.Run("should set and retrieve a list of common.Address options", func(t *testing.T) { addressStrs := []string{ "0x20f33ce90a13a4b5e7697e3544c3083b8f8a51d4", "0x18df82c7e422a42d47345ed86b0e935e9718ebda", @@ -119,36 +110,30 @@ var _ = Describe("Parser", func() { common.HexToAddress(addressStrs[0]), common.HexToAddress(addressStrs[1]), } - - // Run the test using the runTest function runTestWithOutput( - appOpts, parser.GetCommonAddressList, addressStrs, expectedAddresses) + t, appOpts, parser.GetCommonAddressList, addressStrs, expectedAddresses) }) - It("should set and retrieve a hexutil.Bytes option", func() { + t.Run("should set and retrieve a hexutil.Bytes option", func(t *testing.T) { bytesStr := "0x1234567890abcdef" expectedBytes := hexutil.MustDecode(bytesStr) - - // Run the test using the runTest function - runTest(appOpts, parser.GetHexutilBytes, expectedBytes) + runTest(t, appOpts, parser.GetHexutilBytes, expectedBytes) }) -}) +} -// runTest handles testing of various types. func runTest[A any]( - appOpts *mocks.AppOptions, parser func(string) (A, error), value A) { - runTestWithOutput(appOpts, parser, value, value) + t *testing.T, appOpts *mocks.AppOptions, parser func(string) (A, error), value A, +) { + runTestWithOutput(t, appOpts, parser, value, value) } -// runTest handles testing of various types. func runTestWithOutput[A, B any]( - appOpts *mocks.AppOptions, parser func(string) (B, error), value A, output B) { - // Set the value. - appOpts.On("Get", "myTestKey").Return(value).Once() + t *testing.T, appOpts *mocks.AppOptions, parser func(string) (B, error), value A, output B, +) { + appOpts.On("Get", mock.Anything).Return(value).Once() - // Retrieve the option retrievedValue, err := parser("myTestKey") - Expect(err).ToNot(HaveOccurred()) - Expect(retrievedValue).To(Equal(output)) + require.NoError(t, err) + require.Equal(t, output, retrievedValue) } diff --git a/cosmos/api/types/consensus/v1/block.pulsar.go b/cosmos/api/types/consensus/v1/block.pulsar.go index 37c5d18abd..4aa1d20db3 100644 --- a/cosmos/api/types/consensus/v1/block.pulsar.go +++ b/cosmos/api/types/consensus/v1/block.pulsar.go @@ -115,8 +115,8 @@ func (x *fastReflection_BaseBeaconKitBlock) Range(f func(protoreflect.FieldDescr return } } - if x.Version != uint64(0) { - value := protoreflect.ValueOfUint64(x.Version) + if x.Version != int64(0) { + value := protoreflect.ValueOfInt64(x.Version) if !f(fd_BaseBeaconKitBlock_version, value) { return } @@ -149,7 +149,7 @@ func (x *fastReflection_BaseBeaconKitBlock) Has(fd protoreflect.FieldDescriptor) case "types.consensus.v1.BaseBeaconKitBlock.value": return x.Value != uint64(0) case "types.consensus.v1.BaseBeaconKitBlock.version": - return x.Version != uint64(0) + return x.Version != int64(0) case "types.consensus.v1.BaseBeaconKitBlock.exec_data": return len(x.ExecData) != 0 default: @@ -175,7 +175,7 @@ func (x *fastReflection_BaseBeaconKitBlock) Clear(fd protoreflect.FieldDescripto case "types.consensus.v1.BaseBeaconKitBlock.value": x.Value = uint64(0) case "types.consensus.v1.BaseBeaconKitBlock.version": - x.Version = uint64(0) + x.Version = int64(0) case "types.consensus.v1.BaseBeaconKitBlock.exec_data": x.ExecData = nil default: @@ -205,7 +205,7 @@ func (x *fastReflection_BaseBeaconKitBlock) Get(descriptor protoreflect.FieldDes return protoreflect.ValueOfUint64(value) case "types.consensus.v1.BaseBeaconKitBlock.version": value := x.Version - return protoreflect.ValueOfUint64(value) + return protoreflect.ValueOfInt64(value) case "types.consensus.v1.BaseBeaconKitBlock.exec_data": value := x.ExecData return protoreflect.ValueOfBytes(value) @@ -236,7 +236,7 @@ func (x *fastReflection_BaseBeaconKitBlock) Set(fd protoreflect.FieldDescriptor, case "types.consensus.v1.BaseBeaconKitBlock.value": x.Value = value.Uint() case "types.consensus.v1.BaseBeaconKitBlock.version": - x.Version = value.Uint() + x.Version = value.Int() case "types.consensus.v1.BaseBeaconKitBlock.exec_data": x.ExecData = value.Bytes() default: @@ -289,7 +289,7 @@ func (x *fastReflection_BaseBeaconKitBlock) NewField(fd protoreflect.FieldDescri case "types.consensus.v1.BaseBeaconKitBlock.value": return protoreflect.ValueOfUint64(uint64(0)) case "types.consensus.v1.BaseBeaconKitBlock.version": - return protoreflect.ValueOfUint64(uint64(0)) + return protoreflect.ValueOfInt64(int64(0)) case "types.consensus.v1.BaseBeaconKitBlock.exec_data": return protoreflect.ValueOfBytes(nil) default: @@ -553,7 +553,7 @@ func (x *fastReflection_BaseBeaconKitBlock) ProtoMethods() *protoiface.Methods { } b := dAtA[iNdEx] iNdEx++ - x.Version |= uint64(b&0x7F) << shift + x.Version |= int64(b&0x7F) << shift if b < 0x80 { break } @@ -674,7 +674,7 @@ type BaseBeaconKitBlock struct { Slot uint64 `protobuf:"varint,1,opt,name=slot,proto3" json:"slot,omitempty"` Time uint64 `protobuf:"varint,2,opt,name=time,proto3" json:"time,omitempty"` Value uint64 `protobuf:"varint,3,opt,name=value,proto3" json:"value,omitempty"` - Version uint64 `protobuf:"varint,4,opt,name=version,proto3" json:"version,omitempty"` + Version int64 `protobuf:"varint,4,opt,name=version,proto3" json:"version,omitempty"` ExecData []byte `protobuf:"bytes,5,opt,name=exec_data,json=execData,proto3" json:"exec_data,omitempty"` } @@ -719,7 +719,7 @@ func (x *BaseBeaconKitBlock) GetValue() uint64 { return 0 } -func (x *BaseBeaconKitBlock) GetVersion() uint64 { +func (x *BaseBeaconKitBlock) GetVersion() int64 { if x != nil { return x.Version } @@ -754,7 +754,7 @@ var file_types_consensus_v1_block_proto_rawDesc = []byte{ 0x70, 0x72, 0x79, 0x73, 0x6d, 0x61, 0x74, 0x69, 0x63, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x34, 0x2f, 0x6d, 0x61, 0x74, 0x68, 0x2e, 0x47, 0x77, 0x65, 0x69, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, - 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, + 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1b, 0x0a, 0x09, 0x65, 0x78, 0x65, 0x63, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x65, 0x78, 0x65, 0x63, 0x44, 0x61, 0x74, 0x61, 0x42, 0xbf, 0x01, 0x0a, 0x16, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x63, 0x6f, 0x6e, diff --git a/cosmos/x/beacon/keeper/keeper_test.go b/cosmos/x/beacon/keeper/keeper_test.go index 41dd6249fd..30bc4aaced 100644 --- a/cosmos/x/beacon/keeper/keeper_test.go +++ b/cosmos/x/beacon/keeper/keeper_test.go @@ -24,15 +24,3 @@ // OTHER DEALINGS IN THE SOFTWARE. package keeper_test - -import ( - "testing" - - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" -) - -func TestKeeper(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "cosmos/x/beacon/keeper") -} diff --git a/cosmos/x/beacon/keeper/store/beacon.go b/cosmos/x/beacon/keeper/store/beacon.go index 80ceb5df0a..59b7e54212 100644 --- a/cosmos/x/beacon/keeper/store/beacon.go +++ b/cosmos/x/beacon/keeper/store/beacon.go @@ -38,11 +38,16 @@ import ( // BeaconStore is a wrapper around a KVStore sdk.Context // that provides access to all beacon related data. type BeaconStore struct { - sdkCtx sdk.Context store.KVStore + + // sdkCtx is the context of the store. + sdkCtx sdk.Context + + // cfg is the beacon configuration. cfg *config.Beacon // lastValidHash is the last valid head in the store. + // TODO: we need to handle this in a better way. lastValidHash common.Hash } diff --git a/cosmos/x/beacon/keeper/store/metadata.go b/cosmos/x/beacon/keeper/store/metadata.go index 437de28bbf..0023667981 100644 --- a/cosmos/x/beacon/keeper/store/metadata.go +++ b/cosmos/x/beacon/keeper/store/metadata.go @@ -36,7 +36,7 @@ func (s *BeaconStore) Slot() primitives.Slot { // TODO: move these? It feels coupled to this x/beacon. But it's okay for now. // Time returns the current time of the beacon chain in Unix timestamp format. func (s *BeaconStore) Time() uint64 { - return uint64(s.sdkCtx.BlockTime().Unix()) + return uint64(s.sdkCtx.BlockTime().Unix()) //#nosec:G701 // won't realistically overflow. } // Version returns the active fork version of the beacon chain based on the current slot. diff --git a/go.mod b/go.mod index 1b1f03c9e8..95bfc11772 100644 --- a/go.mod +++ b/go.mod @@ -2,11 +2,7 @@ module github.com/itsdevbear/bolaris go 1.21 -replace ( - // Required until bumped in the sdk. - github.com/cometbft/cometbft => github.com/cometbft/cometbft v0.38.5 - github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 -) +replace github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 require ( cosmossdk.io/api v0.7.2 @@ -23,19 +19,16 @@ require ( github.com/cometbft/cometbft v0.38.5 github.com/cosmos/cosmos-db v1.0.0 github.com/cosmos/cosmos-proto v1.0.0-beta.3 - github.com/cosmos/cosmos-sdk v0.50.4-0.20240119174318-d0c414eb6212 + github.com/cosmos/cosmos-sdk v0.50.4-0.20240130215335-d2f96344437f github.com/cosmos/gogoproto v1.4.11 github.com/cosmos/gosec/v2 v2.0.0-20230124142343-bf28a33fadf2 github.com/ethereum/go-ethereum v1.13.11 github.com/golangci/golangci-lint v1.55.2 github.com/google/addlicense v1.1.1 github.com/grpc-ecosystem/grpc-gateway v1.16.0 - github.com/onsi/ginkgo/v2 v2.15.0 - github.com/onsi/gomega v1.31.1 github.com/pkg/errors v0.9.1 github.com/prysmaticlabs/fastssz v0.0.0-20221107182844-78142813af44 github.com/prysmaticlabs/prysm/v4 v4.2.1 - github.com/securego/gosec/v2 v2.18.2 github.com/spf13/cast v1.6.0 github.com/spf13/cobra v1.8.0 github.com/spf13/viper v1.18.2 @@ -179,7 +172,6 @@ require ( github.com/go-logr/logr v1.4.1 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-ole/go-ole v1.3.0 // indirect - github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect github.com/go-toolsmith/astcast v1.1.0 // indirect github.com/go-toolsmith/astcopy v1.1.0 // indirect github.com/go-toolsmith/astequal v1.1.0 // indirect @@ -367,6 +359,7 @@ require ( github.com/sashamelentyev/interfacebloat v1.1.0 // indirect github.com/sashamelentyev/usestdlibvars v1.24.0 // indirect github.com/schollz/progressbar/v3 v3.3.4 // indirect + github.com/securego/gosec/v2 v2.18.2 // indirect github.com/shazow/go-diff v0.0.0-20160112020656-b6b7b6733b8c // indirect github.com/shirou/gopsutil v3.21.11+incompatible // indirect github.com/sirupsen/logrus v1.9.3 // indirect diff --git a/go.sum b/go.sum index 121e4786d6..558f7d1de5 100644 --- a/go.sum +++ b/go.sum @@ -465,8 +465,8 @@ github.com/cosmos/cosmos-db v1.0.0 h1:EVcQZ+qYag7W6uorBKFPvX6gRjw6Uq2hIh4hCWjuQ0 github.com/cosmos/cosmos-db v1.0.0/go.mod h1:iBvi1TtqaedwLdcrZVYRSSCb6eSy61NLj4UNmdIgs0U= github.com/cosmos/cosmos-proto v1.0.0-beta.3 h1:VitvZ1lPORTVxkmF2fAp3IiA61xVwArQYKXTdEcpW6o= github.com/cosmos/cosmos-proto v1.0.0-beta.3/go.mod h1:t8IASdLaAq+bbHbjq4p960BvcTqtwuAxid3b/2rOD6I= -github.com/cosmos/cosmos-sdk v0.50.4-0.20240119174318-d0c414eb6212 h1:VpSx7GIlKEyuNKsyHS4/1SRrJ96xUW7JGVj47YJ0tqY= -github.com/cosmos/cosmos-sdk v0.50.4-0.20240119174318-d0c414eb6212/go.mod h1:tlrkY1sntOt1q0OX/rqF0zRJtmXNoffAS6VFTcky+w8= +github.com/cosmos/cosmos-sdk v0.50.4-0.20240130215335-d2f96344437f h1:6RniqBz3CkMKNcb8GBeIK9HZU/rrwivT7yDyPLZd0Ps= +github.com/cosmos/cosmos-sdk v0.50.4-0.20240130215335-d2f96344437f/go.mod h1:0D9mrUy1eAUMQuvYzf2xvhEPk2ta9w7XH1zcYvyFiuM= github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY= github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= github.com/cosmos/gogogateway v1.2.0 h1:Ae/OivNhp8DqBi/sh2A8a1D0y638GpL3tkmLQAiKxTE= @@ -1280,15 +1280,15 @@ github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108 github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= -github.com/onsi/ginkgo/v2 v2.15.0 h1:79HwNRBAZHOEwrczrgSOPy+eFTTlIGELKy5as+ClttY= -github.com/onsi/ginkgo/v2 v2.15.0/go.mod h1:HlxMHtYF57y6Dpf+mc5529KKmSq9h2FpCF+/ZkwUxKM= +github.com/onsi/ginkgo/v2 v2.13.0 h1:0jY9lJquiL8fcf3M4LAXN5aMlS/b2BV86HFFPCPMgE4= +github.com/onsi/ginkgo/v2 v2.13.0/go.mod h1:TE309ZR8s5FsKKpuB1YAQYBzCaAfUgatB/xlT/ETL/o= github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= -github.com/onsi/gomega v1.31.1 h1:KYppCUK+bUgAZwHOu7EXVBKyQA6ILvOESHkn/tgoqvo= -github.com/onsi/gomega v1.31.1/go.mod h1:y40C95dwAD1Nz36SsEnxvfFe8FFfNxzI5eJ0EYGyAy0= +github.com/onsi/gomega v1.28.1 h1:MijcGUbfYuznzK/5R4CPNoUP/9Xvuo20sXfEm6XxoTA= +github.com/onsi/gomega v1.28.1/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ= github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= github.com/openconfig/gnmi v0.0.0-20190823184014-89b2bf29312c/go.mod h1:t+O9It+LKzfOAhKTT5O0ehDix+MTqbtT0T9t+7zzOvc= github.com/openconfig/reference v0.0.0-20190727015836-8dfd928c9696/go.mod h1:ym2A+zigScwkSEb/cVQB0/ZMpU3rqiH6X7WRRsxgOGw= diff --git a/proto/types/consensus/v1/block.proto b/proto/types/consensus/v1/block.proto index 619a12c702..b98d050a24 100644 --- a/proto/types/consensus/v1/block.proto +++ b/proto/types/consensus/v1/block.proto @@ -35,6 +35,6 @@ message BaseBeaconKitBlock { uint64 slot = 1 [(gogoproto.casttype) = "github.com/prysmaticlabs/prysm/v4/consensus-types/primitives.Slot"]; uint64 time = 2; uint64 value = 3 [(gogoproto.casttype) = "github.com/prysmaticlabs/prysm/v4/math.Gwei"]; - uint64 version = 4; + int64 version = 4; bytes exec_data = 5; } diff --git a/runtime/abci/proposal/proposal.go b/runtime/abci/proposal/proposal.go index b09eb80dfb..4f0a119c4b 100644 --- a/runtime/abci/proposal/proposal.go +++ b/runtime/abci/proposal/proposal.go @@ -39,7 +39,8 @@ import ( consensusv1 "github.com/itsdevbear/bolaris/types/consensus/v1" ) -// Handler is a struct that encapsulates the necessary components to handle the proposal processes. +// Handler is a struct that encapsulates the necessary components to handle +// the proposal processes. type Handler struct { cfg *config.Proposal beaconChain *blockchain.Service @@ -62,6 +63,8 @@ func NewHandler( } } +// PrepareProposalHandler is a wrapper around the prepare proposal handler +// that injects the beacon block into the proposal. func (h *Handler) PrepareProposalHandler( ctx sdk.Context, req *abci.RequestPrepareProposal, ) (*abci.ResponsePrepareProposal, error) { @@ -97,6 +100,8 @@ func (h *Handler) PrepareProposalHandler( return resp, nil } +// ProcessProposalHandler is a wrapper around the process proposal handler +// that extracts the beacon block from the proposal and processes it. func (h *Handler) ProcessProposalHandler( ctx sdk.Context, req *abci.RequestProcessProposal, ) (*abci.ResponseProcessProposal, error) { diff --git a/types/consensus/v1/block.go b/types/consensus/v1/block.go index a1f80e4251..17a28b30f4 100644 --- a/types/consensus/v1/block.go +++ b/types/consensus/v1/block.go @@ -58,7 +58,7 @@ func NewBaseBeaconKitBlock( block := &BaseBeaconKitBlock{ Slot: slot, Time: time, - Version: uint64(version), + Version: int64(version), } if executionData != nil { if err := block.AttachExecutionData(executionData); err != nil { @@ -140,6 +140,9 @@ func (b *BaseBeaconKitBlock) AttachExecutionData( // ExecutionData returns the execution data of the block. func (b *BaseBeaconKitBlock) ExecutionData() interfaces.ExecutionData { // Safe to ignore the error since we successfully marshalled the data before. - data, _ := BytesToExecutionData(b.ExecData, b.Value, int(b.Version)) + data, err := BytesToExecutionData(b.ExecData, b.Value, int(b.Version)) + if err != nil { + panic(err) + } return data } diff --git a/types/consensus/v1/block.pb.go b/types/consensus/v1/block.pb.go index e2cd558a1b..021eecc801 100644 --- a/types/consensus/v1/block.pb.go +++ b/types/consensus/v1/block.pb.go @@ -30,7 +30,7 @@ type BaseBeaconKitBlock struct { Slot github_com_prysmaticlabs_prysm_v4_consensus_types_primitives.Slot `protobuf:"varint,1,opt,name=slot,proto3,casttype=github.com/prysmaticlabs/prysm/v4/consensus-types/primitives.Slot" json:"slot,omitempty"` Time uint64 `protobuf:"varint,2,opt,name=time,proto3" json:"time,omitempty"` Value github_com_prysmaticlabs_prysm_v4_math.Gwei `protobuf:"varint,3,opt,name=value,proto3,casttype=github.com/prysmaticlabs/prysm/v4/math.Gwei" json:"value,omitempty"` - Version uint64 `protobuf:"varint,4,opt,name=version,proto3" json:"version,omitempty"` + Version int64 `protobuf:"varint,4,opt,name=version,proto3" json:"version,omitempty"` ExecData []byte `protobuf:"bytes,5,opt,name=exec_data,json=execData,proto3" json:"exec_data,omitempty"` } @@ -88,7 +88,7 @@ func (m *BaseBeaconKitBlock) GetValue() github_com_prysmaticlabs_prysm_v4_math.G return 0 } -func (m *BaseBeaconKitBlock) GetVersion() uint64 { +func (m *BaseBeaconKitBlock) GetVersion() int64 { if m != nil { return m.Version } @@ -109,27 +109,27 @@ func init() { func init() { proto.RegisterFile("types/consensus/v1/block.proto", fileDescriptor_b29fa1ac1aaec767) } var fileDescriptor_b29fa1ac1aaec767 = []byte{ - // 313 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x91, 0xbf, 0x4e, 0xf3, 0x30, - 0x14, 0xc5, 0x9b, 0x7e, 0xe9, 0x07, 0x58, 0x4c, 0x16, 0x43, 0x04, 0x92, 0x5b, 0x31, 0x55, 0x42, - 0xc4, 0x54, 0xf0, 0x02, 0x44, 0x54, 0x48, 0xb0, 0x85, 0x09, 0x16, 0xe4, 0xa4, 0x57, 0xad, 0x45, - 0x12, 0x47, 0xb9, 0xb7, 0x86, 0x8e, 0xbc, 0x01, 0x8f, 0xc5, 0xd8, 0x91, 0xa9, 0x42, 0xcd, 0x5b, - 0x74, 0x42, 0x71, 0xc4, 0x1f, 0x89, 0x81, 0xed, 0x1e, 0x1f, 0xfb, 0x77, 0x8e, 0x7c, 0x99, 0xa0, - 0x45, 0x09, 0x28, 0x53, 0x53, 0x20, 0x14, 0x38, 0x47, 0x69, 0x47, 0x32, 0xc9, 0x4c, 0xfa, 0x10, - 0x96, 0x95, 0x21, 0xc3, 0xb9, 0xf3, 0xc3, 0x2f, 0x3f, 0xb4, 0xa3, 0xfd, 0xbd, 0xa9, 0x99, 0x1a, - 0x67, 0xcb, 0x66, 0x6a, 0x6f, 0x1e, 0x3e, 0x77, 0x19, 0x8f, 0x14, 0x42, 0x04, 0x2a, 0x35, 0xc5, - 0xb5, 0xa6, 0xa8, 0xc1, 0xf0, 0x5b, 0xe6, 0x63, 0x66, 0x28, 0xf0, 0x06, 0xde, 0xd0, 0x8f, 0xc6, - 0x9b, 0x55, 0xff, 0x7c, 0xaa, 0x69, 0x36, 0x4f, 0xc2, 0xd4, 0xe4, 0xb2, 0xac, 0x16, 0x98, 0x2b, - 0xd2, 0x69, 0xa6, 0x12, 0x6c, 0x95, 0xb4, 0x67, 0xdf, 0x75, 0x8e, 0xdb, 0x7a, 0x65, 0xa5, 0x73, - 0x4d, 0xda, 0x02, 0x86, 0x37, 0x99, 0xa1, 0xd8, 0x21, 0x39, 0x67, 0x3e, 0xe9, 0x1c, 0x82, 0x6e, - 0x83, 0x8e, 0xdd, 0xcc, 0xc7, 0xac, 0x67, 0x55, 0x36, 0x87, 0xe0, 0x9f, 0xcb, 0x93, 0x9b, 0x55, - 0xff, 0xe8, 0xef, 0xbc, 0x5c, 0xd1, 0x2c, 0xbc, 0x7c, 0x04, 0x1d, 0xb7, 0xaf, 0x79, 0xc0, 0xb6, - 0x2c, 0x54, 0xa8, 0x4d, 0x11, 0xf8, 0x8e, 0xfe, 0x29, 0xf9, 0x01, 0xdb, 0x81, 0x27, 0x48, 0xef, - 0x27, 0x8a, 0x54, 0xd0, 0x1b, 0x78, 0xc3, 0xdd, 0x78, 0xbb, 0x39, 0xb8, 0x50, 0xa4, 0xa2, 0xab, - 0xd7, 0xb5, 0xf0, 0x96, 0x6b, 0xe1, 0xbd, 0xaf, 0x85, 0xf7, 0x52, 0x8b, 0xce, 0xb2, 0x16, 0x9d, - 0xb7, 0x5a, 0x74, 0xee, 0x4e, 0x7e, 0x94, 0xd0, 0x84, 0x13, 0xb0, 0x09, 0xa8, 0x4a, 0x26, 0x26, - 0x53, 0x95, 0x46, 0xf9, 0x7b, 0x0b, 0xc9, 0x7f, 0xf7, 0xad, 0xa7, 0x1f, 0x01, 0x00, 0x00, 0xff, - 0xff, 0xde, 0x02, 0x64, 0x2d, 0xa2, 0x01, 0x00, 0x00, + // 314 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x51, 0x4d, 0x4b, 0xc3, 0x40, + 0x10, 0xed, 0xb6, 0xa9, 0x1f, 0x8b, 0xa7, 0xc5, 0x43, 0x50, 0xd8, 0x16, 0x4f, 0x05, 0x31, 0x6b, + 0xd1, 0x3f, 0x60, 0xb0, 0x08, 0x7a, 0x8b, 0x27, 0xbd, 0xc8, 0x26, 0x1d, 0xda, 0xc5, 0x24, 0x1b, + 0x32, 0xd3, 0xd5, 0x1e, 0xfd, 0x07, 0xfe, 0x2c, 0x8f, 0x3d, 0x7a, 0x2a, 0xd2, 0xfe, 0x8b, 0x9e, + 0x24, 0x09, 0x7e, 0x80, 0x07, 0x6f, 0xef, 0xed, 0xdb, 0x79, 0xef, 0x31, 0xc3, 0x25, 0xcd, 0x0b, + 0x40, 0x95, 0xd8, 0x1c, 0x21, 0xc7, 0x19, 0x2a, 0x37, 0x54, 0x71, 0x6a, 0x93, 0xc7, 0xa0, 0x28, + 0x2d, 0x59, 0x21, 0x6a, 0x3d, 0xf8, 0xd6, 0x03, 0x37, 0x3c, 0xd8, 0x9f, 0xd8, 0x89, 0xad, 0x65, + 0x55, 0xa1, 0xe6, 0xe7, 0xd1, 0x4b, 0x9b, 0x8b, 0x50, 0x23, 0x84, 0xa0, 0x13, 0x9b, 0xdf, 0x18, + 0x0a, 0x2b, 0x1b, 0x71, 0xc7, 0x3d, 0x4c, 0x2d, 0xf9, 0xac, 0xcf, 0x06, 0x5e, 0x38, 0xda, 0x2c, + 0x7b, 0x17, 0x13, 0x43, 0xd3, 0x59, 0x1c, 0x24, 0x36, 0x53, 0x45, 0x39, 0xc7, 0x4c, 0x93, 0x49, + 0x52, 0x1d, 0x63, 0xc3, 0x94, 0x3b, 0xff, 0xa9, 0x73, 0xd2, 0xd4, 0x2b, 0x4a, 0x93, 0x19, 0x32, + 0x0e, 0x30, 0xb8, 0x4d, 0x2d, 0x45, 0xb5, 0xa5, 0x10, 0xdc, 0x23, 0x93, 0x81, 0xdf, 0xae, 0xac, + 0xa3, 0x1a, 0x8b, 0x11, 0xef, 0x3a, 0x9d, 0xce, 0xc0, 0xef, 0xd4, 0x79, 0x6a, 0xb3, 0xec, 0x1d, + 0xff, 0x9f, 0x97, 0x69, 0x9a, 0x06, 0x57, 0x4f, 0x60, 0xa2, 0x66, 0x5a, 0xf8, 0x7c, 0xdb, 0x41, + 0x89, 0xc6, 0xe6, 0xbe, 0xd7, 0x67, 0x83, 0x4e, 0xf4, 0x45, 0xc5, 0x21, 0xdf, 0x85, 0x67, 0x48, + 0x1e, 0xc6, 0x9a, 0xb4, 0xdf, 0xed, 0xb3, 0xc1, 0x5e, 0xb4, 0x53, 0x3d, 0x5c, 0x6a, 0xd2, 0xe1, + 0xf5, 0xdb, 0x4a, 0xb2, 0xc5, 0x4a, 0xb2, 0x8f, 0x95, 0x64, 0xaf, 0x6b, 0xd9, 0x5a, 0xac, 0x65, + 0xeb, 0x7d, 0x2d, 0x5b, 0xf7, 0xa7, 0xbf, 0x4a, 0x18, 0xc2, 0x31, 0xb8, 0x18, 0x74, 0xa9, 0x62, + 0x9b, 0xea, 0xd2, 0xa0, 0xfa, 0x7b, 0x85, 0x78, 0xab, 0x5e, 0xeb, 0xd9, 0x67, 0x00, 0x00, 0x00, + 0xff, 0xff, 0xd5, 0x20, 0x5e, 0x9e, 0xa2, 0x01, 0x00, 0x00, } func (m *BaseBeaconKitBlock) Marshal() (dAtA []byte, err error) { @@ -324,7 +324,7 @@ func (m *BaseBeaconKitBlock) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Version |= uint64(b&0x7F) << shift + m.Version |= int64(b&0x7F) << shift if b < 0x80 { break }