Skip to content

Commit

Permalink
Merge branch 'hiveos_integration' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
tmrlvi committed Jan 16, 2022
2 parents ddae0b1 + c164c34 commit 2427f08
Show file tree
Hide file tree
Showing 7 changed files with 205 additions and 1 deletion.
12 changes: 12 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ jobs:
- name: Checkout sources
uses: actions/checkout@v2

- name: Fix LibOpenCL on Linux
if: runner.os == 'Linux'
run: |
sudo apt update
sudo apt install ocl-icd-opencl-dev -y
- name: Fix CRLF on Windows
if: runner.os == 'Windows'
run: git config --global core.autocrlf false
Expand Down Expand Up @@ -126,6 +132,12 @@ jobs:
- name: Checkout sources
uses: actions/checkout@v2

- name: Fix LibOpenCL on Linux
if: runner.os == 'Linux'
run: |
sudo apt update
sudo apt install ocl-icd-opencl-dev -y
- name: Fix CRLF on Windows
if: runner.os == 'Windows'
run: git config --global core.autocrlf false
Expand Down
55 changes: 54 additions & 1 deletion .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
if: runner.os == 'Linux'
run: |
sudo apt update
sudo apt install ocl-icd-opencl-dev
sudo apt install ocl-icd-opencl-dev -y
- name: Check out code into the Go module directory
uses: actions/checkout@v2
Expand Down Expand Up @@ -92,3 +92,56 @@ jobs:
asset_path: "./${{ env.archive }}"
asset_name: "${{ env.asset_name }}"
asset_content_type: application/zip

intergrations:
runs-on: ubuntu-18.04
strategy:
fail-fast: false
matrix:
# Build gnu-linux on ubuntu-18.04 and musl on ubuntu latest
itegration: [ hiveos ]
name: Integrating, ${{ matrix.itegration }}
steps:
- name: Fix LibOpenCL on Linux
run: |
sudo apt update
sudo apt install ocl-icd-opencl-dev -y
- name: Check out code into the module directory
uses: actions/checkout@v2

- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true

- name: Install CUDA Linux
if: runner.os == 'Linux'
uses: tmrlvi/cuda-toolkit@master
with:
cuda: '11.2.2'

- name: Build ${{ matrix.itegration }} Script
run: |
cargo build --target=x86_64-unknown-linux-gnu --release --all
binary_name="kaspa-miner-${{ github.event.release.tag_name }}-linux-gnu-amd64"
asset_name="kaspa-miner-${{ matrix.itegration }}"
strip ./target/x86_64-unknown-linux-gnu/release/kaspa-miner
mkdir ${asset_name}
mv ./target/x86_64-unknown-linux-gnu/release/kaspa-miner ${asset_name}/${binary_name}
mv ./target/x86_64-unknown-linux-gnu/release/libkaspa*.so ${asset_name}/
bash integrations/${{ matrix.itegration }}/build.sh "${{ github.event.release.tag_name }}" "${binary_name}" "${asset_name}"
echo "archive=${asset_name}.tgz" >> $GITHUB_ENV
echo "asset_name=${asset_name}.tgz" >> $GITHUB_ENV
- name: Upload release asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: "./${{ env.archive }}"
asset_name: "${{ env.asset_name }}"
asset_content_type: application/zip
4 changes: 4 additions & 0 deletions integrations/hiveos/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
integrations/hiveos/createmanifest.sh $1 $2
mkdir $3
cp h-manifest.conf integrations/hiveos/*.sh $2/* $3
tar czvf $3.tgz $3
42 changes: 42 additions & 0 deletions integrations/hiveos/createmanifest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
####################################################################################
###
### kaspa-miner
### https://github.com/tmrlvi/kaspa-miner/releases
###
### Hive integration: Merlin
###
####################################################################################

if [ "$#" -ne "2" ]
then
echo "No arguments supplied. Call using createmanifest.sh <VERSION_NUMBER> <MINER BINARY NAME>"
exit
fi
cat > h-manifest.conf << EOF
####################################################################################
###
### kaspa-miner
### https://github.com/tmrlvi/kaspa-miner/releases
###
### Hive integration: Merlin
###
####################################################################################
# The name of the miner
CUSTOM_NAME=kaspa-miner
# Optional version of your custom miner package
CUSTOM_VERSION=$1
CUSTOM_BUILD=0
CUSTOM_MINERBIN=$2
# Full path to miner config file
CUSTOM_CONFIG_FILENAME=/hive/miners/custom/$CUSTOM_NAME/config.ini
# Full path to log file basename. WITHOUT EXTENSION (don't include .log at the end)
# Used to truncate logs and rotate,
# E.g. /var/log/miner/mysuperminer/somelogname (filename without .log at the end)
CUSTOM_LOG_BASENAME=/var/log/miner/$CUSTOM_NAME
WEB_PORT=3338
EOF
21 changes: 21 additions & 0 deletions integrations/hiveos/h-config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
####################################################################################
###
### kaspa-miner
### https://github.com/tmrlvi/kaspa-miner/releases
###
### Hive integration: Merlin
###
####################################################################################

#!/usr/bin/env bash
[[ -e /hive/custom ]] && . /hive/custom/kaspa-miner/h-manifest.conf
[[ -e /hive/miners/custom ]] && . /hive/miners/custom/kaspa-miner/h-manifest.conf
conf=""
conf+=" --kaspad-address=$CUSTOM_URL --mining-address $CUSTOM_TEMPLATE"


[[ ! -z $CUSTOM_USER_CONFIG ]] && conf+=" $CUSTOM_USER_CONFIG"

echo "$conf"
echo "$conf" > $CUSTOM_CONFIG_FILENAME

29 changes: 29 additions & 0 deletions integrations/hiveos/h-run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
####################################################################################
###
### kaspa-miner
### https://github.com/tmrlvi/kaspa-miner/releases
###
### Hive integration: Merlin
###
####################################################################################

#!/usr/bin/env bash

cd `dirname $0`

[ -t 1 ] && . colors

. h-manifest.conf

echo $CUSTOM_NAME
echo $CUSTOM_LOG_BASENAME
echo $CUSTOM_CONFIG_FILENAME

[[ -z $CUSTOM_LOG_BASENAME ]] && echo -e "${RED}No CUSTOM_LOG_BASENAME is set${NOCOLOR}" && exit 1
[[ -z $CUSTOM_CONFIG_FILENAME ]] && echo -e "${RED}No CUSTOM_CONFIG_FILENAME is set${NOCOLOR}" && exit 1
[[ ! -f $CUSTOM_CONFIG_FILENAME ]] && echo -e "${RED}Custom config ${YELLOW}$CUSTOM_CONFIG_FILENAME${RED} is not found${NOCOLOR}" && exit 1


./$CUSTOM_MINERBIN $(< $CUSTOM_CONFIG_FILENAME) $@ 2>&1 | tee $CUSTOM_LOG_BASENAME.log


43 changes: 43 additions & 0 deletions integrations/hiveos/h-stats.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
####################################################################################
###
### kaspa-miner
### https://github.com/tmrlvi/kaspa-miner/releases
###
### Hive integration: Merlin
###
####################################################################################

#!/usr/bin/env bash

#######################
# MAIN script body
#######################

. /hive/miners/custom/kaspa-miner/h-manifest.conf
stats_raw=`cat $CUSTOM_LOG_BASENAME.log | grep -w "hashrate" | tail -n 1 `

#Calculate miner log freshness

maxDelay=120
time_now=`date +%T | awk -F: '{ print ($1 * 3600) + $2*60 + $3 }'`
time_rep=`echo $stats_raw | awk -FT '{print $2}' | awk -FZ '{print $1}' | awk -F: '{ print (($1+1)*3600) + $2*60 + $3}'`
diffTime=`echo $((time_now-time_rep)) | tr -d '-'`

if [ "$diffTime" -lt "$maxDelay" ]; then
total_hashrate=`echo $stats_raw | awk '{print $7}' | cut -d "." -f 1,2 --output-delimiter='' | sed 's/$/0/'`
if [[ $stats_raw == *"Ghash"* ]]; then
total_hashrate=$(($total_hashrate*1000))
fi
stats=$(jq -nc \
--argjson hs "[$total_hashrate]"\
--arg ver "$CUSTOM_VERSION" \
--arg ths "$total_hashrate" \
'{ hs: $hs, hs_units: "khs", algo : "heavyhash", ver:$ver }')
khs=$total_hashrate
else
khs=0
stats="null"
fi

[[ -z $khs ]] && khs=0
[[ -z $stats ]] && stats="null"

0 comments on commit 2427f08

Please sign in to comment.