Skip to content

Commit d85139d

Browse files
committed
Parallel execution
1 parent a0a98b9 commit d85139d

File tree

61 files changed

+498
-733
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+498
-733
lines changed

.mergify.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,12 @@ pull_request_rules:
2828
backport:
2929
branches:
3030
- release/v0.4.x
31+
- name: backport patches to v0.5.x branch
32+
conditions:
33+
- base=main
34+
- label=backport/0.5.x
35+
actions:
36+
backport:
37+
branches:
38+
- release/v0.5.x
39+

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,14 @@
1010

1111
### FEATURES
1212

13+
- [\#589](https://github.com/cosmos/evm/pull/589) Remove parallelization blockers via migration from transient to object store, refactoring of gas, indexing, and bloom utilities.
14+
1315
### BUG FIXES
1416

1517
- [\#748](https://github.com/cosmos/evm/pull/748) Fix DynamicFeeChecker in Cosmos ante handler to respect NoBaseFee feemarkets' parameter.
1618
- [\#756](https://github.com/cosmos/evm/pull/756) Fix error message typo in NewMsgCancelProposal.
1719
- [\#772](https://github.com/cosmos/evm/pull/772) Avoid panic on close if evm mempool not used.
20+
- [\#774](https://github.com/cosmos/evm/pull/774) Emit proper allowance amount in erc20 event.
1821

1922
## v0.5.0
2023

@@ -103,7 +106,6 @@
103106
- [\#577](https://github.com/cosmos/evm/pull/577) Changed the way to create a stateful precompile based on the cmn.Precompile, change `NewPrecompile` to not return error.
104107
- [\#661](https://github.com/cosmos/evm/pull/661) Removes evmAppOptions from the repository and moves initialization to genesis. Chains must now have a display and denom metadata set for the defined EVM denom in the bank module's metadata.
105108

106-
107109
## v0.4.1
108110

109111
### DEPENDENCIES

ante/cosmos.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,5 @@ func newCosmosAnteHandler(ctx sdk.Context, options HandlerOptions) sdk.AnteHandl
4040
ante.NewSigVerificationDecorator(options.AccountKeeper, options.SignModeHandler),
4141
ante.NewIncrementSequenceDecorator(options.AccountKeeper),
4242
ibcante.NewRedundantRelayDecorator(options.IBCKeeper),
43-
evmante.NewGasWantedDecorator(options.EvmKeeper, options.FeeMarketKeeper, &feemarketParams),
4443
)
4544
}

ante/evm/01_setup_ctx.go

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package evm
22

33
import (
4-
anteinterfaces "github.com/cosmos/evm/ante/interfaces"
54
evmante "github.com/cosmos/evm/x/vm/ante"
65

76
errorsmod "cosmossdk.io/errors"
@@ -16,18 +15,10 @@ var _ sdktypes.AnteDecorator = &EthSetupContextDecorator{}
1615

1716
// EthSetupContextDecorator is adapted from SetUpContextDecorator from cosmos-sdk, it ignores gas consumption
1817
// by setting the gas meter to infinite
19-
type EthSetupContextDecorator struct {
20-
evmKeeper anteinterfaces.EVMKeeper
21-
}
22-
23-
func NewEthSetUpContextDecorator(evmKeeper anteinterfaces.EVMKeeper) EthSetupContextDecorator {
24-
return EthSetupContextDecorator{
25-
evmKeeper: evmKeeper,
26-
}
27-
}
18+
type EthSetupContextDecorator struct{}
2819

2920
func (esc EthSetupContextDecorator) AnteHandle(ctx sdktypes.Context, tx sdktypes.Tx, simulate bool, next sdktypes.AnteHandler) (newCtx sdktypes.Context, err error) {
30-
newCtx, err = SetupContextAndResetTransientGas(ctx, tx, esc.evmKeeper)
21+
newCtx, err = SetupContextAndResetTransientGas(ctx, tx)
3122
if err != nil {
3223
return ctx, err
3324
}
@@ -37,7 +28,7 @@ func (esc EthSetupContextDecorator) AnteHandle(ctx sdktypes.Context, tx sdktypes
3728
// SetupContextAndResetTransientGas modifies the context to be used in the
3829
// execution of the ante handler associated with an EVM transaction. Previous
3930
// gas consumed is reset in the transient store.
40-
func SetupContextAndResetTransientGas(ctx sdktypes.Context, tx sdktypes.Tx, evmKeeper anteinterfaces.EVMKeeper) (sdktypes.Context, error) {
31+
func SetupContextAndResetTransientGas(ctx sdktypes.Context, tx sdktypes.Tx) (sdktypes.Context, error) {
4132
// all transactions must implement GasTx
4233
_, ok := tx.(authante.GasTx)
4334
if !ok {
@@ -50,12 +41,5 @@ func SetupContextAndResetTransientGas(ctx sdktypes.Context, tx sdktypes.Tx, evmK
5041
newCtx := evmante.BuildEvmExecutionCtx(ctx).
5142
WithGasMeter(storetypes.NewInfiniteGasMeter())
5243

53-
// Reset transient gas used to prepare the execution of current cosmos tx.
54-
// Transient gas-used is necessary to sum the gas-used of cosmos tx, when it contains multiple eth msgs.
55-
//
56-
// TODO: add more context here to explain why gas used is reset. Not clear
57-
// from docstring.
58-
evmKeeper.ResetTransientGasUsed(ctx)
59-
6044
return newCtx, nil
6145
}

ante/evm/10_gas_wanted.go

Lines changed: 0 additions & 85 deletions
This file was deleted.

ante/evm/11_emit_event.go

Lines changed: 2 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -3,62 +3,23 @@ package evm
33
import (
44
"strconv"
55

6-
anteinterfaces "github.com/cosmos/evm/ante/interfaces"
76
evmtypes "github.com/cosmos/evm/x/vm/types"
87

9-
errorsmod "cosmossdk.io/errors"
10-
118
sdk "github.com/cosmos/cosmos-sdk/types"
12-
errortypes "github.com/cosmos/cosmos-sdk/types/errors"
139
)
1410

15-
// EthEmitEventDecorator emit events in ante handler in case of tx execution failed (out of block gas limit).
16-
type EthEmitEventDecorator struct {
17-
evmKeeper anteinterfaces.EVMKeeper
18-
}
19-
20-
// NewEthEmitEventDecorator creates a new EthEmitEventDecorator
21-
func NewEthEmitEventDecorator(evmKeeper anteinterfaces.EVMKeeper) EthEmitEventDecorator {
22-
return EthEmitEventDecorator{evmKeeper}
23-
}
24-
25-
// AnteHandle emits some basic events for the eth messages
26-
func (eeed EthEmitEventDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) {
27-
// After eth tx passed ante handler, the fee is deducted and nonce increased, it shouldn't be ignored by json-rpc,
28-
// we need to emit some basic events at the very end of ante handler to be indexed by CometBFT.
29-
blockTxIndex := eeed.evmKeeper.GetTxIndexTransient(ctx)
30-
31-
msgs := tx.GetMsgs()
32-
if msgs == nil {
33-
return ctx, errorsmod.Wrap(errortypes.ErrUnknownRequest, "invalid transaction. Transaction without messages")
34-
}
35-
36-
for i, msg := range msgs {
37-
msgEthTx, ok := msg.(*evmtypes.MsgEthereumTx)
38-
if !ok {
39-
return ctx, errorsmod.Wrapf(errortypes.ErrUnknownRequest, "invalid message type %T, expected %T", msg, (*evmtypes.MsgEthereumTx)(nil))
40-
}
41-
42-
txIdx := uint64(i) //nolint:gosec // G115 // won't exceed uint64
43-
EmitTxHashEvent(ctx, msgEthTx, blockTxIndex, txIdx)
44-
}
45-
46-
return next(ctx, tx, simulate)
47-
}
48-
4911
// EmitTxHashEvent emits the Ethereum tx
5012
//
5113
// FIXME: This is Technical debt. Ideally the sdk.Tx hash should be the Ethereum
5214
// tx hash (msg.Hash) instead of using events for indexing Eth txs.
53-
// TxIndex should be included in the header vote extension as part of ABCI++
54-
func EmitTxHashEvent(ctx sdk.Context, msg *evmtypes.MsgEthereumTx, blockTxIndex, msgIndex uint64) {
15+
func EmitTxHashEvent(ctx sdk.Context, msg *evmtypes.MsgEthereumTx, blockTxIndex uint64) {
5516
// emit ethereum tx hash as an event so that it can be indexed by CometBFT for query purposes
5617
// it's emitted in ante handler, so we can query failed transaction (out of block gas limit).
5718
ctx.EventManager().EmitEvent(
5819
sdk.NewEvent(
5920
evmtypes.EventTypeEthereumTx,
6021
sdk.NewAttribute(evmtypes.AttributeKeyEthereumTxHash, msg.Hash().String()),
61-
sdk.NewAttribute(evmtypes.AttributeKeyTxIndex, strconv.FormatUint(blockTxIndex+msgIndex, 10)), // #nosec G115
22+
sdk.NewAttribute(evmtypes.AttributeKeyTxIndex, strconv.FormatUint(blockTxIndex, 10)), // #nosec G115
6223
),
6324
)
6425
}

ante/evm/mono_decorator.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func (md MonoDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, ne
7979
evmDenom := evmtypes.GetEVMCoinDenom()
8080

8181
// 1. setup ctx
82-
ctx, err = SetupContextAndResetTransientGas(ctx, tx, md.evmKeeper)
82+
ctx, err = SetupContextAndResetTransientGas(ctx, tx)
8383
if err != nil {
8484
return ctx, err
8585
}
@@ -265,14 +265,8 @@ func (md MonoDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, ne
265265
return ctx, err
266266
}
267267

268-
// 10. gas wanted
269-
if err := CheckGasWanted(ctx, md.feeMarketKeeper, tx, decUtils.Rules.IsLondon, md.feemarketParams); err != nil {
270-
return ctx, err
271-
}
272-
273-
// 11. emit events
274-
txIdx := uint64(msgIndex) //nolint:gosec // G115
275-
EmitTxHashEvent(ctx, ethMsg, decUtils.BlockTxIndex, txIdx)
268+
// Emit event unconditionally - ctx.TxIndex() will be valid during block execution
269+
EmitTxHashEvent(ctx, ethMsg, uint64(ctx.TxIndex())) // #nosec G115 -- no overlfow here
276270

277271
if err := CheckTxFee(txFeeInfo, decUtils.TxFee, decUtils.TxGasLimit); err != nil {
278272
return ctx, err

ante/evm/mono_decorator_test.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,11 @@ func (k *ExtendedEVMKeeper) SpendableCoin(ctx sdk.Context, addr common.Address)
6262
return uint256.NewInt(0)
6363
}
6464

65-
func (k *ExtendedEVMKeeper) ResetTransientGasUsed(_ sdk.Context) {}
6665
func (k *ExtendedEVMKeeper) GetParams(_ sdk.Context) evmsdktypes.Params {
6766
return evmsdktypes.DefaultParams()
6867
}
6968
func (k *ExtendedEVMKeeper) GetBaseFee(_ sdk.Context) *big.Int { return big.NewInt(0) }
7069
func (k *ExtendedEVMKeeper) GetMinGasPrice(_ sdk.Context) math.LegacyDec { return math.LegacyZeroDec() }
71-
func (k *ExtendedEVMKeeper) GetTxIndexTransient(_ sdk.Context) uint64 { return 0 }
7270

7371
// only methods called by EVMMonoDecorator
7472
type MockFeeMarketKeeper struct{}
@@ -79,9 +77,6 @@ func (m MockFeeMarketKeeper) GetParams(ctx sdk.Context) feemarkettypes.Params {
7977
return param
8078
}
8179

82-
func (m MockFeeMarketKeeper) AddTransientGasWanted(_ sdk.Context, _ uint64) (uint64, error) {
83-
return 0, nil
84-
}
8580
func (m MockFeeMarketKeeper) GetBaseFeeEnabled(_ sdk.Context) bool { return true }
8681
func (m MockFeeMarketKeeper) GetBaseFee(_ sdk.Context) math.LegacyDec { return math.LegacyZeroDec() }
8782

@@ -222,6 +217,12 @@ func TestMonoDecorator(t *testing.T) {
222217
monoDec := evm.NewEVMMonoDecorator(accountKeeper, feeMarketKeeper, keeper, 0, &params, &feemarketParams)
223218
ctx := sdk.NewContext(nil, tmproto.Header{}, false, log.NewNopLogger())
224219
ctx = ctx.WithBlockGasMeter(storetypes.NewGasMeter(1e19))
220+
blockParams := tmproto.BlockParams{
221+
MaxBytes: 200000,
222+
MaxGas: 81500000, // default limit
223+
}
224+
consParams := tmproto.ConsensusParams{Block: &blockParams}
225+
ctx = ctx.WithConsensusParams(consParams)
225226

226227
msgs := tc.buildMsgs(privKey)
227228
tx, err := utiltx.PrepareEthTx(cfg.TxConfig, nil, toMsgSlice(msgs)...)

ante/evm/nonce_limit_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func (m *mockAccountKeeper) GetAccount(ctx context.Context, addr sdk.AccAddress)
3434
}
3535
func (m *mockAccountKeeper) SetAccount(ctx context.Context, account sdk.AccountI) { m.last = account }
3636
func (m *mockAccountKeeper) RemoveAccount(ctx context.Context, account sdk.AccountI) {}
37-
func (m *mockAccountKeeper) GetParams(ctx context.Context) (params authtypes.Params) { return }
37+
func (m *mockAccountKeeper) GetParams(ctx context.Context) (params authtypes.Params) { return params }
3838
func (m *mockAccountKeeper) GetSequence(ctx context.Context, addr sdk.AccAddress) (uint64, error) {
3939
if m.last == nil {
4040
return 0, nil

ante/evm/utils.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ type DecoratorUtils struct {
2626
BaseFee *big.Int
2727
MempoolMinGasPrice sdkmath.LegacyDec
2828
GlobalMinGasPrice sdkmath.LegacyDec
29-
BlockTxIndex uint64
3029
TxGasLimit uint64
3130
GasWanted uint64
3231
MinPriority int64
@@ -73,7 +72,6 @@ func NewMonoDecoratorUtils(
7372
BaseFee: baseFee,
7473
MempoolMinGasPrice: mempoolMinGasPrice,
7574
GlobalMinGasPrice: globalMinGasPrice,
76-
BlockTxIndex: ek.GetTxIndexTransient(ctx),
7775
GasWanted: 0,
7876
MinPriority: int64(math.MaxInt64),
7977
// TxGasLimit and TxFee are set to zero because they are updated

0 commit comments

Comments
 (0)