@@ -59,10 +59,15 @@ type Receipt struct {
5959 Logs []* Log `json:"logs" gencodec:"required"`
6060
6161 // Implementation fields: These fields are added by geth when processing a transaction.
62- TxHash common.Hash `json:"transactionHash" gencodec:"required"`
63- ContractAddress common.Address `json:"contractAddress"`
64- GasUsed uint64 `json:"gasUsed" gencodec:"required"`
65- EffectiveGasPrice * big.Int `json:"effectiveGasPrice"`
62+ TxHash common.Hash `json:"transactionHash" gencodec:"required"`
63+ ContractAddress common.Address `json:"contractAddress"`
64+ GasUsed uint64 `json:"gasUsed" gencodec:"required"`
65+ // TODO: EffectiveGasPrice should be a required field:
66+ // https://github.com/ethereum/execution-apis/blob/af82a989bead35e2325ecc49a9023df39c548756/src/schemas/receipt.yaml#L49
67+ // Changing it to required is currently breaking cmd/evm/t8n_test.go, so leaving as omitempty for now.
68+ EffectiveGasPrice * big.Int `json:"effectiveGasPrice,omitempty"`
69+ DataGasUsed uint64 `json:"dataGasUsed,omitempty"`
70+ DataGasPrice * big.Int `json:"dataGasPrice,omitempty"`
6671
6772 // Inclusion information: These fields provide information about the inclusion of the
6873 // transaction corresponding to this receipt.
@@ -318,10 +323,9 @@ func (rs Receipts) EncodeIndex(i int, w *bytes.Buffer) {
318323
319324// DeriveFields fills the receipts with their computed fields based on consensus
320325// data and contextual infos like containing block and transactions.
321- func (rs Receipts ) DeriveFields (config * params.ChainConfig , hash common.Hash , number uint64 , time uint64 , baseFee * big.Int , txs []* Transaction ) error {
326+ func (rs Receipts ) DeriveFields (config * params.ChainConfig , hash common.Hash , number uint64 , time uint64 , baseFee * big.Int , parentExcessDataGas * big. Int , txs []* Transaction ) error {
322327 signer := MakeSigner (config , new (big.Int ).SetUint64 (number ), time )
323328
324- logIndex := uint (0 )
325329 if len (txs ) != len (rs ) {
326330 return errors .New ("transaction and receipt count mismatch" )
327331 }
@@ -353,13 +357,30 @@ func (rs Receipts) DeriveFields(config *params.ChainConfig, hash common.Hash, nu
353357 rs [i ].GasUsed = rs [i ].CumulativeGasUsed - rs [i - 1 ].CumulativeGasUsed
354358 }
355359
360+ // Set data gas fields for blob-containing txs
361+ if len (txs [i ].DataHashes ()) > 0 {
362+ rs [i ].DataGasUsed = GetDataGasUsed (len (txs [i ].DataHashes ()))
363+ rs [i ].DataGasPrice = GetDataGasPrice (parentExcessDataGas )
364+ }
365+ }
366+ return rs .DeriveLogFields (hash , number , txs )
367+ }
368+
369+ // DeriveLogFields fills the receipt logs with their computed fields based on consensus data and
370+ // contextual infos like containing block and transactions.
371+ func (rs Receipts ) DeriveLogFields (hash common.Hash , number uint64 , txs []* Transaction ) error {
372+ if len (txs ) != len (rs ) {
373+ return errors .New ("transaction and receipt count mismatch" )
374+ }
375+ logIndex := uint (0 )
376+ for i , r := range rs {
356377 // The derived log fields can simply be set from the block and transaction
357- for j := 0 ; j < len ( rs [ i ] .Logs ); j ++ {
358- rs [ i ]. Logs [ j ] .BlockNumber = number
359- rs [ i ]. Logs [ j ] .BlockHash = hash
360- rs [ i ]. Logs [ j ]. TxHash = rs [i ].TxHash
361- rs [ i ]. Logs [ j ] .TxIndex = uint (i )
362- rs [ i ]. Logs [ j ] .Index = logIndex
378+ for _ , l := range r .Logs {
379+ l .BlockNumber = number
380+ l .BlockHash = hash
381+ l . TxHash = txs [i ].Hash ()
382+ l .TxIndex = uint (i )
383+ l .Index = logIndex
363384 logIndex ++
364385 }
365386 }
0 commit comments