-
Notifications
You must be signed in to change notification settings - Fork 11
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
instant slashing of all balance in case of kycQuizResetAt passed #107
base: master
Are you sure you want to change the base?
Conversation
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.
Resurrection case must be handled. Most probably needSlashDueToQuizReset flag should be passed into resurrect function and handled there.
miner/mining.go
Outdated
updatedUser.SlashingRateForTMinus1 = usr.BalanceForTMinus1 / elapsedTimeFraction | ||
} | ||
} | ||
func (updatedUser *user) restoreInstantSlashing(usr *user, t0Ref, tMinus1Ref *referral, unAppliedSoloPending, elapsedTimeFraction float64) { |
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.
Not sure that this function is needed at all as if:
- user has mined minimal balance after burning out of balances, he don't need in slashing rates for the next iteration.
- user in slashing, he still will have 0 in balances.
miner/mining.go
Outdated
} | ||
|
||
if needSlashDueToQuizReset { | ||
updatedUser.applyInstantSlashing(usr, t0Ref, tMinus1Ref, unAppliedSoloPending, elapsedTimeFraction) |
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.
Will not lines 111, 118 affect on slashingRatesForT0 and TMinus1 that they will not be accepted at 165-166?
model/model.go
Outdated
@@ -408,6 +413,20 @@ func (kyc *KYCState) DelayPassedSinceLastKYCStepAttempt(kycStep users.KYCStep, d | |||
return kyc.KYCStepAttempted(kycStep) && time.Now().Sub(*(*kyc.KYCStepsLastUpdatedAt)[kycStep-1].Time) >= duration | |||
} | |||
|
|||
func (kyc *KYCState) WasQuizReset(now *time.Time) bool { |
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.
now is not a good name; try past
dd7c747
to
fdd092f
Compare
miner/resurrection.go
Outdated
|
||
usr.BalanceSolo += usr.SlashingRateSolo * resurrectDelta | ||
usr.BalanceT0 += usr.SlashingRateT0 * resurrectDelta | ||
amountSolo := usr.SlashingRateSolo * resurrectDelta |
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.
rollback
miner/mining.go
Outdated
@@ -14,14 +14,19 @@ func mine(baseMiningRate float64, now *time.Time, usr *user, t0Ref, tMinus1Ref * | |||
clonedUser1 := *usr | |||
updatedUser = &clonedUser1 | |||
pendingResurrectionForTMinus1, pendingResurrectionForT0 := resurrect(now, updatedUser, t0Ref, tMinus1Ref) | |||
wasResurrected := !updatedUser.ResurrectSoloUsedAt.IsNil() && updatedUser.ResurrectSoloUsedAt.Equal(*now.Time) |
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.
what about if t0/t-1 resurrected?
miner/mining.go
Outdated
|
||
needInstantSlashing := usr.WasQuizReset(updatedUser.BalanceLastUpdatedAt) | ||
if wasResurrected && needInstantSlashing { | ||
updatedUser.ResurrectSoloUsedAt = nil |
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.
why?
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 should consume the resurrection, but it shouldn't resurrect the coins u lost forever
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.
But it seems situation when we have to resurrect part of the coins are impossible, in instant slashing we slash all the balance, and slashing stops, nothing to be resuttected if instant slashing occured (so that reset date does not affect to resurrectedDelta in anyway it seems)
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.
Yea but u dont consume the resurrection
miner/mining.go
Outdated
|
||
needInstantSlashing := usr.WasQuizReset(updatedUser.BalanceLastUpdatedAt) | ||
if wasResurrected && needInstantSlashing { | ||
updatedUser.ResurrectSoloUsedAt = nil |
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.
same thing here
No description provided.