Problem: New validator projection. Implement migration scripts and views [Part 2]#684
Problem: New validator projection. Implement migration scripts and views [Part 2]#684ysong42 wants to merge 24 commits intofeature/652-validator-delegationfrom
Conversation
…and validators tables.
| channel_id: "channel-131" | ||
| starting_height: 899374 | ||
| ValidatorDelegation: | ||
| unbonding_time: "2419200000000000ns" |
There was a problem hiding this comment.
suggest to change to ms / s
There was a problem hiding this comment.
oh this is from Crypto.org genesis. I just copied from the genesis.
Later when we support proposals updaing params in this projection, we will remove this config.
| starting_height: 899374 | ||
| ValidatorDelegation: | ||
| unbonding_time: "2419200000000000ns" | ||
| slash_fraction_double_sign: "0.050000000000000000" |
There was a problem hiding this comment.
May i know that are those slash fractions can be change by proposal?
There was a problem hiding this comment.
https://crypto.org/explorer/proposals
You can check those proposals there. So there are different type of proposals. And there are module params that could be configured through gov module's proposal.
| httpapi.Success(ctx, validator) | ||
| } | ||
|
|
||
| func (handler *ValidatorDelegation) ListValidator(ctx *fasthttp.RequestCtx) { |
There was a problem hiding this comment.
may i know what is the diff between this ListValidator and the List in Validator projection view?
There was a problem hiding this comment.
This one is on http handler. It is for parsing the query params. Then triggered the under-lying view logic to interact with DB.
| @@ -0,0 +1,13 @@ | |||
| CREATE EXTENSION btree_gist; | |||
|
|
|||
| CREATE TABLE view_vd_delegations ( | |||
There was a problem hiding this comment.
suggest to change it in completed form instead of vd
There was a problem hiding this comment.
Updated. And the similar places below
| @@ -0,0 +1,8 @@ | |||
| CREATE TABLE view_vd_evidences ( | |||
| @@ -0,0 +1,6 @@ | |||
| CREATE TABLE view_vd_redelegation_queue ( | |||
| @@ -0,0 +1,19 @@ | |||
| CREATE TABLE view_vd_redelegations ( | |||
| @@ -0,0 +1,6 @@ | |||
| CREATE TABLE view_vd_unbonding_delegation_queue ( | |||
| @@ -0,0 +1,13 @@ | |||
| CREATE TABLE view_vd_unbonding_delegations ( | |||
| @@ -0,0 +1,6 @@ | |||
| CREATE TABLE view_vd_unbonding_validators ( | |||
| @@ -0,0 +1,28 @@ | |||
| CREATE TABLE view_vd_validators ( | |||
| return nil | ||
| } | ||
|
|
||
| func (view *DelegationsView) checkIfDelegationRecordExistByHeightLowerBound(row DelegationRow) (bool, error) { |
There was a problem hiding this comment.
suggest IsExistedByLowerBoundHeight(validatorAddress, delegatorAddress string, height int64) (bool, error) for readability
There was a problem hiding this comment.
Thanks! Updated. I will use isExistedByLowerBoundHeight to keep the func as private.
| return view.setDelegationRecordHeightUpperBound(row) | ||
| } | ||
|
|
||
| func (view *DelegationsView) setDelegationRecordHeightUpperBound(row DelegationRow) error { |
There was a problem hiding this comment.
Thanks, updated. I will use updateUpperBoundHeight, as I want to keep it as private.
| return nil | ||
| } | ||
|
|
||
| func (view *RedelegationsView) checkIfRedelegationRecordExistByHeightLowerBound(row RedelegationRow) (bool, error) { |
There was a problem hiding this comment.
suggest change toIsExistedByLowerBoundHeight(delegatorAddress, validatorSrcAddress, validatorDstAddress string, height int64) for readability
| return view.setRedelegationRecordHeightUpperBound(row) | ||
| } | ||
|
|
||
| func (view *RedelegationsView) setRedelegationRecordHeightUpperBound(row RedelegationRow) error { |
| CREATE TABLE view_vd_unbonding_delegation_queue ( | ||
| id BIGSERIAL, | ||
| completion_time BIGINT NOT NULL UNIQUE, | ||
| dv_pairs JSONB NOT NULL, |
There was a problem hiding this comment.
Can we add some description for short formed column?
| CREATE TABLE view_vd_redelegation_queue ( | ||
| id BIGSERIAL, | ||
| completion_time BIGINT NOT NULL UNIQUE, | ||
| dvv_triplets JSONB NOT NULL, |
There was a problem hiding this comment.
Can we add some description for short formed column?
| return nil | ||
| } | ||
|
|
||
| func (view *UnbondingDelegationsView) checkIfUnbondingDelegationRecordExistByHeightLowerBound(row UnbondingDelegationRow) (bool, error) { |
| return view.setUnbondingDelegationRecordHeightUpperBound(row) | ||
| } | ||
|
|
||
| func (view *UnbondingDelegationsView) setUnbondingDelegationRecordHeightUpperBound(row UnbondingDelegationRow) error { |
| return nil | ||
| } | ||
|
|
||
| func (view *ValidatorsView) checkIfValidatorRecordExistByHeightLowerBound(row ValidatorRow) (bool, error) { |
| return view.setValidatorRecordHeightUpperBound(row) | ||
| } | ||
|
|
||
| func (view *ValidatorsView) setValidatorRecordHeightUpperBound(row ValidatorRow) error { |
| } | ||
|
|
||
| func (view *ValidatorsView) FindByTendermintAddr(tendermintAddress string, height int64) (ValidatorRow, error) { | ||
| func (view *ValidatorsView) findBy( |
There was a problem hiding this comment.
is it intended to make it private?
There was a problem hiding this comment.
Yes. Users are expected to use FindByOperatorAddr and FindByConsensusNodeAddr to find a specific record.
The FindByOperatorAddr and FindByConsensusNodeAddr will invoke findBy internally. These two functions are mainly for readability. The real logic is in findBy.
FindByTendermintAddr is not used in implementation, so I simply remove it.
|
@davcrypto Thanks for the review! The code is updated! Feel free to have another review 🙏 |
Solution: fix #665 #678
Changes
New Temporary APIs Examples
Performance and Correctness
Please refer to: #678 (comment)