Skip to content

feat(x/gov): change lazy dynamic deposit computation in favor of endblocker per-tick update #104

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

giunatale
Copy link
Collaborator

@giunatale giunatale commented Mar 22, 2025

As per the title.

It seems unnecessarily complex in hindsight to lazily compute the dynamic deposit.
If we assume per-tick updates aren't too frequent, it's better to do this then only once and limit to reading a single value for queries.
Moreover, since store updates just overwrite an existing value, even a per-block update should not be too expensive in practice.

lastMinDeposit, lastMinDepositTime := keeper.GetLastMinDeposit(ctx)
if checkElapsedTime && ctx.BlockTime().Sub(lastMinDepositTime).Nanoseconds() < tick.Nanoseconds() {
return
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

There is no additional case in the unit tests for this new condition, is it because it is already covered or is it a miss ?

lastMinInitialDeposit, lastMinInitialDepositTime := keeper.GetLastMinInitialDeposit(ctx)
if checkElapsedTime && ctx.BlockTime().Sub(lastMinInitialDepositTime).Nanoseconds() < tick.Nanoseconds() {
return
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same question here

@tbruyelle
Copy link
Collaborator

This PR should be closed in favor of #105 because it already changes the lazy computation.

@giunatale
Copy link
Collaborator Author

I can do that, it's a miss! thanks for spotting it.

both #104 and #103 are included in #105 actually.
I was unsure we were gonna be going with #105 after all but started from #104 as a base.

I will add the coverage there.

@giunatale
Copy link
Collaborator Author

Closing in favor of #105

@giunatale giunatale closed this Mar 26, 2025
@giunatale giunatale deleted the giunatale/dynamic-deposit/endblocker branch March 26, 2025 21:09
giunatale added a commit that referenced this pull request May 29, 2025
… and decreases only with time (#105)

This PR is based on #104 

Based on discussions, this is a revised model for the dynamic deposit
that:
- only performs deposit increases upon proposal activation (proposal
deactivation does not trigger an update of the deposit), and
- only perform time-dependent updates to decrease the deposit, and a
decrease happens only if active proposals is less than the target,
otherwise the time-based update has no effect.

Plus, remove the sensitivity to the distance for increases.

This PR should be merged only after #104 is (or in its stead). Moreover,
if this PR is accepted, the partially overlapping PR #103 can be closed.

---

Importantly, this PR does not yet update neither the `x/gov` README.md
nor the Dynamic Deposit ADR to reflect these changes, so it needs to be
done.

---------

Co-authored-by: Thomas Bruyelle <thomas.bruyelle@tendermint.com>
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.

2 participants