Skip to content

Commit

Permalink
wip: save local progress
Browse files Browse the repository at this point in the history
  • Loading branch information
MSalopek committed Nov 2, 2023
1 parent ff99872 commit a73a06c
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 16 deletions.
20 changes: 7 additions & 13 deletions app/provider/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,11 +277,6 @@ func New(
consensusparamtypes.StoreKey,
)

// register streaming services
if err := bApp.RegisterStreamingServices(appOpts, keys); err != nil {
panic(err)
}

tkeys := storetypes.NewTransientStoreKeys(paramstypes.TStoreKey)
memKeys := storetypes.NewMemoryStoreKeys(capabilitytypes.MemStoreKey)

Expand Down Expand Up @@ -311,7 +306,6 @@ func New(
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
runtime.EventService{},
)

bApp.SetParamStore(&app.ConsensusParamsKeeper.ParamsStore)

// add capability keeper and ScopeToModule for ibc module
Expand Down Expand Up @@ -576,8 +570,8 @@ func New(
crisistypes.ModuleName,
govtypes.ModuleName,
stakingtypes.ModuleName,
ibctransfertypes.ModuleName,
ibcexported.ModuleName,
ibctransfertypes.ModuleName,
authtypes.ModuleName,
banktypes.ModuleName,
distrtypes.ModuleName,
Expand All @@ -592,18 +586,18 @@ func New(

app.MM.SetOrderEndBlockers(
crisistypes.ModuleName,
authtypes.ModuleName,
govtypes.ModuleName,
capabilitytypes.ModuleName,
evidencetypes.ModuleName,
stakingtypes.ModuleName,
ibctransfertypes.ModuleName,
ibcexported.ModuleName,
capabilitytypes.ModuleName,
authtypes.ModuleName,
ibctransfertypes.ModuleName,
banktypes.ModuleName,
distrtypes.ModuleName,
slashingtypes.ModuleName,
minttypes.ModuleName,
genutiltypes.ModuleName,
evidencetypes.ModuleName,
paramstypes.ModuleName,
upgradetypes.ModuleName,
vestingtypes.ModuleName,
Expand All @@ -617,6 +611,7 @@ func New(
// so that other modules that want to create or claim capabilities afterwards in InitChain
// can do so safely.
app.MM.SetOrderInitGenesis(
genutiltypes.ModuleName,
capabilitytypes.ModuleName,
authtypes.ModuleName,
banktypes.ModuleName,
Expand All @@ -626,10 +621,9 @@ func New(
govtypes.ModuleName,
minttypes.ModuleName,
crisistypes.ModuleName,
ibcexported.ModuleName,
evidencetypes.ModuleName,
ibcexported.ModuleName,
ibctransfertypes.ModuleName,
genutiltypes.ModuleName,
paramstypes.ModuleName,
upgradetypes.ModuleName,
vestingtypes.ModuleName,
Expand Down
3 changes: 3 additions & 0 deletions tests/integration/normal_operations.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package integration

import (
"fmt"

"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"

tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
Expand All @@ -18,6 +20,7 @@ func (k CCVTestSuite) TestHistoricalInfo() { //nolint:govet // this is a test so
initValsetLen := len(consumerKeeper.GetAllCCValidator(cCtx()))
// save current block height
initHeight := cCtx().BlockHeight()
fmt.Println("### AFTER SETUP ###")

// define an utility function that creates a new cross-chain validator
// and then call track historical info in the next block
Expand Down
6 changes: 5 additions & 1 deletion tests/integration/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func NewCCVTestSuite[Tp testutil.ProviderApp, Tc testutil.ConsumerApp](
// Add provider to coordinator, store returned test chain and app.
// Concrete provider app type is passed to the generic function here.
provider, providerApp := icstestingutils.AddProvider[Tp](t, coordinator, providerAppIniter)

fmt.Println("------ provider added ----------")
// Pass variables to suite.
return coordinator, provider, providerApp
}
Expand All @@ -103,6 +103,7 @@ func NewCCVTestSuite[Tp testutil.ProviderApp, Tc testutil.ConsumerApp](
coordinator *ibctesting.Coordinator,
index int,
) *icstestingutils.ConsumerBundle {
fmt.Println("------ adding consumer ----------")
return icstestingutils.AddConsumer[Tp, Tc](coordinator, s, index, consumerAppIniter)
}

Expand Down Expand Up @@ -163,6 +164,7 @@ func (suite *CCVTestSuite) SetupTest() {
err = bundle.Path.EndpointA.UpdateClient()
suite.Require().NoError(err)
}
fmt.Println("## REACHED END ---")
}

func (s *CCVTestSuite) registerPacketSniffer(chain *ibctesting.TestChain) {
Expand Down Expand Up @@ -395,6 +397,7 @@ func (ps *packetSniffer) ListenFinalizeBlock(ctx context.Context, req abci.Reque
// TODO: @MSalopek this was deprecated, figure out how to use it
packets := ParsePacketsFromEvents(res.GetEvents())
for _, packet := range packets {
fmt.Println("#----------- packet --------------- #", packet)
ps.packets[getSentPacketKey(packet.Sequence, packet.SourceChannel)] = packet
}
return nil
Expand All @@ -407,6 +410,7 @@ func getSentPacketKey(sequence uint64, channelID string) string {
}

func (*packetSniffer) ListenCommit(ctx context.Context, res abci.ResponseCommit, cs []*store.StoreKVPair) error {
fmt.Println("# HAVE A COMMIT ##", res)
return nil
}

Expand Down
2 changes: 2 additions & 0 deletions testutil/ibc_testing/generic_setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ func AddProvider[T testutil.ProviderApp](t *testing.T, coordinator *ibctesting.C
ibctesting.DefaultTestingAppInit = appIniter
provider := ibctesting.NewTestChain(t, coordinator, provChainID)
coordinator.Chains[provChainID] = provider
fmt.Println("### PROVI BLOCK", coordinator.Chains[provChainID].GetContext().BlockHeight())

providerToReturn, ok := provider.App.(T)
if !ok {
Expand Down Expand Up @@ -131,6 +132,7 @@ func AddConsumer[Tp testutil.ProviderApp, Tc testutil.ConsumerApp](
providerChain.GetContext(),
prop,
)
fmt.Println("### ERRORED ON CREATE #####", err)
s.Require().NoError(err)

// commit the state on the provider chain
Expand Down
6 changes: 4 additions & 2 deletions testutil/ibc_testing/specific_setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package ibc_testing

import (
"encoding/json"
"fmt"

db "github.com/cosmos/cosmos-db"
ibctesting "github.com/cosmos/ibc-go/v8/testing"
Expand Down Expand Up @@ -34,6 +35,7 @@ var (
func ProviderAppIniter() (ibctesting.TestingApp, map[string]json.RawMessage) {
encoding := appProvider.MakeTestEncodingConfig()
testApp := appProvider.New(log.NewNopLogger(), db.NewMemDB(), nil, true, simtestutil.EmptyAppOptions{})
fmt.Println("$$$$ ProviderAppIniter done")
return testApp, appProvider.NewDefaultGenesisState(encoding.Codec)
}

Expand All @@ -43,7 +45,7 @@ func ConsumerAppIniter(initValPowers []types.ValidatorUpdate) AppIniter {
encoding := appConsumer.MakeTestEncodingConfig()
testApp := appConsumer.New(log.NewNopLogger(), db.NewMemDB(), nil, true, simtestutil.EmptyAppOptions{})
genesisState := appConsumer.NewDefaultGenesisState(encoding.Codec)
// NOTE ibc-go/v7/testing.SetupWithGenesisValSet requires a staking module
// NOTE: starting from ibc-go/v7/testing.SetupWithGenesisValSet requires a staking module
// genesisState or it panics. Feed a minimum one.
genesisState[stakingtypes.ModuleName] = encoding.Codec.MustMarshalJSON(
&stakingtypes.GenesisState{
Expand All @@ -56,7 +58,7 @@ func ConsumerAppIniter(initValPowers []types.ValidatorUpdate) AppIniter {
consumerGenesis.InitialValSet = initValPowers
consumerGenesis.Params.Enabled = true
genesisState[consumertypes.ModuleName] = encoding.Codec.MustMarshalJSON(&consumerGenesis)

fmt.Println("$$$$ ConsumerAppIniter done")
return testApp, genesisState
}
}
Expand Down
3 changes: 3 additions & 0 deletions x/ccv/provider/keeper/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ func (k Keeper) CreateConsumerClient(ctx sdk.Context, prop *types.ConsumerAdditi
clientState.UnbondingPeriod = consumerUnbondingPeriod

consumerGen, validatorSetHash, err := k.MakeConsumerGenesis(ctx, prop)
fmt.Println("## ERRORS IN PROPOSAL ###", err)
if err != nil {
return err
}
Expand Down Expand Up @@ -246,6 +247,7 @@ func (k Keeper) MakeConsumerGenesis(
return gen, nil, errorsmod.Wrapf(types.ErrNoUnbondingTime, "ubonding time not found: %s", err)
}
height := clienttypes.GetSelfHeight(ctx)
fmt.Println("## PROVIDER HEIGHT at MakeConsumerGenesis", height)

clientState := k.GetTemplateClient(ctx)
// this is the counter party chain ID for the consumer
Expand All @@ -261,6 +263,7 @@ func (k Keeper) MakeConsumerGenesis(
clientState.UnbondingPeriod = providerUnbondingPeriod

consState, err := k.clientKeeper.GetSelfConsensusState(ctx, height)
fmt.Println("! NO CONSENSUS STATE !", err)
if err != nil {
return gen, nil, errorsmod.Wrapf(clienttypes.ErrConsensusStateNotFound, "error %s getting self consensus state for: %s", err, height)
}
Expand Down

0 comments on commit a73a06c

Please sign in to comment.