GithubHelp home page GithubHelp logo

solo-mining-scripts's Introduction

EN | 中文

Phala Network

Phala Mining Script

Navigate

Instructions

Before Getting Started

  • BIOS Settings

    • Disable Secure Boot
    • Boot Mode must be UEFI
    • Intel© SGX Settings must be Enabled or Software Controlled

👇 More details about the hardware requirements:

Phala Wiki

Manual Installation

  • Download the Script
sudo apt update && sudo apt upgrade -y && sudo apt autoremove -y
sudo apt install wget unzip
cd ~
wget https://github.com/Phala-Network/solo-mining-scripts/archive/refs/heads/main.zip
unzip main.zip
rm -r main.zip #cleaning up the installation
  • Run the egx_enable if your SGX setting in BIOS is Software Controlled
cd solo-mining-scripts-main/tools/ #note this depends on your current directory
sudo chmod +x sgx_enable
sudo ./sgx_enable

It is now recommended to reboot you machine.

sudo reboot

Install the Phala Scripts

Go to the Phala folder

cd solo-mining-scripts-main/ #note this depends on your current directory
sudo ./phala.sh install
  • Check if Mainboard is Supported

    • Use the sudo phala install command to install all dependencies without their configuration
    sudo phala sgx-test
  • Installation mode

    • You can choose to install "Full" mode or "Prune" mode based on the size of your hard disk.
    • In “Prune” mode, after the configuration for the first time.
    sudo phala update headers
    sudo phala update snapshot
Get Logs
sudo phala logs node
sudo phala logs pruntime
sudo phala logs pherry
Check the Configuration of the Miner
sudo phala config show
Update the Script
sudo phala update script

Script Usage

Installation
sudo phala install init

Enter your information as prompted.

Miner Configuration
sudo phala config set
Start the Miner
sudo phala start
Stop the Miner
sudo phala stop
Check the Miner's Status
sudo phala status

Head back to top ☝️ to navigate to other sections.

Phala & Docker 🐳

Start Docker Separately
sudo phala start node
sudo phala start pruntime
sudo phala start pherry
Stop Docker Separately
sudo phala stop node
sudo phala stop pruntime
sudo phala stop pherry
Update Phala Docker Containers
Update Phala Dockers Without Clean Data
sudo phala update
Update Phala Docker Images with Clean Data
sudo phala update clean

🙋‍♀️🙋‍♂️

Troubleshooting

The community is here to help! Check for existing posts on our forum if you are stuck. In rare circumstances, your issue may be new; feel free to post it then so that we can help. For us to be able to help you, please read the investigating the issue first, so you know how and where to get your logs from prior to posting.

General

Most symptoms are solved by restarting your node. If you experience issues running your node, try stopping the node by:

sudo phala stop

And attempt a restart with

sudo phala start

If you still have issues attempt to update the script.

Head back to top ☝️ to navigate to other sections.

Investigating the Issue

Get an overview of your miner's status first.

sudo phala status

In case your node is stuck, a typical scenario would look like the following:

Phala Network

(image showing stuck node on the miner)

With the symptom in the scenario above, the right method to solve the issue would be restarting the node container only, with the commands mentioned here, and restarting the containers.

Now check the status of the node again.

If the local node block height is empty first, check if all required containers are running.

sudo docker ps

You should have three containers running as shown in this example:

Phala Network

(image showing the miner node's running docker containers)

To get the most recent logs of each container, you may execute:

docker logs <container_ID/container_name> -n 100 -f

Note that <container_ID/container_name> must be replaced with the container you wish the receive the logs from. In the example above the container_ID is 8dc34f63861e and container_name would be phala-pherry.
If you attempt to post on the phala forum and do not know where the issue lies, please post the logs of all three docker containers. Copy-paste the container logs from the terminal into the forum post.

If a container is missing, you may attempt to restart it separately with the respective commands below. Use the applicable command for your missing container:

sudo phala start node
sudo phala start pruntime
sudo phala start pherry
Peer Connectivity

Some users running nodes may find their nodes are struggling to connect to peers, which causes nodes to be dropped from the network. You can check your node connections through executing:

sudo docker logs -f phala-node

For an optimal setup, you should have between 40 and 50 peers.

If you have insufficient peers do the following:

  • Check your firewall settings
  • Ensure there are no NAT or Policy-based filters

Feel free to read NAT for more information if you are curious about the root causes. Also, do not hesitate to look for existing Phala forum posts before posing your issue if you are stuck.

Failed to install the DCAP driver

ℹ️ The most common issue is that your mainboard may not support a DCAP driver. In this case, the script cannot automatically install the isgx driver and results in the following error message.

Phala Network

(image of the terminal showing the DCAP driver error message)

In this case, prior to running sudo phala start, you need to manually install the isgx driver:

sudo phala install isgx

Khala Node Stops Synching

If the Khala Chain stops synching and is stuck at a specific block and does not continue to sync, we advise you first to restart your node. Prior to restarting your miner confirm that your node is stuck, through execututing:

docker logs phala-node -n 100 -f

Within the logs if there is an issue in synchronizing a block, it will typically look as follows:

Phala Network

If the synchronization still fails, you may try to delete the khala chain database on your miner's node.
It is located in /var/khala-dev-node/chains/khala.

Phala Network

(image showing the khala blockchain files of the miner node)

It is located in /var/khala-dev-node/chains/khala.

First, stop your node with:

sudo phala stop

To delete the khala blockchain database on your node, execute the following commands:

rm -rf /var/khala-dev-node/chains/khala

To delete the Kusama blockchain , run:

rm -rf /var/khala-dev-node/chains/polkadot

Now restart your node.

Head back to top ☝️ to navigate to other sections.

solo-mining-scripts's People

Contributors

doyleguo avatar h4x3rotab avatar hauni97 avatar jasl avatar koutakou avatar mailbad avatar nanometerzhu avatar skysummerice avatar suugee avatar wonderfulstudy avatar zozyo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

solo-mining-scripts's Issues

Logic and labelling in sudo phala status

"khala chain synchronization status" appears to not actually show khala's chain data but is instead showing kusama's. See the below example, according to this I have 8,876,624 blocks to go until khala will be sync'd "khala chain synchronization status" "Synchronizing, please wait, difference is 8876624". 8,876,624 is much larger than the entire block height of the khala chain, so it should be impossible to display a value so large as 8876624. I believe this line in the status is actually a count down of how many blocks are left until kusama is sync'd. Further, kusama chain sync status shows the difference is '0' however I know that kusama chain is not completely sync'd.

It may be worth noting in my particular case, khala-node container continuously crashes and is not running, which is likely an unrelated issue but worth mentioning.

------------------------------ Script version 0.1.6 ----------------------------
service name service status local node block height

    khala-node              exited                   / 428696
    kusama-node             exited                   / 9305320
    phala-pruntime          running
    phala-pherry            running                 khala 0 / kusama 0

    Status check                                            result

    khala chain synchronization status              Synchronizing, please wait, difference is 8876624
    kusama chain synchronization status             Synchronization completed, difference is 0
    pherry synchronizes khala chain status          Synchronization completed, difference is 
    pherry syncs kusama chain status                Synchronization completed, difference is 

Phost 启动失败

/opt/phala/scripts/start.sh: 第 186 行: [: 参数太多
Starting PHost with extra opts '-r'
bridge() exited with result: Err(SubxtRpcError(WsHandshake(Connect(Timeout))))

Bug in sudo phala start - endless loop

When I run sudo phala start I get an endless loop that says the script has been automatically upgraded.

$ sudo phala start
----------The local script version is too low and has been automatically upgraded. Please execute the command again!----------
$ sudo phala start
----------The local script version is too low and has been automatically upgraded. Please execute the command again!----------
$ sudo phala start
----------The local script version is too low and has been automatically upgraded. Please execute the command again!----------

无法获取gas账户余额

config.sh和status.sh里面的 node console.js ..... 2>&1 是不是本意应该是 2>/dev/null
不然错误信息也赋值到$balance里面了

ws-endpoint in para branch should be wss://para2-api.phala.network/ws in status.sh

command "sudo phala status" returns gas account balance is 0

use "wss://para2-api.phala.network/ws" as the --substrate-ws-endpoint parameter in status.sh can get correct balance:

the tested command:
$ node /opt/phala/console.js --substrate-ws-endpoint "wss://khala.api.onfinality.io/public-ws" chain free-balance 43cAJWN2gCu8ds5bJgq3nFuJhBAbJKMMgDXr8fPuFq46Q7YF
2021-09-20 06:37:41 API-WS: disconnected from wss://khala.api.onfinality.io/public-ws: 1006:: connection failed
2021-09-20 06:37:44 API-WS: disconnected from wss://khala.api.onfinality.io/public-ws: 1006:: connection failed
2021-09-20 06:37:48 API-WS: disconnected from wss://khala.api.onfinality.io/public-ws: 1006:: connection failed
2021-09-20 06:37:51 API-WS: disconnected from wss://khala.api.onfinality.io/public-ws: 1006:: connection failed
2021-09-20 06:37:58 REGISTRY: Unknown signed extensions CheckMqSequence found, treating them as no-effect
2021-09-20 06:37:58 API/INIT: RPC methods not decorated: pha_getMqNextSequence, pha_getStorageChanges
0
$ node /opt/phala/console.js --substrate-ws-endpoint "wss://para2-api.phala.network/ws" chain free-balance 43cAJWN2gCu8ds5bJgq3nFuJhBAbJKMMgDXr8fPuFq46Q7YF
2021-09-20 06:39:13 REGISTRY: Unknown signed extensions CheckMqSequence found, treating them as no-effect
2021-09-20 06:39:13 API/INIT: RPC methods not decorated: pha_getMqNextSequence, pha_getStorageChanges
99999859263693441

Please check is there other codes should be modified.

Networking or low-level protocol error:

[2021-06-28T18:49:28Z INFO phost] bridge() exited with result: Err(Rpc error: Networking or low-level protocol error: Couldn't find any IP address for this hostname

Caused by:
    0: Networking or low-level protocol error: Couldn't find any IP address for this hostname
    1: Couldn't find any IP address for this hostname)

root@phatest:~/solo-mining-scripts-main# lsa

Command 'lsa' not found, but there are 17 similar ones.

'sudo phala sgx-test' now results in 'driver not found' error

'sudo phala sgx-test' used to work, however now it appears to uninstall then re-install the driver and then results in an error. I've found other users with the same issue.

Output below:

~# sudo phala sgx-test
----------Remove dcap/isgx driver----------

-------- Uninstall Beginning --------
Module: sgx
Version: 1.41
Kernel: 5.4.0-84-generic (x86_64)

Status: Before uninstall, this module version was ACTIVE on this kernel.

intel_sgx.ko:

  • Uninstallation
    • Deleting from: /lib/modules/5.4.0-84-generic/updates/dkms/
  • Original module
    • No original module was found for this module on this kernel.
    • Use the dkms install command to reinstall any previous module version.

depmod...

DKMS: uninstall completed.


Deleting module version: 1.41
completely from the DKMS tree.

Done.
----------Download dcap driver----------
--2021-09-18 19:50:29-- https://download.01.org/intel-sgx/latest/dcap-latest/linux/distro/ubuntu20.04-server/sgx_linux_x64_driver_1.41.bin
Resolving download.01.org (download.01.org)... 23.72.203.92, 2a02:26f0:9100:bb5::4b21, 2a02:26f0:9100:b9e::4b21
Connecting to download.01.org (download.01.org)|23.72.203.92|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 41637 (41K) [application/octet-stream]
Saving to: ‘/tmp/sgx_linux_x64_driver_1.41.bin’

/tmp/sgx_linux_x64_driver_1.41.bin 100%[=================================================================>] 40.66K --.-KB/s in 0.005s

2021-09-18 19:50:29 (7.85 MB/s) - ‘/tmp/sgx_linux_x64_driver_1.41.bin’ saved [41637/41637]

----------Give dcap driver executable permission----------
----------Installing dcap driver----------
Unpacking Intel SGX Driver ... done.
Verifying the integrity of the install package ... done.
Installing Intel SGX Driver ...
/tmp/sgx-driver-AYPK2a ~
install -d /opt/intel/sgxdriver/package
install -d /opt/intel/sgxdriver/scripts
cp -r package/* /opt/intel/sgxdriver/package
install scripts/* /opt/intel/sgxdriver/scripts
~

Creating symlink /var/lib/dkms/sgx/1.41/source ->
/usr/src/sgx-1.41

DKMS: add completed.

Kernel preparation unnecessary for this kernel. Skipping...

Building module:
cleaning build area...
'make' KDIR=/lib/modules/5.4.0-84-generic/build...
cleaning build area...

DKMS: build completed.

intel_sgx.ko:
Running module version sanity check.

  • Original module
    • No original module exists within this kernel
  • Installation
    • Installing to /lib/modules/5.4.0-84-generic/updates/dkms/

depmod...

DKMS: install completed.

You may need to run "/sbin/modprobe intel_sgx (--allow-unsupported)" or reboot system manually!

uninstall.sh script generated in "/opt/intel/sgxdriver".

----------Delete temporary files----------
----------The driver file was not found, please check the driver installation logs!----------

Feature Request: Single Command Mining Script GUI Custom Installation Link

Summary

A custom domain for example ubuntu.miner.phala.network, that forwards to the single command mining script GUI installation RAW file on the Phala GitHub solo-mining-script repository.

Currently under https://raw.githubusercontent.com/Phala-Network/solo-mining-scripts/improvement-test/gui.sh & shown in the documentation.

Basic example

Phala Network Ubuntu 21.10 Single Command Miner GUI setup [v0.10]

wget -O - https://ubuntu.miner.phala.network/gui.sh | bash

Motivation

This adds Phala's branding and looks more professional, as the installation script becomes shorter and increases user friendliness.

"sudo phala score-test <parameter>" does not work

The command "sudo phala score-test 4" returns the output of "sudo phala help" below is a snippet:

_~# sudo phala score-test 4
Usage:
phala [OPTION]...

Options:
help display help information
install install your phala node
install DCAP driver..._

Improve readme.md

  1. Use rm -rf ... instead of echo yes | rm -r ...
  2. Specify the full path in deleting script section (should we use sudo rm -rf $HOME/solo-mining-scripts-main?)
  3. Deleting the database
    • To delete Khala, just run rm -rf /var/khala-dev-node/chains/khala. No need to delete the three directories separately
    • Add: to delete Kusama blockchain ,run rm -rf /var/khala-dev-node/chains/polkadot

bug in update.sh

in function check_version()

if wget form github failed, the script will still rm files. ( whcih happens frequently in China )

in line 8, only check the version not equal, does not check if the tmp exist or not.

should check if wget success or not, if failed, retry 3 times then exit with error code.

if [ "$(cat $installdir/.env | awk -F "=" 'NR==15 {print $NF}')" != "$(cat /tmp/phala/solo-mining-scripts-main/.env | awk -F "=" 'NR==15 {print $NF}')" ]; then

`phala sgx-test` fails with `SGX_ERROR_NETWORK_FAILURE`

Hardware:
Intel i9-9900k
Asrock Z390 Phantom Gaming 6

Kernel:
5.17.7

Admitted, this is a non standard system but I installed the dependencies manually: Docker, Kernel module.

When running phala sgx-test I get the following error. It takes a few seconds before it comes back with the error after trying the remote attestation. I guess it is some network timeout. Can you disclose IP:Port it is trying to connect to. Would it make easier to debug the network traffic.

thread '<unnamed>' panicked at 'error while doing remote attestation: SGX_ERROR_NETWORK_FAILURE', src/lib.rs:448:132

The full output:

Sleep 12s
aesm_service[15]: [get_qpl_handle ../qe_logic.cpp:263] Cannot open Quote Provider Library libdcap_quoteprov.so.1 and libdcap_quoteprov.so

aesm_service[15]: The server sock is 0x563566a312c0
Detecting SGX, this may take a minute...
aesm_service[15]: Malformed request received (May be forged for attack)
aesm_service[15]: InKernel LE loaded
aesm_service[15]: InKernel LE loaded
aesm_service[15]: InKernel LE loaded
aesm_service[15]: InKernel LE loaded
aesm_service[15]: InKernel LE loaded
aesm_service[15]: InKernel LE loaded
aesm_service[15]: InKernel LE loaded
aesm_service[15]: InKernel LE loaded
✔  SGX instruction set
  ✔  CPU support
  ✔  CPU configuration
  ✔  Enclave attributes
  ✔  Enclave Page Cache
  SGX features
    ✘  SGX2  ✘  EXINFO  ✘  ENCLV  ✘  OVERSUB  ✘  KSS  
    Total EPC size: 93.5MiB
✔  Flexible launch control
  ✔  CPU support
  ? CPU configuration
  ✔  Able to launch production mode enclave
✔  SGX system software
  ✔  SGX kernel device (/dev/sgx/enclave)
  ✔  libsgx_enclave_common
  ✔  AESM service
  ✔  Able to launch enclaves
    ✔  Debug mode
    ✔  Production mode
    ✔  Production mode (Intel whitelisted)

You're all set to start running SGX programs!
Generated machine id:
[censored]

CPU Cores:
16

Encoded runtime info:
[censored]
Testing RA...
aesm_service[15]: [ADMIN]EPID Provisioning initiated
aesm_service[15]: [ADMIN]EPID Provisioning failed due to network error
aesm_service[15]: SGX EPID provisioning network failure
thread '<unnamed>' panicked at 'error while doing remote attestation: SGX_ERROR_NETWORK_FAILURE', src/lib.rs:448:132
note: Call backtrace::enable_backtrace with 'PrintFormat::Short/Full' for a backtrace.
fatal runtime error: failed to initiate panic, error 5
./start_sgx_detect.sh: line 20:    41 Illegal instruction     (core dumped) ./app
----------------------------------------------------------------------------------------------------
 [ phala_scripts_check_sgxtest ] unknown error!
----------------------------------------------------------------------------------------------------

Is the source of the sgx-test binary available somewhere?

Docker installation failure on Ubuntu 18.04

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

This fails in execution, asadd-apt-repository is not installed on all Ubuntu 18.04 by default. Instead, it has to be installed with sudo apt install software-properties-common.

Will aim to add this fix to: https://github.com/Phala-Network/solo-mining-scripts/tree/improvement-test

docker compose device logic bug report

On my ubuntu 20.04 machine, I found after installed phala scipts. the docker-compose.yaml device is set

devices:
     - /dev/sgx_enclave
     - /dev/sgx_provision

Using this configuration will not let the pruntime work correctly . I have to manually change it to below

devices:
     - /dev/sgx/enclave:/dev/sgx/enclave
     - /dev/sgx/provision:/dev/sgx/provision

I am not confirmed if it is a bug or my machine env problem

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.