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

MaksymMalicki and others added 30 commits August 1, 2025 17:46
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