Skip to content

Conversation

DracoLi
Copy link

@DracoLi DracoLi commented Jul 29, 2025

Why this should be merged

Shouldn't be merged in as is.

This is a POC for integrating a dedicated block database via blockdb and a starting point to start the discussion on how to best integrate x/blockdb into coreth.

How this works

Updates coreth to use blockdb for block storage instead of the existing key-value ethdb.Database. Block related data like hash -> block number mapping, receipts are all still stored in the eth database. Only the raw block bytes (block header and body) are moved out into the blockdb.

  • Blocks are written to the blockdb on Verify.
  • Since blockdb only supports one block per height, if we need to store additional blocks per height, it will be stored in the eth database like before.
  • blockdb will always store the accepted blocks.
  • When reorgs happen, we will ensure the blockdb stores the accepted blocks and the eth database stores the sidechain blocks. This sidechain blocks will eventually get deleted when Reject is called on them.

How this was tested

  • All tests passing

Copy link
Contributor

@alarso16 alarso16 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm really glad you tried to match interfaces as much as possible. The fact that blockDb can only store one block at any height is pretty prohibitive right now - I think some of this would be resolved with SAE, but @StephenButtolph would have more details on this

snaptree *snapshot.Tree
}

func ReadHeadBlock(db ethdb.Database, blockDb ethblockdb.Database) *types.Block {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function feels out of place here

if !bc.blockDb.HasBlock(blockNumber) {
bc.blockDb.WriteBlock(block)
} else {
// write block to the chaindb if we already stored a block at the same height
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems really confusing, we only use blockDB to store 1 block at any given height? This seems fine after SAE but is pretty incompatible until then.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a note: we usually use the prefix eth to mean that it was taken from upstream (i.e. go-ethereum). You should drop it from this folder name

@DracoLi
Copy link
Author

DracoLi commented Sep 9, 2025

replaced by #1189

@DracoLi DracoLi closed this Sep 9, 2025
@DracoLi DracoLi deleted the dl/blockdb-poc branch September 26, 2025 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants