chore: Gofumpt (#1298)

* fumpt

* golangci

* Update keeper_test.go

* Update keeper_test.go

* Update handler_test.go

* Update rpc_pending_test.go

* lll

* line length limits

* Update CHANGELOG.md
This commit is contained in:
Jacob Gadikian 2022-08-26 17:30:55 +07:00 committed by GitHub
parent 1ea0cb31b7
commit 524e25c038
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
37 changed files with 268 additions and 94 deletions

View File

@ -5,7 +5,7 @@ run:
linters: linters:
enable: enable:
# - bodyclose - bodyclose
- deadcode - deadcode
- depguard - depguard
- dogsled - dogsled
@ -13,38 +13,30 @@ linters:
- errcheck - errcheck
- goconst - goconst
- gocritic - gocritic
- gofmt - gofumpt
- goimports
- revive - revive
- gosec - gosec
- gosimple - gosimple
- govet - govet
- ineffassign - ineffassign
# - lll TODO: enable - lll
- misspell - misspell
- nakedret - nakedret
- prealloc - prealloc
- exportloopref - exportloopref
- staticcheck - staticcheck
# - structcheck
- stylecheck - stylecheck
# - typecheck #TODO: enable - typecheck
- unconvert - unconvert
# - unparam - unparam
- unused - unused
- varcheck - varcheck
- nolintlint - nolintlint
- asciicheck - asciicheck
# - exhaustive
- exportloopref - exportloopref
- gofumpt - gofumpt
- gomodguard - gomodguard
# - nestif - whitespace
# - nlreturn
# - noctx
# - rowserrcheck
# - whitespace
# - wsl
issues: issues:
exclude-rules: exclude-rules:
@ -57,6 +49,8 @@ issues:
max-same-issues: 50 max-same-issues: 50
linters-settings: linters-settings:
lll:
line-length: 150
dogsled: dogsled:
max-blank-identifiers: 3 max-blank-identifiers: 3
golint: golint:

View File

@ -53,6 +53,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
### Improvements ### Improvements
* (lint) [#1298](https://github.com/evmos/ethermint/pull/1298) 150 character line length limit, gofumpt, and linting
* (rpc) [#1229](https://github.com/evmos/ethermint/pull/1229) Add support for configuring RPC `MaxOpenConnections` * (rpc) [#1229](https://github.com/evmos/ethermint/pull/1229) Add support for configuring RPC `MaxOpenConnections`
* (feemarket) [\#1165](https://github.com/evmos/ethermint/pull/1165) Add hint in specs about different gas terminology for gas in Cosmos and Ethereum. * (feemarket) [\#1165](https://github.com/evmos/ethermint/pull/1165) Add hint in specs about different gas terminology for gas in Cosmos and Ethereum.
* (cli) [#1226](https://github.com/evmos/ethermint/pull/1226) Add custom app db backend flag. * (cli) [#1226](https://github.com/evmos/ethermint/pull/1226) Add custom app db backend flag.

View File

@ -49,7 +49,11 @@ func NewEip712SigVerificationDecorator(ak evmtypes.AccountKeeper, signModeHandle
// AnteHandle handles validation of EIP712 signed cosmos txs. // AnteHandle handles validation of EIP712 signed cosmos txs.
// it is not run on RecheckTx // it is not run on RecheckTx
func (svd Eip712SigVerificationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) { func (svd Eip712SigVerificationDecorator) AnteHandle(ctx sdk.Context,
tx sdk.Tx,
simulate bool,
next sdk.AnteHandler,
) (newCtx sdk.Context, err error) {
// no need to verify signatures on recheck tx // no need to verify signatures on recheck tx
if ctx.IsReCheckTx() { if ctx.IsReCheckTx() {
return next(ctx, tx, simulate) return next(ctx, tx, simulate)

View File

@ -96,7 +96,12 @@ func NewEthAccountVerificationDecorator(ak evmtypes.AccountKeeper, ek EVMKeeper)
// - any of the msgs is not a MsgEthereumTx // - any of the msgs is not a MsgEthereumTx
// - from address is empty // - from address is empty
// - account balance is lower than the transaction cost // - account balance is lower than the transaction cost
func (avd EthAccountVerificationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) { func (avd EthAccountVerificationDecorator) AnteHandle(
ctx sdk.Context,
tx sdk.Tx,
simulate bool,
next sdk.AnteHandler,
) (newCtx sdk.Context, err error) {
if !ctx.IsCheckTx() { if !ctx.IsCheckTx() {
return next(ctx, tx, simulate) return next(ctx, tx, simulate)
} }
@ -134,7 +139,6 @@ func (avd EthAccountVerificationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx
if err := evmkeeper.CheckSenderBalance(sdkmath.NewIntFromBigInt(acct.Balance), txData); err != nil { if err := evmkeeper.CheckSenderBalance(sdkmath.NewIntFromBigInt(acct.Balance), txData); err != nil {
return ctx, sdkerrors.Wrap(err, "failed to check sender balance") return ctx, sdkerrors.Wrap(err, "failed to check sender balance")
} }
} }
return next(ctx, tx, simulate) return next(ctx, tx, simulate)
} }

View File

@ -62,7 +62,10 @@ func (mpd MinGasPriceDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate
} }
if !feeCoins.IsAnyGTE(requiredFees) { if !feeCoins.IsAnyGTE(requiredFees) {
return ctx, sdkerrors.Wrapf(sdkerrors.ErrInsufficientFee, "provided fee < minimum global fee (%s < %s). Please increase the gas price.", feeCoins, requiredFees) return ctx, sdkerrors.Wrapf(sdkerrors.ErrInsufficientFee,
"provided fee < minimum global fee (%s < %s). Please increase the gas price.",
feeCoins,
requiredFees)
} }
return next(ctx, tx, simulate) return next(ctx, tx, simulate)
@ -132,7 +135,7 @@ func (empd EthMinGasPriceDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simul
if fee.LT(requiredFee) { if fee.LT(requiredFee) {
return ctx, sdkerrors.Wrapf( return ctx, sdkerrors.Wrapf(
sdkerrors.ErrInsufficientFee, sdkerrors.ErrInsufficientFee,
"provided fee < minimum global fee (%d < %d). Please increase the priority tip (for EIP-1559 txs) or the gas prices (for access list or legacy txs)", "provided fee < minimum global fee (%d < %d). Please increase the priority tip (for EIP-1559 txs) or the gas prices (for access list or legacy txs)", //nolint:lll
fee.TruncateInt().Int64(), requiredFee.TruncateInt().Int64(), fee.TruncateInt().Int64(), requiredFee.TruncateInt().Int64(),
) )
} }

View File

@ -310,40 +310,81 @@ func NewEthermintApp(
// use custom Ethermint account for contracts // use custom Ethermint account for contracts
app.AccountKeeper = authkeeper.NewAccountKeeper( app.AccountKeeper = authkeeper.NewAccountKeeper(
appCodec, keys[authtypes.StoreKey], app.GetSubspace(authtypes.ModuleName), ethermint.ProtoAccount, maccPerms, sdk.GetConfig().GetBech32AccountAddrPrefix(), appCodec, keys[authtypes.StoreKey],
app.GetSubspace(authtypes.ModuleName),
ethermint.ProtoAccount,
maccPerms,
sdk.GetConfig().GetBech32AccountAddrPrefix(),
) )
app.BankKeeper = bankkeeper.NewBaseKeeper( app.BankKeeper = bankkeeper.NewBaseKeeper(
appCodec, keys[banktypes.StoreKey], app.AccountKeeper, app.GetSubspace(banktypes.ModuleName), app.BlockedAddrs(), appCodec,
keys[banktypes.StoreKey],
app.AccountKeeper,
app.GetSubspace(banktypes.ModuleName),
app.BlockedAddrs(),
) )
stakingKeeper := stakingkeeper.NewKeeper( stakingKeeper := stakingkeeper.NewKeeper(
appCodec, keys[stakingtypes.StoreKey], app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName), appCodec, keys[stakingtypes.StoreKey],
app.AccountKeeper,
app.BankKeeper,
app.GetSubspace(stakingtypes.ModuleName),
) )
app.MintKeeper = mintkeeper.NewKeeper( app.MintKeeper = mintkeeper.NewKeeper(
appCodec, keys[minttypes.StoreKey], app.GetSubspace(minttypes.ModuleName), &stakingKeeper, appCodec,
app.AccountKeeper, app.BankKeeper, authtypes.FeeCollectorName, keys[minttypes.StoreKey],
app.GetSubspace(minttypes.ModuleName),
&stakingKeeper,
app.AccountKeeper,
app.BankKeeper,
authtypes.FeeCollectorName,
) )
app.DistrKeeper = distrkeeper.NewKeeper( app.DistrKeeper = distrkeeper.NewKeeper(
appCodec, keys[distrtypes.StoreKey], app.GetSubspace(distrtypes.ModuleName), app.AccountKeeper, app.BankKeeper, appCodec,
&stakingKeeper, authtypes.FeeCollectorName, keys[distrtypes.StoreKey],
app.GetSubspace(distrtypes.ModuleName),
app.AccountKeeper,
app.BankKeeper,
&stakingKeeper,
authtypes.FeeCollectorName,
) )
app.SlashingKeeper = slashingkeeper.NewKeeper( app.SlashingKeeper = slashingkeeper.NewKeeper(
appCodec, keys[slashingtypes.StoreKey], &stakingKeeper, app.GetSubspace(slashingtypes.ModuleName), appCodec,
keys[slashingtypes.StoreKey],
&stakingKeeper,
app.GetSubspace(slashingtypes.ModuleName),
) )
app.CrisisKeeper = crisiskeeper.NewKeeper( app.CrisisKeeper = crisiskeeper.NewKeeper(
app.GetSubspace(crisistypes.ModuleName), invCheckPeriod, app.BankKeeper, authtypes.FeeCollectorName, app.GetSubspace(crisistypes.ModuleName),
invCheckPeriod,
app.BankKeeper,
authtypes.FeeCollectorName,
) )
app.FeeGrantKeeper = feegrantkeeper.NewKeeper(appCodec, keys[feegrant.StoreKey], app.AccountKeeper) app.FeeGrantKeeper = feegrantkeeper.NewKeeper(
appCodec,
keys[feegrant.StoreKey],
app.AccountKeeper)
// set the governance module account as the authority for conducting upgrades // set the governance module account as the authority for conducting upgrades
app.UpgradeKeeper = upgradekeeper.NewKeeper(skipUpgradeHeights, keys[upgradetypes.StoreKey], appCodec, homePath, app.BaseApp, authtypes.NewModuleAddress(govtypes.ModuleName).String()) app.UpgradeKeeper = upgradekeeper.NewKeeper(
skipUpgradeHeights,
keys[upgradetypes.StoreKey],
appCodec,
homePath,
app.BaseApp,
authtypes.NewModuleAddress(govtypes.ModuleName).String())
// register the staking hooks // register the staking hooks
// NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks // NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks
app.StakingKeeper = *stakingKeeper.SetHooks( app.StakingKeeper = *stakingKeeper.SetHooks(
stakingtypes.NewMultiStakingHooks(app.DistrKeeper.Hooks(), app.SlashingKeeper.Hooks()), stakingtypes.NewMultiStakingHooks(app.DistrKeeper.Hooks(),
app.SlashingKeeper.Hooks()),
) )
app.AuthzKeeper = authzkeeper.NewKeeper(keys[authzkeeper.StoreKey], appCodec, app.MsgServiceRouter(), app.AccountKeeper) app.AuthzKeeper = authzkeeper.NewKeeper(
keys[authzkeeper.StoreKey],
appCodec,
app.MsgServiceRouter(),
app.AccountKeeper)
tracer := cast.ToString(appOpts.Get(srvflags.EVMTracer)) tracer := cast.ToString(appOpts.Get(srvflags.EVMTracer))

View File

@ -59,7 +59,15 @@ func Setup(isCheckTx bool, patchGenesis func(*EthermintApp, simapp.GenesisState)
// SetupWithDB initializes a new EthermintApp. A Nop logger is set in EthermintApp. // SetupWithDB initializes a new EthermintApp. A Nop logger is set in EthermintApp.
func SetupWithDB(isCheckTx bool, patchGenesis func(*EthermintApp, simapp.GenesisState) simapp.GenesisState, db dbm.DB) *EthermintApp { func SetupWithDB(isCheckTx bool, patchGenesis func(*EthermintApp, simapp.GenesisState) simapp.GenesisState, db dbm.DB) *EthermintApp {
app := NewEthermintApp(log.NewNopLogger(), db, nil, true, map[int64]bool{}, DefaultNodeHome, 5, encoding.MakeConfig(ModuleBasics), simapp.EmptyAppOptions{}) app := NewEthermintApp(log.NewNopLogger(),
db,
nil,
true,
map[int64]bool{},
DefaultNodeHome,
5,
encoding.MakeConfig(ModuleBasics),
simapp.EmptyAppOptions{})
if !isCheckTx { if !isCheckTx {
// init chain must be called to stop deliverState from being nil // init chain must be called to stop deliverState from being nil
genesisState := NewTestGenesisState(app.AppCodec()) genesisState := NewTestGenesisState(app.AppCodec())
@ -236,7 +244,6 @@ func genesisStateWithValSet(codec codec.Codec, genesisState simapp.GenesisState,
} }
validators = append(validators, validator) validators = append(validators, validator)
delegations = append(delegations, stakingtypes.NewDelegation(genAccs[0].GetAddress(), val.Address.Bytes(), sdk.OneDec())) delegations = append(delegations, stakingtypes.NewDelegation(genAccs[0].GetAddress(), val.Address.Bytes(), sdk.OneDec()))
} }
// set validators and delegations // set validators and delegations
stakingGenesis := stakingtypes.NewGenesisState(stakingtypes.DefaultParams(), validators, delegations) stakingGenesis := stakingtypes.NewGenesisState(stakingtypes.DefaultParams(), validators, delegations)

View File

@ -247,7 +247,9 @@ func printCreate(cmd *cobra.Command, k *keyring.Record, showMnemonic bool, mnemo
// print mnemonic unless requested not to. // print mnemonic unless requested not to.
if showMnemonic { if showMnemonic {
if _, err := fmt.Fprintf(cmd.ErrOrStderr(), "\n**Important** write this mnemonic phrase in a safe place.\nIt is the only way to recover your account if you ever forget your password.\n\n%s\n\n", mnemonic); err != nil { if _, err := fmt.Fprintf(cmd.ErrOrStderr(),
"\n**Important** write this mnemonic phrase in a safe place.\nIt is the only way to recover your account if you ever forget your password.\n\n%s\n\n", //nolint:lll
mnemonic); err != nil {
return fmt.Errorf("failed to print mnemonic: %v", err) return fmt.Errorf("failed to print mnemonic: %v", err)
} }
} }

View File

@ -89,7 +89,10 @@ func addTestnetFlagsToCmd(cmd *cobra.Command) {
cmd.Flags().Int(flagNumValidators, 4, "Number of validators to initialize the testnet with") cmd.Flags().Int(flagNumValidators, 4, "Number of validators to initialize the testnet with")
cmd.Flags().StringP(flagOutputDir, "o", "./.testnets", "Directory to store initialization data for the testnet") cmd.Flags().StringP(flagOutputDir, "o", "./.testnets", "Directory to store initialization data for the testnet")
cmd.Flags().String(flags.FlagChainID, "", "genesis file chain-id, if left blank will be randomly created") cmd.Flags().String(flags.FlagChainID, "", "genesis file chain-id, if left blank will be randomly created")
cmd.Flags().String(sdkserver.FlagMinGasPrices, fmt.Sprintf("0.000006%s", ethermint.AttoPhoton), "Minimum gas prices to accept for transactions; All fees in a tx must meet this minimum (e.g. 0.01photino,0.001stake)") cmd.Flags().String(sdkserver.FlagMinGasPrices,
fmt.Sprintf("0.000006%s",
ethermint.AttoPhoton),
"Minimum gas prices to accept for transactions; All fees in a tx must meet this minimum (e.g. 0.01photino,0.001stake)")
cmd.Flags().String(flags.FlagKeyAlgorithm, string(hd.EthSecp256k1Type), "Key signing algorithm to generate keys for") cmd.Flags().String(flags.FlagKeyAlgorithm, string(hd.EthSecp256k1Type), "Key signing algorithm to generate keys for")
} }
@ -114,7 +117,7 @@ func NewTestnetCmd(mbm module.BasicManager, genBalIterator banktypes.GenesisBala
func testnetInitFilesCmd(mbm module.BasicManager, genBalIterator banktypes.GenesisBalancesIterator) *cobra.Command { func testnetInitFilesCmd(mbm module.BasicManager, genBalIterator banktypes.GenesisBalancesIterator) *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "init-files", Use: "init-files",
Short: "Initialize config directories & files for a multi-validator testnet running locally via separate processes (e.g. Docker Compose or similar)", Short: "Initialize config directories & files for a multi-validator testnet running locally via separate processes (e.g. Docker Compose or similar)", //nolint:lll
Long: `init-files will setup "v" number of directories and populate each with Long: `init-files will setup "v" number of directories and populate each with
necessary files (private validator, genesis, config, etc.) for running "v" validator nodes. necessary files (private validator, genesis, config, etc.) for running "v" validator nodes.
@ -152,7 +155,9 @@ Example:
addTestnetFlagsToCmd(cmd) addTestnetFlagsToCmd(cmd)
cmd.Flags().String(flagNodeDirPrefix, "node", "Prefix the directory name for each node with (node results in node0, node1, ...)") cmd.Flags().String(flagNodeDirPrefix, "node", "Prefix the directory name for each node with (node results in node0, node1, ...)")
cmd.Flags().String(flagNodeDaemonHome, "evmosd", "Home directory of the node's daemon configuration") cmd.Flags().String(flagNodeDaemonHome, "evmosd", "Home directory of the node's daemon configuration")
cmd.Flags().String(flagStartingIPAddress, "192.168.0.1", "Starting IP address (192.168.0.1 results in persistent peers list ID0@192.168.0.1:46656, ID1@192.168.0.2:46656, ...)") cmd.Flags().String(flagStartingIPAddress,
"192.168.0.1",
"Starting IP address (192.168.0.1 results in persistent peers list ID0@192.168.0.1:46656, ID1@192.168.0.2:46656, ...)")
cmd.Flags().String(flags.FlagKeyringBackend, flags.DefaultKeyringBackend, "Select keyring's backend (os|file|test)") cmd.Flags().String(flags.FlagKeyringBackend, flags.DefaultKeyringBackend, "Select keyring's backend (os|file|test)")
return cmd return cmd

View File

@ -313,7 +313,6 @@ func traverseFields(
} }
if fieldType.Kind() == reflect.Struct { if fieldType.Kind() == reflect.Struct {
var fieldTypedef string var fieldTypedef string
if isCollection { if isCollection {

View File

@ -62,7 +62,7 @@ func TestKVIndexer(t *testing.T) {
"success, format 1", "success, format 1",
&tmtypes.Block{Header: tmtypes.Header{Height: 1}, Data: tmtypes.Data{Txs: []tmtypes.Tx{txBz}}}, &tmtypes.Block{Header: tmtypes.Header{Height: 1}, Data: tmtypes.Data{Txs: []tmtypes.Tx{txBz}}},
[]*abci.ResponseDeliverTx{ []*abci.ResponseDeliverTx{
&abci.ResponseDeliverTx{ {
Code: 0, Code: 0,
Events: []abci.Event{ Events: []abci.Event{
{Type: types.EventTypeEthereumTx, Attributes: []abci.EventAttribute{ {Type: types.EventTypeEthereumTx, Attributes: []abci.EventAttribute{
@ -82,7 +82,7 @@ func TestKVIndexer(t *testing.T) {
"success, format 2", "success, format 2",
&tmtypes.Block{Header: tmtypes.Header{Height: 1}, Data: tmtypes.Data{Txs: []tmtypes.Tx{txBz}}}, &tmtypes.Block{Header: tmtypes.Header{Height: 1}, Data: tmtypes.Data{Txs: []tmtypes.Tx{txBz}}},
[]*abci.ResponseDeliverTx{ []*abci.ResponseDeliverTx{
&abci.ResponseDeliverTx{ {
Code: 0, Code: 0,
Events: []abci.Event{ Events: []abci.Event{
{Type: types.EventTypeEthereumTx, Attributes: []abci.EventAttribute{ {Type: types.EventTypeEthereumTx, Attributes: []abci.EventAttribute{
@ -104,7 +104,7 @@ func TestKVIndexer(t *testing.T) {
"success, exceed block gas limit", "success, exceed block gas limit",
&tmtypes.Block{Header: tmtypes.Header{Height: 1}, Data: tmtypes.Data{Txs: []tmtypes.Tx{txBz}}}, &tmtypes.Block{Header: tmtypes.Header{Height: 1}, Data: tmtypes.Data{Txs: []tmtypes.Tx{txBz}}},
[]*abci.ResponseDeliverTx{ []*abci.ResponseDeliverTx{
&abci.ResponseDeliverTx{ {
Code: 11, Code: 11,
Log: "out of gas in location: block gas meter; gasWanted: 21000", Log: "out of gas in location: block gas meter; gasWanted: 21000",
Events: []abci.Event{}, Events: []abci.Event{},
@ -116,7 +116,7 @@ func TestKVIndexer(t *testing.T) {
"fail, failed eth tx", "fail, failed eth tx",
&tmtypes.Block{Header: tmtypes.Header{Height: 1}, Data: tmtypes.Data{Txs: []tmtypes.Tx{txBz}}}, &tmtypes.Block{Header: tmtypes.Header{Height: 1}, Data: tmtypes.Data{Txs: []tmtypes.Tx{txBz}}},
[]*abci.ResponseDeliverTx{ []*abci.ResponseDeliverTx{
&abci.ResponseDeliverTx{ {
Code: 15, Code: 15,
Log: "nonce mismatch", Log: "nonce mismatch",
Events: []abci.Event{}, Events: []abci.Event{},
@ -128,7 +128,7 @@ func TestKVIndexer(t *testing.T) {
"fail, invalid events", "fail, invalid events",
&tmtypes.Block{Header: tmtypes.Header{Height: 1}, Data: tmtypes.Data{Txs: []tmtypes.Tx{txBz}}}, &tmtypes.Block{Header: tmtypes.Header{Height: 1}, Data: tmtypes.Data{Txs: []tmtypes.Tx{txBz}}},
[]*abci.ResponseDeliverTx{ []*abci.ResponseDeliverTx{
&abci.ResponseDeliverTx{ {
Code: 0, Code: 0,
Events: []abci.Event{}, Events: []abci.Event{},
}, },
@ -139,7 +139,7 @@ func TestKVIndexer(t *testing.T) {
"fail, not eth tx", "fail, not eth tx",
&tmtypes.Block{Header: tmtypes.Header{Height: 1}, Data: tmtypes.Data{Txs: []tmtypes.Tx{txBz2}}}, &tmtypes.Block{Header: tmtypes.Header{Height: 1}, Data: tmtypes.Data{Txs: []tmtypes.Tx{txBz2}}},
[]*abci.ResponseDeliverTx{ []*abci.ResponseDeliverTx{
&abci.ResponseDeliverTx{ {
Code: 0, Code: 0,
Events: []abci.Event{}, Events: []abci.Event{},
}, },

View File

@ -57,7 +57,12 @@ var apiCreators map[string]APICreator
func init() { func init() {
apiCreators = map[string]APICreator{ apiCreators = map[string]APICreator{
EthNamespace: func(ctx *server.Context, clientCtx client.Context, tmWSClient *rpcclient.WSClient, allowUnprotectedTxs bool, indexer ethermint.EVMTxIndexer) []rpc.API { EthNamespace: func(ctx *server.Context,
clientCtx client.Context,
tmWSClient *rpcclient.WSClient,
allowUnprotectedTxs bool,
indexer ethermint.EVMTxIndexer,
) []rpc.API {
evmBackend := backend.NewBackend(ctx, ctx.Logger, clientCtx, allowUnprotectedTxs, indexer) evmBackend := backend.NewBackend(ctx, ctx.Logger, clientCtx, allowUnprotectedTxs, indexer)
return []rpc.API{ return []rpc.API{
{ {
@ -94,7 +99,12 @@ func init() {
}, },
} }
}, },
PersonalNamespace: func(ctx *server.Context, clientCtx client.Context, _ *rpcclient.WSClient, allowUnprotectedTxs bool, indexer ethermint.EVMTxIndexer) []rpc.API { PersonalNamespace: func(ctx *server.Context,
clientCtx client.Context,
_ *rpcclient.WSClient,
allowUnprotectedTxs bool,
indexer ethermint.EVMTxIndexer,
) []rpc.API {
evmBackend := backend.NewBackend(ctx, ctx.Logger, clientCtx, allowUnprotectedTxs, indexer) evmBackend := backend.NewBackend(ctx, ctx.Logger, clientCtx, allowUnprotectedTxs, indexer)
return []rpc.API{ return []rpc.API{
{ {
@ -115,7 +125,12 @@ func init() {
}, },
} }
}, },
DebugNamespace: func(ctx *server.Context, clientCtx client.Context, _ *rpcclient.WSClient, allowUnprotectedTxs bool, indexer ethermint.EVMTxIndexer) []rpc.API { DebugNamespace: func(ctx *server.Context,
clientCtx client.Context,
_ *rpcclient.WSClient,
allowUnprotectedTxs bool,
indexer ethermint.EVMTxIndexer,
) []rpc.API {
evmBackend := backend.NewBackend(ctx, ctx.Logger, clientCtx, allowUnprotectedTxs, indexer) evmBackend := backend.NewBackend(ctx, ctx.Logger, clientCtx, allowUnprotectedTxs, indexer)
return []rpc.API{ return []rpc.API{
{ {
@ -126,7 +141,12 @@ func init() {
}, },
} }
}, },
MinerNamespace: func(ctx *server.Context, clientCtx client.Context, _ *rpcclient.WSClient, allowUnprotectedTxs bool, indexer ethermint.EVMTxIndexer) []rpc.API { MinerNamespace: func(ctx *server.Context,
clientCtx client.Context,
_ *rpcclient.WSClient,
allowUnprotectedTxs bool,
indexer ethermint.EVMTxIndexer,
) []rpc.API {
evmBackend := backend.NewBackend(ctx, ctx.Logger, clientCtx, allowUnprotectedTxs, indexer) evmBackend := backend.NewBackend(ctx, ctx.Logger, clientCtx, allowUnprotectedTxs, indexer)
return []rpc.API{ return []rpc.API{
{ {
@ -141,7 +161,13 @@ func init() {
} }
// GetRPCAPIs returns the list of all APIs // GetRPCAPIs returns the list of all APIs
func GetRPCAPIs(ctx *server.Context, clientCtx client.Context, tmWSClient *rpcclient.WSClient, allowUnprotectedTxs bool, indexer ethermint.EVMTxIndexer, selectedAPIs []string) []rpc.API { func GetRPCAPIs(ctx *server.Context,
clientCtx client.Context,
tmWSClient *rpcclient.WSClient,
allowUnprotectedTxs bool,
indexer ethermint.EVMTxIndexer,
selectedAPIs []string,
) []rpc.API {
var apis []rpc.API var apis []rpc.API
for _, ns := range selectedAPIs { for _, ns := range selectedAPIs {

View File

@ -35,7 +35,10 @@ func (b *Backend) GetCode(address common.Address, blockNrOrHash rpctypes.BlockNu
} }
// GetProof returns an account object with proof and any storage proofs // GetProof returns an account object with proof and any storage proofs
func (b *Backend) GetProof(address common.Address, storageKeys []string, blockNrOrHash rpctypes.BlockNumberOrHash) (*rpctypes.AccountResult, error) { func (b *Backend) GetProof(address common.Address,
storageKeys []string,
blockNrOrHash rpctypes.BlockNumberOrHash,
) (*rpctypes.AccountResult, error) {
blockNum, err := b.GetBlockNumber(blockNrOrHash) blockNum, err := b.GetBlockNumber(blockNrOrHash)
if err != nil { if err != nil {
return nil, err return nil, err

View File

@ -196,7 +196,6 @@ func (b *Backend) SetTxDefaults(args evmtypes.TransactionArgs) (evmtypes.Transac
if args.MaxFeePerGas.ToInt().Cmp(args.MaxPriorityFeePerGas.ToInt()) < 0 { if args.MaxFeePerGas.ToInt().Cmp(args.MaxPriorityFeePerGas.ToInt()) < 0 {
return args, fmt.Errorf("maxFeePerGas (%v) < maxPriorityFeePerGas (%v)", args.MaxFeePerGas, args.MaxPriorityFeePerGas) return args, fmt.Errorf("maxFeePerGas (%v) < maxPriorityFeePerGas (%v)", args.MaxFeePerGas, args.MaxPriorityFeePerGas)
} }
} else { } else {
if args.MaxFeePerGas != nil || args.MaxPriorityFeePerGas != nil { if args.MaxFeePerGas != nil || args.MaxPriorityFeePerGas != nil {
return args, errors.New("maxFeePerGas or maxPriorityFeePerGas specified but london is not active yet") return args, errors.New("maxFeePerGas or maxPriorityFeePerGas specified but london is not active yet")

View File

@ -233,7 +233,12 @@ func (b *Backend) ListAccounts() ([]common.Address, error) {
} }
// NewAccount will create a new account and returns the address for the new account. // NewAccount will create a new account and returns the address for the new account.
func (b *Backend) NewMnemonic(uid string, language keyring.Language, hdPath, bip39Passphrase string, algo keyring.SignatureAlgo) (*keyring.Record, error) { func (b *Backend) NewMnemonic(uid string,
language keyring.Language,
hdPath,
bip39Passphrase string,
algo keyring.SignatureAlgo,
) (*keyring.Record, error) {
info, _, err := b.clientCtx.Keyring.NewMnemonic(uid, keyring.English, bip39Passphrase, bip39Passphrase, algo) info, _, err := b.clientCtx.Keyring.NewMnemonic(uid, keyring.English, bip39Passphrase, bip39Passphrase, algo)
if err != nil { if err != nil {
return nil, err return nil, err

View File

@ -113,7 +113,10 @@ func (b *Backend) TraceTransaction(hash common.Hash, config *evmtypes.TraceConfi
// traceBlock configures a new tracer according to the provided configuration, and // traceBlock configures a new tracer according to the provided configuration, and
// executes all the transactions contained within. The return value will be one item // executes all the transactions contained within. The return value will be one item
// per transaction, dependent on the requested tracer. // per transaction, dependent on the requested tracer.
func (b *Backend) TraceBlock(height rpctypes.BlockNumber, config *evmtypes.TraceConfig, block *tmrpctypes.ResultBlock) ([]*evmtypes.TxTraceResult, error) { func (b *Backend) TraceBlock(height rpctypes.BlockNumber,
config *evmtypes.TraceConfig,
block *tmrpctypes.ResultBlock,
) ([]*evmtypes.TxTraceResult, error) {
txs := block.Block.Txs txs := block.Block.Txs
txsLength := len(txs) txsLength := len(txs)

View File

@ -269,7 +269,10 @@ func (e *PublicAPI) GetCode(address common.Address, blockNrOrHash rpctypes.Block
} }
// GetProof returns an account object with proof and any storage proofs // GetProof returns an account object with proof and any storage proofs
func (e *PublicAPI) GetProof(address common.Address, storageKeys []string, blockNrOrHash rpctypes.BlockNumberOrHash) (*rpctypes.AccountResult, error) { func (e *PublicAPI) GetProof(address common.Address,
storageKeys []string,
blockNrOrHash rpctypes.BlockNumberOrHash,
) (*rpctypes.AccountResult, error) {
e.logger.Debug("eth_getProof", "address", address.Hex(), "keys", storageKeys, "block number or hash", blockNrOrHash) e.logger.Debug("eth_getProof", "address", address.Hex(), "keys", storageKeys, "block number or hash", blockNrOrHash)
return e.backend.GetProof(address, storageKeys, blockNrOrHash) return e.backend.GetProof(address, storageKeys, blockNrOrHash)
} }
@ -279,7 +282,10 @@ func (e *PublicAPI) GetProof(address common.Address, storageKeys []string, block
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// Call performs a raw contract call. // Call performs a raw contract call.
func (e *PublicAPI) Call(args evmtypes.TransactionArgs, blockNrOrHash rpctypes.BlockNumberOrHash, _ *rpctypes.StateOverride) (hexutil.Bytes, error) { func (e *PublicAPI) Call(args evmtypes.TransactionArgs,
blockNrOrHash rpctypes.BlockNumberOrHash,
_ *rpctypes.StateOverride,
) (hexutil.Bytes, error) {
e.logger.Debug("eth_call", "args", args.String(), "block number or hash", blockNrOrHash) e.logger.Debug("eth_call", "args", args.String(), "block number or hash", blockNrOrHash)
blockNum, err := e.backend.GetBlockNumber(blockNrOrHash) blockNum, err := e.backend.GetBlockNumber(blockNrOrHash)
@ -345,7 +351,10 @@ func (e *PublicAPI) EstimateGas(args evmtypes.TransactionArgs, blockNrOptional *
return e.backend.EstimateGas(args, blockNrOptional) return e.backend.EstimateGas(args, blockNrOptional)
} }
func (e *PublicAPI) FeeHistory(blockCount rpc.DecimalOrHex, lastBlock rpc.BlockNumber, rewardPercentiles []float64) (*rpctypes.FeeHistoryResult, error) { func (e *PublicAPI) FeeHistory(blockCount rpc.DecimalOrHex,
lastBlock rpc.BlockNumber,
rewardPercentiles []float64,
) (*rpctypes.FeeHistoryResult, error) {
e.logger.Debug("eth_feeHistory") e.logger.Debug("eth_feeHistory")
return e.backend.FeeHistory(blockCount, lastBlock, rewardPercentiles) return e.backend.FeeHistory(blockCount, lastBlock, rewardPercentiles)
} }
@ -499,7 +508,11 @@ func (e *PublicAPI) FillTransaction(args evmtypes.TransactionArgs) (*rpctypes.Si
// Resend accepts an existing transaction and a new gas price and limit. It will remove // Resend accepts an existing transaction and a new gas price and limit. It will remove
// the given transaction from the pool and reinsert it with the new gas price and limit. // the given transaction from the pool and reinsert it with the new gas price and limit.
func (e *PublicAPI) Resend(_ context.Context, args evmtypes.TransactionArgs, gasPrice *hexutil.Big, gasLimit *hexutil.Uint64) (common.Hash, error) { func (e *PublicAPI) Resend(_ context.Context,
args evmtypes.TransactionArgs,
gasPrice *hexutil.Big,
gasLimit *hexutil.Uint64,
) (common.Hash, error) {
e.logger.Debug("eth_resend", "args", args.String()) e.logger.Debug("eth_resend", "args", args.String())
return e.backend.Resend(args, gasPrice, gasLimit) return e.backend.Resend(args, gasPrice, gasLimit)
} }

View File

@ -136,7 +136,12 @@ func (api *PublicFilterAPI) NewPendingTransactionFilter() rpc.ID {
return rpc.ID(fmt.Sprintf("error creating pending tx filter: %s", err.Error())) return rpc.ID(fmt.Sprintf("error creating pending tx filter: %s", err.Error()))
} }
api.filters[pendingTxSub.ID()] = &filter{typ: filters.PendingTransactionsSubscription, deadline: time.NewTimer(deadline), hashes: make([]common.Hash, 0), s: pendingTxSub} api.filters[pendingTxSub.ID()] = &filter{
typ: filters.PendingTransactionsSubscription,
deadline: time.NewTimer(deadline),
hashes: make([]common.Hash, 0),
s: pendingTxSub,
}
go func(txsCh <-chan coretypes.ResultEvent, errCh <-chan error) { go func(txsCh <-chan coretypes.ResultEvent, errCh <-chan error) {
defer cancelSubs() defer cancelSubs()
@ -455,7 +460,13 @@ func (api *PublicFilterAPI) NewFilter(criteria filters.FilterCriteria) (rpc.ID,
filterID = logsSub.ID() filterID = logsSub.ID()
api.filters[filterID] = &filter{typ: filters.LogsSubscription, crit: criteria, deadline: time.NewTimer(deadline), hashes: []common.Hash{}, s: logsSub} api.filters[filterID] = &filter{
typ: filters.LogsSubscription,
crit: criteria,
deadline: time.NewTimer(deadline),
hashes: []common.Hash{},
s: logsSub,
}
go func(eventCh <-chan coretypes.ResultEvent) { go func(eventCh <-chan coretypes.ResultEvent) {
defer cancelSubs() defer cancelSubs()

View File

@ -27,8 +27,12 @@ import (
) )
var ( var (
txEvents = tmtypes.QueryForEvent(tmtypes.EventTx).String() txEvents = tmtypes.QueryForEvent(tmtypes.EventTx).String()
evmEvents = tmquery.MustParse(fmt.Sprintf("%s='%s' AND %s.%s='%s'", tmtypes.EventTypeKey, tmtypes.EventTx, sdk.EventTypeMessage, sdk.AttributeKeyModule, evmtypes.ModuleName)).String() evmEvents = tmquery.MustParse(fmt.Sprintf("%s='%s' AND %s.%s='%s'",
tmtypes.EventTypeKey,
tmtypes.EventTx,
sdk.EventTypeMessage,
sdk.AttributeKeyModule, evmtypes.ModuleName)).String()
headerEvents = tmtypes.QueryForEvent(tmtypes.EventNewBlockHeader).String() headerEvents = tmtypes.QueryForEvent(tmtypes.EventNewBlockHeader).String()
) )

View File

@ -69,8 +69,8 @@ func AddTxFlags(cmd *cobra.Command) (*cobra.Command, error) {
cmd.PersistentFlags().String(flags.FlagFrom, "", "Name or address of private key with which to sign") cmd.PersistentFlags().String(flags.FlagFrom, "", "Name or address of private key with which to sign")
cmd.PersistentFlags().String(flags.FlagFees, "", "Fees to pay along with transaction; eg: 10aphoton") cmd.PersistentFlags().String(flags.FlagFees, "", "Fees to pay along with transaction; eg: 10aphoton")
cmd.PersistentFlags().String(flags.FlagGasPrices, "", "Gas prices to determine the transaction fee (e.g. 10aphoton)") cmd.PersistentFlags().String(flags.FlagGasPrices, "", "Gas prices to determine the transaction fee (e.g. 10aphoton)")
cmd.PersistentFlags().String(flags.FlagNode, "tcp://localhost:26657", "<host>:<port> to tendermint rpc interface for this chain") cmd.PersistentFlags().String(flags.FlagNode, "tcp://localhost:26657", "<host>:<port> to tendermint rpc interface for this chain") //nolint:lll
cmd.PersistentFlags().Float64(flags.FlagGasAdjustment, flags.DefaultGasAdjustment, "adjustment factor to be multiplied against the estimate returned by the tx simulation; if the gas limit is set manually this flag is ignored ") cmd.PersistentFlags().Float64(flags.FlagGasAdjustment, flags.DefaultGasAdjustment, "adjustment factor to be multiplied against the estimate returned by the tx simulation; if the gas limit is set manually this flag is ignored ") //nolint:lll
cmd.PersistentFlags().StringP(flags.FlagBroadcastMode, "b", flags.BroadcastSync, "Transaction broadcasting mode (sync|async|block)") cmd.PersistentFlags().StringP(flags.FlagBroadcastMode, "b", flags.BroadcastSync, "Transaction broadcasting mode (sync|async|block)")
cmd.PersistentFlags().String(flags.FlagKeyringBackend, keyring.BackendOS, "Select keyring's backend") cmd.PersistentFlags().String(flags.FlagKeyringBackend, keyring.BackendOS, "Select keyring's backend")

View File

@ -19,7 +19,13 @@ import (
) )
// StartJSONRPC starts the JSON-RPC server // StartJSONRPC starts the JSON-RPC server
func StartJSONRPC(ctx *server.Context, clientCtx client.Context, tmRPCAddr, tmEndpoint string, config *config.Config, indexer ethermint.EVMTxIndexer) (*http.Server, chan struct{}, error) { func StartJSONRPC(ctx *server.Context,
clientCtx client.Context,
tmRPCAddr,
tmEndpoint string,
config *config.Config,
indexer ethermint.EVMTxIndexer,
) (*http.Server, chan struct{}, error) {
tmWsClient := ConnectTmWS(tmRPCAddr, tmEndpoint, ctx.Logger) tmWsClient := ConnectTmWS(tmRPCAddr, tmEndpoint, ctx.Logger)
logger := ctx.Logger.With("module", "geth") logger := ctx.Logger.With("module", "geth")

View File

@ -131,7 +131,7 @@ which accepts a path for the resulting pprof file.
cmd.Flags().String(srvflags.Address, "tcp://0.0.0.0:26658", "Listen address") cmd.Flags().String(srvflags.Address, "tcp://0.0.0.0:26658", "Listen address")
cmd.Flags().String(srvflags.Transport, "socket", "Transport protocol: socket, grpc") cmd.Flags().String(srvflags.Transport, "socket", "Transport protocol: socket, grpc")
cmd.Flags().String(srvflags.TraceStore, "", "Enable KVStore tracing to an output file") cmd.Flags().String(srvflags.TraceStore, "", "Enable KVStore tracing to an output file")
cmd.Flags().String(server.FlagMinGasPrices, "", "Minimum gas prices to accept for transactions; Any fee in a tx must meet this minimum (e.g. 0.01photon;0.0001stake)") cmd.Flags().String(server.FlagMinGasPrices, "", "Minimum gas prices to accept for transactions; Any fee in a tx must meet this minimum (e.g. 0.01photon;0.0001stake)") //nolint:lll
cmd.Flags().IntSlice(server.FlagUnsafeSkipUpgrades, []int{}, "Skip a set of upgrade heights to continue the old binary") cmd.Flags().IntSlice(server.FlagUnsafeSkipUpgrades, []int{}, "Skip a set of upgrade heights to continue the old binary")
cmd.Flags().Uint64(server.FlagHaltHeight, 0, "Block height at which to gracefully halt the chain and shutdown the node") cmd.Flags().Uint64(server.FlagHaltHeight, 0, "Block height at which to gracefully halt the chain and shutdown the node")
cmd.Flags().Uint64(server.FlagHaltTime, 0, "Minimum block time (in Unix seconds) at which to gracefully halt the chain and shutdown the node") cmd.Flags().Uint64(server.FlagHaltTime, 0, "Minimum block time (in Unix seconds) at which to gracefully halt the chain and shutdown the node")
@ -140,7 +140,7 @@ which accepts a path for the resulting pprof file.
cmd.Flags().Bool(server.FlagTrace, false, "Provide full stack traces for errors in ABCI Log") cmd.Flags().Bool(server.FlagTrace, false, "Provide full stack traces for errors in ABCI Log")
cmd.Flags().String(server.FlagPruning, pruningtypes.PruningOptionDefault, "Pruning strategy (default|nothing|everything|custom)") cmd.Flags().String(server.FlagPruning, pruningtypes.PruningOptionDefault, "Pruning strategy (default|nothing|everything|custom)")
cmd.Flags().Uint64(server.FlagPruningKeepRecent, 0, "Number of recent heights to keep on disk (ignored if pruning is not 'custom')") cmd.Flags().Uint64(server.FlagPruningKeepRecent, 0, "Number of recent heights to keep on disk (ignored if pruning is not 'custom')")
cmd.Flags().Uint64(server.FlagPruningInterval, 0, "Height interval at which pruned heights are removed from disk (ignored if pruning is not 'custom')") cmd.Flags().Uint64(server.FlagPruningInterval, 0, "Height interval at which pruned heights are removed from disk (ignored if pruning is not 'custom')") //nolint:lll
cmd.Flags().Uint(server.FlagInvCheckPeriod, 0, "Assert registered invariants every N blocks") cmd.Flags().Uint(server.FlagInvCheckPeriod, 0, "Assert registered invariants every N blocks")
cmd.Flags().Uint64(server.FlagMinRetainBlocks, 0, "Minimum block height offset during ABCI commit to prune Tendermint blocks") cmd.Flags().Uint64(server.FlagMinRetainBlocks, 0, "Minimum block height offset during ABCI commit to prune Tendermint blocks")
cmd.Flags().String(srvflags.AppDBBackend, "", "The type of database for application and snapshots databases") cmd.Flags().String(srvflags.AppDBBackend, "", "The type of database for application and snapshots databases")
@ -157,20 +157,20 @@ which accepts a path for the resulting pprof file.
cmd.Flags().StringSlice(srvflags.JSONRPCAPI, config.GetDefaultAPINamespaces(), "Defines a list of JSON-RPC namespaces that should be enabled") cmd.Flags().StringSlice(srvflags.JSONRPCAPI, config.GetDefaultAPINamespaces(), "Defines a list of JSON-RPC namespaces that should be enabled")
cmd.Flags().String(srvflags.JSONRPCAddress, config.DefaultJSONRPCAddress, "the JSON-RPC server address to listen on") cmd.Flags().String(srvflags.JSONRPCAddress, config.DefaultJSONRPCAddress, "the JSON-RPC server address to listen on")
cmd.Flags().String(srvflags.JSONWsAddress, config.DefaultJSONRPCWsAddress, "the JSON-RPC WS server address to listen on") cmd.Flags().String(srvflags.JSONWsAddress, config.DefaultJSONRPCWsAddress, "the JSON-RPC WS server address to listen on")
cmd.Flags().Uint64(srvflags.JSONRPCGasCap, config.DefaultGasCap, "Sets a cap on gas that can be used in eth_call/estimateGas unit is aphoton (0=infinite)") cmd.Flags().Uint64(srvflags.JSONRPCGasCap, config.DefaultGasCap, "Sets a cap on gas that can be used in eth_call/estimateGas unit is aphoton (0=infinite)") //nolint:lll
cmd.Flags().Float64(srvflags.JSONRPCTxFeeCap, config.DefaultTxFeeCap, "Sets a cap on transaction fee that can be sent via the RPC APIs (1 = default 1 photon)") cmd.Flags().Float64(srvflags.JSONRPCTxFeeCap, config.DefaultTxFeeCap, "Sets a cap on transaction fee that can be sent via the RPC APIs (1 = default 1 photon)") //nolint:lll
cmd.Flags().Int32(srvflags.JSONRPCFilterCap, config.DefaultFilterCap, "Sets the global cap for total number of filters that can be created") cmd.Flags().Int32(srvflags.JSONRPCFilterCap, config.DefaultFilterCap, "Sets the global cap for total number of filters that can be created")
cmd.Flags().Duration(srvflags.JSONRPCEVMTimeout, config.DefaultEVMTimeout, "Sets a timeout used for eth_call (0=infinite)") cmd.Flags().Duration(srvflags.JSONRPCEVMTimeout, config.DefaultEVMTimeout, "Sets a timeout used for eth_call (0=infinite)")
cmd.Flags().Duration(srvflags.JSONRPCHTTPTimeout, config.DefaultHTTPTimeout, "Sets a read/write timeout for json-rpc http server (0=infinite)") cmd.Flags().Duration(srvflags.JSONRPCHTTPTimeout, config.DefaultHTTPTimeout, "Sets a read/write timeout for json-rpc http server (0=infinite)")
cmd.Flags().Duration(srvflags.JSONRPCHTTPIdleTimeout, config.DefaultHTTPIdleTimeout, "Sets a idle timeout for json-rpc http server (0=infinite)") cmd.Flags().Duration(srvflags.JSONRPCHTTPIdleTimeout, config.DefaultHTTPIdleTimeout, "Sets a idle timeout for json-rpc http server (0=infinite)")
cmd.Flags().Bool(srvflags.JSONRPCAllowUnprotectedTxs, config.DefaultAllowUnprotectedTxs, "Allow for unprotected (non EIP155 signed) transactions to be submitted via the node's RPC when the global parameter is disabled") cmd.Flags().Bool(srvflags.JSONRPCAllowUnprotectedTxs, config.DefaultAllowUnprotectedTxs, "Allow for unprotected (non EIP155 signed) transactions to be submitted via the node's RPC when the global parameter is disabled") //nolint:lll
cmd.Flags().Int32(srvflags.JSONRPCLogsCap, config.DefaultLogsCap, "Sets the max number of results can be returned from single `eth_getLogs` query") cmd.Flags().Int32(srvflags.JSONRPCLogsCap, config.DefaultLogsCap, "Sets the max number of results can be returned from single `eth_getLogs` query")
cmd.Flags().Int32(srvflags.JSONRPCBlockRangeCap, config.DefaultBlockRangeCap, "Sets the max block range allowed for `eth_getLogs` query") cmd.Flags().Int32(srvflags.JSONRPCBlockRangeCap, config.DefaultBlockRangeCap, "Sets the max block range allowed for `eth_getLogs` query")
cmd.Flags().Int(srvflags.JSONRPCMaxOpenConnections, config.DefaultMaxOpenConnections, "Sets the maximum number of simultaneous connections for the server listener") cmd.Flags().Int(srvflags.JSONRPCMaxOpenConnections, config.DefaultMaxOpenConnections, "Sets the maximum number of simultaneous connections for the server listener") //nolint:lll
cmd.Flags().Bool(srvflags.JSONRPCEnableIndexer, false, "Enable the custom tx indexer for json-rpc") cmd.Flags().Bool(srvflags.JSONRPCEnableIndexer, false, "Enable the custom tx indexer for json-rpc")
cmd.Flags().String(srvflags.EVMTracer, config.DefaultEVMTracer, "the EVM tracer type to collect execution traces from the EVM transaction execution (json|struct|access_list|markdown)") cmd.Flags().String(srvflags.EVMTracer, config.DefaultEVMTracer, "the EVM tracer type to collect execution traces from the EVM transaction execution (json|struct|access_list|markdown)") //nolint:lll
cmd.Flags().Uint64(srvflags.EVMMaxTxGasWanted, config.DefaultMaxTxGasWanted, "the gas wanted for each eth tx returned in ante handler in check tx mode") cmd.Flags().Uint64(srvflags.EVMMaxTxGasWanted, config.DefaultMaxTxGasWanted, "the gas wanted for each eth tx returned in ante handler in check tx mode") //nolint:lll
cmd.Flags().String(srvflags.TLSCertPath, "", "the cert.pem file path for the server TLS configuration") cmd.Flags().String(srvflags.TLSCertPath, "", "the cert.pem file path for the server TLS configuration")
cmd.Flags().String(srvflags.TLSKeyPath, "", "the key.pem file path for the server TLS configuration") cmd.Flags().String(srvflags.TLSKeyPath, "", "the key.pem file path for the server TLS configuration")

View File

@ -21,7 +21,13 @@ import (
) )
// AddCommands adds server commands // AddCommands adds server commands
func AddCommands(rootCmd *cobra.Command, defaultNodeHome string, appCreator types.AppCreator, appExport types.AppExporter, addStartFlags types.ModuleInitFlags) { func AddCommands(
rootCmd *cobra.Command,
defaultNodeHome string,
appCreator types.AppCreator,
appExport types.AppExporter,
addStartFlags types.ModuleInitFlags,
) {
tendermintCmd := &cobra.Command{ tendermintCmd := &cobra.Command{
Use: "tendermint", Use: "tendermint",
Short: "Tendermint subcommands", Short: "Tendermint subcommands",
@ -86,7 +92,6 @@ func MountGRPCWebServices(
logger tmlog.Logger, logger tmlog.Logger,
) { ) {
for _, res := range grpcResources { for _, res := range grpcResources {
logger.Info("[GRPC Web] HTTP POST mounted", "resource", res) logger.Info("[GRPC Web] HTTP POST mounted", "resource", res)
s := router.Methods("POST").Subrouter() s := router.Methods("POST").Subrouter()

View File

@ -96,8 +96,12 @@ func (cc *ChainContext) Finalize(
// Note: The block header and state database might be updated to reflect any // Note: The block header and state database might be updated to reflect any
// consensus rules that happen at finalization (e.g. block rewards). // consensus rules that happen at finalization (e.g. block rewards).
// TODO: Figure out if this needs to be hooked up to any part of the ABCI? // TODO: Figure out if this needs to be hooked up to any part of the ABCI?
func (cc *ChainContext) FinalizeAndAssemble(_ ethcons.ChainHeaderReader, _ *ethtypes.Header, _ *ethstate.StateDB, _ []*ethtypes.Transaction, func (cc *ChainContext) FinalizeAndAssemble(_ ethcons.ChainHeaderReader,
_ []*ethtypes.Header, _ []*ethtypes.Receipt, _ *ethtypes.Header,
_ *ethstate.StateDB,
_ []*ethtypes.Transaction,
_ []*ethtypes.Header,
_ []*ethtypes.Receipt,
) (*ethtypes.Block, error) { ) (*ethtypes.Block, error) {
return nil, nil return nil, nil
} }

View File

@ -56,7 +56,7 @@ type ImporterTestSuite struct {
ctx sdk.Context ctx sdk.Context
} }
/// DoSetupTest setup test environment, it uses`require.TestingT` to support both `testing.T` and `testing.B`. // / DoSetupTest setup test environment, it uses`require.TestingT` to support both `testing.T` and `testing.B`.
func (suite *ImporterTestSuite) DoSetupTest(t require.TestingT) { func (suite *ImporterTestSuite) DoSetupTest(t require.TestingT) {
checkTx := false checkTx := false
suite.app = app.Setup(checkTx, nil) suite.app = app.Setup(checkTx, nil)

View File

@ -1,7 +1,5 @@
// This is a test utility for Ethermint's Web3 JSON-RPC services. // This is a test utility for Ethermint's Web3 JSON-RPC services.
//
// To run these tests please first ensure you have the ethermintd running // To run these tests please first ensure you have the ethermintd running
//
// You can configure the desired HOST and MODE as well in integration-test-all.sh // You can configure the desired HOST and MODE as well in integration-test-all.sh
package rpc package rpc

View File

@ -173,7 +173,7 @@ func DeployTestContract(t *testing.T, addr []byte) (hexutil.Bytes, map[string]in
param := make([]map[string]string, 1) param := make([]map[string]string, 1)
param[0] = make(map[string]string) param[0] = make(map[string]string)
param[0]["from"] = "0x" + fmt.Sprintf("%x", addr) param[0]["from"] = "0x" + fmt.Sprintf("%x", addr)
param[0]["data"] = "0x6080604052348015600f57600080fd5b5060117f775a94827b8fd9b519d36cd827093c664f93347070a554f65e4a6f56cd73889860405160405180910390a2603580604b6000396000f3fe6080604052600080fdfea165627a7a723058206cab665f0f557620554bb45adf266708d2bd349b8a4314bdff205ee8440e3c240029" param[0]["data"] = "0x6080604052348015600f57600080fd5b5060117f775a94827b8fd9b519d36cd827093c664f93347070a554f65e4a6f56cd73889860405160405180910390a2603580604b6000396000f3fe6080604052600080fdfea165627a7a723058206cab665f0f557620554bb45adf266708d2bd349b8a4314bdff205ee8440e3c240029" //nolint:lll
param[0]["gas"] = "0x200000" param[0]["gas"] = "0x200000"
rpcRes := Call(t, "personal_unlockAccount", []interface{}{param[0]["from"], ""}) rpcRes := Call(t, "personal_unlockAccount", []interface{}{param[0]["from"], ""})
@ -212,7 +212,7 @@ func DeployTestContractWithFunction(t *testing.T, addr []byte) hexutil.Bytes {
// } // }
// } // }
bytecode := "0x608060405234801561001057600080fd5b5060117f775a94827b8fd9b519d36cd827093c664f93347070a554f65e4a6f56cd73889860405160405180910390a260d08061004d6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c8063eb8ac92114602d575b600080fd5b606060048036036040811015604157600080fd5b8101908080359060200190929190803590602001909291905050506062565b005b8160008190555080827ff3ca124a697ba07e8c5e80bebcfcc48991fc16a63170e8a9206e30508960d00360405160405180910390a3505056fea265627a7a723158201d94d2187aaf3a6790527b615fcc40970febf0385fa6d72a2344848ebd0df3e964736f6c63430005110032" bytecode := "0x608060405234801561001057600080fd5b5060117f775a94827b8fd9b519d36cd827093c664f93347070a554f65e4a6f56cd73889860405160405180910390a260d08061004d6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c8063eb8ac92114602d575b600080fd5b606060048036036040811015604157600080fd5b8101908080359060200190929190803590602001909291905050506062565b005b8160008190555080827ff3ca124a697ba07e8c5e80bebcfcc48991fc16a63170e8a9206e30508960d00360405160405180910390a3505056fea265627a7a723158201d94d2187aaf3a6790527b615fcc40970febf0385fa6d72a2344848ebd0df3e964736f6c63430005110032" //nolint:lll
param := make([]map[string]string, 1) param := make([]map[string]string, 1)
param[0] = make(map[string]string) param[0] = make(map[string]string)

View File

@ -15,7 +15,12 @@ var (
regexEIP155 = `[1-9][0-9]*` regexEIP155 = `[1-9][0-9]*`
regexEpochSeparator = `-{1}` regexEpochSeparator = `-{1}`
regexEpoch = `[1-9][0-9]*` regexEpoch = `[1-9][0-9]*`
ethermintChainID = regexp.MustCompile(fmt.Sprintf(`^(%s)%s(%s)%s(%s)$`, regexChainID, regexEIP155Separator, regexEIP155, regexEpochSeparator, regexEpoch)) ethermintChainID = regexp.MustCompile(fmt.Sprintf(`^(%s)%s(%s)%s(%s)$`,
regexChainID,
regexEIP155Separator,
regexEIP155,
regexEpochSeparator,
regexEpoch))
) )
// IsValidChainID returns false if the given chain identifier is incorrectly formatted. // IsValidChainID returns false if the given chain identifier is incorrectly formatted.

View File

@ -33,7 +33,7 @@ func GetStorageCmd() *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "storage [address] [key]", Use: "storage [address] [key]",
Short: "Gets storage for an account with a given key and height", Short: "Gets storage for an account with a given key and height",
Long: "Gets storage for an account with a given key and height. If the height is not provided, it will use the latest height from context.", Long: "Gets storage for an account with a given key and height. If the height is not provided, it will use the latest height from context.", //nolint:lll
Args: cobra.ExactArgs(2), Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd) clientCtx, err := client.GetClientQueryContext(cmd)

View File

@ -62,7 +62,7 @@ type EvmTestSuite struct {
dynamicTxFee bool dynamicTxFee bool
} }
/// DoSetupTest setup test environment, it uses`require.TestingT` to support both `testing.T` and `testing.B`. // DoSetupTest setup test environment, it uses`require.TestingT` to support both `testing.T` and `testing.B`.
func (suite *EvmTestSuite) DoSetupTest(t require.TestingT) { func (suite *EvmTestSuite) DoSetupTest(t require.TestingT) {
checkTx := false checkTx := false

View File

@ -93,7 +93,7 @@ func (suite *KeeperTestSuite) SetupTest() {
suite.SetupApp(checkTx) suite.SetupApp(checkTx)
} }
/// SetupApp setup test environment, it uses`require.TestingT` to support both `testing.T` and `testing.B`. // SetupApp setup test environment, it uses`require.TestingT` to support both `testing.T` and `testing.B`.
func (suite *KeeperTestSuite) SetupApp(checkTx bool) { func (suite *KeeperTestSuite) SetupApp(checkTx bool) {
t := suite.T() t := suite.T()
// account key, use a constant account to keep unit test deterministic. // account key, use a constant account to keep unit test deterministic.

View File

@ -343,7 +343,13 @@ func (k *Keeper) ApplyTransaction(ctx sdk.Context, tx *ethtypes.Transaction) (*t
// # Commit parameter // # Commit parameter
// //
// If commit is true, the `StateDB` will be committed, otherwise discarded. // If commit is true, the `StateDB` will be committed, otherwise discarded.
func (k *Keeper) ApplyMessageWithConfig(ctx sdk.Context, msg core.Message, tracer vm.EVMLogger, commit bool, cfg *types.EVMConfig, txConfig statedb.TxConfig) (*types.MsgEthereumTxResponse, error) { func (k *Keeper) ApplyMessageWithConfig(ctx sdk.Context,
msg core.Message,
tracer vm.EVMLogger,
commit bool,
cfg *types.EVMConfig,
txConfig statedb.TxConfig,
) (*types.MsgEthereumTxResponse, error) {
var ( var (
ret []byte // return bytes from evm execution ret []byte // return bytes from evm execution
vmErr error // vm errors do not effect consensus and are therefore not assigned to err vmErr error // vm errors do not effect consensus and are therefore not assigned to err

View File

@ -60,7 +60,10 @@ func (k Keeper) DeductTxCostsFromUserBalance(
baseFee := k.getBaseFee(ctx, london) baseFee := k.getBaseFee(ctx, london)
if baseFee != nil && txData.GetGasFeeCap().Cmp(baseFee) < 0 { if baseFee != nil && txData.GetGasFeeCap().Cmp(baseFee) < 0 {
return nil, 0, sdkerrors.Wrapf(sdkerrors.ErrInsufficientFee, "the tx gasfeecap is lower than the tx baseFee: %s (gasfeecap), %s (basefee) ", txData.GetGasFeeCap(), baseFee) return nil, 0, sdkerrors.Wrapf(sdkerrors.ErrInsufficientFee,
"the tx gasfeecap is lower than the tx baseFee: %s (gasfeecap), %s (basefee) ",
txData.GetGasFeeCap(),
baseFee)
} }
feeAmt = txData.EffectiveFee(baseFee) feeAmt = txData.EffectiveFee(baseFee)

View File

@ -115,7 +115,8 @@ func SimulateEthSimpleTransfer(ak types.AccountKeeper, k *keeper.Keeper) simtype
} }
// SimulateEthCreateContract simulate create an ERC20 contract. // SimulateEthCreateContract simulate create an ERC20 contract.
// It makes operationSimulateEthCallContract the future operations of SimulateEthCreateContract to ensure valid contract call. // It makes operationSimulateEthCallContract the future operations of SimulateEthCreateContract
// to ensure valid contract call.
func SimulateEthCreateContract(ak types.AccountKeeper, k *keeper.Keeper) simtypes.Operation { func SimulateEthCreateContract(ak types.AccountKeeper, k *keeper.Keeper) simtypes.Operation {
return func( return func(
r *rand.Rand, bapp *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, r *rand.Rand, bapp *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string,
@ -203,7 +204,12 @@ func SimulateEthTx(
} }
// CreateRandomValidEthTx create the ethereum tx with valid random values // CreateRandomValidEthTx create the ethereum tx with valid random values
func CreateRandomValidEthTx(ctx *simulateContext, from, to *common.Address, amount *big.Int, data *hexutil.Bytes) (ethTx *types.MsgEthereumTx, err error) { func CreateRandomValidEthTx(ctx *simulateContext,
from,
to *common.Address,
amount *big.Int,
data *hexutil.Bytes,
) (ethTx *types.MsgEthereumTx, err error) {
gasCap := ctx.rand.Uint64() gasCap := ctx.rand.Uint64()
estimateGas, err := EstimateGas(ctx, from, to, data, gasCap) estimateGas, err := EstimateGas(ctx, from, to, data, gasCap)
if err != nil { if err != nil {
@ -269,7 +275,12 @@ func RandomTransferableAmount(ctx *simulateContext, address common.Address, esti
} }
// GetSignedTx sign the ethereum tx and packs it as a signing.Tx . // GetSignedTx sign the ethereum tx and packs it as a signing.Tx .
func GetSignedTx(ctx *simulateContext, txBuilder client.TxBuilder, msg *types.MsgEthereumTx, prv cryptotypes.PrivKey) (signedTx signing.Tx, err error) { func GetSignedTx(
ctx *simulateContext,
txBuilder client.TxBuilder,
msg *types.MsgEthereumTx,
prv cryptotypes.PrivKey,
) (signedTx signing.Tx, err error) {
builder, ok := txBuilder.(tx.ExtensionOptionsTxBuilder) builder, ok := txBuilder.(tx.ExtensionOptionsTxBuilder)
if !ok { if !ok {
return nil, fmt.Errorf("can not initiate ExtensionOptionsTxBuilder") return nil, fmt.Errorf("can not initiate ExtensionOptionsTxBuilder")

View File

@ -60,7 +60,13 @@ func NewNoOpTracer() *NoOpTracer {
} }
// CaptureStart implements vm.Tracer interface // CaptureStart implements vm.Tracer interface
func (dt NoOpTracer) CaptureStart(env *vm.EVM, from common.Address, to common.Address, create bool, input []byte, gas uint64, value *big.Int) { func (dt NoOpTracer) CaptureStart(env *vm.EVM,
from common.Address,
to common.Address,
create bool,
input []byte,
gas uint64,
value *big.Int) {
} }
// CaptureState implements vm.Tracer interface // CaptureState implements vm.Tracer interface

View File

@ -69,7 +69,7 @@ func TestKeeperTestSuite(t *testing.T) {
RunSpecs(t, "Keeper Suite") RunSpecs(t, "Keeper Suite")
} }
/// SetupTest setup test environment, it uses`require.TestingT` to support both `testing.T` and `testing.B`. // SetupTest setup test environment, it uses`require.TestingT` to support both `testing.T` and `testing.B`.
func (suite *KeeperTestSuite) SetupTest() { func (suite *KeeperTestSuite) SetupTest() {
checkTx := false checkTx := false
suite.app = app.Setup(checkTx, nil) suite.app = app.Setup(checkTx, nil)

View File

@ -12,7 +12,13 @@ import (
// RandomizedGenState generates a random GenesisState for nft // RandomizedGenState generates a random GenesisState for nft
func RandomizedGenState(simState *module.SimulationState) { func RandomizedGenState(simState *module.SimulationState) {
params := types.NewParams(simState.Rand.Uint32()%2 == 0, simState.Rand.Uint32(), simState.Rand.Uint32(), simState.Rand.Uint64(), simState.Rand.Int63(), sdk.ZeroDec(), types.DefaultMinGasMultiplier) params := types.NewParams(simState.Rand.Uint32()%2 == 0,
simState.Rand.Uint32(),
simState.Rand.Uint32(),
simState.Rand.Uint64(),
simState.Rand.Int63(),
sdk.ZeroDec(),
types.DefaultMinGasMultiplier)
blockGas := simState.Rand.Uint64() blockGas := simState.Rand.Uint64()
feemarketGenesis := types.NewGenesisState(params, blockGas) feemarketGenesis := types.NewGenesisState(params, blockGas)