forked from DecentralizedClimateFoundation/DCIPs
106 lines
2.8 KiB
Markdown
106 lines
2.8 KiB
Markdown
|
---
|
||
|
eip: 3521
|
||
|
title: Reduce access list cost
|
||
|
author: Matt Garnett (@lightclient)
|
||
|
discussions-to: https://ethereum-magicians.org/t/eip-3521-reduce-access-list-cost/6072
|
||
|
status: Stagnant
|
||
|
type: Standards Track
|
||
|
category: Core
|
||
|
created: 2021-04-15
|
||
|
requires: 2028, 2930
|
||
|
---
|
||
|
|
||
|
## Simple Summary
|
||
|
|
||
|
Reduce the cost of declaring `tx.to` storage keys in access lists.
|
||
|
|
||
|
## Motivation
|
||
|
|
||
|
Currently, a transaction must read at least 25 distinct storage slots in `tx.to`
|
||
|
before it's more expensive to forego an access list.
|
||
|
|
||
|
```
|
||
|
ACCESS_LIST_ADDRESS_COST + (ACCESS_LIST_STORAGE_KEY_COST + WARM_STORAGE_READ_COST) * x = COLD_SLOAD_COST * x
|
||
|
x = 24
|
||
|
```
|
||
|
|
||
|
EIP-2930 requires the address under which the storage keys reside be declared
|
||
|
explicitly, since it must be added to the EIP-2929 `accessed_addresses` list.
|
||
|
However, `tx.to` is a special case that is added by default, so paying
|
||
|
`ACCESS_LIST_ADDRESS_COST` for `tx.to` is essentially paying twice for the same
|
||
|
address. Avoiding overpayment here will reduce the differential to just 5 unique
|
||
|
reads before using an access list is cheaper -- making them a more attractive
|
||
|
option.
|
||
|
|
||
|
## Specification
|
||
|
|
||
|
Treat the first occurrence of `tx.to` in an access list as `calldata` for gas
|
||
|
accounting purposes. Do not charge `ACCESS_LIST_ADDRESS_COST` for it. Storage
|
||
|
keys underneath the address are unaffected.
|
||
|
|
||
|
If `tx.to == nil`, `tx.to` is defined be the derived contract address created by
|
||
|
the transaction.
|
||
|
|
||
|
## Rationale
|
||
|
|
||
|
### Why charge at all?
|
||
|
|
||
|
EIP-2930 is specifically written to make access lists simple to reason about and
|
||
|
validate. It may be possible to modify the structure of the access list to avoid
|
||
|
including `tx.to` explicitly, but this would renege on the spirit of EIP-2930.
|
||
|
|
||
|
### Why charge as `calldata`?
|
||
|
|
||
|
The cost of `calldata` was thoroughly analyzed in EIP-2028 to determine
|
||
|
a fair value that is not susceptible to denial-of-service attacks. We consider
|
||
|
this the lower bound on how much transaction data should cost. Since there is
|
||
|
no computation burden imposed for adding `tx.to` to the `accessed_addresses`
|
||
|
map (it's added by default by [EIP-2929](./eip-2929.md)), there is no reason to charge more than
|
||
|
the absolute minimum for the data.
|
||
|
|
||
|
## Test Cases
|
||
|
```
|
||
|
{
|
||
|
"0xffffffffffffffffffffffffffffffffffffffff": []
|
||
|
}
|
||
|
cost = 320
|
||
|
|
||
|
{
|
||
|
"0x00ffffffffffffffffffffffffffffffffffffff": []
|
||
|
}
|
||
|
cost = 308
|
||
|
|
||
|
{
|
||
|
"0xffffffffffffffffffffffffffffffffffffffff": []
|
||
|
"0xffffffffffffffffffffffffffffffffffffffff": []
|
||
|
}
|
||
|
cost = 2720
|
||
|
|
||
|
{
|
||
|
"0xffffffffffffffffffffffffffffffffffffffff": [
|
||
|
"0x00"
|
||
|
]
|
||
|
"0xffffffffffffffffffffffffffffffffffffffff": []
|
||
|
}
|
||
|
cost = 4620
|
||
|
|
||
|
{
|
||
|
"0xffffffffffffffffffffffffffffffffffffffff": [
|
||
|
"0x00"
|
||
|
]
|
||
|
"0xffffffffffffffffffffffffffffffffffffffff": [
|
||
|
"0x00"
|
||
|
]
|
||
|
}
|
||
|
cost = 6520
|
||
|
```
|
||
|
|
||
|
## Backwards Compatibility
|
||
|
No issues.
|
||
|
|
||
|
## Security Considerations
|
||
|
None.
|
||
|
|
||
|
## Copyright
|
||
|
Copyright and related rights waived via [CC0](../LICENSE.md).
|