Skip to content

Commit

Permalink
Feat: update consumer init and export genesis
Browse files Browse the repository at this point in the history
* Stop exporting client and consensus states in consumer genesis
* Add LastTransmissionBlockHeight to genesis proto
  • Loading branch information
sainoe committed Nov 9, 2022
1 parent 03c643c commit eb59e50
Show file tree
Hide file tree
Showing 97 changed files with 8,003 additions and 1,859 deletions.
4 changes: 4 additions & 0 deletions .github/ISSUE_TEMPLATE/issue-template.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ assignees: ''


# Closing criteria

# TODOs
- [ ] Labels have been added for issue
- [ ] Issue has been added to the ICS project
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ ENV CGO_ENABLED=0
ENV GOOS=linux
ENV GOFLAGS="-buildvcs=false"

WORKDIR /downloads

# Copy in the repo under test
ADD . /interchain-security

Expand All @@ -24,11 +22,13 @@ RUN go mod tidy
RUN make install

# Get Hermes build
FROM informalsystems/hermes:1.0.0 AS hermes-builder
# FROM informalsystems/hermes:1.0.0 AS hermes-builder
# remove line below and use the line above once hermes is updated
FROM majita/hermes-unofficial:latest AS hermes-builder

FROM --platform=linux/amd64 fedora:36
RUN dnf update -y
RUN dnf install -y which iproute iputils procps-ng vim-minimal tmux net-tools htop jq
RUN dnf install -y which iproute iputils procps-ng vim-minimal tmux net-tools htop jq openssl1.1
USER root

# Copy Hermes and IS binaries to final image
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ Unit tests are useful for simple standalone functionality, and CRUD operations.

### End to End (e2e) Tests

[e2e-tests](./tests/e2e/) utilize the [IBC Testing Package](https://github.com/cosmos/ibc-go/tree/main/testing), and test functionality that is wider in scope than a unit test, but still able to be validated in-memory. Ie. code where advancing blocks would be useful, simulated handshakes, simulated packet relays, etc.
[e2e-tests](./tests/e2e/) utilize the [IBC Testing Package](https://github.com/cosmos/ibc-go/tree/main/testing), and test functionality that is wider in scope than a unit test, but still able to be validated in-memory. Ie. code where advancing blocks would be useful, simulated handshakes, simulated packet relays, etc.

To run e2e tests against your own consumer/provider implementations, use [instance_test.go](./tests/e2e/instance_test.go) as an example. All you'll need to do is make sure your applications implement the necessary interfaces defined in [interfaces.go](./testutil/e2e/interfaces.go), then pass in an appropriate callback to the testing suites.

### Differential Tests (WIP)

Expand Down
48 changes: 48 additions & 0 deletions app/consumer-democracy/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ import (
ccvdistrclient "github.com/cosmos/cosmos-sdk/x/distribution/client"
ccvdistrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper"
ccvdistrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
"github.com/cosmos/interchain-security/testutil/e2e"
ccvdistr "github.com/cosmos/interchain-security/x/ccv/democracy/distribution"

ccvstakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
Expand Down Expand Up @@ -757,6 +758,53 @@ func (app *App) SimulationManager() *module.SimulationManager {
return app.sm
}

// DemocConsumerApp interface implementations for e2e tests

// GetConsumerKeeper implements the ConsumerApp interface.
func (app *App) GetConsumerKeeper() ibcconsumerkeeper.Keeper {
return app.ConsumerKeeper
}

// GetE2eBankKeeper implements the ConsumerApp interface.
func (app *App) GetE2eBankKeeper() e2e.E2eBankKeeper {
return app.BankKeeper
}

// GetE2eAccountKeeper implements the ConsumerApp interface.
func (app *App) GetE2eAccountKeeper() e2e.E2eAccountKeeper {
return app.AccountKeeper
}

// GetE2eSlashingKeeper implements the ConsumerApp interface.
func (app *App) GetE2eSlashingKeeper() e2e.E2eSlashingKeeper {
return app.SlashingKeeper
}

// GetE2eEvidenceKeeper implements the ConsumerApp interface.
func (app *App) GetE2eEvidenceKeeper() e2e.E2eEvidenceKeeper {
return app.EvidenceKeeper
}

// GetE2eStakingKeeper implements the ConsumerApp interface.
func (app *App) GetE2eStakingKeeper() e2e.E2eStakingKeeper {
return app.StakingKeeper
}

// GetE2eDistributionKeeper implements the ConsumerApp interface.
func (app *App) GetE2eDistributionKeeper() e2e.E2eDistributionKeeper {
return app.DistrKeeper
}

// GetE2eMintKeeper implements the ConsumerApp interface.
func (app *App) GetE2eMintKeeper() e2e.E2eMintKeeper {
return app.MintKeeper
}

// GetE2eGovKeeper implements the ConsumerApp interface.
func (app *App) GetE2eGovKeeper() e2e.E2eGovKeeper {
return app.GovKeeper
}

// TestingApp functions

// GetBaseApp implements the TestingApp interface.
Expand Down
3 changes: 2 additions & 1 deletion app/consumer-democracy/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ func (app *App) ExportAppStateAndValidators(

// prepare for fresh start at zero height
// NOTE zero height genesis is a temporary feature which will be deprecated
// in favour of export at a block height
//
// in favour of export at a block height
func (app *App) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []string) {
// applyAllowedAddrs := false

Expand Down
28 changes: 28 additions & 0 deletions app/consumer/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ import (
tmos "github.com/tendermint/tendermint/libs/os"
dbm "github.com/tendermint/tm-db"

"github.com/cosmos/interchain-security/testutil/e2e"
ibcconsumer "github.com/cosmos/interchain-security/x/ccv/consumer"
ibcconsumerkeeper "github.com/cosmos/interchain-security/x/ccv/consumer/keeper"
ibcconsumertypes "github.com/cosmos/interchain-security/x/ccv/consumer/types"
Expand Down Expand Up @@ -651,6 +652,33 @@ func (app *App) SimulationManager() *module.SimulationManager {
return app.sm
}

// ConsumerApp interface implementations for e2e tests

// GetConsumerKeeper implements the ConsumerApp interface.
func (app *App) GetConsumerKeeper() ibcconsumerkeeper.Keeper {
return app.ConsumerKeeper
}

// GetE2eBankKeeper implements the ConsumerApp interface.
func (app *App) GetE2eBankKeeper() e2e.E2eBankKeeper {
return app.BankKeeper
}

// GetE2eAccountKeeper implements the ConsumerApp interface.
func (app *App) GetE2eAccountKeeper() e2e.E2eAccountKeeper {
return app.AccountKeeper
}

// GetE2eSlashingKeeper implements the ConsumerApp interface.
func (app *App) GetE2eSlashingKeeper() e2e.E2eSlashingKeeper {
return app.SlashingKeeper
}

// GetE2eEvidenceKeeper implements the ConsumerApp interface.
func (app *App) GetE2eEvidenceKeeper() e2e.E2eEvidenceKeeper {
return app.EvidenceKeeper
}

// TestingApp functions

// GetBaseApp implements the TestingApp interface.
Expand Down
32 changes: 31 additions & 1 deletion app/provider/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ import (
ibcproviderkeeper "github.com/cosmos/interchain-security/x/ccv/provider/keeper"
providertypes "github.com/cosmos/interchain-security/x/ccv/provider/types"

e2e "github.com/cosmos/interchain-security/testutil/e2e"

"github.com/tendermint/spm/cosmoscmd"

// unnamed import of statik for swagger UI support
Expand Down Expand Up @@ -142,7 +144,8 @@ var (
upgradeclient.CancelProposalHandler,
ibcclientclient.UpdateClientProposalHandler,
ibcclientclient.UpgradeProposalHandler,
ibcproviderclient.ProposalHandler,
ibcproviderclient.ConsumerAdditionProposalHandler,
ibcproviderclient.ConsumerRemovalProposalHandler,
),
params.AppModuleBasic{},
crisis.AppModuleBasic{},
Expand Down Expand Up @@ -796,6 +799,33 @@ func (app *App) SimulationManager() *module.SimulationManager {
return app.sm
}

// ProviderApp interface implementations for e2e tests

// GetProviderKeeper implements the ProviderApp interface.
func (app *App) GetProviderKeeper() ibcproviderkeeper.Keeper {
return app.ProviderKeeper
}

// GetE2eStakingKeeper implements the ProviderApp interface.
func (app *App) GetE2eStakingKeeper() e2e.E2eStakingKeeper {
return app.StakingKeeper
}

// GetE2eBankKeeper implements the ProviderApp interface.
func (app *App) GetE2eBankKeeper() e2e.E2eBankKeeper {
return app.BankKeeper
}

// GetE2eSlashingKeeper implements the ProviderApp interface.
func (app *App) GetE2eSlashingKeeper() e2e.E2eSlashingKeeper {
return app.SlashingKeeper
}

// GetE2eDistributionKeeper implements the ProviderApp interface.
func (app *App) GetE2eDistributionKeeper() e2e.E2eDistributionKeeper {
return app.DistrKeeper
}

// TestingApp functions

// GetBaseApp implements the TestingApp interface.
Expand Down
3 changes: 2 additions & 1 deletion app/provider/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ func (app *App) ExportAppStateAndValidators(

// prepare for fresh start at zero height
// NOTE zero height genesis is a temporary feature which will be deprecated
// in favour of export at a block height
//
// in favour of export at a block height
func (app *App) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []string) {
applyAllowedAddrs := false

Expand Down
Loading

0 comments on commit eb59e50

Please sign in to comment.