From ba50800d3e9ef02657e7e86a2264cd5c6ed8cd4f Mon Sep 17 00:00:00 2001 From: Olexander Hofman Date: Tue, 9 Apr 2024 22:00:15 +0100 Subject: [PATCH] kava v0.25.1; ethermint v0.21.0-kava-v24-0 mamoru-sniffer-go v0.12.1 --- app/app.go | 5 ++++- mamoru_cosmos_sdk/sniffer_test.go | 2 +- mamoru_cosmos_sdk/streaming.go | 15 +++++++-------- mamoru_cosmos_sdk/streaming_test.go | 20 ++++++++++++++------ 4 files changed, 26 insertions(+), 16 deletions(-) diff --git a/app/app.go b/app/app.go index 47e8fb39b8..31a91d6f37 100644 --- a/app/app.go +++ b/app/app.go @@ -956,7 +956,10 @@ func NewApp( app.RegisterUpgradeHandlers() ////////////////////////// MAMORU SNIFFER ////////////////////////// - bApp.SetStreamingService(mamoru_cosmos_sdk.NewStreamingService(logger, mamoru_cosmos_sdk.NewSniffer(logger), app.evmKeeper)) + getTStoreFunc := func(ctx sdk.Context) sdk.KVStore { + return ctx.TransientStore(tkeys[evmtypes.TransientKey]) + } + bApp.SetStreamingService(mamoru_cosmos_sdk.NewStreamingService(logger, mamoru_cosmos_sdk.NewSniffer(logger), getTStoreFunc)) ////////////////////////// MAMORU SNIFFER ////////////////////////// // create the simulation manager and define the order of the modules for deterministic simulations diff --git a/mamoru_cosmos_sdk/sniffer_test.go b/mamoru_cosmos_sdk/sniffer_test.go index 4af9fd0f76..80054cf135 100644 --- a/mamoru_cosmos_sdk/sniffer_test.go +++ b/mamoru_cosmos_sdk/sniffer_test.go @@ -55,7 +55,7 @@ func TestSnifferSmoke(t *testing.T) { } ctx := context.Background() - streamingService := NewStreamingService(logger, sniffer) + streamingService := NewStreamingService(logger, sniffer, nil) regBB := abci.RequestBeginBlock{} resBB := abci.ResponseBeginBlock{} err := streamingService.ListenBeginBlock(ctx, regBB, resBB) diff --git a/mamoru_cosmos_sdk/streaming.go b/mamoru_cosmos_sdk/streaming.go index 88eb96fab0..5d1b5c047e 100644 --- a/mamoru_cosmos_sdk/streaming.go +++ b/mamoru_cosmos_sdk/streaming.go @@ -12,7 +12,6 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/store/types" sdktypes "github.com/cosmos/cosmos-sdk/types" - evmkeeper "github.com/evmos/ethermint/x/evm/keeper" "github.com/evmos/ethermint/x/evm/types/mamoru" abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/libs/bytes" @@ -31,17 +30,17 @@ type StreamingService struct { storeListeners []*types.MemoryListener - sniffer *Sniffer - evmkeeper *evmkeeper.Keeper + sniffer *Sniffer + getTStoreFunc func(ctx sdktypes.Context) types.KVStore } -func NewStreamingService(logger log.Logger, sniffer *Sniffer, evmKeeper *evmkeeper.Keeper) *StreamingService { +func NewStreamingService(logger log.Logger, sniffer *Sniffer, getTStoreFunc func(ctx sdktypes.Context) types.KVStore) *StreamingService { logger.Info("Mamoru StreamingService start") return &StreamingService{ - sniffer: sniffer, - logger: logger, - evmkeeper: evmKeeper, + sniffer: sniffer, + logger: logger, + getTStoreFunc: getTStoreFunc, } } @@ -64,7 +63,7 @@ func (ss *StreamingService) ListenDeliverTx(ctx context.Context, req abci.Reques Response: &res, }) - transientStore := ss.evmkeeper.GetTransientStore(sdktypes.UnwrapSDKContext(ctx)) + transientStore := ss.getTStoreFunc(sdktypes.UnwrapSDKContext(ctx)) takeCallFrames(ss.logger, transientStore, ss.currentBlockNumber, &ss.callFrame) return nil diff --git a/mamoru_cosmos_sdk/streaming_test.go b/mamoru_cosmos_sdk/streaming_test.go index b49a22c5af..86363f9df6 100644 --- a/mamoru_cosmos_sdk/streaming_test.go +++ b/mamoru_cosmos_sdk/streaming_test.go @@ -1,7 +1,7 @@ package mamoru_cosmos_sdk import ( - "context" + sdk "github.com/cosmos/cosmos-sdk/types" "testing" "time" @@ -14,10 +14,19 @@ import ( func TestListenBeginBlock(t *testing.T) { t.Run("TestListenBeginBlock", func(t *testing.T) { + logger := log.TestingLogger() - ss := NewStreamingService(logger.With("module", "mamoru"), nil) + header := tmprototypes.Header{} + ischeck := true + ctx := sdk.NewContext(nil, header, ischeck, logger) + sdkctx := sdk.UnwrapSDKContext(ctx) + + getTStoreFunc := func(ctx sdk.Context) sdk.KVStore { + return sdkctx.TransientStore(sdk.NewKVStoreKey("somekey")) + } + + ss := NewStreamingService(logger.With("module", "mamoru"), nil, getTStoreFunc) - ctx := context.Background() req := tmabci.RequestBeginBlock{Header: tmprototypes.Header{ Version: tmversion.Consensus{}, ChainID: "", @@ -30,9 +39,8 @@ func TestListenBeginBlock(t *testing.T) { NextValidatorsHash: []byte{'a', 'b', 'c'}, ConsensusHash: []byte{'a', 'b', 'c'}, AppHash: []byte{'a', 'b', 'c'}, - LastResultsHash: []byte{'a', 'b', 'c'}, - EvidenceHash: []byte{'a', 'b', 'c'}, - ProposerAddress: []byte{'a', 'b', 'c'}, + LastResultsHash: []byte{'a', 'b', 'c'}, EvidenceHash: []byte{'a', 'b', 'c'}, + ProposerAddress: []byte{'a', 'b', 'c'}, }} res := tmabci.ResponseBeginBlock{}