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

Block Delay Parameter #171

Merged
merged 18 commits into from
May 21, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
DRY consensus metadata setting
  • Loading branch information
AdityaSripal committed May 17, 2021
commit 89cb274a18101bdcd39816608d8ccd9fa9c8acb6
14 changes: 14 additions & 0 deletions modules/core/03-connection/types/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,20 @@ func TestValidateGenesis(t *testing.T) {
),
expPass: false,
},
{
name: "invalid params",
genState: types.NewGenesisState(
[]types.IdentifiedConnection{
types.NewIdentifiedConnection(connectionID, types.NewConnectionEnd(types.INIT, clientID, types.Counterparty{clientID2, connectionID2, commitmenttypes.NewMerklePrefix([]byte("prefix"))}, []*types.Version{ibctesting.ConnectionVersion}, 500)),
},
[]types.ConnectionPaths{
{clientID, []string{connectionID}},
},
0,
types.Params{},
),
expPass: false,
},
}

for _, tc := range testCases {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,8 @@ func (cs ClientState) CheckSubstituteAndUpdateState(
}
SetConsensusState(subjectClientStore, cdc, consensusState, height)

processedTime, found := GetProcessedTime(substituteClientStore, height)
if !found {
continue
}
SetProcessedTime(subjectClientStore, height, processedTime)

// set metadata for this consensus state
setConsensusMetadata(ctx, subjectClientStore, height)
}

cs.LatestHeight = substituteClientState.LatestHeight
Expand Down
19 changes: 12 additions & 7 deletions modules/light-clients/07-tendermint/types/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,13 +212,18 @@ func update(ctx sdk.Context, clientStore sdk.KVStore, clientState *ClientState,
NextValidatorsHash: header.Header.NextValidatorsHash,
}

// set context time as processed time and set context height as processed height
// as this is internal tendermint light client logic.
// client state and consensus state will be set by client keeper
// set iteration key to provide ability for efficient ordered iteration of consensus states.
SetProcessedTime(clientStore, header.GetHeight(), uint64(ctx.BlockTime().UnixNano()))
SetProcessedHeight(clientStore, header.GetHeight(), clienttypes.GetSelfHeight(ctx))
SetIterationKey(clientStore, header.GetHeight())
// set metadata for this consensus state
setConsensusMetadata(ctx, clientStore, header.GetHeight())

return clientState, consensusState
}

// set context time as processed time and set context height as processed height
// as this is internal tendermint light client logic.
// client state and consensus state will be set by client keeper
// set iteration key to provide ability for efficient ordered iteration of consensus states.
func setConsensusMetadata(ctx sdk.Context, clientStore sdk.KVStore, height exported.Height) {
SetProcessedTime(clientStore, height, uint64(ctx.BlockTime().UnixNano()))
SetProcessedHeight(clientStore, height, clienttypes.GetSelfHeight(ctx))
SetIterationKey(clientStore, height)
}
5 changes: 4 additions & 1 deletion modules/light-clients/07-tendermint/types/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
clienttypes "github.com/cosmos/ibc-go/modules/core/02-client/types"
commitmenttypes "github.com/cosmos/ibc-go/modules/core/23-commitment/types"
"github.com/cosmos/ibc-go/modules/core/exported"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
)

// VerifyUpgradeAndUpdateState checks if the upgraded client has been committed by the current client
Expand Down Expand Up @@ -122,6 +122,9 @@ func (cs ClientState) VerifyUpgradeAndUpdateState(
tmUpgradeConsState.Timestamp, commitmenttypes.MerkleRoot{}, tmUpgradeConsState.NextValidatorsHash,
)

// set metadata for this consensus state
setConsensusMetadata(ctx, clientStore, tmUpgradeClient.LatestHeight)

return newClientState, newConsState, nil
}

Expand Down