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

SLOAD-SSTORE pair special handling #15

Open
Scooletz opened this issue Oct 28, 2023 · 0 comments
Open

SLOAD-SSTORE pair special handling #15

Scooletz opened this issue Oct 28, 2023 · 0 comments
Labels
potential optimization an aspect that can provide benefit for contrat execution

Comments

@Scooletz
Copy link
Contributor

Scooletz commented Oct 28, 2023

WrappedEth that uses a regular ERC20. It can be seen decompiled under here and you can see its Etherscan profile. As it's ERC20 one of the core operations is the transfer that consists of two Read-Update-Write pairs, that access one StorageCell. Unfortunately, the underlying encoding of the key of the StorageCell index must take place twice. With IL-EVM we could optimize it by properly noticing SLOAD followed by SSTORE for the same value. It's worth to notice that Solidity/Yul will do their job here and the SHA3 that creates the index will be calculated only once.

PUSH1     0x20
ADD       
PUSH1     0x0
SHA3      
PUSH1     0x0
DUP3      
DUP3      
SLOAD
SUB     (or ADD if this is the transfer to)    
SWAP3     
POP       
POP       
SWAP1
SSTORE
@Scooletz Scooletz added the potential optimization an aspect that can provide benefit for contrat execution label Oct 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
potential optimization an aspect that can provide benefit for contrat execution
Projects
None yet
Development

No branches or pull requests

1 participant