Hexa's Blog

Công thức tính số Alephium (ALPH) có để đào solo trong ngày

06/01/2022 Mining Rig

Trước khi đi vào công thức chi tiết, ta cần hiểu là trong một ngày số lượng block được đào tối đa là 21,600 blocks, hiện tại, khi đào mỗi blocks, miner được thưởng là 3.2 ALPH.

[1] Công thức
[1] Công thức

Như vậy giả sử như số hashrate của mình là 16 GH/s và tổng hashrate của network là 14 TH/s (14,000GH/s). Sau mỗi 24 giờ, miner sẽ nhận được xấp xỉ 79 ALPH.

[2] Ví dụ
[2] Ví dụ

ASDF, Dependencies Installation for Erlang

26/12/2021 Linux

This script should be run before asdf erlang installation.

#!/usr/bin/zsh
sudo yum groupinstall -y 'Development Tools' 'C Development Tools and Libraries';
sudo yum install -y autoconf;
sudo yum install -y ncurses-devel;
sudo yum install -y wxGTK3-devel wxBase3;
sudo yum install -y openssl-devel;
sudo yum install -y java-1.8.0-openjdk-devel;
sudo yum install -y libiodbc unixODBC-devel.x86_64 erlang-odbc.x86_64;
sudo yum install -y libxslt fop;

After executing the script above, you can run asdf install erlang YOUR_ERLANG_VERSION without a missing erlang features.

[1] Example, asdf install erlang 22.3
[1] Example, asdf install erlang 22.3

Cách khởi động nguồn máy tính tự động mỗi khi có điện?

18/12/2021 Mining Rig

Bài viết này tập trung giải quyết vấn đề khởi động máy tính tự động khi có điện dành cho bo mạch chủ không có cổng nhận jack 24-pin cấp điện từ nguồn (PSU), điện được lấy từ các jack 6 pin. Những bo mạch chủ này không hiếm gặp trên các dàn đào tiền mã hóa. Trên những bo mạch chủ này, không thể cài đặt chế độ tự khởi động trên BIOS được mà bạn sẽ cần chơi chiêu trên jack 24-pin.

Không dài dòng nữa, tất cả những gì bạn cần làm là chú ý đến dây 24-pin xuất ra từ bộ nguồn máy tính (PSU).

[1] Sơ đồ jack 24-pin từ PSU.
[1] Sơ đồ jack 24-pin từ PSU.

Hai cổng duy nhất cần chú ý đó là cổng số 1617, bạn sẽ cần phải làm chúng nối tiếp nhau. Lưu ý nhìn cái ngàm ngang nó nắm ở đâu nhé, cắm nhầm là căng thẳng đó. Trên hình bạn sẽ thấy cái ngàm ngang nằm ở vị trí cổng số 1819. Một lần nữa, chú ý đừng có nhầm, bạn mà cắn nhầm sang cổng số 45 là toang đó nhé, 5 volt chạy thẳng vào ground. Cực mạnh.

Anh em thầy thợ có rất nhiều cách thú vị. Đôi khi là đấu dây trực tiếp 2 cổng này, hoặc xịn xò hơn thì sẽ dùng một cái chấu chữ U để kết nối.

Dưới đây là hình ảnh ví dụ.

[2] Hình ảnh thực tế.
[2] Hình ảnh thực tế.

Trích Dẫn:

How to make executable jar with Gradle?

16/12/2021 Linux

Gradle is a build automation tool for multi-language software development. It controls the development process in the tasks of compilation and packaging to testing, deployment, and publishing. Supported languages include Java (as well as Kotlin, Groovy, Scala), C/C++, and JavaScript. The other, if not the major function of Gradle is to collect statistical data about the usage of software libraries around the globe.

In this post, I would like to introduce a solution to create an executable jar with Gradle. All modification related to a file named build.gradle. This file located at /project-root/app/build.gradle. By default, this file will be generated with Gradle init task.

There are three part concerned:

  • Add a plugin named application to plugins block.
plugins {
    // Apply the application plugin to add support for building a CLI application in Java.
    id 'application'
}
  • Define mainClass in application block.
application {
    // Define the main class for the application.
    mainClass = 'JekyllPostGenerator.App'              # MODIFY IT
}
  • Define jar block.
jar {
    archiveBaseName = 'jekyll-post-generator'          # MODIFY IT
    archiveVersion =  '2.0.0'                          # MODIFY IT
    manifest {
        attributes(
               'Main-Class': 'JekyllPostGenerator.App' # MODIFY IT
        )
    }
}

Last but not least, you need to run gradle task named jar to created an executable jar file which would be created in /root-project/app/build/libs. Regarding above configuration, my executable file will be jekyll-post-generator-2.0.0.jar. This file now can be executed with java -jar jekyll-post-generator-2.0.0.jar. And this is a command to create jar file.


# In the project-root
./gradlew jar

[1] `gradlew jar` task output example.
[1] `gradlew jar` task output example.

How to install VGA - GTX 1060 on Fedora with Secure Boot enabled?

15/12/2021 Linux

In this post, I would like to introduce solution to install VGA drivers for 1060 on Fedora with enabled SECURE BOOT.

Step 1: Determine vga installed on the motherboard.

On terminal, use the following command to see avaialble installed VGA.

lspci |grep -E "VGA|3D"

Example output:

02:00.0 VGA compatible controller: NVIDIA Corporation GP106 [GeForce GTX 1060 6GB] (rev a1)
04:00.0 VGA compatible controller: ASPEED Technology, Inc. ASPEED Graphics Family (rev 30)

Step 2: Download nvidia driver from Nvidia Official Website

[1] NVIDIA Driver Downloads
[1] NVIDIA Driver Downloads

In this post, I would like to pick the latest stable version 510.68.02 which was released on April 26, 2022. After your downloading finished, remember to make the file executable with chmod +x NVIDIA-Linux-x86_64-510.68.02.run, and copy it to $HOME/Software/VGA-1060-key, you will need to execute this file each time your update your kernels.

mkdir -p $HOME/Software/VGA-1060-key;
cd $HOME/Software/VGA-1060-key;
wget https://us.download.nvidia.com/XFree86/Linux-x86_64/470.94/NVIDIA-Linux-x86_64-470.94.run;
chmod +x NVIDIA-Linux-x86_64-470.94.run;

Step 3: Generate new pair private-key and public-key

mkdir -p $HOME/Software/VGA-1060-key/key;
cd $HOME/Software/VGA-1060-key/key;
openssl req -new -x509 -newkey rsa:2048 -keyout vga-1060.key -outform DER -out vga-1060.der -nodes -days 365000 -subj "/CN=Graphics Drivers";

Your directory tree should look like:

[2] Directory Tree
[2] Directory Tree

Step 4: Enroll new public key with mokutil

You need to run this command to import your new public key with mokutil, this program will ask you a password for enrolling, which then be asked in the next reboot.

sudo mokutil --import $HOME/Software/VGA-1060-key/key/vga-1060.der;

Step 5: Make install.sh in VGA-1060-key directory

This is install.sh content:

#!/bin/bash
./NVIDIA-Linux-x86_64-510.68.02.run --module-signing-secret-key=/home/YOUR_USERNAME/Software/VGA-1060-key/key/vga-1060.key \
                                    --module-signing-public-key=/home/YOUR_USERNAME/Software/VGA-1060-key/key/vga-1060.der

Each time you update your kernel, you need to go boots OS with level 3 and run this script install.sh.

[3] Directory Tree
[3] Directory Tree

Step 5: Install package dependencies & update OS

This step ensure you got the lastest kernel & all dependent packages.

sudo dnf install kernel-devel kernel-headers gcc make dkms acpid libglvnd-glx libglvnd-opengl libglvnd-devel pkgconfig;
sudo dnf update;

Step 6: Disable nouveau

  • Create or edit /etc/modprobe.d/blacklist-nouveau.conf
sudo echo "blacklist nouveau" >> /etc/modprobe.d/blacklist-nouveau.conf
  • Edit /etc/default/grub Append following flag to the end of GRUB_CMDLINE_LINUX
    • rd.driver.blacklist=nouveau
    • modprobe.blacklist=nouveau
    • nvidia-drm.modeset=1

For example:

[4] /etc/default/grub
[4] /etc/default/grub

Step 7: Update grub2 config & generate new initramfs

grub2-mkconfig -o /boot/grub2/grub.cfg;

## Backup old initramfs nouveau image ##
mv /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r)-with-nouveau.img;

## Generate new initramfs image ##
dracut /boot/initramfs-$(uname -r).img $(uname -r);

Step 8: Boots OS on level 3 and execute the install.sh

Boots OS on level 3 and reboot

sudo systemctl set-default multi-user.target;
sudo shutdown -r now;

After login, go to VGA-1060-key directory and execute install.sh. At this step, just keep accepting and the driver will be installed.

cd /home/nguyenvinhlinh/Software/VGA-1060-key;
sudo ./install.sh;

After installing vga driver, you will need reboot OS on level 5 - graphical

systemctl set-default graphical.target;
shutdown -r now;

Next time, if you update your kernel, you can run this step (Step 8) again, it should be fine. In addition, you should encrypt your private-key with gpg, it’s not a good practice leave it unencrypted. You can check this guide Mã hóa và giải mã file trên linux sử dụng GPG

Reference

PhoenixMiner - config.txt Template

07/12/2021 Mining Rig

# PhoenixMiner configuration file config.txt

-pool   asia1.ethermine.org:4444
-pool2  asia2.ethermine.org:4444
-wal    miner_address_here
-worker huyen-vu

Personal Note: Installing a Monero full node

I. Monero Node Config - monerod.conf

# Data directory (blockchain db and indices)
data-dir=/mnt/disk_2/CryptoCurrency/Monero  # Remember to create the monero user first

# Log file
log-file=/mnt/disk_2/CryptoCurrency/Monero/log/monerod.log
max-log-file-size=0            # Prevent monerod from managing the log files; we want logrotate to take care of that
log-level=0

# P2P full node
p2p-bind-ip=0.0.0.0            # Bind to all interfaces (the default)
p2p-bind-port=18080            # Bind to default port

add-peer=nodes.hashvault.pro:18080

# RPC Restricted IP/PORT
rpc-restricted-bind-ip=0.0.0.0
rpc-restricted-bind-port=18081

# RPC Full Permission, local access only
rpc-bind-ip=127.0.0.1          # Bind to all interfaces
rpc-bind-port=18084            # Bind on default port

confirm-external-bind=1        # Open node (confirm)
no-igd=1                       # Disable UPnP port mapping

zmq-pub=tcp://127.0.0.1:18083

# Slow but reliable db writes
db-sync-mode=safe:sync
block-sync-size=10
prep-blocks-threads=28

# Emergency checkpoints set by MoneroPulse operators will be enforced to workaround potential consensus bugs
# Check https://monerodocs.org/infrastructure/monero-pulse/ for explanation and trade-offs
enforce-dns-checkpointing=1

out-peers=128              # This will enable much faster sync and tx awareness; the default 8 is suboptimal nowadays
in-peers=128             # The default is unlimited; we prefer to put a cap on this

limit-rate-up=1048576     # 1048576 kB/s == 1GB/s; a raise from default 2048 kB/s; contribute more to p2p network
limit-rate-down=1048576   # 1048576 kB/s == 1GB/s; a raise from default 8192 kB/s; allow for faster initial sync

II. Systemctl service - /etc/systemd/system/monero.service

[Unit]
Description=Monero Full Node
After=network.target  mnt-disk_2.mount

[Service]
WorkingDirectory=/opt/monero-x86_64-linux-gnu-v0.18.3.1
ExecStart=/opt/monero-x86_64-linux-gnu-v0.18.3.1/monerod --config-file /opt/monero-x86_64-linux-gnu-v0.18.3.1/monerod.conf --non-interactive
User=nguyenvinhlinh
RemainAfterExit=yes
Restart=on-failure
RestartSec=10
TimeoutStopSec=infinity

[Install]
WantedBy=multi-user.target

III. Firewall-cmd service - /etc/firewalld/services/monero.xml

<?xml version="1.0" encoding="utf-8"?>
<service>
  <short>Monero node</short>
  <description>
    This option allows Monero node to use tcp port:
    - 18080: p2p network
    - 18081: JSON-RPC server
  </description>
  <port protocol="tcp" port="18080"/>
  <port protocol="tcp" port="18081"/>
</service>

Personal Note: Installing an Alephium full node

I. Alephium node config - $ALEPHIUM_HOME/user.conf

alephium.network.external-address="x.x.x.x:9973"
alephium.api.network-interface = "0.0.0.0"
alephium.mining.api-interface="0.0.0.0"

alephium.mining.miner-addresses=[
 "miner_address_1",
 "miner_address_2",
 "miner_address_3",
 "miner_address_4",
]

II. Systemctl EnvironmentFile - /opt/alephium/alephium.env

ALEPHIUM_HOME=/mnt/CaHeoNas/disk_3/Alephium

III. Systemctl service - /etc/systemd/system/alephium.service

[Unit]
Description=Alphelium Full Node
After=network.target mnt-CaHeoNas-disk_3.mount

[Service]
WorkingDirectory=/opt/alephium
EnvironmentFile=/opt/alephium/alephium.env
ExecStart=java -jar -Xms512m -Xmx1028m alephium-1.0.0.jar
User=nguyenvinhlinh
RemainAfterExit=yes
Restart=on-failure
RestartSec=10

[Install]
WantedBy=multi-user.target

IV. Firewall-cmd service - /etc/firewalld/services/alephium.xml

Port List:

  • 9973: p2p
  • 10973: miner
  • 12973: api (danger to expose to the internet.)
<?xml version="1.0" encoding="utf-8"?>
<service>
  <short>Alephium node</short>
  <description>
    This option allows Alephium node to use tcp port 9973, 10973
  </description>
  <port protocol="tcp" port="9973"/>
  <port protocol="tcp" port="10973"/>
</service>

IV. Balance checking script

All Credit goes this guy Mark Rahmani (diomark#8272) https://www.facebook.com/diomark/

#!/bin/zsh

#first need to unlock wallet. not putting password in here

#check wallet
curlResult=`curl -X 'GET'   'http://127.0.0.1:12973/wallets/MINER_WALLET_NAME/balances'   -H 'accept: application/json' 2>/dev/null | json_pp | grep totalBalanceHint| cut -f1 -d","`
lastdate=`date +%s`


if echo $curlResult | grep -q ALPH; then
  datestr=`date +"%x %R"`
  echo -n "$datestr "
  echo Wallet unlocked - $curlResult;
else
  echo Please unlock wallet first
  exit
fi

while true; do
 oldResult=$curlResult

 datestr=`date +"%x %R"`; echo -n "."; curlResult=`curl -X 'GET'   'http://127.0.0.1:12973/wallets/MINER_WALLET_NAME/balances'   -H 'accept: application/json' 2>/dev/null | json_pp | grep totalBalanceHint| cut -f1 -d","`
 if [ "$oldResult" != "" ]; then
    if [ "$curlResult" != "$oldResult" ]; then
       echo
       echo -n "$datestr "
       newdate=`date +%s`
       secs=`expr $newdate - $lastdate`
       mins=`expr $secs / 60`
       echo  -n "Won a block after $mins minutes! "
       echo $curlResult
       lastdate=$newdate
    fi
 fi

 sleep 30
done

Balance Checking Script Output.
Balance Checking Script Output.

Personal Note: Installing a Bitcoin full node

I. Systemctl service - /etc/systemd/system/bitcoin.service

[Unit]
Description=Bitcoin Full Node
After=network.target  mnt-disk_2.mount

[Service]
WorkingDirectory=/opt/bitcoin-0.21.1/
ExecStart=/opt/bitcoin-0.21.1/bin/bitcoind -datadir=/mnt/disk_2/Bitcoin -daemon
ExecStop=/opt/bitcoin-0.21.1/bin/bitcoin-cli -datadir=/mnt/disk_2/Bitcoin stop
User=nguyenvinhlinh
RemainAfterExit=yes
Restart=on-failure
RestartSec=10
TimeoutStopSec=infinity

[Install]
WantedBy=multi-user.target

II. Firewall-cmd service - /etc/firewalld/services/bitcoin.xml

<?xml version="1.0" encoding="utf-8"?>
<service>
  <short>Bitcoin node</short>
  <description>This option allows Bitcoin node to use tcp port 8333</description>
  <port protocol="tcp" port="8333"/>
</service>

Thiết lập thông số 3080 - Dàn #2 Bạch Hổ

01/10/2021 Mining Rig

I. Lời mở đầu

Bài viết này phục vụ mục đích duy nhất là đó là nếu tôi lỡ tay xóa mấy profile trên MSI Afterburner. Tôi sẽ quay lại đây xem.

  • MSI 3080 GAMING X TRIO (1 cái)
  • MSI 3080 VENTUS (2 cái)
  • GIGABYTE 3080 GAMING OC 10G (1 cái)
Vị Trí trên main VGA Vị trí trên OS
1 MSI 3080 GAMING X TRIO 3
2 MSI 3080 VENTUS 1
3 MSI 3080 VENTUS 2
4 GIGABYTE 3080 GAMING OC 10G 4
[1] Dàn 3080 - #2 Bạch Hổ
[1] Dàn 3080 - #2 Bạch Hổ

II. Ethereum - MSI Afterburner - 95MH/s

a. Tinh chỉnh tốc độ quạt theo nhiệt độ

  • 30C –> 40% Fan
  • 50C –> 80% Fan
  • 60C –> 90% Fan
  • 65C –> 100% Fan
[2] Tinh chỉnh tốc độ quạt
[2] Tinh chỉnh tốc độ quạt

b. Tinh chỉnh MSI Afterburner

No. VGA Power Limit Temp. Limit Core Clock Mem Clock
1 MSI 3080 VENTUS 77% priority 65C -502MHz +900Mhz
2 MSI 3080 VENTUS 77% priority 65C -502MHz +900Mhz
3 MSI 3080 GAMING X TRIO 106% priority 65C -502MHz +825Mhz
4 GIGABYTE 3080 GAMING OC 10G 64% priority 65C -502MHz +900Mhz

c. Kết quả thu được

No. VGA Power Consumption Hashrate GPU Temperature Memory Temperature
1 [1] MSI 3080 VENTUS 246W 96.50Mh/s 61C 90C
2 [2] MSI 3080 VENTUS 246W 96.01Mh/s 64C 90C
3 [3] MSI 3080 GAMING X TRIO 229W 95.02MH/s 62C 106C
4 [4] GIGABYTE 3080 GAMING OC 10G 236W 95.51Mh/s 65C 90C
           
  Total 957 Walt 383.04 MH/s    

III Ethereum - Minerstat - 95 MH/s

a. Tinh chỉnh ClockTune

  • Mode: Built-in (Default)
  • Power Limit (%): skip
  • Core Clock (-/+ MHz): skip
  • Locked Memory Clock (MHz):skip
  • Force P2 State: skip
  • ClockTune delay: 30
No. No. VGA Power Limit (Walt) Locked Core Clock (MHz) Memory Clock (-/+ MHz)
1 MSI 3080 VENTUS 240 1170 950
2 MSI 3080 VENTUS 240 1170 950
3 MSI 3080 GAMING X TRIO 392 1170 950
4 GIGABYTE 3080 GAMING OC 10G 240 1170 950

b. Triggers trong Minerstat

  • IF GPU temperature OF Any IS >=40°C THEN Set fans TO 60%
  • IF GPU temperature OF Any IS >=50°C THEN Set fans TO 85%
  • IF GPU temperature OF Any IS >=55°C THEN Set fans TO 90%
  • IF GPU temperature OF Any IS >=60°C THEN Set fans TO 95%
  • IF GPU temperature OF Any IS >=65°C THEN Set fans TO 100%

c. Kết quả thu được

No. No. VGA Power Consumption Hashrate GPU Temperature Memory Temperature
1 MSI 3080 VENTUS 228 Walt 97.468 MH/s 51C 82C
2 MSI 3080 VENTUS 236 Walt 97.588 MH/s 57C 84C
3 MSI 3080 GAMING X TRIO 221 Walt 96.377 MH/s 54C 102C
4 GIGABYTE 3080 GAMING OC 10G 227 Walt 97.529 MH/s 58C 82C
           
  Total 912 Walt 388.962 MH/s    
[3] Minerstat
[3] Minerstat