Coder Social home page Coder Social logo

amoveo-c-miner's Introduction

Amoveo C miner

Dependencies

   sudo apt-get install erlang libncurses5-dev libssl-dev unixodbc-dev g++ git

You might need less than what is listed above ^ If you still have trouble with dependencies, look at dependencies from Amoveo:

installation

git clone https://github.com/zack-bitcoin/amoveo-c-miner.git

configure

You can connect it to a full node. Change the url at the top of miner.erl to point to your full node. It is named Peer. This gives all your money to whoever runs that full node.

You can also connect to a mining pool. If you connect to a mining pool, you get paid by the person running the pool. This way you don't have to run Amoveo. set Peer to be the url for the mining pool.

By default Peer is set up to connect to a public mining pool.

Put your pubkey into the Pubkey definition at the top of miner.erl so that you can get paid.

By default it uses 2 threads for mining. To change this, change the line near the top of miner.erl It says -define(CORES, 2).

Change the 2 to the number of threads that you want to mine with. Usually, this should be the same as, or one less than the number of CPU cores on your computer.

You can tell it to sleep in between mining periods so that you consume less CPU for mining.

mining

On ubuntu, the miner in C language can be compiled and turned on like this:

sh build.sh 

Then you start mining like this:

miner:start().

To turn it off, first use Control + C, a, enter to exit the erlang interface. Then to kill the miner processes, do:

sh clean.sh

On windows, you'll need Visual Studio Community 2017. To compile the miner, you have to run the Visual Studio and open Tools > Visual Studio Command Prompt. Then within the command prompt:

cd <miner_repo_path>
build.bat

Then, just like on ubuntu, start miner by:

miner:start().

Check how fast you can mine in megahashes per second.

You can do a speed test to measure how fast your computer is able to mine. First build the software normally

sh build.sh

Then change the settings to be in speed-test mode.

miner:speed_test().

then quit from erlang

halt().

now run the c program alone

./amoveo_c_miner

other notes

The build.sh install script works for ubuntu linux and Mac OSX. If you are using a different system, you will have to make some simple changes.

By writing a miner for Amoveo in C, it becomes easier to write miners for the GPU and FPGAs. This simple C miner is a template for making miners in other languages.

Here is a link to where the same mining is implemented in erlang. The 'pow' function is the one to look at

Here is a link to the main Amoveo repo.. If you want to solo mine without a mining pool, you will need this. Solo miners make more profit.

amoveo-c-miner's People

Contributors

mandelhoff avatar nextquick avatar smiled0g avatar zack-bitcoin avatar

Stargazers

 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

amoveo-c-miner's Issues

get a error and stop mining

I am mining in VMWARE ubuntu , get a error like this and stop mining

exception error: bad argument
in function list_to_binary/1
called as list_to_binary(ok)
in call from miner:unpack_mining_data/1 (miner.erl, line 20)
in call from miner:start_c_miners/1 (miner.erl, line 61)

exception exit

hi zack,
i want to mine on amoveo. i tried this program, but i got this error. i already installed all the dependencies. sorry if this is a newbie problem

➜  amoveo-c-miner git:(master) ✗ sh build.sh 
miner.erl:107: Warning: variable 'E' is unused
miner.erl:118: Warning: no clause will ever match
Erlang/OTP 21 [erts-10.0.3] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe] [dtrace]

Eshell V10.0.3  (abort with ^G)
1> miner:start().
Started mining.
** exception exit: {noproc,
                       {gen_server,call,
                           [httpc_manager,
                            {request,
                                {request,undefined,<0.75.0>,0,http,
                                    {"159.89.106.253",8085},
                                    "/",[],post,
                                    {http_request_h,undefined,"keep-alive",undefined,undefined,
                                        undefined,undefined,undefined,undefined,undefined,...},
                                    {"application/octet-stream",<<"[\"mining_data\"]">>},
                                    {http_options,"HTTP/1.1",3000,true,
                                        {essl,[]},
                                        undefined,false,3000,...},
                                    "http://159.89.106.253:8085/",[],none,[],1532594070965,
                                    undefined,undefined,undefined,...}},
                            infinity]}}
     in function  gen_server:call/3 (gen_server.erl, line 223)
     in call from httpc:handle_request/9 (httpc.erl, line 565)
     in call from miner:talk_helper/3 (miner.erl, line 100)
     in call from miner:start2/0 (miner.erl, line 37)
2> 

need your help! thanks zack!

Difficulty Max 64k?

Looks like a maximum of two bytes of the integer difficulty go in to the 66 byte buffer that gets hashed. Is that correct?

text[32] = difficulty / 256;

text[33] = difficulty % 256;

If that's not correct, should the 66 byte buffer become larger (fixed) or is that length dynamic with the difficulty's size?

The pool appears to verify the hash using the difficulty. Does that have similar issue or is it good?

Enhancement Request: Add extra Difficulty input argument

Enhancement Request: Add extra Difficulty input argument

Two difficulties sent to the miner:

  1. Network diff - used in the sha256(bhash + diff1 + nonce)
  2. Pool share diff - used to prove to a pool that work is done even if this is not "block quality" results.

A second input argument for difficulty is needed for a "share" based mining pool. Your prototype Amoveo mining pool will just send the difficulty twice as it only accepts block quality results.

Fast hash code logic

You need to update a 64 byte chunk, then save the ctx state. You then update the 2 bytes in the second chunk, and reset the state back to the saved ctx state on each iteration.

Server gave confusing response

➜  amoveo-c-miner git:(master) ✗ git pull
Already up-to-date.
➜  amoveo-c-miner git:(master) ✗ sh build_ubuntu.sh
miner.erl:72: Warning: variable 'E' is unused
miner.erl:83: Warning: no clause will ever match
Erlang/OTP 18 [erts-7.3] [source] [64-bit] [async-threads:10] [hipe] [kernel-poll:false]

Eshell V7.3  (abort with ^G)
1> miner:start().
Started mining.
server gave confusing response
server gave confusing response
server gave confusing response
server gave confusing response
server gave confusing response
server gave confusing response
server gave confusing response
server gave confusing response
server gave confusing response

May be the miner code had not update from amoveo.

Segmentation fault (core dumped)

C program unexpected crashes by startup:

$ ./amoveo_c_miner 
Segmentation fault (core dumped)

My debug for reveal root of causes (gdb build):

$ gcc -O0 -g -std=c99 -c sha256.c
$ gcc -O0 -g -std=c99 -c amoveo_pow.c
$ gcc sha256.o amoveo_pow.o -o amoveo_c_miner
$ gdb ./amoveo_c_miner

GNU gdb (GDB) Red Hat Enterprise Linux 8.0.1-26.el7.sc1
Copyright (C) 2017 Free Software Foundation, Inc.
Reading symbols from ./amoveo_c_miner...done.
(gdb) run
Starting program: /home/doka/proj/2019/amoveo-c-miner/amoveo_c_miner 
Missing separate debuginfos, use: debuginfo-install glibc-2.17-196.el7_4.2.x86_64

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7a8b60c in fseek () from /lib64/libc.so.6

(gdb) backtrace
#0  0x00007ffff7a8b60c in fseek () from /lib64/libc.so.6
#1  0x000000000040155f in read_input (B=0x7fffffffd3b0 "", N=0x7fffffffd390 "\t", id=0) at amoveo_pow.c:114
#2  0x00000000004016d1 in main (argc=1, argv=0x7fffffffd4e8) at amoveo_pow.c:151
(gdb) 

It seems root of cause the string 114:

fseek(fileptr, 0, SEEK_END); // Jump to the end of the file

I try to manually create file mining_input (from previous string: fileptr = fopen("mining_input", "rb");) and crashes stops.

Exception error on C miner

Hi Zack, for your information:

While I was:

  • On computer A, windows 7:
    • mining from JS wallet to pubkey 1
  • On computer B, ubuntu:
    • mining from c-miner to pubkey 1, connected to your 146.185.142.103 pool
    • running full node with pubkey 2, not minning

I got this on c-miner:

did not find a block in that period
did not find a block in that period
Found a block. 1

You need to turn on and sync your Amoveo node before you can mine. You can get it here: https://github.com/zack-bitcoin/amoveo
** exception error: no match of right hand side value 2
     in function  miner:talk_helper/3 (miner.erl, line 76)
     in call from miner:start_c_miners/1 (miner.erl, line 52)
2> miner:start().
Started mining.
did not find a block in that period
did not find a block in that period
Found a block. 1
Found a block. 2
did not find a block in that period

Quite strange since I suppose that the full node is not needed to run the c-miner, isn't it?

I restarted the c-miner and still working ok. Also tried to stop the node and still minning, as is supposed to be?

Let me know if you need any logfile.

Thanks

PS: is it possible to "autosync" the full node? Any command for this?

No mining and error print out ""If you are running a solo-mi.."

I changed it to my public key and uncomented the line for your mining pool (159.89.106.253:8085) in miner.erl. Then I run run.sh and start with miner:start(). I use ubuntu.

I only get this error keep printing out: "If you are running a solo-mining node, then this error may have happened because you need to turn on and sync your Amoveo node before you can mine.
If this error happens while connected to the public mining node, then it can probably be safely ignored."

I did run it succesfuly once, on the first mainnet day. I even got 0.7 coin. Whats wrong now?

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.