CI Setup (#19)

This commit is contained in:
Aleksandr Bezobchuk 2023-03-14 10:23:27 -04:00 committed by GitHub
parent 1c96a6c3c2
commit 0d475f632d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 176 additions and 40 deletions

17
.github/dependabot.yml vendored Normal file
View File

@ -0,0 +1,17 @@
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
version: 2
updates:
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: daily
- package-ecosystem: gomod
directory: "/"
schedule:
interval: daily
labels:
- "A:automerge"
- dependencies

25
.github/workflows/lint.yml vendored Normal file
View File

@ -0,0 +1,25 @@
name: Lint
on:
push:
branches:
- main
- release/**
pull_request:
permissions:
contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option.
# pull-requests: read
jobs:
golangci:
name: golangci-lint
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.20.2
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: latest

35
.github/workflows/test.yml vendored Normal file
View File

@ -0,0 +1,35 @@
name: Tests / Code Coverage
on:
pull_request:
push:
branches:
- main
permissions:
contents: read
concurrency:
group: ci-${{ github.ref }}-tests
cancel-in-progress: true
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.20.2
cache: true
cache-dependency-path: go.sum
- uses: technote-space/get-diff-action@v6.1.2
id: git_diff
with:
PATTERNS: |
**/*.go
go.mod
go.sum
- name: tests
if: env.GIT_DIFF
run: |
make test

59
.golangci.yml Normal file
View File

@ -0,0 +1,59 @@
run:
tests: true
timeout: 10m
sort-results: true
allow-parallel-runners: true
concurrency: 4
linters:
disable-all: true
enable:
- depguard
- dogsled
- exportloopref
- goconst
- gocritic
- gofumpt
- gosec
- gosimple
- govet
- ineffassign
- misspell
- nakedret
- nolintlint
- staticcheck
- revive
- stylecheck
- typecheck
- unconvert
- unused
issues:
exclude-rules:
- text: "Use of weak random number generator"
linters:
- gosec
# - text: "ST1003:"
# linters:
# - stylecheck
# - text: "ST1016:"
# linters:
# - stylecheck
# - text: "leading space"
# linters:
# - nolintlint
max-issues-per-linter: 10000
max-same-issues: 10000
linters-settings:
dogsled:
max-blank-identifiers: 3
maligned:
# print struct with more effective memory layout or not, false by default
suggest-new: true
nolintlint:
allow-unused: false
allow-leading-space: true
require-explanation: false
require-specific: false

View File

@ -10,6 +10,15 @@ PROJECT_NAME = $(shell git remote get-url origin | xargs basename -s .git)
HTTPS_GIT := https://github.com/skip-mev/pob.git
DOCKER := $(shell which docker)
###############################################################################
### Tests ###
###############################################################################
test:
@go test -v ./...
.PHONY: test
###############################################################################
### Protobuf ###
###############################################################################

View File

@ -48,7 +48,7 @@ func (h *ProposalHandler) PrepareProposalHandler() sdk.PrepareProposalHandler {
totalTxBytes int64
)
bidTxMap := make(map[string]struct{})
bidTxMap := make(map[string]struct{}) //nolint
bidTxIterator := h.mempool.AuctionBidSelect(ctx)
// Attempt to select the highest bid transaction that is valid and whose

View File

@ -99,15 +99,15 @@ func (k Keeper) ValidateAuctionBundle(ctx sdk.Context, bidder sdk.AccAddress, tr
// as long as all subsequent transactions are signed by the bidder.
if len(prevSigners) == 0 {
if seenBidder {
return fmt.Errorf("bundle contains transactions signed by multiple parties. possible front-running or sandwich attack.")
} else {
seenBidder = true
prevSigners = map[string]bool{bidder.String(): true}
filterSigners(prevSigners, txSigners)
return fmt.Errorf("bundle contains transactions signed by multiple parties; possible front-running or sandwich attack")
}
if len(prevSigners) == 0 {
return fmt.Errorf("bundle contains transactions signed by multiple parties. possible front-running or sandwich attack.")
}
seenBidder = true
prevSigners = map[string]bool{bidder.String(): true}
filterSigners(prevSigners, txSigners)
if len(prevSigners) == 0 {
return fmt.Errorf("bundle contains transactions signed by multiple parties; possible front-running or sandwich attack")
}
}
}

View File

@ -16,15 +16,15 @@ import (
func (suite *IntegrationTestSuite) TestValidateAuctionMsg() {
var (
// Tx building variables
accounts []Account = []Account{} // tracks the order of signers in the bundle
balance sdk.Coins = sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(10000)))
bid sdk.Coins = sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(1000)))
accounts = []Account{} // tracks the order of signers in the bundle
balance = sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(10000)))
bid = sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(1000)))
// Auction params
maxBundleSize uint32 = 10
reserveFee sdk.Coins = sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(1000)))
minBuyInFee sdk.Coins = sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(1000)))
escrowAddress sdk.AccAddress = sdk.AccAddress([]byte("escrow"))
maxBundleSize uint32 = 10
reserveFee = sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(1000)))
minBuyInFee = sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(1000)))
escrowAddress = sdk.AccAddress([]byte("escrow"))
)
rnd := rand.New(rand.NewSource(time.Now().Unix()))
@ -160,11 +160,9 @@ func (suite *IntegrationTestSuite) TestValidateAuctionMsg() {
}
func (suite *IntegrationTestSuite) TestValidateBundle() {
var (
// TODO: Update this to be multi-dimensional to test multi-sig
// https://github.com/skip-mev/pob/issues/14
accounts []Account // tracks the order of signers in the bundle
)
// TODO: Update this to be multi-dimensional to test multi-sig
// https://github.com/skip-mev/pob/issues/14
var accounts []Account // tracks the order of signers in the bundle
rng := rand.New(rand.NewSource(time.Now().Unix()))
bidder := RandomAccounts(rng, 1)[0]

View File

@ -7,9 +7,7 @@ import (
"github.com/skip-mev/pob/x/auction/types"
)
var (
_ types.QueryServer = QueryServer{}
)
var _ types.QueryServer = QueryServer{}
// QueryServer defines the auction module's gRPC querier service.
type QueryServer struct {

View File

@ -8,9 +8,7 @@ import (
"github.com/skip-mev/pob/x/auction/types"
)
var (
_ types.MsgServer = MsgServer{}
)
var _ types.MsgServer = MsgServer{}
// MsgServer is the wrapper for the auction module's msg service.
type MsgServer struct {

View File

@ -129,9 +129,10 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw
func (AppModule) ConsensusVersion() uint64 { return ConsensusVersion }
// BeginBlock returns the begin blocker for the auction module.
func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {}
func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} //nolint
// EndBlock returns the end blocker for the auction module. It returns no validator updates.
func (am AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate {
func (am AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { //nolint
return []abci.ValidatorUpdate{}
}

View File

@ -18,7 +18,5 @@ const (
prefixParams = iota + 1
)
var (
// KeyPrefixParams is the store key for the auction module's parameters.
KeyParams = []byte{prefixParams}
)
// KeyParams is the store key for the auction module's parameters.
var KeyParams = []byte{prefixParams}

View File

@ -72,7 +72,6 @@ func TestMsgAuctionBid(t *testing.T) {
for _, tc := range cases {
t.Run(tc.description, func(t *testing.T) {
err := tc.msg.ValidateBasic()
if tc.expectPass {
if err != nil {
@ -115,7 +114,6 @@ func TestMsgUpdateParams(t *testing.T) {
for _, tc := range cases {
t.Run(tc.description, func(t *testing.T) {
err := tc.msg.ValidateBasic()
if tc.expectPass {
if err != nil {

View File

@ -10,11 +10,11 @@ var (
// TODO: Choose reasonable default values.
//
// Ref: https://github.com/skip-mev/pob/issues/7
DefaultMaxBundleSize uint32 = 0
DefaultEscrowAccountAddress = ""
DefaultReserveFee = sdk.Coins{}
DefaultMinBuyInFee = sdk.Coins{}
DefaultMinBidIncrement = sdk.Coins{}
DefaultMaxBundleSize uint32
DefaultEscrowAccountAddress string
DefaultReserveFee = sdk.Coins{}
DefaultMinBuyInFee = sdk.Coins{}
DefaultMinBidIncrement = sdk.Coins{}
)
// NewParams returns a new Params instance with the provided values.