From 8fc109a741b5091bf14447a73c777039b5da4330 Mon Sep 17 00:00:00 2001 From: dudong2 Date: Mon, 4 Nov 2024 04:11:08 +0900 Subject: [PATCH] test: Add tx execute counter for stm tx executor --- app/executor.go | 14 ++++++++++++++ go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/app/executor.go b/app/executor.go index 1cff225d61..1241dbe567 100644 --- a/app/executor.go +++ b/app/executor.go @@ -24,6 +24,12 @@ import ( const MinimalParallelPreEstimate = 16 +var ( + TESTMODE = false + + TxExecuteCounter []atomic.Int32 +) + func DefaultTxExecutor(_ context.Context, txs [][]byte, ms storetypes.MultiStore, @@ -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, @@ -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) diff --git a/go.mod b/go.mod index cb5d1c4a1b..3533eccda5 100644 --- a/go.mod +++ b/go.mod @@ -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 ) diff --git a/go.sum b/go.sum index 94ba57e042..e9f97c661f 100644 --- a/go.sum +++ b/go.sum @@ -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=