-
Notifications
You must be signed in to change notification settings - Fork 137
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
Proposal: Solving state staking issue #124
Comments
Expanding on (7) I suggest the following:
If we limit the size of the contract state to be 10MiB and make creation of a single contract require staking 200 NEAR then it will limit the total state to 50Tb, independently on what is the price per byte of a contract state. |
Re @mfornet
This problem already exists today in a different form. If contract is not implemented carefully its users can increase state without staking tokens, and at some point contract will not have enough staked tokens to function. Additionally, limiting contract state has the following benefits:
|
Having a limit on the contract state effectively blocks the contract from processing further transactions, so it's not much different from being blocked someone who fills the storage with random data. If a developer needs to think about the maximum state right now, then we are making it even more complicated than just to think about the capital. I'm pretty sure that once we hit one account congestion, it will be a better motivation than introducing a state limit. But it will also allow contracts to react by sharding them once the time arrives. |
@evgenykuzyakov could you remind me what the abuse is here (assuming we only do this for contract storage)? |
Would be also curious to know what the actual concerns for getting rid of staking in favor of charging written bytes at sufficient/appropriate rate (besides implementation complexity) are, the devX/UX is definitely simpler without storage staking. I guess the downside is - storage becomes more expensive overall (because 1-time fee you'd charge must be high enough to account for the fact that it's permanent - and you'd wanna err on the safe side). For completeness, looks like the continuation of this discussion resides at gov.near.org and there is a relevant video-call discussion and an older design session too. |
Solving state staking issue
Background
With the current state staking pricing, the cost of storing
100
bytes of data is0.01
NEAR.Storage stake
A fungible token contract will stop functioning once the total state stake exceeds account balance.
This may break the logic of some contracts that rely on the fact that the transfer method doesn't fail.
So fungible token standard charges small amount of
extra NEAR deposit for every function call in order to cover increased storage cost.
If we attach extra NEAR for every function in fungible token, it breaks the DevX.
Because now exchange contracts that wants to transfer with fungible token, has to attach extra NEAR.
The exchange doesn't want to pay from their balance, so it will ask the user to pay for this, but the
refund will go to exchange, so the exchange needs to return to a user. It creates a deep chain of
extra deposits for every function calls with complicated refunds.
Ethereum EVM doesn't have this issue, because the storage increase comes from gas.
But because our compute is cheaper than ethereum, it possible to increase the state size faster
than the persistent state of the network. It'll be possible to exceed the storage in the long term.
Research
At the research meeting, we had a few options on how to address the issue:
After the discussion we've decided to explore (7).
Research meeting video recording: https://drive.google.com/file/d/1CIbj89DXWXUWNTVJI42OqWEmFvU0tYma/view?usp=sharing
Proposal
The goal is to be able to write storage and cover the persistent storage stake only from gas.
Currently, you need
1T gas
to pay for1 byte
of state stake at minimum gas price.If we decrease the cost by
100X
, then1T gas
will be able to pay for the100 bytes
.Considering the contract has a reward of
30%
from the burnt gas, this operation is very similar.Let's say a contract burns
1T gas
as the minimum gas price, it will result in being able to storeextra
30 bytes
.We can make a decision whether to allow burn gas for storage increase to receive a reward at a higher percentage or just keep it as is to not adjust economics.
For example if we consider this change and the new fungible contract implementation. In order to do a transfer to a new account, a
contract has to get a storage for extra
69
bytes. So it needs to regularly burn2.3T gas
.Drawbacks
Biggest drawback is the potential state size increase due to cheaper state stake.
With the current pricing the maximum state is
10T bytes
if all tokens are used for state stake.With the proposed change, the maximum state can potentially grow to
1000T bytes
.Another drawback is the changes required to split the contract storage usage vs non-contract storage usage.
Alternative
Just drop the price of storage stake by 100X. No changes needed for the runtime, considering they burn gas enough gas during regular operations.
We can get this done fast with a simple protocol upgrade and it will address most of the problems.
It's unclear whether this alternative is worse than the proposed solution.
The text was updated successfully, but these errors were encountered: