Skip to content

Commit

Permalink
rework
Browse files Browse the repository at this point in the history
  • Loading branch information
itsdevbear committed Feb 4, 2024
1 parent f644260 commit 8ed362a
Show file tree
Hide file tree
Showing 47 changed files with 122 additions and 41 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
strategy:
matrix:
args: ["build", "lint", "gosec", "test-unit-cover"]
os: [ubuntu-latest]
os: [ubuntu-latest-large]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
Expand Down
77 changes: 77 additions & 0 deletions .github/workflows/tagged_docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# 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.

name: docker

on:
push:
# tags:
branches:
- '**'

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push:
runs-on: ubuntu-latest-large
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GH_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
file: examples/beacond/docker/base.Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
TAG=${{ github.ref_name }}
38 changes: 21 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ IMAGE_VERSION ?= v0.0.0
BASE_IMAGE ?= beacond/base:$(IMAGE_VERSION)

# Docker Paths
BASE_DOCKER_PATH = ./app/docker
BASE_DOCKER_PATH = ./examples/beacond/docker
EXEC_DOCKER_PATH = $(BASE_DOCKER_PATH)/base.Dockerfile
LOCAL_DOCKER_PATH = $(BASE_DOCKER_PATH)/local/Dockerfile
SEED_DOCKER_PATH = $(BASE_DOCKER_PATH)/seed/Dockerfile
Expand Down Expand Up @@ -151,11 +151,14 @@ mockery:
# beacond #
#################

# TODO: add start-erigon and start-nethermind
# TODO: add start-erigon and start-nethermin

JWT_PATH = ${TESTAPP_DIR}/jwt.hex
ETH_GENESIS_PATH = ${TESTAPP_DIR}/eth-genesis.json

# Start beacond
start:
@./app/entrypoint.sh
@JWT_SECRET_PATH=$(JWT_PATH) ./examples/beacond/entrypoint.sh

# Start reth node
start-reth:
Expand All @@ -164,38 +167,39 @@ start-reth:
-p 30303:30303 \
-p 8545:8545 \
-p 8551:8551 \
--rm -v $(PWD)/app:/app \
--rm -v $(PWD)/${TESTAPP_DIR}:/${TESTAPP_DIR} \
-v $(PWD)/.tmp:/.tmp \
ghcr.io/paradigmxyz/reth node \
--chain ./app/eth-genesis.json \
--chain ${ETH_GENESIS_PATH} \
--http \
--http.addr "0.0.0.0" \
--http.api eth \
--authrpc.addr "0.0.0.0" \
--authrpc.jwtsecret ./app/jwt.hex
--authrpc.jwtsecret $(JWT_PATH) \
--datadir .tmp/reth

# Init and start geth node
start-geth:
rm -rf .tmp/geth
docker run \
--rm -v $(PWD)/app:/app \
--rm -v $(PWD)/${TESTAPP_DIR}:/${TESTAPP_DIR} \
-v $(PWD)/.tmp:/.tmp \
ethereum/client-go init \
--datadir .tmp/geth \
./app/eth-genesis.json
${ETH_GENESIS_PATH}

docker run \
-p 30303:30303 \
-p 8545:8545 \
-p 8551:8551 \
--rm -v $(PWD)/app:/app \
--rm -v $(PWD)/${TESTAPP_DIR}:/${TESTAPP_DIR} \
-v $(PWD)/.tmp:/.tmp \
ethereum/client-go \
--http \
--http.addr 0.0.0.0 \
--http.api eth \
--authrpc.addr 0.0.0.0 \
--authrpc.jwtsecret ./app/jwt.hex \
--authrpc.jwtsecret $(JWT_PATH) \
--authrpc.vhosts "*" \
--datadir .tmp/geth

Expand All @@ -205,37 +209,37 @@ start-nethermind:
-p 30303:30303 \
-p 8545:8545 \
-p 8551:8551 \
-v $(PWD)/app:/app \
-v $(PWD)/${TESTAPP_DIR}:/${TESTAPP_DIR} \
-v $(PWD)/.tmp:/.tmp \
nethermind/nethermind \
nethermind/nethermind \y
--JsonRpc.Port 8545 \
--JsonRpc.EngineEnabledModules "eth,net,engine" \
--JsonRpc.EnginePort 8551 \
--JsonRpc.EngineHost 0.0.0.0 \
--JsonRpc.Host 0.0.0.0 \
--JsonRpc.JwtSecretFile ../app/jwt.hex \
--JsonRpc.JwtSecretFile ../$(JWT_PATH) \
--Sync.PivotNumber 0 \
--Init.ChainSpecPath ../app/eth-nether-genesis.json
--Init.ChainSpecPath ../$(TESTAPP_DIR)/eth-nether-genesis.json

# Start besu node
start-besu:
docker run \
-p 30303:30303 \
-p 8545:8545 \
-p 8551:8551 \
-v $(PWD)/app:/app \
-v $(PWD)/${TESTAPP_DIR}:/${TESTAPP_DIR} \
-v $(PWD)/.tmp:/.tmp \
hyperledger/besu:latest \
--data-path=.tmp/besu \
--genesis-file=../../app/eth-genesis.json \
--genesis-file=../../${ETH_GENESIS_PATH} \
--rpc-http-enabled \
--rpc-http-api=ETH,NET,ENGINE,DEBUG,NET,WEB3 \
--host-allowlist="*" \
--rpc-http-cors-origins="all" \
--engine-rpc-port=8551 \
--engine-rpc-enabled \
--engine-host-allowlist="*" \
--engine-jwt-secret=../../app/jwt.hex
--engine-jwt-secret=../../${JWT_PATH}



Expand Down
Empty file removed app/README.md
Empty file.
2 changes: 1 addition & 1 deletion build/scripts/cosmos.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export COMMIT := $(shell git log -1 --format='%H')
CURRENT_DIR = $(shell pwd)
OUT_DIR ?= $(CURDIR)/build/bin
BINDIR ?= $(GOPATH)/build/bin
TESTAPP_DIR = ./app
TESTAPP_DIR = examples/beacond
PROJECT_NAME = $(shell git remote get-url origin | xargs basename -s .git)

# process build tags
Expand Down
2 changes: 1 addition & 1 deletion config/execution_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func DefaultExecutionClientConfig() ExecutionClient {
RPCDialURL: "http://localhost:8551",
RPCTimeout: 5, //nolint:gomnd // default config.
RPCRetries: 3, //nolint:gomnd // default config.
JWTSecretPath: "./app/jwt.hex",
JWTSecretPath: "./jwt.hex",
RequiredChainID: 7, //nolint:gomnd // default config.
}
}
5 changes: 5 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# examples

Here we show a variety of examples of how to use beaconkit.


2 changes: 1 addition & 1 deletion app/app.go → examples/beacond/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.

package testapp
package app

import (
"context"
Expand Down
2 changes: 1 addition & 1 deletion app/app_config.go → examples/beacond/app/app_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.

package testapp
package app

import (
runtimev1alpha1 "cosmossdk.io/api/cosmos/app/runtime/v1alpha1"
Expand Down
2 changes: 1 addition & 1 deletion app/export.go → examples/beacond/app/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.

package testapp
package app

import (
"encoding/json"
Expand Down
8 changes: 4 additions & 4 deletions app/beacond/main.go → examples/beacond/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ import (

svrcmd "github.com/cosmos/cosmos-sdk/server/cmd"

testapp "github.com/itsdevbear/bolaris/app"
"github.com/itsdevbear/bolaris/app/beacond/cmd"
"github.com/itsdevbear/bolaris/config"
"github.com/itsdevbear/bolaris/examples/beacond/app"
"github.com/itsdevbear/bolaris/examples/beacond/cmd/root"
)

func main() {
config.SetupCosmosConfig()
rootCmd := cmd.NewRootCmd()
if err := svrcmd.Execute(rootCmd, "", testapp.DefaultNodeHome); err != nil {
rootCmd := root.NewRootCmd()
if err := svrcmd.Execute(rootCmd, "", app.DefaultNodeHome); err != nil {
log.NewLogger(rootCmd.OutOrStderr()).Error("failure when running app", "error", err)
os.Exit(1)
}
Expand Down
4 changes: 2 additions & 2 deletions app/beacond/cmd/root.go → examples/beacond/cmd/root/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
// OTHER DEALINGS IN THE SOFTWARE.

//nolint:govet,gomnd,lll // from sdk.
package cmd
package root

import (
"context"
Expand Down Expand Up @@ -70,7 +70,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/crisis"
genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli"

testapp "github.com/itsdevbear/bolaris/app"
testapp "github.com/itsdevbear/bolaris/examples/beacond/app"

beaconconfig "github.com/itsdevbear/bolaris/config"
beacontemplate "github.com/itsdevbear/bolaris/config/template"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.

package cmd_test
package root_test

import (
"fmt"
Expand All @@ -34,12 +34,12 @@ import (
svrcmd "github.com/cosmos/cosmos-sdk/server/cmd"
"github.com/cosmos/cosmos-sdk/x/genutil/client/cli"

testapp "github.com/itsdevbear/bolaris/app"
"github.com/itsdevbear/bolaris/app/beacond/cmd"
testapp "github.com/itsdevbear/bolaris/examples/beacond/app"
"github.com/itsdevbear/bolaris/examples/beacond/cmd/root"
)

func TestInitCommand(t *testing.T) {
rootCmd := cmd.NewRootCmd()
rootCmd := root.NewRootCmd()
rootCmd.SetOut(os.NewFile(0, os.DevNull))
rootCmd.SetArgs([]string{
"init", // Test the init cmd
Expand All @@ -59,7 +59,7 @@ func TestHomeFlagRegistration(t *testing.T) {
os.Stdout = os.NewFile(0, os.DevNull)
homeDir := os.TempDir()

rootCmd := cmd.NewRootCmd()
rootCmd := root.NewRootCmd()
rootCmd.SetArgs([]string{
"query",
fmt.Sprintf("--%s", flags.FlagHome),
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"

"github.com/itsdevbear/bolaris/app/contracts"
"github.com/itsdevbear/bolaris/beacon/logs/callback"
"github.com/itsdevbear/bolaris/examples/beacond/contracts"
evmv1 "github.com/itsdevbear/bolaris/types/evm/v1"
)

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
ARG GO_VERSION=1.21.6
ARG RUNNER_IMAGE=alpine
ARG BUILD_TAGS="netgo,ledger,muslc"
ARG GOARCH=amd64
ARG GOOS=linux
ARG NAME=beacond
ARG APP_NAME=beacond
ARG DB_BACKEND=pebbledb
Expand Down Expand Up @@ -64,16 +62,13 @@ COPY . .

# Build args
ARG NAME
ARG GOARCH
ARG GOOS
ARG APP_NAME
ARG DB_BACKEND
ARG CMD_PATH

# Build beacond
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/root/go/pkg/mod \
env GOOS=${GOOS} GOARCH=${GOARCH} && \
env NAME=${NAME} DB_BACKEND=${DB_BACKEND} && \
env APP_NAME=${APP_NAME} && \
env CGO_ENABLED=1 && \
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion app/entrypoint.sh → examples/beacond/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,4 @@ fi
./build/bin/beacond start --pruning=nothing "$TRACE" \
--log_level $LOGLEVEL --api.enabled-unsafe-cors \
--api.enable --api.swagger --minimum-gas-prices=0.0001abera \
--home "$HOMEDIR" --beacon-kit.execution-client.jwt-secret-path "./app/jwt.hex"
--home "$HOMEDIR" --beacon-kit.execution-client.jwt-secret-path ${JWT_SECRET_PATH}
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 8ed362a

Please sign in to comment.