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

[lite-client] Interceptor and recreate trie #6484

Open
wants to merge 16 commits into
base: feat/light-client
Choose a base branch
from

Conversation

miiu96
Copy link
Contributor

@miiu96 miiu96 commented Sep 23, 2024

Reasoning behind the pull request

  • Added interceptor for receipts data trie
  • Added trie sync part and recreate trie for receipts data trie

Testing procedure

Pre-requisites

Based on the Contributing Guidelines the PR author and the reviewers must check the following requirements are met:

  • was the PR targeted to the correct branch?
  • if this is a larger feature that probably needs more than one PR, is there a feat branch created?
  • if this is a feat branch merging, do all satellite projects have a proper tag inside go.mod?

@miiu96 miiu96 self-assigned this Sep 23, 2024
Base automatically changed from receipts-data-trie to feat/light-client September 25, 2024 11:05
# Conflicts:
#	process/receiptslog/trieInteractor.go
}

// NewReceiptsManager will create a new instance of receipts manager
func NewReceiptsManager(args ArgsReceiptsManager) (*receiptsManager, error) {
if check.IfNil(args.TrieHandler) {
return nil, ErrNilTrieInteractor
}
if args.ReceiptsDataSyncer == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Use check.IfNil(). Also, add a check for the marshaller and hasher

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

}

func (rm *receiptsManager) syncBranchNodesData(receiptsRootHash []byte) (map[string][]byte, error) {
err := rm.receiptsDataSyncer.SyncReceiptsDataFor([][]byte{receiptsRootHash}, context.Background())
Copy link
Contributor

Choose a reason for hiding this comment

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

L105 -> L113 and L127 -> L135 can be extracted in a common function

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

db storage.Persister
}

func NewStorageManagerOnlyGet(db storage.Persister) (*storageManagerOnlyGet, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing comment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added

return nil, nil
}

func (s storageManagerOnlyGet) PutInEpochWithoutCache(_ []byte, _ []byte, _ uint32) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing comment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added

return nil
}

func (s storageManagerOnlyGet) SetEpochForPutOperation(_ uint32) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing comment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added

"github.com/multiversx/mx-chain-go/trie"
)

// RecreateTrieFromDB will recreate the trie from the provided storer
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this not inside trieInteractor.go ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved there


import "context"

type ReceiptsDataSyncerStub struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing comment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added


leafHashes = append(leafHashes, hashes...)

fmt.Println("here", len(nodeHash), len([]byte(nodeHash)))
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove this print

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

continue
}

leafHashes = append(leafHashes, hashes...)
Copy link
Contributor

Choose a reason for hiding this comment

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

These are not only leaf hashes. An intermediary node can have another intermediary node as a child. So basically you collect here every hash except for the root hash.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed.


err = manager.SyncReceiptsTrie(receiptsTrieHash)
require.Nil(t, err)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

You should check that the correct data was synced.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added check in receipts manager

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.

2 participants