Skip to content

Commit

Permalink
test: Add tx execute counter for stm tx executor
Browse files Browse the repository at this point in the history
  • Loading branch information
dudong2 committed Nov 3, 2024
1 parent 808f0a8 commit 8fc109a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ require (

replace (
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-20241030095706-9a094eafbb87
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-20241030045232-36fbb2cddc00
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,8 @@ github.com/b-harvest/cosmos-sdk v0.0.0-20241030055507-b84851e4379f h1:Y/kLwnoGpQ
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-20241030095706-9a094eafbb87 h1:VVrRHM7NoGQ1/lGmM/c/rv0adf1uFayPu7VbFW0HcuY=
github.com/b-harvest/cosmos-sdk/x/tx v0.0.0-20241030095706-9a094eafbb87/go.mod h1:V6DImnwJMTq5qFjeGWpXNiT/fjgE4HtmclRmTqRVM3w=
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-20241030045232-36fbb2cddc00 h1:7s2WNRLlFqLkgeOv7QI78MqpOapk5GVQTN2QgOOPr3s=
github.com/b-harvest/go-ethereum v0.0.0-20241030045232-36fbb2cddc00/go.mod h1:uGFqiVeidhYHnAoU1koPGoWI5bVKbVeYH7WjbkIC+Mo=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
Expand Down

0 comments on commit 8fc109a

Please sign in to comment.