Skip to content

Conversation

@MaksymMalicki
Copy link
Contributor

@MaksymMalicki MaksymMalicki commented Oct 18, 2025

  1. This PR should be reviewed after refactor(juno): Use common interfaces in Juno #3283

  2. It integrates the common interfaces across the project, including in utilities and tests. This PR uses rawDB - direct pebbleDB reads/writes - as a trieDB engine. New components of the pathDB engine will be introduced in the follow-up PRs.

  3. Some parts of the logic weren’t straightforward to unify due to the different ways the old and new states interact with PebbleDB. The old state is tightly coupled with IndexedBatch for reads and writes, while the new state is designed to read using raw DB/snapshots and write using regular PebbleDB Batch. As a result, the following methods were "duplicated" and tailored to the way the respective state and trie functionalities are meant to interact with the DB:

  • blockchain.Store

  • blockchain.GetReverseStateDiff

  • blockchain.Finalise

The adapting had to be also done for the prove logic inside of rpc/v8/storage.go, rpc/v8/storage_test.go, rpc/v9/storage.go, rpc/v9/storage_test.go

  1. The experimental --new-state boolean CLI flag is now fully integrated. It can be used via the command line and in the dbcmd utilities.

  2. The new state package includes some minor bug fixes discovered during previous work (#2912) while debugging sync, RPC, and E2E tests.

  3. A new command was added to the Makefile, to run the unit tests strictly with the new state and trie implementations in the future CI/CD:

test-new-state: clean-testcache rustdeps ## Run tests with new state
	USE_NEW_STATE=true go test $(GO_TAGS) -v ./...

Next PR to review: #3188

@codecov
Copy link

codecov bot commented Oct 18, 2025

Codecov Report

❌ Patch coverage is 29.43633% with 338 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.63%. Comparing base (f1e4fde) to head (18d6727).

Files with missing lines Patch % Lines
blockchain/blockchain.go 27.18% 131 Missing and 19 partials ⚠️
rpc/v8/storage.go 21.87% 72 Missing and 3 partials ⚠️
rpc/v9/storage.go 20.21% 72 Missing and 3 partials ⚠️
core/state/history.go 0.00% 9 Missing ⚠️
core/state/object.go 40.00% 6 Missing ⚠️
genesis/genesis.go 45.45% 3 Missing and 3 partials ⚠️
cmd/juno/dbcmd.go 66.66% 2 Missing and 2 partials ⚠️
core/trie2/triedb/pathdb/database.go 0.00% 4 Missing ⚠️
core/state/state.go 50.00% 1 Missing and 1 partial ⚠️
core/state/statefactory/state_factory.go 0.00% 2 Missing ⚠️
... and 4 more

❌ Your patch check has failed because the patch coverage (29.43%) is below the target coverage (60.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@                             Coverage Diff                              @@
##           maksym/integrate-common-interfaces-rawdb    #3187      +/-   ##
============================================================================
- Coverage                                     76.30%   75.63%   -0.68%     
============================================================================
  Files                                           327      327              
  Lines                                         32335    32704     +369     
============================================================================
+ Hits                                          24673    24735      +62     
- Misses                                         5889     6175     +286     
- Partials                                       1773     1794      +21     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment on lines -281 to -283
root, err := chain.StateCommitment()
require.NoError(t, err)
assert.Equal(t, stateUpdate1.NewRoot, &root)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we remove this test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same here

}

func fetchStateUpdatesAndBlocks(samples int) ([]*core.StateUpdate, []*core.Block, error) {
client := feeder.NewClient(utils.Mainnet.FeederURL)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: We should have a definition var network = utils.Mainnet and use network.FeederURL here, because:

  1. Guarantee that the used network here and in the test functions are the same.
  2. It's easy to change the test network if necessary.

return err
}

return b.trieDB.Journal(stateUpdate.NewRoot)
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: What happens if synchronizer writes a new block in the middle of this process?

// storeBlockData persists all block-related data to the database
func (b *Blockchain) storeBlockData(
txn db.IndexedBatch,
w db.KeyValueWriter,
Copy link
Contributor

@infrmtcs infrmtcs Oct 21, 2025

Choose a reason for hiding this comment

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

I think we should create a separate small PR to replace this db.IndexedBatch with either db.KeyValueWriter or db.KeyValueReader. Because db.IndexedBatch implements both of them, I think it should be quite easy to do.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good idea!

@MaksymMalicki MaksymMalicki changed the base branch from maksym/trie-interface to maksym/rawdb November 18, 2025 20:07
@MaksymMalicki MaksymMalicki changed the base branch from maksym/rawdb to maksym/integrate-common-interfaces-rawdb November 19, 2025 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants