mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
only allow blob tx after cancun fork
This commit is contained in:
parent
93c541ad56
commit
ca54e8aa52
2 changed files with 25 additions and 17 deletions
|
|
@ -110,4 +110,7 @@ var (
|
||||||
|
|
||||||
// ErrBlobTxCreate is returned if a blob transaction has no explicit to field.
|
// ErrBlobTxCreate is returned if a blob transaction has no explicit to field.
|
||||||
ErrBlobTxCreate = errors.New("blob transaction of type create")
|
ErrBlobTxCreate = errors.New("blob transaction of type create")
|
||||||
|
|
||||||
|
// ErrBlobTxTooEarly is returned if a blob transaction is found before cancun fork.
|
||||||
|
ErrBlobTxTooEarly = errors.New("blob transaction is only allowed after cancun fork")
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -319,25 +319,26 @@ func (st *StateTransition) preCheck() error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Check the blob version validity
|
|
||||||
if msg.BlobHashes != nil {
|
|
||||||
// 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.
|
|
||||||
// However, messages created through RPC (eth_call) don't have this restriction.
|
|
||||||
if msg.To == nil {
|
|
||||||
return ErrBlobTxCreate
|
|
||||||
}
|
|
||||||
if len(msg.BlobHashes) == 0 {
|
|
||||||
return ErrMissingBlobHashes
|
|
||||||
}
|
|
||||||
for i, hash := range msg.BlobHashes {
|
|
||||||
if !kzg4844.IsValidVersionedHash(hash[:]) {
|
|
||||||
return fmt.Errorf("blob %d has invalid hash version", i)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Check that the user is paying at least the current blob fee
|
// Check that the user is paying at least the current blob fee
|
||||||
if st.evm.ChainConfig().IsCancun(st.evm.Context.BlockNumber, st.evm.Context.Time) {
|
if st.evm.ChainConfig().IsCancun(st.evm.Context.BlockNumber, st.evm.Context.Time) {
|
||||||
|
// Check the blob version validity
|
||||||
|
if msg.BlobHashes != nil {
|
||||||
|
// 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.
|
||||||
|
// However, messages created through RPC (eth_call) don't have this restriction.
|
||||||
|
if msg.To == nil {
|
||||||
|
return ErrBlobTxCreate
|
||||||
|
}
|
||||||
|
if len(msg.BlobHashes) == 0 {
|
||||||
|
return ErrMissingBlobHashes
|
||||||
|
}
|
||||||
|
for i, hash := range msg.BlobHashes {
|
||||||
|
if !kzg4844.IsValidVersionedHash(hash[:]) {
|
||||||
|
return fmt.Errorf("blob %d has invalid hash version", i)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if st.blobGasUsed() > 0 {
|
if st.blobGasUsed() > 0 {
|
||||||
// Skip the checks if gas fields are zero and blobBaseFee was explicitly disabled (eth_call)
|
// Skip the checks if gas fields are zero and blobBaseFee was explicitly disabled (eth_call)
|
||||||
skipCheck := st.evm.Config.NoBaseFee && msg.BlobGasFeeCap.BitLen() == 0
|
skipCheck := st.evm.Config.NoBaseFee && msg.BlobGasFeeCap.BitLen() == 0
|
||||||
|
|
@ -350,6 +351,10 @@ func (st *StateTransition) preCheck() error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if msg.BlobHashes != nil {
|
||||||
|
return ErrBlobTxTooEarly
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return st.buyGas()
|
return st.buyGas()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue