mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-23 13:16:42 +00:00
core: add SkipTransactionChecks
Also move EIP-7825 check earlier.
This commit is contained in:
parent
ef133c3c9f
commit
fdaff4efe1
1 changed files with 13 additions and 12 deletions
|
|
@ -164,11 +164,12 @@ type Message struct {
|
||||||
// or the state prefetching.
|
// or the state prefetching.
|
||||||
SkipNonceChecks bool
|
SkipNonceChecks bool
|
||||||
|
|
||||||
// When SkipFromEOACheck is true, the message sender is not checked to be an EOA.
|
// When set, the message is not treated as a transaction, and certain
|
||||||
SkipFromEOACheck bool
|
// transaction-specific checks are skipped:
|
||||||
|
//
|
||||||
// If enabled, the message gas limit is not checked against the protocol-enforced tx gaslimit.
|
// - From is not verified to be an EOA
|
||||||
SkipTxGasLimitCheck bool
|
// - GasLimit is not checked against the protocol defined tx gaslimit
|
||||||
|
SkipTransactionChecks bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// TransactionToMessage converts a transaction into a Message.
|
// TransactionToMessage converts a transaction into a Message.
|
||||||
|
|
@ -185,7 +186,7 @@ func TransactionToMessage(tx *types.Transaction, s types.Signer, baseFee *big.In
|
||||||
AccessList: tx.AccessList(),
|
AccessList: tx.AccessList(),
|
||||||
SetCodeAuthorizations: tx.SetCodeAuthorizations(),
|
SetCodeAuthorizations: tx.SetCodeAuthorizations(),
|
||||||
SkipNonceChecks: false,
|
SkipNonceChecks: false,
|
||||||
SkipFromEOACheck: false,
|
SkipTransactionChecks: false,
|
||||||
BlobHashes: tx.BlobHashes(),
|
BlobHashes: tx.BlobHashes(),
|
||||||
BlobGasFeeCap: tx.BlobGasFeeCap(),
|
BlobGasFeeCap: tx.BlobGasFeeCap(),
|
||||||
}
|
}
|
||||||
|
|
@ -323,7 +324,12 @@ func (st *stateTransition) preCheck() error {
|
||||||
msg.From.Hex(), stNonce)
|
msg.From.Hex(), stNonce)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !msg.SkipFromEOACheck {
|
isOsaka := st.evm.ChainConfig().IsOsaka(st.evm.Context.BlockNumber, st.evm.Context.Time)
|
||||||
|
if !msg.SkipTransactionChecks {
|
||||||
|
// Verify tx gas limit does not exceed EIP-7825 cap.
|
||||||
|
if isOsaka && msg.GasLimit > params.MaxTxGas {
|
||||||
|
return fmt.Errorf("%w (cap: %d, tx: %d)", ErrGasLimitTooHigh, params.MaxTxGas, msg.GasLimit)
|
||||||
|
}
|
||||||
// Make sure the sender is an EOA
|
// Make sure the sender is an EOA
|
||||||
code := st.state.GetCode(msg.From)
|
code := st.state.GetCode(msg.From)
|
||||||
_, delegated := types.ParseDelegation(code)
|
_, delegated := types.ParseDelegation(code)
|
||||||
|
|
@ -357,7 +363,6 @@ func (st *stateTransition) preCheck() error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Check the blob version validity
|
// Check the blob version validity
|
||||||
isOsaka := st.evm.ChainConfig().IsOsaka(st.evm.Context.BlockNumber, st.evm.Context.Time)
|
|
||||||
if msg.BlobHashes != nil {
|
if msg.BlobHashes != nil {
|
||||||
// The to field of a blob tx type is mandatory, and a `BlobTx` transaction internally
|
// The to field of a blob tx type is mandatory, and a `BlobTx` transaction internally
|
||||||
// has it as a non-nillable value, so any msg derived from blob transaction has it non-nil.
|
// has it as a non-nillable value, so any msg derived from blob transaction has it non-nil.
|
||||||
|
|
@ -401,10 +406,6 @@ func (st *stateTransition) preCheck() error {
|
||||||
return fmt.Errorf("%w (sender %v)", ErrEmptyAuthList, msg.From)
|
return fmt.Errorf("%w (sender %v)", ErrEmptyAuthList, msg.From)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Verify tx gas limit does not exceed EIP-7825 cap.
|
|
||||||
if isOsaka && !msg.SkipTxGasLimitCheck && msg.GasLimit > params.MaxTxGas {
|
|
||||||
return fmt.Errorf("%w (cap: %d, tx: %d)", ErrGasLimitTooHigh, params.MaxTxGas, msg.GasLimit)
|
|
||||||
}
|
|
||||||
return st.buyGas()
|
return st.buyGas()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue