Shared global key-value storage #385
Replies: 14 comments
-
I think this will create some issues long term because we cannot reshard this global storage. Even if it is more expensive to write to, because values cannot be removed, this storage will eventually grow so large that nodes will not be able to track it anymore. |
Beta Was this translation helpful? Give feedback.
-
The price of this storage is linked to the total_supply + inflation. Let's say we dedicate 1TB for it and map it to the total supply of 1B NEAR. Then we define the price of global storage will be 1 NEAR = 1Kb. Let's say the global storage grows similarly to the inflation at 5% per year. Then the maximum storage requirement is 1TB + 5% grows per year. |
Beta Was this translation helpful? Give feedback.
-
Big fan of this idea! Why would all developers deploy the same code for common design patterns? Why not leverage existing code and extend it by wrapping it in a higher order contract? I think every account where the code is referenced having it's own storage space is key here too. Personally I think there will be many more use cases where someone will want to deploy, instantiate and provide their own arguments to a contract that's already written. The examples from Ethereum in ERC20/721s, DeFi tokens, etc... are many. |
Beta Was this translation helpful? Give feedback.
-
@evgenykuzyakov I don't see how that answers my concern. Given that this storage is shared globally, even 100GB feels too much. It will decrease the speed of syncing significantly. |
Beta Was this translation helpful? Give feedback.
-
Current proposal is for permanent storage, so there are no issue for syncing it. Downloading 100GB seems like a trivial problem, so long as you don't have to worry about it changing over time. |
Beta Was this translation helpful? Give feedback.
-
@evgenykuzyakov are we not going to make it verifiable? |
Beta Was this translation helpful? Give feedback.
-
If the key is the hash of the value, then we need to merkalize keys only. Rollout idea for global contracts.Let's say we have a global storage that all nodes have access to. And each key is the hash of the corresponding value. Automatic state clean-upLet's say I deploy a fungible contract to a global storage. If the contract was already used by a lot of existing accounts, then these accounts can now use it for free and we should be able to release the occupied trie space (by deleting a copy for an account) and refund the locked storage value for the account. Ideally we do this the next time we touch this account. We can do this without modifying Or we can have upgradable ProsDevelopers can create contracts and first deploy them on accounts. If contract becomes popular then someone can create a DAO to publish it globally. Once the DAO reaches the limit, it will submit the contract to the global key-value store and the contract becomes free to deploy. |
Beta Was this translation helpful? Give feedback.
-
As discussed during a townhall session. The current proposal for implementation is to introduce a new shard with a single ephemeral account (e.g. All nodes will have to track this shard. In order to deploy there, you'll have to pass enough token amount to cover the storage of contract through a transfer action. The deployment may look as:
If this action succeeds then the contract code will be hashed and stored in the state. We want to achieve the following:
|
Beta Was this translation helpful? Give feedback.
-
@evgenykuzyakov @Longarithm @abacabadabacaba I wonder whether it is better to do this per shard vs. having a global shard that everyone needs to track. This reduces the complexity on the protocol level since we don't need to worry about how it interacts with sharding, state sync, etc. However, it likely requires changing the deploy contract action to allow users to specify how the contract should be deployed (burning tokens vs. staking tokens). |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
We have not decided on this yet. @abacabadabacaba correctly pointed out that my proposal does not work well if we decide to implement dynamic resharding one day (contract deployment would be underpaid because it now replicates to another shard). Currently @Longarithm is discussing with @abacabadabacaba on possible solutions. |
Beta Was this translation helpful? Give feedback.
-
@abacabadabacaba actually we should not consider the storage cost to be constant. If we increase the number of shards, theoretically the amount of storage also increases and therefore the storage price should go down proportionally. Let's say we have dynamic resharding and there is some contract deployed in one out of |
Beta Was this translation helpful? Give feedback.
-
https://www.pagoda.co/blog/protocol-roadmap-2023-4-the-next-2-years-of-near linked here, but the comments in this discussion are very old. Are there more updated discussions published somewhere else? Thanks! |
Beta Was this translation helpful? Give feedback.
-
There are other use cases like http://web4.near.page/ and http://near.social/ where you want to be able to store some common code (which isn't smart contract) and assets on chain. I think it makes sense if we essentially have arweave-like storage built in, so that you can smoothly pay for it with NEAR token. |
Beta Was this translation helpful? Give feedback.
-
To be able to reuse contracts code across multiple accounts, we suggest to dedicate a shared global key-value storage that is available for reads from every shard.
Simple version:
This storage has the following properties:
PRICE_PER_BYTE_PER_SHARD * NUM_SHARD * (NUM_BYTES_VALUES + NUM_BYTES_KEY)
This will allow the following use-cases:
Beta Was this translation helpful? Give feedback.
All reactions