diff --git a/.github/workflows/simulations.yml b/.github/workflows/simulations.yml new file mode 100644 index 00000000..67828b27 --- /dev/null +++ b/.github/workflows/simulations.yml @@ -0,0 +1,47 @@ +name: Simulation +# Simulation workflow runs simulation test +# This workflow is run on pushes to master & every Pull Requests where a .go, .mod, .sum have been changed +on: + pull_request: + push: + branches: + - main + +env: + GO_VERSION: "1.21.0" + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v4 + with: + go-version: ${{ env.GO_VERSION }} + check-latest: true + cache: true + cache-dependency-path: go.sum + - + name: Get git diff + uses: technote-space/get-diff-action@v6.1.2 + with: + PATTERNS: | + **/**!(test).go + go.mod + go.sum + Makefile + + - name: Run determinism check simulation + run: | + make test-sim-determinism + if: env.GIT_DIFF + + - name: Run export-import simulation + run: | + make test-sim-export-import + if: env.GIT_DIFF + + - name: Run after-import simulation + run: | + make test-sim-after-import + if: env.GIT_DIFF diff --git a/Makefile b/Makefile index 73252a91..38144030 100644 --- a/Makefile +++ b/Makefile @@ -224,6 +224,40 @@ endif .PHONY: cover-html run-tests $(TEST_TARGETS) test test-race docker-build-e2e +############################################################################### +### Simulation Tests ### +############################################################################### + +CURRENT_DIR = $(shell pwd) + +test-sim-determinism: + @echo "Running determinism test..." + @cd ${CURRENT_DIR}/simulation && go test -mod=readonly -run TestAppStateDeterminism -Enabled=true \ + -NumBlocks=100 -BlockSize=200 -Commit=true -Period=0 -v -timeout 24h + +test-sim-export-import: + @echo "Running export-import test..." + @cd ${CURRENT_DIR}/simulation && go test -mod=readonly -run TestAppExportImport -Enabled=true \ + -NumBlocks=100 -BlockSize=200 -Commit=true -Period=0 -v -timeout 24h + +test-sim-after-import: + @echo "Running simulation-after-import test..." + @cd ${CURRENT_DIR}/simulation && go test -mod=readonly -run TestAppSimulationAfterImport -Enabled=true \ + -NumBlocks=100 -BlockSize=200 -Commit=true -Period=0 -v -timeout 24h + +.PHONY: test-sim-determinism test-sim-export-import test-sim-after-import + +SIM_NUM_BLOCKS ?= 500 +SIM_BLOCK_SIZE ?= 200 +SIM_COMMIT ?= true + +test-sim-benchmark: + @echo "Running application benchmark for numBlocks=$(SIM_NUM_BLOCKS), blockSize=$(SIM_BLOCK_SIZE). This may take awhile!" + @cd ${CURRENT_DIR}/simulation && go test -mod=readonly -run=^$$ $(.) -bench ^BenchmarkSimulation$$ \ + -Enabled=true -NumBlocks=$(SIM_NUM_BLOCKS) -BlockSize=$(SIM_BLOCK_SIZE) -Commit=$(SIM_COMMIT) -timeout 24h + +.PHONY: test-sim-benchmark + ############################################################################### ### interchaintest ### ############################################################################### diff --git a/app/app.go b/app/app.go index 4c1bd280..2870b660 100644 --- a/app/app.go +++ b/app/app.go @@ -566,18 +566,6 @@ func NewApp( wasmOpts..., ) - // // - // // - // // Register the proposal types - // // Deprecated: Avoid adding new handlers, instead use the new proposal flow - // // by granting the governance module the right to execute the message. - // // See: https://docs.cosmos.network/main/modules/gov#proposal-messages - // govRouter := govv1beta1.NewRouter() - // govRouter.AddRoute(govtypes.RouterKey, govv1beta1.ProposalHandler). - // AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)) - // // - // // - govConfig := govtypes.DefaultConfig() govKeeper := govkeeper.NewKeeper( appCodec, @@ -591,13 +579,6 @@ func NewApp( authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) - // // - // // - // // Set legacy router for backwards compatibility with gov v1beta1 - // govKeeper.SetLegacyRouter(govRouter) - // // - // // - app.GovKeeper = *govKeeper.SetHooks( govtypes.NewMultiGovHooks( // register the governance hooks diff --git a/simulation/simulation_test.go b/simulation/simulation_test.go index 2b3ade23..2e324061 100644 --- a/simulation/simulation_test.go +++ b/simulation/simulation_test.go @@ -43,10 +43,8 @@ func init() { } // BenchmarkSimulation run the chain simulation -// Running using starport command: -// `starport chain simulate -v --numBlocks 200 --blockSize 50` // Running as go benchmark test: -// `go test -benchmem -run=^$ -bench ^BenchmarkSimulation ./app -NumBlocks=200 -BlockSize 50 -Commit=true -Verbose=true -Enabled=true` +// go test -benchmem -run=^$ -bench ^BenchmarkSimulation ./simulation -NumBlocks=200 -BlockSize 50 -Commit=true -Verbose=true -Enabled=true func BenchmarkSimulation(b *testing.B) { simcli.FlagSeedValue = time.Now().Unix() simcli.FlagVerboseValue = true @@ -162,7 +160,7 @@ func TestAppStateDeterminism(t *testing.T) { ) fmt.Printf( - "running non-determinism simulation; seed %d: %d/%d, attempt: %d/%d\n", + "running determinism simulation; seed %d: %d/%d, attempt: %d/%d\n", config.Seed, i+1, numSeeds, j+1, numTimesToRunPerSeed, ) @@ -193,16 +191,16 @@ func TestAppStateDeterminism(t *testing.T) { if j != 0 { require.Equal( t, string(appHashList[0]), string(appHashList[j]), - "non-determinism in seed %d: %d/%d, attempt: %d/%d\n", config.Seed, i+1, numSeeds, j+1, numTimesToRunPerSeed, + "determinism in seed %d: %d/%d, attempt: %d/%d\n", config.Seed, i+1, numSeeds, j+1, numTimesToRunPerSeed, ) } } } } -func TestAppImportExport(t *testing.T) { +func TestAppExportImport(t *testing.T) { config := simcli.NewConfigFromFlags() - config.ChainID = "seda-simapp-import" + config.ChainID = "seda-simapp-export-import" db, dir, logger, skip, err := simtestutil.SetupSimulation( config,