Skip to content

Commit

Permalink
kava v0.25.1; ethermint v0.21.0-kava-v24-0
Browse files Browse the repository at this point in the history
mamoru-sniffer-go v0.12.1
  • Loading branch information
gofmanaa committed Apr 9, 2024
1 parent 5b17c92 commit ba50800
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 16 deletions.
5 changes: 4 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion mamoru_cosmos_sdk/sniffer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
15 changes: 7 additions & 8 deletions mamoru_cosmos_sdk/streaming.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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,
}
}

Expand All @@ -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
Expand Down
20 changes: 14 additions & 6 deletions mamoru_cosmos_sdk/streaming_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package mamoru_cosmos_sdk

import (
"context"
sdk "github.com/cosmos/cosmos-sdk/types"
"testing"
"time"

Expand All @@ -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: "",
Expand All @@ -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{}

Expand Down

0 comments on commit ba50800

Please sign in to comment.