Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jewei1997 committed Jul 20, 2024
1 parent b323aef commit e1657a5
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 7 deletions.
3 changes: 3 additions & 0 deletions modules/apps/transfer/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod
return gs.Validate()
}

// ValidateGenesisStream performs genesis state validation for the ibc transfer module in a streaming fashion.
func (am AppModuleBasic) ValidateGenesisStream(cdc codec.JSONCodec, config client.TxEncodingConfig, genesisCh <-chan json.RawMessage) error {
for genesis := range genesisCh {
err := am.ValidateGenesis(cdc, config, genesis)
Expand Down Expand Up @@ -153,6 +154,8 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw
return cdc.MustMarshalJSON(gs)
}

// StreamGenesis returns the exported genesis state as raw bytes for the ibc-transfer module in a
// streaming fashion.
func (am AppModule) StreamGenesis(ctx sdk.Context, cdc codec.JSONCodec) <-chan json.RawMessage {
ch := make(chan json.RawMessage)
go func() {
Expand Down
5 changes: 0 additions & 5 deletions modules/core/02-client/types/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ func (gs GenesisState) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error {

// Validate performs basic genesis state validation returning an error upon any
// failure.
// JEREMYFLAG - main validate
func (gs GenesisState) Validate() error {
// keep track of the max sequence to ensure it is less than
// the next sequence used in creating client identifers.
Expand All @@ -120,7 +119,6 @@ func (gs GenesisState) Validate() error {
validClients := make(map[string]string)

for i, client := range gs.Clients {
fmt.Println("client.ClientId: ", client.ClientId)
if err := host.ClientIdentifierValidator(client.ClientId); err != nil {
return fmt.Errorf("invalid client consensus state identifier %s index %d: %w", client.ClientId, i, err)
}
Expand Down Expand Up @@ -170,15 +168,12 @@ func (gs GenesisState) Validate() error {
return fmt.Errorf("consensus state height cannot be zero")
}

// JEREMYFLAG - unmarshalling
cs, ok := consensusState.ConsensusState.GetCachedValue().(exported.ConsensusState)
fmt.Println("unmarshalling cs: ", cs)
if !ok {
return fmt.Errorf("invalid consensus state with client ID %s at height %s", cc.ClientId, consensusState.Height)
}

if err := cs.ValidateBasic(); err != nil {
fmt.Printf("consensus state: %+v\n", cs)
return fmt.Errorf("invalid client consensus state %v clientID %s index %d: %w", cs, cc.ClientId, i, err)
}

Expand Down
2 changes: 2 additions & 0 deletions modules/core/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw
return cdc.MustMarshalJSON(ExportGenesis(ctx, *am.keeper))
}

// StreamGenesis returns the exported genesis state as raw bytes for the ibc
// module in a streaing fashion
func (am AppModule) StreamGenesis(ctx sdk.Context, cdc codec.JSONCodec) <-chan json.RawMessage {
ch := make(chan json.RawMessage)
go func() {
Expand Down
2 changes: 0 additions & 2 deletions modules/light-clients/07-tendermint/types/consensus_state.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package types

import (
fmt "fmt"
"time"

sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
Expand Down Expand Up @@ -50,7 +49,6 @@ func (cs ConsensusState) ValidateBasic() error {
return sdkerrors.Wrap(clienttypes.ErrInvalidConsensus, "root cannot be empty")
}
if err := tmtypes.ValidateHash(cs.NextValidatorsHash); err != nil {
fmt.Println("invalid next validators hash = ", cs.NextValidatorsHash)
return sdkerrors.Wrap(err, "next validators hash is invalid")
}
if cs.Timestamp.Unix() <= 0 {
Expand Down

0 comments on commit e1657a5

Please sign in to comment.