Skip to content

Commit

Permalink
Merge branch 'main' into feat/fix_estimateXX
Browse files Browse the repository at this point in the history
  • Loading branch information
joldie777 committed Jun 18, 2024
2 parents d236ce9 + 51f9cb6 commit c494684
Show file tree
Hide file tree
Showing 149 changed files with 26,467 additions and 20,108 deletions.
85 changes: 85 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: CI

on:
push:
branches:
- "main"
- "releases/v3.x"
- "chore/fix-ci"
pull_request:
branches:
- "main"
- "releases/v3.x"
- "chore/fix-ci"

jobs:
docker:
runs-on: self-hosted
env:
DOCKER_BUILDKIT: 1

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y jq curl git

- name: Install Go
run: |
GO_VERSION=1.22.4
curl -LO https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go${GO_VERSION}.linux-amd64.tar.gz
echo "export PATH=$PATH:/usr/local/go/bin" >> $HOME/.profile
source $HOME/.profile
shell: bash

- name: Download Buildx with Hydrobuilder support
run: |
ARCH=amd64
BUILDX_URL=$(curl -s https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/buildx-lab-releases.json | jq -r ".latest.assets[] | select(endswith(\"linux-$ARCH\"))")
mkdir -vp ~/.docker/cli-plugins/
curl --silent -L --output ~/.docker/cli-plugins/docker-buildx $BUILDX_URL
chmod a+x ~/.docker/cli-plugins/docker-buildx
- name: Get version from git tags
id: get_version
run: echo "VERSION=v$(git describe --tags --abbrev=0 | sed 's/^v//')" >> $GITHUB_ENV

- name: Log in to Docker Hub
run: echo "${{ secrets.DOCKERHUB_TOKEN }}" | docker login --username ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
with:
version: "lab:latest"
driver: cloud
endpoint: "neutronorg/neutron"
install: true

# - name: Build and push
# uses: docker/build-push-action@v5
# with:
# context: .
# file: Dockerfile.builder
# tags: "${{ env.VERSION }}"
# # For pull requests, export results to the build cache.
# # Otherwise, push to a registry.
# outputs: ${{ github.event_name == 'pull_request' && 'type=cacheonly' || 'type=registry,push=true' }}

- name: Build and push Docker image
env:
VERSION: ${{ env.VERSION }}
BUILDER: ${{ steps.buildx.outputs.name }}
run: |
docker buildx use $BUILDER
make build-static-linux-amd64
docker tag neutron-amd64:latest neutronorg/neutron:${{ env.VERSION }}
docker push neutronorg/neutron:${{ env.VERSION }}
- name: Cleanup temporary container
run: docker rm -f neutronbinary || true

2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ permissions:
jobs:
golangci:
name: lint
runs-on: ubuntu-latest
runs-on: self-hosted
steps:
- uses: actions/setup-go@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on: [push, pull_request]
jobs:
tests:
name: Test
runs-on: ubuntu-latest
runs-on: self-hosted
steps:
- name: Set up Go 1.22
uses: actions/setup-go@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_trigger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:
jobs:
dispatch:
name: Dispatch Tests Workflow
runs-on: ubuntu-latest
runs-on: self-hosted
steps:
- name: Evaluate PR Merged Status and Labels
run: |
Expand Down
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ build-static-linux-amd64: go.sum $(BUILDDIR)/
$(DOCKER) cp neutronbinary:/bin/neutrond $(BUILDDIR)/neutrond-linux-amd64
$(DOCKER) rm -f neutronbinary

build-slinky-e2e-docker-image: go.sum $(BUILDDIR)/
build-e2e-docker-image: go.sum $(BUILDDIR)/
$(DOCKER) buildx create --name neutronbuilder || true
$(DOCKER) buildx use neutronbuilder
$(DOCKER) buildx build \
Expand All @@ -136,7 +136,12 @@ build-slinky-e2e-docker-image: go.sum $(BUILDDIR)/
-f Dockerfile.builder .

slinky-e2e-test:
cd ./tests/slinky && go mod tidy && go test -v -race -timeout 20m ./...
@echo "Running e2e slinky tests..."
cd ./tests/slinky && go mod tidy && go test -v -race -timeout 30m -count=1 ./...

feemarket-e2e-test:
@echo "Running e2e feemarket tests..."
@cd ./tests/feemarket && go mod tidy && go test -p 1 -v -race -timeout 30m -count=1 ./...

install-test-binary: check_version go.sum
go install -mod=readonly $(BUILD_FLAGS_TEST_BINARY) ./cmd/neutrond
Expand Down
53 changes: 35 additions & 18 deletions app/ante_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/auth/ante"

ibcante "github.com/cosmos/ibc-go/v8/modules/core/ante"
ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper"
consumerante "github.com/cosmos/interchain-security/v5/app/consumer/ante"
ibcconsumerkeeper "github.com/cosmos/interchain-security/v5/x/ccv/consumer/keeper"
auctionante "github.com/skip-mev/block-sdk/v2/x/auction/ante"
auctionkeeper "github.com/skip-mev/block-sdk/v2/x/auction/keeper"
feemarketante "github.com/skip-mev/feemarket/x/feemarket/ante"

globalfeeante "github.com/neutron-org/neutron/v4/x/globalfee/ante"
globalfeekeeper "github.com/neutron-org/neutron/v4/x/globalfee/keeper"
Expand All @@ -26,16 +24,13 @@ import (
type HandlerOptions struct {
ante.HandlerOptions

AccountKeeper feemarketante.AccountKeeper
IBCKeeper *ibckeeper.Keeper
ConsumerKeeper ibcconsumerkeeper.Keeper
GlobalFeeKeeper globalfeekeeper.Keeper
WasmConfig *wasmTypes.WasmConfig
TXCounterStoreService corestoretypes.KVStoreService

// dependencies for the x/auction ante-handler
AuctionKeeper auctionkeeper.Keeper
TxEncoder sdk.TxEncoder
MEVLane auctionante.MEVLane
FeeMarketKeeper feemarketante.FeeMarketKeeper
}

func NewAnteHandler(options HandlerOptions, logger log.Logger) (sdk.AnteHandler, error) {
Expand All @@ -55,8 +50,8 @@ func NewAnteHandler(options HandlerOptions, logger log.Logger) (sdk.AnteHandler,
return nil, errors.Wrap(sdkerrors.ErrLogic, "tx counter store service is required for ante builder")
}

if options.MEVLane == nil {
return nil, errors.Wrap(sdkerrors.ErrLogic, "mev lane is required for AnteHandler")
if options.FeeMarketKeeper == nil {
return nil, errors.Wrap(sdkerrors.ErrLogic, "feemarket keeper is required for ante builder")
}

sigGasConsumer := options.SigGasConsumer
Expand All @@ -74,21 +69,17 @@ func NewAnteHandler(options HandlerOptions, logger log.Logger) (sdk.AnteHandler,
ante.NewTxTimeoutHeightDecorator(),
ante.NewValidateMemoDecorator(options.AccountKeeper),
ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper),
globalfeeante.NewFeeDecorator(options.GlobalFeeKeeper),

ante.NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, options.TxFeeChecker),
feemarketante.NewFeeMarketCheckDecorator(
options.FeeMarketKeeper,
NewFeeDecoratorWithSwitch(options),
),
// SetPubKeyDecorator must be called before all signature verification decorators
ante.NewSetPubKeyDecorator(options.AccountKeeper),
ante.NewValidateSigCountDecorator(options.AccountKeeper),
ante.NewSigGasConsumeDecorator(options.AccountKeeper, sigGasConsumer),
ante.NewSigVerificationDecorator(options.AccountKeeper, options.SignModeHandler),
ante.NewIncrementSequenceDecorator(options.AccountKeeper),
ibcante.NewRedundantRelayDecorator(options.IBCKeeper),
auctionante.NewAuctionDecorator(
options.AuctionKeeper,
options.TxEncoder,
options.MEVLane,
),
}

// Don't delete it even if IDE tells you so.
Expand All @@ -101,3 +92,29 @@ func NewAnteHandler(options HandlerOptions, logger log.Logger) (sdk.AnteHandler,

return sdk.ChainAnteDecorators(anteDecorators...), nil
}

// FeeDecoratorWithSwitch is a fee ante decorator which switches between globalfee ante handler
// and feemarket's one, depending on the `params.Enabled` field feemarket's module.
// If feemarket is enabled, we don't need to perform checks for min gas prices, since they are handled by feemarket
// so we switch the execution directly to feemarket ante handler
// If feemarket is disabled, we call globalfee + native cosmos fee ante handler where min gas prices will be checked
// via globalfee and then they will be deducted via native cosmos fee ante handler.
type FeeDecoratorWithSwitch struct {
globalfeeDecorator globalfeeante.FeeDecorator
cosmosFeeDecorator ante.DeductFeeDecorator
}

func NewFeeDecoratorWithSwitch(options HandlerOptions) FeeDecoratorWithSwitch {
return FeeDecoratorWithSwitch{
globalfeeDecorator: globalfeeante.NewFeeDecorator(options.GlobalFeeKeeper),
cosmosFeeDecorator: ante.NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, options.TxFeeChecker),
}
}

func (d FeeDecoratorWithSwitch) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) {
// If feemarket is disabled, we call globalfee + native cosmos fee ante handler where min gas prices will be checked
// via globalfee and then they will be deducted via native cosmos fee ante handler.
return d.globalfeeDecorator.AnteHandle(ctx, tx, simulate, func(ctx sdk.Context, tx sdk.Tx, simulate bool) (sdk.Context, error) {
return d.cosmosFeeDecorator.AnteHandle(ctx, tx, simulate, next)
})
}
Loading

0 comments on commit c494684

Please sign in to comment.