diff --git a/cmd/geth/chaincmd.go b/cmd/geth/chaincmd.go index 6e19edeb46eb..d61562ee440d 100644 --- a/cmd/geth/chaincmd.go +++ b/cmd/geth/chaincmd.go @@ -208,6 +208,7 @@ func initGenesis(ctx *cli.Context) error { func dumpGenesis(ctx *cli.Context) error { // TODO(rjl493456442) support loading from the custom datadir + utils.SetWemixConfig(ctx) genesis := utils.MakeGenesis(ctx) if genesis == nil { genesis = core.DefaultGenesisBlock() diff --git a/cmd/geth/config.go b/cmd/geth/config.go index 0b0ff3c19867..6cba9f59e420 100644 --- a/cmd/geth/config.go +++ b/cmd/geth/config.go @@ -144,7 +144,7 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, gethConfig) { utils.Fatalf("Failed to set account manager backends: %v", err) } - utils.SetWemixConfig(ctx, stack, &cfg.Eth) + utils.SetWemixConfig(ctx) utils.SetEthConfig(ctx, stack, &cfg.Eth) if ctx.GlobalIsSet(utils.EthStatsURLFlag.Name) { cfg.Ethstats.URL = ctx.GlobalString(utils.EthStatsURLFlag.Name) diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 6786ac702d82..533173fae553 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -1981,7 +1981,7 @@ func SetDNSDiscoveryDefaults(cfg *ethconfig.Config, genesis common.Hash) { } // SetWemixConfig applies wemix related command line flags to the config. -func SetWemixConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) { +func SetWemixConfig(ctx *cli.Context) { if ctx.GlobalIsSet(ConsensusMethodFlag.Name) { params.ConsensusMethod = ctx.GlobalInt(ConsensusMethodFlag.Name) } else { diff --git a/consensus/ethash/consensus.go b/consensus/ethash/consensus.go index 5a0efda8bfff..1d857e1f9ff3 100644 --- a/consensus/ethash/consensus.go +++ b/consensus/ethash/consensus.go @@ -319,6 +319,10 @@ func (ethash *Ethash) verifyHeader(chain consensus.ChainHeaderReader, header, pa if err := misc.VerifyForkHashes(chain.Config(), header, uncle); err != nil { return err } + // Wemix: Verify SPoA block + if chain.Config().IsMontBlanc(header.Number) { + return fmt.Errorf("go-wemix does not support blocks after MontBlanc hard fork") + } // Wemix: Check if it's generated and signed by a registered node if !wemixminer.IsPoW() && !wemixminer.VerifyBlockSig(header.Number, header.Coinbase, header.MinerNodeId, header.Root, header.MinerNodeSig, chain.Config().IsPangyo(header.Number)) { return consensus.ErrUnauthorized diff --git a/local-docker-env/Dockerfile.boot b/local-docker-env/Dockerfile.boot index 17e95a8abacc..612bbffaa138 100644 --- a/local-docker-env/Dockerfile.boot +++ b/local-docker-env/Dockerfile.boot @@ -2,7 +2,7 @@ ARG UBUNTU_VERSION # Stage 1: Build stage -FROM golang:1.19 as builder +FROM golang:1.19 AS builder # Set environment variables ENV PATH=/usr/local/go/bin:$PATH @@ -42,7 +42,7 @@ RUN apt-get remove -y \ apt-get clean # Stage 2: Runtime stage -FROM ubuntu:${UBUNTU_VERSION} +FROM ubuntu:${UBUNTU_VERSION:-latest} # Update and upgrade the package list RUN apt-get update && \ diff --git a/local-docker-env/Dockerfile.boot.git b/local-docker-env/Dockerfile.boot.git index 1f52860298e1..9b5bb45e370e 100644 --- a/local-docker-env/Dockerfile.boot.git +++ b/local-docker-env/Dockerfile.boot.git @@ -2,7 +2,7 @@ ARG UBUNTU_VERSION # Stage 1: Build stage -FROM golang:1.19 as builder +FROM golang:1.19 AS builder # Set environment variables ENV PATH=/usr/local/go/bin:$PATH @@ -52,7 +52,7 @@ RUN apt-get remove -y \ apt-get clean # Stage 2: Runtime stage -FROM ubuntu:${UBUNTU_VERSION} +FROM ubuntu:${UBUNTU_VERSION:-latest} # Set environment variables ENV SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt diff --git a/local-docker-env/Dockerfile.node b/local-docker-env/Dockerfile.node index 85da7dbe0274..d106e510ef21 100644 --- a/local-docker-env/Dockerfile.node +++ b/local-docker-env/Dockerfile.node @@ -2,7 +2,7 @@ ARG UBUNTU_VERSION # Stage 1: Build stage -FROM golang:1.19 as builder +FROM golang:1.19 AS builder # Set environment variables ENV PATH=/usr/local/go/bin:$PATH @@ -42,7 +42,7 @@ RUN apt-get remove -y \ apt-get clean # Stage 2: Runtime stage -FROM ubuntu:${UBUNTU_VERSION} +FROM ubuntu:${UBUNTU_VERSION:-latest} # Update and upgrade the package list RUN apt-get update && \ diff --git a/local-docker-env/Dockerfile.node.git b/local-docker-env/Dockerfile.node.git index b741be8c4236..07213c3b3625 100644 --- a/local-docker-env/Dockerfile.node.git +++ b/local-docker-env/Dockerfile.node.git @@ -2,7 +2,7 @@ ARG UBUNTU_VERSION # Stage 1: Build stage -FROM golang:1.19 as builder +FROM golang:1.19 AS builder # Set environment variables ENV PATH=/usr/local/go/bin:$PATH @@ -52,7 +52,7 @@ RUN apt-get remove -y \ apt-get clean # Stage 2: Runtime stage -FROM ubuntu:${UBUNTU_VERSION} +FROM ubuntu:${UBUNTU_VERSION:-latest} # Set environment variables ENV SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt diff --git a/local-docker-env/README.md b/local-docker-env/README.md index 29a15f0b3d9a..6a15a5ad9ad7 100644 --- a/local-docker-env/README.md +++ b/local-docker-env/README.md @@ -11,32 +11,22 @@ This document explains how to set up a local testing environment based on the `g ### local-docker.sh - **Purpose**: Integrated running script for local testing based on the local repository. -- **Usage**: `./local-docker-env/local-docker.sh -a -v (optional)` +- **Usage**: `./local-docker-env/local-docker.sh -a -v (optional) --keep-nodekey(optional)` ### local-docker-git.sh - **Purpose**: Integrated running script for local testing based on the Git repository. -- **Usage**: `./local-docker-env/local-docker-git.sh -a -b -r -v (optional)` +- **Usage**: `./local-docker-env/local-docker-git.sh -a -b -r -v (optional --keep-nodekey(optional)` -### key-gen.sh +### gen-nodekey.sh -- **Purpose**: Generates an account in the `keystore` folder and creates a nodekey in the `nodekey` folder. -- **Usage**: `./key-gen.sh -a ` +- **Purpose**: Script for generating a nodekey for the node. +- **Usage**: `./local-docker-env/gen-nodekey.sh -a ` -### config-gen.sh +### gen-account.sh -- **Purpose**: Generates the `config.json` file. -- **Usage**: `./config-gen.sh -a -f ` - -### docker-compose-gen.sh - -- **Purpose**: Generates the `docker-compose.yml` file based on the local repository. -- **Usage**: `./docker-compose-gen.sh -a -f -v (optional)` - -### docker-compose-gen-git.sh - -- **Purpose**: Generates the `docker-compose.yml` file based on the Git repository. -- **Usage**: `./docker-compose-gen-git.sh -a -f -r -b -v (optional)` +- **Purpose**: Script for generating a nodekey for the node. +- **Usage**: `./local-docker-env/gen-account.sh -a ` ### init-boot.sh @@ -66,11 +56,11 @@ This document explains how to set up a local testing environment based on the `g ### Execution based on the local repository code ```bash -./local-docker-env/local-docker.sh -a -v (optional) +./local-docker-env/local-docker.sh -a -v (optional) --keep-nodekey (optional) ``` ### Execution based on the Git repository code ```bash -./local-docker-env/local-docker-git.sh -a -b -r -v (optional) +./local-docker-env/local-docker-git.sh -a -b -r -v (optional) --keep-nodekey (optional) ``` diff --git a/local-docker-env/key-gen.sh b/local-docker-env/gen-account.sh similarity index 57% rename from local-docker-env/key-gen.sh rename to local-docker-env/gen-account.sh index 65a0a8ed297b..88952ec506aa 100755 --- a/local-docker-env/key-gen.sh +++ b/local-docker-env/gen-account.sh @@ -1,33 +1,32 @@ #!/bin/bash -# 필수 인수 확인 +# Check required arguments if [ "$#" -ne 2 ]; then echo "Usage: $0 -a " exit 1 fi -# 옵션 파싱 +# Option parsing while getopts "a:" opt; do case ${opt} in a) ACCOUNT_NUM=$OPTARG ;; \?) - echo "Usage: $0 -a -f " + echo "Usage: $0 -a " exit 1 ;; esac done -# 필수 인수 확인 +# Check required arguments if [ -z "$ACCOUNT_NUM" ]; then exit 1 fi mkdir local-docker-env/keystore -mkdir local-docker-env/nodekey -# 계정 및 노드 키 생성 +# Create accounts for ((i = 1; i <= ACCOUNT_NUM; i++)); do if [ -f "local-docker-env/keystore/account$i" ]; then rm local-docker-env/keystore/account$i @@ -39,14 +38,4 @@ for ((i = 1; i <= ACCOUNT_NUM; i++)); do echo "Failed to create account $i" exit 1 fi - - if [ -f "local-docker-env/nodekey/nodekey$i" ]; then - rm local-docker-env/nodekey/nodekey$i - fi - if gwemix wemix new-nodekey --out local-docker-env/nodekey/nodekey$i; then - echo "Nodekey $i created successfully" - else - echo "Failed to create nodekey $i" - exit 1 - fi done \ No newline at end of file diff --git a/local-docker-env/config-gen.sh b/local-docker-env/gen-config.sh similarity index 81% rename from local-docker-env/config-gen.sh rename to local-docker-env/gen-config.sh index 116f89aed279..2d634fe213e2 100755 --- a/local-docker-env/config-gen.sh +++ b/local-docker-env/gen-config.sh @@ -1,39 +1,39 @@ #!/bin/bash -# 필수 인수 확인 +# Check required arguments if [ "$#" -ne 4 ]; then - echo "Usage: $0 -a -f " + echo "Usage: $0 -a -f " exit 1 fi -# 옵션 파싱 +# Option parsing while getopts "a:f:" opt; do case ${opt} in a) - ACCOUNT_NUM=$OPTARG + NODE_NUM=$OPTARG ;; f) OUTPUT_CONFIG_FILE=$OPTARG ;; \?) - echo "Usage: $0 -a -f " + echo "Usage: $0 -a -f " exit 1 ;; esac done -# 필수 인수 확인 -if [ -z "$ACCOUNT_NUM" ] || [ -z "$OUTPUT_CONFIG_FILE" ]; then +# Check required arguments +if [ -z "$NODE_NUM" ] || [ -z "$OUTPUT_CONFIG_FILE" ]; then exit 1 fi -# 초기화 +# Initialize echo '{"members":[], "accounts":[]}' >"$OUTPUT_CONFIG_FILE" -# 파일을 JSON 형식으로 로드 +# Load file as JSON json_content=$(cat "$OUTPUT_CONFIG_FILE") -# 고정된 env 값을 포함한 JSON 객체 +# JSON object with fixed env values ENV_JSON='{ "ballotDurationMin": 86400, "ballotDurationMax": 604800, @@ -53,8 +53,8 @@ ENV_JSON='{ json_content=$(echo "$json_content" | jq --argjson env "$ENV_JSON" \ '.env = $env| .extraData = "chain for local test"') -# JSON 구성 파일 생성 -for ((i = 1; i <= ACCOUNT_NUM; i++)); do +# Generate JSON config file +for ((i = 1; i <= NODE_NUM; i++)); do ids=$(gwemix wemix nodeid local-docker-env/nodekey/nodekey$i) || { echo "Failed to get node ID"; exit 1; } idv5=$(echo "$ids" | awk '/idv5:/ {print $2}') idv5="0x$idv5" @@ -74,6 +74,6 @@ for ((i = 1; i <= ACCOUNT_NUM; i++)); do fi done -# 수정된 내용을 파일에 저장 +# Save modified content to file echo "$json_content" >"$OUTPUT_CONFIG_FILE" echo "Updated config saved to $OUTPUT_CONFIG_FILE" \ No newline at end of file diff --git a/local-docker-env/docker-compose-gen-git.sh b/local-docker-env/gen-docker-compose-git.sh similarity index 89% rename from local-docker-env/docker-compose-gen-git.sh rename to local-docker-env/gen-docker-compose-git.sh index bf0580145b39..d5e60de670c4 100755 --- a/local-docker-env/docker-compose-gen-git.sh +++ b/local-docker-env/gen-docker-compose-git.sh @@ -1,13 +1,13 @@ #!/bin/bash # Usage: ./gen-docker-compose.sh -a -f -r -b -# -a: 계정 수 -# -f: 출력 파일 -# -r: 레포지토리 URL -# -b: 브랜치 이름 -# -a 옵션은 필수이며, -f 옵션은 선택적 -# -f 옵션을 지정하지 않으면, 현재 디렉토리에 docker-compose.yml 파일을 생성 -# -f 옵션을 지정하면, 해당 경로에 docker-compose.yml 파일을 생성 +# -a: number of accounts +# -f: output file +# -r: repository URL +# -b: branch name +# -a option is mandatory, -f option is optional +# If -f option is not specified, a docker-compose.yml file will be created in the current directory +# If -f option is specified, a docker-compose.yml file will be created at the specified path # Parse command line arguments while getopts "a:f:r:b:v:" opt; do @@ -63,7 +63,7 @@ fi # Set default version if not provided if [ -z "$version" ]; then - version="latest" + version="22.04" fi # Generate docker-compose.yml content diff --git a/local-docker-env/docker-compose-gen.sh b/local-docker-env/gen-docker-compose.sh similarity index 83% rename from local-docker-env/docker-compose-gen.sh rename to local-docker-env/gen-docker-compose.sh index 8639703a0b76..2cfccd50d7fe 100755 --- a/local-docker-env/docker-compose-gen.sh +++ b/local-docker-env/gen-docker-compose.sh @@ -1,13 +1,13 @@ #!/bin/bash # Usage: ./gen-docker-compose.sh -a -f -# -a: 계정 수 -# -f: 출력 파일 -# -a 옵션은 필수이며, -f, -v 옵션은 선택적 -# -f 옵션을 지정하지 않으면, 현재 디렉토리에 docker-compose.yml 파일을 생성 -# -f 옵션을 지정하면, 해당 경로에 docker-compose.yml 파일을 생성 -# -v 옵션을 지정하지 않으면, latest 버전으로 설정 -# -v 옵션을 지정하면, 해당 버전으로 설정 +# -a: number of accounts +# -f: output file +# -a option is required, -f and -v options are optional +# If -f option is not specified, a docker-compose.yml file will be created in the current directory +# If -f option is specified, a docker-compose.yml file will be created at the specified path +# If -v option is not specified, the version will be set to latest +# If -v option is specified, the version will be set to the specified version # Parse command line arguments while getopts "a:f:v:" opt; do @@ -45,7 +45,7 @@ fi # Set default version if not provided if [ -z "$version" ]; then - version="latest" + version="22.04" fi # Generate docker-compose.yml content diff --git a/local-docker-env/gen-nodekey.sh b/local-docker-env/gen-nodekey.sh new file mode 100755 index 000000000000..94a18f3330bd --- /dev/null +++ b/local-docker-env/gen-nodekey.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +# Check required arguments +if [ "$#" -ne 2 ]; then + echo "Usage: $0 -a " + exit 1 +fi + +# Option parsing +while getopts "a:" opt; do + case ${opt} in + a) + NODEKEY_NUM=$OPTARG + ;; + \?) + echo "Usage: $0 -a " + exit 1 + ;; + esac +done + +# Check required arguments +if [ -z "$NODEKEY_NUM" ]; then + exit 1 +fi + +mkdir local-docker-env/nodekey + +# Create nodekeys +for ((i = 1; i <= NODEKEY_NUM; i++)); do + if [ -f "local-docker-env/nodekey/nodekey$i" ]; then + rm local-docker-env/nodekey/nodekey$i + fi + if gwemix wemix new-nodekey --out local-docker-env/nodekey/nodekey$i; then + echo "Nodekey $i created successfully" + else + echo "Failed to create nodekey $i" + exit 1 + fi +done \ No newline at end of file diff --git a/local-docker-env/init-boot.sh b/local-docker-env/init-boot.sh index 8657784d18e7..088f946055b0 100644 --- a/local-docker-env/init-boot.sh +++ b/local-docker-env/init-boot.sh @@ -4,9 +4,9 @@ chmod a+x bin/gwemix.sh bin/gwemix.sh init "" conf/config.json bin/gwemix.sh start -# gwemix 서비스가 정상적으로 시작되었는지 확인 +# Check if gwemix service has started successfully check_gwemix_started() { - local log_file="logs/log" # gwemix 로그 파일 경로 + local log_file="logs/log" local success_message="HTTP server started" local max_retries=30 local retries=0 @@ -32,7 +32,7 @@ check_gwemix_started() { fi } -# gwemix 서비스가 정상적으로 시작되었는지 확인 +# Check if gwemix service has started successfully check_gwemix_started bin/gwemix.sh init-gov "" conf/config.json keystore/account1 test diff --git a/local-docker-env/init-node.sh b/local-docker-env/init-node.sh index b88abbf43f54..45d00c10c804 100644 --- a/local-docker-env/init-node.sh +++ b/local-docker-env/init-node.sh @@ -1,6 +1,6 @@ #!/bin/bash -# gwemix 서비스 시작 +# Set the permissions for the gwemix binary chmod a+x bin/gwemix # Check if the boot node has started @@ -31,5 +31,12 @@ check_boot_node_started() { check_boot_node_started -bin/gwemix wemix download-genesis --url http://172.16.237.11:8588 --out genesis.json +bin/gwemix wemix download-genesis --url http://172.16.237.11:8588 --out /usr/local/wemix/genesis.json + +# Check if the genesis.json file has been created +if [ ! -f /usr/local/wemix/genesis.json ]; then + echo "Failed to create genesis.json file." + exit 1 +fi + bin/gwemix --datadir /usr/local/wemix --metrics --http --http.addr 0.0.0.0 --mine --http.port 8588 --ws --ws.addr 0.0.0.0 --ws.port 8598 --syncmode full --gcmode archive --port 8589 \ No newline at end of file diff --git a/local-docker-env/local-docker-git.sh b/local-docker-env/local-docker-git.sh index 6cf4e3c10e47..843cbf7f93e4 100755 --- a/local-docker-env/local-docker-git.sh +++ b/local-docker-env/local-docker-git.sh @@ -1,14 +1,15 @@ #!/bin/bash -# gwemix path를 환경변수에 추가 +# Add gwemix path to environment variables current_dir=$(pwd) -export PATH=$PATH:${current_dir}/go-wemix/build/bin +export PATH=$PATH:${current_dir}/build/bin -# 옵션 파싱 -while getopts "a:b:r:v:" opt; do +# Parse command line arguments +KEEP_NODEKEY=false +while getopts "a:b:r:v:-:" opt; do case ${opt} in a) - ACCOUNT_NUM=$OPTARG + NODE_NUM=$OPTARG ;; b) BRANCH=$OPTARG @@ -19,16 +20,28 @@ while getopts "a:b:r:v:" opt; do v) VERSION=$OPTARG ;; + -) + case "${OPTARG}" in + keep-nodekey) + KEEP_NODEKEY=true + ;; + *) + echo "Usage: $0 -a -b -r -v [--keep-nodekey]" + exit 1 + ;; + esac + ;; \?) - echo "Usage: $0 -a -b -r " + echo "Usage: $0 -a -b -r -v [--keep-nodekey]" exit 1 ;; esac done +shift $((OPTIND -1)) -# 필수 인수 확인 -if [ -z "$ACCOUNT_NUM" ] || [ -z "$BRANCH" ] || [ -z "$REPO" ]; then - echo "Missing required arguments. Usage: $0 -a -b -r " +# Check required arguments +if [ -z "$NODE_NUM" ] || [ -z "$BRANCH" ] || [ -z "$REPO" ]; then + echo "Missing required arguments. Usage: $0 -a -b -r " exit 1 fi @@ -37,22 +50,40 @@ if [ -z "$VERSION" ]; then VERSION="latest" fi -# key-gen.sh 실행 -chmod +x local-docker-env/key-gen.sh -./local-docker-env/key-gen.sh -a "$ACCOUNT_NUM" || { echo "Failed to execute key-gen.sh."; exit 1; } +# Stop the currently running docker-compose, proceed if there is no running docker-compose +docker compose -f docker-compose.yml down || { echo "Failed to stop docker-compose."; } + +# Execute gen-account.sh +chmod +x local-docker-env/gen-account.sh +./local-docker-env/gen-account.sh -a "$NODE_NUM" || { echo "Failed to execute gen-account.sh."; exit 1; } + +# If the keep-nodekey option is not set, execute gen-nodekey.sh. If it is set, check if nodekey1 to nodekey exist. +if [ "$KEEP_NODEKEY" = false ]; then + chmod +x local-docker-env/gen-nodekey.sh + ./local-docker-env/gen-nodekey.sh -a "$NODE_NUM" || { echo "Failed to execute gen-nodekey.sh."; exit 1; } + echo "Nodekey generated successfully." +else + for ((i = 1; i <= NODE_NUM; i++)); do + if [ ! -f "local-docker-env/nodekey/nodekey$i" ]; then + echo "Nodekey $i does not exist" + exit 1 + fi + done + echo "Nodekey exists." +fi -# config-gen.sh 실행 -chmod +x local-docker-env/config-gen.sh -./local-docker-env/config-gen.sh -a "$ACCOUNT_NUM" -f local-docker-env/config.json || { echo "Failed to execute config-gen.sh."; exit 1; } +# Execute gen-config.sh +chmod +x local-docker-env/gen-config.sh +./local-docker-env/gen-config.sh -a "$NODE_NUM" -f local-docker-env/config.json || { echo "Failed to execute gen-config.sh."; exit 1; } -# BRANCH와 REPO 정보를 입력으로 받아 docker-compose-gen.sh 실행 -chmod +x local-docker-env/docker-compose-gen-git.sh -./local-docker-env/docker-compose-gen-git.sh -a "$ACCOUNT_NUM" -b "$BRANCH" -r "$REPO" -v "$VERSION" || { echo "Failed to execute docker-compose-gen-git.sh."; exit 1; } +# Execute gen-docker-compose-git.sh with BRANCH and REPO information as input +chmod +x local-docker-env/gen-docker-compose-git.sh +./local-docker-env/gen-docker-compose-git.sh -a "$NODE_NUM" -b "$BRANCH" -r "$REPO" -f docker-compose.yml -v "$VERSION" || { echo "Failed to execute gen-docker-compose-git.sh."; exit 1; } -# Dockerfile.boot.git 및 Dockerfile.node.git 파일 복사 +# Copy Dockerfile.boot.git and Dockerfile.node.git files cp local-docker-env/Dockerfile.boot.git ./ || { echo "Failed to copy Dockerfile.boot.git."; exit 1; } cp local-docker-env/Dockerfile.node.git ./ || { echo "Failed to copy Dockerfile.node.git."; exit 1; } -# docker-compose.yml 파일을 이용해 docker-compose build 및 up 실행 +# Execute docker-compose build and up using the generated docker-compose.yml docker compose -f docker-compose.yml build --no-cache || { echo "Failed to build docker-compose."; exit 1; } docker compose -f docker-compose.yml up -d || { echo "Failed to start docker-compose."; exit 1; } \ No newline at end of file diff --git a/local-docker-env/local-docker.sh b/local-docker-env/local-docker.sh index cc57ae26d2e0..4ea4ab3fbe76 100755 --- a/local-docker-env/local-docker.sh +++ b/local-docker-env/local-docker.sh @@ -1,28 +1,41 @@ #!/bin/bash -# gwemix path를 환경변수에 추가 +# Add gwemix path to environment variables current_dir=$(pwd) -export PATH=$PATH:${current_dir}/go-wemix/build/bin +export PATH=$PATH:${current_dir}/build/bin -# 옵션 파싱 -while getopts "a:v:" opt; do +# Parse command line arguments +KEEP_NODEKEY=false +while getopts "a:v:-:" opt; do case ${opt} in a) - ACCOUNT_NUM=$OPTARG + NODE_NUM=$OPTARG ;; v) VERSION=$OPTARG ;; + -) + case "${OPTARG}" in + keep-nodekey) + KEEP_NODEKEY=true + ;; + *) + echo "Usage: $0 -a -v [--keep-nodekey]" + exit 1 + ;; + esac + ;; \?) - echo "Usage: $0 -a " + echo "Usage: $0 -a -v [--keep-nodekey]" exit 1 ;; esac done +shift $((OPTIND -1)) -# 필수 인수 확인 -if [ -z "$ACCOUNT_NUM" ]; then - echo "Account number is required. Usage: $0 -a " +# Check required arguments +if [ -z "$NODE_NUM" ]; then + echo "Node number is required. Usage: $0 -a " exit 1 fi @@ -31,22 +44,40 @@ if [ -z "$VERSION" ]; then VERSION="latest" fi -# key-gen.sh 실행 -chmod +x local-docker-env/key-gen.sh -./local-docker-env/key-gen.sh -a "$ACCOUNT_NUM" || { echo "Failed to execute key-gen.sh."; exit 1; } +# Stop the currently running docker-compose, proceed if there is no running docker-compose +docker compose -f docker-compose.yml down || { echo "Failed to stop docker-compose."; } + +# Execute gen-account.sh +chmod +x local-docker-env/gen-account.sh +./local-docker-env/gen-account.sh -a "$NODE_NUM" || { echo "Failed to execute gen-account.sh."; exit 1; } + +# If the keep-nodekey option is not set, execute gen-nodekey.sh. If it is set, check if nodekey1 to nodekey exist. +if [ "$KEEP_NODEKEY" = false ]; then + chmod +x local-docker-env/gen-nodekey.sh + ./local-docker-env/gen-nodekey.sh -a "$NODE_NUM" || { echo "Failed to execute gen-nodekey.sh."; exit 1; } + echo "Nodekey generated successfully." +else + for ((i = 1; i <= NODE_NUM; i++)); do + if [ ! -f "local-docker-env/nodekey/nodekey$i" ]; then + echo "Nodekey $i does not exist" + exit 1 + fi + done + echo "Nodekey exists." +fi -# config-gen.sh 실행 -chmod +x local-docker-env/config-gen.sh -./local-docker-env/config-gen.sh -a "$ACCOUNT_NUM" -f local-docker-env/config.json || { echo "Failed to execute config-gen.sh."; exit 1; } +# Execute gen-config.sh +chmod +x local-docker-env/gen-config.sh +./local-docker-env/gen-config.sh -a "$NODE_NUM" -f local-docker-env/config.json || { echo "Failed to execute gen-config.sh."; exit 1; } -# docker-compose-gen.sh 실행 -chmod +x local-docker-env/docker-compose-gen.sh -./local-docker-env/docker-compose-gen.sh -a "$ACCOUNT_NUM" -v "$VERSION" || { echo "Failed to execute docker-compose-gen.sh."; exit 1; } +# Execute gen-docker-compose.sh +chmod +x local-docker-env/gen-docker-compose.sh +./local-docker-env/gen-docker-compose.sh -a "$NODE_NUM" -f docker-compose.yml -v "$VERSION" || { echo "Failed to execute gen-docker-compose.sh."; exit 1; } -# Dockerfile.boot 및 Dockerfile.node 파일 복사 +# Copy Dockerfile.boot and Dockerfile.node to the current directory cp local-docker-env/Dockerfile.boot ./ || { echo "Failed to copy Dockerfile.boot."; exit 1; } cp local-docker-env/Dockerfile.node ./ || { echo "Failed to copy Dockerfile.node."; exit 1; } -# docker-compose.yml 파일을 이용해 docker-compose build 및 up 실행 +# Execute docker-compose build and up using the generated docker-compose.yml docker compose -f docker-compose.yml build --no-cache || { echo "Failed to build docker-compose."; exit 1; } docker compose -f docker-compose.yml up -d || { echo "Failed to start docker-compose."; exit 1; } \ No newline at end of file diff --git a/local-docker-env/nodekey/nodekey1 b/local-docker-env/nodekey/nodekey1 new file mode 100644 index 000000000000..3d8fbf191b9d --- /dev/null +++ b/local-docker-env/nodekey/nodekey1 @@ -0,0 +1 @@ +87f0d2ae17635165d1f6c6ec53e07858ad9553947b3dab781b6eb15a13c9a9dc \ No newline at end of file diff --git a/local-docker-env/nodekey/nodekey2 b/local-docker-env/nodekey/nodekey2 new file mode 100644 index 000000000000..1f45d1dfdf79 --- /dev/null +++ b/local-docker-env/nodekey/nodekey2 @@ -0,0 +1 @@ +3855f9fa8ed87ef0b519500ee5914178897022a7b27b027b629ab19ae9777682 \ No newline at end of file diff --git a/local-docker-env/nodekey/nodekey3 b/local-docker-env/nodekey/nodekey3 new file mode 100644 index 000000000000..0e0035d802b5 --- /dev/null +++ b/local-docker-env/nodekey/nodekey3 @@ -0,0 +1 @@ +4ddc0db5580b3da257107fd5a4caf62f8e5dd16e71be20d4ee829098a5cb167a \ No newline at end of file diff --git a/local-docker-env/nodekey/nodekey4 b/local-docker-env/nodekey/nodekey4 new file mode 100644 index 000000000000..69cfe67dacb1 --- /dev/null +++ b/local-docker-env/nodekey/nodekey4 @@ -0,0 +1 @@ +c691145c915daa12bc80bed77575ba9b9f604fbe6366620a7762c9fcb0ad443c \ No newline at end of file diff --git a/local-docker-env/set-nodekey.sh b/local-docker-env/set-nodekey.sh index 34df658888bb..f3e1fa8cf284 100755 --- a/local-docker-env/set-nodekey.sh +++ b/local-docker-env/set-nodekey.sh @@ -1,12 +1,12 @@ #!/bin/bash -# 필수 인수 확인 +# Check required arguments if [ "$#" -ne 2 ]; then echo "Usage: $0 -a " exit 1 fi -# 옵션 파싱 +# Option parsing while getopts "a:" opt; do case ${opt} in a) @@ -19,7 +19,7 @@ while getopts "a:" opt; do esac done -# 필수 인수 확인 +# Check required arguments if [ -z "$ACCOUNT_NUM" ]; then exit 1 fi diff --git a/miner/worker.go b/miner/worker.go index 364bf034970f..bd49dd676304 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -1595,9 +1595,14 @@ func (w *worker) commitWork(interrupt *int32, noempty bool, timestamp int64) { } else { return } + parent := w.chain.CurrentBlock() + height := new(big.Int).Add(parent.Number(), common.Big1) + // Wemix: Skip blocks after MontBlanc hard fork + if w.chain.Config().IsMontBlanc(height) { + log.Warn("go-wemix skips mining due to MontBlanc hard fork", "height", height, "parent-hash", parent.Hash()) + return + } if !wemixminer.IsPoW() { - parent := w.chain.CurrentBlock() - height := new(big.Int).Add(parent.Number(), common.Big1) ok, err := wemixminer.AcquireMiningToken(height, parent.Hash()) if ok { log.Debug("Mining Token, successful", "height", height, "parent-hash", parent.Hash()) diff --git a/params/config.go b/params/config.go index c86356c663ad..c7dfdb78617b 100644 --- a/params/config.go +++ b/params/config.go @@ -321,16 +321,16 @@ var ( // // This configuration is intentionally not using keyed fields to force anyone // adding flags to the config to also have to set these fields. - AllEthashProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, nil, nil, nil, new(EthashConfig), nil, nil} + AllEthashProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, nil, nil, nil, nil, new(EthashConfig), nil, nil} // AllCliqueProtocolChanges contains every protocol change (EIPs) introduced // and accepted by the Ethereum core developers into the Clique consensus. // // This configuration is intentionally not using keyed fields to force anyone // adding flags to the config to also have to set these fields. - AllCliqueProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, nil, nil, nil, nil, nil, &CliqueConfig{Period: 0, Epoch: 30000}, nil} + AllCliqueProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, nil, nil, nil, nil, nil, nil, &CliqueConfig{Period: 0, Epoch: 30000}, nil} - TestChainConfig = &ChainConfig{big.NewInt(1), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, nil, nil, nil, new(EthashConfig), nil, nil} + TestChainConfig = &ChainConfig{big.NewInt(1), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, nil, nil, nil, nil, new(EthashConfig), nil, nil} TestRules = TestChainConfig.Rules(new(big.Int), false) ) @@ -414,6 +414,7 @@ type ChainConfig struct { PangyoBlock *big.Int `json:"pangyoBlock,omitempty"` // Pangyo switch block (nil = no fork, 0 = already on pangyo) ApplepieBlock *big.Int `json:"applepieBlock,omitempty"` // Applepie switch block (nil = no fork, 0 = already on applepie) BriocheBlock *big.Int `json:"briocheBlock,omitempty"` // Brioche switch block (nil = no fork, 0 = already on brioche) + MontBlancBlock *big.Int `json:"montBlancBlock,omitempty"` // MontBlanc switch block (nil = no fork, 0 = already on MontBlanc) // TerminalTotalDifficulty is the amount of total difficulty reached by // the network that triggers the consensus upgrade. @@ -509,7 +510,7 @@ func (c *ChainConfig) String() string { default: engine = "unknown" } - return fmt.Sprintf("{ChainID: %v Homestead: %v DAO: %v DAOSupport: %v EIP150: %v EIP155: %v EIP158: %v Byzantium: %v Constantinople: %v Petersburg: %v Istanbul: %v, Muir Glacier: %v, Berlin: %v, London: %v, Arrow Glacier: %v, MergeFork: %v, PangyoFork: %v, ApplepieFork: %v, BriocheFork: %v, Terminal TD: %v, BriocheConfig: %v, Engine: %v}", + return fmt.Sprintf("{ChainID: %v Homestead: %v DAO: %v DAOSupport: %v EIP150: %v EIP155: %v EIP158: %v Byzantium: %v Constantinople: %v Petersburg: %v Istanbul: %v, Muir Glacier: %v, Berlin: %v, London: %v, Arrow Glacier: %v, MergeFork: %v, PangyoFork: %v, ApplepieFork: %v, BriocheFork: %v, MontBlancFork: %v, Terminal TD: %v, BriocheConfig: %v, Engine: %v}", c.ChainID, c.HomesteadBlock, c.DAOForkBlock, @@ -529,6 +530,7 @@ func (c *ChainConfig) String() string { c.PangyoBlock, c.ApplepieBlock, c.BriocheBlock, + c.MontBlancBlock, c.TerminalTotalDifficulty, c.Brioche, engine, @@ -617,6 +619,10 @@ func (c *ChainConfig) IsBrioche(num *big.Int) bool { return isForked(c.BriocheBlock, num) } +func (c *ChainConfig) IsMontBlanc(num *big.Int) bool { + return isForked(c.MontBlancBlock, num) +} + // IsTerminalPoWBlock returns whether the given block is the last block of PoW stage. func (c *ChainConfig) IsTerminalPoWBlock(parentTotalDiff *big.Int, totalDiff *big.Int) bool { if c.TerminalTotalDifficulty == nil { @@ -675,6 +681,7 @@ func (c *ChainConfig) CheckConfigForkOrder() error { {name: "pangyoBlock", block: c.PangyoBlock, optional: true}, {name: "applepieBlock", block: c.ApplepieBlock, optional: true}, {name: "briocheBlock", block: c.BriocheBlock, optional: true}, + {name: "montBlancBlock", block: c.MontBlancBlock, optional: true}, } { if lastFork.name != "" { // Next one must be higher number @@ -759,6 +766,9 @@ func (c *ChainConfig) checkCompatible(newcfg *ChainConfig, head *big.Int) *Confi if isForkIncompatible(c.BriocheBlock, newcfg.BriocheBlock, head) { return newCompatError("Brioche fork block", c.BriocheBlock, newcfg.BriocheBlock) } + if isForkIncompatible(c.MontBlancBlock, newcfg.MontBlancBlock, head) { + return newCompatError("Mont Blanc fork block", c.MontBlancBlock, newcfg.MontBlancBlock) + } return nil } @@ -828,7 +838,7 @@ type Rules struct { IsByzantium, IsConstantinople, IsPetersburg, IsIstanbul bool IsBerlin, IsLondon bool IsMerge bool - IsPangyo, IsApplepie, IsBrioche bool + IsPangyo, IsApplepie, IsBrioche, IsMontBlanc bool } // Rules ensures c's ChainID is not nil. @@ -853,5 +863,6 @@ func (c *ChainConfig) Rules(num *big.Int, isMerge bool) Rules { IsPangyo: c.IsPangyo(num), IsApplepie: c.IsApplepie(num), IsBrioche: c.IsBrioche(num), + IsMontBlanc: c.IsMontBlanc(num), } } diff --git a/params/version.go b/params/version.go index b058883ad9e4..5b60c0e703d0 100644 --- a/params/version.go +++ b/params/version.go @@ -23,7 +23,7 @@ import ( const ( VersionMajor = 0 // Major version component of the current release VersionMinor = 10 // Minor version component of the current release - VersionPatch = 9 // Patch version component of the current release + VersionPatch = 10 // Patch version component of the current release VersionMeta = "stable" // Version metadata to append to the version string ) diff --git a/params/wemix_config.go b/params/wemix_config.go index 455782306915..6146115c33fe 100644 --- a/params/wemix_config.go +++ b/params/wemix_config.go @@ -10,7 +10,7 @@ var ( "enode://3d3608eda1b79cfb2bcb3ca930936daf29452da57e544268fa3674adc04e6e0d877a34a99f8a15fdcb942d68a4b8979cd7c04bf90382a46dc4cf2beed1617d4c@20.196.145.6:8589", "enode://d1d2f866efe5443d56a9007b5c44095a89d41f6b32414901afd94e12d6a647dc624d77a79facdee472fb14285e01e9b4fbeef1c19c42a0aa588faf15db249152@20.198.171.74:8589", "enode://c8813a968f0a344309866b717c001b6d73f9d7479bbf54b54e855304162d60b32b362863803db9b243ae31f9706dedf72740577c18d29ec0767afa88c3506f78@20.198.171.82:8589", - "enode://3468344f9521b8e54776065b0e00ee187856929e0cd9e2a52e55b49bde79d89bb59d422eb9d52f70e9fe275cc520e0a0d867775edfd9f6fb294092b58f0ebd8d@20.245.50.85:8589", + "enode://254ae9e482037ae2335a3f44db42e637176ef83d7cbcd8abc02b6ef034c6fd8b1403df0cecb55f583b8f4eaf8987db87288cd216a2fd16cbcd339ddf5c664d68@40.85.150.71:8589", "enode://0696fd60ec2ccf1330e52f495758420314c033eb7b5f19636abaa1feb0686188224d3f3707fdbdb505bc72e58ea82a56ce1e70db64b2251fcd0d6780db5d78c2@20.245.50.76:8589", } diff --git a/wemix/scripts/genesis-template.json b/wemix/scripts/genesis-template.json index 44a2860fbf5e..902ac35b785a 100644 --- a/wemix/scripts/genesis-template.json +++ b/wemix/scripts/genesis-template.json @@ -28,6 +28,8 @@ "londonBlock": 0, "muirGlacierBlock": 0, "pangyoBlock": 0, - "applepieBlock": 0 + "applepieBlock": 0, + "briocheBlock" : 0, + "montBlancBlock": 100 } }