-
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] Update block header #915
Conversation
@h5law Friendly reminder to please update Issue/PR metdata |
ur too fast |
@@ -101,6 +101,16 @@ func (t *treeStore) GetTree(name string) ([]byte, kvstore.KVStore) { | |||
return nil, nil | |||
} | |||
|
|||
// GetTreeHashes returns a map of tree names to their root hashes for all | |||
// the trees tracked by the treestore, excluding the root tree | |||
func (t *treeStore) GetTreeHashes() map[string]string { |
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.
Can you add a unit test for this?
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.
) | ||
require.NoError(t, err) | ||
|
||
currValSet, err = db.GetValidatorSet(currHeight - 1) |
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.
Can you also update the test to insure the validators are sorted by address?
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.
So the validators are sorted by address and height this means they could look like this:
"aaaaaaa"(height10)
"ccccccc" (height9)
"bbbbbb"(height9)
"zzzzzzz"(height1)
"ddddddd"(height1)
What is important is that although the ordering may not be lexigraphically ordered by address alone it is still deterministic by height. This means the hash will be consistent by height. I think testing they are lexigraphically ordered only passes at genesis and afterwards will not alway be the case
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.
My request is to update the test to verify this explicitly:
For example:
require.Equal(t, "aaaaa", valSet[0].address) // height10
require.Equal(t, "cccc", valSet[0].address) // height9
require.Equal(t, "bbb", valSet[0].address) // height8
Makes it easier for future maintainers of the code and also increase the surface area of bugs
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.
My bad I actually misunderstood the query. They are sorted by address ASC alone as the select is ON DISTINCT it means even if the address is at multiple heights only the most recent is chosen but results are still sorted by address ASC. Updated to test for this.
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.
Just one more request: https://github.com/pokt-network/pocket/pull/915/files#r1268771205
) | ||
require.NoError(t, err) | ||
|
||
currValSet, err = db.GetValidatorSet(currHeight - 1) |
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.
My request is to update the test to verify this explicitly:
For example:
require.Equal(t, "aaaaa", valSet[0].address) // height10
require.Equal(t, "cccc", valSet[0].address) // height9
require.Equal(t, "bbb", valSet[0].address) // height8
Makes it easier for future maintainers of the code and also increase the surface area of bugs
if i == 0 { | ||
continue | ||
} | ||
require.True(t, val.Address > nextValSet.Validators[i-1].Address) |
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.
clever!
Description
Summary generated by Reviewpad on 20 Jul 23 20:52 UTC
This pull request includes the following changes:
GetTreeHashes
in thetrees.go
file.TestTreeStore_GetTreeHashes
in thetrees_test.go
file.block.proto
file including updating theBlockHeader
message, adding theValidatorSet
message, and adding theValidatorIdentity
message.GetTreeHashes
in thetreestore_module.go
file.openapi.yaml
file related to the "Block" schema.GetValidatorSet
in theactor.go
file.actor_test.go
file related to importing packages and adding test functions.rpc/utils.go
file related to adding fields to theBlockHeader
struct in theblockToRPCBlock
function.GetValidatorSet
to thePersistenceReadContext
interface in thepersistence_module.go
file.Issue
Fixes N/A
Type of change
Please mark the relevant option(s):
List of changes
Testing
make develop_test
; if any code changes were mademake test_e2e
on k8s LocalNet; if any code changes were madee2e-devnet-test
passes tests on DevNet; if any code was changedRequired Checklist
godoc
format comments on touched members (see: tip.golang.org/doc/comment)If Applicable Checklist
shared/docs/*
if I updatedshared/*
README(s)