Skip to content

Commit

Permalink
Merge branch 'devnet' of https://github.com/wemixarchive/go-wemix int…
Browse files Browse the repository at this point in the history
…o feat/brioche_devnet
  • Loading branch information
egonspace committed Jun 10, 2024
2 parents d3d1ba4 + 40910c4 commit f6f95ae
Show file tree
Hide file tree
Showing 38 changed files with 1,355 additions and 135 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/artifacts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: artifacts

on:
push:
branches:
- devnet
- master

jobs:

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.19'

- name: Build Go-WEMIX tarball
run: USE_ROCKSDB=YES make gwemix.tar.gz

- name: Stat Go-WEMIX tarball
run: |
ls -l build/gwemix.tar.gz
tar tf build/gwemix.tar.gz
- name: Move results to artifact
run: mv build/gwemix.tar.gz gwemix-${{ github.ref_name }}-${{ github.sha }}-linux-amd64-rocksdb.tar.gz

- name: Upload Go-WEMIX
uses: actions/upload-artifact@v4
with:
name: artifact-${{ github.ref_name }}-${{ github.sha }}
path: gwemix-${{ github.ref_name }}-${{ github.sha }}-linux-amd64-rocksdb.tar.gz
60 changes: 60 additions & 0 deletions .github/workflows/devnet-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: devnet-ci

on:
pull_request:
branches:
- devnet

jobs:
build_test:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19

- name: Build Go-WEMIX
run: make gwemix.tar.gz
- name: Check Build
run: ls -al build/gwemix.tar.gz

lint_test:
strategy:
fail-fast: false
matrix:
version: [1.17, 1.18, 1.19]
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.version }}

- name: Check Lint
run: make lint

unit_test:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19

- name: Check golang Test Cases
run: |
unset ANDROID_HOME
make test
104 changes: 87 additions & 17 deletions Dockerfile.wemix
Original file line number Diff line number Diff line change
@@ -1,24 +1,94 @@
# builder image
# Stage 1: Build stage
FROM golang:1.19 as builder

FROM ubuntu:focal as base
# Set environment variables
ENV PATH=/usr/local/go/bin:$PATH

SHELL ["/bin/bash", "-c"]
# Update and upgrade the package list
RUN apt-get update && \
apt-get upgrade -q -y

RUN apt-get update -q -y && apt-get upgrade -q -y
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y tzdata
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends build-essential ca-certificates curl libjemalloc-dev liblz4-dev libsnappy-dev libzstd-dev libudev-dev git
# Install required packages
RUN apt-get install -y --no-install-recommends \
git \
ca-certificates \
openssl \
make && \
rm -rf /var/lib/apt/lists/*

# golang
RUN curl -sL -o /tmp/go.tar.gz https://dl.google.com/go/$(curl -sL https://golang.org/VERSION?m=text | head -1).linux-amd64.tar.gz && \
pushd /usr/local/ && \
tar xfz /tmp/go.tar.gz && \
cd /usr/local/bin/ && \
ln -sf ../go/bin/* . && \
popd && \
rm /tmp/go.tar.gz
# Define the location for custom certificates
ARG cert_location=/usr/local/share/ca-certificates

RUN apt autoremove && apt autoclean
# Fetch and install certificates for github.com and proxy.golang.org
RUN openssl s_client -showcerts -connect github.com:443 </dev/null 2>/dev/null | \
openssl x509 -outform PEM > ${cert_location}/github.crt && \
openssl s_client -showcerts -connect proxy.golang.org:443 </dev/null 2>/dev/null | \
openssl x509 -outform PEM > ${cert_location}/proxy.golang.crt && \
update-ca-certificates

ENTRYPOINT ["/bin/bash", "-c"]
# Clone the repository, install dependencies, and build the project
RUN git clone https://github.com/wemixarchive/go-wemix.git /go-wemix && \
cd /go-wemix && \
go mod download && \
make

# EOF
# Clean up unnecessary packages and files after building
RUN apt-get remove -y \
git \
ca-certificates \
openssl \
make && \
apt autoremove -y && \
apt-get clean

# Stage 2: Runtime stage
FROM ubuntu:22.04

# Set environment variables
ENV SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt

# Update and upgrade the package list
RUN apt-get update && \
apt-get upgrade -q -y

# Install required runtime packages
RUN apt-get install -y --no-install-recommends \
g++ \
libc-dev \
ca-certificates \
bash \
wget && \
update-ca-certificates && \
rm -rf /var/lib/apt/lists/*

# Create directories for wemix
RUN mkdir -p /usr/local/wemix /usr/local/wemix/keystore

# Set environment variables
ENV PATH=/usr/local/wemix/bin:$PATH

# Copy the built binaries and configuration files from the builder stage
COPY --from=builder /go-wemix/build /usr/local/wemix/

# Download and install solc
RUN wget -nv -O /usr/local/bin/solc https://github.com/ethereum/solidity/releases/download/v0.4.24/solc-static-linux && \
chmod a+x /usr/local/bin/solc

# Create new accounts for wemix
RUN bash -c 'for i in 1 2 3 4; do \
/usr/local/wemix/bin/gwemix wemix new-account --password <(echo demo) --out /usr/local/wemix/keystore/account-$i; \
done'

# Clean up unnecessary packages
RUN apt-get remove -y \
g++ \
libc-dev \
wget && \
apt autoremove -y && \
apt-get clean

# Expose necessary ports
EXPOSE 8588 8589 8598

# Set the entrypoint
ENTRYPOINT ["/usr/local/wemix/bin/gwemix"]
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ After getting enodes of mining nodes, run gwemix as follows.

bin/gwemix --syncmode full --datadir <data-directory> --bootnodes <enodes> --http --http.addr 0.0.0.0

### Starting Nodes With Docker

See documentation [here](docs/container.md)

### The original go-ethereum README follows...

## Go Ethereum
Expand Down
6 changes: 3 additions & 3 deletions cmd/geth/dbcmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"sort"
"strconv"
"strings"
"syscall"
"time"

"github.com/ethereum/go-ethereum/cmd/utils"
Expand All @@ -40,6 +39,7 @@ import (
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/trie"
"github.com/olekukonko/tablewriter"
"golang.org/x/sys/unix"
"gopkg.in/urfave/cli.v1"
)

Expand Down Expand Up @@ -597,7 +597,7 @@ func importLDBdata(ctx *cli.Context) error {
stop = make(chan struct{})
)
defer stack.Close()
signal.Notify(interrupt, syscall.SIGINT, syscall.SIGTERM)
signal.Notify(interrupt, unix.SIGINT, unix.SIGTERM)
defer signal.Stop(interrupt)
defer close(interrupt)
go func() {
Expand Down Expand Up @@ -693,7 +693,7 @@ func exportChaindata(ctx *cli.Context) error {
stop = make(chan struct{})
)
defer stack.Close()
signal.Notify(interrupt, syscall.SIGINT, syscall.SIGTERM)
signal.Notify(interrupt, unix.SIGINT, unix.SIGTERM)
defer signal.Stop(interrupt)
defer close(interrupt)
go func() {
Expand Down
6 changes: 3 additions & 3 deletions cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"sort"
"strconv"
"strings"
"syscall"
"time"

"github.com/elastic/gosigar"
Expand All @@ -45,6 +44,7 @@ import (
"github.com/ethereum/go-ethereum/metrics"
"github.com/ethereum/go-ethereum/node"
"github.com/ethereum/go-ethereum/wemix"
"golang.org/x/sys/unix"

// Force-load the tracer engines to trigger registration
_ "github.com/ethereum/go-ethereum/eth/tracers/js"
Expand Down Expand Up @@ -514,8 +514,8 @@ func limitMaxRss(max int64) {
timer := time.NewTimer(interval)
for {
<-timer.C
rusage := syscall.Rusage{}
err := syscall.Getrusage(syscall.RUSAGE_SELF, &rusage)
rusage := unix.Rusage{}
err := unix.Getrusage(unix.RUSAGE_SELF, &rusage)
if err != nil {
log.Error("Getrusage() failed:", "reason", err)
} else {
Expand Down
10 changes: 5 additions & 5 deletions cmd/geth/wemixcmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"path/filepath"
"strconv"
"strings"
"syscall"

"github.com/charlanxcc/logrot"
"github.com/ethereum/go-ethereum/accounts/keystore"
Expand All @@ -29,6 +28,7 @@ import (
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/p2p/enode"
"github.com/ethereum/go-ethereum/wemix/metclient"
"golang.org/x/sys/unix"
"gopkg.in/urfave/cli.v1"
)

Expand Down Expand Up @@ -667,10 +667,10 @@ func logrota(ctx *cli.Context) error {
if err != nil {
return err
}
syscall.Close(syscall.Stdout)
syscall.Close(syscall.Stdout)
syscall.Dup2(int(w.Fd()), syscall.Stdout)
syscall.Dup2(int(w.Fd()), syscall.Stderr)
unix.Close(unix.Stdout)
unix.Close(unix.Stdout)
unix.Dup2(int(w.Fd()), unix.Stdout)
unix.Dup2(int(w.Fd()), unix.Stderr)

go logrot.LogRotate(r, logFile, logSize, logCount)

Expand Down
10 changes: 5 additions & 5 deletions cmd/utils/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"os/signal"
"runtime"
"strings"
"syscall"
"time"

"github.com/ethereum/go-ethereum/common"
Expand All @@ -41,6 +40,7 @@ import (
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/node"
"github.com/ethereum/go-ethereum/rlp"
"golang.org/x/sys/unix"
"gopkg.in/urfave/cli.v1"
)

Expand Down Expand Up @@ -74,7 +74,7 @@ func StartNode(ctx *cli.Context, stack *node.Node, isConsole bool) {
}
go func() {
sigc := make(chan os.Signal, 1)
signal.Notify(sigc, syscall.SIGINT, syscall.SIGTERM)
signal.Notify(sigc, unix.SIGINT, unix.SIGTERM)
defer signal.Stop(sigc)

minFreeDiskSpace := 2 * ethconfig.Defaults.TrieDirtyCache // Default 2 * 256Mb
Expand Down Expand Up @@ -105,7 +105,7 @@ func StartNode(ctx *cli.Context, stack *node.Node, isConsole bool) {
// However, SIGTERM still shuts down the node.
for {
sig := <-sigc
if sig == syscall.SIGTERM {
if sig == unix.SIGTERM {
shutdown()
return
}
Expand All @@ -126,7 +126,7 @@ func monitorFreeDiskSpace(sigc chan os.Signal, path string, freeDiskSpaceCritica
}
if freeSpace < freeDiskSpaceCritical {
log.Error("Low disk space. Gracefully shutting down Geth to prevent database corruption.", "available", common.StorageSize(freeSpace))
sigc <- syscall.SIGTERM
sigc <- unix.SIGTERM
break
} else if freeSpace < 2*freeDiskSpaceCritical {
log.Warn("Disk space is running low. Geth will shutdown if disk space runs below critical level.", "available", common.StorageSize(freeSpace), "critical_level", common.StorageSize(freeDiskSpaceCritical))
Expand All @@ -140,7 +140,7 @@ func ImportChain(chain *core.BlockChain, fn string) error {
// If a signal is received, the import will stop at the next batch.
interrupt := make(chan os.Signal, 1)
stop := make(chan struct{})
signal.Notify(interrupt, syscall.SIGINT, syscall.SIGTERM)
signal.Notify(interrupt, unix.SIGINT, unix.SIGTERM)
defer signal.Stop(interrupt)
defer close(interrupt)
go func() {
Expand Down
3 changes: 3 additions & 0 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -1041,6 +1041,9 @@ func setRandomBootstrapNodes(ctx *cli.Context, bootnodes []string) []string {
}
// select random bootnodes
selectcount := params.BootnodeCount
if selectcount > bootnodeslen {
selectcount = bootnodeslen
}
urls := make([]string, selectcount)
tempnode := make([]string, bootnodeslen)
copy(tempnode, bootnodes)
Expand Down
Loading

0 comments on commit f6f95ae

Please sign in to comment.