From 7bd28ff455b805e5043e1627dd42714760357745 Mon Sep 17 00:00:00 2001
From: Dave Collins
Date: Thu, 28 Sep 2023 17:46:58 -0500
Subject: [PATCH] pool: Remove code related to Innosilicon D9.
The Innosilicon D9 is no longer supported since it mines blake256 and
the hash algorithm is now blake3.
---
internal/gui/assets/templates/index.html | 5 --
pool/client.go | 40 ---------
pool/client_test.go | 100 -----------------------
pool/difficulty.go | 2 -
pool/message.go | 20 -----
pool/miner_id.go | 3 -
pool/share.go | 5 +-
7 files changed, 2 insertions(+), 173 deletions(-)
diff --git a/internal/gui/assets/templates/index.html b/internal/gui/assets/templates/index.html
index 3e0a88bb..59b32233 100644
--- a/internal/gui/assets/templates/index.html
+++ b/internal/gui/assets/templates/index.html
@@ -63,11 +63,6 @@ Identify the Miner
- -
- Innosilicon D9
-
- Obelisk DCR1
diff --git a/pool/client.go b/pool/client.go
index d401833c..8c8f757a 100644
--- a/pool/client.go
+++ b/pool/client.go
@@ -909,42 +909,6 @@ func hexReversed(in string) (string, error) {
return buf.String(), nil
}
-// handleInnosiliconD9Work prepares work notifications for the Innosilicon D9.
-func (c *Client) handleInnosiliconD9Work(req *Request) {
- miner := "InnosiliconD9"
- jobID, prevBlock, genTx1, genTx2, blockVersion, nBits, nTime,
- cleanJob, err := ParseWorkNotification(req)
- if err != nil {
- log.Errorf("%s: %v", miner, err)
- }
-
- // The D9 requires the nBits and nTime fields of a mining.notify message
- // as big endian.
- nBits, err = hexReversed(nBits)
- if err != nil {
- log.Errorf("%s: %v for nBits", miner, err)
- c.cancel()
- return
- }
- nTime, err = hexReversed(nTime)
- if err != nil {
- log.Errorf("%s: %v for nTime", miner, err)
- c.cancel()
- return
- }
- prevBlockRev := reversePrevBlockWords(prevBlock)
- workNotif := WorkNotification(jobID, prevBlockRev,
- genTx1, genTx2, blockVersion, nBits, nTime, cleanJob)
- err = c.encoder.Encode(workNotif)
- if err != nil {
- log.Errorf("%s: work encoding error, %v", miner, err)
- c.cancel()
- return
- }
-
- atomic.StoreInt64(&c.lastWorkTime, time.Now().Unix())
-}
-
// handleCPUWork prepares work for the cpu miner.
func (c *Client) handleCPUWork(req *Request) {
const miner = "CPU"
@@ -1161,10 +1125,6 @@ func (c *Client) send() {
c.handleCPUWork(req)
log.Tracef("%s notified of new work", id)
- case InnosiliconD9:
- c.handleInnosiliconD9Work(req)
- log.Tracef("%s notified of new work", id)
-
case ObeliskDCR1:
c.handleObeliskDCR1Work(req)
log.Tracef("%s notified of new work", id)
diff --git a/pool/client_test.go b/pool/client_test.go
index ee711c5b..93b31c94 100644
--- a/pool/client_test.go
+++ b/pool/client_test.go
@@ -412,43 +412,6 @@ func testClientMessageHandling(t *testing.T) {
t.Fatalf("expected a non-error response, got %s", resp.Error.Message)
}
- // Ensure an Innosilicon D9 client receives a valid non-error
- // response when a valid subscribe request is sent.
- err = setMiner(client, InnosiliconD9)
- if err != nil {
- t.Fatalf("unexpected set miner error: %v", err)
- }
-
- id++
- d9, d9Version := splitMinerID(d9ID)
- r = SubscribeRequest(&id, userAgent(d9, d9Version), "")
- err = sE.Encode(r)
- if err != nil {
- t.Fatalf("[Encode] unexpected error: %v", err)
- }
- select {
- case <-client.ctx.Done():
- t.Fatalf("client context done: %v", err)
- case data = <-recvCh:
- }
- msg, mType, err = IdentifyMessage(data)
- if err != nil {
- t.Fatalf("[IdentifyMessage] unexpected error: %v", err)
- }
- if mType != ResponseMessage {
- t.Fatalf("expected a subscribe response message, got %v", mType)
- }
- resp, ok = msg.(*Response)
- if !ok {
- t.Fatalf("expected subsribe response with id %d, got %d", *r.ID, resp.ID)
- }
- if resp.ID != *r.ID {
- t.Fatalf("expected subscribe response with id %d, got %d", *r.ID, resp.ID)
- }
- if resp.Error != nil {
- t.Fatalf("expected a non-error response, got %s", resp.Error.Message)
- }
-
// Ensure a CPU client receives a valid non-error response when a
// valid subscribe request is sent.
err = setMiner(client, CPU)
@@ -581,35 +544,6 @@ func testClientMessageHandling(t *testing.T) {
client.lastWorkTime)
}
- // Send a work notification to an Innosilicon D9 client.
- err = setMiner(client, InnosiliconD9)
- if err != nil {
- t.Fatalf("unexpected set miner error: %v", err)
- }
-
- select {
- case <-client.ctx.Done():
- t.Fatalf("client context done: %v", err)
- case client.ch <- r:
- }
-
- // Ensure the work notification received is unique to the D9.
- var d9Work []byte
- select {
- case <-client.ctx.Done():
- t.Fatalf("client context done: %v", err)
- case d9Work = <-recvCh:
- }
- if bytes.Equal(cpuWork, d9Work) {
- t.Fatalf("expected innosilicond9 work to be different from cpu work")
- }
-
- // Claim a weighted share for the Innosilicon D9 client.
- err = client.claimWeightedShare()
- if err != nil {
- t.Fatalf("[claimWeightedShare (D9)] unexpected error: %v", err)
- }
-
// Send a work notification to an Obelisk DCR1 client.
err = setMiner(client, ObeliskDCR1)
if err != nil {
@@ -938,40 +872,6 @@ func testClientMessageHandling(t *testing.T) {
t.Fatalf("expected no-error work submission response, got %v", resp.Error)
}
- // Ensure the pool processes Innosilicon D9 work submissions.
- err = setMiner(client, InnosiliconD9)
- if err != nil {
- t.Fatalf("unexpected set miner error: %v", err)
- }
-
- id++
- sub = SubmitWorkRequest(&id, "tcl", job.UUID, "00000000",
- "954cee5d", "6ddf0200")
- err = sE.Encode(sub)
- if err != nil {
- t.Fatalf("[Encode] unexpected error: %v", err)
- }
- var d9Sub []byte
- select {
- case <-client.ctx.Done():
- t.Fatalf("client context done: %v", err)
- case d9Sub = <-recvCh:
- }
- msg, mType, err = IdentifyMessage(d9Sub)
- if err != nil {
- t.Fatalf("[IdentifyMessage] unexpected error: %v", err)
- }
- if mType != ResponseMessage {
- t.Fatalf("expected a response message, got %v", mType)
- }
- resp, ok = msg.(*Response)
- if !ok {
- t.Fatalf("unable to cast message as response")
- }
- if resp.ID != *sub.ID {
- t.Fatalf("expected a response with id %d, got %d", *sub.ID, resp.ID)
- }
-
// Ensure the pool processes Obelisk DCR1 work submissions.
err = setMiner(client, ObeliskDCR1)
if err != nil {
diff --git a/pool/difficulty.go b/pool/difficulty.go
index 801b1410..bf1c6a76 100644
--- a/pool/difficulty.go
+++ b/pool/difficulty.go
@@ -19,7 +19,6 @@ import (
// Supported mining clients.
const (
CPU = "cpu"
- InnosiliconD9 = "innosilicond9"
ObeliskDCR1 = "obeliskdcr1"
NiceHashValidator = "nicehash"
)
@@ -30,7 +29,6 @@ var (
minerHashes = map[string]*big.Int{
CPU: new(big.Int).SetInt64(5e3),
ObeliskDCR1: new(big.Int).SetInt64(1.2e12),
- InnosiliconD9: new(big.Int).SetInt64(2.4e12),
NiceHashValidator: new(big.Int).SetInt64(20e10),
}
)
diff --git a/pool/message.go b/pool/message.go
index cac1a9f3..f7dae635 100644
--- a/pool/message.go
+++ b/pool/message.go
@@ -626,26 +626,6 @@ func GenerateSolvedBlockHeader(headerE string, extraNonce1E string,
copy(headerEB[288:296], []byte(extraNonce1E))
copy(headerEB[296:304], []byte(extraNonce2E))
- // The Innosilicon D9 respects the extraNonce2Size specified in the
- // mining.subscribe response sent to it. The extraNonce2 value submitted is
- // exclusively the extraNonce2. The nTime and nonce values submitted are
- // big endian, they have to be reversed to little endian before header
- // reconstruction.
- case InnosiliconD9:
- nTimeERev, err := hexReversed(nTimeE)
- if err != nil {
- return nil, err
- }
- copy(headerEB[272:280], []byte(nTimeERev))
-
- nonceERev, err := hexReversed(nonceE)
- if err != nil {
- return nil, err
- }
- copy(headerEB[280:288], []byte(nonceERev))
- copy(headerEB[288:296], []byte(extraNonce1E))
- copy(headerEB[296:304], []byte(extraNonce2E))
-
default:
desc := fmt.Sprintf("miner %s is unknown", miner)
return nil, errs.MsgError(errs.MinerUnknown, desc)
diff --git a/pool/miner_id.go b/pool/miner_id.go
index 8bb19096..8b9dcd5e 100644
--- a/pool/miner_id.go
+++ b/pool/miner_id.go
@@ -16,7 +16,6 @@ var (
cpuID = "cpuminer/1.0.0"
dcr1ID = "cgminer/4.10.0"
- d9ID = "sgminer/4.4.2"
nhID = "NiceHash/1.0.0"
)
@@ -45,12 +44,10 @@ func generateMinerIDs() map[string]*minerIDPair {
ids := make(map[string]*minerIDPair)
cpu := newMinerIDPair(cpuID, CPU)
obelisk := newMinerIDPair(dcr1ID, ObeliskDCR1)
- innosilicon := newMinerIDPair(d9ID, InnosiliconD9)
nicehash := newMinerIDPair(nhID, NiceHashValidator)
ids[cpu.id] = cpu
ids[obelisk.id] = obelisk
- ids[innosilicon.id] = innosilicon
ids[nicehash.id] = nicehash
return ids
}
diff --git a/pool/share.go b/pool/share.go
index c6f1ddc9..87b9c4b0 100644
--- a/pool/share.go
+++ b/pool/share.go
@@ -18,9 +18,8 @@ import (
//
// (Hash of Miner X * Weight of LHM)/ Hash of LHM
var ShareWeights = map[string]*big.Rat{
- CPU: new(big.Rat).SetFloat64(1.0), // Reserved for testing.
- ObeliskDCR1: new(big.Rat).SetFloat64(1.0),
- InnosiliconD9: new(big.Rat).SetFloat64(2.182),
+ CPU: new(big.Rat).SetFloat64(1.0), // Reserved for testing.
+ ObeliskDCR1: new(big.Rat).SetFloat64(1.0),
}
// shareID generates a unique share id using the provided account, creation