core: implement eip-7981: Increase Access List Cost - #34755
Merged
Conversation
MariusVanDerWijden
requested review from
fjl,
gballet,
lightclient,
rjl493456442 and
zsfelfoldi
as code owners
April 17, 2026 15:42
| if accessList != nil { | ||
| gas += uint64(len(accessList)) * params.TxAccessListAddressGas | ||
| gas += uint64(accessList.StorageKeys()) * params.TxAccessListStorageKeyGas | ||
| // EIP-7981: access list data is charged in addition to the base charge. |
Member
There was a problem hiding this comment.
I am not sure how we can get rid of the overflow checking, but apparently the validation is missing here.
diff --git a/core/state_transition.go b/core/state_transition.go
index 3f7ec50f5b..e7b06a96ed 100644
--- a/core/state_transition.go
+++ b/core/state_transition.go
@@ -107,12 +107,31 @@ func IntrinsicGas(data []byte, accessList types.AccessList, authList []types.Set
}
}
if accessList != nil {
- gas += uint64(len(accessList)) * params.TxAccessListAddressGas
- gas += uint64(accessList.StorageKeys()) * params.TxAccessListStorageKeyGas
+ addresses := uint64(len(accessList))
+ storageKeys := uint64(accessList.StorageKeys())
+ if (math.MaxUint64-gas)/params.TxAccessListAddressGas < addresses {
+ return 0, ErrGasUintOverflow
+ }
+ gas += addresses * params.TxAccessListAddressGas
+ if (math.MaxUint64-gas)/params.TxAccessListStorageKeyGas < storageKeys {
+ return 0, ErrGasUintOverflow
+ }
+ gas += storageKeys * params.TxAccessListStorageKeyGas
+
// EIP-7981: access list data is charged in addition to the base charge.
if isAmsterdam {
- gas += uint64(len(accessList)) * common.AddressLength * params.TxCostFloorPerToken7976 * params.TxTokenPerNonZeroByte
- gas += uint64(accessList.StorageKeys()) * common.HashLength * params.TxCostFloorPerToken7976 * params.TxTokenPerNonZeroByte
+ const (
+ addressCost = common.AddressLength * params.TxCostFloorPerToken7976 * params.TxTokenPerNonZeroByte
+ storageKeyCost = common.HashLength * params.TxCostFloorPerToken7976 * params.TxTokenPerNonZeroByte
+ )
+ if (math.MaxUint64-gas)/addressCost < addresses {
+ return 0, ErrGasUintOverflow
+ }
+ gas += addresses * addressCost
+ if (math.MaxUint64-gas)/storageKeyCost < storageKeys {
+ return 0, ErrGasUintOverflow
+ }
+ gas += storageKeys * storageKeyCost
}
}
if authList != nil {
Member
Author
There was a problem hiding this comment.
Yeah makes sense
Member
|
Please rebase and address the comments i left. |
fjl
reviewed
Apr 21, 2026
|
|
||
| // Check for overflow | ||
| if (math.MaxUint64-params.TxGas)/params.TxCostFloorPerToken < tokens { | ||
| if (math.MaxUint64-params.TxGas)/tokenCost < tokens { |
Contributor
There was a problem hiding this comment.
The overflow check here seems a bit over-protective. The overflow could only happen if len(data) is very large. But if we were worried about that happening, we would have to check for overflow also in the code above where we calculate based on len(data). Checking for overflow only here is just weird.
MariusVanDerWijden
force-pushed
the
eip-7981
branch
from
April 22, 2026 10:50
877cc58 to
e9d5e21
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
based on: #34748
spec: https://eips.ethereum.org/EIPS/eip-7981