Skip to content

[Flow EVM] Optimize block formation #6958

@bluesign

Description

@bluesign

Problem Definition

Currently block formation is accessing storage for each EVM transaction, each read and write is metered.

Which has huge implications for gas usage:

example with 100 EVM transactions ( individual vs batchrun )

https://testnet.flowscan.io/tx/2096a30d58d311416fd5e0fccf8ef8aa4439884fe0cdc10e1737033a2ff487a2
https://testnet.flowscan.io/tx/73ee4d199c071e3f913723fbb6c0795daa7d2c74cdfb79b224d6ae1649ea6a95
(credit @m-Peter)

cadence tx 1
├─ EVM tx 1
├── read block proposal & blockhashlist
├── execute transaction
├── write block proposal & blockhashlist
├─ EVM tx 2
├── read block proposal & blockhashlist
├── execute transaction
├── write block proposal & blockhashlist
cadence tx 2
... (same as above ) 
evm heartbeat
├── read block proposal & blockhashlist
├── create block

I think it should be optimized as: (only one cadence transaction below )

cadence tx 1
├─ read block proposal & blockhashlist
├─ EVM tx 1
├── execute transaction
├── update block proposal & blockhashlist in memory
├─ EVM tx 2
├── execute transaction
├── update block proposal & blockhashlist in memory
├─ write block proposal & blockhashlist

Proposed Solution

With minimal change, we can use PersistantSlabStorage and add a commit phase after TX is executed.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions