Coder Social home page Coder Social logo

mining-proxy's Introduction

Mining Server Proxy

A simple proxy which supports serving work via the Stratum and the BetterHash mining protocols.

Work is obtained using the BetterHash work protocol via a request to bitcoind in conjunction with the 2018-02-miningserver patchset. Payout information is obtained using the BetterHash pool protocol via a request to the pool daemon included in this repo.

mining-proxy's People

Contributors

devfans avatar ffranr avatar thebluematt 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  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  avatar  avatar

mining-proxy's Issues

Clean up logging

Shouldn't write per-user crap to the log generally without some debug options on.

Detect Missing Weak Blocks

We need some analysis on a per-user basis of too many shares possibly indicative of weak block witholding. Assuming a max-median payout limit this should just be belt-and-suspenders, and assuming the majority of hashrate on a pool is self-controlled (ie via pool-proxy, which it almost certainly is initially) this is redundant. Thus, not gonna tag MVP.

Build error

Hi on what platform this build successfully ? I am new to rust, I simply build it with cargo build -vv, wht is the right way ?

following is the error

TARGET = Some("x86_64-unknown-linux-gnu")
TARGET = Some("x86_64-unknown-linux-gnu")
HOST = Some("x86_64-unknown-linux-gnu")
AR_x86_64-unknown-linux-gnu = None
AR_x86_64_unknown_linux_gnu = None
HOST_AR = None
AR = None
TARGET = Some("x86_64-unknown-linux-gnu")
TARGET = Some("x86_64-unknown-linux-gnu")


   Running `rustc --crate-name pool_proxy src/multi_user_proxy.rs --crate-type bin --emit=dep-info,link -C panic=abort -C debuginfo=2 -C metadata=8b1edf85e8460e1f -C extra-filename=-8b1edf85e8460e1f --out-dir /home/user/mining-proxy/target/debug/deps -C incremental=/home/user/mining-proxy/target/debug/incremental -L dependency=/home/user/mining-proxy/target/debug/deps --extern bytes=/home/user/mining-proxy/target/debug/deps/libbytes-a41d1b62832a3c8b.rlib --extern tokio_io=/home/user/mining-proxy/target/debug/deps/libtokio_io-ea6a015c12c63591.rlib --extern serde_json=/home/user/mining-proxy/target/debug/deps/libserde_json-79d63cfa520a0390.rlib --extern futures=/home/user/mining-proxy/target/debug/deps/libfutures-56ff4ec8ae738410.rlib --extern hyper=/home/user/mining-proxy/target/debug/deps/libhyper-c0ed480c8d9a8341.rlib --extern tokio_codec=/home/user/mining-proxy/target/debug/deps/libtokio_codec-3fa1f9a4f9e9e7cb.rlib --extern secp256k1=/home/user/mining-proxy/target/debug/deps/libsecp256k1-97ec2b122d88b15c.rlib --extern tokio=/home/user/mining-proxy/target/debug/deps/libtokio-327e274533aca8b8.rlib --extern bitcoin=/home/user/mining-proxy/target/debug/deps/libbitcoin-8702673a1103cc73.rlib --extern crypto=/home/user/mining-proxy/target/debug/deps/libcrypto-75bcdb4b9ab551c7.rlib --extern base64=/home/user/mining-proxy/target/debug/deps/libbase64-003533131bf1972c.rlib -L native=/home/user/mining-proxy/target/debug/build/rust-crypto-73b153254d3aa119/out -L native=/home/user/mining-proxy/target/debug/build/secp256k1-0dde8a0148b24f70/out -L native=/home/user/mining-proxy/target/debug/build/secp256k1-57ca9c967a33f52f/out`
error[E0658]: `impl Trait` in return position is experimental (see issue #34511)
  --> src/rpc_client.rs:27:67
   |
27 |     pub fn make_rpc_call(&self, method: &str, params: &Vec<&str>) -> impl Future<Item=serde_json::Value, Error=()> {
   |                                                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0658]: non-reference pattern used to match a reference (see issue #42640)
   --> src/sample_pool.rs:156:15
    |
156 |         if let Some(serde_json::Value::String(chainwork_v)) = header.get("chainwork") {
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using a reference: `&serde_json::Value::String(chainwork_v)`

error[E0658]: non-reference pattern used to match a reference (see issue #42640)
   --> src/sample_pool.rs:157:16
    |
157 |             if let Some(serde_json::Value::String(hash_v)) = header.get("hash") {
    |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using a reference: `&serde_json::Value::String(hash_v)`

error[E0658]: non-reference pattern used to match a reference (see issue #42640)
   --> src/sample_pool.rs:158:17
    |
158 |                 if let Some(serde_json::Value::Number(confs_v)) = header.get("confirmations") {
    |                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using a reference: `&serde_json::Value::Number(confs_v)`

error[E0658]: non-reference pattern used to match a reference (see issue #42640)
   --> src/sample_pool.rs:380:16
    |
380 |             if let Some(serde_json::Value::String(besthash_v)) = chain_info.get("bestblockhash") {
    |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using a reference: `&serde_json::Value::String(besthash_v)`

error[E0658]: non-reference pattern used to match a reference (see issue #42640)
   --> src/sample_pool.rs:382:18
    |
382 |                     if let Some(serde_json::Value::String(targethash_v)) = chain_info.get("target") {
    |                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using a reference: `&serde_json::Value::String(targethash_v)`

error[E0658]: non-reference pattern used to match a reference (see issue #42640)
   --> src/sample_pool.rs:383:19
    |
383 |                         if let Some(serde_json::Value::String(chainwork_v)) = chain_info.get("chainwork") {
    |                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using a reference: `&serde_json::Value::String(chainwork_v)`

error[E0308]: mismatched types
   --> src/sample_pool.rs:656:58
    |
656 |                                     auth_key: PublicKey::from_secret_key(&secp_ctx, &auth_key.unwrap()).unwrap(),
    |                                                                                     ^^^^^^^^^^^^^^^^^^ expected struct `secp256k1::SecretKey`, found struct `secp256k1::key::SecretKey`
    |
    = note: expected type `&secp256k1::SecretKey`
               found type `&secp256k1::key::SecretKey`
note: Perhaps two different versions of crate `secp256k1` are being used?
   --> src/sample_pool.rs:656:58
    |
656 |                                     auth_key: PublicKey::from_secret_key(&secp_ctx, &auth_key.unwrap()).unwrap(),
    |                                                                                     ^^^^^^^^^^^^^^^^^^

error[E0308]: mismatched types
   --> src/single_user_proxy.rs:231:67
    |
231 |             bind_and_handle!(mining_listen_bind, MiningServer::new(job_rx, mining_auth_key.unwrap()), MiningServer);
    |                                                                            ^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `secp256k1::SecretKey`, found struct `secp256k1::key::SecretKey`
    |
    = note: expected type `secp256k1::SecretKey`
               found type `secp256k1::key::SecretKey`
note: Perhaps two different versions of crate `secp256k1` are being used?
   --> src/single_user_proxy.rs:231:67
    |
231 |             bind_and_handle!(mining_listen_bind, MiningServer::new(job_rx, mining_auth_key.unwrap()), MiningServer);
    |                                                                            ^^^^^^^^^^^^^^^^^^^^^^^^

error[E0308]: mismatched types
   --> src/sample_pool.rs:483:30
    |
483 |                                 secp_ctx.sign(&hash, &auth_key.unwrap()).unwrap()
    |                                                      ^^^^^^^^^^^^^^^^^^ expected struct `secp256k1::SecretKey`, found struct `secp256k1::key::SecretKey`
...
667 |                                     signature: sign_message!(payout_info, 13),
    |                                                ------------------------------ in this macro invocation
    |
    = note: expected type `&secp256k1::SecretKey`
               found type `&secp256k1::key::SecretKey`
note: Perhaps two different versions of crate `secp256k1` are being used?
   --> src/sample_pool.rs:483:30
    |
483 |                                 secp_ctx.sign(&hash, &auth_key.unwrap()).unwrap()
    |                                                      ^^^^^^^^^^^^^^^^^^
...
667 |                                     signature: sign_message!(payout_info, 13),
    |                                                ------------------------------ in this macro invocation

error[E0308]: mismatched types
   --> src/single_user_proxy.rs:243:70
    |
243 |             bind_and_handle!(mining_listen_bind, MiningServer::new(mining_rx, mining_auth_key.unwrap()), MiningServer);
    |                                                                               ^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `secp256k1::SecretKey`, found struct `secp256k1::key::SecretKey`
    |
    = note: expected type `secp256k1::SecretKey`
               found type `secp256k1::key::SecretKey`
note: Perhaps two different versions of crate `secp256k1` are being used?
   --> src/single_user_proxy.rs:243:70
    |
243 |             bind_and_handle!(mining_listen_bind, MiningServer::new(mining_rx, mining_auth_key.unwrap()), MiningServer);
    |                                                                               ^^^^^^^^^^^^^^^^^^^^^^^^

error[E0308]: mismatched types
   --> src/sample_pool.rs:483:30
    |
483 |                                 secp_ctx.sign(&hash, &auth_key.unwrap()).unwrap()
    |                                                      ^^^^^^^^^^^^^^^^^^ expected struct `secp256k1::SecretKey`, found struct `secp256k1::key::SecretKey`
...
718 |                                             signature: sign_message!(user_payout_info, 15),
    |                                                        ----------------------------------- in this macro invocation
    |
    = note: expected type `&secp256k1::SecretKey`
               found type `&secp256k1::key::SecretKey`
note: Perhaps two different versions of crate `secp256k1` are being used?
   --> src/sample_pool.rs:483:30
    |
483 |                                 secp_ctx.sign(&hash, &auth_key.unwrap()).unwrap()
    |                                                      ^^^^^^^^^^^^^^^^^^
...
718 |                                             signature: sign_message!(user_payout_info, 15),
    |                                                        ----------------------------------- in this macro invocation

error[E0560]: struct `bitcoin::TxIn` has no field named `prev_hash`
   --> src/stratum_server.rs:696:10
    |
696 |                                     prev_hash: Default::default(),
    |                                     ^^^^^^^^^^ `bitcoin::TxIn` does not have this field
    |
    = note: available fields are: `previous_output`, `script_sig`, `sequence`, `witness`

error[E0560]: struct `bitcoin::TxIn` has no field named `prev_index`
   --> src/stratum_server.rs:697:10
    |
697 |                                     prev_index: 0xffffffff,
    |                                     ^^^^^^^^^^^ `bitcoin::TxIn` does not have this field
    |
    = note: available fields are: `previous_output`, `script_sig`, `sequence`, `witness`

error: aborting due to 2 previous errors

error: Could not compile `mining-proxy`.

Caused by:
  process didn't exit successfully: `rustc --crate-name pool_proxy src/multi_user_proxy.rs --crate-type bin --emit=dep-info,link -C panic=abort -C debuginfo=2 -C metadata=8b1edf85e8460e1f -C extra-filename=-8b1edf85e8460e1f --out-dir /home/user/mining-proxy/target/debug/deps -C incremental=/home/user/mining-proxy/target/debug/incremental -L dependency=/home/user/mining-proxy/target/debug/deps --extern bytes=/home/user/mining-proxy/target/debug/deps/libbytes-a41d1b62832a3c8b.rlib --extern tokio_io=/home/user/mining-proxy/target/debug/deps/libtokio_io-ea6a015c12c63591.rlib --extern serde_json=/home/user/mining-proxy/target/debug/deps/libserde_json-79d63cfa520a0390.rlib --extern futures=/home/user/mining-proxy/target/debug/deps/libfutures-56ff4ec8ae738410.rlib --extern hyper=/home/user/mining-proxy/target/debug/deps/libhyper-c0ed480c8d9a8341.rlib --extern tokio_codec=/home/user/mining-proxy/target/debug/deps/libtokio_codec-3fa1f9a4f9e9e7cb.rlib --extern secp256k1=/home/user/mining-proxy/target/debug/deps/libsecp256k1-97ec2b122d88b15c.rlib --extern tokio=/home/user/mining-proxy/target/debug/deps/libtokio-327e274533aca8b8.rlib --extern bitcoin=/home/user/mining-proxy/target/debug/deps/libbitcoin-8702673a1103cc73.rlib --extern crypto=/home/user/mining-proxy/target/debug/deps/libcrypto-75bcdb4b9ab551c7.rlib --extern base64=/home/user/mining-proxy/target/debug/deps/libbase64-003533131bf1972c.rlib -L native=/home/user/mining-proxy/target/debug/build/rust-crypto-73b153254d3aa119/out -L native=/home/user/mining-proxy/target/debug/build/secp256k1-0dde8a0148b24f70/out -L native=/home/user/mining-proxy/target/debug/build/secp256k1-57ca9c967a33f52f/out` (exit code: 101)
warning: build failed, waiting for other jobs to finish...
error[E0560]: struct `bitcoin::TxIn` has no field named `prev_hash`
   --> src/stratum_server.rs:696:10
    |
696 |                                     prev_hash: Default::default(),
    |                                     ^^^^^^^^^^ `bitcoin::TxIn` does not have this field
    |
    = note: available fields are: `previous_output`, `script_sig`, `sequence`, `witness`

error[E0560]: struct `bitcoin::TxIn` has no field named `prev_index`
   --> src/stratum_server.rs:697:10
    |
697 |                                     prev_index: 0xffffffff,
    |                                     ^^^^^^^^^^^ `bitcoin::TxIn` does not have this field
    |
    = note: available fields are: `previous_output`, `script_sig`, `sequence`, `witness`

error[E0560]: struct `bitcoin::TxIn` has no field named `prev_hash`
  --> src/mining_server.rs:61:4
   |
61 |             prev_hash: Default::default(),
   |             ^^^^^^^^^^ `bitcoin::TxIn` does not have this field
   |
   = note: available fields are: `previous_output`, `script_sig`, `sequence`, `witness`

error[E0560]: struct `bitcoin::TxIn` has no field named `prev_index`
  --> src/mining_server.rs:62:4
   |
62 |             prev_index: 0xffffffff,
   |             ^^^^^^^^^^^ `bitcoin::TxIn` does not have this field
   |
   = note: available fields are: `previous_output`, `script_sig`, `sequence`, `witness`

error: aborting due to 10 previous errors

error: Could not compile `mining-proxy`.

Caused by:
  process didn't exit successfully: `rustc --crate-name sample_pool src/sample_pool.rs --crate-type bin --emit=dep-info,link -C panic=abort -C debuginfo=2 -C metadata=fa9157f6d01f828a -C extra-filename=-fa9157f6d01f828a --out-dir /home/user/mining-proxy/target/debug/deps -C incremental=/home/user/mining-proxy/target/debug/incremental -L dependency=/home/user/mining-proxy/target/debug/deps --extern bytes=/home/user/mining-proxy/target/debug/deps/libbytes-a41d1b62832a3c8b.rlib --extern tokio_io=/home/user/mining-proxy/target/debug/deps/libtokio_io-ea6a015c12c63591.rlib --extern serde_json=/home/user/mining-proxy/target/debug/deps/libserde_json-79d63cfa520a0390.rlib --extern futures=/home/user/mining-proxy/target/debug/deps/libfutures-56ff4ec8ae738410.rlib --extern hyper=/home/user/mining-proxy/target/debug/deps/libhyper-c0ed480c8d9a8341.rlib --extern tokio_codec=/home/user/mining-proxy/target/debug/deps/libtokio_codec-3fa1f9a4f9e9e7cb.rlib --extern secp256k1=/home/user/mining-proxy/target/debug/deps/libsecp256k1-97ec2b122d88b15c.rlib --extern tokio=/home/user/mining-proxy/target/debug/deps/libtokio-327e274533aca8b8.rlib --extern bitcoin=/home/user/mining-proxy/target/debug/deps/libbitcoin-8702673a1103cc73.rlib --extern crypto=/home/user/mining-proxy/target/debug/deps/libcrypto-75bcdb4b9ab551c7.rlib --extern base64=/home/user/mining-proxy/target/debug/deps/libbase64-003533131bf1972c.rlib -L native=/home/user/mining-proxy/target/debug/build/rust-crypto-73b153254d3aa119/out -L native=/home/user/mining-proxy/target/debug/build/secp256k1-0dde8a0148b24f70/out -L native=/home/user/mining-proxy/target/debug/build/secp256k1-57ca9c967a33f52f/out` (exit code: 101)
warning: build failed, waiting for other jobs to finish...
error: aborting due to 6 previous errors

error: Could not compile `mining-proxy`.

Caused by:
  process didn't exit successfully: `rustc --crate-name mining_proxy src/single_user_proxy.rs --crate-type bin --emit=dep-info,link -C panic=abort -C debuginfo=2 -C metadata=57bdfdcab68221e9 -C extra-filename=-57bdfdcab68221e9 --out-dir /home/user/mining-proxy/target/debug/deps -C incremental=/home/user/mining-proxy/target/debug/incremental -L dependency=/home/user/mining-proxy/target/debug/deps --extern bytes=/home/user/mining-proxy/target/debug/deps/libbytes-a41d1b62832a3c8b.rlib --extern tokio_io=/home/user/mining-proxy/target/debug/deps/libtokio_io-ea6a015c12c63591.rlib --extern serde_json=/home/user/mining-proxy/target/debug/deps/libserde_json-79d63cfa520a0390.rlib --extern futures=/home/user/mining-proxy/target/debug/deps/libfutures-56ff4ec8ae738410.rlib --extern hyper=/home/user/mining-proxy/target/debug/deps/libhyper-c0ed480c8d9a8341.rlib --extern tokio_codec=/home/user/mining-proxy/target/debug/deps/libtokio_codec-3fa1f9a4f9e9e7cb.rlib --extern secp256k1=/home/user/mining-proxy/target/debug/deps/libsecp256k1-97ec2b122d88b15c.rlib --extern tokio=/home/user/mining-proxy/target/debug/deps/libtokio-327e274533aca8b8.rlib --extern bitcoin=/home/user/mining-proxy/target/debug/deps/libbitcoin-8702673a1103cc73.rlib --extern crypto=/home/user/mining-proxy/target/debug/deps/libcrypto-75bcdb4b9ab551c7.rlib --extern base64=/home/user/mining-proxy/target/debug/deps/libbase64-003533131bf1972c.rlib -L native=/home/user/mining-proxy/target/debug/build/rust-crypto-73b153254d3aa119/out -L native=/home/user/mining-proxy/target/debug/build/secp256k1-0dde8a0148b24f70/out -L native=/home/user/mining-proxy/target/debug/build/secp256k1-57ca9c967a33f52f/out` (exit code: 101)


Need LICENSE

Can you add a LICENSE file @TheBlueMatt ? I'd like to make some contributions but need to know what I'm agreeing to. ;-)

Transaction Data Deduplication

Pool-side transaction data should be deduplicated in memory across clients, with clients sending lots of novel data getting weak block data resets.

Bitcoind stopped responding work protocol.

Seems after the bitcoind ran for some time(maybe several days), it stopped to respond to work protocol.

The proxy established the work connection to bitcoind, and proposed supported protocol version, then got no response and no block templates got received. Several days ago it's working good as i remember.

default difficulty

I am trying to make this work with Nicehash, but if I run it in a solo mode, than difficulty is extremely high like 21111111111111+ so all are rejects, if I run it together with a pool its using mining.set.difficulty which requests difficulty from a miner and sets it to around 16k which in contrast is too low ...

How can we set a static or min/max difficulty for instance ?

panicked error on new stratum connection

Seems we met a panic exception with pool-proxy when a new stratum connected is established:
The output:

thread 'tokio-runtime-worker-0' panicked at 'called `Result::unwrap()` on an `Err` value: "PoisonError { inner: .. }"', libcore/result.rs:945:5
Got new client connection (id 120)
thread 'tokio-runtime-worker-0' panicked at 'called `Result::unwrap()` on an `Err` value: "PoisonError { inner: .. }"', libcore/result.rs:945:5
Got new client connection (id 121)
thread 'tokio-runtime-worker-0' panicked at 'called `Result::unwrap()` on an `Err` value: "PoisonError { inner: .. }"', libcore/result.rs:945:5
Got new client connection (id 122)
thread 'tokio-runtime-worker-1' panicked at 'called `Result::unwrap()` on an `Err` value: "PoisonError { inner: .. }"', libcore/result.rs:945:5
Got new client connection (id 123)
thread 'tokio-runtime-worker-1' panicked at 'called `Result::unwrap()` on an `Err` value: "PoisonError { inner: .. }"', libcore/result.rs:945:5
Got new client connection (id 124)
thread 'tokio-runtime-worker-1' panicked at 'called `Result::unwrap()` on an `Err` value: "PoisonError { inner: .. }"', libcore/result.rs:945:5
Got new client connection (id 125)
thread 'tokio-runtime-worker-0' panicked at 'called `Result::unwrap()` on an `Err` value: "PoisonError { inner: .. }"', libcore/result.rs:945:5

Panicked points:

  • at src/pool_client.rs:139
  • at src/pool_client.rs:171
  • at src/pool_client.rs:312
  • at src/stratum_server.rs:742
  • at src/stratum_server.rs:966
  • at src/stratum_server.rs:794
  • at src/stratum_server.rs:493
  • at src/stratum_server.rs:352
  • at src/multi_user_proxy.rs:131
  • at src/work_client.rs:420

Timeouts

Need to timeout connections on server-side stuff.

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.