Skip to content

Commit

Permalink
add todos for BasicManager
Browse files Browse the repository at this point in the history
  • Loading branch information
kingpinXD committed Oct 3, 2024
1 parent cad3f4f commit c07d519
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 22 deletions.
1 change: 1 addition & 0 deletions app/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
evmenc "github.com/zeta-chain/ethermint/encoding"
ethermint "github.com/zeta-chain/ethermint/types"
evmtypes "github.com/zeta-chain/ethermint/x/evm/types"

authoritytypes "github.com/zeta-chain/node/x/authority/types"
crosschaintypes "github.com/zeta-chain/node/x/crosschain/types"
emissionstypes "github.com/zeta-chain/node/x/emissions/types"
Expand Down
16 changes: 9 additions & 7 deletions app/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import (
evmtypes "github.com/zeta-chain/ethermint/x/evm/types"
"github.com/zeta-chain/ethermint/x/feemarket"
feemarkettypes "github.com/zeta-chain/ethermint/x/feemarket/types"

authoritymodule "github.com/zeta-chain/node/x/authority"
authoritytypes "github.com/zeta-chain/node/x/authority/types"
crosschainmodule "github.com/zeta-chain/node/x/crosschain"
Expand Down Expand Up @@ -126,6 +127,7 @@ func InitGenesisModuleList() []string {
}
}

// simulationModules returns a list of modules to include in the simulation
func simulationModules(
app *App,
appCodec codec.Codec,
Expand All @@ -139,13 +141,13 @@ func simulationModules(
app.GetSubspace(authtypes.ModuleName),
),
bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper, app.GetSubspace(banktypes.ModuleName)),
gov.NewAppModule(
appCodec,
&app.GovKeeper,
app.AccountKeeper,
app.BankKeeper,
app.GetSubspace(govtypes.ModuleName),
),
//gov.NewAppModule(
// appCodec,
// &app.GovKeeper,
// app.AccountKeeper,
// app.BankKeeper,
// app.GetSubspace(govtypes.ModuleName),
//),
staking.NewAppModule(
appCodec,
app.StakingKeeper,
Expand Down
27 changes: 16 additions & 11 deletions sims.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,32 @@ 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..."
@(cd /tmp && go install github.com/cosmos/tools/cmd/[email protected])
@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'


test-sim-nondeterminism:
@echo "Running non-determinism test..."
@go test -mod=readonly $(SIMAPP) -run TestAppStateDeterminism -Enabled=true \
-NumBlocks=10 -BlockSize=20 -Commit=true -Period=0 -v -timeout 24h
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:
@echo "Running TestFullAppSimulation."
@go test -mod=readonly $(SIMAPP) -run TestFullAppSimulation -Enabled=true \
-NumBlocks=100 -BlockSize=200 -Commit=true -Period=0 -v -timeout 24h
$(call run-sim-test,"TestFullAppSimulation",TestFullAppSimulation,100,200,2h)

test-sim-multi-seed-long: runsim
@echo "Running long multi-seed application simulation. This may take awhile!"
@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. This may take awhile!"
@echo "Running short multi-seed application simulation."
@$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) -ExitOnFail 50 10 TestFullAppSimulation


Expand Down
15 changes: 11 additions & 4 deletions tests/simulation/sim/sim_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ import (
"github.com/cosmos/cosmos-sdk/types/simulation"
)

const (
defaultSeed = 42
defaultNumBlocks = 500
defaultInitialHeight = 1
defaultBlockSize = 200
)

// List of available flags for the simulator
var (
FlagGenesisFileValue string
Expand Down Expand Up @@ -68,10 +75,10 @@ func GetSimulatorFlags() {
"",
"custom file path to save the exported simulation statistics JSON",
)
flag.Int64Var(&FlagSeedValue, "Seed", 42, "simulation random seed")
flag.IntVar(&FlagInitialBlockHeightValue, "InitialBlockHeight", 1, "initial block to start the simulation")
flag.IntVar(&FlagNumBlocksValue, "NumBlocks", 500, "number of new blocks to simulate from the initial block height")
flag.IntVar(&FlagBlockSizeValue, "BlockSize", 200, "operations per block")
flag.Int64Var(&FlagSeedValue, "Seed", defaultSeed, "simulation random seed")
flag.IntVar(&FlagInitialBlockHeightValue, "InitialBlockHeight", defaultInitialHeight, "initial block to start the simulation")
flag.IntVar(&FlagNumBlocksValue, "NumBlocks", defaultNumBlocks, "number of new blocks to simulate from the initial block height")
flag.IntVar(&FlagBlockSizeValue, "BlockSize", defaultBlockSize, "operations per block")
flag.BoolVar(&FlagLeanValue, "Lean", false, "lean simulation log output")
flag.BoolVar(&FlagCommitValue, "Commit", false, "have the simulation commit")
flag.BoolVar(&FlagOnOperationValue, "SimulateEveryOperation", false, "run slow invariants every operation")
Expand Down
4 changes: 4 additions & 0 deletions tests/simulation/sim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ func TestAppStateDeterminism(t *testing.T) {
appHash := simApp.LastCommitID().Hash
appHashList[j] = appHash

// Clean up resources
require.NoError(t, db.Close())
require.NoError(t, os.RemoveAll(dir))

if j != 0 {
require.Equal(
t,
Expand Down

0 comments on commit c07d519

Please sign in to comment.