core: check for create blob txes

This commit is contained in:
Sina Mahmoodi 2024-01-09 16:22:35 +03:30
parent 1010a79c7c
commit 003d175e21
2 changed files with 10 additions and 2 deletions

View file

@ -104,4 +104,10 @@ var (
// ErrBlobFeeCapTooLow is returned if the transaction fee cap is less than the
// blob gas fee of the block.
ErrBlobFeeCapTooLow = errors.New("max fee per blob gas less than block blob gas fee")
// ErrBlobTxCreate is returned if a blob transaction has no explicit to field.
ErrBlobTxCreate = errors.New("blob transaction of type create")
// ErrMissingBlobHashes is returned if a blob transaction has no blob hashes.
ErrMissingBlobHashes = errors.New("blob transaction missing blob hashes")
)

View file

@ -17,7 +17,6 @@
package core
import (
"errors"
"fmt"
"math"
"math/big"
@ -315,8 +314,11 @@ func (st *StateTransition) preCheck() error {
}
// Check the blob version validity
if msg.BlobHashes != nil {
if msg.To == nil {
return ErrBlobTxCreate
}
if len(msg.BlobHashes) == 0 {
return errors.New("blob transaction missing blob hashes")
return ErrMissingBlobHashes
}
for i, hash := range msg.BlobHashes {
if hash[0] != params.BlobTxHashVersion {