Skip to content

Commit

Permalink
Sby1 (#278)
Browse files Browse the repository at this point in the history
* cancel the mdns function

* update readme and checkNetworkEnv
  • Loading branch information
AstaFrode authored Aug 5, 2024
1 parent b83b8a3 commit 0fe3d02
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 114 deletions.
122 changes: 61 additions & 61 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ If you find any system errors or you have better suggestions, please submit an i
## 📢 Announcement
**CESS test network rpc endpoints**
```
wss://testnet-rpc.cess.cloud/ws/
wss://testnet-rpc.cess.network/ws/
```
**CESS test network bootstrap node**
```
_dnsaddr.boot-miner-testnet.cess.cloud
_dnsaddr.boot-miner-testnet.cess.network
```

## 🚰 CESS test network faucet
Expand All @@ -31,37 +31,37 @@ The following commands are executed with root privileges, if the prompt `Permiss

For the Debian and ubuntu families of linux systems:

```shell
apt install git curl wget vim util-linux -y
```bash
# apt install git curl wget vim util-linux -y
```

For the Fedora, RedHat and CentOS families of linux systems:

```shell
yum install git curl wget vim util-linux -y
```bash
# yum install git curl wget vim util-linux -y
```

### Firewall configuration
By default, cess-miner uses port `4001` to listen for incoming connections, if your platform blocks these two ports by default, you may need to enable access to these port.

#### ufw
For hosts with ufw enabled (Debian, Ubuntu, etc.), you can use the ufw command to allow traffic to flow to specific ports. Use the following command to allow access to a port:
```
ufw allow 4001
```bash
# ufw allow 4001
```

#### firewall-cmd
For hosts with firewall-cmd enabled (CentOS), you can use the firewall-cmd command to allow traffic on specific ports. Use the following command to allow access to a port:
```
firewall-cmd --get-active-zones
```bash
# firewall-cmd --get-active-zones
```
This command gets the active zone(s). Now, apply port rules to the relevant zones returned above. For example if the zone is public, use
```
firewall-cmd --zone=public --add-port=4001/tcp --permanent
```bash
# firewall-cmd --zone=public --add-port=4001/tcp --permanent
```
Note that permanent makes sure the rules are persistent across firewall start, restart or reload. Finally reload the firewall for changes to take effect.
```
firewall-cmd --reload
```bash
# firewall-cmd --reload
```

#### iptables
Expand Down Expand Up @@ -103,8 +103,8 @@ If you are using the test network, Please join the [CESS discord](https://discor
## 🏗 Get the binary program
### Method one
Download the latest release of the binary application directly at:
```
wget https://github.com/CESSProject/cess-miner/releases/download/v0.7.11/bucket0.7.11.linux-amd64.tar.gz
```bash
# wget https://github.com/CESSProject/cess-miner/releases/download/v0.7.11/bucket0.7.11.linux-amd64.tar.gz
```
### Method two
Compile the binary program from the storage node source code and follow the process as follows:
Expand All @@ -113,32 +113,32 @@ Compile the binary program from the storage node source code and follow the proc
CESS-Bucket requires [Go 1.21](https://golang.org/dl/), See the [official Golang installation instructions](https://golang.org/doc/install).

Open gomod mode:
```
go env -w GO111MODULE="on"
```bash
# go env -w GO111MODULE="on"
```

Users in China can add go proxy to speed up the download:
```
go env -w GOPROXY="https://goproxy.cn,direct"
```bash
# go env -w GOPROXY="https://goproxy.cn,direct"
```

**2) clone code**

```shell
git clone https://github.com/CESSProject/cess-miner.git
```bash
# git clone https://github.com/CESSProject/cess-miner.git
```

**3) compile code**

```shell
cd cess-miner/
go build -o miner cmd/main.go
```bash
# cd cess-miner/
# go build -o miner cmd/main.go
```

**4) Grant execute permission**

```shell
chmod +x miner
```bash
# chmod +x miner
```

**5) View miner features (optional)**
Expand Down Expand Up @@ -177,37 +177,37 @@ The `miner` has many functions, you can use `./miner -h` or `./miner --help` to
The miner program has two running modes: foreground and background.

> :warning: If you are not running the `miner` program with root privileges, make sure that the user you are currently logged in to has all permissions for the workspace directory you have configured. If you are logged in as `user`, the configured directory is `/cess`, and your signature account is `cXfyomKDABfehLkvARFE854wgDJFMbsxwAJEHezRb6mfcAi2y`, execute the following command to grant permissions:
```
chown -R user:user /cess/cXfyomKDABfehLkvARFE854wgDJFMbsxwAJEHezRb6mfcAi2y/
```bash
# chown -R user:user /cess/cXfyomKDABfehLkvARFE854wgDJFMbsxwAJEHezRb6mfcAi2y/
```

### Foreground operation mode

The foreground operation mode requires the terminal window to be kept all the time, and the window cannot be closed. You can use the screen command to create a window for the miner and ensure that the window always exists.
Create and enter the miner window command:
```
screen -S miner
```bash
# screen -S miner
```
Press `ctrl + A + D` to exit the miner window without closing it.

View window list command:
```
screen -ls
```bash
# screen -ls
```
Re-enter the miner window command:
```
screen -r miner
```bash
# screen -r miner
```


**method one**

Enter the `miner run` command to run directly, and enter the information according to the prompt to complete the startup:

```
```bash
# ./miner run
>> Please enter the rpc address of the chain, multiple addresses are separated by spaces:
wss://testnet-rpc0.cess.cloud/ws/ wss://testnet-rpc1.cess.cloud/ws/ wss://testnet-rpc2.cess.cloud/ws/
wss://testnet-rpc.cess.network/ws/
>> Please enter the workspace, press enter to use / by default workspace:
/
>> Please enter your earnings account, if you are already registered and do not want to update, please press enter to skip:
Expand All @@ -222,33 +222,33 @@ cXfyomKDABfehLkvARFE854wgDJFMbsxwAJEHezRb6mfcAi2y
**method two**
```
# ./miner run --rpc wss://testnet-rpc0.cess.cloud/ws/ wss://testnet-rpc1.cess.cloud/ws/ wss://testnet-rpc2.cess.cloud/ws/ --ws / --earnings cXfyomKDABfehLkvARFE854wgDJFMbsxwAJEHezRb6mfcAi2y --port 4001 --space 2000
```bash
# ./miner run --rpc wss://testnet-rpc.cess.network/ws/ --ws / --earnings cXfyomKDABfehLkvARFE854wgDJFMbsxwAJEHezRb6mfcAi2y --port 4001 --space 2000
>> Please enter the mnemonic of the staking account:
*******************************************************************************
```
### Background operation mode
Generate configuration file:
```
./miner config
```bash
# ./miner config
OK /root/miner/conf.yaml
```
Edit the configuration file and fill in the correct information, then run:
```
nohup ./miner run -c /root/miner/conf.yaml &
```bash
# nohup ./miner run -c /root/miner/conf.yaml &
```
If the configuration file is named conf.yaml and is located in the same directory as the miner program, you can specify without -c:
```
nohup ./miner run &
```bash
# nohup ./miner run &
```
## 💡 Other commands
- stat
```shell
./miner stat --rpc wss://testnet-rpc.cess.cloud/ws/
```bash
# ./miner stat --rpc wss://testnet-rpc.cess.network/ws/
>> Please enter the mnemonic of the staking account:
*******************************************************************************
+-------------------+------------------------------------------------------+
Expand All @@ -269,24 +269,24 @@ nohup ./miner run &
```
- increase staking
```shell
./miner increase staking 1000000000000000000000 --rpc wss://testnet-rpc.cess.cloud/ws/
```bash
# ./miner increase staking 1000000000000000000000 --rpc wss://testnet-rpc.cess.network/ws/
>> Please enter the mnemonic of the staking account:
*******************************************************************************
OK 0xe098179a4a668690f28947d20083014e5a510b8907aac918e7b96efe1845e053
```
- increase space
```shell
./miner increase space 10 --rpc wss://testnet-rpc.cess.cloud/ws/
```bash
# ./miner increase space 10 --rpc wss://testnet-rpc.cess.network/ws/
>> Please enter the mnemonic of the staking account:
*******************************************************************************
OK 0xe098179a4a668690f28947d20083014e5a510b8907aac918e7b96efe1845e053
```
- update earnings
```shell
./miner update earnings cXgDBpxj2vHhR9qP8wTkZ5ZST9YMu6WznFsEAZi3SZPD4b4qw --rpc wss://testnet-rpc.cess.cloud/ws/
```bash
# ./miner update earnings cXgDBpxj2vHhR9qP8wTkZ5ZST9YMu6WznFsEAZi3SZPD4b4qw --rpc wss://testnet-rpc.cess.network/ws/
>> Please enter the mnemonic of the staking account:
*******************************************************************************
OK 0x0fa67b89d9f8ff134b45e4e507ccda00c0923d43c3b8166a2d75d3f42e5a269a
Expand All @@ -299,32 +299,32 @@ miner v0.7.11
```
- exit
```shell
./miner exit --rpc wss://testnet-rpc.cess.cloud/ws/
```bash
# ./miner exit --rpc wss://testnet-rpc.cess.network/ws/
>> Please enter the mnemonic of the staking account:
*******************************************************************************
OK 0xf6e9573ba53a90c4bbd8c3784ef97bbf74bdb1cf8c01df697310a64c2a7d4513
```
- withdraw
```shell
./miner withdraw --rpc wss://testnet-rpc.cess.cloud/ws/
```bash
# ./miner withdraw --rpc wss://testnet-rpc.cess.network/ws/
>> Please enter the mnemonic of the staking account:
*******************************************************************************
OK 0xfbcc77c072f88668a83f2dd3ea00f3ba2e5806aae8265cfba1582346d6ada3f1
```
- claim
```shell
./miner claim --rpc wss://testnet-rpc.cess.cloud/ws/
```bash
# ./miner claim --rpc wss://testnet-rpc.cess.network/ws/
>> Please enter the mnemonic of the staking account:
*******************************************************************************
OK 0x59096fd095b66665c838f89ae4f1384ab31255cdc9c80003b05b50124cfdcfee
```
- reward
```shell
./miner reward --rpc wss://testnet-rpc.cess.cloud/ws/
```bash
# ./miner reward --rpc wss://testnet-rpc.cess.network/ws/
>> Please enter the mnemonic of the staking account:
*******************************************************************************
+------------------+---------------------------+
Expand Down
28 changes: 21 additions & 7 deletions cmd/console/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -926,28 +926,42 @@ func checkNetworkEnv(cli *chain.ChainClient, netenv string) error {
chain := cli.GetNetworkEnv()
if strings.Contains(chain, configs.DevNet) {
if !strings.Contains(netenv, configs.DevNet) {
return errors.New("chain and p2p are not in the same network")
return fmt.Errorf("chain and storage are not on the same network, chain: %s storage: %s", chain, netenv)
}
} else if strings.Contains(chain, configs.TestNet) {
if !strings.Contains(netenv, configs.TestNet) {
return errors.New("chain and p2p are not in the same network")
return fmt.Errorf("chain and storage are not on the same network, chain: %s storage: %s", chain, netenv)
}
} else if strings.Contains(chain, configs.MainNet) {
if !strings.Contains(netenv, configs.MainNet) {
return errors.New("chain and p2p are not in the same network")
return fmt.Errorf("chain and storage are not on the same network, chain: %s storage: %s", chain, netenv)
}
} else {
return errors.New("unknown chain network")
return fmt.Errorf("unknown chain network: %s", chain)
}

chainVersion, err := cli.SystemVersion()
if err != nil {
return errors.New("Failed to read chain version: network connection is down")
return errors.New("failed to query the chain version: rpc connection is down")
}

if strings.Contains(chain, configs.TestNet) {
if !strings.Contains(chainVersion, configs.ChainVersion) {
return fmt.Errorf("The chain version you are using is not %s, please check your rpc service", configs.ChainVersion)
tmps := strings.Split(chainVersion, "-")
for _, v := range tmps {
if strings.Contains(v, ".") {
values := strings.Split(v, ".")
if len(values) == 3 {
if values[0] != configs.ChainVersionStr[0] || values[1] != configs.ChainVersionStr[1] {
return fmt.Errorf("chain version number is not v%d.%d, please check your rpc service", configs.ChainVersionInt[0], configs.ChainVersionInt[1])
}
versionI, err := strconv.Atoi(values[2])
if err == nil {
if versionI < configs.ChainVersionInt[2] {
return fmt.Errorf("chain version number is lower than v%d.%d.%d, please check your rpc service", configs.ChainVersionInt[0], configs.ChainVersionInt[1], configs.ChainVersionInt[2])
}
}
}
}
}
}

Expand Down
6 changes: 4 additions & 2 deletions configs/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ const (
Description = "Storage miner implementation in CESS networks"
// NameSpace is the cached namespace
NameSpaces = Name
// Chain version
ChainVersion = "0.7.7"
)

// Chain version
var ChainVersionStr = [3]string{"0", "7", "7"}
var ChainVersionInt = [3]int{0, 7, 7}

var cp *x509.CertPool

// system init
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ require (
github.com/libp2p/go-netroute v0.2.1 // indirect
github.com/libp2p/go-reuseport v0.4.0 // indirect
github.com/libp2p/go-yamux/v4 v4.0.1 // indirect
github.com/libp2p/zeroconf/v2 v2.2.0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/marten-seemann/tcp v0.0.0-20210406111302-dfbc87cc63fd // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
Expand Down
5 changes: 0 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,6 @@ github.com/libp2p/go-reuseport v0.4.0 h1:nR5KU7hD0WxXCJbmw7r2rhRYruNRl2koHw8fQsc
github.com/libp2p/go-reuseport v0.4.0/go.mod h1:ZtI03j/wO5hZVDFo2jKywN6bYKWLOy8Se6DrI2E1cLU=
github.com/libp2p/go-yamux/v4 v4.0.1 h1:FfDR4S1wj6Bw2Pqbc8Uz7pCxeRBPbwsBbEdfwiCypkQ=
github.com/libp2p/go-yamux/v4 v4.0.1/go.mod h1:NWjl8ZTLOGlozrXSOZ/HlfG++39iKNnM5wwmtQP1YB4=
github.com/libp2p/zeroconf/v2 v2.2.0 h1:Cup06Jv6u81HLhIj1KasuNM/RHHrJ8T7wOTS4+Tv53Q=
github.com/libp2p/zeroconf/v2 v2.2.0/go.mod h1:fuJqLnUwZTshS3U/bMRJ3+ow/v9oid1n0DmyYyNO1Xs=
github.com/lunixbochs/vtclean v1.0.0/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm/+2c2E2WMI=
github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
Expand All @@ -356,7 +354,6 @@ github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/microcosm-cc/bluemonday v1.0.1/go.mod h1:hsXNsILzKxV+sX77C5b8FSuKF00vh2OMYv+xgHpAMF4=
github.com/miekg/dns v1.1.41/go.mod h1:p6aan82bvRIyn+zDIv9xYNUpwa73JcSh9BKwknJysuI=
github.com/miekg/dns v1.1.43/go.mod h1:+evo5L0630/F6ca/Z9+GAqzhjGyn8/c+TBaOyfEl0V4=
github.com/miekg/dns v1.1.58 h1:ca2Hdkz+cDg/7eNF6V56jjzuZ4aCAE+DbVkILdQWG/4=
github.com/miekg/dns v1.1.58/go.mod h1:Ypv+3b/KadlvW9vJfXOTf300O4UqaHFzFCuHz+rPkBY=
github.com/mikioh/tcp v0.0.0-20190314235350-803a9b46060c h1:bzE/A84HN25pxAuk9Eej1Kz9OUelF97nAc82bDquQI8=
Expand Down Expand Up @@ -676,7 +673,6 @@ golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/net v0.0.0-20210423184538-5f58ad60dda6/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
golang.org/x/net v0.0.0-20220607020251-c690dde0001d/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
Expand Down Expand Up @@ -722,7 +718,6 @@ golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20210316164454-77fc1eacc6aa/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210426080607-c94f62235c83/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
Expand Down
2 changes: 1 addition & 1 deletion node/attestation_idle.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func attestation_idle(cli *chain.ChainClient, peernode *core.PeerNode, p *Pois,
return errors.Wrapf(err, "[ProveCommitAndAcc]")
}

if err == nil && commitProofs == nil && accProof == nil {
if commitProofs == nil && accProof == nil {
p.Prover.AccRollback(false)
return errors.New("other programs are updating the data of the prover object")
}
Expand Down
Loading

0 comments on commit 0fe3d02

Please sign in to comment.