Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' into GAtom22/evm-params
Browse files Browse the repository at this point in the history
  • Loading branch information
GAtom22 authored Jan 22, 2023
2 parents 3d276ec + b990a83 commit 110cd8e
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 50 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (upgrade) [#1617](https://github.com/evmos/ethermint/pull/1617) Refactor `evm` module's parameters to store them under a single store key
* (rpc) [#1611](https://github.com/evmos/ethermint/pull/1611) Add missing next fee in fee history, fix wrong oldestBlock and align earliest input as ethereum.

### Improvements

* (cli) [#1615](https://github.com/evmos/ethermint/pull/1615) Support customize db opener in `StartCmd`.

## [v0.21.0-rc1] - 2022-1-13

### State Machine Breaking
Expand Down Expand Up @@ -139,6 +143,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (rpc) [#1503](https://github.com/evmos/ethermint/pull/1503) Fix block hashes returned on JSON-RPC filter `eth_newBlockFilter`.
* (rpc) [#1557](https://github.com/evmos/ethermint/pull/1557) Patch GasUsed before the fix of revert gas refund logic when transaction reverted for `eth_getTransactionReceipt`.
* (ante) [#1566](https://github.com/evmos/ethermint/pull/1566) Fix `gasWanted` on `EthGasConsumeDecorator` ante handler when running transaction in `ReCheckMode`
* (rpc) [#1591](https://github.com/evmos/ethermint/pull/1591) Fix block number returned in opcode for debug trace related api.

## [v0.19.3] - 2022-10-14

Expand Down
2 changes: 1 addition & 1 deletion cmd/ethermintd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func NewRootCmd() (*cobra.Command, params.EncodingConfig) {
)

a := appCreator{encodingConfig}
server.AddCommands(rootCmd, app.DefaultNodeHome, a.newApp, a.appExport, addModuleInitFlags)
server.AddCommands(rootCmd, server.NewDefaultStartOptions(a.newApp, app.DefaultNodeHome), a.appExport, addModuleInitFlags)

// add keybase, auxiliary RPC, query, and tx child commands
rootCmd.AddCommand(
Expand Down
55 changes: 26 additions & 29 deletions gomod2nix.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ schema = 3
version = "v0.105.0"
hash = "sha256-2nYtHjuN9ghGcM6aPlOxyNNarHebHtj0Xec48sWwdaI="
[mod."cloud.google.com/go/compute"]
version = "v1.12.1"
hash = "sha256-mMsdL+6R1KuFeAFqEJv8oq/cmRc9hSluEisCpGP0GTc="
version = "v1.14.0"
hash = "sha256-Ay0oTR0I/ROajIiBSuZ1LfVVio142f8mUa64tGwreG8="
[mod."cloud.google.com/go/compute/metadata"]
version = "v0.2.1"
hash = "sha256-gqjkb6y5POkTWXGQtCvgygvXqoLkESB+cykKp7Mp3jI="
version = "v0.2.3"
hash = "sha256-kYB1FTQRdTDqCqJzSU/jJYbVUGyxbkASUKbEs36FUyU="
[mod."cloud.google.com/go/iam"]
version = "v0.7.0"
hash = "sha256-2UTJ/BbZ+YMGJhyo3HRPUYVDXW6+B5znFdqiutboYtA="
version = "v0.8.0"
hash = "sha256-legngj53V4RLUbAzDFlzL7LYv5Ano8IW28Ia3Ar69BM="
[mod."cloud.google.com/go/storage"]
version = "v1.27.0"
hash = "sha256-V4B6A1Ms8cemB5Cs6nAtUe1N1ldaI9oqTdzGU2FUhrc="
Expand Down Expand Up @@ -226,11 +226,11 @@ schema = 3
version = "v1.3.0"
hash = "sha256-QoR55eBtA94T2tBszyxfDtO7/pjZZSGb5vm7U0Xhs0Y="
[mod."github.com/googleapis/enterprise-certificate-proxy"]
version = "v0.2.0"
hash = "sha256-5gxsS5kDLqNFBkQ4eK6GS/sNn+aFknm6jjfteO+6jl4="
version = "v0.2.1"
hash = "sha256-FN0dEdtJygo24AKwcHyy6pL+esTKfxSz9tXPX8FV1rE="
[mod."github.com/googleapis/gax-go/v2"]
version = "v2.6.0"
hash = "sha256-sSsncbJmv0n5jB3G7tHY1Zr2ucCusIeTrXZH4A8QqYI="
version = "v2.7.0"
hash = "sha256-n/9o8RFFDwowqSTLUPvsTE1lp4KUJpq53j733nLYrWk="
[mod."github.com/gorilla/handlers"]
version = "v1.5.1"
hash = "sha256-GnBAARgOx1E+hDMQ63SI17hdhGtLQxb31lZOmn5j/pU="
Expand Down Expand Up @@ -316,8 +316,8 @@ schema = 3
version = "v0.1.0"
hash = "sha256-wQqGTtRWsfR9n0O/SXHVgECebbnNmHddxJIbG63OJBQ="
[mod."github.com/magiconair/properties"]
version = "v1.8.6"
hash = "sha256-xToSfpuePctkTdhJtsuKIEkXwfMZbnkFT98ahIfd4wY="
version = "v1.8.7"
hash = "sha256-XQ2bnc2s7/IH3WxEO4GishZurMyKwEclZy1DXg+2xXc="
[mod."github.com/manifoldco/promptui"]
version = "v0.9.0"
hash = "sha256-Fe2OPoyRExZejwtUBivKhfJAJW7o9b1eyYpgDlWQ1No="
Expand Down Expand Up @@ -363,12 +363,9 @@ schema = 3
[mod."github.com/onsi/gomega"]
version = "v1.25.0"
hash = "sha256-knaJppfBzKSMD4Gsqzx22SGrti7G5UyDBYrothAqsrs="
[mod."github.com/pelletier/go-toml"]
version = "v1.9.5"
hash = "sha256-RJ9K1BTId0Mled7S66iGgxHkZ5JKEIsrrNaEfM8aImc="
[mod."github.com/pelletier/go-toml/v2"]
version = "v2.0.5"
hash = "sha256-YWdHmuCGliWfiH0tTHuf07AAn/zOJNoq7g+5fvqdnrQ="
version = "v2.0.6"
hash = "sha256-BxAeApnn5H+OLlH3TXGvIbtC6LmbRnjwbcfT1qMZ4PE="
[mod."github.com/petermattis/goid"]
version = "v0.0.0-20180202154549-b0b1615b78e5"
hash = "sha256-TCyVuP7rAtrvlterVCapFtbf6UmIf72FXQvkQoDtDj4="
Expand Down Expand Up @@ -418,8 +415,8 @@ schema = 3
version = "v3.21.4-0.20210419000835-c7a38de76ee5+incompatible"
hash = "sha256-oqIqyFquWabIE6DID6uTEc8oFEmM1rVu2ATn3toiCEg="
[mod."github.com/spf13/afero"]
version = "v1.9.2"
hash = "sha256-R1mir7Fu95QK+YL99U14RGbLJzxqWRH5rSFpssgJvzA="
version = "v1.9.3"
hash = "sha256-8WqLcfhb9IasbUWLbxD3g48t/cWc8XbgHUZOm3ALNjA="
[mod."github.com/spf13/cast"]
version = "v1.5.0"
hash = "sha256-Pdp+wC5FWqyJKzyYHb7JCcV9BoJk/sxQw6nLyuLJvuQ="
Expand All @@ -433,8 +430,8 @@ schema = 3
version = "v1.0.5"
hash = "sha256-w9LLYzxxP74WHT4ouBspH/iQZXjuAh2WQCHsuvyEjAw="
[mod."github.com/spf13/viper"]
version = "v1.14.0"
hash = "sha256-qn3VzD339HZIub5QP4aWVciSufAfVb9llbmQZ8pfDEs="
version = "v1.15.0"
hash = "sha256-FvpbekXegcdWNbek/vs2zakgRsT5FROF8O8fhn5DNpI="
[mod."github.com/status-im/keycard-go"]
version = "v0.0.0-20200402102358-957c09536969"
hash = "sha256-yddXXuu6mEFEO2/K6c1tWymeBKzOcvLQnNsFGRjtfXk="
Expand All @@ -445,8 +442,8 @@ schema = 3
version = "v1.8.1"
hash = "sha256-3e0vOJLgCMAan+GfaGN8RGZdarh5iCavM6flf6YMNPk="
[mod."github.com/subosito/gotenv"]
version = "v1.4.1"
hash = "sha256-aHAUs8Gh+BREUulljWr7vBZQg1BLu/M/8UfNK8CWSn8="
version = "v1.4.2"
hash = "sha256-LnrDR1k/AoCFWBMcU7vQsoQLkZ65evT2hoQHLDudTsg="
[mod."github.com/syndtr/goleveldb"]
version = "v1.0.1-0.20210819022825-2ae1ddf74ef7"
hash = "sha256-36a4hgVQfwtS2zhylKpQuFhrjdc/Y8pF0dxc26jcZIU="
Expand Down Expand Up @@ -487,8 +484,8 @@ schema = 3
version = "v1.3.6"
hash = "sha256-DenVAmyN22xUiivk6fdJp4C9ZnUJXCMDUf8E0goRRV4="
[mod."go.opencensus.io"]
version = "v0.23.0"
hash = "sha256-R3O9GyNtv6j0ic7s+2xkLLaLzbJEop0Otj1nJDFBjsg="
version = "v0.24.0"
hash = "sha256-4H+mGZgG2c9I1y0m8avF4qmt8LUKxxVsTqR8mKgP4yo="
[mod."golang.org/x/crypto"]
version = "v0.3.0"
hash = "sha256-Un9wPqz8u/xpV98T4IqE6RMXIPhGCIm2prsNkHP3cjg="
Expand Down Expand Up @@ -517,14 +514,14 @@ schema = 3
version = "v0.0.0-20220907171357-04be3eba64a2"
hash = "sha256-6+zueutgefIYmgXinOflz8qGDDDj0Zhv+2OkGhBTKno="
[mod."google.golang.org/api"]
version = "v0.102.0"
hash = "sha256-q8t08Wu0qzOQOmhY4GSoUrhqLTW/TeXiKhio+5ONfe4="
version = "v0.107.0"
hash = "sha256-jDYEv25KOU/k8fnS31DXl0a8lob0LmFxj88qV+P9NiU="
[mod."google.golang.org/appengine"]
version = "v1.6.7"
hash = "sha256-zIxGRHiq4QBvRqkrhMGMGCaVL4iM4TtlYpAi/hrivS4="
[mod."google.golang.org/genproto"]
version = "v0.0.0-20221118155620-16455021b5e6"
hash = "sha256-FFSliEzgr7AceO8B+ZoPAlZDFVPLeqAFg+25VQw6cFs="
version = "v0.0.0-20221227171554-f9683d7f8bef"
hash = "sha256-vvYjJcG73odJwPUb3sZIz4MSHnzK1Jj2uo0CwZ8S8rQ="
[mod."google.golang.org/grpc"]
version = "v1.52.0"
hash = "sha256-wYJ/ysugKxz1O9u6BxECTIGFJ3sv0XmxOfM+Y0jW3KQ="
Expand Down
41 changes: 30 additions & 11 deletions server/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,28 @@ import (
ethermint "github.com/evmos/ethermint/types"
)

// DBOpener is a function to open `application.db`, potentially with customized options.
type DBOpener func(opts types.AppOptions, rootDir string, backend dbm.BackendType) (dbm.DB, error)

// StartOptions defines options that can be customized in `StartCmd`
type StartOptions struct {
AppCreator types.AppCreator
DefaultNodeHome string
DBOpener DBOpener
}

// NewDefaultStartOptions use the default db opener provided in tm-db.
func NewDefaultStartOptions(appCreator types.AppCreator, defaultNodeHome string) StartOptions {
return StartOptions{
AppCreator: appCreator,
DefaultNodeHome: defaultNodeHome,
DBOpener: openDB,
}
}

// StartCmd runs the service passed in, either stand-alone or in-process with
// Tendermint.
func StartCmd(appCreator types.AppCreator, defaultNodeHome string) *cobra.Command {
func StartCmd(opts StartOptions) *cobra.Command {
cmd := &cobra.Command{
Use: "start",
Short: "Run the full node",
Expand Down Expand Up @@ -119,7 +138,7 @@ which accepts a path for the resulting pprof file.
withTM, _ := cmd.Flags().GetBool(srvflags.WithTendermint)
if !withTM {
serverCtx.Logger.Info("starting ABCI without Tendermint")
return startStandAlone(serverCtx, appCreator)
return startStandAlone(serverCtx, opts)
}

serverCtx.Logger.Info("Unlocking keyring")
Expand All @@ -136,7 +155,7 @@ which accepts a path for the resulting pprof file.
serverCtx.Logger.Info("starting ABCI with Tendermint")

// amino is needed here for backwards compatibility of REST routes
err = startInProcess(serverCtx, clientCtx, appCreator)
err = startInProcess(serverCtx, clientCtx, opts)
errCode, ok := err.(server.ErrorCode)
if !ok {
return err
Expand All @@ -147,7 +166,7 @@ which accepts a path for the resulting pprof file.
},
}

cmd.Flags().String(flags.FlagHome, defaultNodeHome, "The application home directory")
cmd.Flags().String(flags.FlagHome, opts.DefaultNodeHome, "The application home directory")
cmd.Flags().Bool(srvflags.WithTendermint, true, "Run abci app embedded in-process with tendermint")
cmd.Flags().String(srvflags.Address, "tcp://0.0.0.0:26658", "Listen address")
cmd.Flags().String(srvflags.Transport, "socket", "Transport protocol: socket, grpc")
Expand Down Expand Up @@ -206,12 +225,12 @@ which accepts a path for the resulting pprof file.
return cmd
}

func startStandAlone(ctx *server.Context, appCreator types.AppCreator) error {
func startStandAlone(ctx *server.Context, opts StartOptions) error {
addr := ctx.Viper.GetString(srvflags.Address)
transport := ctx.Viper.GetString(srvflags.Transport)
home := ctx.Viper.GetString(flags.FlagHome)

db, err := openDB(home, server.GetAppDBBackend(ctx.Viper))
db, err := opts.DBOpener(ctx.Viper, home, server.GetAppDBBackend(ctx.Viper))
if err != nil {
return err
}
Expand All @@ -228,7 +247,7 @@ func startStandAlone(ctx *server.Context, appCreator types.AppCreator) error {
return err
}

app := appCreator(ctx.Logger, db, traceWriter, ctx.Viper)
app := opts.AppCreator(ctx.Logger, db, traceWriter, ctx.Viper)

config, err := config.GetConfig(ctx.Viper)
if err != nil {
Expand Down Expand Up @@ -269,7 +288,7 @@ func startStandAlone(ctx *server.Context, appCreator types.AppCreator) error {
}

// legacyAminoCdc is used for the legacy REST API
func startInProcess(ctx *server.Context, clientCtx client.Context, appCreator types.AppCreator) (err error) {
func startInProcess(ctx *server.Context, clientCtx client.Context, opts StartOptions) (err error) {
cfg := ctx.Config
home := cfg.RootDir
logger := ctx.Logger
Expand Down Expand Up @@ -300,7 +319,7 @@ func startInProcess(ctx *server.Context, clientCtx client.Context, appCreator ty
}()
}

db, err := openDB(home, server.GetAppDBBackend(ctx.Viper))
db, err := opts.DBOpener(ctx.Viper, home, server.GetAppDBBackend(ctx.Viper))
if err != nil {
logger.Error("failed to open DB", "error", err.Error())
return err
Expand Down Expand Up @@ -330,7 +349,7 @@ func startInProcess(ctx *server.Context, clientCtx client.Context, appCreator ty
return err
}

app := appCreator(ctx.Logger, db, traceWriter, ctx.Viper)
app := opts.AppCreator(ctx.Logger, db, traceWriter, ctx.Viper)

nodeKey, err := p2p.LoadOrGenNodeKey(cfg.NodeKeyFile())
if err != nil {
Expand Down Expand Up @@ -625,7 +644,7 @@ func startInProcess(ctx *server.Context, clientCtx client.Context, appCreator ty
return server.WaitForQuitSignals()
}

func openDB(rootDir string, backendType dbm.BackendType) (dbm.DB, error) {
func openDB(_ types.AppOptions, rootDir string, backendType dbm.BackendType) (dbm.DB, error) {
dataDir := filepath.Join(rootDir, "data")
return dbm.NewDB("application", backendType, dataDir)
}
Expand Down
9 changes: 4 additions & 5 deletions server/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ import (
// AddCommands adds server commands
func AddCommands(
rootCmd *cobra.Command,
defaultNodeHome string,
appCreator types.AppCreator,
opts StartOptions,
appExport types.AppExporter,
addStartFlags types.ModuleInitFlags,
) {
Expand All @@ -57,15 +56,15 @@ func AddCommands(
tmcmd.ResetStateCmd,
)

startCmd := StartCmd(appCreator, defaultNodeHome)
startCmd := StartCmd(opts)
addStartFlags(startCmd)

rootCmd.AddCommand(
startCmd,
tendermintCmd,
sdkserver.ExportCmd(appExport, defaultNodeHome),
sdkserver.ExportCmd(appExport, opts.DefaultNodeHome),
version.NewVersionCommand(),
sdkserver.NewRollbackCmd(appCreator, defaultNodeHome),
sdkserver.NewRollbackCmd(opts.AppCreator, opts.DefaultNodeHome),

// custom tx indexer command
NewIndexTxCmd(),
Expand Down
8 changes: 4 additions & 4 deletions x/evm/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -402,8 +402,8 @@ func (k Keeper) TraceTx(c context.Context, req *types.QueryTraceTxRequest) (*typ
return nil, status.Errorf(codes.InvalidArgument, "output limit cannot be negative, got %d", req.TraceConfig.Limit)
}

// minus one to get the context of block beginning
contextHeight := req.BlockNumber - 1
// get the context of block beginning
contextHeight := req.BlockNumber
if contextHeight < 1 {
// 0 is a special value in `ContextWithHeight`
contextHeight = 1
Expand Down Expand Up @@ -479,8 +479,8 @@ func (k Keeper) TraceBlock(c context.Context, req *types.QueryTraceBlockRequest)
return nil, status.Errorf(codes.InvalidArgument, "output limit cannot be negative, got %d", req.TraceConfig.Limit)
}

// minus one to get the context of block beginning
contextHeight := req.BlockNumber - 1
// get the context of block beginning
contextHeight := req.BlockNumber
if contextHeight < 1 {
// 0 is a special value in `ContextWithHeight`
contextHeight = 1
Expand Down

0 comments on commit 110cd8e

Please sign in to comment.