Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

P-Chain merkledb -- remove caches #2392

Merged
merged 14 commits into from
Dec 1, 2023

Conversation

danlaine
Copy link

Why this should be merged

merkledb does its own caching. Instead of caching in both state and merkledb, we can just rely on merkledb to cache bytes and parse those bytes.

How this works

CTRL + X

How this was tested

Existing UT

@@ -674,31 +542,23 @@ func (s *state) GetSubnets() ([]*txs.Tx, error) {

func (s *state) AddSubnet(createSubnetTx *txs.Tx) {
s.addedPermissionedSubnets = append(s.addedPermissionedSubnets, createSubnetTx)
if s.permissionedSubnetCache != nil {
s.permissionedSubnetCache = append(s.permissionedSubnetCache, createSubnetTx)
Copy link
Author

Choose a reason for hiding this comment

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

s.permissionedSubnetCache has to be updated, or else GetSubnets may return a stale result after the first call.


// UTXOs section
modifiedUTXOs map[ids.ID]*avax.UTXO // map of UTXO ID -> *UTXO
utxoCache cache.Cacher[ids.ID, *avax.UTXO] // UTXO ID -> *UTXO. If the *UTXO is nil the UTXO doesn't exist
modifiedUTXOs map[ids.ID]*avax.UTXO // map of UTXO ID -> *UTXO

// Metadata section
chainTime, latestComittedChainTime time.Time
Copy link
Contributor

Choose a reason for hiding this comment

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

@danlaine do we really need latestComittedChainTime and latestCommittedLastAcceptedBlkID? I can't recall if we do

Copy link
Author

Choose a reason for hiding this comment

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

They can save us from doing unnecessary writes but they'll probably be removed in a subsequent PR as we change how we commit this data to merkledb (i.e. with views)

@danlaine danlaine merged commit 3ea16e1 into pchain_merkleDB Dec 1, 2023
14 checks passed
@danlaine danlaine deleted the pchain_merkleDB_remove_caches branch December 1, 2023 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants