If it costs 20000 gas to store a single value in the Ethereum Virtual Machine, how much does it cost in the StarkNet side? Are subsequent updates to the same slot cheaper?
I guess the exact answer probably depends on at least the following:
- Rollup size
- Whether the slot has been updated multiple times within the same rollup
If no exact answer is possible, some rough guidelines would be great.
Let's not delve into off-chain storage (Validium) options - this question focuses on on-chain storage.
The fee mechanism on Starknet is in development, but some high level principles are certain.
First, the general maxim is "compute is cheap, writes are expensive" (source) because storage is persisted on the L1. As you allude to, this will change in the future when Starkware introduces Validium mode which will enable data to be stored off-chain in a data availability network, with only data validity (not availability) guaranteed by the L1. This will also change with The Merge, sharding on the L1 and EIP 4488.
See this link for details on fees for computation, and here is a back of the envelope calculation for on-chain storage (as it is today):
-> USD per storage slot: ~$0.20
As you mention, subsequent updates to the same storage slot within one L2 batch will be cheaper, as the cost of writing to L1 is only incurred once per state update. This feature is not live on Starknet yet, and how high this rebate is will depend significantly on L2 batch time. Given that batch time is ideally at most a minute in steady state (and roughly that on testnet today), unless you are updating much more frequently than that, don't expect a big boost from the batching rebate.