Skip to content

Commit

Permalink
pool: Remove code related to Antminer DR3.
Browse files Browse the repository at this point in the history
The Antimner DR3 is no longer supported since it mines blake256 and the
hash algorithm is now blake3.
  • Loading branch information
davecgh committed Sep 29, 2023
1 parent 459d30e commit 41413e1
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 198 deletions.
4 changes: 0 additions & 4 deletions internal/gui/assets/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,6 @@ <h2>Identify the Miner</h2>
rel="noopener noreferrer"
href="http://www.innosilicon.com.cn/download/d9_20190521_071217.swu">Innosilicon&nbsp;D9</a>
</li>
<li><a
rel="noopener noreferrer"
href="https://file12.bitmain.com/shop-product/firmware/Antminer%20DR3/Firmware/007201907271437364778LxDsS1k06AF/Antminer-DR3-201907161805-410M.tar.gz">Antminer&nbsp;DR3</a>
</li>
<li><a
rel="noopener noreferrer"
href="https://mining.obelisk.tech/downloads/firmware/obelisk-sc1-v1.3.2.img">Obelisk&nbsp;DCR1</a>
Expand Down
52 changes: 0 additions & 52 deletions pool/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,18 +420,6 @@ func (c *Client) handleSubscribeRequest(req *Request, allowed bool) error {
resp = SubscribeResponse(*req.ID, nid, c.extraNonce1,
ExtraNonce2Size, nil)

case AntminerDR3:
// The DR3 is not fully complaint with the stratum spec.
// It uses an 8-byte extraNonce2 regardless of the
// extraNonce2Size provided.
//
// The extraNonce1 is appended to the extraNonce2 in the
// extraNonce2 value returned in mining.submit. As a result,
// the extraNonce1 sent in mining.subscribe response is formatted as:
// extraNonce2 space (8-byte) + miner's extraNonce1 (4-byte)
paddedExtraNonce1 := strings.Repeat("0", 16) + c.extraNonce1
resp = SubscribeResponse(*req.ID, nid, paddedExtraNonce1, 8, nil)

default:
// The default case handles mining clients that support the
// stratum spec and respect the extraNonce2Size provided.
Expand Down Expand Up @@ -921,42 +909,6 @@ func hexReversed(in string) (string, error) {
return buf.String(), nil
}

// handleAntminerDR3 prepares work notifications for the Antminer DR3.
func (c *Client) handleAntminerDR3Work(req *Request) {
miner := "AntminerDR3"
jobID, prevBlock, genTx1, genTx2, blockVersion, nBits, nTime,
cleanJob, err := ParseWorkNotification(req)
if err != nil {
log.Errorf("%s: %v", miner, err)
}

// The DR3 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())
}

// handleInnosiliconD9Work prepares work notifications for the Innosilicon D9.
func (c *Client) handleInnosiliconD9Work(req *Request) {
miner := "InnosiliconD9"
Expand Down Expand Up @@ -1209,10 +1161,6 @@ func (c *Client) send() {
c.handleCPUWork(req)
log.Tracef("%s notified of new work", id)

case AntminerDR3:
c.handleAntminerDR3Work(req)
log.Tracef("%s notified of new work", id)

case InnosiliconD9:
c.handleInnosiliconD9Work(req)
log.Tracef("%s notified of new work", id)
Expand Down
106 changes: 2 additions & 104 deletions pool/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,43 +375,6 @@ func testClientMessageHandling(t *testing.T) {
t.Fatalf("expected %s message method, got %s", SetDifficulty, req.Method)
}

// Ensure an Antminer DR3 client receives a valid non-error
// response when a valid subscribe request is sent.
err = setMiner(client, AntminerDR3)
if err != nil {
t.Fatalf("unexpected set miner error: %v", err)
}

id++
dr3, dr3Version := splitMinerID(dr3ID)
r = SubscribeRequest(&id, userAgent(dr3, dr3Version), "")
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 response with id %d, got %d", *r.ID, resp.ID)
}
if resp.ID != *r.ID {
t.Fatalf("expected 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 an Obelisk DCR1 client receives a valid non-error
// response when a valid subscribe request is sent.
err = setMiner(client, ObeliskDCR1)
Expand Down Expand Up @@ -647,36 +610,6 @@ func testClientMessageHandling(t *testing.T) {
t.Fatalf("[claimWeightedShare (D9)] unexpected error: %v", err)
}

// Send a work notification to an Antminer DR3 client.
err = setMiner(client, AntminerDR3)
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 DR3.
var dr3Work []byte
select {
case <-client.ctx.Done():
t.Fatalf("client context done: %v", err)
case dr3Work = <-recvCh:
}
if !bytes.Equal(dr3Work, d9Work) {
t.Fatalf("expected antminer dr3 work to be equal to innosilicon d9 " +
"work")
}

// Claim a weighted share for the Antminer DR3.
err = client.claimWeightedShare()
if err != nil {
t.Fatalf("[claimWeightedShare (DR3)] unexpected error: %v", err)
}

// Send a work notification to an Obelisk DCR1 client.
err = setMiner(client, ObeliskDCR1)
if err != nil {
Expand All @@ -696,9 +629,8 @@ func testClientMessageHandling(t *testing.T) {
t.Fatalf("client context done: %v", err)
case dcr1Work = <-recvCh:
}
if !bytes.Equal(dr3Work, dcr1Work) {
t.Fatalf("expected obelisk DCR1 work to be different from " +
"antminer dr3 work")
if bytes.Equal(cpuWork, dcr1Work) {
t.Fatalf("expected obelisk DCR1 work to be different from cpu work")
}

// Claim a weighted share for the Obelisk DCR1.
Expand Down Expand Up @@ -1006,40 +938,6 @@ func testClientMessageHandling(t *testing.T) {
t.Fatalf("expected no-error work submission response, got %v", resp.Error)
}

// Ensure the pool processes Antminer DR3 work submissions.
err = setMiner(client, AntminerDR3)
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 dr3Sub []byte
select {
case <-client.ctx.Done():
t.Fatalf("client context done: %v", err)
case dr3Sub = <-recvCh:
}
msg, mType, err = IdentifyMessage(dr3Sub)
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 Innosilicon D9 work submissions.
err = setMiner(client, InnosiliconD9)
if err != nil {
Expand Down
2 changes: 0 additions & 2 deletions pool/difficulty.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
const (
CPU = "cpu"
InnosiliconD9 = "innosilicond9"
AntminerDR3 = "antminerdr3"
ObeliskDCR1 = "obeliskdcr1"
NiceHashValidator = "nicehash"
)
Expand All @@ -32,7 +31,6 @@ var (
CPU: new(big.Int).SetInt64(5e3),
ObeliskDCR1: new(big.Int).SetInt64(1.2e12),
InnosiliconD9: new(big.Int).SetInt64(2.4e12),
AntminerDR3: new(big.Int).SetInt64(7.8e12),
NiceHashValidator: new(big.Int).SetInt64(20e10),
}
)
Expand Down
24 changes: 10 additions & 14 deletions pool/difficulty_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,20 +73,16 @@ func TestDifficulty(t *testing.T) {
diffSet := []struct {
miner string
expectedErr error
}{
{
miner: CPU,
expectedErr: nil,
},
{
miner: "",
expectedErr: errs.ValueNotFound,
},
{
miner: "antminerdr7",
expectedErr: errs.ValueNotFound,
},
}
}{{
miner: CPU,
expectedErr: nil,
}, {
miner: "",
expectedErr: errs.ValueNotFound,
}, {
miner: "non-existent",
expectedErr: errs.ValueNotFound,
}}

for idx, tc := range diffSet {
net := chaincfg.SimNetParams()
Expand Down
18 changes: 0 additions & 18 deletions pool/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -626,24 +626,6 @@ func GenerateSolvedBlockHeader(headerE string, extraNonce1E string,
copy(headerEB[288:296], []byte(extraNonce1E))
copy(headerEB[296:304], []byte(extraNonce2E))

// The Antiminer DR3 returns a 12-byte extraNonce comprised of the
// extraNonce1 and extraNonce2 regardless of the extraNonce2Size specified
// in the mining.subscribe message. The nTime and nonce values submitted are
// big endian, they have to be reversed before block header reconstruction.
case AntminerDR3:
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:312], []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
Expand Down
3 changes: 0 additions & 3 deletions pool/miner_id.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ var (
cpuID = "cpuminer/1.0.0"
dcr1ID = "cgminer/4.10.0"
d9ID = "sgminer/4.4.2"
dr3ID = "cgminer/4.9.0"
nhID = "NiceHash/1.0.0"
)

Expand Down Expand Up @@ -47,13 +46,11 @@ func generateMinerIDs() map[string]*minerIDPair {
cpu := newMinerIDPair(cpuID, CPU)
obelisk := newMinerIDPair(dcr1ID, ObeliskDCR1)
innosilicon := newMinerIDPair(d9ID, InnosiliconD9)
antminer := newMinerIDPair(dr3ID, AntminerDR3)
nicehash := newMinerIDPair(nhID, NiceHashValidator)

ids[cpu.id] = cpu
ids[obelisk.id] = obelisk
ids[innosilicon.id] = innosilicon
ids[antminer.id] = antminer
ids[nicehash.id] = nicehash
return ids
}
Expand Down
1 change: 0 additions & 1 deletion pool/share.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ 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),
AntminerDR3: new(big.Rat).SetFloat64(7.091),
}

// shareID generates a unique share id using the provided account, creation
Expand Down

0 comments on commit 41413e1

Please sign in to comment.