Skip to content

Commit

Permalink
Strip down debug statements
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel committed Nov 1, 2022
1 parent e344959 commit b71fc9d
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 33 deletions.
13 changes: 2 additions & 11 deletions tests/difference/core/driver/core_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
}
23 changes: 11 additions & 12 deletions tests/difference/core/driver/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package core
import (
"bytes"
"encoding/json"
"fmt"
"time"

codectypes "github.com/cosmos/cosmos-sdk/codec/types"
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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
}
1 change: 0 additions & 1 deletion x/ccv/consumer/keeper/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion x/ccv/consumer/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions x/ccv/provider/keeper/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions x/ccv/provider/keeper/keymap.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 0 additions & 3 deletions x/ccv/provider/keeper/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit b71fc9d

Please sign in to comment.