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..9d7b5e2593 100644 --- a/core/types/unsealed_block.go +++ b/core/types/unsealed_block.go @@ -91,6 +91,7 @@ type Frag struct { BlockNumber uint64 Seq uint64 IsLast bool + BlobGasUsed uint64 Txs []*Transaction } @@ -103,6 +104,7 @@ func (f *Frag) UnmarshalJSON(data []byte) error { BlockNumber uint64 `json:"blockNumber"` Seq uint64 `json:"seq"` IsLast bool `json:"isLast"` + BlobGasUsed uint64 `json:"blobGasUsed"` Txs []hexutil.Bytes `json:"txs"` } @@ -114,6 +116,7 @@ func (f *Frag) UnmarshalJSON(data []byte) error { f.BlockNumber = frag.BlockNumber f.Seq = frag.Seq f.IsLast = frag.IsLast + f.BlobGasUsed = frag.BlobGasUsed f.Txs = make([]*Transaction, len(frag.Txs)) for i, txData := range frag.Txs { @@ -144,11 +147,13 @@ func (f *Frag) MarshalJSON() ([]byte, error) { Seq uint64 `json:"seq"` IsLast bool `json:"isLast"` WithdrawalsRoot common.Hash `json:"withdrawalsRoot"` + BlobGasUsed uint64 `json:"blobGasUsed"` Txs [][]byte `json:"txs"` }{ BlockNumber: f.BlockNumber, Seq: f.Seq, IsLast: f.IsLast, + BlobGasUsed: f.BlobGasUsed, Txs: txs, }) }