From d1720277d08f504c8c4b7b5072248e0b88cb8b94 Mon Sep 17 00:00:00 2001 From: ltitanb Date: Fri, 21 Nov 2025 17:19:31 +0000 Subject: [PATCH 1/2] fix --- beacon/engine/types.go | 3 ++- core/blockchain_insert.go | 10 ++++++---- core/types/unsealed_block.go | 5 +++++ 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/beacon/engine/types.go b/beacon/engine/types.go index 304da1defb..f2807884bd 100644 --- a/beacon/engine/types.go +++ b/beacon/engine/types.go @@ -470,7 +470,7 @@ func SealBlock(bc *core.BlockChain, ub *types.UnsealedBlock) (*types.Block, erro Nonce: types.EncodeNonce(0), BaseFee: new(big.Int).SetUint64(ub.Env.Basefee), WithdrawalsHash: withDrawalsHash, - BlobGasUsed: new(uint64), + BlobGasUsed: &ub.CumulativeBlobGasUsed, ExcessBlobGas: new(uint64), ParentBeaconRoot: &ub.Env.ParentBeaconBlockRoot, RequestsHash: requestsHash, @@ -536,6 +536,7 @@ type Seal struct { StateRoot common.Hash `json:"stateRoot"` WithdrawalsRoot common.Hash `json:"withdrawalsRoot"` BlockHash common.Hash `json:"blockHash"` + BlobGasUsed uint64 `json:"blobGasUsed"` } type SignedEnv struct { diff --git a/core/blockchain_insert.go b/core/blockchain_insert.go index 403bc0ebea..0ed886a3a0 100644 --- a/core/blockchain_insert.go +++ b/core/blockchain_insert.go @@ -201,7 +201,7 @@ func (bc *BlockChain) InsertNewFrag(frag types.Frag) error { Nonce: types.EncodeNonce(0), BaseFee: new(big.Int).SetUint64(currentUnsealedBlock.Env.Basefee), WithdrawalsHash: &types.EmptyWithdrawalsHash, - BlobGasUsed: new(uint64), + BlobGasUsed: ¤tUnsealedBlock.CumulativeBlobGasUsed, ExcessBlobGas: new(uint64), ParentBeaconRoot: ¤tUnsealedBlock.Env.ParentBeaconBlockRoot, }).WithBody(types.Body{ @@ -216,15 +216,17 @@ func (bc *BlockChain) InsertNewFrag(frag types.Frag) error { return err } - for _, receipt := range res.Receipts { - currentUnsealedBlock.CumulativeBlobGasUsed += receipt.BlobGasUsed - } + // blob txs are not supported, blobGasUsed is used for DA footprint instead + // for _, receipt := range res.Receipts { + // currentUnsealedBlock.CumulativeBlobGasUsed += receipt.BlobGasUsed + // } currentUnsealedBlock.Frags = append(currentUnsealedBlock.Frags, frag) currentUnsealedBlock.LastSequenceNumber = &frag.Seq currentUnsealedBlock.Receipts = append(currentUnsealedBlock.Receipts, res.Receipts...) currentUnsealedBlock.Logs = append(currentUnsealedBlock.Logs, res.Logs...) currentUnsealedBlock.CumulativeGasUsed = res.GasUsed + currentUnsealedBlock.CumulativeBlobGasUsed += frag.BlobGasUsed return nil } diff --git a/core/types/unsealed_block.go b/core/types/unsealed_block.go index 53fec9e673..240b2e5e9a 100644 --- a/core/types/unsealed_block.go +++ b/core/types/unsealed_block.go @@ -92,6 +92,7 @@ type Frag struct { Seq uint64 IsLast bool Txs []*Transaction + BlobGasUsed uint64 } func (f *Frag) IsFirst() bool { @@ -104,6 +105,7 @@ func (f *Frag) UnmarshalJSON(data []byte) error { Seq uint64 `json:"seq"` IsLast bool `json:"isLast"` Txs []hexutil.Bytes `json:"txs"` + BlobGasUsed uint64 `json:"blobGasUsed"` } if err := json.Unmarshal(data, &frag); err != nil { @@ -115,6 +117,7 @@ func (f *Frag) UnmarshalJSON(data []byte) error { f.Seq = frag.Seq f.IsLast = frag.IsLast f.Txs = make([]*Transaction, len(frag.Txs)) + f.BlobGasUsed = frag.BlobGasUsed for i, txData := range frag.Txs { var tx Transaction @@ -145,11 +148,13 @@ func (f *Frag) MarshalJSON() ([]byte, error) { IsLast bool `json:"isLast"` WithdrawalsRoot common.Hash `json:"withdrawalsRoot"` Txs [][]byte `json:"txs"` + BlobGasUsed uint64 `json:"blobGasUsed"` }{ BlockNumber: f.BlockNumber, Seq: f.Seq, IsLast: f.IsLast, Txs: txs, + BlobGasUsed: f.BlobGasUsed, }) } From 32d7572c885fa640e5eb9563f8fe0a7cacb878db Mon Sep 17 00:00:00 2001 From: Suthiwat Date: Mon, 24 Nov 2025 12:39:53 +0000 Subject: [PATCH 2/2] reordered BlobGasUsed --- core/types/unsealed_block.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/core/types/unsealed_block.go b/core/types/unsealed_block.go index 240b2e5e9a..9d7b5e2593 100644 --- a/core/types/unsealed_block.go +++ b/core/types/unsealed_block.go @@ -91,8 +91,8 @@ type Frag struct { BlockNumber uint64 Seq uint64 IsLast bool - Txs []*Transaction BlobGasUsed uint64 + Txs []*Transaction } func (f *Frag) IsFirst() bool { @@ -104,8 +104,8 @@ func (f *Frag) UnmarshalJSON(data []byte) error { BlockNumber uint64 `json:"blockNumber"` Seq uint64 `json:"seq"` IsLast bool `json:"isLast"` - Txs []hexutil.Bytes `json:"txs"` BlobGasUsed uint64 `json:"blobGasUsed"` + Txs []hexutil.Bytes `json:"txs"` } if err := json.Unmarshal(data, &frag); err != nil { @@ -116,8 +116,8 @@ func (f *Frag) UnmarshalJSON(data []byte) error { f.BlockNumber = frag.BlockNumber f.Seq = frag.Seq f.IsLast = frag.IsLast - f.Txs = make([]*Transaction, len(frag.Txs)) f.BlobGasUsed = frag.BlobGasUsed + f.Txs = make([]*Transaction, len(frag.Txs)) for i, txData := range frag.Txs { var tx Transaction @@ -147,14 +147,14 @@ func (f *Frag) MarshalJSON() ([]byte, error) { Seq uint64 `json:"seq"` IsLast bool `json:"isLast"` WithdrawalsRoot common.Hash `json:"withdrawalsRoot"` - Txs [][]byte `json:"txs"` BlobGasUsed uint64 `json:"blobGasUsed"` + Txs [][]byte `json:"txs"` }{ BlockNumber: f.BlockNumber, Seq: f.Seq, IsLast: f.IsLast, - Txs: txs, BlobGasUsed: f.BlobGasUsed, + Txs: txs, }) }