-
Notifications
You must be signed in to change notification settings - Fork 28
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
Problem: New validator projection. Implement migration scripts and views [Part 2] #684
base: feature/652-validator-delegation
Are you sure you want to change the base?
Conversation
…and validators tables.
extra_configs: | ||
BridgePendingActivity: | ||
this_chain_id: "testnet-croeseid-4" | ||
this_chain_name: "Crypto.org-Chain" | ||
counterparty_chain_name: "Cronos" | ||
channel_id: "channel-131" | ||
starting_height: 899374 | ||
ValidatorDelegation: | ||
unbonding_time: "2419200000000000ns" |
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.
suggest to change to ms / s
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.
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.
extra_configs: | ||
BridgePendingActivity: | ||
this_chain_id: "testnet-croeseid-4" | ||
this_chain_name: "Crypto.org-Chain" | ||
counterparty_chain_name: "Cronos" | ||
channel_id: "channel-131" | ||
starting_height: 899374 | ||
ValidatorDelegation: | ||
unbonding_time: "2419200000000000ns" | ||
slash_fraction_double_sign: "0.050000000000000000" |
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.
May i know that are those slash fractions can be change by proposal?
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
may i know what is the diff between this ListValidator
and the List
in Validator
projection view?
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggest to change it in completed form instead of vd
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.
Updated. And the similar places below
@@ -0,0 +1,8 @@ | |||
CREATE TABLE view_vd_evidences ( |
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.
same here
@@ -0,0 +1,6 @@ | |||
CREATE TABLE view_vd_redelegation_queue ( |
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.
same here
@@ -0,0 +1,19 @@ | |||
CREATE TABLE view_vd_redelegations ( |
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.
same here
@@ -0,0 +1,6 @@ | |||
CREATE TABLE view_vd_unbonding_delegation_queue ( |
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.
same here
@@ -0,0 +1,13 @@ | |||
CREATE TABLE view_vd_unbonding_delegations ( |
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.
same here
@@ -0,0 +1,6 @@ | |||
CREATE TABLE view_vd_unbonding_validators ( |
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.
same here
@@ -0,0 +1,28 @@ | |||
CREATE TABLE view_vd_validators ( |
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.
same here
return nil | ||
} | ||
|
||
func (view *DelegationsView) checkIfDelegationRecordExistByHeightLowerBound(row DelegationRow) (bool, 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.
suggest IsExistedByLowerBoundHeight(validatorAddress, delegatorAddress string, height int64) (bool, error)
for readability
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UpdateUpperBoundHeight
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggest change toIsExistedByLowerBoundHeight(delegatorAddress, validatorSrcAddress, validatorDstAddress string, height int64)
for readability
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.
Thanks, updated.
return view.setRedelegationRecordHeightUpperBound(row) | ||
} | ||
|
||
func (view *RedelegationsView) setRedelegationRecordHeightUpperBound(row RedelegationRow) 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.
UpdateUpperBoundHeight
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.
Thanks, updated.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add some description for short formed column?
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.
Sure.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add some description for short formed column?
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.
Sure.
|
||
return nil | ||
} | ||
|
||
func (view *UnbondingDelegationsView) checkIfUnbondingDelegationRecordExistByHeightLowerBound(row UnbondingDelegationRow) (bool, 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.
similar suggestion here
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.
Thanks, updated.
return view.setUnbondingDelegationRecordHeightUpperBound(row) | ||
} | ||
|
||
func (view *UnbondingDelegationsView) setUnbondingDelegationRecordHeightUpperBound(row UnbondingDelegationRow) 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.
similar suggestion here
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.
Thanks, updated.
return nil | ||
} | ||
|
||
func (view *ValidatorsView) checkIfValidatorRecordExistByHeightLowerBound(row ValidatorRow) (bool, 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.
similar suggestion here
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.
Thanks, updated.
return view.setValidatorRecordHeightUpperBound(row) | ||
} | ||
|
||
func (view *ValidatorsView) setValidatorRecordHeightUpperBound(row ValidatorRow) 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.
similar suggestion here
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.
Thanks, updated.
} | ||
|
||
func (view *ValidatorsView) FindByTendermintAddr(tendermintAddress string, height int64) (ValidatorRow, error) { | ||
func (view *ValidatorsView) findBy( |
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.
is it intended to make it private?
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.
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)