From b71fc9d3d574c4a29bf441c1fb1a4fa034fe7622 Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 1 Nov 2022 19:29:05 +0000 Subject: [PATCH] Strip down debug statements --- tests/difference/core/driver/core_test.go | 13 ++----------- tests/difference/core/driver/setup.go | 23 +++++++++++------------ x/ccv/consumer/keeper/relay.go | 1 - x/ccv/consumer/module.go | 1 - x/ccv/provider/keeper/hooks.go | 4 ++-- x/ccv/provider/keeper/keymap.go | 3 --- x/ccv/provider/keeper/relay.go | 3 --- 7 files changed, 15 insertions(+), 33 deletions(-) diff --git a/tests/difference/core/driver/core_test.go b/tests/difference/core/driver/core_test.go index 4b52a6c90a..5e5c302230 100644 --- a/tests/difference/core/driver/core_test.go +++ b/tests/difference/core/driver/core_test.go @@ -340,17 +340,8 @@ func (s *CoreSuite) keyAssignment() { } } -func (s *CoreSuite) debugPrintProviderValidatorConsAddresses() { - for i := 0; i < initState.NumValidators; i++ { - cons := s.consAddr(int64(i)) - fmt.Println(i, " cons:", cons.String()[14:20]) - } -} - func (s *CoreSuite) executeTrace() { - s.debugPrintProviderValidatorConsAddresses() - for i := range s.traces.Actions() { s.traces.CurrentActionIx = i @@ -598,10 +589,10 @@ func TestCoreSuite(t *testing.T) { // the initial state in the model. func (s *CoreSuite) SetupTest() { state := initState - path, valAddresses, offsetHeight, offsetTimeUnix := GetZeroState(&s.Suite, state) + path, valAddresses, offsetHeight, offsetTimeUnix, providerVscID := GetZeroState(&s.Suite, state) s.valAddresses = valAddresses s.offsetHeight = offsetHeight s.offsetTimeUnix = offsetTimeUnix - s.offsetProviderVscId = 32 // TODO: do properly + s.offsetProviderVscId = providerVscID s.simibc = simibc.MakeRelayedPath(s.Suite.T(), path) } diff --git a/tests/difference/core/driver/setup.go b/tests/difference/core/driver/setup.go index 40fca3dbfb..23739a44f2 100644 --- a/tests/difference/core/driver/setup.go +++ b/tests/difference/core/driver/setup.go @@ -3,7 +3,6 @@ package core import ( "bytes" "encoding/json" - "fmt" "time" codectypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -382,7 +381,7 @@ func (b *Builder) createValidator(seedIx int) (tmtypes.PrivValidator, sdk.ValAdd // setSigningInfos sets the validator signing info in the provider Slashing module func (b *Builder) setSigningInfos() { - for i := 0; i < 4; i++ { // TODO: unhardcode + for i := 0; i < initState.NumValidators; i++ { info := slashingtypes.NewValidatorSigningInfo( b.consAddr(int64(i)), b.chain(P).CurrentHeader.GetHeight(), @@ -493,13 +492,13 @@ func (b *Builder) createConsumerGenesis(tmConfig *ibctesting.TendermintConfig) * consumertypes.DefaultConsumerUnbondingPeriod, ) - { - // TODO: this is a hack - for _, u := range valUpdates { - b.providerKeeper().KeyMap(b.ctx(P), b.chainID(C)).SetProviderPubKeyToConsumerPubKey(u.PubKey, u.PubKey) - } - b.providerKeeper().KeyMap(b.ctx(P), b.chainID(C)).ComputeUpdates(0, valUpdates) + // For each update, assign a default key assignment from provider key to provider key. + // In this manner the default behavior is for the consumer to be assigned the same consensus + // key as is used on the provider, for a given validator. + for _, u := range valUpdates { + b.providerKeeper().KeyMap(b.ctx(P), b.chainID(C)).SetProviderPubKeyToConsumerPubKey(u.PubKey, u.PubKey) } + b.providerKeeper().KeyMap(b.ctx(P), b.chainID(C)).ComputeUpdates(0, valUpdates) return consumertypes.NewInitialGenesisState(providerClient, providerConsState, valUpdates, consumertypes.SlashRequests{}, params) } @@ -779,14 +778,14 @@ func (b *Builder) build() { // state does not necessarily mimic the order of steps that happen in a // live scenario. func GetZeroState(suite *suite.Suite, initState InitState) ( - *ibctesting.Path, []sdk.ValAddress, int64, int64) { + *ibctesting.Path, []sdk.ValAddress, int64, int64, uint64) { b := Builder{initState: initState, suite: suite} b.build() // Height of the last committed block (current header is not committed) heightLastCommitted := b.chain(P).CurrentHeader.Height - 1 // Time of the last committed block (current header is not committed) timeLastCommitted := b.chain(P).CurrentHeader.Time.Add(-b.initState.BlockSeconds).Unix() - // TODO: - fmt.Println("id", b.providerKeeper().GetValidatorSetUpdateId(b.ctx(P))) - return b.path, b.valAddresses, heightLastCommitted, timeLastCommitted + // Get the current provider vscID + providerVscid := b.providerKeeper().GetValidatorSetUpdateId(b.ctx(P)) + return b.path, b.valAddresses, heightLastCommitted, timeLastCommitted, providerVscid } diff --git a/x/ccv/consumer/keeper/relay.go b/x/ccv/consumer/keeper/relay.go index 729db20d8c..83692c7eef 100644 --- a/x/ccv/consumer/keeper/relay.go +++ b/x/ccv/consumer/keeper/relay.go @@ -56,7 +56,6 @@ func (k Keeper) OnRecvVSCPacket(ctx sdk.Context, packet channeltypes.Packet, new // Save maturity time and packet maturityTime := ctx.BlockTime().Add(k.GetUnbondingPeriod(ctx)) k.SetPacketMaturityTime(ctx, newChanges.ValsetUpdateId, uint64(maturityTime.UnixNano())) - fmt.Println("consumer receive vscid: ", newChanges.ValsetUpdateId) // set height to VSC id mapping k.SetHeightValsetUpdateID(ctx, uint64(ctx.BlockHeight())+1, newChanges.ValsetUpdateId) diff --git a/x/ccv/consumer/module.go b/x/ccv/consumer/module.go index c233d8e941..ae6f6bfda8 100644 --- a/x/ccv/consumer/module.go +++ b/x/ccv/consumer/module.go @@ -191,7 +191,6 @@ func (am AppModule) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) []abci.V // apply changes to cross-chain validator set tendermintUpdates := am.keeper.ApplyCCValidatorChanges(ctx, data.ValidatorUpdates) am.keeper.DeletePendingChanges(ctx) - fmt.Println("consumer endblock") return tendermintUpdates } diff --git a/x/ccv/provider/keeper/hooks.go b/x/ccv/provider/keeper/hooks.go index b0fbdfb080..52c873e2d8 100644 --- a/x/ccv/provider/keeper/hooks.go +++ b/x/ccv/provider/keeper/hooks.go @@ -61,8 +61,8 @@ func (h Hooks) AfterUnbondingInitiated(ctx sdk.Context, ID uint64) { func (h Hooks) AfterValidatorCreated(ctx sdk.Context, valAddr sdk.ValAddress) { } func (h Hooks) AfterValidatorRemoved(ctx sdk.Context, ca sdk.ConsAddress, _ sdk.ValAddress) { - fmt.Println("validator removed!") - + // Delete any key assignments that are associated with this + // validator across all consumer chains h.k.IterateConsumerChains(ctx, func(ctx sdk.Context, chainID, clientID string) (stop bool) { h.k.KeyMap(ctx, chainID).DeleteProviderKey(ca) return false diff --git a/x/ccv/provider/keeper/keymap.go b/x/ccv/provider/keeper/keymap.go index ca7311fb68..f8c4f21c94 100644 --- a/x/ccv/provider/keeper/keymap.go +++ b/x/ccv/provider/keeper/keymap.go @@ -2,7 +2,6 @@ package keeper import ( "errors" - "fmt" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/interchain-security/x/ccv/provider/types" @@ -140,8 +139,6 @@ func (e *KeyMap) SetProviderPubKeyToConsumerPubKey(pk ProviderPublicKey, ck Cons } func (e *KeyMap) DeleteProviderKey(pca ProviderConsAddr) error { - fmt.Println("called deleteProviderKey!") - // TODO: document expensive operation if ck, ok := e.Store.GetPcaToCk(pca); ok { e.Store.DelCkToPk(ck) diff --git a/x/ccv/provider/keeper/relay.go b/x/ccv/provider/keeper/relay.go index 05dea2f547..92ab5be1a5 100644 --- a/x/ccv/provider/keeper/relay.go +++ b/x/ccv/provider/keeper/relay.go @@ -230,10 +230,8 @@ func (k Keeper) HandleSlashPacket(ctx sdk.Context, chainID string, data ccv.Slas // TODO: document better consumerConsAddr := sdk.ConsAddress(data.Validator.Address) providerConsAddr, err := GetProviderConsAddr(k.KeyMap(ctx, chainID), consumerConsAddr) - // debugStr("recv slash, ", providerConsAddr, data) if err != nil { - fmt.Println("could not find providerConsAddr using keymap lookup") return false, nil } validator, found := k.stakingKeeper.GetValidatorByConsAddr(ctx, providerConsAddr) @@ -274,7 +272,6 @@ func (k Keeper) HandleSlashPacket(ctx sdk.Context, chainID string, data ccv.Slas default: return false, fmt.Errorf("invalid infraction type: %v", data.Infraction) } - // debugStr("actu slash, ", providerConsAddr, data) // slash validator k.stakingKeeper.Slash(