-
Notifications
You must be signed in to change notification settings - Fork 33
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
[Persistence] Add logic for updateParamsTree
and updateFlagsTree
functions for the Sparse Merkle Tree
#453
Conversation
Something I was concerned about is whether the Also whether the method for generating the keys/values to actually update the trees is alright? I chose this method as the other functions have types already so defining the struct and its |
updateParamsTree
and updateFlagsTree
functions for the Sparse Merkle TreeupdateParamsTree
and updateFlagsTree
functions for the Sparse Merkle Tree
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.
Definitely heading in the right direction and most of the logic is in place. Left a couple of major regarding next steps.
Let me know if you need any more clarifying details
updateParamsTree
and updateFlagsTree
functions for the Sparse Merkle TreeupdateParamsTree
and updateFlagsTree
functions for the Sparse Merkle Tree
updateParamsTree
and updateFlagsTree
functions for the Sparse Merkle TreeupdateParamsTree
and updateFlagsTree
functions for the Sparse Merkle Tree
…and updateFlagsTree functions
updateParamsTree
and updateFlagsTree
functions for the Sparse Merkle TreeupdateParamsTree
and updateFlagsTree
functions for the Sparse Merkle Tree
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.
Almost good to 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.
Do you mind replacing the other proto.Marshal
to codec.GetCodec().Marhsal()
?
After that, feel free to merge!
Description
This PR is in response to the comments left in the
peristence/state.go
file:The functions work by utilising the new
getParamsUpdated(height int64)
andgetFlagsUpdated(height int64)
functions that return a slice of[]*coreTypes.Param
and[]*coreTypes.Flag
respectively. The function runs a query against the PostgreSQL DB to get all the parameter's/flag's at the given height, their names, values, and heights (+enabled status for flags) are then loaded from the returned rows into individualParam
orFlag
protobufs and these are then returned.The
updateParamsTree
andupdateFlagsTree
functions then iterate over each protobuf in this slice and for each one runs the SMTUpdate
function using the result ofcrypto.SHA3Hash([]byte(proto.String()))
function (whereproto
is eitherparam
orflag
depending on the function) as the key, and the marshalled protobuf as a[]byte
as the value.The corresponding hashes have been updated in the
TestStateHash_DeterministicStateWhenUpdatingAppStake
test, following the comment at the start of the function.Issue
Fixes N/A
Type of change
Please mark the relevant option(s):
List of changes
Param
andFlag
protobufsgetParamsOrFlagsAtHeightQuery()
andgetParamsUpdated()
andgetFlagsUpdated()
functions to return the a slice of the respective protobufs for the given heightupdateParamsTree()
andupdateFlagsTree()
functions to utilise these functions and update their respective Merkle TreesTestStateHash_DeterministicStateWhenUpdatingAppStake
test hardcoded hashes to use new ones as the business logic has changed for calculating theseproto.Marshal
withcodec.GetCodec().Marshal()
inpersistence/state.go
Testing
make develop_test
README
Required Checklist
If Applicable Checklist
shared/docs/*
if I updatedshared/*
README(s)