-
Notifications
You must be signed in to change notification settings - Fork 514
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
opencl: fix ethash light handling, fix errorf formats #83
Conversation
@@ -560,7 +560,7 @@ func (c *OpenCLMiner) Search(block pow.Block, stop <-chan struct{}, index int) ( | |||
ds := C.uint64_t(c.dagSize) | |||
// We verify that the nonce is indeed a solution by | |||
// executing the Ethash verification function (on the CPU). | |||
ret := C.ethash_light_compute_internal(c.ethash.Light.current.ptr, ds, hashToH256(headerHash), cn) | |||
ret := C.ethash_light_compute_internal(c.ethash.Light.getCache(block.NumberU64()).ptr, ds, hashToH256(headerHash), cn) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is dangerous because of the finalizer. To keep the C pointer live during the call, you need to keep a reference to it, e.g.
cache := c.ethash.Light.getCache(...)
C.ethash_light_compute_internal(cache.ptr, ...)
_ = cache // keep live
This is very subtle though, so I'd prefer a solution that shares this code with ethash.go.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So what should the proper solution be?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can make a method on Light that does this check and then use it here and in Light.Verify.
Basically refactor the core of Light.Verify into its own method.
@fjl Could you please check if this is enough? |
You really do need the What I would like to see instead of duplicating this trickery in the GPU half is a Go wrapper for |
Won't this be optimized out by the compiler? |
@fjl I've pulled in your commit on top of mine. This should fix the OpenCL build issue so I think we can go ahead and merge this as is, and then figure out if we need to do any changes to cover the Go SSA compilation afterwards. |
👍 |
@obscuren please review |
@obscuren pling |
👍 |
This PR does two things:
Errorf
formatting issues that the code did wrong previously.