Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Apply b-harvest/cosmos-sdk #27

Merged
merged 10 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/ante/handler_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ func (options HandlerOptions) validate() error {
return nil
}

func NewEthAnteHandler(options HandlerOptions) sdk.AnteHandler {
return newEthAnteHandler(options)
}

func newEthAnteHandler(options HandlerOptions) sdk.AnteHandler {
return func(ctx sdk.Context, tx sdk.Tx, simulate bool) (sdk.Context, error) {
blockCfg, err := options.EvmKeeper.EVMBlockConfig(ctx, options.EvmKeeper.ChainID())
Expand Down
14 changes: 14 additions & 0 deletions app/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ import (

const MinimalParallelPreEstimate = 16

var (
TESTMODE = false

TxExecuteCounter []atomic.Int32
)

func DefaultTxExecutor(_ context.Context,
txs [][]byte,
ms storetypes.MultiStore,
Expand Down Expand Up @@ -86,6 +92,10 @@ func STMTxExecutor(
memTxs, estimates = preEstimates(txs, workers, authStore, bankStore, evmDenom, txDecoder)
}

if TESTMODE {
TxExecuteCounter = make([]atomic.Int32, blockSize)
}

if err := blockstm.ExecuteBlockWithEstimates(
ctx,
blockSize,
Expand All @@ -96,6 +106,10 @@ func STMTxExecutor(
func(txn blockstm.TxnIndex, ms blockstm.MultiStore) {
var cache map[string]any

if TESTMODE {
TxExecuteCounter[txn].Add(1)
}

// only one of the concurrent incarnations gets the cache if there are any, otherwise execute without
// cache, concurrent incarnations should be rare.
v := incarnationCache[txn].Swap(nil)
Expand Down
9 changes: 4 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -244,17 +244,16 @@ require (
)

replace (
// release/v0.50.x
cosmossdk.io/store => github.com/crypto-org-chain/cosmos-sdk/store v0.0.0-20240930015419-f4ea363b3fdf
cosmossdk.io/x/tx => github.com/crypto-org-chain/cosmos-sdk/x/tx v0.0.0-20240930015419-f4ea363b3fdf
github.com/cosmos/cosmos-sdk => github.com/crypto-org-chain/cosmos-sdk v0.50.6-0.20240930015419-f4ea363b3fdf
cosmossdk.io/store => github.com/b-harvest/cosmos-sdk/store v0.0.0-20241030161953-9e8e56b00f17
cosmossdk.io/x/tx => github.com/b-harvest/cosmos-sdk/x/tx v0.0.0-20241103053257-79f3f75686a0
github.com/cosmos/cosmos-sdk => github.com/b-harvest/cosmos-sdk v0.0.0-20241030055507-b84851e4379f
github.com/ethereum/go-ethereum => github.com/b-harvest/go-ethereum v0.0.0-20241106045451-23c79ab53226
)

replace (
// use cosmos keyring
github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0
// release/v1.11.x
github.com/ethereum/go-ethereum => github.com/crypto-org-chain/go-ethereum v1.10.20-0.20240926023215-d2275b4afb9a
// Fix upstream GHSA-h395-qcrw-5vmq vulnerability.
// TODO Remove it: https://github.com/cosmos/cosmos-sdk/issues/10409
github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.7.0
Expand Down
16 changes: 8 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,14 @@ github.com/aws/aws-sdk-go v1.44.122/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX
github.com/aws/aws-sdk-go v1.44.224 h1:09CiaaF35nRmxrzWZ2uRq5v6Ghg/d2RiPjZnSgtt+RQ=
github.com/aws/aws-sdk-go v1.44.224/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI=
github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g=
github.com/b-harvest/cosmos-sdk v0.0.0-20241030055507-b84851e4379f h1:Y/kLwnoGpQV6S++JCEi91d/yvFNgRsRy2ClmWaDUR34=
github.com/b-harvest/cosmos-sdk v0.0.0-20241030055507-b84851e4379f/go.mod h1:swzHMI2C9wU0c5WPyPS/ihryqQmvHukx0/RWS6u8WAY=
github.com/b-harvest/cosmos-sdk/store v0.0.0-20241030161953-9e8e56b00f17 h1:JHnbr52bO0MlDMgdZS/J53d1VPAUYllWscCfzXn1a/I=
github.com/b-harvest/cosmos-sdk/store v0.0.0-20241030161953-9e8e56b00f17/go.mod h1:oZfW/4Fc/zYqu3JmQcQdUJ3fqu5vnYTn3LZFFy8P8ng=
github.com/b-harvest/cosmos-sdk/x/tx v0.0.0-20241103053257-79f3f75686a0 h1:rv/Dq2G2+l+66SLaqZH+fFtx41Om2/qd7Jusie/9xIY=
github.com/b-harvest/cosmos-sdk/x/tx v0.0.0-20241103053257-79f3f75686a0/go.mod h1:V6DImnwJMTq5qFjeGWpXNiT/fjgE4HtmclRmTqRVM3w=
github.com/b-harvest/go-ethereum v0.0.0-20241106045451-23c79ab53226 h1:TUw0xOKTEKSqWPmCcFO8Gci49mvxHKWJ8NwERwD1o5I=
github.com/b-harvest/go-ethereum v0.0.0-20241106045451-23c79ab53226/go.mod h1:A249HEl6XyiV5zSnKM9j9RF3szMghMNONMyNvYuqQIw=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
Expand Down Expand Up @@ -412,16 +420,8 @@ github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7Do
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/crypto-org-chain/btree v0.0.0-20240406140148-2687063b042c h1:MOgfS4+FBB8cMkDE2j2VBVsbY+HCkPIu0YsJ/9bbGeQ=
github.com/crypto-org-chain/btree v0.0.0-20240406140148-2687063b042c/go.mod h1:twD9XRA5jj9VUQGELzDO4HPQTNJsoWWfYEL+EUQ2cKY=
github.com/crypto-org-chain/cosmos-sdk v0.50.6-0.20240930015419-f4ea363b3fdf h1:QNQ9uB3DEfJqSMwERDSaYQMofgfzfcSp49iDt7B2jvc=
github.com/crypto-org-chain/cosmos-sdk v0.50.6-0.20240930015419-f4ea363b3fdf/go.mod h1:iJLknPnyzlcQGdgfIp9d8QCuqt8g1RjJeh8pJ/p5wj4=
github.com/crypto-org-chain/cosmos-sdk/store v0.0.0-20240930015419-f4ea363b3fdf h1:vGFA8f1EbNLgabbSBBnT1bArLnrl4ETk4PUTJLb01Pc=
github.com/crypto-org-chain/cosmos-sdk/store v0.0.0-20240930015419-f4ea363b3fdf/go.mod h1:8DwVTz83/2PSI366FERGbWSH7hL6sB7HbYp8bqksNwM=
github.com/crypto-org-chain/cosmos-sdk/x/tx v0.0.0-20240930015419-f4ea363b3fdf h1:u6BY+dtlmhuQYfPDnpGhDBF2uiCA0HvrIk22L67nB6Q=
github.com/crypto-org-chain/cosmos-sdk/x/tx v0.0.0-20240930015419-f4ea363b3fdf/go.mod h1:V6DImnwJMTq5qFjeGWpXNiT/fjgE4HtmclRmTqRVM3w=
github.com/crypto-org-chain/go-block-stm v0.0.0-20240919080136-6c49aef68716 h1:OvD5Rm0B6LHUJk6z858UgwdP72jU2DuUdXeclRyKpDI=
github.com/crypto-org-chain/go-block-stm v0.0.0-20240919080136-6c49aef68716/go.mod h1:iwQTX9xMX8NV9k3o2BiWXA0SswpsZrDk5q3gA7nWYiE=
github.com/crypto-org-chain/go-ethereum v1.10.20-0.20240926023215-d2275b4afb9a h1:IUPD+dg1YQl8cLocxQ/Mbx/ObTgAgcrZlcBhFjsLO40=
github.com/crypto-org-chain/go-ethereum v1.10.20-0.20240926023215-d2275b4afb9a/go.mod h1:A249HEl6XyiV5zSnKM9j9RF3szMghMNONMyNvYuqQIw=
github.com/danieljoos/wincred v1.2.0 h1:ozqKHaLK0W/ii4KVbbvluM91W2H3Sh0BncbUNPS7jLE=
github.com/danieljoos/wincred v1.2.0/go.mod h1:FzQLLMKBFdvu+osBrnFODiv32YGwCfx0SkRa/eYHgec=
github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down
19 changes: 18 additions & 1 deletion types/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,36 @@
// along with the Ethermint library. If not, see https://github.com/evmos/ethermint/blob/main/LICENSE
package types

import sdk "github.com/cosmos/cosmos-sdk/types"
import (
math "math"

sdk "github.com/cosmos/cosmos-sdk/types"
)

// BlockGasLimit returns the max gas (limit) defined in the block gas meter. If the meter is not
// set, it returns the max gas from the application consensus params.
// NOTE: see https://github.com/cosmos/cosmos-sdk/issues/9514 for full reference
func BlockGasLimit(ctx sdk.Context) uint64 {
blockGasMeter := ctx.BlockGasMeter()

// Get the limit from the gas meter only if its not null and not an InfiniteGasMeter
if blockGasMeter != nil && blockGasMeter.Limit() != 0 {
return blockGasMeter.Limit()
}

// Otherwise get from the consensus parameters
cp := ctx.ConsensusParams()
if cp.Block == nil {
return 0
}

maxGas := cp.Block.MaxGas

// Setting maxGas to -1 means that block gas is unlimited
if maxGas == -1 {
return math.MaxUint64
}

if maxGas > 0 {
return uint64(maxGas)
}
Expand Down
Loading