evm: fix EndBlock
panic (#51)
This commit is contained in:
parent
73dac6f5b1
commit
0805bf80e5
@ -230,7 +230,7 @@ func NewEthermintApp(
|
|||||||
cdc := encodingConfig.Amino
|
cdc := encodingConfig.Amino
|
||||||
interfaceRegistry := encodingConfig.InterfaceRegistry
|
interfaceRegistry := encodingConfig.InterfaceRegistry
|
||||||
|
|
||||||
// NOTE we use custom Injective transaction decoder that supports the sdk.Tx interface instead of sdk.StdTx
|
// NOTE we use custom transaction decoder that supports the sdk.Tx interface instead of sdk.StdTx
|
||||||
bApp := baseapp.NewBaseApp(
|
bApp := baseapp.NewBaseApp(
|
||||||
appName,
|
appName,
|
||||||
logger,
|
logger,
|
||||||
@ -383,7 +383,7 @@ func NewEthermintApp(
|
|||||||
ibc.NewAppModule(app.IBCKeeper),
|
ibc.NewAppModule(app.IBCKeeper),
|
||||||
params.NewAppModule(app.ParamsKeeper),
|
params.NewAppModule(app.ParamsKeeper),
|
||||||
transferModule,
|
transferModule,
|
||||||
// Injective app modules
|
// Ethermint app modules
|
||||||
evm.NewAppModule(app.EvmKeeper, app.AccountKeeper, app.BankKeeper),
|
evm.NewAppModule(app.EvmKeeper, app.AccountKeeper, app.BankKeeper),
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -413,7 +413,7 @@ func NewEthermintApp(
|
|||||||
capabilitytypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName, distrtypes.ModuleName, stakingtypes.ModuleName,
|
capabilitytypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName, distrtypes.ModuleName, stakingtypes.ModuleName,
|
||||||
slashingtypes.ModuleName, govtypes.ModuleName, minttypes.ModuleName,
|
slashingtypes.ModuleName, govtypes.ModuleName, minttypes.ModuleName,
|
||||||
ibchost.ModuleName, genutiltypes.ModuleName, evidencetypes.ModuleName, ibctransfertypes.ModuleName,
|
ibchost.ModuleName, genutiltypes.ModuleName, evidencetypes.ModuleName, ibctransfertypes.ModuleName,
|
||||||
// Injective modules
|
// Ethermint modules
|
||||||
evmtypes.ModuleName,
|
evmtypes.ModuleName,
|
||||||
|
|
||||||
// NOTE: crisis module must go at the end to check for invariants on each module
|
// NOTE: crisis module must go at the end to check for invariants on each module
|
||||||
@ -457,7 +457,7 @@ func NewEthermintApp(
|
|||||||
app.SetInitChainer(app.InitChainer)
|
app.SetInitChainer(app.InitChainer)
|
||||||
app.SetBeginBlocker(app.BeginBlocker)
|
app.SetBeginBlocker(app.BeginBlocker)
|
||||||
|
|
||||||
// use Injective's custom AnteHandler
|
// use Ethermint's custom AnteHandler
|
||||||
app.SetAnteHandler(
|
app.SetAnteHandler(
|
||||||
ante.NewAnteHandler(
|
ante.NewAnteHandler(
|
||||||
app.AccountKeeper, app.BankKeeper, app.EvmKeeper,
|
app.AccountKeeper, app.BankKeeper, app.EvmKeeper,
|
||||||
|
@ -4,16 +4,13 @@ package client
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"bytes"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
|
||||||
|
|
||||||
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
|
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
|
||||||
|
|
||||||
@ -47,8 +44,6 @@ import (
|
|||||||
evmtypes "github.com/cosmos/ethermint/x/evm/types"
|
evmtypes "github.com/cosmos/ethermint/x/evm/types"
|
||||||
|
|
||||||
"github.com/cosmos/ethermint/cmd/ethermintd/config"
|
"github.com/cosmos/ethermint/cmd/ethermintd/config"
|
||||||
"github.com/cosmos/ethermint/crypto/ethsecp256k1"
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -136,7 +131,7 @@ func InitTestnet(
|
|||||||
) error {
|
) error {
|
||||||
|
|
||||||
if chainID == "" {
|
if chainID == "" {
|
||||||
chainID = fmt.Sprintf("injective-%d", tmrand.Int63n(9999999999999)+1)
|
chainID = fmt.Sprintf("ethermint-%d", tmrand.Int63n(9999999999999)+1)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !chaintypes.IsValidChainID(chainID) {
|
if !chaintypes.IsValidChainID(chainID) {
|
||||||
@ -297,9 +292,6 @@ func InitTestnet(
|
|||||||
}
|
}
|
||||||
|
|
||||||
config.WriteConfigFile(filepath.Join(nodeDir, "config/app.toml"), appConfig)
|
config.WriteConfigFile(filepath.Join(nodeDir, "config/app.toml"), appConfig)
|
||||||
|
|
||||||
ethPrivKey, err := keyring.NewUnsafe(kb).UnsafeExportPrivKeyHex(nodeDirName)
|
|
||||||
initPeggo(outputDir, nodeDirName, []byte(strings.ToUpper(ethPrivKey)))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := initGenFiles(clientCtx, mbm, chainID, coinDenom, genAccounts, genBalances, genFiles, numValidators); err != nil {
|
if err := initGenFiles(clientCtx, mbm, chainID, coinDenom, genAccounts, genBalances, genFiles, numValidators); err != nil {
|
||||||
@ -318,32 +310,6 @@ func InitTestnet(
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func initPeggo(outputDir string, nodeDirName string, privKey []byte) {
|
|
||||||
peggoDir := filepath.Join(outputDir, nodeDirName, "peggo")
|
|
||||||
if envdata, _ := ioutil.ReadFile("./templates/peggo_config.template"); len(envdata) > 0 {
|
|
||||||
s := bufio.NewScanner(bytes.NewReader(envdata))
|
|
||||||
for s.Scan() {
|
|
||||||
parts := strings.Split(s.Text(), "=")
|
|
||||||
if len(parts) != 2 {
|
|
||||||
continue
|
|
||||||
} else {
|
|
||||||
content := []byte(s.Text())
|
|
||||||
if parts[0] == "PEGGY_COSMOS_PRIVKEY" {
|
|
||||||
content = append([]byte(parts[0]+"="), privKey...)
|
|
||||||
} else if parts[0] == "PEGGY_ETH_PRIVATE_KEY" {
|
|
||||||
newPrivkey, _ := ethsecp256k1.GenerateKey()
|
|
||||||
privKeyStr := common.Bytes2Hex(newPrivkey.GetKey())
|
|
||||||
privKeyBytes := []byte(strings.ToUpper(privKeyStr))
|
|
||||||
content = append([]byte(parts[0]+"="), privKeyBytes...)
|
|
||||||
}
|
|
||||||
if err := appendToFile(fmt.Sprintf("config.env"), peggoDir, content); err != nil {
|
|
||||||
fmt.Println("Error writing peggo config", "error", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func initGenFiles(
|
func initGenFiles(
|
||||||
clientCtx client.Context,
|
clientCtx client.Context,
|
||||||
mbm module.BasicManager,
|
mbm module.BasicManager,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// 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 injectived running
|
// To run these tests please first ensure you have the ethermintd running
|
||||||
// and have started the RPC service with `injectived rest-server`.
|
// and have started the RPC service with `ethermintd rest-server`.
|
||||||
//
|
//
|
||||||
// You can configure the desired HOST and MODE as well
|
// You can configure the desired HOST and MODE as well
|
||||||
package rpc
|
package rpc
|
||||||
|
@ -45,6 +45,7 @@ func (k Keeper) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) []abci.Valid
|
|||||||
// Gas costs are handled within msg handler so costs should be ignored
|
// Gas costs are handled within msg handler so costs should be ignored
|
||||||
ctx = ctx.WithGasMeter(sdk.NewInfiniteGasMeter())
|
ctx = ctx.WithGasMeter(sdk.NewInfiniteGasMeter())
|
||||||
k.CommitStateDB.WithContext(ctx)
|
k.CommitStateDB.WithContext(ctx)
|
||||||
|
k.WithContext(ctx)
|
||||||
|
|
||||||
// Update account balances before committing other parts of state
|
// Update account balances before committing other parts of state
|
||||||
k.CommitStateDB.UpdateAccounts()
|
k.CommitStateDB.UpdateAccounts()
|
||||||
|
Loading…
Reference in New Issue
Block a user