ً Profile picture
26 Apr, 16 tweets, 4 min read
Smart contract developers:

How much does the storage refund need to decrease before you start using a different value to represent 0?
The London hard fork in July will almost certainly modify the behavior of refunds. There have been several iterations, but the latest is EIP-3529: Reduction in refunds.
I recommend reading the EIP as it is very thorough and explains the past proposals, however the main case we care about for this thread is setting a nonzero storage element to zero and the refund that incurs.

eips.ethereum.org/EIPS/eip-3529
EIP-3529 reduces the storage clearing refund from 15,000 to 4,800. The reasoning is that for gas tokens to work, the refund needs to be greater than the cost of zeroing out the storage element.
Since clearing a storage element costs 4,800 and it refunds 4,800, therefore there is no net-gain to clearing storage, and it can’t be used as a battery for locking up gas during periods of inactivity and deployed during congestion.
Aside - this thread isn’t about gas tokens or the importance of reducing the elasticity of blocks. I recommend reading the EIP, reviewing the last few ACDs, and directing discussions on these topics to ethereum magicians forum.
Before Berlin, it cost 20,000 to initialize a new storage element and 5,000 to modify and existing one. Therefore, it never made *not* to zero out storage elements when zeros occurred naturally, since you’d be refunded 15,000.
After Berlin, it costs 22,100 to initialize a new storage element and it costs 5,000 to modify an existing one. The difference of 17,100 can be considered the refund inflection point at which you’d always clear storage.
With the current refund of 15,000, you would need to be 15,000/17,100 = 87.7% sure that you’ll reuse that slot before you should consider using a nonzero value to represent zero.
After EIP-3529, the refund would be 4,800, so you need to be 4,800/17,100 = 28.1% sure that you will not reuse that slot at a later point. If you think there is a decent chance of reusing the slot, you’re better off using a nonzero value to represent zero.
This then yields the question for developers - would this reduction cause you to change the way you write your contract?
I would guess the answer would be “yes” for many if this was to be the expected behavior long term. So, it’s important to mention though that in the next 1.5-3 years there will be modifications to state trie that will completely remove the concept of cross-tx refunds.
The state trie considers zero and nil as the same thing. When a element is zeroed out, it is dropped from the trie. In the future, there will be a distinction between the two. The reasons and mechanisms are for another thread, but for those curious - check out “regenesis”.
Once zero and nil are each unique values, there will be no advantage to representing zero with a nonzero value. In fact, it will most likely be technical debt confusing users and developers alike.
So to reframe the above question, would the refund reduction cause you to change the way you write contracts, *even if* the advantage will only last for 1.5-3 years?

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with ً

ً Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @lightclients

23 Apr
In the last month, users spent $23,830,482 on ERC-20 approvals. EIP-3074 would reduce that number by at least 30%, saving users millions while freeing up block space (thread). Image
Anyone whose nonce is greater than ten has likely experienced the approve+transfer flow that defi applications use to interact with ERC-20 tokens. The approve method is a relic of the original ERC-20 design.

@DuneAnalytics dashboard for above tweet: duneanalytics.com/lightclient/US…
There have been many attempts to alleviate the burden of token approvals, but none have succeeded. We believe EIP-3074 will resolve the issue because it addresses the two problems that have beleaguered other approaches.
Read 15 tweets
16 Mar
Ethereum wallets may be getting a significant upgrade soon. With the proposed change, EOAs will immediately be able to send batch txs, expiring txs, unordered txs, and more. (thread)
My colleagues, @_SamWilsn_ and @adietrichs, and I have been working on improving the UX of interacting with Ethereum. After many iterations, we've come up with EIP-3074: AUTH and AUTHCALL opcodes.
To use these opcodes, an EOA signs a message off-chain, provides the message to a relayer, the relayer passes the signature and calldata to a contract on-chain (called an invoker), the contract verifies the signature using AUTH, and then relays the EOA's call with AUTHCALL.
Read 26 tweets
13 Jan
2021 will be the most innovative year for the Ethereum protocol since 2016. Here are the EIPs to keep an eye on this year (thread):
The next hardfork is named "Berlin" & is scheduled to ship with 4 EIPs:

* EIP-2929: Gas cost increases for state access opcodes
* EIP-2930: Optional Access List Txs
* EIP-2718: Typed Transaction Envelope
* EIP-2315: Simple Subroutines
EIP-2929: Gas cost increases for state access opcodes

Storage accessing opcodes have historically been underpriced & malicious txs which take 20-80 seconds to execute can be created today.

This EIP increases the cost of state accesses by ~3x.
Read 21 tweets
12 Jan
What are the most exciting new(ish) ERCs? cc @0xMaki @bantg @nicksdjohnson @thegostep @AndreCronjeTech @kaiynne @danfinlay
so far, the most interesting IMO (as a non-dapp dev) are EIP-2535 Diamond Standard (@mudgen), EIP-3009 Transfer with Authorization (@petejkim), EIP-3000 Optimistic enactment of governance (@izqui9), and EIP-3156 Flash Loans (@acuestacanada)
but i feel like there are interesting conversations happening in some lower number EIPs that I'm just not following. any standards to improve the readability of tx data when signing (or signing standards in general)?
Read 4 tweets
12 Nov 20
Yesterday's chain split will be cemented in Ethereum's history as an inadvertent hard fork. Let's look at exactly what the vulnerability was & how this transaction exploited it (thread): etherscan.io/tx/0x57f7f9ec3…
I also want to preface that this is completely an outsiders account of the incident & therefore everything posted here is only to the best of my knowledge. I look forward to the go-ethereum team's full disclosure of the vulnerability!
On 2019-11-07, Geth v1.9.7 was released. It contained a few fixes and optimization, including PR #20177 titled "core/evm: avoid copying memory for input in calls".
Read 25 tweets
1 Nov 20
Geth's transaction pool (aka mempool) can be boiled down to a few key data structures and processes. Transactions are the main building block. They are stored on the heap while references to them populate four objects: "all", "priced", "queue", and "pending".
The "all" object is a mapping of the transaction's hash to the actual transaction object on the heap. It is the canonical source of transactions in the mempool and is used to build (and rebuild) the "priced" object.
The "priced" object is a heap (data structure) that orders the transactions in the mempool highest to lowest priced. When the mempool is completely saturated, "priced" is asked to find the N cheapest transactions so that they can be fully evicted from the mempool.
Read 16 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!