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

Pre-calculate expiring block of postage batches at creation #117

Open
tmm360 opened this issue Mar 4, 2023 · 1 comment
Open

Pre-calculate expiring block of postage batches at creation #117

tmm360 opened this issue Mar 4, 2023 · 1 comment
Labels

Comments

@tmm360
Copy link

tmm360 commented Mar 4, 2023

Currently expiration is calculate dynamically, updating the totalOutPayment variable, each time that price is updated.

This has downside that, when a postage batch is created, the owning user knows when the postage will expire only with current price. But if price changes, also the expiring date will change. This generated a bad UX, because it is not possible to schedule top ups having precise dates.

My propose instead is to pre-calculate the exact expiring block when the postage is created, for each postage. Users can purchase postages at current price, and this will be cost for their full life, regardless on price changes. This is acceptable, because doesn't open to new vulnerabilities (I don't see any), and make expiration predictable.

Other functions like top up and dilute can be implemented with this logic also.

Top up simply consider the current price at top up moment, calculate how many additional blocks of life you can add with the new amount, and simply add these blocks to the expiration block.

Dilute instead divide remaining live blocks per 2^(newDepth - prevDepth).

@bee-runner bee-runner bot added the issue label Mar 4, 2023
@significance
Copy link
Member

this is interesting and i do like the ux, but it certainly changes a lot of assumptions!

i'll bring this up for discussion, thanks @tmm360

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants