Skip to content

Commit

Permalink
Merge pull request #59 from Fairblock/audit-fixes-2
Browse files Browse the repository at this point in the history
Merge audit-fixes-2 to main
  • Loading branch information
p0p3yee authored Sep 28, 2023
2 parents d67b99b + e72d1b2 commit c3daf93
Show file tree
Hide file tree
Showing 192 changed files with 23,276 additions and 5,192 deletions.
23 changes: 21 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ endif
PACKAGES_SIMTEST=$(shell go list ./... | grep '/simulation')
LEDGER_ENABLED ?= true
SDK_PACK := $(shell go list -m github.com/cosmos/cosmos-sdk | sed 's/ /\@/g')
TM_VERSION := $(shell go list -m github.com/tendermint/tendermint | sed 's:.* ::') # grab everything after the space in "github.com/tendermint/tendermint v0.34.7"
TM_VERSION := $(shell go list -m github.com/cometbft/cometbft | sed 's:.* ::') # grab everything after the space in "github.com/cometbft/cometbft v0.37.2"
DOCKER := $(shell which docker)
BUILDDIR ?= $(CURDIR)/build

Expand Down Expand Up @@ -68,7 +68,7 @@ ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=fairyring \
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \
-X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags_comma_sep)" \
-X github.com/tendermint/tendermint/version.TMCoreSemVer=$(TM_VERSION)
-X github.com/cometbft/cometbft/version.TMCoreSemVer=$(TM_VERSION)

ifeq (cleveldb,$(findstring cleveldb,$(FR_BUILD_OPTIONS)))
ldflags += -X github.com/cosmos/cosmos-sdk/types.DBBackend=cleveldb
Expand Down Expand Up @@ -170,13 +170,27 @@ sync-docs:
### Integration Tests ###
###############################################################################

clear-pipes:
@echo "Clearing named pipes..."; \
rm /tmp/testfairyringsubmit_tx*; \
rm /tmp/testfairyringnormaltx*;

test-block-tx-limit: init-test-block-limit-framework \
test-tx-limit
-@rm -rf ./data
-@killall fairyringd 2>/dev/null

integration-test-all: init-test-framework \
init-relayer \
test-keyshare-module \
test-pep-module
-@rm -rf ./data
-@killall fairyringd 2>/dev/null

test-tx-limit:
@echo "Testing Block tx limit..."
./scripts/tests/blockTxLimit.sh

test-keyshare-module:
@echo "Testing KeyShare module..."
./scripts/tests/keyshare.sh
Expand All @@ -190,6 +204,11 @@ init-relayer:
./scripts/tests/relayer.sh
@sleep 2

init-test-block-limit-framework: clean-testing-data install
@echo "Initializing fairyring..."
./scripts/tests/start_test_block_tx_limit.sh
@sleep 3

init-test-framework: clean-testing-data install
@echo "Initializing fairyring..."
./scripts/tests/start.sh
Expand Down
61 changes: 61 additions & 0 deletions app/ante.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package app

import (
"fairyring/blockbuster"
pepante "fairyring/x/pep/ante"
pepkeeper "fairyring/x/pep/keeper"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
)

type FairyringHandlerOptions struct {
BaseOptions ante.HandlerOptions
Mempool blockbuster.Mempool
KeyShareLane pepante.KeyShareLane
TxDecoder sdk.TxDecoder
TxEncoder sdk.TxEncoder
PepKeeper pepkeeper.Keeper
}

// NewFairyringAnteHandler wraps all of the default Cosmos SDK AnteDecorators with the Fairyring AnteHandler.
func NewFairyringAnteHandler(options FairyringHandlerOptions) sdk.AnteHandler {
if options.BaseOptions.AccountKeeper == nil {
panic("account keeper is required for ante builder")
}

if options.BaseOptions.BankKeeper == nil {
panic("bank keeper is required for ante builder")
}

if options.BaseOptions.SignModeHandler == nil {
panic("sign mode handler is required for ante builder")
}

if options.BaseOptions.FeegrantKeeper == nil {
panic("fee grant keeper is required for ante builder")
}

anteDecorators := []sdk.AnteDecorator{
ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first
ante.NewExtensionOptionsDecorator(options.BaseOptions.ExtensionOptionChecker),
ante.NewValidateBasicDecorator(),
ante.NewTxTimeoutHeightDecorator(),
ante.NewValidateMemoDecorator(options.BaseOptions.AccountKeeper),
ante.NewConsumeGasForTxSizeDecorator(options.BaseOptions.AccountKeeper),
ante.NewDeductFeeDecorator(
options.BaseOptions.AccountKeeper,
options.BaseOptions.BankKeeper,
options.BaseOptions.FeegrantKeeper,
options.BaseOptions.TxFeeChecker,
),
ante.NewSetPubKeyDecorator(options.BaseOptions.AccountKeeper), // SetPubKeyDecorator must be called before all signature verification decorators
ante.NewValidateSigCountDecorator(options.BaseOptions.AccountKeeper),
ante.NewSigGasConsumeDecorator(options.BaseOptions.AccountKeeper, options.BaseOptions.SigGasConsumer),
ante.NewSigVerificationDecorator(options.BaseOptions.AccountKeeper, options.BaseOptions.SignModeHandler),
ante.NewIncrementSequenceDecorator(options.BaseOptions.AccountKeeper),
pepante.NewPepDecorator(options.PepKeeper, options.TxEncoder, options.KeyShareLane, options.Mempool),
}

return sdk.ChainAnteDecorators(anteDecorators...)
}
Loading

0 comments on commit c3daf93

Please sign in to comment.