Skip to content

Commit

Permalink
Merge pull request #1 from skip-mev/chore/lint-fix
Browse files Browse the repository at this point in the history
chore: lint fix
Alex Johnson authored Nov 9, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
2 parents ed16576 + 0bf2151 commit cb4f78b
Showing 7 changed files with 738 additions and 34 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -20,7 +20,6 @@ build/

# Go workspace file
go.work
go.work.sum

# editor
.idea/
32 changes: 8 additions & 24 deletions Makefile
Original file line number Diff line number Diff line change
@@ -85,47 +85,31 @@ build-and-start-app: build-test-app

.PHONY: build-test-app build-and-start-app

###############################################################################
## Workspaces ##
###############################################################################

use-main:
go work edit -use .
go work edit -dropuse ./tests/integration

use-integration:
go work edit -dropuse .
go work edit -use ./tests/integration

tidy:
go mod tidy
gofmt -s -w ./

.PHONY: docker-build docker-build-integration
###############################################################################
## Docker ##
###############################################################################

docker-build: use-main
docker-build:
@echo "Building E2E Docker image..."
@DOCKER_BUILDKIT=1 docker build -t skip-mev/feemarket-e2e -f contrib/images/feemarket.e2e.Dockerfile .

docker-build-integration: use-main
docker-build-integration:
@echo "Building integration-test Docker image..."
@DOCKER_BUILDKIT=1 docker build -t feemarket-integration -f contrib/images/feemarket.integration.Dockerfile .

###############################################################################
### Tests ###
###############################################################################

TEST_INTEGRATION_DEPS = docker-build-integration use-integration
TEST_INTEGRATION_DEPS = docker-build-integration
TEST_INTEGRATION_TAGS = integration

test-integration: $(TEST_INTEGRATION_DEPS)
@ echo "Running integration tests..."
@echo "Running integration tests..."
@go test ./tests/integration/feemarket_integration_test.go -timeout 30m -p 1 -race -v -tags='$(TEST_INTEGRATION_TAGS)'

test: use-main
test:
@go test -v -race $(shell go list ./... | grep -v tests/)

.PHONY: test test-integration
@@ -167,11 +151,11 @@ proto-update-deps:
### Linting ###
###############################################################################

lint: use-main
lint:
@echo "--> Running linter"
@go run github.com/golangci/golangci-lint/cmd/golangci-lint run --out-format=tab

lint-fix: use-main
lint-fix:
@echo "--> Running linter"
@go run github.com/golangci/golangci-lint/cmd/golangci-lint run --fix --out-format=tab --issues-exit-code=0

@@ -185,7 +169,7 @@ lint-markdown:
### Formatting ###
###############################################################################

format: use-main
format:

format:
@find . -name '*.go' -type f -not -path "*.git*" -not -path "./client/docs/statik/statik.go" -not -name '*.pb.go' -not -name '*.pulsar.go' -not -name '*.gw.go' | xargs go run mvdan.cc/gofumpt -w .
691 changes: 691 additions & 0 deletions go.work.sum

Large diffs are not rendered by default.

45 changes: 36 additions & 9 deletions tests/simapp/export.go
Original file line number Diff line number Diff line change
@@ -76,14 +76,17 @@ func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []

/* Handle fee distribution state. */
// withdraw all validator commission
app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) {
err := app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) {
valAddress, err := sdk.ValAddressFromBech32(val.GetOperator())
if err != nil {
return true
}
_, _ = app.DistrKeeper.WithdrawValidatorCommission(ctx, valAddress)
return false
})
if err != nil {
panic(err)
}

// withdraw all delegator rewards
dels, err := app.StakingKeeper.GetAllDelegations(ctx)
@@ -112,7 +115,7 @@ func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []
ctx = ctx.WithBlockHeight(0)

// reinitialize all validators
app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) {
err = app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) {
valAddress, err := sdk.ValAddressFromBech32(val.GetOperator())
if err != nil {
panic(err)
@@ -136,6 +139,9 @@ func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []
}
return false
})
if err != nil {
panic(err)
}

// reinitialize all delegations
for _, del := range dels {
@@ -162,22 +168,34 @@ func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []
/* Handle staking state. */

// iterate through redelegations, reset creation height
app.StakingKeeper.IterateRedelegations(ctx, func(_ int64, red stakingtypes.Redelegation) (stop bool) {
err = app.StakingKeeper.IterateRedelegations(ctx, func(_ int64, red stakingtypes.Redelegation) (stop bool) {
for i := range red.Entries {
red.Entries[i].CreationHeight = 0
}
app.StakingKeeper.SetRedelegation(ctx, red)
err = app.StakingKeeper.SetRedelegation(ctx, red)
if err != nil {
panic(err)
}
return false
})
if err != nil {
panic(err)
}

// iterate through unbonding delegations, reset creation height
app.StakingKeeper.IterateUnbondingDelegations(ctx, func(_ int64, ubd stakingtypes.UnbondingDelegation) (stop bool) {
err = app.StakingKeeper.IterateUnbondingDelegations(ctx, func(_ int64, ubd stakingtypes.UnbondingDelegation) (stop bool) {
for i := range ubd.Entries {
ubd.Entries[i].CreationHeight = 0
}
app.StakingKeeper.SetUnbondingDelegation(ctx, ubd)
err = app.StakingKeeper.SetUnbondingDelegation(ctx, ubd)
if err != nil {
panic(err)
}
return false
})
if err != nil {
panic(err)
}

// Iterate through validators by power descending, reset bond heights, and
// update bond intra-tx counters.
@@ -197,7 +215,10 @@ func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []
validator.Jailed = true
}

app.StakingKeeper.SetValidator(ctx, validator)
err = app.StakingKeeper.SetValidator(ctx, validator)
if err != nil {
panic(err)
}
counter++
}

@@ -214,12 +235,18 @@ func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []
/* Handle slashing state. */

// reset start height on signing infos
app.SlashingKeeper.IterateValidatorSigningInfos(
err = app.SlashingKeeper.IterateValidatorSigningInfos(
ctx,
func(addr sdk.ConsAddress, info slashingtypes.ValidatorSigningInfo) (stop bool) {
info.StartHeight = 0
app.SlashingKeeper.SetValidatorSigningInfo(ctx, addr, info)
err = app.SlashingKeeper.SetValidatorSigningInfo(ctx, addr, info)
if err != nil {
panic(err)
}
return false
},
)
if err != nil {
panic(err)
}
}
1 change: 1 addition & 0 deletions tests/simapp/feemarketd/main.go
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ import (

"cosmossdk.io/log"
svrcmd "github.com/cosmos/cosmos-sdk/server/cmd"

"github.com/skip-mev/feemarket/tests/simapp"
cmd "github.com/skip-mev/feemarket/tests/simapp/feemarketd/testappd"
)
1 change: 1 addition & 0 deletions tests/simapp/feemarketd/testappd/root.go
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@ import (
"cosmossdk.io/depinject"
"cosmossdk.io/log"
confixcmd "cosmossdk.io/tools/confix/cmd"

"github.com/skip-mev/feemarket/tests/simapp"

"github.com/cosmos/cosmos-sdk/client"
1 change: 1 addition & 0 deletions tests/simapp/feemarketd/testappd/testnet.go
Original file line number Diff line number Diff line change
@@ -33,6 +33,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/genutil"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"

"github.com/skip-mev/feemarket/tests/simapp"
)

0 comments on commit cb4f78b

Please sign in to comment.