@@ -33,6 +33,8 @@ import (
3333 "github.com/erigontech/erigon-lib/common/u256"
3434 "github.com/erigontech/erigon-lib/crypto"
3535 "github.com/erigontech/erigon-lib/log/v3"
36+ "github.com/erigontech/erigon/consensus"
37+ "github.com/erigontech/erigon/core/state"
3638 "github.com/erigontech/erigon/core/tracing"
3739 "github.com/erigontech/erigon/core/types"
3840 "github.com/erigontech/erigon/core/vm"
@@ -102,7 +104,8 @@ type Message interface {
102104 BlobHashes () []libcommon.Hash
103105 Authorizations () []types.Authorization
104106
105- IsFree () bool
107+ IsFree () bool // service transactions on Gnosis are exempt from EIP-1559 mandatory fees
108+ SetIsFree (bool )
106109}
107110
108111// NewStateTransition initialises and returns a new state transition object.
@@ -133,7 +136,17 @@ func NewStateTransition(evm *vm.EVM, msg Message, gp *GasPool) *StateTransition
133136// `refunds` is false when it is not required to apply gas refunds
134137// `gasBailout` is true when it is not required to fail transaction if the balance is not enough to pay gas.
135138// for trace_call to replicate OE/Parity behaviour
136- func ApplyMessage (evm * vm.EVM , msg Message , gp * GasPool , refunds bool , gasBailout bool ) (* evmtypes.ExecutionResult , error ) {
139+ func ApplyMessage (evm * vm.EVM , msg Message , gp * GasPool , refunds bool , gasBailout bool , engine consensus.EngineReader ) (
140+ * evmtypes.ExecutionResult , error ) {
141+ // Only zero-gas transactions may be service ones
142+ if msg .FeeCap ().IsZero () && ! msg .IsFree () && engine != nil {
143+ blockContext := evm .Context
144+ blockContext .Coinbase = state .SystemAddress
145+ syscall := func (contract libcommon.Address , data []byte ) ([]byte , error ) {
146+ return SysCallContractWithBlockContext (contract , data , evm .ChainConfig (), evm .IntraBlockState (), blockContext , engine , true /* constCall */ )
147+ }
148+ msg .SetIsFree (engine .IsServiceTransaction (msg .From (), syscall ))
149+ }
137150 return NewStateTransition (evm , msg , gp ).TransitionDb (refunds , gasBailout )
138151}
139152
0 commit comments