Skip to content

Commit 69ae161

Browse files
authored
Revert "core/types: add 4844 data gas fields in Receipt (ethereum#27743)"
This reverts commit 4121121.
1 parent 0d0ee8d commit 69ae161

File tree

11 files changed

+14
-69
lines changed

11 files changed

+14
-69
lines changed

consensus/beacon/consensus.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import (
2424
"github.com/ethereum/go-ethereum/common"
2525
"github.com/ethereum/go-ethereum/consensus"
2626
"github.com/ethereum/go-ethereum/consensus/misc"
27-
"github.com/ethereum/go-ethereum/consensus/misc/eip4844"
2827
"github.com/ethereum/go-ethereum/core/state"
2928
"github.com/ethereum/go-ethereum/core/types"
3029
"github.com/ethereum/go-ethereum/params"
@@ -278,7 +277,7 @@ func (beacon *Beacon) verifyHeader(chain consensus.ChainHeaderReader, header, pa
278277
return fmt.Errorf("invalid dataGasUsed: have %d, expected nil", header.DataGasUsed)
279278
}
280279
if cancun {
281-
if err := eip4844.VerifyEIP4844Header(parent, header); err != nil {
280+
if err := misc.VerifyEIP4844Header(parent, header); err != nil {
282281
return err
283282
}
284283
}

consensus/misc/eip4844/eip4844.go renamed to consensus/misc/eip4844.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// You should have received a copy of the GNU Lesser General Public License
1515
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
1616

17-
package eip4844
17+
package misc
1818

1919
import (
2020
"errors"

consensus/misc/eip4844/eip4844_test.go renamed to consensus/misc/eip4844_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// You should have received a copy of the GNU Lesser General Public License
1515
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
1616

17-
package eip4844
17+
package misc
1818

1919
import (
2020
"fmt"

core/blockchain.go

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ import (
3333
"github.com/ethereum/go-ethereum/common/mclock"
3434
"github.com/ethereum/go-ethereum/common/prque"
3535
"github.com/ethereum/go-ethereum/consensus"
36-
"github.com/ethereum/go-ethereum/consensus/misc/eip4844"
3736
"github.com/ethereum/go-ethereum/core/rawdb"
3837
"github.com/ethereum/go-ethereum/core/state"
3938
"github.com/ethereum/go-ethereum/core/state/snapshot"
@@ -2028,14 +2027,8 @@ func (bc *BlockChain) recoverAncestors(block *types.Block) (common.Hash, error)
20282027
// collectLogs collects the logs that were generated or removed during
20292028
// the processing of a block. These logs are later announced as deleted or reborn.
20302029
func (bc *BlockChain) collectLogs(b *types.Block, removed bool) []*types.Log {
2031-
var dataGasPrice *big.Int
2032-
excessDataGas := b.ExcessDataGas()
2033-
if excessDataGas != nil {
2034-
dataGasPrice = eip4844.CalcBlobFee(*excessDataGas)
2035-
}
2036-
20372030
receipts := rawdb.ReadRawReceipts(bc.db, b.Hash(), b.NumberU64())
2038-
if err := receipts.DeriveFields(bc.chainConfig, b.Hash(), b.NumberU64(), b.Time(), b.BaseFee(), dataGasPrice, b.Transactions()); err != nil {
2031+
if err := receipts.DeriveFields(bc.chainConfig, b.Hash(), b.NumberU64(), b.Time(), b.BaseFee(), b.Transactions()); err != nil {
20392032
log.Error("Failed to derive block receipts fields", "hash", b.Hash(), "number", b.NumberU64(), "err", err)
20402033
}
20412034

core/rawdb/accessors_chain.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import (
2424
"math/big"
2525

2626
"github.com/ethereum/go-ethereum/common"
27-
"github.com/ethereum/go-ethereum/consensus/misc/eip4844"
2827
"github.com/ethereum/go-ethereum/core/types"
2928
"github.com/ethereum/go-ethereum/crypto"
3029
"github.com/ethereum/go-ethereum/ethdb"
@@ -638,21 +637,13 @@ func ReadReceipts(db ethdb.Reader, hash common.Hash, number uint64, time uint64,
638637
return nil
639638
}
640639
header := ReadHeader(db, hash, number)
641-
642640
var baseFee *big.Int
643641
if header == nil {
644642
baseFee = big.NewInt(0)
645643
} else {
646644
baseFee = header.BaseFee
647645
}
648-
649-
// Compute effective data gas price.
650-
var dataGasPrice *big.Int
651-
if header != nil && header.ExcessDataGas != nil {
652-
dataGasPrice = eip4844.CalcBlobFee(*header.ExcessDataGas)
653-
}
654-
655-
if err := receipts.DeriveFields(config, hash, number, time, baseFee, dataGasPrice, body.Transactions); err != nil {
646+
if err := receipts.DeriveFields(config, hash, number, time, baseFee, body.Transactions); err != nil {
656647
log.Error("Failed to derive block receipts fields", "hash", hash, "number", number, "err", err)
657648
return nil
658649
}

core/state_processor_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import (
2727
"github.com/ethereum/go-ethereum/consensus/beacon"
2828
"github.com/ethereum/go-ethereum/consensus/ethash"
2929
"github.com/ethereum/go-ethereum/consensus/misc"
30-
"github.com/ethereum/go-ethereum/consensus/misc/eip4844"
3130
"github.com/ethereum/go-ethereum/core/rawdb"
3231
"github.com/ethereum/go-ethereum/core/types"
3332
"github.com/ethereum/go-ethereum/core/vm"
@@ -406,7 +405,7 @@ func GenerateBadBlock(parent *types.Block, engine consensus.Engine, txs types.Tr
406405
pExcess = *parent.ExcessDataGas()
407406
pUsed = *parent.DataGasUsed()
408407
}
409-
excess := eip4844.CalcExcessDataGas(pExcess, pUsed)
408+
excess := misc.CalcExcessDataGas(pExcess, pUsed)
410409
used := uint64(nBlobs * params.BlobTxDataGasPerBlob)
411410
header.ExcessDataGas = &excess
412411
header.DataGasUsed = &used

core/state_transition.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424

2525
"github.com/ethereum/go-ethereum/common"
2626
cmath "github.com/ethereum/go-ethereum/common/math"
27-
"github.com/ethereum/go-ethereum/consensus/misc/eip4844"
27+
"github.com/ethereum/go-ethereum/consensus/misc"
2828
"github.com/ethereum/go-ethereum/core/types"
2929
"github.com/ethereum/go-ethereum/core/vm"
3030
"github.com/ethereum/go-ethereum/params"
@@ -252,7 +252,7 @@ func (st *StateTransition) buyGas() error {
252252
balanceCheck.Add(balanceCheck, blobBalanceCheck)
253253
// Pay for dataGasUsed * actual blob fee
254254
blobFee := new(big.Int).SetUint64(dataGas)
255-
blobFee.Mul(blobFee, eip4844.CalcBlobFee(*st.evm.Context.ExcessDataGas))
255+
blobFee.Mul(blobFee, misc.CalcBlobFee(*st.evm.Context.ExcessDataGas))
256256
mgval.Add(mgval, blobFee)
257257
}
258258
}
@@ -333,9 +333,8 @@ func (st *StateTransition) preCheck() error {
333333
if st.evm.ChainConfig().IsCancun(st.evm.Context.BlockNumber, st.evm.Context.Time) {
334334
if st.dataGasUsed() > 0 {
335335
// Check that the user is paying at least the current blob fee
336-
blobFee := eip4844.CalcBlobFee(*st.evm.Context.ExcessDataGas)
337-
if st.msg.BlobGasFeeCap.Cmp(blobFee) < 0 {
338-
return fmt.Errorf("%w: address %v have %v want %v", ErrBlobFeeCapTooLow, st.msg.From.Hex(), st.msg.BlobGasFeeCap, blobFee)
336+
if have, want := st.msg.BlobGasFeeCap, misc.CalcBlobFee(*st.evm.Context.ExcessDataGas); have.Cmp(want) < 0 {
337+
return fmt.Errorf("%w: address %v have %v want %v", ErrBlobFeeCapTooLow, st.msg.From.Hex(), have, want)
339338
}
340339
}
341340
}

core/types/gen_receipt_json.go

Lines changed: 0 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/types/receipt.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ type Receipt struct {
6363
ContractAddress common.Address `json:"contractAddress"`
6464
GasUsed uint64 `json:"gasUsed" gencodec:"required"`
6565
EffectiveGasPrice *big.Int `json:"effectiveGasPrice"` // required, but tag omitted for backwards compatibility
66-
DataGasUsed uint64 `json:"dataGasUsed,omitempty"`
67-
DataGasPrice *big.Int `json:"dataGasPrice,omitempty"`
6866

6967
// Inclusion information: These fields provide information about the inclusion of the
7068
// transaction corresponding to this receipt.
@@ -315,7 +313,7 @@ func (rs Receipts) EncodeIndex(i int, w *bytes.Buffer) {
315313

316314
// DeriveFields fills the receipts with their computed fields based on consensus
317315
// data and contextual infos like containing block and transactions.
318-
func (rs Receipts) DeriveFields(config *params.ChainConfig, hash common.Hash, number uint64, time uint64, baseFee *big.Int, dataGasPrice *big.Int, txs []*Transaction) error {
316+
func (rs Receipts) DeriveFields(config *params.ChainConfig, hash common.Hash, number uint64, time uint64, baseFee *big.Int, txs []*Transaction) error {
319317
signer := MakeSigner(config, new(big.Int).SetUint64(number), time)
320318

321319
logIndex := uint(0)
@@ -326,13 +324,8 @@ func (rs Receipts) DeriveFields(config *params.ChainConfig, hash common.Hash, nu
326324
// The transaction type and hash can be retrieved from the transaction itself
327325
rs[i].Type = txs[i].Type()
328326
rs[i].TxHash = txs[i].Hash()
329-
rs[i].EffectiveGasPrice = txs[i].inner.effectiveGasPrice(new(big.Int), baseFee)
330327

331-
// EIP-4844 blob transaction fields
332-
if txs[i].Type() == BlobTxType {
333-
rs[i].DataGasUsed = txs[i].BlobGas()
334-
rs[i].DataGasPrice = dataGasPrice
335-
}
328+
rs[i].EffectiveGasPrice = txs[i].inner.effectiveGasPrice(new(big.Int), baseFee)
336329

337330
// block location fields
338331
rs[i].BlockHash = hash

core/types/receipt_test.go

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ var (
137137
GasTipCap: uint256.NewInt(66),
138138
GasFeeCap: uint256.NewInt(1066),
139139
BlobFeeCap: uint256.NewInt(100066),
140-
BlobHashes: []common.Hash{{}},
141140
}),
142141
NewTx(&BlobTx{
143142
To: to7,
@@ -147,7 +146,6 @@ var (
147146
GasTipCap: uint256.NewInt(77),
148147
GasFeeCap: uint256.NewInt(1077),
149148
BlobFeeCap: uint256.NewInt(100077),
150-
BlobHashes: []common.Hash{{}, {}, {}},
151149
}),
152150
}
153151

@@ -272,8 +270,6 @@ var (
272270
TxHash: txs[5].Hash(),
273271
GasUsed: 6,
274272
EffectiveGasPrice: big.NewInt(1066),
275-
DataGasUsed: params.BlobTxDataGasPerBlob,
276-
DataGasPrice: big.NewInt(920),
277273
BlockHash: blockHash,
278274
BlockNumber: blockNumber,
279275
TransactionIndex: 5,
@@ -287,8 +283,6 @@ var (
287283
TxHash: txs[6].Hash(),
288284
GasUsed: 7,
289285
EffectiveGasPrice: big.NewInt(1077),
290-
DataGasUsed: 3 * params.BlobTxDataGasPerBlob,
291-
DataGasPrice: big.NewInt(920),
292286
BlockHash: blockHash,
293287
BlockNumber: blockNumber,
294288
TransactionIndex: 6,
@@ -309,9 +303,8 @@ func TestDecodeEmptyTypedReceipt(t *testing.T) {
309303
func TestDeriveFields(t *testing.T) {
310304
// Re-derive receipts.
311305
basefee := big.NewInt(1000)
312-
dataGasPrice := big.NewInt(920)
313306
derivedReceipts := clearComputedFieldsOnReceipts(receipts)
314-
err := Receipts(derivedReceipts).DeriveFields(params.TestChainConfig, blockHash, blockNumber.Uint64(), blockTime, basefee, dataGasPrice, txs)
307+
err := Receipts(derivedReceipts).DeriveFields(params.TestChainConfig, blockHash, blockNumber.Uint64(), blockTime, basefee, txs)
315308
if err != nil {
316309
t.Fatalf("DeriveFields(...) = %v, want <nil>", err)
317310
}
@@ -508,9 +501,6 @@ func clearComputedFieldsOnReceipt(receipt *Receipt) *Receipt {
508501
cpy.ContractAddress = common.Address{0xff, 0xff, 0x33}
509502
cpy.GasUsed = 0xffffffff
510503
cpy.Logs = clearComputedFieldsOnLogs(receipt.Logs)
511-
cpy.EffectiveGasPrice = big.NewInt(0)
512-
cpy.DataGasUsed = 0
513-
cpy.DataGasPrice = nil
514504
return &cpy
515505
}
516506

0 commit comments

Comments
 (0)