Skip to content

Commit

Permalink
Merge branch 'develop' into feat/staking-distribute-function
Browse files Browse the repository at this point in the history
  • Loading branch information
Francisco de Borja Aranda Castillejo authored Oct 24, 2024
2 parents 7da0e3a + b334267 commit 36e36a8
Show file tree
Hide file tree
Showing 86 changed files with 3,252 additions and 1,193 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ jobs:
core.setOutput('SOLANA_TESTS', true);
core.setOutput('TON_TESTS', true);
core.setOutput('V2_TESTS', true); // for v2 tests, TODO: remove this once we fully migrate to v2 (https://github.com/zeta-chain/node/issues/2627)
core.setOutput('V2_MIGRATION_TESTS', true); // for v2 tests, TODO: remove this once we fully migrate to v2 (https://github.com/zeta-chain/node/issues/2627)
} else if (context.eventName === 'schedule') {
core.setOutput('DEFAULT_TESTS', true);
core.setOutput('UPGRADE_TESTS', true);
Expand All @@ -102,7 +101,6 @@ jobs:
core.setOutput('SOLANA_TESTS', true);
core.setOutput('TON_TESTS', true);
core.setOutput('V2_TESTS', true); // for v2 tests, TODO: remove this once we fully migrate to v2 (https://github.com/zeta-chain/node/issues/2627)
core.setOutput('V2_MIGRATION_TESTS', true); // for v2 tests, TODO: remove this once we fully migrate to v2 (https://github.com/zeta-chain/node/issues/2627)
} else if (context.eventName === 'workflow_dispatch') {
const makeTargets = context.payload.inputs['make-targets'].split(',');
core.setOutput('DEFAULT_TESTS', makeTargets.includes('default-test'));
Expand Down
85 changes: 70 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ DOCKER ?= docker
# allow setting of NODE_COMPOSE_ARGS to pass additional args to docker compose
# useful for setting profiles and/ort optional overlays
# example: NODE_COMPOSE_ARGS="--profile monitoring -f docker-compose-persistent.yml"
DOCKER_COMPOSE ?= $(DOCKER) compose $(NODE_COMPOSE_ARGS)
DOCKER_COMPOSE ?= $(DOCKER) compose -f docker-compose.yml $(NODE_COMPOSE_ARGS)
DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace bufbuild/buf
GOFLAGS := ""
GOLANG_CROSS_VERSION ?= v1.22.4
Expand Down Expand Up @@ -221,11 +221,11 @@ start-localnet: zetanode start-localnet-skip-build
start-localnet-skip-build:
@echo "--> Starting localnet"
export LOCALNET_MODE=setup-only && \
cd contrib/localnet/ && $(DOCKER_COMPOSE) -f docker-compose.yml up -d
cd contrib/localnet/ && $(DOCKER_COMPOSE) up -d

# stop-localnet should include all profiles so other containers are also removed
stop-localnet:
cd contrib/localnet/ && $(DOCKER_COMPOSE) --profile all -f docker-compose.yml down --remove-orphans
cd contrib/localnet/ && $(DOCKER_COMPOSE) --profile all down --remove-orphans

###############################################################################
### E2E tests ###
Expand Down Expand Up @@ -253,22 +253,22 @@ start-e2e-test: zetanode
start-e2e-admin-test: zetanode
@echo "--> Starting e2e admin test"
export E2E_ARGS="--skip-regular --test-admin" && \
cd contrib/localnet/ && $(DOCKER_COMPOSE) --profile eth2 -f docker-compose.yml up -d
cd contrib/localnet/ && $(DOCKER_COMPOSE) --profile eth2 up -d

start-e2e-performance-test: zetanode
@echo "--> Starting e2e performance test"
export E2E_ARGS="--test-performance" && \
cd contrib/localnet/ && $(DOCKER_COMPOSE) --profile stress -f docker-compose.yml up -d
cd contrib/localnet/ && $(DOCKER_COMPOSE) --profile stress up -d

start-e2e-import-mainnet-test: zetanode
@echo "--> Starting e2e import-data test"
export ZETACORED_IMPORT_GENESIS_DATA=true && \
export ZETACORED_START_PERIOD=15m && \
cd contrib/localnet/ && ./scripts/import-data.sh mainnet && $(DOCKER_COMPOSE) -f docker-compose.yml up -d
cd contrib/localnet/ && ./scripts/import-data.sh mainnet && $(DOCKER_COMPOSE) up -d

start-stress-test: zetanode
@echo "--> Starting stress test"
cd contrib/localnet/ && $(DOCKER_COMPOSE) --profile stress -f docker-compose.yml up -d
cd contrib/localnet/ && $(DOCKER_COMPOSE) --profile stress up -d

start-tss-migration-test: zetanode
@echo "--> Starting tss migration test"
Expand All @@ -279,17 +279,17 @@ start-tss-migration-test: zetanode
start-solana-test: zetanode solana
@echo "--> Starting solana test"
export E2E_ARGS="--skip-regular --test-solana" && \
cd contrib/localnet/ && $(DOCKER_COMPOSE) --profile solana -f docker-compose.yml up -d
cd contrib/localnet/ && $(DOCKER_COMPOSE) --profile solana up -d

start-ton-test: zetanode
@echo "--> Starting TON test"
export E2E_ARGS="--skip-regular --test-ton" && \
cd contrib/localnet/ && $(DOCKER_COMPOSE) --profile ton -f docker-compose.yml up -d
cd contrib/localnet/ && $(DOCKER_COMPOSE) --profile ton up -d

start-v2-test: zetanode
@echo "--> Starting e2e smart contracts v2 test"
export E2E_ARGS="--skip-regular --test-v2" && \
cd contrib/localnet/ && $(DOCKER_COMPOSE) -f docker-compose.yml up -d
cd contrib/localnet/ && $(DOCKER_COMPOSE) up -d

###############################################################################
### Upgrade Tests ###
Expand Down Expand Up @@ -321,20 +321,20 @@ start-upgrade-test: zetanode-upgrade
@echo "--> Starting upgrade test"
export LOCALNET_MODE=upgrade && \
export UPGRADE_HEIGHT=225 && \
cd contrib/localnet/ && $(DOCKER_COMPOSE) --profile upgrade -f docker-compose.yml -f docker-compose-upgrade.yml up -d
cd contrib/localnet/ && $(DOCKER_COMPOSE) --profile upgrade -f docker-compose-upgrade.yml up -d

start-upgrade-test-light: zetanode-upgrade
@echo "--> Starting light upgrade test (no ZetaChain state populating before upgrade)"
export LOCALNET_MODE=upgrade && \
export UPGRADE_HEIGHT=90 && \
cd contrib/localnet/ && $(DOCKER_COMPOSE) --profile upgrade -f docker-compose.yml -f docker-compose-upgrade.yml up -d
cd contrib/localnet/ && $(DOCKER_COMPOSE) --profile upgrade -f docker-compose-upgrade.yml up -d

start-upgrade-test-admin: zetanode-upgrade
@echo "--> Starting admin upgrade test"
export LOCALNET_MODE=upgrade && \
export UPGRADE_HEIGHT=90 && \
export E2E_ARGS="--skip-regular --test-admin" && \
cd contrib/localnet/ && $(DOCKER_COMPOSE) --profile upgrade -f docker-compose.yml -f docker-compose-upgrade.yml up -d
cd contrib/localnet/ && $(DOCKER_COMPOSE) --profile upgrade -f docker-compose-upgrade.yml up -d

# this test upgrades from v18 and execute the v2 contracts migration process
# this tests is part of upgrade test part because it should run the upgrade from v18 to fully replicate the upgrade process
Expand All @@ -343,7 +343,7 @@ start-upgrade-v2-migration-test: zetanode-upgrade
export LOCALNET_MODE=upgrade && \
export UPGRADE_HEIGHT=90 && \
export E2E_ARGS="--test-v2-migration" && \
cd contrib/localnet/ && $(DOCKER_COMPOSE) --profile upgrade -f docker-compose.yml -f docker-compose-upgrade.yml up -d
cd contrib/localnet/ && $(DOCKER_COMPOSE) --profile upgrade -f docker-compose-upgrade.yml up -d


start-upgrade-import-mainnet-test: zetanode-upgrade
Expand All @@ -352,7 +352,62 @@ start-upgrade-import-mainnet-test: zetanode-upgrade
export ZETACORED_IMPORT_GENESIS_DATA=true && \
export ZETACORED_START_PERIOD=15m && \
export UPGRADE_HEIGHT=225 && \
cd contrib/localnet/ && ./scripts/import-data.sh mainnet && $(DOCKER_COMPOSE) --profile upgrade -f docker-compose.yml -f docker-compose-upgrade.yml up -d
cd contrib/localnet/ && ./scripts/import-data.sh mainnet && $(DOCKER_COMPOSE) --profile upgrade -f docker-compose-upgrade.yml up -d


###############################################################################
### Simulation Tests ###
###############################################################################

BINDIR ?= $(GOPATH)/bin
SIMAPP = ./tests/simulation


# Run sim is a cosmos tool which helps us to run multiple simulations in parallel.
runsim: $(BINDIR)/runsim
$(BINDIR)/runsim:
@echo 'Installing runsim...'
@TEMP_DIR=$$(mktemp -d) && \
cd $$TEMP_DIR && \
go install github.com/cosmos/tools/cmd/[email protected] && \
rm -rf $$TEMP_DIR || (echo 'Failed to install runsim' && exit 1)
@echo 'runsim installed successfully'


# Configuration parameters for simulation tests
# NumBlocks: Number of blocks to simulate
# BlockSize: Number of transactions in a block
# Commit: Whether to commit the block or not
# Period: Invariant check period
# Timeout: Timeout for the simulation test
define run-sim-test
@echo "Running $(1)..."
@go test -mod=readonly $(SIMAPP) -run $(2) -Enabled=true \
-NumBlocks=$(3) -BlockSize=$(4) -Commit=true -Period=0 -v -timeout $(5)
endef

test-sim-nondeterminism:
$(call run-sim-test,"non-determinism test",TestAppStateDeterminism,100,200,2h)

test-sim-fullappsimulation:
$(call run-sim-test,"TestFullAppSimulation",TestFullAppSimulation,100,200,2h)

test-sim-multi-seed-long: runsim
@echo "Running long multi-seed application simulation."
@$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) -ExitOnFail 500 50 TestFullAppSimulation

test-sim-multi-seed-short: runsim
@echo "Running short multi-seed application simulation."
@$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) -ExitOnFail 50 10 TestFullAppSimulation



.PHONY: \
test-sim-nondeterminism \
test-sim-fullappsimulation \
test-sim-multi-seed-long \
test-sim-multi-seed-short


###############################################################################
### GoReleaser ###
Expand Down
103 changes: 44 additions & 59 deletions app/app.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package app

import (
"encoding/json"
"io"
"net/http"
"os"
Expand Down Expand Up @@ -178,64 +179,33 @@ func getGovProposalHandlers() []govclient.ProposalHandler {
return govProposalHandlers
}

var (
ModuleBasics = module.NewBasicManager(
auth.AppModuleBasic{},
genutil.NewAppModuleBasic(genutiltypes.DefaultMessageValidator),
bank.AppModuleBasic{},
//capability.AppModuleBasic{},
staking.AppModuleBasic{},
distr.AppModuleBasic{},
gov.NewAppModuleBasic(getGovProposalHandlers()),
params.AppModuleBasic{},
crisis.AppModuleBasic{},
slashing.AppModuleBasic{},
//ibc.AppModuleBasic{},
//ibctm.AppModuleBasic{},
upgrade.AppModuleBasic{},
evidence.AppModuleBasic{},
//transfer.AppModuleBasic{},
vesting.AppModuleBasic{},
consensus.AppModuleBasic{},
evm.AppModuleBasic{},
feemarket.AppModuleBasic{},
authoritymodule.AppModuleBasic{},
lightclientmodule.AppModuleBasic{},
crosschainmodule.AppModuleBasic{},
//ibccrosschain.AppModuleBasic{},
observermodule.AppModuleBasic{},
fungiblemodule.AppModuleBasic{},
emissionsmodule.AppModuleBasic{},
groupmodule.AppModuleBasic{},
authzmodule.AppModuleBasic{},
)

// module account permissions
maccPerms = map[string][]string{
authtypes.FeeCollectorName: nil,
distrtypes.ModuleName: nil,
stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking},
stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking},
govtypes.ModuleName: {authtypes.Burner},
//ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
crosschaintypes.ModuleName: {authtypes.Minter, authtypes.Burner},
//ibccrosschaintypes.ModuleName: nil,
evmtypes.ModuleName: {authtypes.Minter, authtypes.Burner},
fungibletypes.ModuleName: {authtypes.Minter, authtypes.Burner},
emissionstypes.ModuleName: nil,
emissionstypes.UndistributedObserverRewardsPool: nil,
emissionstypes.UndistributedTSSRewardsPool: nil,
}
type GenesisState map[string]json.RawMessage

// module account permissions
var maccPerms = map[string][]string{
authtypes.FeeCollectorName: nil,
distrtypes.ModuleName: nil,
stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking},
stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking},
govtypes.ModuleName: {authtypes.Burner},
//ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
crosschaintypes.ModuleName: {authtypes.Minter, authtypes.Burner},
//ibccrosschaintypes.ModuleName: nil,
evmtypes.ModuleName: {authtypes.Minter, authtypes.Burner},
fungibletypes.ModuleName: {authtypes.Minter, authtypes.Burner},
emissionstypes.ModuleName: nil,
emissionstypes.UndistributedObserverRewardsPool: nil,
emissionstypes.UndistributedTSSRewardsPool: nil,
}

// module accounts that are NOT allowed to receive tokens
blockedReceivingModAcc = map[string]bool{
distrtypes.ModuleName: true,
authtypes.FeeCollectorName: true,
stakingtypes.BondedPoolName: true,
stakingtypes.NotBondedPoolName: true,
govtypes.ModuleName: true,
}
)
// module accounts that are NOT allowed to receive tokens
var blockedReceivingModAcc = map[string]bool{
distrtypes.ModuleName: true,
authtypes.FeeCollectorName: true,
stakingtypes.BondedPoolName: true,
stakingtypes.NotBondedPoolName: true,
govtypes.ModuleName: true,
}

var (
_ runtime.AppI = (*App)(nil)
Expand All @@ -260,6 +230,7 @@ type App struct {

mm *module.Manager
sm *module.SimulationManager
mb module.BasicManager
configurator module.Configurator

// sdk keepers
Expand Down Expand Up @@ -637,6 +608,7 @@ func New(
govRouter.AddRoute(govtypes.RouterKey, govv1beta1.ProposalHandler).
AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)).
AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper))

govConfig := govtypes.DefaultConfig()
govKeeper := govkeeper.NewKeeper(
appCodec,
Expand All @@ -648,11 +620,14 @@ func New(
govConfig,
authAddr,
)

app.GovKeeper = *govKeeper.SetHooks(
govtypes.NewMultiGovHooks(
// register governance hooks
),
)
// Set legacy router for backwards compatibility with gov v1beta1
// app.GovKeeper.SetLegacyRouter(govRouter)

// Create evidence Keeper for to register the IBC light client misbehaviour evidence route
evidenceKeeper := evidencekeeper.NewKeeper(
Expand Down Expand Up @@ -738,6 +713,8 @@ func New(
authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
)

app.mb = ModuleBasics

// During begin block slashing happens after distr.BeginBlocker so that
// there is nothing left over in the validator fee pool, so as to keep the
// CanWithdrawInvariant invariant.
Expand Down Expand Up @@ -813,6 +790,10 @@ func New(
app.configurator = module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter())
app.mm.RegisterServices(app.configurator)

app.sm = module.NewSimulationManager(simulationModules(app, appCodec, skipGenesisInvariants)...)

app.sm.RegisterStoreDecoders()

// initialize stores
app.MountKVStores(keys)
app.MountTransientStores(tKeys)
Expand Down Expand Up @@ -920,7 +901,7 @@ func (app *App) ModuleAccountAddrs() map[string]bool {
return modAccAddrs
}

// LegacyAmino returns SimApp's amino codec.
// LegacyAmino returns app's amino codec.
//
// NOTE: This is solely to be used for testing purposes as it may be desirable
// for modules to register their own custom testing types.
Expand Down Expand Up @@ -983,7 +964,7 @@ func (app *App) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig
nodeservice.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)

// Register legacy and grpc-gateway routes for all modules.
ModuleBasics.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)
app.mb.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)

// register app's OpenAPI routes.
if apiConfig.Swagger {
Expand Down Expand Up @@ -1075,6 +1056,10 @@ func (app *App) SimulationManager() *module.SimulationManager {
return app.sm
}

func (app *App) BasicManager() module.BasicManager {
return app.mb
}

func (app *App) BlockedAddrs() map[string]bool {
blockList := make(map[string]bool)

Expand Down
2 changes: 2 additions & 0 deletions app/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ func MakeEncodingConfig() ethermint.EncodingConfig {
encodingConfig := evmenc.MakeConfig(ModuleBasics)
registry := encodingConfig.InterfaceRegistry

// TODO test if we need to register these interfaces again as MakeConfig already registers them
// https://github.com/zeta-chain/node/issues/3003
cryptocodec.RegisterInterfaces(registry)
authtypes.RegisterInterfaces(registry)
authz.RegisterInterfaces(registry)
Expand Down
21 changes: 0 additions & 21 deletions app/genesis.go

This file was deleted.

Loading

0 comments on commit 36e36a8

Please sign in to comment.