Skip to content

Commit

Permalink
Merge pull request #7 from InjectiveLabs/firehose
Browse files Browse the repository at this point in the history
Firehose
  • Loading branch information
arrivets authored Oct 23, 2024
2 parents 6173e61 + ffcfd44 commit dd4800f
Show file tree
Hide file tree
Showing 30 changed files with 7,820 additions and 186 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,6 @@ contracts/@openzeppelin/*
# direnv
/.envrc
/.direnv

# env file
.env
54 changes: 49 additions & 5 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ import (
"github.com/cosmos/ibc-go/modules/capability"
capabilitykeeper "github.com/cosmos/ibc-go/modules/capability/keeper"
capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types"

"github.com/cosmos/ibc-go/v8/modules/apps/transfer"
ibctransferkeeper "github.com/cosmos/ibc-go/v8/modules/apps/transfer/keeper"
ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
Expand All @@ -126,7 +125,6 @@ import (
ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported"
ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper"
ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint"

"github.com/evmos/ethermint/client/docs"

"github.com/evmos/ethermint/app/ante"
Expand All @@ -138,6 +136,7 @@ import (
"github.com/evmos/ethermint/x/evm"
evmkeeper "github.com/evmos/ethermint/x/evm/keeper"
v0evmtypes "github.com/evmos/ethermint/x/evm/migrations/v0/types"
evmtracing "github.com/evmos/ethermint/x/evm/tracing"
evmtypes "github.com/evmos/ethermint/x/evm/types"
"github.com/evmos/ethermint/x/feemarket"
feemarketkeeper "github.com/evmos/ethermint/x/feemarket/keeper"
Expand All @@ -150,6 +149,7 @@ import (
// Force-load the tracer engines to trigger registration due to Go-Ethereum v1.10.15 changes
_ "github.com/ethereum/go-ethereum/eth/tracers/js"
_ "github.com/ethereum/go-ethereum/eth/tracers/native"
ethparams "github.com/ethereum/go-ethereum/params"
)

func init() {
Expand Down Expand Up @@ -250,6 +250,8 @@ type EthermintApp struct {

// the configurator
configurator module.Configurator

evmTracer *evmtracing.Hooks
}

// NewEthermintApp returns a reference to a new initialized Ethermint application.
Expand Down Expand Up @@ -480,8 +482,6 @@ func NewEthermintApp(
authAddr,
)

tracer := cast.ToString(appOpts.Get(srvflags.EVMTracer))

// Create Ethermint keepers
feeMarketSs := app.GetSubspace(feemarkettypes.ModuleName)
app.FeeMarketKeeper = feemarketkeeper.NewKeeper(
Expand All @@ -497,7 +497,6 @@ func NewEthermintApp(
appCodec,
keys[evmtypes.StoreKey], okeys[evmtypes.ObjectStoreKey], authtypes.NewModuleAddress(govtypes.ModuleName),
app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.FeeMarketKeeper,
tracer,
evmSs,
nil,
)
Expand Down Expand Up @@ -799,6 +798,27 @@ func NewEthermintApp(
app.ScopedIBCKeeper = scopedIBCKeeper
app.ScopedTransferKeeper = scopedTransferKeeper

tracer := cast.ToString(appOpts.Get(srvflags.EVMTracer))

// Currently only the firehose live tracer is supported
if tracer == "firehose" {
liveTracer, err := evmtypes.NewFirehoseCosmosLiveTracer()
if err != nil {
panic(err)
}
app.EvmKeeper.SetTracer(liveTracer)
app.evmTracer = liveTracer
} else if tracer == "access_list" {
panic("access_list tracer is not supported")
} else if tracer != "" {
liveTracer := evmtypes.NewTracer(tracer, nil, ethparams.Rules{})
t := &evmtracing.Hooks{
Hooks: liveTracer.Hooks,
}
app.EvmKeeper.SetTracer(t)
app.evmTracer = t
}

return app
}

Expand Down Expand Up @@ -846,6 +866,13 @@ func (app *EthermintApp) setPostHandler() {
app.SetPostHandler(postHandler)
}

func (app *EthermintApp) initializeEVM(ctx sdk.Context) {
if app.EvmKeeper != nil && app.EvmKeeper.ChainID() == nil {
app.EvmKeeper.WithChainID(ctx)
app.EvmKeeper.InitChainer(ctx)
}
}

// Name returns the name of the App
func (app *EthermintApp) Name() string { return app.BaseApp.Name() }

Expand All @@ -856,11 +883,21 @@ func (app *EthermintApp) PreBlocker(ctx sdk.Context, _ *abci.RequestFinalizeBloc

// BeginBlocker updates every begin block
func (app *EthermintApp) BeginBlocker(ctx sdk.Context) (sdk.BeginBlock, error) {
if app.evmTracer != nil {
ctx = evmtracing.SetTracingHooks(ctx, app.evmTracer)
}

app.initializeEVM(ctx)

return app.ModuleManager.BeginBlock(ctx)
}

// EndBlocker updates every end block
func (app *EthermintApp) EndBlocker(ctx sdk.Context) (sdk.EndBlock, error) {
if app.evmTracer != nil {
ctx = evmtracing.SetTracingHooks(ctx, app.evmTracer)
}

return app.ModuleManager.EndBlock(ctx)
}

Expand All @@ -877,6 +914,13 @@ func (app *EthermintApp) InitChainer(ctx sdk.Context, req *abci.RequestInitChain
if err := app.UpgradeKeeper.SetModuleVersionMap(ctx, app.ModuleManager.GetVersionMap()); err != nil {
return nil, err
}

if app.evmTracer != nil {
ctx = evmtracing.SetTracingHooks(ctx, app.evmTracer)
}

app.initializeEVM(ctx)

return app.ModuleManager.InitGenesis(ctx, app.appCodec, genesisState)
}

Expand Down
31 changes: 16 additions & 15 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ toolchain go1.22.5
require (
cosmossdk.io/api v0.7.5
cosmossdk.io/client/v2 v2.0.0-beta.1
cosmossdk.io/core v0.11.0
cosmossdk.io/core v0.11.1
cosmossdk.io/errors v1.0.1
cosmossdk.io/log v1.3.1
cosmossdk.io/math v1.3.0
cosmossdk.io/store v1.1.0
cosmossdk.io/tools/confix v0.1.1
cosmossdk.io/x/evidence v0.1.0
cosmossdk.io/x/feegrant v0.1.0
cosmossdk.io/x/tx v0.13.3
cosmossdk.io/x/tx v0.13.4
cosmossdk.io/x/upgrade v0.1.1
github.com/btcsuite/btcd v0.24.2
github.com/btcsuite/btcd/btcutil v1.1.5
github.com/cometbft/cometbft v0.38.9
github.com/cometbft/cometbft v0.38.10
github.com/cosmos/cosmos-db v1.0.2
github.com/cosmos/cosmos-proto v1.0.0-beta.5
github.com/cosmos/cosmos-sdk v0.50.6
Expand Down Expand Up @@ -50,9 +50,10 @@ require (
github.com/tidwall/gjson v1.17.1
github.com/tidwall/sjson v1.2.5
github.com/tyler-smith/go-bip39 v1.1.0
golang.org/x/net v0.27.0
golang.org/x/sync v0.7.0
golang.org/x/text v0.16.0
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8
golang.org/x/net v0.29.0
golang.org/x/sync v0.8.0
golang.org/x/text v0.18.0
google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157
google.golang.org/grpc v1.65.0
google.golang.org/protobuf v1.34.2
Expand All @@ -65,7 +66,7 @@ require (
cloud.google.com/go/iam v1.1.6 // indirect
cloud.google.com/go/storage v1.38.0 // indirect
cosmossdk.io/collections v0.4.0 // indirect
cosmossdk.io/depinject v1.0.0-alpha.4 // indirect
cosmossdk.io/depinject v1.0.0 // indirect
filippo.io/edwards25519 v1.1.0 // indirect
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
github.com/99designs/keyring v1.2.2 // indirect
Expand Down Expand Up @@ -206,7 +207,7 @@ require (
github.com/oklog/run v1.1.0 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/outcaste-io/ristretto v0.2.3 // indirect
github.com/pelletier/go-toml/v2 v2.1.1 // indirect
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
github.com/petermattis/goid v0.0.0-20231207134359-e60b3f734c67 // indirect
github.com/philhofer/fwd v1.1.2 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
Expand Down Expand Up @@ -249,17 +250,16 @@ require (
go.opentelemetry.io/otel/trace v1.24.0 // indirect
go.uber.org/atomic v1.11.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.25.0 // indirect
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect
golang.org/x/crypto v0.27.0 // indirect
golang.org/x/oauth2 v0.20.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/term v0.22.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/term v0.24.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.22.0 // indirect
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect
google.golang.org/api v0.169.0 // indirect
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240709173604-40e1e62336c5 // indirect
gopkg.in/DataDog/dd-trace-go.v1 v1.62.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
Expand All @@ -275,7 +275,8 @@ replace (
cosmossdk.io/store => github.com/InjectiveLabs/cosmos-sdk/store v0.0.0-20240904140803-b4127ecb5410
cosmossdk.io/x/tx => github.com/InjectiveLabs/cosmos-sdk/x/tx v0.0.0-20240904140803-b4127ecb5410

github.com/cometbft/cometbft => github.com/InjectiveLabs/cometbft v0.38.11-inj-2
github.com/cosmos/cosmos-sdk => github.com/InjectiveLabs/cosmos-sdk v0.50.9-0.20240904140803-b4127ecb5410
github.com/cometbft/cometbft => github.com/Injectivelabs/cometbft v0.38.11-inj-5
github.com/cosmos/cosmos-sdk => github.com/InjectiveLabs/cosmos-sdk v0.50.10-0.20241014111010-224eb95c9eb1
github.com/ethereum/go-ethereum => github.com/InjectiveLabs/go-ethereum v1.9.22-0.20240923100242-5e28e23d353e
nhooyr.io/websocket => github.com/coder/websocket v1.8.10 // replaced as instructed here:https://coder.com/blog/websocket
)
Loading

0 comments on commit dd4800f

Please sign in to comment.