onemorebsmith / kaspa-stratum-bridge

Bridge/Adapter between the stratum-based miners and a kaspad node
MIT License
67 stars 102 forks source link

Possible to write to log by default - More Stats like when block is hit and hash rate? #5

Closed Chadwicksracing closed 2 years ago

Chadwicksracing commented 2 years ago

Requested improvement

onemorebsmith commented 2 years ago

Yep, looking at adding this soon.. It should already report when a block is hit but I'll look to add hashrate reporting.

Also considering adding discord/telegram hooks for blocks and if a miner disconnects if there's interest there.

Chadwicksracing commented 2 years ago

I hit a few blocks last night, but never got any notification in my miner or the bridge logs. I did this a a quick stop gap for logging.

./kaspabridge >> kaspabridge.log tail -f ./kaspa-stratum-bridge/cmd/kaspabridge/kaspabridge.log

Perhaps it might be easier to integrate into miningcore and use their API that is already built out? I don't know how much work that is, but miningcore has a API that allows you to use a pool ui.

minin https://github.com/minernl/Miningcore.WebUI

onemorebsmith commented 2 years ago

Hmm, ok I'll look at that tonight. Thanks for the feedback

Chadwicksracing commented 2 years ago

image

It does show when blocks are hit.

onemorebsmith commented 2 years ago

Yep, I just confirmed it also image

I'll look at the hashrate reporting tonight but I don't think that's going to be a trivial change

Chadwicksracing commented 2 years ago

Found this js lib for translation of deamon in to js. https://github.com/GateKVite/Kaspajs

Used by kstratum.

onemorebsmith commented 2 years ago

image

Testing this now as a stop-gap til I get an actual webui of some kind

Chadwicksracing commented 2 years ago

incredible. image

Testing on one rig. No shares reporting back to miner. Using SRB.

Amazing how fast you can build this out. I'd love to see this project get put into a pool for community.

I did get this socket error: image

I am running PRD Bridge with DEV on the same server though..

onemorebsmith commented 2 years ago

Oh weird. I'll have to pull SRB down and test. I've been doing everything with lolminer since that's what I was already running. And thanks! Loving the project

Chadwicksracing commented 2 years ago

Just had this too

runtime.goexit() /snap/go/9952/src/runtime/asm_amd64.s:1571 +0x1 fp=0xc00013f7e8 sp=0xc00013f7e0 pc=0x464ca1 created by github.com/onemorebsmith/kaspastratum/src/kaspastratum.(*StratumServer).startBlockTemplateListener.func2 /root/kaspa-stratum-bridge-dev/src/kaspastratum/stratum_server.go:154 +0xcf

goroutine 1 [IO wait, 3 minutes]: internal/poll.runtime_pollWait(0x7f7b74049658, 0x72) /snap/go/9952/src/runtime/netpoll.go:302 +0x89 internal/poll.(pollDesc).wait(0xc00012a180?, 0x5?, 0x0) /snap/go/9952/src/internal/poll/fd_poll_runtime.go:83 +0x32 internal/poll.(pollDesc).waitRead(...) /snap/go/9952/src/internal/poll/fd_poll_runtime.go:88 internal/poll.(FD).Accept(0xc00012a180) /snap/go/9952/src/internal/poll/fd_unix.go:614 +0x22c net.(netFD).accept(0xc00012a180) /snap/go/9952/src/net/fd_unix.go:172 +0x35 net.(TCPListener).accept(0xc00012fb48) /snap/go/9952/src/net/tcpsock_posix.go:139 +0x28 net.(TCPListener).Accept(0xc00012fb48) /snap/go/9952/src/net/tcpsock.go:288 +0x3d github.com/onemorebsmith/kaspastratum/src/kaspastratum.ListenAndServe({{0xc000035538, 0x5}, {0xc000035560, 0xf}, 0x1}) /root/kaspa-stratum-bridge-dev/src/kaspastratum/stratum_server.go:76 +0x2f1 main.main() /root/kaspa-stratum-bridge-dev/cmd/kaspabridge/main.go:36 +0x31b

goroutine 6 [select, 19 minutes]: google.golang.org/grpc.(*ccBalancerWrapper).watcher(0xc00007ee40) /root/go/pkg/mod/google.golang.org/grpc@v1.38.0/balancer_conn_wrappers.go:69 +0x8f created by google.golang.org/grpc.newCCBalancerWrapper /root/go/pkg/mod/google.golang.org/grpc@v1.38.0/balancer_conn_wrappers.go:60 +0x1d0

goroutine 7 [chan receive, 19 minutes]: google.golang.org/grpc.(addrConn).resetTransport(0xc00024e000) /root/go/pkg/mod/google.golang.org/grpc@v1.38.0/clientconn.go:1214 +0x47a created by google.golang.org/grpc.(addrConn).connect /root/go/pkg/mod/google.golang.org/grpc@v1.38.0/clientconn.go:844 +0x145

goroutine 18 [IO wait]: internal/poll.runtime_pollWait(0x7f7b74049748, 0x72) /snap/go/9952/src/runtime/netpoll.go:302 +0x89 internal/poll.(pollDesc).wait(0xc0001a8400?, 0xc00028a000?, 0x0) /snap/go/9952/src/internal/poll/fd_poll_runtime.go:83 +0x32 internal/poll.(pollDesc).waitRead(...) /snap/go/9952/src/internal/poll/fd_poll_runtime.go:88 internal/poll.(FD).Read(0xc0001a8400, {0xc00028a000, 0x8000, 0x8000}) /snap/go/9952/src/internal/poll/fd_unix.go:167 +0x25a net.(netFD).Read(0xc0001a8400, {0xc00028a000?, 0x46ea69?, 0x4385e0?}) /snap/go/9952/src/net/fd_posix.go:55 +0x29 net.(conn).Read(0xc000286000, {0xc00028a000?, 0xc000b9b680?, 0x800010601?}) /snap/go/9952/src/net/net.go:183 +0x45 bufio.(Reader).Read(0xc000282060, {0xc0002a4038, 0x9, 0x18?}) /snap/go/9952/src/bufio/bufio.go:236 +0x1b4 io.ReadAtLeast({0xa139e0, 0xc000282060}, {0xc0002a4038, 0x9, 0x9}, 0x9) /snap/go/9952/src/io/io.go:331 +0x9a io.ReadFull(...) /snap/go/9952/src/io/io.go:350 golang.org/x/net/http2.readFrameHeader({0xc0002a4038?, 0x9?, 0xd901e0?}, {0xa139e0?, 0xc000282060?}) /root/go/pkg/mod/golang.org/x/net@v0.0.0-20210405180319-a5a99cb37ef4/http2/frame.go:237 +0x6e golang.org/x/net/http2.(Framer).ReadFrame(0xc0002a4000) /root/go/pkg/mod/golang.org/x/net@v0.0.0-20210405180319-a5a99cb37ef4/http2/frame.go:492 +0x95 google.golang.org/grpc/internal/transport.(http2Client).reader(0xc0002ac000) /root/go/pkg/mod/google.golang.org/grpc@v1.38.0/internal/transport/http2_client.go:1347 +0x40b created by google.golang.org/grpc/internal/transport.newHTTP2Client /root/go/pkg/mod/google.golang.org/grpc@v1.38.0/internal/transport/http2_client.go:346 +0x187f

goroutine 19 [select]: google.golang.org/grpc/internal/transport.(controlBuffer).get(0xc0002a2050, 0x1) /root/go/pkg/mod/google.golang.org/grpc@v1.38.0/internal/transport/controlbuf.go:407 +0x115 google.golang.org/grpc/internal/transport.(loopyWriter).run(0xc000282120) /root/go/pkg/mod/google.golang.org/grpc@v1.38.0/internal/transport/controlbuf.go:527 +0x85 google.golang.org/grpc/internal/transport.newHTTP2Client.func3() /root/go/pkg/mod/google.golang.org/grpc@v1.38.0/internal/transport/http2_client.go:396 +0x65 created by google.golang.org/grpc/internal/transport.newHTTP2Client /root/go/pkg/mod/google.golang.org/grpc@v1.38.0/internal/transport/http2_client.go:394 +0x1ed1

goroutine 34 [select, 19 minutes]: google.golang.org/grpc.newClientStreamWithParams.func4() /root/go/pkg/mod/google.golang.org/grpc@v1.38.0/stream.go:363 +0x92 created by google.golang.org/grpc.newClientStreamWithParams /root/go/pkg/mod/google.golang.org/grpc@v1.38.0/stream.go:362 +0x1065

goroutine 36 [chan receive]: github.com/kaspanet/kaspad/infrastructure/network/netadapter/router.(Route).Dequeue(0xc00010e2a0) /root/go/pkg/mod/github.com/kaspanet/kaspad@v0.12.4/infrastructure/network/netadapter/router/route.go:88 +0x34 github.com/kaspanet/kaspad/infrastructure/network/rpcclient/grpcclient.(GRPCClient).AttachRouter.func1() /root/go/pkg/mod/github.com/kaspanet/kaspad@v0.12.4/infrastructure/network/rpcclient/grpcclient/grpcclient.go:69 +0x3a github.com/kaspanet/kaspad/util/panics.handleSpawnedFunction(0xc0001aadb0, {0xc0005a2000, 0x4b3, 0x800}, {0x967658?, 0x0?}, 0xc00012e0c0) /root/go/pkg/mod/github.com/kaspanet/kaspad@v0.12.4/util/panics/panics.go:83 +0x26a github.com/kaspanet/kaspad/util/panics.GoroutineWrapperFunc.func1.1() /root/go/pkg/mod/github.com/kaspanet/kaspad@v0.12.4/util/panics/panics.go:32 +0x35 created by github.com/kaspanet/kaspad/util/panics.GoroutineWrapperFunc.func1 /root/go/pkg/mod/github.com/kaspanet/kaspad@v0.12.4/util/panics/panics.go:31 +0xf8

goroutine 37 [select]: google.golang.org/grpc/internal/transport.(recvBufferReader).readClient(0xc0001260a0, {0xc00012e088, 0x5, 0x5}) /root/go/pkg/mod/google.golang.org/grpc@v1.38.0/internal/transport/transport.go:189 +0xa5 google.golang.org/grpc/internal/transport.(recvBufferReader).Read(0xc0001260a0, {0xc00012e088?, 0xc000130000?, 0xc000f8f988?}) /root/go/pkg/mod/google.golang.org/grpc@v1.38.0/internal/transport/transport.go:169 +0x147 google.golang.org/grpc/internal/transport.(transportReader).Read(0xc00010e1e0, {0xc00012e088?, 0xc000f8fa00?, 0x740b47?}) /root/go/pkg/mod/google.golang.org/grpc@v1.38.0/internal/transport/transport.go:483 +0x32 io.ReadAtLeast({0xa16960, 0xc00010e1e0}, {0xc00012e088, 0x5, 0x5}, 0x5) /snap/go/9952/src/io/io.go:331 +0x9a io.ReadFull(...) /snap/go/9952/src/io/io.go:350 google.golang.org/grpc/internal/transport.(Stream).Read(0xc000128240, {0xc00012e088, 0x5, 0x5}) /root/go/pkg/mod/google.golang.org/grpc@v1.38.0/internal/transport/transport.go:467 +0xa5 google.golang.org/grpc.(parser).recvMsg(0xc00012e078, 0x40000000) /root/go/pkg/mod/google.golang.org/grpc@v1.38.0/rpc_util.go:558 +0x47 google.golang.org/grpc.recvAndDecompress(0x0?, 0xc000128240, {0x0, 0x0}, 0x40000000, 0x0, {0xa18f70, 0xc00008a7d0}) /root/go/pkg/mod/google.golang.org/grpc@v1.38.0/rpc_util.go:689 +0x66 google.golang.org/grpc.recv(0xa0?, {0x7f7b74086fc8, 0xdc00f8}, 0xc000f8fc40?, {0x0?, 0x0?}, {0x953ae0, 0xc0005c1fc0}, 0xc0002b1040?, 0x0, ...) /root/go/pkg/mod/google.golang.org/grpc@v1.38.0/rpc_util.go:757 +0x6e google.golang.org/grpc.(csAttempt).recvMsg(0xc00012a000, {0x953ae0?, 0xc0005c1fc0}, 0xc0005c1fc0?) /root/go/pkg/mod/google.golang.org/grpc@v1.38.0/stream.go:957 +0x2b0 google.golang.org/grpc.(clientStream).RecvMsg.func1(0x40727d?) /root/go/pkg/mod/google.golang.org/grpc@v1.38.0/stream.go:808 +0x25 google.golang.org/grpc.(clientStream).withRetry(0xc000128000, 0xc000f8fdd8, 0xc000f8fda8) /root/go/pkg/mod/google.golang.org/grpc@v1.38.0/stream.go:662 +0x2f6 google.golang.org/grpc.(clientStream).RecvMsg(0xc000128000, {0x953ae0?, 0xc0005c1fc0?}) /root/go/pkg/mod/google.golang.org/grpc@v1.38.0/stream.go:807 +0x11f github.com/kaspanet/kaspad/infrastructure/network/netadapter/server/grpcserver/protowire.(rPCMessageStreamClient).Recv(0xc00011a130) /root/go/pkg/mod/github.com/kaspanet/kaspad@v0.12.4/infrastructure/network/netadapter/server/grpcserver/protowire/messages_grpc.pb.go:179 +0x4c github.com/kaspanet/kaspad/infrastructure/network/rpcclient/grpcclient.(GRPCClient).receive(0x464de7?) /root/go/pkg/mod/github.com/kaspanet/kaspad@v0.12.4/infrastructure/network/rpcclient/grpcclient/grpcclient.go:106 +0x22 github.com/kaspanet/kaspad/infrastructure/network/rpcclient/grpcclient.(GRPCClient).AttachRouter.func2() /root/go/pkg/mod/github.com/kaspanet/kaspad@v0.12.4/infrastructure/network/rpcclient/grpcclient/grpcclient.go:83 +0x32 github.com/kaspanet/kaspad/util/panics.handleSpawnedFunction(0xc0001aadb0, {0xc0005a2800, 0x4b3, 0x800}, {0x969947?, 0x0?}, 0xc00012e0d8) /root/go/pkg/mod/github.com/kaspanet/kaspad@v0.12.4/util/panics/panics.go:83 +0x26a github.com/kaspanet/kaspad/util/panics.GoroutineWrapperFunc.func1.1() /root/go/pkg/mod/github.com/kaspanet/kaspad@v0.12.4/util/panics/panics.go:32 +0x35 created by github.com/kaspanet/kaspad/util/panics.GoroutineWrapperFunc.func1 /root/go/pkg/mod/github.com/kaspanet/kaspad@v0.12.4/util/panics/panics.go:31 +0xf8

goroutine 50 [select]: github.com/onemorebsmith/kaspastratum/src/kaspastratum.(*StratumServer).startBlockTemplateListener(0xc0002327e0) /root/kaspa-stratum-bridge-dev/src/kaspastratum/stratum_server.go:161 +0x14f created by github.com/onemorebsmith/kaspastratum/src/kaspastratum.ListenAndServe /root/kaspa-stratum-bridge-dev/src/kaspastratum/stratum_server.go:62 +0x1b7

goroutine 51 [sleep]: time.Sleep(0x2540be400) /snap/go/9952/src/runtime/time.go:194 +0x12e github.com/onemorebsmith/kaspastratum/src/kaspastratum.(*StratumServer).startStatsThread(0xc0002327e0) /root/kaspa-stratum-bridge-dev/src/kaspastratum/stratum_server.go:189 +0x99 created by github.com/onemorebsmith/kaspastratum/src/kaspastratum.ListenAndServe /root/kaspa-stratum-bridge-dev/src/kaspastratum/stratum_server.go:72 +0x27a

goroutine 52 [chan receive]: github.com/kaspanet/kaspad/infrastructure/network/netadapter/router.(Route).Dequeue(0xc00010f170) /root/go/pkg/mod/github.com/kaspanet/kaspad@v0.12.4/infrastructure/network/netadapter/router/route.go:88 +0x34 github.com/kaspanet/kaspad/infrastructure/network/rpcclient.(RPCClient).RegisterForNewBlockTemplateNotifications.func1() /root/go/pkg/mod/github.com/kaspanet/kaspad@v0.12.4/infrastructure/network/rpcclient/rpc_on_new_block_template.go:26 +0x5f github.com/kaspanet/kaspad/util/panics.handleSpawnedFunction(0xc0001aadb0, {0xc0000d8400, 0x37e, 0x400}, {0x96cc37?, 0x0?}, 0xc00000e480) /root/go/pkg/mod/github.com/kaspanet/kaspad@v0.12.4/util/panics/panics.go:83 +0x26a github.com/kaspanet/kaspad/util/panics.GoroutineWrapperFunc.func1.1() /root/go/pkg/mod/github.com/kaspanet/kaspad@v0.12.4/util/panics/panics.go:32 +0x35 created by github.com/kaspanet/kaspad/util/panics.GoroutineWrapperFunc.func1 /root/go/pkg/mod/github.com/kaspanet/kaspad@v0.12.4/util/panics/panics.go:31 +0xf8

goroutine 1384 [IO wait, 1 minutes]: internal/poll.runtime_pollWait(0x7f7b74049568, 0x72) /snap/go/9952/src/runtime/netpoll.go:302 +0x89 internal/poll.(pollDesc).wait(0xc000683300?, 0xc000ab4c00?, 0x0) /snap/go/9952/src/internal/poll/fd_poll_runtime.go:83 +0x32 internal/poll.(pollDesc).waitRead(...) /snap/go/9952/src/internal/poll/fd_poll_runtime.go:88 internal/poll.(FD).Read(0xc000683300, {0xc000ab4c00, 0x400, 0x400}) /snap/go/9952/src/internal/poll/fd_unix.go:167 +0x25a net.(netFD).Read(0xc000683300, {0xc000ab4c00?, 0xc000aabe40?, 0x44bdf2?}) /snap/go/9952/src/net/fd_posix.go:55 +0x29 net.(conn).Read(0xc000011868, {0xc000ab4c00?, 0xc000aabf00?, 0x8180cb?}) /snap/go/9952/src/net/net.go:183 +0x45 github.com/onemorebsmith/kaspastratum/src/kaspastratum.(MinerConnection).listen(0xc0002e8ab0) /root/kaspa-stratum-bridge-dev/src/kaspastratum/mining_client.go:50 +0x70 github.com/onemorebsmith/kaspastratum/src/kaspastratum.(MinerConnection).RunStratum(0xc0002e8ab0, 0xc0002e8870?) /root/kaspa-stratum-bridge-dev/src/kaspastratum/mining_client.go:82 +0x3d created by github.com/onemorebsmith/kaspastratum/src/kaspastratum.(StratumServer).spawnClient /root/kaspa-stratum-bridge-dev/src/kaspastratum/stratum_server.go:45 +0x10d

goroutine 1557 [runnable]: golang.org/x/crypto/blake2b.(digest).Write(0xc000690c00, {0xc00026e280?, 0x20, 0x40?}) /root/go/pkg/mod/golang.org/x/crypto@v0.0.0-20210513164829-c07d793c2f9a/blake2b/blake2b.go:215 +0x291 github.com/onemorebsmith/kaspastratum/src/kaspastratum.writeHexString({0xa1bd30, 0xc000690c00}, {0xc00026aec0?, 0x2?}) /root/kaspa-stratum-bridge-dev/src/kaspastratum/hasher.go:142 +0x6d github.com/onemorebsmith/kaspastratum/src/kaspastratum.SerializeBlockHeader(0xc000696b10) /root/kaspa-stratum-bridge-dev/src/kaspastratum/hasher.go:25 +0x525 github.com/onemorebsmith/kaspastratum/src/kaspastratum.(MinerConnection).NewBlockAvailable(0xc0002e8ab0) /root/kaspa-stratum-bridge-dev/src/kaspastratum/mining_client.go:268 +0x2c5 created by github.com/onemorebsmith/kaspastratum/src/kaspastratum.(*StratumServer).startBlockTemplateListener.func2 /root/kaspa-stratum-bridge-dev/src/kaspastratum/stratum_server.go:154 +0xcf

onemorebsmith commented 2 years ago

💀 Let me look.

onemorebsmith commented 2 years ago

Should be fixed now, lmk if you see it again.

Chadwicksracing commented 2 years ago

I just rebuilt. Will run for a while now and check back