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

Re-work rent to not require in-order index and pubkey #18233

Closed
sakridge opened this issue Jun 25, 2021 · 3 comments
Closed

Re-work rent to not require in-order index and pubkey #18233

sakridge opened this issue Jun 25, 2021 · 3 comments
Labels
stale [bot only] Added to stale content; results in auto-close after a week.

Comments

@sakridge
Copy link
Member

Problem

Rent collection is done on a set of keys with the same pubkey prefix today at the end of a slot in a blocking operation which involves potentially looking up account state from disk incurring page faults.

The in-order requirement on the index also limits the design-space to structures which can iterate the elements in-order efficiently which may impede the speed of the index for other operations such as writing new account states or doing lookups.

Proposed Solution

Find a way to collect rent from a random or pseudo-random set of keys, maybe something like an RNG seeded with the block hash which then picks N number of pubkeys which is designed to on average collect rent from each account every epoch but might not be guaranteed as it is today.

A somewhat related idea is to have some special rent update which does not write the whole account state again, but maybe references a previous update and a new lamports value to indicate that it was changed. This could keep the

@sakridge
Copy link
Member Author

cc @ryoqun

@jon-chuang
Copy link
Contributor

jon-chuang commented Jul 7, 2021

The other idea was that to prevent grinding attacks, the rent collection keeps a memory of the last pubkey it has collected rent from. Then, it collects rent from N pubkeys following that pubkey, where N = num_pubkeys_remaining / num_slots_remaining.

This implies not having a fixed schedule, but the runtime can still start reading accounts into memory preemptively on an as-needed basis, at a stable rate.

This would avoid having to reshuffle rent collection each epoch.

Why is this good enough?

  • Someone trying to "bomb" this rent-collection approach would need to wait till the end of the epoch, then spam the network with transactions with keys whose prefix exceed the current rent_pubkey_pointer. Thankfully, such accounts would already be in memory during that short window. There is a tradeoff between how close to the boundary one is, and how much one can spam the network with new accounts.
  • To further guard against such things, the bank can also have some spill over logic to the next epoch, after which it catches up. The rent_pubkey_pointer needs to be recoverable from snapshots.

@stale
Copy link

stale bot commented Jul 10, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale [bot only] Added to stale content; results in auto-close after a week.
Projects
None yet
Development

No branches or pull requests

2 participants