Skip to content

Commit

Permalink
chore: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ninabarbakadze committed Jan 17, 2024
1 parent 0996fd5 commit b317f19
Show file tree
Hide file tree
Showing 20 changed files with 227 additions and 40 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ on:
- cron: '24 20 * * 4'

env:
GO_VERSION: '1.21.5'
GO_VERSION: '1.21.6'

jobs:
analyze:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/govulncheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
pull_request:

env:
GO_VERSION: '1.21.5'
GO_VERSION: '1.21.6'

jobs:
govulncheck:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on:
workflow_call:

env:
GO_VERSION: '1.21.5'
GO_VERSION: '1.21.6'

jobs:
golangci-lint:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
workflow_dispatch:

env:
GO_VERSION: '1.21.5'
GO_VERSION: '1.21.6'

jobs:
test-e2e:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on:
workflow_call:

env:
GO_VERSION: '1.21.5'
GO_VERSION: '1.21.6'

jobs:
test-short:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ DOCKER_PROTO_BUILDER := docker run -v $(shell pwd):/workspace --workdir /workspa
PROJECTNAME=$(shell basename "$(PWD)")
HTTPS_GIT := https://github.com/celestiaorg/celestia-app.git
PACKAGE_NAME := github.com/celestiaorg/celestia-app
GOLANG_CROSS_VERSION ?= v1.21.5
GOLANG_CROSS_VERSION ?= v1.21.6

# process linker flags
ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=celestia-app \
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ node | | | |

### Source

1. [Install Go](https://go.dev/doc/install) 1.21.5
1. [Install Go](https://go.dev/doc/install) 1.21.6
1. Clone this repo
1. Install the celestia-app CLI

Expand Down
18 changes: 15 additions & 3 deletions app/ante/fee_checker.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package ante

import (
"math"
"fmt"

errors "cosmossdk.io/errors"
"github.com/celestiaorg/celestia-app/pkg/appconsts"
Expand All @@ -26,10 +26,22 @@ func CheckTxFeeWithGlobalMinGasPrices(ctx sdk.Context, tx sdk.Tx) (sdk.Coins, in
fee := feeTx.GetFee().AmountOf(appconsts.BondDenom)
gas := feeTx.GetGas()

minFee := sdk.NewInt(int64(math.Ceil(appconsts.GlobalMinGasPrice * float64(gas))))

// global minimum fee only applies to app versions greater than one
if ctx.BlockHeader().Version.App > v1.Version {
// convert the global minimum gas price to a big.Int
globalMinGasPrice, err := sdk.NewDecFromStr(fmt.Sprintf("%f", appconsts.GlobalMinGasPrice))
if err != nil {
return nil, 0, errors.Wrap(err, "invalid GlobalMinGasPrice")
}

gasInt := sdk.NewIntFromUint64(gas)
minFee := globalMinGasPrice.MulInt(gasInt).TruncateInt()

// if min fee truncates to zero, set it to one
if minFee.LT(sdk.NewInt(appconsts.MinFee)) {
minFee = sdk.NewInt(appconsts.MinFee)
}

if !fee.GTE(minFee) {
return nil, 0, errors.Wrapf(sdkerror.ErrInsufficientFee, "insufficient fees; got: %s required: %s", fee, minFee)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package ante
import (
"testing"

"github.com/celestiaorg/celestia-app/pkg/appconsts"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/assert"
)
Expand All @@ -16,31 +17,31 @@ func TestGetTxPriority(t *testing.T) {
}{
{
name: "1 TIA fee large gas",
fee: sdk.NewCoins(sdk.NewInt64Coin("utia", 1_000_000)),
fee: sdk.NewCoins(sdk.NewInt64Coin(appconsts.BondDenom, 1_000_000)),
gas: 1000000,
expectedPri: 1000000,
},
{
name: "1 utia fee small gas",
fee: sdk.NewCoins(sdk.NewInt64Coin("utia", 1)),
fee: sdk.NewCoins(sdk.NewInt64Coin(appconsts.BondDenom, 1)),
gas: 1,
expectedPri: 1000000,
},
{
name: "2 utia fee small gas",
fee: sdk.NewCoins(sdk.NewInt64Coin("utia", 2)),
fee: sdk.NewCoins(sdk.NewInt64Coin(appconsts.BondDenom, 2)),
gas: 1,
expectedPri: 2000000,
},
{
name: "1_000_000 TIA fee normal gas tx",
fee: sdk.NewCoins(sdk.NewInt64Coin("utia", 1_000_000_000_000)),
fee: sdk.NewCoins(sdk.NewInt64Coin(appconsts.BondDenom, 1_000_000_000_000)),
gas: 75000,
expectedPri: 13333333333333,
},
{
name: "0.001 utia gas price",
fee: sdk.NewCoins(sdk.NewInt64Coin("utia", 1_000)),
fee: sdk.NewCoins(sdk.NewInt64Coin(appconsts.BondDenom, 1_000)),
gas: 1_000_000,
expectedPri: 1000,
},
Expand Down
3 changes: 2 additions & 1 deletion app/ante/gov_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/celestiaorg/celestia-app/app"
"github.com/celestiaorg/celestia-app/app/ante"
"github.com/celestiaorg/celestia-app/app/encoding"
"github.com/celestiaorg/celestia-app/pkg/appconsts"
"github.com/celestiaorg/celestia-app/test/util/testfactory"
"github.com/celestiaorg/celestia-app/test/util/testnode"
"github.com/cosmos/cosmos-sdk/types"
Expand All @@ -18,7 +19,7 @@ func TestGovDecorator(t *testing.T) {
decorator := ante.NewGovProposalDecorator()
anteHandler := types.ChainAnteDecorators(decorator)
accounts := testfactory.GenerateAccounts(1)
coins := types.NewCoins(types.NewCoin("utia", types.NewInt(10)))
coins := types.NewCoins(types.NewCoin(appconsts.BondDenom, types.NewInt(10)))

msgSend := banktypes.NewMsgSend(
testnode.RandomAddress().(types.AccAddress),
Expand Down
44 changes: 38 additions & 6 deletions app/ante/min_fee_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ante_test

import (
"math"
"testing"

"github.com/celestiaorg/celestia-app/app"
Expand Down Expand Up @@ -28,45 +29,76 @@ func TestCheckTxFeeWithGlobalMinGasPrices(t *testing.T) {

feeAmount := int64(1000)

gasLimit := uint64(float64(feeAmount) / appconsts.GlobalMinGasPrice)
builder.SetGasLimit(gasLimit)

ctx := sdk.Context{}

testCases := []struct {
name string
fee sdk.Coins
gasLimit uint64
appVersion uint64
expErr bool
}{
{
name: "bad tx; fee below required minimum",
fee: sdk.NewCoins(sdk.NewInt64Coin(appconsts.BondDenom, feeAmount-1)),
gasLimit: uint64(float64(feeAmount) / appconsts.GlobalMinGasPrice),
appVersion: uint64(2),
expErr: true,
},
{
name: "good tx; fee equal to required minimum",
fee: sdk.NewCoins(sdk.NewInt64Coin(appconsts.BondDenom, feeAmount)),
gasLimit: uint64(float64(feeAmount) / appconsts.GlobalMinGasPrice),
appVersion: uint64(2),
expErr: false,
},
{
name: "good tx; fee above required minimum",
fee: sdk.NewCoins(sdk.NewInt64Coin(appconsts.BondDenom, feeAmount+1)),
gasLimit: uint64(float64(feeAmount) / appconsts.GlobalMinGasPrice),
appVersion: uint64(2),
expErr: false,
},
{
name: "good tx; fee equal to required minimum",
name: "good tx; with no fee (v1)",
fee: sdk.NewCoins(sdk.NewInt64Coin(appconsts.BondDenom, feeAmount)),
gasLimit: uint64(float64(feeAmount) / appconsts.GlobalMinGasPrice),
appVersion: uint64(1),
expErr: false,
},
{
name: "good tx; gas limit and fee are maximum values",
fee: sdk.NewCoins(sdk.NewInt64Coin(appconsts.BondDenom, math.MaxInt64)),
gasLimit: math.MaxUint64,
appVersion: uint64(2),
expErr: false,
},
{
name: "good tx; with no fee (v1)",
name: "bad tx; gas limit and fee are 0",
fee: sdk.NewCoins(sdk.NewInt64Coin(appconsts.BondDenom, 0)),
appVersion: uint64(1),
gasLimit: 0,
appVersion: uint64(2),
expErr: true,
},
{
name: "good tx; rounds down to 0 gets reset to 1",
fee: sdk.NewCoins(sdk.NewInt64Coin(appconsts.BondDenom, feeAmount)),
gasLimit: 400,
appVersion: uint64(2),
expErr: false,
},
{
name: "good tx; fee is 1",
fee: sdk.NewCoins(sdk.NewInt64Coin(appconsts.BondDenom, 1)),
gasLimit: uint64(float64(1) / appconsts.GlobalMinGasPrice),
appVersion: uint64(2),
expErr: false,
},
}

for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
builder.SetGasLimit(tc.gasLimit)
builder.SetFeeAmount(tc.fee)
tx := builder.GetTx()

Expand Down
13 changes: 9 additions & 4 deletions app/process_proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"time"

"github.com/celestiaorg/celestia-app/app/ante"
v1 "github.com/celestiaorg/celestia-app/pkg/appconsts/v1"
"github.com/celestiaorg/celestia-app/pkg/blob"
"github.com/celestiaorg/celestia-app/pkg/da"
"github.com/celestiaorg/celestia-app/pkg/shares"
Expand Down Expand Up @@ -58,10 +59,14 @@ func (app *App) ProcessProposal(req abci.RequestProcessProposal) (resp abci.Resp

sdkTx, err := app.txConfig.TxDecoder()(tx)
if err != nil {
// we don't reject the block here because it is not a block validity
// rule that all transactions included in the block data are
// decodable
continue
if req.Header.Version.App == v1.Version {
// For appVersion 1, there was no block validity rule that all
// transactions must be decodable.
continue
}
// An error here means that a tx was included in the block that is not decodable.
logInvalidPropBlock(app.Logger(), req.Header, fmt.Sprintf("tx %d is not decodable", idx))
return reject()
}

// handle non-blob transactions first
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/celestiaorg/celestia-app

go 1.21.5
go 1.21.6

require (
cosmossdk.io/errors v1.0.1
Expand All @@ -13,7 +13,7 @@ require (
github.com/cosmos/cosmos-sdk v0.46.14
github.com/cosmos/gogoproto v1.4.11
github.com/cosmos/ibc-go/v6 v6.2.1
github.com/ethereum/go-ethereum v1.13.8
github.com/ethereum/go-ethereum v1.13.10
github.com/gogo/protobuf v1.3.3
github.com/golang/protobuf v1.5.3
github.com/gorilla/mux v1.8.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -513,8 +513,8 @@ github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7
github.com/ethereum/c-kzg-4844 v0.4.0 h1:3MS1s4JtA868KpJxroZoepdV0ZKBp3u/O5HcZ7R3nlY=
github.com/ethereum/c-kzg-4844 v0.4.0/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0=
github.com/ethereum/go-ethereum v1.10.17/go.mod h1:Lt5WzjM07XlXc95YzrhosmR4J9Ahd6X2wyEV2SvGhk0=
github.com/ethereum/go-ethereum v1.13.8 h1:1od+thJel3tM52ZUNQwvpYOeRHlbkVFZ5S8fhi0Lgsg=
github.com/ethereum/go-ethereum v1.13.8/go.mod h1:sc48XYQxCzH3fG9BcrXCOOgQk2JfZzNAmIKnceogzsA=
github.com/ethereum/go-ethereum v1.13.10 h1:Ppdil79nN+Vc+mXfge0AuUgmKWuVv4eMqzoIVSdqZek=
github.com/ethereum/go-ethereum v1.13.10/go.mod h1:sc48XYQxCzH3fG9BcrXCOOgQk2JfZzNAmIKnceogzsA=
github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c h1:8ISkoahWXwZR41ois5lSJBSVw4D0OV19Ht/JSTzvSv0=
github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c/go.mod h1:Yg+htXGokKKdzcwhuNDwVvN+uBxDGXJ7G/VN1d8fa64=
github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 h1:JWuenKqqX8nojtoVVWjGfOF9635RETekkoH6Cc9SX0A=
Expand Down
2 changes: 1 addition & 1 deletion go.work
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
go 1.21.5
go 1.21.6

use (
.
Expand Down
Loading

0 comments on commit b317f19

Please sign in to comment.