Skip to content
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

Update #264 - updates genesis and genesis tests #382

Merged
merged 49 commits into from
Nov 18, 2022
Merged
Changes from 1 commit
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
ba651e3
reformat consumer genesis test
sainoe Jul 18, 2022
a87495d
remove validator fill in of ExportAppStateAndValidators
sainoe Jul 19, 2022
e3919b5
checkpoint, testing export genesis consumer
sainoe Jul 25, 2022
3dcd610
test consumer export
sainoe Jul 27, 2022
a815a15
make pass the tests
sainoe Jul 29, 2022
b25f968
fix export height to valset update id in consumer
sainoe Aug 2, 2022
4a06760
pass the tests
sainoe Aug 3, 2022
7b48c09
pass the tests
sainoe Aug 3, 2022
1378a52
* Update the provider and consumer export/init genesis with the new C…
sainoe Aug 11, 2022
c3cfeb4
remove pendingVSCPackets
sainoe Aug 12, 2022
0e548e4
remove references in create consumer chain proposal setters and getters
sainoe Aug 22, 2022
9a70d95
merge with remotes
sainoe Aug 22, 2022
524a0aa
fix unchecked errors
sainoe Aug 22, 2022
2a670e0
Merge branch 'main' into sainoe/export-genesis
sainoe Sep 29, 2022
65dc723
fix iterator bug
sainoe Sep 29, 2022
c711ecb
fix last nits
sainoe Sep 29, 2022
a4e83d8
Merge remote-tracking branch 'upstream/main' into sainoe/export-genesis
sainoe Sep 29, 2022
ecb643a
fix linter
sainoe Sep 30, 2022
06b5df5
Fix conflicts and make pass the tests
sainoe Oct 3, 2022
4ec85d5
format provider genesis tests
sainoe Oct 3, 2022
8017c29
format consumer genesis tests
sainoe Oct 3, 2022
d62dc16
Merge branch 'main' into sainoe/export-genesis
jtremback Oct 4, 2022
f1a415e
clarify consumer keeper genesis
sainoe Oct 6, 2022
9ea6c5a
push missing merge commit
sainoe Oct 6, 2022
5f03831
remove unused test helpers
sainoe Oct 7, 2022
03c643c
Merge branch 'main' into sainoe/export-genesis-2
shaspitz Oct 7, 2022
eb59e50
Feat: update consumer init and export genesis
sainoe Nov 9, 2022
de20341
Revert "Feat: update consumer init and export genesis"
sainoe Nov 9, 2022
c856708
merge main
sainoe Nov 9, 2022
d3b5bef
* Add LastTransmissionBlockHeight to consumer genesis proto
sainoe Nov 7, 2022
c292da4
Update consumer init
sainoe Nov 9, 2022
74aa7e9
Update consumer genesis export
sainoe Nov 9, 2022
19e4b93
fix last nits
sainoe Nov 9, 2022
0599369
Fix consumer InitGenesis
sainoe Nov 10, 2022
de4a73e
Update comments in genesis.proto
sainoe Nov 10, 2022
30b141c
format consumer genesis test
sainoe Nov 10, 2022
0399487
update comments
sainoe Nov 10, 2022
255c96d
Update provider genesis comments
sainoe Nov 14, 2022
1d06cd7
fix small lint errs
shaspitz Nov 14, 2022
26ec9e8
Merge branch 'main' into sainoe/export-genesis-2
shaspitz Nov 14, 2022
ebd590b
Merge branch 'main' into sainoe/export-genesis-2
shaspitz Nov 15, 2022
d0d5db1
* Update consumer genesis validation
sainoe Nov 15, 2022
4aca97e
Document consumer genesis validation
sainoe Nov 17, 2022
fd9dc10
Document consumer genesis validation
sainoe Nov 17, 2022
50ae321
Merge branch 'main' into sainoe/export-genesis-2
sainoe Nov 18, 2022
af1aebb
Update after #448 merge
sainoe Nov 18, 2022
6d93504
Merge branch 'sainoe/export-genesis-2' into export-2-upstream
sainoe Nov 18, 2022
504c44c
Merge branch 'main' into sainoe/export-genesis-2
shaspitz Nov 18, 2022
aff5156
Update x/ccv/consumer/types/genesis.go
jtremback Nov 18, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Document consumer genesis validation
sainoe committed Nov 18, 2022

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
commit 4aca97eb10340566add3e25bf831cc85e2a3bcfc
37 changes: 31 additions & 6 deletions x/ccv/consumer/types/genesis.go
Original file line number Diff line number Diff line change
@@ -58,6 +58,22 @@ func DefaultGenesisState() *GenesisState {
}

// Validate performs basic genesis state validation returning an error upon any failure.
//
// The three cases where a consumer chain starts/restarts
// expect the following optional and mandatory genesis states:
//
// 1. New chain starts:
// - Params, InitialValset, IBC provider client state, IBC provider consensus state // mandatory
//
// 2. Chain restarts with CCV handshake still in progress:
// - Params, InitialValset, ProviderID, HeightToValidatorSetUpdateID // mandatory
// - PendingSlashRequest // optional
//
// 3. Chain restarts with CCV handshake completed:
// - Params, InitialValset, ProviderID, channelID, HeightToValidatorSetUpdateID // mandatory
// - MaturingVSCPackets, OutstandingDowntime, LastTransmissionBlockHeight // optional
//

func (gs GenesisState) Validate() error {
if !gs.Params.Enabled {
return nil
@@ -111,11 +127,20 @@ func (gs GenesisState) Validate() error {
return sdkerrors.Wrap(ccv.ErrInvalidGenesis, "provider client id must be set for a restarting consumer genesis state")
}
// handshake is still in progress
if gs.ProviderChannelId == "" && (len(gs.MaturingPackets) != 0 || len(gs.OutstandingDowntimeSlashing) != 0 || gs.LastTransmissionBlockHeight.Height != 0) {
return sdkerrors.Wrap(
ccv.ErrInvalidGenesis,
"maturing packets, outstanding downtime slashing and last transmission block height must be empty when handshake isn't completed",
)
handshakeInProgress := gs.ProviderChannelId == ""
if handshakeInProgress {
if len(gs.MaturingPackets) != 0 {
return sdkerrors.Wrap(
ccv.ErrInvalidGenesis, "maturing packets must be empty when handshake isn't completed")
}
if len(gs.OutstandingDowntimeSlashing) != 0 {
return sdkerrors.Wrap(
ccv.ErrInvalidGenesis, "outstanding downtime must be empty when handshake isn't completed")
}
if gs.LastTransmissionBlockHeight.Height != 0 {
return sdkerrors.Wrap(
ccv.ErrInvalidGenesis, "last transmission block height must be zero when handshake isn't completed")
}
}
if gs.HeightToValsetUpdateId == nil {
return sdkerrors.Wrap(
@@ -124,7 +149,7 @@ func (gs GenesisState) Validate() error {
)
}
if gs.ProviderClientState != nil || gs.ProviderConsensusState != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is a restart of a running chain where the handshake did not complete, then how is it ever going to get restarted?

return sdkerrors.Wrap(ccv.ErrInvalidGenesis, "provider client state and consensus states must be nil for a restarting genesis state")
return sdkerrors.Wrap(ccv.ErrInvalidGenesis, "provider client state and consensus state must be nil for a restarting genesis state")
}
for _, mat := range gs.MaturingPackets {
if err := mat.Validate(); err != nil {