-
Notifications
You must be signed in to change notification settings - Fork 14
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
[R4R]validator rpc api consume mutch time #61
Conversation
9a19cb5
to
d6cf119
Compare
d6cf119
to
c9b69fe
Compare
state/store.go
Outdated
@@ -202,7 +201,14 @@ func (valInfo *ValidatorsInfo) Bytes() []byte { | |||
|
|||
// LoadValidators loads the ValidatorSet for a given height. | |||
// Returns ErrNoValSetForHeight if the validator set can't be found for this height. | |||
func LoadValidators(db dbm.DB, height int64) (*types.ValidatorSet, error) { | |||
// Notice: for recent 1048576 block, it will get exactly result. But the block before that height, |
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 we change comment magic number into latestStateToKeep
?
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
state/store.go
Outdated
proposalAddr := meta.Header.ProposerAddress | ||
_, proposer := valInfo.ValidatorSet.GetByAddress(proposalAddr.Bytes()) | ||
if proposer == nil { | ||
panic( |
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.
doesn't look like it need panic here, can we just log an error? Or the panic would be captured on entrance of query?
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.
I think panic is ok(the previous code before I modified is also panic). When can't find proposer from ValidatorSet or can't load valInfo2 from store, our data store is broken, which is a disaster, just fail fast. This service weight accurate more than availability.
c9b69fe
to
6998a0d
Compare
tendermint/tendermint#3044 (comment)
According to the above comment, I think there is no accuracy issue about ProposerPriority calculation. Do you agree with me? if |
) | ||
} | ||
valInfo2.ValidatorSet.IncrementProposerPriority(int(height - valInfo.LastHeightChanged)) // mutate |
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.
Without IncrementProposerPriority
, the priority information of getted valInfo may be inaccurate. Why not to save validator info at every height.
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.
Without
IncrementProposerPriority
, the priority information of getted valInfo may be inaccurate. Why not to save validator info at every height.
It takes too much storage, almost reduntant. @ackratos have save it in 100000000 recent blocks, but before that just rewrite the storage
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.
How about save validator info at every 1000 or 10000 height no matter validator change or not? Thus IncrementProposerPriority
would not cost too much time and disk storage will be much less.
Yes, |
also - unexpose it - add a comment - refactor code - add a benchmark, which shows that 100000 results in ~ 100ms to get 100 validators
6998a0d
to
d0e8d30
Compare
Description
fix /validators rpc response time grow with time.
Rationale
This pr do not fully resolve the issue.
There still one problem:
** for recent 1048576 block, it will get exactly result. But the block before that height,
the ProposerPriority is not accurate. **
My concern is that it takes too much cost to get
ProposerPriority
(we have to get each block round and replay it ).put the pr in tendermint, community want to rewrite
IncrementProposerPriority
, but since it is a hard fork, it will not be that quick, so this pr is a hot fix, I will keep trace ittendermint/tendermint#3438
Now community submit this pr:
tendermint/tendermint#3537
Example
After fix this, no matter what hight we use, it takes 0.01s.
Changes
Preflight checks
make build
)make test
)make integration_test
)Already reviewed by
...
Related issues