-
Notifications
You must be signed in to change notification settings - Fork 214
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
Transfer total slots calculation to smesher service #6624
Comments
Moving this calculation to the smeshing service might not give the expected benefit. Currently, slots are calculated on the node-service like this: go-spacemesh/miner/proposal_builder.go Lines 555 to 575 in 837e7fa
AFAIR, the calculation might return a different result depending on which node is asked or when it is asked (what view on atxSetWeight it has) . Because the smesher must be consistent about its slots throughout the epoch, it mustn't change its mind after publihing the first ballot. Thus, to remove the API to calculate the slots I would need to add another one to obtain the first ballot. At this point, the entire effort loses the point because it's trading 1 API call for another... |
I don't fully understand the dilemma here. The flow should go like this: Right before the start of the epoch, the smesher should determine their own eligibility for the epoch that's about to start. There are two steps to this calculation:
Doing 1 requires access to state for the total weight, so can't be done be the smesher without node involvement. However, other than finding the total weight - the rest of the calculation is trivial. It's just dividing my weight by the total, multiplying by the desired number of ballots and rounding. That's it. Doing 2 requires the private key, so cannot be done on the node. I prefer to make most node endpoints cache-able and the return values being universally useful, so for that reason I prefer the node just saying the total weight and letting the smesher calculate the number of eligibilities. The only potential issue with this is that I think we publish the active set in the first ballot (do we?) and that has to be consistent with the total weight used for the eligibility calculation. If that's not the case: don't change anything. If it's the case: instead of only asking for the total weight, the smesher should ask for active set AND total weight. It can then use the total weight to calculate the number of eligibilities and keep the active set so it can be included in the first ballot. Am I missing something? |
I'm sorry I wasn't clear. The smesher's eligibility count is included in the first proposal in the go-spacemesh/common/types/ballot.go Lines 242 to 249 in f31f02b
Once the first proposal is published, this count mustn't be changed (same for the beacon and active set hash). Normally, we look up the smesher's first ballot in the given epoch and pick the eligibility count from it, if it exists. I believe we should do the same in the node-split. Imagine a situation when the user installs and runs the smeshing-service client on a new computer (the state is not preserved) after publishing its first ballot. Suppose it calculates the eligibility count from the active set weight and ATX weight (which also needs to be fetched from the node-service). In that case, it might get a different result because the active set might be different now (another node was asked or new ATXs were published). I think that to make eligibility count calculation robust and do it on the smashing-service side, the flow would need to be something like this:
My claim is, that we cannot get rid of the call in the point in 1 and thus there is no real benefit of moving the calculation of the slots to the smeshing service side. In the current implementation, the logic of checking the first ballot is hidden inside the call from point 2. |
Under normal circumstances, the smeshing service will NOT need to ask for the previous ballot. This is only relevant when bringing up a new smeshing service for an existing identity (rare). I would put this logic on the smeshing service and only have it ask for a potential missing ballot if needed. |
It could not be that rare in cloud setups where someone forgets to keep local DB, etc. And sadly, there is a really high penalty for that mistake. Can we leave it as post beta for some case optimization? |
No description provided.
The text was updated successfully, but these errors were encountered: