Skip to content

Commit 1f9ff33

Browse files
authored
merge v0.10.10 to devnet (#146)
- fix: dumpgenesis for wemix (#140) - feat: implement montblanc hard fork (#137) - fix: modify pn (#144) - fix: dumpgenesis failure (#143) - test scripts with fixed nodekey (#142) - fix: version up to 0.10.10 (#145)
2 parents 9a7d5ae + 78c7491 commit 1f9ff33

28 files changed

+248
-133
lines changed

cmd/geth/chaincmd.go

+1
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ func initGenesis(ctx *cli.Context) error {
208208

209209
func dumpGenesis(ctx *cli.Context) error {
210210
// TODO(rjl493456442) support loading from the custom datadir
211+
utils.SetWemixConfig(ctx)
211212
genesis := utils.MakeGenesis(ctx)
212213
if genesis == nil {
213214
genesis = core.DefaultGenesisBlock()

cmd/geth/config.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, gethConfig) {
144144
utils.Fatalf("Failed to set account manager backends: %v", err)
145145
}
146146

147-
utils.SetWemixConfig(ctx, stack, &cfg.Eth)
147+
utils.SetWemixConfig(ctx)
148148
utils.SetEthConfig(ctx, stack, &cfg.Eth)
149149
if ctx.GlobalIsSet(utils.EthStatsURLFlag.Name) {
150150
cfg.Ethstats.URL = ctx.GlobalString(utils.EthStatsURLFlag.Name)

cmd/utils/flags.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1981,7 +1981,7 @@ func SetDNSDiscoveryDefaults(cfg *ethconfig.Config, genesis common.Hash) {
19811981
}
19821982

19831983
// SetWemixConfig applies wemix related command line flags to the config.
1984-
func SetWemixConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) {
1984+
func SetWemixConfig(ctx *cli.Context) {
19851985
if ctx.GlobalIsSet(ConsensusMethodFlag.Name) {
19861986
params.ConsensusMethod = ctx.GlobalInt(ConsensusMethodFlag.Name)
19871987
} else {

consensus/ethash/consensus.go

+4
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,10 @@ func (ethash *Ethash) verifyHeader(chain consensus.ChainHeaderReader, header, pa
319319
if err := misc.VerifyForkHashes(chain.Config(), header, uncle); err != nil {
320320
return err
321321
}
322+
// Wemix: Verify SPoA block
323+
if chain.Config().IsMontBlanc(header.Number) {
324+
return fmt.Errorf("go-wemix does not support blocks after MontBlanc hard fork")
325+
}
322326
// Wemix: Check if it's generated and signed by a registered node
323327
if !wemixminer.IsPoW() && !wemixminer.VerifyBlockSig(header.Number, header.Coinbase, header.MinerNodeId, header.Root, header.MinerNodeSig, chain.Config().IsPangyo(header.Number)) {
324328
return consensus.ErrUnauthorized

local-docker-env/Dockerfile.boot

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
ARG UBUNTU_VERSION
33

44
# Stage 1: Build stage
5-
FROM golang:1.19 as builder
5+
FROM golang:1.19 AS builder
66

77
# Set environment variables
88
ENV PATH=/usr/local/go/bin:$PATH
@@ -42,7 +42,7 @@ RUN apt-get remove -y \
4242
apt-get clean
4343

4444
# Stage 2: Runtime stage
45-
FROM ubuntu:${UBUNTU_VERSION}
45+
FROM ubuntu:${UBUNTU_VERSION:-latest}
4646

4747
# Update and upgrade the package list
4848
RUN apt-get update && \

local-docker-env/Dockerfile.boot.git

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
ARG UBUNTU_VERSION
33

44
# Stage 1: Build stage
5-
FROM golang:1.19 as builder
5+
FROM golang:1.19 AS builder
66

77
# Set environment variables
88
ENV PATH=/usr/local/go/bin:$PATH
@@ -52,7 +52,7 @@ RUN apt-get remove -y \
5252
apt-get clean
5353

5454
# Stage 2: Runtime stage
55-
FROM ubuntu:${UBUNTU_VERSION}
55+
FROM ubuntu:${UBUNTU_VERSION:-latest}
5656

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

local-docker-env/Dockerfile.node

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
ARG UBUNTU_VERSION
33

44
# Stage 1: Build stage
5-
FROM golang:1.19 as builder
5+
FROM golang:1.19 AS builder
66

77
# Set environment variables
88
ENV PATH=/usr/local/go/bin:$PATH
@@ -42,7 +42,7 @@ RUN apt-get remove -y \
4242
apt-get clean
4343

4444
# Stage 2: Runtime stage
45-
FROM ubuntu:${UBUNTU_VERSION}
45+
FROM ubuntu:${UBUNTU_VERSION:-latest}
4646

4747
# Update and upgrade the package list
4848
RUN apt-get update && \

local-docker-env/Dockerfile.node.git

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
ARG UBUNTU_VERSION
33

44
# Stage 1: Build stage
5-
FROM golang:1.19 as builder
5+
FROM golang:1.19 AS builder
66

77
# Set environment variables
88
ENV PATH=/usr/local/go/bin:$PATH
@@ -52,7 +52,7 @@ RUN apt-get remove -y \
5252
apt-get clean
5353

5454
# Stage 2: Runtime stage
55-
FROM ubuntu:${UBUNTU_VERSION}
55+
FROM ubuntu:${UBUNTU_VERSION:-latest}
5656

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

local-docker-env/README.md

+10-20
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,22 @@ This document explains how to set up a local testing environment based on the `g
1111
### local-docker.sh
1212

1313
- **Purpose**: Integrated running script for local testing based on the local repository.
14-
- **Usage**: `./local-docker-env/local-docker.sh -a <account_num> -v <ubuntu_version>(optional)`
14+
- **Usage**: `./local-docker-env/local-docker.sh -a <account_num> -v <ubuntu_version>(optional) --keep-nodekey(optional)`
1515

1616
### local-docker-git.sh
1717

1818
- **Purpose**: Integrated running script for local testing based on the Git repository.
19-
- **Usage**: `./local-docker-env/local-docker-git.sh -a <account_num> -b <branch> -r <repo> -v <ubuntu_version>(optional)`
19+
- **Usage**: `./local-docker-env/local-docker-git.sh -a <account_num> -b <branch> -r <repo> -v <ubuntu_version>(optional --keep-nodekey(optional)`
2020

21-
### key-gen.sh
21+
### gen-nodekey.sh
2222

23-
- **Purpose**: Generates an account in the `keystore` folder and creates a nodekey in the `nodekey` folder.
24-
- **Usage**: `./key-gen.sh -a <account_num>`
23+
- **Purpose**: Script for generating a nodekey for the node.
24+
- **Usage**: `./local-docker-env/gen-nodekey.sh -a <nodekey_num>`
2525

26-
### config-gen.sh
26+
### gen-account.sh
2727

28-
- **Purpose**: Generates the `config.json` file.
29-
- **Usage**: `./config-gen.sh -a <account_num> -f <output_config_file>`
30-
31-
### docker-compose-gen.sh
32-
33-
- **Purpose**: Generates the `docker-compose.yml` file based on the local repository.
34-
- **Usage**: `./docker-compose-gen.sh -a <account_num> -f <output_file_path> -v <ubuntu_version>(optional)`
35-
36-
### docker-compose-gen-git.sh
37-
38-
- **Purpose**: Generates the `docker-compose.yml` file based on the Git repository.
39-
- **Usage**: `./docker-compose-gen-git.sh -a <account_num> -f <output_file_path> -r <repo_url> -b <branch_name> -v <ubuntu_version>(optional)`
28+
- **Purpose**: Script for generating a nodekey for the node.
29+
- **Usage**: `./local-docker-env/gen-account.sh -a <account_num>`
4030

4131
### init-boot.sh
4232

@@ -66,11 +56,11 @@ This document explains how to set up a local testing environment based on the `g
6656
### Execution based on the local repository code
6757

6858
```bash
69-
./local-docker-env/local-docker.sh -a <account_num> -v <ubuntu_version>(optional)
59+
./local-docker-env/local-docker.sh -a <account_num> -v <ubuntu_version> (optional) --keep-nodekey (optional)
7060
```
7161

7262
### Execution based on the Git repository code
7363

7464
```bash
75-
./local-docker-env/local-docker-git.sh -a <account_num> -b <branch> -r <repo> -v <ubuntu_version>(optional)
65+
./local-docker-env/local-docker-git.sh -a <account_num> -b <branch> -r <repo> -v <ubuntu_version> (optional) --keep-nodekey (optional)
7666
```
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,32 @@
11
#!/bin/bash
22

3-
# 필수 인수 확인
3+
# Check required arguments
44
if [ "$#" -ne 2 ]; then
55
echo "Usage: $0 -a <account_num>"
66
exit 1
77
fi
88

9-
# 옵션 파싱
9+
# Option parsing
1010
while getopts "a:" opt; do
1111
case ${opt} in
1212
a)
1313
ACCOUNT_NUM=$OPTARG
1414
;;
1515
\?)
16-
echo "Usage: $0 -a <account_num> -f <output_config_file>"
16+
echo "Usage: $0 -a <account_num>"
1717
exit 1
1818
;;
1919
esac
2020
done
2121

22-
# 필수 인수 확인
22+
# Check required arguments
2323
if [ -z "$ACCOUNT_NUM" ]; then
2424
exit 1
2525
fi
2626

2727
mkdir local-docker-env/keystore
28-
mkdir local-docker-env/nodekey
2928

30-
# 계정 및 노드 키 생성
29+
# Create accounts
3130
for ((i = 1; i <= ACCOUNT_NUM; i++)); do
3231
if [ -f "local-docker-env/keystore/account$i" ]; then
3332
rm local-docker-env/keystore/account$i
@@ -39,14 +38,4 @@ for ((i = 1; i <= ACCOUNT_NUM; i++)); do
3938
echo "Failed to create account $i"
4039
exit 1
4140
fi
42-
43-
if [ -f "local-docker-env/nodekey/nodekey$i" ]; then
44-
rm local-docker-env/nodekey/nodekey$i
45-
fi
46-
if gwemix wemix new-nodekey --out local-docker-env/nodekey/nodekey$i; then
47-
echo "Nodekey $i created successfully"
48-
else
49-
echo "Failed to create nodekey $i"
50-
exit 1
51-
fi
5241
done

local-docker-env/config-gen.sh local-docker-env/gen-config.sh

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,39 @@
11
#!/bin/bash
22

3-
# 필수 인수 확인
3+
# Check required arguments
44
if [ "$#" -ne 4 ]; then
5-
echo "Usage: $0 -a <account_num> -f <output_config_file>"
5+
echo "Usage: $0 -a <node_num> -f <output_config_file>"
66
exit 1
77
fi
88

9-
# 옵션 파싱
9+
# Option parsing
1010
while getopts "a:f:" opt; do
1111
case ${opt} in
1212
a)
13-
ACCOUNT_NUM=$OPTARG
13+
NODE_NUM=$OPTARG
1414
;;
1515
f)
1616
OUTPUT_CONFIG_FILE=$OPTARG
1717
;;
1818
\?)
19-
echo "Usage: $0 -a <account_num> -f <output_config_file>"
19+
echo "Usage: $0 -a <node_num> -f <output_config_file>"
2020
exit 1
2121
;;
2222
esac
2323
done
2424

25-
# 필수 인수 확인
26-
if [ -z "$ACCOUNT_NUM" ] || [ -z "$OUTPUT_CONFIG_FILE" ]; then
25+
# Check required arguments
26+
if [ -z "$NODE_NUM" ] || [ -z "$OUTPUT_CONFIG_FILE" ]; then
2727
exit 1
2828
fi
2929

30-
# 초기화
30+
# Initialize
3131
echo '{"members":[], "accounts":[]}' >"$OUTPUT_CONFIG_FILE"
3232

33-
# 파일을 JSON 형식으로 로드
33+
# Load file as JSON
3434
json_content=$(cat "$OUTPUT_CONFIG_FILE")
3535

36-
# 고정된 env 값을 포함한 JSON 객체
36+
# JSON object with fixed env values
3737
ENV_JSON='{
3838
"ballotDurationMin": 86400,
3939
"ballotDurationMax": 604800,
@@ -53,8 +53,8 @@ ENV_JSON='{
5353
json_content=$(echo "$json_content" | jq --argjson env "$ENV_JSON" \
5454
'.env = $env| .extraData = "chain for local test"')
5555

56-
# JSON 구성 파일 생성
57-
for ((i = 1; i <= ACCOUNT_NUM; i++)); do
56+
# Generate JSON config file
57+
for ((i = 1; i <= NODE_NUM; i++)); do
5858
ids=$(gwemix wemix nodeid local-docker-env/nodekey/nodekey$i) || { echo "Failed to get node ID"; exit 1; }
5959
idv5=$(echo "$ids" | awk '/idv5:/ {print $2}')
6060
idv5="0x$idv5"
@@ -74,6 +74,6 @@ for ((i = 1; i <= ACCOUNT_NUM; i++)); do
7474
fi
7575
done
7676

77-
# 수정된 내용을 파일에 저장
77+
# Save modified content to file
7878
echo "$json_content" >"$OUTPUT_CONFIG_FILE"
7979
echo "Updated config saved to $OUTPUT_CONFIG_FILE"

local-docker-env/docker-compose-gen-git.sh local-docker-env/gen-docker-compose-git.sh

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#!/bin/bash
22

33
# Usage: ./gen-docker-compose.sh -a <account_num> -f <output_config_file> -r <repo_url> -b <branch_name>
4-
# -a: 계정 수
5-
# -f: 출력 파일
6-
# -r: 레포지토리 URL
7-
# -b: 브랜치 이름
8-
# -a 옵션은 필수이며, -f 옵션은 선택적
9-
# -f 옵션을 지정하지 않으면, 현재 디렉토리에 docker-compose.yml 파일을 생성
10-
# -f 옵션을 지정하면, 해당 경로에 docker-compose.yml 파일을 생성
4+
# -a: number of accounts
5+
# -f: output file
6+
# -r: repository URL
7+
# -b: branch name
8+
# -a option is mandatory, -f option is optional
9+
# If -f option is not specified, a docker-compose.yml file will be created in the current directory
10+
# If -f option is specified, a docker-compose.yml file will be created at the specified path
1111

1212
# Parse command line arguments
1313
while getopts "a:f:r:b:v:" opt; do
@@ -63,7 +63,7 @@ fi
6363

6464
# Set default version if not provided
6565
if [ -z "$version" ]; then
66-
version="latest"
66+
version="22.04"
6767
fi
6868

6969
# Generate docker-compose.yml content

local-docker-env/docker-compose-gen.sh local-docker-env/gen-docker-compose.sh

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#!/bin/bash
22

33
# Usage: ./gen-docker-compose.sh -a <account_num> -f <output_config_file>
4-
# -a: 계정 수
5-
# -f: 출력 파일
6-
# -a 옵션은 필수이며, -f, -v 옵션은 선택적
7-
# -f 옵션을 지정하지 않으면, 현재 디렉토리에 docker-compose.yml 파일을 생성
8-
# -f 옵션을 지정하면, 해당 경로에 docker-compose.yml 파일을 생성
9-
# -v 옵션을 지정하지 않으면, latest 버전으로 설정
10-
# -v 옵션을 지정하면, 해당 버전으로 설정
4+
# -a: number of accounts
5+
# -f: output file
6+
# -a option is required, -f and -v options are optional
7+
# If -f option is not specified, a docker-compose.yml file will be created in the current directory
8+
# If -f option is specified, a docker-compose.yml file will be created at the specified path
9+
# If -v option is not specified, the version will be set to latest
10+
# If -v option is specified, the version will be set to the specified version
1111

1212
# Parse command line arguments
1313
while getopts "a:f:v:" opt; do
@@ -45,7 +45,7 @@ fi
4545

4646
# Set default version if not provided
4747
if [ -z "$version" ]; then
48-
version="latest"
48+
version="22.04"
4949
fi
5050

5151
# Generate docker-compose.yml content

local-docker-env/gen-nodekey.sh

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/bash
2+
3+
# Check required arguments
4+
if [ "$#" -ne 2 ]; then
5+
echo "Usage: $0 -a <nodekey_num>"
6+
exit 1
7+
fi
8+
9+
# Option parsing
10+
while getopts "a:" opt; do
11+
case ${opt} in
12+
a)
13+
NODEKEY_NUM=$OPTARG
14+
;;
15+
\?)
16+
echo "Usage: $0 -a <nodekey_num>"
17+
exit 1
18+
;;
19+
esac
20+
done
21+
22+
# Check required arguments
23+
if [ -z "$NODEKEY_NUM" ]; then
24+
exit 1
25+
fi
26+
27+
mkdir local-docker-env/nodekey
28+
29+
# Create nodekeys
30+
for ((i = 1; i <= NODEKEY_NUM; i++)); do
31+
if [ -f "local-docker-env/nodekey/nodekey$i" ]; then
32+
rm local-docker-env/nodekey/nodekey$i
33+
fi
34+
if gwemix wemix new-nodekey --out local-docker-env/nodekey/nodekey$i; then
35+
echo "Nodekey $i created successfully"
36+
else
37+
echo "Failed to create nodekey $i"
38+
exit 1
39+
fi
40+
done

0 commit comments

Comments
 (0)