mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-24 23:46:17 +00:00
2780: don't charge for precompiles
This commit is contained in:
parent
0b699f5791
commit
bde29cee44
2 changed files with 11 additions and 1 deletions
|
|
@ -854,7 +854,10 @@ func (st *stateTransition) chargeCallRecipientEIP2780(value *uint256.Int) bool {
|
|||
cost vm.GasCosts
|
||||
to = *st.msg.To
|
||||
)
|
||||
if !value.IsZero() && st.state.Empty(to) {
|
||||
// EIP-8037: a value transfer to an empty recipient charges NEW_ACCOUNT
|
||||
// state gas — except for precompiles, which are protocol-inherent and not
|
||||
// "created" by the transfer, so the charge is suppressed for them.
|
||||
if !value.IsZero() && st.state.Empty(to) && !st.evm.IsPrecompile(to) {
|
||||
cost.StateGas += params.AccountCreationSize * st.evm.Context.CostPerStateByte
|
||||
}
|
||||
if _, ok := types.ParseDelegation(st.state.GetCode(to)); ok {
|
||||
|
|
|
|||
|
|
@ -46,6 +46,13 @@ func (evm *EVM) precompile(addr common.Address) (PrecompiledContract, bool) {
|
|||
return p, ok
|
||||
}
|
||||
|
||||
// IsPrecompile reports whether addr is an active precompile for the current
|
||||
// fork ruleset.
|
||||
func (evm *EVM) IsPrecompile(addr common.Address) bool {
|
||||
_, ok := evm.precompiles[addr]
|
||||
return ok
|
||||
}
|
||||
|
||||
// BlockContext provides the EVM with auxiliary information. Once provided
|
||||
// it shouldn't be modified.
|
||||
type BlockContext struct {
|
||||
|
|
|
|||
Loading…
Reference in a new issue