blockcypher / libgrin Goto Github PK
View Code? Open in Web Editor NEWGo utility libraries for Grin
License: Apache License 2.0
Go utility libraries for Grin
License: Apache License 2.0
I'm trying to use this library to verify miner shares, but it's logging the error "endpoints don't match"
This is my application log:
Receive work from miner:
In: {"id":"0","jsonrpc":"2.0","method":"submit","params":{"edge_bits":29,"height":100455,"job_id":6,"nonce":16079481998891884557,"pow":[4950556,10444042,26994871,63816933,64006601,70454862,74408437,101859857,103156578,103619764,110918645,112676394,156469828,164995210,177571941,197003830,206258400,232973126,235492427,243875402,250871506,261431148,294643091,315606197,320713204,328097841,331983190,340029134,341429798,349593608,352254617,363452582,376534642,385998553,399426703,399588750,417560407,418344217,464144305,478639713,500541067,511159362]}}
Convert prepow to byte slice (to use with VerifyShare)
DEBU[Apr 1 13:03:56.232566739] JobId 6
DEBU[Apr 1 13:03:56.232672438] prepow: 00010000000000018867000000005ca1f0170b36068977d5b53e8cc9b9d84441a55d375a3462511bb9ecc9d204db5c83f61675a3d19e6b459e6f2152f080fa72d1b2a08046c976a46a89c712b7fbccd0eefed6eb43dd1a16aff97c41c31714a98c2dbb8cc147064a433995f1fd4c0cd5503515ce25e2ff385bfcf930e0a9be63f6c3d9aa03446d3367a1f5f1b7ac3a3be5c12bbd38b081adde256c51b97bf9c8df613fcd4829d4359be0041b968f122da01b9d801ef2914abdaf7a2892571e78fe92e59625018ea6b9aa1bb019a
DEBU[Apr 1 13:03:56.232751983] Prepow []byte: [0 1 0 0 0 0 0 1 136 103 0 0 0 0 92 161 240 23 11 54 6 137 119 213 181 62 140 201 185 216 68 65 165 93 55 90 52 98 81 27 185 236 201 210 4 219 92 131 246 22 117 163 209 158 107 69 158 111 33 82 240 128 250 114 209 178 160 128 70 201 118 164 106 137 199 18 183 251 204 208 238 254 214 235 67 221 26 22 175 249 124 65 195 23 20 169 140 45 187 140 193 71 6 74 67 57 149 241 253 76 12 213 80 53 21 206 37 226 255 56 91 252 249 48 224 169 190 99 246 195 217 170 3 68 109 51 103 161 245 241 183 172 58 59 229 193 43 189 56 176 129 173 222 37 108 81 185 123 249 200 223 97 63 205 72 41 212 53 155 224 4 27 150 143 18 45 160 27 157 128 30 242 145 74 189 175 122 40 146 87 30 120 254 146 229 150 37 1 142 166 185 170 27 176 25 174 122 85 159 58 0 0 0 0 0 4 222 130 0 0 0 0 0 3 211 103 0 0 0 3 208 114 212 188 0 0 0 13]
Verifyshare fails:
ERRO[Apr 1 13:03:56.233148512] Error processing share: endpoints don't match up
DEBU[Apr 1 13:03:56.233174480] VerifyShare: false
Proxy connection to grin stratum server returns blockfound, so the share was valid.
DEBU[Apr 1 13:03:56.279445356] Share: {Result:blockfound - 087e45d5f0405e1ada29456ed7050bab592f1e9ed82729f6b41aede39a113dab Err:{Code:0 Msg:}}
Code:
type SubmitParams struct {
Height uint64 `json:"height"`
JobId int `json:"job_id"`
Nonce uint64 `json:"nonce"`
EdgeBits uint8 `json:"edge_bits"`
Pow []uint64 `json:"pow"`
}
func VerifyShare(prePoW []uint8, params *SubmitParams) bool {
header := &hasher.BlockHeader{}
header.Height = params.Height
header.PoW.Proof.EdgeBits = params.EdgeBits
header.PoW.Proof.Nonces = params.Pow
err := hasher.VerifySize(hasher.Floonet, prePoW, header)
if err != nil {
log.Errorf("Error processing share: %v", err)
return false
}
return true
}
The github.com/blockcypher/libgrin
uses Go modules and the current release version is v3
. And it’s module path is "github.com/blockcypher/libgrin"
, instead of "github.com/blockcypher/libgrin/v3"
. It must comply with the specification of "Releasing Modules for v2 or higher" available in the Modules documentation. Quoting the specification:
A package that has opted in to modules must include the major version in the import path to import any v2+ modules
To preserve import compatibility, the go command requires that modules with major version v2 or later use a module path with that major version as the final element. For example, version v2.0.0 of example.com/m must instead use module path example.com/m/v2.
https://github.com/golang/go/wiki/Modules#releasing-modules-v2-or-higher
GO111MODULE=on, run go get
targeting any version >= v3.0.0 of the blockcypher/libgrin
:
$ go get github.com/blockcypher/[email protected]
go get github.com/blockcypher/[email protected]: github.com/blockcypher/[email protected]: invalid version: module contains a go.mod file, so major version must be compatible: should be v0 or v1, not v3
run go get github.com/blockcypher/libgrin
, the version will stuck in v2.0.0:
$go get github.com/blockcypher/libgrin
go: downloading github.com/blockcypher/libgrin v2.0.0+incompatible
go: github.com/blockcypher/libgrin upgrade => v2.0.0+incompatible
SO anyone using Go modules will not be able to easily use any newer version of blockcypher/libgrin
.
This would push them back to not being managed by Go modules (instead of incorrectly using Go modules).
Ensure compatibility for downstream module-aware projects and module-unaware projects projects
Patch the go.mod
file to declare the module path as github.com/blockcypher/libgrin/v3
as per the specs. And adjust all internal imports.
The downstream projects might be negatively affected in their building if they are module-unaware (Go versions older than 1.9.7 and 1.10.3; Or use third-party dependency management tools, such as: Dep, glide,govendor…).
If you don't want to break the above repos. This method can provides better backwards-compatibility.
Release a v2 or higher module through the major subdirectory strategy: Create a new v3 subdirectory
(github.com/blockcypher/libgrin/v3) and place a new go.mod file in that subdirectory. The module path
must end with /v3
. Copy or move the code into the v3 subdirectory. Update import statements
within the module to also use /v3
(import "github.com/blockcypher/libgrin/v3/…"). Tag the release with v3.x.y
.
If the standard rule of go modules conflicts with your development mode. Or not intended to be used as a library and does not make any guarantees about the API. So you can’t comply with the specification of "Releasing Modules for v2 or higher" available in the Modules documentation.
Regardless, since it's against one of the design choices of Go, it'll be a bit of a hack. Instead of go get github.com/blockcypher/libgrin@version-tag
, module users need to use this following way to get the blockcypher/libgrin
:
(1) Search for the tag
you want (in browser)
(2) Get the commit hash
for the tag
you want
(3) Run go get github.com/blockcypher/libgrin@commit-hash
(4) Edit the go.mod file to put a comment about which version you actually used
This will make it difficult for module users to get and upgrade blockcypher/libgrin
.
You can make a choice to fix DM issues by balancing your own development schedules/mode against the affects on the downstream projects.
For this issue, Solution 2
can maximize your benefits and with minimal impacts to your downstream projects the ecosystem.
how to implement the grin-wallet receive -i file1.json with the api ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.