@@ -1365,16 +1365,6 @@ func (bc *BlockChain) InsertReceiptChain(blockChain types.Blocks, receiptChain [
13651365 if n , err := bc .hc .ValidateHeaderChain (headers ); err != nil {
13661366 return n , err
13671367 }
1368-
1369- // check DA after cancun
1370- lastBlk := blockChain [len (blockChain )- 1 ]
1371- if bc .chainConfig .DBFT != nil && bc .chainConfig .IsCancun (lastBlk .Number (), lastBlk .Time ()) {
1372- if _ , err := CheckDataAvailableInBatch (bc , blockChain ); err != nil {
1373- log .Debug ("CheckDataAvailableInBatch" , "err" , err )
1374- return 0 , err
1375- }
1376- }
1377-
13781368 // Hold the mutation lock
13791369 if ! bc .chainmu .TryLock () {
13801370 return 0 , errChainStopped
@@ -1433,7 +1423,7 @@ func (bc *BlockChain) InsertReceiptChain(blockChain types.Blocks, receiptChain [
14331423 return 0 , consensus .ErrUnknownAncestor
14341424 }
14351425 td := new (big.Int ).Add (ptd , blockChain [0 ].Difficulty ())
1436- writeSize , err := rawdb .WriteAncientBlocksWithBlobs (bc .db , blockChain , receiptChain , td )
1426+ writeSize , err := rawdb .WriteAncientBlocks (bc .db , blockChain , receiptChain , td )
14371427 if err != nil {
14381428 log .Error ("Error importing chain data to ancients" , "err" , err )
14391429 return 0 , err
@@ -1499,9 +1489,6 @@ func (bc *BlockChain) InsertReceiptChain(blockChain types.Blocks, receiptChain [
14991489 rawdb .WriteCanonicalHash (batch , block .Hash (), block .NumberU64 ())
15001490 rawdb .WriteBlock (batch , block )
15011491 rawdb .WriteReceipts (batch , block .Hash (), block .NumberU64 (), receiptChain [i ])
1502- if bc .chainConfig .IsCancun (block .Number (), block .Time ()) {
1503- rawdb .WriteBlobSidecars (batch , block .Hash (), block .NumberU64 (), block .Sidecars ())
1504- }
15051492
15061493 // Write everything belongs to the blocks into the database. So that
15071494 // we can ensure all components of body is completed(body, receipts)
@@ -1576,10 +1563,6 @@ func (bc *BlockChain) writeBlockWithoutState(block *types.Block, td *big.Int) (e
15761563 batch := bc .db .NewBatch ()
15771564 rawdb .WriteTd (batch , block .Hash (), block .NumberU64 (), td )
15781565 rawdb .WriteBlock (batch , block )
1579- // if cancun is enabled, here need to write sidecars too
1580- if bc .chainConfig .IsCancun (block .Number (), block .Time ()) {
1581- rawdb .WriteBlobSidecars (batch , block .Hash (), block .NumberU64 (), block .Sidecars ())
1582- }
15831566 if err := batch .Write (); err != nil {
15841567 log .Crit ("Failed to write block into disk" , "err" , err )
15851568 }
@@ -1618,17 +1601,10 @@ func (bc *BlockChain) writeBlockWithState(block *types.Block, receipts []*types.
16181601 rawdb .WriteTd (blockBatch , block .Hash (), block .NumberU64 (), externTd )
16191602 rawdb .WriteBlock (blockBatch , block )
16201603 rawdb .WriteReceipts (blockBatch , block .Hash (), block .NumberU64 (), receipts )
1621- // if cancun is enabled, here need to write sidecars too
1622- if bc .chainConfig .IsCancun (block .Number (), block .Time ()) {
1623- rawdb .WriteBlobSidecars (blockBatch , block .Hash (), block .NumberU64 (), block .Sidecars ())
1624- }
16251604 rawdb .WritePreimages (blockBatch , statedb .Preimages ())
16261605 if err := blockBatch .Write (); err != nil {
16271606 log .Crit ("Failed to write block into disk" , "err" , err )
16281607 }
1629- if bc .chainConfig .IsCancun (block .Number (), block .Time ()) {
1630- bc .sidecarsCache .Add (block .Hash (), block .Sidecars ())
1631- }
16321608 // Commit all cached state changes into underlying memory database.
16331609 root , err := statedb .Commit (block .NumberU64 (), bc .chainConfig .IsEIP158 (block .Number ()), bc .chainConfig .IsCancun (block .Number (), block .Time ()))
16341610 if err != nil {
@@ -1711,6 +1687,13 @@ func (bc *BlockChain) writeBlockAndSetHead(block *types.Block, receipts []*types
17111687 if err := bc .writeBlockWithState (block , receipts , state ); err != nil {
17121688 return NonStatTy , err
17131689 }
1690+ // if cancun is enabled, here need to write sidecars too
1691+ if bc .chainConfig .IsCancun (block .Number (), block .Time ()) && block .HasBlobTxs () {
1692+ if len (block .Sidecars ()) > 0 {
1693+ rawdb .WriteBlobSidecars (bc .db , block .Hash (), block .NumberU64 (), block .Sidecars ())
1694+ bc .sidecarsCache .Add (block .Hash (), block .Sidecars ())
1695+ }
1696+ }
17141697 currentBlock := bc .CurrentBlock ()
17151698
17161699 // Reorganise the chain if the parent is not the head block
@@ -1843,14 +1826,6 @@ func (bc *BlockChain) insertChain(chain types.Blocks, setHead bool, makeWitness
18431826 bc .chainHeadFeed .Send (ChainHeadEvent {Header : lastCanon .Header ()})
18441827 }
18451828 }()
1846-
1847- // check block data available first
1848- if bc .chainConfig .DBFT != nil {
1849- if index , err := CheckDataAvailableInBatch (bc , chain ); err != nil {
1850- return nil , index , err
1851- }
1852- }
1853-
18541829 // Start the parallel header verifier
18551830 headers := make ([]* types.Header , len (chain ))
18561831 for i , block := range chain {
@@ -2365,9 +2340,6 @@ func (bc *BlockChain) insertSideChain(block *types.Block, it *insertIterator, ma
23652340 // Append the next block to our batch
23662341 block := bc .GetBlock (hashes [i ], numbers [i ])
23672342
2368- if bc .chainConfig .IsCancun (block .Number (), block .Time ()) {
2369- block = block .WithSidecars (bc .GetSidecarsByHash (hashes [i ]))
2370- }
23712343 blocks = append (blocks , block )
23722344 memory += block .Size ()
23732345
@@ -2439,9 +2411,6 @@ func (bc *BlockChain) recoverAncestors(block *types.Block, makeWitness bool) (co
24392411 } else {
24402412 b = bc .GetBlock (hashes [i ], numbers [i ])
24412413 }
2442- if bc .chainConfig .IsCancun (b .Number (), b .Time ()) {
2443- b = b .WithSidecars (bc .GetSidecarsByHash (b .Hash ()))
2444- }
24452414 if _ , _ , err := bc .insertChain (types.Blocks {b }, false , makeWitness && i == 0 ); err != nil {
24462415 return b .ParentHash (), err
24472416 }
@@ -2774,7 +2743,6 @@ func (bc *BlockChain) skipBlock(err error, it *insertIterator) bool {
27742743}
27752744
27762745// reportBlock logs a bad block error.
2777- // bad block need not save receipts & sidecars.
27782746func (bc * BlockChain ) reportBlock (block * types.Block , res * ProcessResult , err error ) {
27792747 var receipts types.Receipts
27802748 if res != nil {
0 commit comments