Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
yuriy0803 committed May 12, 2024
1 parent 039bd41 commit cff9a22
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 42 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
11 changes: 8 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module github.com/yuriy0803/open-etc-pool-friends

go 1.19
go 1.21

toolchain go1.21.5

require (
github.com/gorilla/mux v1.8.1
Expand All @@ -12,17 +14,20 @@ require (
)

require (
github.com/Rethereum-blockchain/ethashb3 v0.0.0-20230804001014-cdc9d7e630df // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
github.com/edsrzf/mmap-go v1.1.0 // indirect
github.com/ethereum/go-ethereum v1.14.3 // indirect
github.com/garyburd/redigo v1.6.4 // indirect
github.com/go-stack/stack v1.8.1 // indirect
github.com/holiman/uint256 v1.2.4 // indirect
github.com/onsi/ginkgo v1.16.5 // indirect
github.com/onsi/gomega v1.30.0 // indirect
github.com/yuriy0803/ethashb3 v0.0.0-20230823074102-1054b1192e82 // indirect
github.com/yvasiyarov/go-metrics v0.0.0-20150112132944-c25f46c4b940 // indirect
github.com/yvasiyarov/newrelic_platform_go v0.0.0-20160601141957-9c099fbc30e9 // indirect
golang.org/x/crypto v0.17.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/crypto v0.22.0 // indirect
golang.org/x/sys v0.19.0 // indirect
gopkg.in/bsm/ratelimit.v1 v1.0.0-20170922094635-f56db5e73a5e // indirect
)
11 changes: 11 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
github.com/Rethereum-blockchain/ethashb3 v0.0.0-20230804001014-cdc9d7e630df h1:kKkwVKcN3yvhXPBBtE5rzwTihX3r905t6jt8We25sFc=
github.com/Rethereum-blockchain/ethashb3 v0.0.0-20230804001014-cdc9d7e630df/go.mod h1:ESTs1L5emd+CQ2FJ9bgnYfo542lcugWqYCqvAKdpESw=
github.com/btcsuite/btcd/btcec/v2 v2.3.2 h1:5n0X6hX0Zk+6omWcihdYvdAlGf2DfasC0GMf7DClJ3U=
github.com/btcsuite/btcd/btcec/v2 v2.3.2/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04=
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U=
Expand All @@ -9,6 +11,8 @@ github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etly
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0=
github.com/edsrzf/mmap-go v1.1.0 h1:6EUwBLQ/Mcr1EYLE4Tn1VdW1A4ckqCQWZBw8Hr0kjpQ=
github.com/edsrzf/mmap-go v1.1.0/go.mod h1:19H/e8pUPLicwkyNgOykDXkJ9F0MHE+Z52B8EIth78Q=
github.com/ethereum/go-ethereum v1.14.3 h1:5zvnAqLtnCZrU9uod1JCvHWJbPMURzYFHfc2eHz4PHA=
github.com/ethereum/go-ethereum v1.14.3/go.mod h1:1STrq471D0BQbCX9He0hUj4bHxX2k6mt5nOQJhDNOJ8=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
Expand Down Expand Up @@ -54,6 +58,8 @@ github.com/yuriy0803/core-geth1 v1.12.18-0.20231209165046-f7272fa572bc h1:Q8sHdu
github.com/yuriy0803/core-geth1 v1.12.18-0.20231209165046-f7272fa572bc/go.mod h1:yf10EqBwKdsy8nnhlSvJFXwzhBh0/btBez47+g+faY8=
github.com/yuriy0803/etchash v1.0.0 h1:Af8/9jkJfdSqkffYbOR8BViXOa2j4Keqv48syka1lwA=
github.com/yuriy0803/etchash v1.0.0/go.mod h1:9q4LZ8KkbmmyS8FUEdCnTeA+sWohK70OyJlzewfcLMk=
github.com/yuriy0803/ethashb3 v0.0.0-20230823074102-1054b1192e82 h1:jMTXeFylCqnhUT+Lh06zQncvDJd4zoWuVfBI+hVJgpw=
github.com/yuriy0803/ethashb3 v0.0.0-20230823074102-1054b1192e82/go.mod h1:NbRy4O4ShVk1CP18yejZFbK0wdMZnxpgHIA8ZVn0lJ4=
github.com/yvasiyarov/go-metrics v0.0.0-20150112132944-c25f46c4b940 h1:p7OofyZ509h8DmPLh8Hn+EIIZm/xYhdZHJ9GnXHdr6U=
github.com/yvasiyarov/go-metrics v0.0.0-20150112132944-c25f46c4b940/go.mod h1:aX5oPXxHm3bOH+xeAttToC8pqch2ScQN/JoXYupl6xs=
github.com/yvasiyarov/gorelic v0.0.7 h1:4DTF1WOM2ZZS/xMOkTFBOcb6XiHu/PKn3rVo6dbewQE=
Expand All @@ -65,13 +71,16 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k=
golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30=
golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
Expand All @@ -86,6 +95,8 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
Expand Down
17 changes: 8 additions & 9 deletions proxy/blocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"strings"
"sync"

"github.com/yuriy0803/core-geth1/common"
"github.com/yuriy0803/open-etc-pool-friends/rpc"
"github.com/yuriy0803/open-etc-pool-friends/util"
)
Expand All @@ -26,24 +25,24 @@ type BlockTemplate struct {
Target string
Difficulty *big.Int
Height uint64
GetPendingBlockCache *rpc.GetBlockReplyPart
GetPendingBlockCache *rpc.GetBlockReplyPart // Assuming this type is defined elsewhere
nonces map[string]bool
headers map[string]heightDiffPair
}

type Block struct {
difficulty *big.Int
hashNoNonce common.Hash
hashNoNonce string // Replacing common.Hash with string
nonce uint64
mixDigest common.Hash
mixDigest string // Replacing common.Hash with string
number uint64
}

func (b Block) Difficulty() *big.Int { return b.difficulty }
func (b Block) HashNoNonce() common.Hash { return b.hashNoNonce }
func (b Block) Nonce() uint64 { return b.nonce }
func (b Block) MixDigest() common.Hash { return b.mixDigest }
func (b Block) NumberU64() uint64 { return b.number }
func (b Block) Difficulty() *big.Int { return b.difficulty }
func (b Block) HashNoNonce() string { return b.hashNoNonce }
func (b Block) Nonce() uint64 { return b.nonce }
func (b Block) MixDigest() string { return b.mixDigest }
func (b Block) NumberU64() uint64 { return b.number }

func (s *ProxyServer) fetchBlockTemplate() {
rpc := s.rpc()
Expand Down
37 changes: 7 additions & 30 deletions proxy/miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,18 @@ import (
"strconv"
"strings"

"github.com/yuriy0803/core-geth1/common"
"github.com/yuriy0803/etchash"
"github.com/ethereum/go-ethereum/common"
ethash "github.com/yuriy0803/ethashb3"
"github.com/yuriy0803/open-etc-pool-friends/util"
)

var (
maxUint256 = new(big.Int).Exp(big.NewInt(2), big.NewInt(256), big.NewInt(0))
ecip1099FBlockClassic uint64 = 11700000 // classic mainnet
ecip1099FBlockMordor uint64 = 2520000 // mordor
uip1FEpoch uint64 = 22 // ubiq mainnet
xip5Block uint64 = 0 // expanse rebirth network
hasher *etchash.Etchash = nil
maxUint256 = new(big.Int).Exp(big.NewInt(2), big.NewInt(256), big.NewInt(0))
)

func (s *ProxyServer) processShare(login, id, ip string, t *BlockTemplate, params []string, stratum bool) (bool, bool) {
var hasher = ethash.New()

if hasher == nil {
if s.config.Network == "expanse" || s.config.Network == "rebirth" {
hasher = etchash.New(nil, nil, &xip5Block)
} else if s.config.Network == "classic" {
hasher = etchash.New(&ecip1099FBlockClassic, nil, nil)
} else if s.config.Network == "mordor" {
hasher = etchash.New(&ecip1099FBlockMordor, nil, nil)
} else if s.config.Network == "ubiq" {
hasher = etchash.New(nil, &uip1FEpoch, nil)
} else if s.config.Network == "ethereum" || s.config.Network == "ropsten" || s.config.Network == "ethereumPow" ||
s.config.Network == "ethereumFair" || s.config.Network == "etica" ||
s.config.Network == "octaspace" || s.config.Network == "universal" || s.config.Network == "canxium" {
hasher = etchash.New(nil, nil, nil)
} else {
// unknown network
log.Printf("Unknown network configuration %s", s.config.Network)
return false, false
}
}
func (s *ProxyServer) processShare(login, id, ip string, t *BlockTemplate, params []string, stratum bool) (bool, bool) {

nonceHex := params[0]
hashNoNonce := params[1]
Expand All @@ -53,14 +30,14 @@ func (s *ProxyServer) processShare(login, id, ip string, t *BlockTemplate, param
if stratum {
hashNoNonceTmp := common.HexToHash(params[2])

mixDigestTmp, hashTmp := hasher.Compute(t.Height, hashNoNonceTmp, nonce)
_, mixDigestTmp, hashTmp := hasher.Compute(t.Height, hashNoNonceTmp, nonce)
params[1] = hashNoNonceTmp.Hex()
params[2] = mixDigestTmp.Hex()
hashNoNonce = params[1]
result = hashTmp
} else {
hashNoNonceTmp := common.HexToHash(hashNoNonce)
mixDigestTmp, hashTmp := hasher.Compute(t.Height, hashNoNonceTmp, nonce)
_, mixDigestTmp, hashTmp := hasher.Compute(t.Height, hashNoNonceTmp, nonce)

// check mixDigest
if mixDigestTmp.Hex() != mixDigest {
Expand Down

0 comments on commit cff9a22

Please sign in to comment.