Hexa's Blog

Tại sao mắc thêm tải mà cường độ dòng điện lại tăng lên?

13/04/2022 @ Saigon Math & Physic

Bài viết này miêu tả vấn đề về cường độ dòng điện (A) mà tôi gặp trong thực tế vì chính sự thiếu sót của tôi trong lúc lúc tính toán.

Bấy giờ, tôi đang làm việc với hai dàn đào là Chu TướcHuyền Vũ , hai cỗ máy này là hai cỗ máy đào tiền ảo với linh kiện mạnh nhất nhì thời điểm đó. Khoe khoang một chút thì Chu Tước sở hửu cho mình là 4 card 3080, và Huyền Vũ170HX. Thời điểm viết bài này là 12/4/2022, Hiện tại ở Việt Nam, gần như không có bài viết hình ảnh nào nói về card 170HX và cũng như chủ sở hữu, dân sưu tập đang khai thác. So sánh một chút với những người đào tiền mã hóa khác bên Châu Âu cũng như Mỹ, dàn Huyền Vũ có thể thua dàn khác là vì số lượng card 170HX chứ không phải là vì chất lượng linh kiện bên trong nó, 170HX thuộc nhóm linh kiện mạnh nhất thời điểm hiện tại, có lẽ chỉ thua 220HX một con quái vật có cực kì ít người sử dụng cũng như sưu tập. Và giờ thì hãy quay lại vấn đề chính.

Trong khi quan trắc hệ thống dàn đào, tôi nhận ra một điểm kì lạ.

Tại sao mỗi khi tôi tắt một trong hai dàn thì cường độ dòng điện lại giảm xuống. Theo như công thức U = I x R , giả sử khi tôi tắt một trong hai dàn, hẳn là điện trở (R) sẽ giảm xuống, kéo theo đó, Cường độ dòng điện tổng (I) sẽ phải tăng lên.

Tuy nhiên thực nghiệm thì lại khác. Mỗi khi tôi tắt một trong hai dàn đào, cường độ dòng điện tổng (I) lập tức giảm xuống, điều này làm tôi phải cân nhắc suy nghĩ, tôi chắc chắn đã sai ở đâu rồi.

Sau khi ngồi vẽ vời và lục lại công thức cùng em trai tôi (Hoàng Sơn), tôi đã nhận ra sai lầm của mình. Việc tắt một dàn đào không đồng nghĩa với việc giảm điện trở tổng (R) . Tại sao? Tại vì tôi đang mắc mạch song song.

[1] Công thức tính điện trở tổng khi mắc song song
[1] Công thức tính điện trở tổng khi mắc song song

Khi tôi mắc song song, việc tôi mắc càng nhiều điện trở song song, tôi càng làm giảm điện trở tổng đi. Theo như công thức U=I x R , khi tổng điện trở giảm xuống thì cường độ dòng điện sẽ phải tăng lên, I↑ = U / R↓ .

Điều này hoàn toàn lý giải câu hỏi của tôi bên trên đó là:

  • Tại sao khi tôi tắt dàn đào, cường độ dòng điện lại giảm xuống,
  • Tại sao khi tôi mở thêm dàn đào, cường độ dòng điện lại tăng lên.

Lý giải đơn giản nhất đó là vì tôi đã mắc song song, càng mắc nhiều điện trở song song, tổng điện trở sẽ càng giảm. Và khi tổng điện trở giảm, cường độ dòng điện tổng chắc chắn sẽ phải tăng lên.

Cách chỉ định IP sẽ bị định tuyến qua VPN

30/03/2022 Linux

Ở bài viết này, chúng ta sẽ mặc định là VPN đã được kết nối thành công. Vấn đề bây h là làm sao để quá trình định tuyến sẽ chỉ và chỉ sử dụng VPN khi bị yêu cầu đến một IP nhất định. Để hiểu rõ hơn, hãy nhìn hình minh họa sau.

[1] Mô hình network
[1] Mô hình network

Ví dụ cụ thể ở đây là máy tính của tôi muốn ping 192.168.1.200 và tôi muốn rằng chỉ có IP 192.168.1.200 là sẽ chạy qua VPN, những yêu cầu khác ví dụ như đến 192.168.1.4 sẽ không có thông qua VPN. 192.168.1.4 sẽ phải được định tuyền trong mạng nội bộ.

Để làm được điều trên, đầu tiên cần phải xác định được vpn network adapter với lệnh ifconfig. Lý do cần tìm vpn network adapter là để tìm:

  • Netmask
  • Gateway

Sau khi gõ lệnh ifconfig, vpn network adapter sẽ có thể trông như sau:

ppp0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST>  mtu 1400
        inet 192.168.1.21  netmask 255.255.255.255  destination 192.168.1.1
        ppp  txqueuelen 3  (Point-to-Point Protocol)
        RX packets 19  bytes 1241 (1.2 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 80  bytes 30120 (29.4 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

Dựa vào thông tin trên, ta thu được:

  • Netmask: 255.255.255.255
  • Gateway: 192.168.1.1 (chính là giá trị destination)

Tiếp theo, vào Setting > Network , chọn tùy chỉnh kết nối VPN. Lưu ý phần Routes, những thông số cần chỉnh bao gồm

  • Address (192.168.1.200)
  • Netmask (255.255.255.255)
  • Gateway (192.168.1.1)
  • Tick chọn use this connection only for resources on its network

Sau khi tinh chỉnh xong, tắt và mở lại VPN. Cuối cùng là tận hưởng thành quả.

[2] VPN Routes
[2] VPN Routes

Đây là terminal trước khi tỉnh chỉnh, lúc này chưa có ping được 192.168.1.200

➜ ~ ping 192.168.1.200
PING 192.168.1.200 (192.168.1.200) 56(84) bytes of data.
From 192.168.1.5 icmp_seq=1 Destination Host Unreachable
From 192.168.1.5 icmp_seq=2 Destination Host Unreachable
From 192.168.1.5 icmp_seq=3 Destination Host Unreachable

Và đây là terminal sau khi tinh chỉnh, lúc này đã ping được 192.168.1.200

➜ ~ ping 192.168.1.200
PING 192.168.1.200 (192.168.1.200) 56(84) bytes of data.
64 bytes from 192.168.1.200: icmp_seq=1 ttl=63 time=6.52 ms
64 bytes from 192.168.1.200: icmp_seq=2 ttl=63 time=4.45 ms
64 bytes from 192.168.1.200: icmp_seq=3 ttl=63 time=4.99 ms
64 bytes from 192.168.1.200: icmp_seq=4 ttl=63 time=4.95 ms

Alephium Miner Bot

16/02/2022 Projects

Github - Alephium Miner Bot

Alephium Miner Bot is a telegram bot that sends the following messages

  • Global network hashrate
  • Current IP
  • Balance & mining reward
Telegram
Telegram

This bot is inspired by Diomark. His shell script about checking alph balance & mining time reward is really cool.

Dependencies

  • Alephium Node: 1.2.0 (if used alephium worker)
  • Kaspa Node: 0.11.9 (if use kaspa worker)
  • Erlang: 22.3
  • Elixir: 1.12

Elixir Processes

Elixir Processes
Elixir Processes

Release

Execute the following command, then project release will be generated at /alephium_miner_bot/_build/prod/rel/alephium_miner_bot

$ mix deps.get
$ MIX_ENV=prod mix release

Execute Release

Make a file named release_run.sh or copy it from release_run.sh.sample. If you download release from github release, after unzip it, you can also use this script named release_run.sh to launch the program, however beaware of your current directory.

#!/bin/bash
ALEPHIUM_WORKER=false \
ALPH_NODE_IP=127.0.0.1 \
ALPH_NODE_PORT=12973 \
ALPH_NODE_API_KEY=cf5062725e62d2096228cd6f7ab0f2a0 \
ALPH_NODE_WALLET_NAME=main \
ALPH_NODE_WALLET_PASSWORD="" \
WORKER_HASHRATE_INTERVAL=1800000 \
WORKER_IP_INTERVAL=60000 \
TELEGRAM_BOT_TOKEN=cf5062725e62d2096228cd6f7ab0f2a0 \
TELEGRAM_CHAT_ID=cf5062725e62d2096228cd6f7ab0f2a0 \
KASPA_WORKER=false \
KASPA_WALLET_PATH=/opt/kaspa/bin/kaspawallet \
_build/prod/rel/alephium_miner_bot/bin/alephium_miner_bot start

To execute the release, it’s important to provide the following parameters:

Alephium Configration:

  • ALEPHIUM_WORKER: enable/disable alephium worker, value: true/false
  • ALPH_NODE_IP: self-explained
  • ALPH_NODE_PORT: self-explained
  • ALPH_NODE_API_KEY: self-explained
  • ALPH_NODE_WALLET_NAME: self-explained
  • ALPH_NODE_WALLET_PASSWORD: self-explained
  • WORKER_HASHRATE_INTERVAL: interval in microsecond that fetching network hashrate.
  • WORKER_IP_INTERVAL: interval in microsecond that fetching IP
  • TELEGRAM_BOT_TOKEN: self-explained
  • TELEGRAM_CHAT_ID: self-explained

Kaspa Configuration:

  • KASPA_WORKER: enable/disable kaspa worker, value: true/false
  • KASPA_WALLET_PATH: path to kaspa wallet executable file

Finally, make the file release-run.sh executable and run it

# Current directory: Project Root
$ ./release_run.sh

You should see the following output on terminal.

[Worker.WorkerIP] started.
[Alephium][Worker.WorkerReward] started.
[Alephium][Worker.WorkerHashrate] started.
[Kaspa][Worker.WorkerReward] started.
2022-02-02 13:07 [Kaspa] Total Balance: 635,292.823
2022-02-02 13:07 IP: 42.112.xxx.xxx
2022-02-02 13:07 [Alephium] Global Hashrate: 27.1 TH/s
2022-02-02 13:07 [Alephium] Total Balance Hint: 0 ALPH
2022-02-02 13:07 [Kaspa] Won a block after 0.1 minute(s). Total Balance Hint: 638,292.823

And your telegram should show:

Telegram
Telegram

Donation

If you want to buy me a coffee, this is my addresses.

  • Alephium: 16ZcUrPRFafXdSjkTq5uWqkSrg6n5zwGB26pc7xrcjM7m
  • Kaspa: kaspa:qz3997w4ew30rgp8wxp2aaj5zk7ect68nnzy80fhrpw0d7fdervkw8lpwrmry

Thank you from Vietnam.

Kaspa, Mining Script

14/01/2022 Mining Rig

  1. Download the latest kaspa-miner https://github.com/tmrlvi/kaspa-miner/releases and unzip.
  2. Create a bat file named run-kaspa-miner.bat at the directory which is unzip at previous step.
::run-kaspa-miner.bat
kaspa-miner-v0.2.1-GPU-0.2-win64-amd64.exe --mining-address=kaspa:qp30cee96qejpnz236fu8gn5yv9dkjdhp9s5hk8tfz8u7w068g7v7tlkvxn90 ^
                                           --threads 0 --devfund-percent 0 --cuda-workload 256 ^
                                           --kaspad-address IP_HERE --port 16110
  1. Execute run-kaspa-miner.bat to start mining. Good Luck!

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