Skip to content
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

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

ice-cronus
Copy link
Contributor

No description provided.

@ice-cronus ice-cronus requested a review from a team as a code owner January 24, 2024 12:51
Copy link
Contributor

@ice-myles ice-myles left a 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) {
Copy link
Contributor

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)
Copy link
Contributor

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 {
Copy link
Contributor

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

@ice-cronus ice-cronus force-pushed the feature/quiz_reset_balances branch from dd7c747 to fdd092f Compare January 25, 2024 08:03

usr.BalanceSolo += usr.SlashingRateSolo * resurrectDelta
usr.BalanceT0 += usr.SlashingRateT0 * resurrectDelta
amountSolo := usr.SlashingRateSolo * resurrectDelta
Copy link
Contributor

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)
Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?

Copy link
Contributor

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

Copy link
Contributor Author

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)

Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same thing here

@ice-ares ice-ares marked this pull request as draft January 25, 2024 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants