Skip to content

Conversation

@joey0612
Copy link
Contributor

@joey0612 joey0612 commented Aug 7, 2024

Description

add a description of your changes here...

Rationale

tell us why we need these changes...

Example

add an example CLI or API response...

Changes

Notable changes:

  • add each change in a bullet point here
  • ...

@joey0612 joey0612 added the wip work in process label Aug 7, 2024

type cachingVersaDB struct {
triedb *triedb.Database
versionDB versa.Database
Copy link

Choose a reason for hiding this comment

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

Why to have a "versionDB" here? Is there any difference with "triedb"?

Copy link
Contributor Author

@joey0612 joey0612 Aug 12, 2024

Choose a reason for hiding this comment

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

There is no essential difference; here, versiondb is for convenience.

codeSizeCache *lru.Cache[common.Hash, int]
codeCache *lru.SizeConstrainedCache[common.Hash, []byte]

accTree *VersaTree
Copy link

Choose a reason for hiding this comment

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

Where is VersaTree impl? And why to have a "accTree"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Facilitate OpenStorageTree to avoid reopen.

}

// TODO:: if root tree, versa db shouldb ignore check version
state, err := cv.versionDB.OpenState(0, root, cv.mode)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggest to use the block num as the version here, not 0.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It’s fine, but currently, this version is of no use to the upper layer and has brought about a burden. The plan is to make the upper layer aware of the version only if needed in the future. The conclusion is that it can be transparent to the upper layer for the time being.

return val
}

func (vt *VersaTree) GetAccount(address common.Address) (*types.StateAccount, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the version of the account should be returned to the caller, and maintained by the account itself, so that it can be provided to versaDB when opening the storage tree.

But if do this, a lot of changes will be required. Therefore, we need to do some trade off whether the version should be known to the caller.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Similarly, currently the upper layer does not have a strong dependency on the version, so it can be transparent to the upper layer for the time being. If needed in the future, it can be exposed then. The focus at this stage should not be on this.

@mtrackeros
Copy link

Description

add a description of your changes here...

Rationale

tell us why we need these changes...

Example

add an example CLI or API response...

Changes

Notable changes:

  • add each change in a bullet point here
  • ...

@buddh0 buddh0 marked this pull request as draft November 28, 2025 01:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

wip work in process

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants