-
Notifications
You must be signed in to change notification settings - Fork 199
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
base: feat/light-client
Are you sure you want to change the base?
Conversation
# Conflicts: # process/receiptslog/trieInteractor_test.go
# Conflicts: # process/receiptslog/receiptsManager.go # process/receiptslog/trieInteractor.go
# 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 { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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()) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing comment
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing comment
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
process/receiptslog/trieRecreate.go
Outdated
"github.com/multiversx/mx-chain-go/trie" | ||
) | ||
|
||
// RecreateTrieFromDB will recreate the trie from the provided storer |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
trie/receiptsTrie.go
Outdated
|
||
leafHashes = append(leafHashes, hashes...) | ||
|
||
fmt.Println("here", len(nodeHash), len([]byte(nodeHash))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this print
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
trie/receiptsTrie.go
Outdated
continue | ||
} | ||
|
||
leafHashes = append(leafHashes, hashes...) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) | ||
} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
Reasoning behind the pull request
Testing procedure
Pre-requisites
Based on the Contributing Guidelines the PR author and the reviewers must check the following requirements are met:
feat
branch created?feat
branch merging, do all satellite projects have a proper tag insidego.mod
?