Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ccv msg filter build tag #287

Merged
merged 3 commits into from
Jul 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ FROM golang:1.20-bullseye
RUN apt-get update && apt-get install -y jq
EXPOSE 26656 26657 1317 9090
COPY --from=app . /opt/neutron
RUN cd /opt/neutron && make install
RUN cd /opt/neutron && make install-test-binary
WORKDIR /opt/neutron

HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 CMD \
Expand Down
19 changes: 10 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,14 @@ endif
build_tags += $(BUILD_TAGS)
build_tags := $(strip $(build_tags))

build_tags_test_binary = $(build_tags)
build_tags_test_binary += skip_ccv_msg_filter

whitespace :=
empty = $(whitespace) $(whitespace)
comma := ,
build_tags_comma_sep := $(subst $(empty),$(comma),$(build_tags))
build_tags_test_binary_comma_sep := $(subst $(empty),$(comma),$(build_tags_test_binary))

# process linker flags

Expand All @@ -73,6 +77,7 @@ ldflags += $(LDFLAGS)
ldflags := $(strip $(ldflags))

BUILD_FLAGS := -tags "$(build_tags_comma_sep)" -ldflags '$(ldflags)' -trimpath
BUILD_FLAGS_TEST_BINARY := -tags "$(build_tags_test_binary_comma_sep)" -ldflags '$(ldflags)' -trimpath

# The below include contains the tools and runsim targets.
include contrib/devtools/Makefile
Expand Down Expand Up @@ -113,6 +118,9 @@ build-static-linux-amd64: go.sum $(BUILDDIR)/
install: check_version go.sum
go install -mod=readonly $(BUILD_FLAGS) ./cmd/neutrond

install-test-binary: check_version go.sum
go install -mod=readonly $(BUILD_FLAGS_TEST_BINARY) ./cmd/neutrond

########################################
### Tools & dependencies

Expand Down Expand Up @@ -194,7 +202,7 @@ proto-format:
test test-all test-build test-cover test-unit test-race \
test-sim-import-export \

init: kill-dev install
init: kill-dev install-test-binary
@echo "Building gaiad binary..."
@cd ./../gaia/ && make install
@echo "Initializing both blockchains..."
Expand All @@ -203,14 +211,7 @@ init: kill-dev install
./network/hermes/restore-keys.sh
./network/hermes/create-conn.sh

init-golang-rly: kill-dev install
@echo "Initializing both blockchains..."
./network/init.sh
./network/start.sh
@echo "Initializing relayer..."
./network/relayer/interchain-acc-config/rly.sh

start: kill-dev install
start: kill-dev install-test-binary
@echo "Starting up neutrond alone..."
BINARY=neutrond CHAINID=test-1 P2PPORT=26656 RPCPORT=26657 RESTPORT=1317 ROSETTA=8080 GRPCPORT=8090 GRPCWEB=8091 STAKEDENOM=untrn \
./network/init.sh && ./network/init-neutrond.sh && ./network/start.sh
Expand Down
12 changes: 10 additions & 2 deletions app/ante_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
ibckeeper "github.com/cosmos/ibc-go/v4/modules/core/keeper"
consumerante "github.com/cosmos/interchain-security/app/consumer/ante"
ibcconsumerkeeper "github.com/cosmos/interchain-security/x/ccv/consumer/keeper"
"github.com/tendermint/tendermint/libs/log"
)

// HandlerOptions extend the SDK's AnteHandler options by requiring the IBC
Expand All @@ -23,7 +24,7 @@ type HandlerOptions struct {
TXCounterStoreKey sdk.StoreKey
}

func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
func NewAnteHandler(options HandlerOptions, logger log.Logger) (sdk.AnteHandler, error) {
if options.AccountKeeper == nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "account keeper is required for AnteHandler")
}
Expand All @@ -50,7 +51,6 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
wasmkeeper.NewLimitSimulationGasDecorator(options.WasmConfig.SimulationGasLimit), // after setup context to enforce limits early
wasmkeeper.NewCountTXDecorator(options.TXCounterStoreKey),
ante.NewRejectExtensionOptionsDecorator(),
consumerante.NewMsgFilterDecorator(options.ConsumerKeeper),
consumerante.NewDisabledModulesDecorator("/cosmos.evidence", "/cosmos.slashing"),
ante.NewMempoolFeeDecorator(),
ante.NewValidateBasicDecorator(),
Expand All @@ -67,5 +67,13 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
ibcante.NewAnteDecorator(options.IBCKeeper),
}

// Don't delete it even if IDE tells you so.
// This constant depends on build tag.
if !SkipCcvMsgFilter {
anteDecorators = append(anteDecorators, consumerante.NewMsgFilterDecorator(options.ConsumerKeeper))
} else {
logger.Error("WARNING: BUILT WITH skip_ccv_msg_filter. THIS IS NOT A PRODUCTION BUILD")
}

return sdk.ChainAnteDecorators(anteDecorators...), nil
}
1 change: 1 addition & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,7 @@ func New(
TXCounterStoreKey: keys[wasm.StoreKey],
ConsumerKeeper: app.ConsumerKeeper,
},
app.Logger(),
)
if err != nil {
panic(err)
Expand Down
5 changes: 5 additions & 0 deletions app/ccv_msg_filter_add.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//go:build !skip_ccv_msg_filter

package app

const SkipCcvMsgFilter = false
5 changes: 5 additions & 0 deletions app/ccv_msg_filter_skip.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//go:build skip_ccv_msg_filter

package app

const SkipCcvMsgFilter = true