Skip to content

Commit 48b1ba7

Browse files
committed
cache typed txs
1 parent cf35fd4 commit 48b1ba7

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

app/app.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1602,6 +1602,7 @@ func (app *App) ProcessBlock(ctx sdk.Context, txs [][]byte, req BlockProcessRequ
16021602
evmTxs := make([]*evmtypes.MsgEVMTransaction, len(txs)) // nil for non-EVM txs
16031603
txResults := make([]*abci.ExecTxResult, len(txs))
16041604
typedTxs := app.DecodeTransactionsConcurrently(ctx, txs)
1605+
app.EvmKeeper.SetTypedTxs(req.GetHeight(), typedTxs)
16051606

16061607
prioritizedTxs, otherTxs, prioritizedTypedTxs, otherTypedTxs, prioritizedIndices, otherIndices := app.PartitionPrioritizedTxs(ctx, txs, typedTxs)
16071608

evmrpc/utils.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,17 @@ func filterTransactions(
199199
startOfBlockNonce := make(map[string]uint64)
200200
latestCtx := ctxProvider(LatestCtxHeight)
201201
prevCtx := ctxProvider(block.Block.Height - 1)
202+
typedTxs := k.GetTypedTxs(block.Block.Height)
202203
for i, tx := range block.Block.Data.Txs {
203-
sdkTx, err := txDecoder(tx)
204-
if err != nil {
205-
continue
204+
var sdkTx sdk.Tx
205+
if typedTxs != nil {
206+
sdkTx = typedTxs[i]
207+
} else {
208+
sdkTx_, err := txDecoder(tx)
209+
if err != nil {
210+
continue
211+
}
212+
sdkTx = sdkTx_
206213
}
207214
for _, msg := range sdkTx.GetMsgs() {
208215
switch m := msg.(type) {

x/evm/keeper/keeper.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ type Keeper struct {
8787
customPrecompiles map[common.Address]precompiles.VersionedPrecompiles
8888
latestCustomPrecompiles map[common.Address]vm.PrecompiledContract
8989
latestUpgrade string
90+
91+
typedTxs map[int64][]sdk.Tx
9092
}
9193

9294
type AddressNoncePair struct {
@@ -606,6 +608,17 @@ func (k *Keeper) getReplayBlockCtx(ctx sdk.Context) (*vm.BlockContext, error) {
606608
}, nil
607609
}
608610

611+
func (k *Keeper) SetTypedTxs(height int64, txs []sdk.Tx) {
612+
if _, ok := k.typedTxs[height-1000]; ok {
613+
delete(k.typedTxs, height-1000)
614+
}
615+
k.typedTxs[height] = txs
616+
}
617+
618+
func (k *Keeper) GetTypedTxs(height int64) []sdk.Tx {
619+
return k.typedTxs[height]
620+
}
621+
609622
func uint64Cmp(a, b uint64) int {
610623
if a < b {
611624
return -1

0 commit comments

Comments
 (0)