Skip to content

Commit

Permalink
Merge pull request #1055 from maticnetwork/v0.3.5-candidate
Browse files Browse the repository at this point in the history
V0.3.5 candidate
  • Loading branch information
VAIBHAVJINDAL3012 authored Sep 12, 2023
2 parents 01b33bb + 31e520c commit 8e5a165
Show file tree
Hide file tree
Showing 71 changed files with 396 additions and 308 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.19.x
go-version: 1.20.x

- name: "Build binaries"
run: make build
Expand All @@ -35,7 +35,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.19.x
go-version: 1.20.x

- name: "Run linter"
run: make lint
Expand All @@ -49,7 +49,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.19.x
go-version: 1.20.x

- name: "Run tests"
run: make tests
Expand All @@ -73,7 +73,7 @@ jobs:

- uses: actions/setup-go@v3
with:
go-version: 1.19.x
go-version: 1.20.x

- name: Checkout matic-cli
uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/packager.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@master
with:
go-version: 1.19
go-version: 1.20.x
- name: Adding TAG to ENV
run: echo "GIT_TAG=`echo $(git describe --tags --abbrev=0)`" >> $GITHUB_ENV

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@master
with:
go-version: 1.19.x
go-version: 1.20.x

- name: Prepare
id: prepare
Expand Down
44 changes: 1 addition & 43 deletions .github/workflows/security-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,6 @@ name: Security CI
on: [push, pull_request]

jobs:
snyk:
name: Snyk and Publish
runs-on: ubuntu-latest
steps:
- name: Checkout Source
uses: actions/checkout@master
- name: Run Snyk to check for vulnerabilities
uses: snyk/actions/golang@master
continue-on-error: true
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
GOFLAGS: "-buildvcs=false"
with:
args: --org=${{ secrets.SNYK_ORG }} --severity-threshold=medium --sarif-file-output=snyk.sarif
- name: Upload result to GitHub Code Scanning
uses: github/codeql-action/upload-sarif@v2
continue-on-error: true
with:
sarif_file: snyk.sarif

snyk-code:
name: Snyk Code and Publish
runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: Checkout Source
uses: actions/checkout@master
- name: Run Snyk SAST to check for code vulnerabilities
uses: snyk/actions/golang@master
continue-on-error: true
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
args: --org=${{ secrets.SNYK_ORG }} --sarif-file-output=snyk.sarif
command: code test
- name: Upload result to GitHub Code Scanning
uses: github/codeql-action/upload-sarif@v2
continue-on-error: true
with:
sarif_file: snyk.sarif

govuln:
name: Run govuln check and Publish
runs-on: ubuntu-latest
Expand All @@ -54,8 +13,7 @@ jobs:
env:
DEBUG: "true"
with:
go-version: 1.19
vulncheck-version: latest
go-version: 1.20.5
package: ./...
github-token: ${{ secrets.GITHUB_TOKEN }}
fail-on-vuln: true
Expand Down
32 changes: 0 additions & 32 deletions .github/workflows/security-sonarqube-ci.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This file configures github.com/golangci/golangci-lint.

run:
go: '1.19'
go: '1.20'
timeout: 20m
tests: true
# default is true. Enables skipping of directories:
Expand Down
5 changes: 0 additions & 5 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,6 @@ nfpms:
scripts:
postinstall: builder/files/heimdall-post-install.sh

overrides:
rpm:
replacements:
amd64: x86_64

snapshot:
name_template: "{{ .Tag }}.next"

Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ build-arm: clean
LINT_COMMAND := $(shell command -v golangci-lint 2> /dev/null)
lint:
ifndef LINT_COMMAND
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.45.2
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.53.3
endif
golangci-lint run --config ./.golangci.yml

Expand All @@ -82,7 +82,7 @@ build-docker-develop:
.PHONY: contracts build

PACKAGE_NAME := github.com/maticnetwork/heimdall
GOLANG_CROSS_VERSION ?= v1.19.1
GOLANG_CROSS_VERSION ?= v1.20.5

.PHONY: release-dry-run
release-dry-run:
Expand Down
2 changes: 1 addition & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ func (app *HeimdallApp) InitChainer(ctx sdk.Context, req abci.RequestInitChain)
}

// TODO make sure old validtors dont go in validator updates ie deactivated validators have to be removed
// udpate validators
// update validators
return abci.ResponseInitChain{
// validator updates
Validators: valUpdates,
Expand Down
4 changes: 2 additions & 2 deletions app/params/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ Package params defines the simulation parameters in the simapp.
It contains the default weights used for each transaction used on the module's
simulation. These weights define the chance for a transaction to be simulated at
any gived operation.
any given operation.
You can repace the default values for the weights by providing a params.json
You can replace the default values for the weights by providing a params.json
file with the weights defined for each of the transaction operations:
{
Expand Down
2 changes: 1 addition & 1 deletion app/side_tx_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ func (app *HeimdallApp) runMsgs(ctx sdk.Context, msgs []sdk.Msg, sideTxResult ab

// cacheTxContext returns a new context based off of the provided context with
// a cache wrapped multi-store.
func (app *HeimdallApp) cacheTxContext(ctx sdk.Context, txBytes []byte) (sdk.Context, sdk.CacheMultiStore) {
func (app *HeimdallApp) cacheTxContext(ctx sdk.Context, _ []byte) (sdk.Context, sdk.CacheMultiStore) {
ms := ctx.MultiStore()
msCache := ms.CacheMultiStore()

Expand Down
2 changes: 1 addition & 1 deletion app/side_tx_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ func (suite *SideTxProcessorTestSuite) TestBeginSideBlocker() {
// try to set random state data to store
happ.SidechannelKeeper.SetTx(ctx, 900, testTxStateData1)

panic("Paniced in handler")
panic("Panicked in handler")
},
}
router.AddRoute(routeMsgSideCounter, handler)
Expand Down
6 changes: 3 additions & 3 deletions app/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package app
import (
"encoding/json"
"io"
"io/ioutil"
"math/rand"
"os"
"time"

"github.com/cosmos/cosmos-sdk/codec"
Expand Down Expand Up @@ -51,7 +51,7 @@ func AppStateFn(cdc *codec.Codec, simManager *module.SimulationManager) simtypes
case config.ParamsFile != "":
appParams := make(simtypes.AppParams)

bz, err := ioutil.ReadFile(config.ParamsFile)
bz, err := os.ReadFile(config.ParamsFile)
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -115,7 +115,7 @@ func AppStateRandomizedFn(

// AppStateFromGenesisFileFn util function to generate the genesis AppState from a genesis.json file.
func AppStateFromGenesisFileFn(r io.Reader, cdc *codec.Codec, genesisFile string) (tmtypes.GenesisDoc, []simtypes.Account) {
bytes, err := ioutil.ReadFile(genesisFile)
bytes, err := os.ReadFile(genesisFile)
if err != nil {
panic(err)
}
Expand Down
2 changes: 1 addition & 1 deletion app/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type App interface {
// Exports the state of the application for a genesis file.
ExportAppStateAndValidators() (json.RawMessage, []tmTypes.GenesisValidator, error)

// All the registered module account addreses.
// All the registered module account addresses.
ModuleAccountAddrs() map[string]bool

// Helper for the simulation framework.
Expand Down
10 changes: 5 additions & 5 deletions app/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package app

import (
"fmt"
"io/ioutil"
"os"

"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down Expand Up @@ -33,7 +33,7 @@ func SetupSimulation(dirPrefix, dbName string) (simTypes.Config, dbm.DB, string,
lggr = log.NewNopLogger()
}

dir, err := ioutil.TempDir("", dirPrefix)
dir, err := os.MkdirTemp("", dirPrefix)
if err != nil {
return simTypes.Config{}, nil, "", nil, false, err
}
Expand All @@ -55,7 +55,7 @@ func SimulationOperations(app App, cdc *codec.Codec, config simTypes.Config) []s
}

if config.ParamsFile != "" {
bz, err := ioutil.ReadFile(config.ParamsFile)
bz, err := os.ReadFile(config.ParamsFile)
if err != nil {
panic(err)
}
Expand All @@ -80,7 +80,7 @@ func CheckExportSimulation(app App, config simTypes.Config, params simTypes.Para
return err
}

if err = ioutil.WriteFile(config.ExportStatePath, appState, 0644); err != nil { //nolint
if err = os.WriteFile(config.ExportStatePath, appState, 0644); err != nil { //nolint
return err
}
}
Expand All @@ -93,7 +93,7 @@ func CheckExportSimulation(app App, config simTypes.Config, params simTypes.Para
return err
}

if err = ioutil.WriteFile(config.ExportParamsPath, paramsBz, 0644); err != nil { //nolint
if err = os.WriteFile(config.ExportParamsPath, paramsBz, 0644); err != nil { //nolint
return err
}
}
Expand Down
20 changes: 17 additions & 3 deletions auth/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func NewAnteHandler(
stdSigs := stdTx.GetSignatures()

// check signature, return account with incremented nonce
signBytes := GetSignBytes(newCtx.ChainID(), stdTx, signerAcc, isGenesis)
signBytes := GetSignBytes(ctx, newCtx.ChainID(), stdTx, signerAcc, isGenesis)

signerAcc, res = processSig(newCtx, signerAcc, stdSigs[0], signBytes, simulate, params, sigGasConsumer)
if !res.IsOK() {
Expand Down Expand Up @@ -313,11 +313,25 @@ func SetGasMeter(simulate bool, ctx sdk.Context, gasLimit uint64) sdk.Context {

// GetSignBytes returns a slice of bytes to sign over for a given transaction
// and an account.
func GetSignBytes(chainID string, stdTx authTypes.StdTx, acc authTypes.Account, genesis bool) []byte {
func GetSignBytes(ctx sdk.Context, chainID string, stdTx authTypes.StdTx, acc authTypes.Account, genesis bool) []byte {
var accNum uint64
if !genesis {
accNum = acc.GetAccountNumber()
}

return authTypes.StdSignBytes(chainID, accNum, acc.GetSequence(), stdTx.Msg, stdTx.Memo)
signBytes := authTypes.StdSignBytes(chainID, accNum, acc.GetSequence(), stdTx.Msg, stdTx.Memo)

if ctx.BlockHeight() > helper.GetNewHexToStringAlgoHeight() {
return signBytes
}

const newData = ",\"data\":\"0x\","

const oldData = ",\"data\":\"0x0\","

if bytes.Contains(signBytes, []byte(newData)) {
signBytes = bytes.Replace(signBytes, []byte(newData), []byte(oldData), 1)
}

return signBytes
}
4 changes: 3 additions & 1 deletion auth/ante_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ func (suite *AnteTestSuite) TestFees() {
//

// run the tx through the anteHandler and ensure its valid
// nolint: unparam
func checkValidTx(t *testing.T, anteHandler sdk.AnteHandler, ctx sdk.Context, tx sdk.Tx, simulate bool) (sdk.Context, sdk.Result, bool) {
t.Helper()

Expand All @@ -420,6 +421,7 @@ func checkValidTx(t *testing.T, anteHandler sdk.AnteHandler, ctx sdk.Context, tx
}

// run the tx through the anteHandler and ensure it fails with the given code
// nolint: unparam
func checkInvalidTx(t *testing.T, anteHandler sdk.AnteHandler, ctx sdk.Context, tx sdk.Tx, simulate bool, code sdk.CodeType) (sdk.Context, sdk.Result, bool) {
t.Helper()

Expand All @@ -433,7 +435,7 @@ func checkInvalidTx(t *testing.T, anteHandler sdk.AnteHandler, ctx sdk.Context,
_, ok := tx.(types.StdTx)
require.True(t, ok, "tx must be in form auth.types.StdTx")
// GasWanted set correctly
require.True(t, result.GasUsed > result.GasWanted, "GasUsed not greated than GasWanted")
require.True(t, result.GasUsed > result.GasWanted, "GasUsed not greater than GasWanted")
// Check that context is set correctly
require.Equal(t, result.GasUsed, newCtx.GasMeter().GasConsumed(), "Context not updated correctly")
}
Expand Down
1 change: 1 addition & 0 deletions auth/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
//

// returns context and app with params set on account keeper
// nolint: unparam
func createTestApp(isCheckTx bool) (*app.HeimdallApp, sdk.Context) {
app := app.Setup(isCheckTx)
ctx := app.BaseApp.NewContext(isCheckTx, abci.Header{})
Expand Down
2 changes: 1 addition & 1 deletion auth/querier.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func NewQuerier(keeper AccountKeeper) sdk.Querier {
}
}

func queryParams(ctx sdk.Context, req abci.RequestQuery, keeper AccountKeeper) ([]byte, sdk.Error) {
func queryParams(ctx sdk.Context, _ abci.RequestQuery, keeper AccountKeeper) ([]byte, sdk.Error) {
bz, err := jsoniter.ConfigFastest.Marshal(keeper.GetParams(ctx))
if err != nil {
return nil, sdk.ErrInternal(sdk.AppendMsgToErr("could not marshal result to JSON", err.Error()))
Expand Down
Loading

0 comments on commit 8e5a165

Please sign in to comment.