From 003d175e21e03858c8879a32ff1ba35425cb8566 Mon Sep 17 00:00:00 2001 From: Sina Mahmoodi Date: Tue, 9 Jan 2024 16:22:35 +0330 Subject: [PATCH 1/2] core: check for create blob txes --- core/error.go | 6 ++++++ core/state_transition.go | 6 ++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/core/error.go b/core/error.go index 4214ed207a91..f77cb6160c4e 100644 --- a/core/error.go +++ b/core/error.go @@ -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") ) diff --git a/core/state_transition.go b/core/state_transition.go index 540f63fda7ea..fa121741d203 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -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 { From 35c0777f95370f166df99290a90e084e4cad923f Mon Sep 17 00:00:00 2001 From: Sina Mahmoodi Date: Tue, 9 Jan 2024 17:28:50 +0330 Subject: [PATCH 2/2] add clarifying comment --- core/state_transition.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/state_transition.go b/core/state_transition.go index fa121741d203..1280ecfd120f 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -314,6 +314,9 @@ func (st *StateTransition) preCheck() error { } // Check the blob version validity if msg.BlobHashes != nil { + // The to field of a blob tx type is mandatory. + // However messages created through RPC (eth_call) + // don't have this restriction. if msg.To == nil { return ErrBlobTxCreate }