Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

core: implement eip-7623: increase calldata cost #29040

Closed

Conversation

MariusVanDerWijden
Copy link
Member

Draft implementation for discussion

@vbuterin
Copy link
Contributor

The floor implementation looks like it's counting bytes rather than tokens?

dataLen := uint64(len(data))

What I think you want is something like:

TokensPerNonzeroByteFrontier uint64 = 17
TokensPerNonzeroByte uint64 = 4
TxTokenGas uint64 = 4
CostFloorPerToken7623 uint64 = 17

tokensPerNonzeroByte = params.TokensPerNonzeroByteFrontier

if isEIP2028 {
    tokensPerNonzeroByte = params.tokensPerNonzeroByte
}
dataTokens = z + nz * TokensPerNonzeroByte
gasForData = dataTokens * params.TxTokenGas
floor := params.CostFloorPerToken7623 * dataTokens

@MariusVanDerWijden
Copy link
Member Author

MariusVanDerWijden commented Feb 28, 2024

Yep, you're right. We have not had the concept of tokens yet, so I got a bit confused.
It should be okay now

edit: (nvm, the contract creation gas is still in the max, fixing...)

@MariusVanDerWijden MariusVanDerWijden changed the title [wip] core: implement eip-7623: increase calldata cost core: implement eip-7623: increase calldata cost Nov 26, 2024
@ChanHongMing
Copy link

ChanHongMing commented Dec 3, 2024

the current implementation doesn't seems to match the specification on https://github.com/ethereum/EIPs/blob/a7fb2260ae2ea39bdd31886832c9e45452d0e76a/EIPS/eip-7623.md

In the EIP, the new formula is

tx.gasUsed = {
    21000 \ 
    + 
    max (
        STANDARD_TOKEN_COST * tokens_in_calldata \
           + evm_gas_used \
           + isContractCreation * (32000 + InitCodeWordGas * words(calldata)),
        TOTAL_COST_FLOOR_PER_TOKEN * tokens_in_calldata
    )
}

This implementation looks like

tx.gasUsed = {
    21000 \ 
    + evm_gas_used \
    + isContractCreation * (32000 + InitCodeWordGas * words(calldata)) \
    + max (
        STANDARD_TOKEN_COST * tokens_in_calldata ,
        TOTAL_COST_FLOOR_PER_TOKEN * tokens_in_calldata
    )
}

@MariusVanDerWijden
Copy link
Member Author

closing this in favor of #30946

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants