-
Notifications
You must be signed in to change notification settings - Fork 21.5k
miner: --miner.notify.full flag: enable full pending block notifications #22323
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
Conversation
|
Added test coverage to the implemented functionality. Ready for the review. |
|
What's the goal of this PR? You can mine without the block details, but the details might be quite large. What's the advantage of knowing all the transactions included? |
|
Good question. Advanced mining pools require having the block template for things like computing block hash when one was mined. Right now, on our pool, when new work was prepared, it gets notified in this way: With this PR, it can be simplified to this: I know that the |
Size increased from 219 bytes to 1341 bytes. 6x more in total.
Also, only the transaction root is included in the response. |
|
Sorry for asking, but do you plan to merge this? A lot of stuff is waiting for this PR. |
|
Resolved conflicts. Having:
What's the reason for ignoring this PR? It will take only a couple of minutes to review and test. |
I still don't understand. In the code/docs, it seems like you're sending the full block. But in the actual example from the PR description, it looks like a block header only. And if you want to compute the block hash, the header is the only thing needed. So is it full block or header? If the latter, the descriptions in PR and code needs to be updated.
It's not being ignored, it was added for triage three days ago. We just can't spend all our time just on PRs, then we'd never do anything else.
That is seldom if ever true. Most PRs require roughly the same time for review as it takes coding it up. Aside from reviewing for potential side-effects and mistakes, we also review for maintainability long-term, coding style. We have to maintain the code once it's merged, so almost every PR has several rounds of review/update/review/update. |
|
Thank you for the reply, @holiman. Sorry if I was pushing this too hard. I was just worried that this PR would be abandoned just like thousands of others in this repo. And yes, this flag will notify the block header because the true full block doesn't have any use cases in mining. I will update the flag description. I appreciate the response :) |
|
So, one thing is that you made That would reduce the size of this PR to be basically just a few additions, maybe around 40 LOC. Am I missing something? |
|
Okay, things I've done:
@holiman I think that everything is ready for the final review. |
consensus/ethash/sealer.go
Outdated
| if err != nil { | ||
| s.ethash.config.Log.Error("Unable to marshal current block for the notification", "err", err) | ||
| return | ||
| } |
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 ignore the error here, just like we do below. It's not a random interface struct, it's a known type so it should be safe
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.
Makes sense, will commit the change in a moment
|
Could you describe your use case a bit? Explicitly? Why is it beneficial to return the full header? You are aware that you'd need to compute the work package yourself? Also, Geth won't accept solutions to work packets it doesn't track, so you can't really modify it. |
I understand this. Primarily, it will be used for block hash computation. |
Co-authored-by: Martin Holst Swende <[email protected]>
We're a bit loathe to add a feature which we don't understand. Maintaining code means that we need to know why something is the way it is, otherwise the thing might be overly complicated, or happened to get refactored away at some point in the future, with the reasoning "there's no good point in having this here". So while the PR generally looks good at this point, we still would like to know more about exactly how this feature fits into the mining stack, and what the usecase is that prompts it. |
|
Sorry for not explaining it verbosely. When the block was mined on the mining pool, the mining pool must understand which exact block was mined. It is impossible to derive the block hash with just a default work package, so mining pools are forced to retrieve the entire block header. By receiving the work package via |
Why? The work packages are controlled by Geth. Geth will track all open work packages and you can submit a solution to any of them. We still don't understand why a mining pool wants to care about the details of a block. In our mental model, the pool just schedules and aggregates remote GPUs. In your model you're obviously doing something more, we'd like to understand what that is. |
Which means, once we get the solution, geth already knows exactly what the block was. |
I see that you forgot about the reward distribution step. How will the pool distribute the rewards if the block reward is unknown? And to determine the block reward, the pool must understand what block it has mined (aka have the block hash). This PR is not about sealing the block but the further processing of it. This PR will provide needed information to the mining pool directly without doing the extra |
|
How does the header help wrt the block reward? |
|
Hmm, yes, the header can be used to get the hash and then go from there. Still, there's no immediate guarantee that the block will be included and whether it's a full block or an uncle. But yeah without the hash it's poblematic. |
Before the reward is distributed, it requires a certain amount of confirmations, and the reward is being verified on the confirmation stage as well. |
| Noverify bool // Disable remote mining solution verification(only useful in ethash). | ||
| Etherbase common.Address `toml:",omitempty"` // Public address for block mining rewards (default = first account) | ||
| Notify []string `toml:",omitempty"` // HTTP URL list to be notified of new work packages (only useful in ethash). | ||
| NotifyFull bool `toml:",omitempty"` // Notify with pending block bodies instead of work packages |
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.
"block header"
| work := s.currentWork | ||
| blob, _ := json.Marshal(work) | ||
| var blob []byte | ||
| var err error |
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.
dead code
|
Generally ok, we'll patch it up a bit to reduce the API changes (and thus the diff). |
|
I have recreated this PR in #22558 in order to make some fixes. |
|
Thank you! |
This PR implements the
--miner.notify.fullflag that enables full pending block notifications. Extends--miner.notifyflag.Notification without this flag:
Notification with this flag: