Daemon framework (#66)
* Implements daemon framework with basic functionality * Comment out unused functions for linter
This commit is contained in:
parent
1d490ba4d9
commit
d982e0961a
@ -1,15 +1,19 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"github.com/cosmos/ethermint/x/evm"
|
||||
"os"
|
||||
|
||||
"github.com/cosmos/ethermint/x/evm"
|
||||
|
||||
bam "github.com/cosmos/cosmos-sdk/baseapp"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/module"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank"
|
||||
distr "github.com/cosmos/cosmos-sdk/x/distribution"
|
||||
"github.com/cosmos/cosmos-sdk/x/genaccounts"
|
||||
"github.com/cosmos/cosmos-sdk/x/genutil"
|
||||
"github.com/cosmos/cosmos-sdk/x/gov"
|
||||
"github.com/cosmos/cosmos-sdk/x/mint"
|
||||
"github.com/cosmos/cosmos-sdk/x/params"
|
||||
@ -35,6 +39,22 @@ var (
|
||||
// default home directories for the application CLI
|
||||
DefaultCLIHome = os.ExpandEnv("$HOME/.emintcli")
|
||||
|
||||
// DefaultNodeHome sets the folder where the applcation data and configuration will be stored
|
||||
DefaultNodeHome = os.ExpandEnv("$HOME/.emintd")
|
||||
|
||||
// ModuleBasics is in charge of setting up basic module elements
|
||||
ModuleBasics = module.NewBasicManager(
|
||||
genaccounts.AppModuleBasic{},
|
||||
genutil.AppModuleBasic{},
|
||||
auth.AppModuleBasic{},
|
||||
bank.AppModuleBasic{},
|
||||
params.AppModuleBasic{},
|
||||
evm.AppModuleBasic{},
|
||||
staking.AppModuleBasic{},
|
||||
distr.AppModuleBasic{},
|
||||
slashing.AppModuleBasic{},
|
||||
)
|
||||
|
||||
storeKeyAccount = sdk.NewKVStoreKey("acc")
|
||||
storeKeyStorage = sdk.NewKVStoreKey("contract_storage")
|
||||
storeKeyMain = sdk.NewKVStoreKey("main")
|
||||
@ -46,34 +66,41 @@ var (
|
||||
storeKeyTransParams = sdk.NewTransientStoreKey("transient_params")
|
||||
)
|
||||
|
||||
type (
|
||||
// EthermintApp implements an extended ABCI application. It is an application
|
||||
// that may process transactions through Ethereum's EVM running atop of
|
||||
// Tendermint consensus.
|
||||
EthermintApp struct {
|
||||
*bam.BaseApp
|
||||
// MakeCodec generates the necessary codecs for Amino
|
||||
func MakeCodec() *codec.Codec {
|
||||
var cdc = codec.New()
|
||||
ModuleBasics.RegisterCodec(cdc)
|
||||
sdk.RegisterCodec(cdc)
|
||||
codec.RegisterCrypto(cdc)
|
||||
return cdc
|
||||
}
|
||||
|
||||
cdc *codec.Codec
|
||||
// EthermintApp implements an extended ABCI application. It is an application
|
||||
// that may process transactions through Ethereum's EVM running atop of
|
||||
// Tendermint consensus.
|
||||
type EthermintApp struct {
|
||||
*bam.BaseApp
|
||||
|
||||
accountKey *sdk.KVStoreKey
|
||||
storageKey *sdk.KVStoreKey
|
||||
mainKey *sdk.KVStoreKey
|
||||
stakeKey *sdk.KVStoreKey
|
||||
slashingKey *sdk.KVStoreKey
|
||||
govKey *sdk.KVStoreKey
|
||||
supplyKey *sdk.KVStoreKey
|
||||
paramsKey *sdk.KVStoreKey
|
||||
tParamsKey *sdk.TransientStoreKey
|
||||
cdc *codec.Codec
|
||||
|
||||
accountKeeper auth.AccountKeeper
|
||||
supplyKeeper supply.Keeper
|
||||
bankKeeper bank.Keeper
|
||||
stakeKeeper staking.Keeper
|
||||
slashingKeeper slashing.Keeper
|
||||
govKeeper gov.Keeper
|
||||
paramsKeeper params.Keeper
|
||||
}
|
||||
)
|
||||
accountKey *sdk.KVStoreKey
|
||||
storageKey *sdk.KVStoreKey
|
||||
mainKey *sdk.KVStoreKey
|
||||
stakeKey *sdk.KVStoreKey
|
||||
slashingKey *sdk.KVStoreKey
|
||||
govKey *sdk.KVStoreKey
|
||||
supplyKey *sdk.KVStoreKey
|
||||
paramsKey *sdk.KVStoreKey
|
||||
tParamsKey *sdk.TransientStoreKey
|
||||
|
||||
accountKeeper auth.AccountKeeper
|
||||
supplyKeeper supply.Keeper
|
||||
bankKeeper bank.Keeper
|
||||
stakeKeeper staking.Keeper
|
||||
slashingKeeper slashing.Keeper
|
||||
govKeeper gov.Keeper
|
||||
paramsKeeper params.Keeper
|
||||
}
|
||||
|
||||
// NewEthermintApp returns a reference to a new initialized Ethermint
|
||||
// application.
|
||||
|
@ -1,7 +1,79 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/server"
|
||||
"github.com/cosmos/cosmos-sdk/x/genaccounts"
|
||||
genaccscli "github.com/cosmos/cosmos-sdk/x/genaccounts/client/cli"
|
||||
"github.com/cosmos/cosmos-sdk/x/staking"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/tendermint/tendermint/libs/cli"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli"
|
||||
emintapp "github.com/cosmos/ethermint/app"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// TODO: Implement daemon command and logic
|
||||
//
|
||||
// Ref: https://github.com/cosmos/ethermint/issues/433
|
||||
cobra.EnableCommandSorting = false
|
||||
|
||||
cdc := emintapp.MakeCodec()
|
||||
|
||||
config := sdk.GetConfig()
|
||||
config.SetBech32PrefixForAccount(sdk.Bech32PrefixAccAddr, sdk.Bech32PrefixAccPub)
|
||||
config.SetBech32PrefixForValidator(sdk.Bech32PrefixValAddr, sdk.Bech32PrefixValPub)
|
||||
config.SetBech32PrefixForConsensusNode(sdk.Bech32PrefixConsAddr, sdk.Bech32PrefixConsPub)
|
||||
config.Seal()
|
||||
|
||||
ctx := server.NewDefaultContext()
|
||||
|
||||
rootCmd := &cobra.Command{
|
||||
Use: "emintd",
|
||||
Short: "Ethermint App Daemon (server)",
|
||||
PersistentPreRunE: server.PersistentPreRunEFn(ctx),
|
||||
}
|
||||
// CLI commands to initialize the chain
|
||||
rootCmd.AddCommand(
|
||||
genutilcli.InitCmd(ctx, cdc, emintapp.ModuleBasics, emintapp.DefaultNodeHome),
|
||||
genutilcli.CollectGenTxsCmd(ctx, cdc, genaccounts.AppModuleBasic{}, emintapp.DefaultNodeHome),
|
||||
genutilcli.GenTxCmd(ctx, cdc, emintapp.ModuleBasics, staking.AppModuleBasic{}, genaccounts.AppModuleBasic{}, emintapp.DefaultNodeHome, emintapp.DefaultCLIHome),
|
||||
genutilcli.ValidateGenesisCmd(ctx, cdc, emintapp.ModuleBasics),
|
||||
|
||||
// AddGenesisAccountCmd allows users to add accounts to the genesis file
|
||||
genaccscli.AddGenesisAccountCmd(ctx, cdc, emintapp.DefaultNodeHome, emintapp.DefaultCLIHome),
|
||||
)
|
||||
|
||||
// TODO: Add export app state and TM validators commands
|
||||
// server.AddCommands(ctx, cdc, rootCmd, newApp, exportAppStateAndTMValidators)
|
||||
|
||||
// prepare and add flags
|
||||
executor := cli.PrepareBaseCmd(rootCmd, "EM", emintapp.DefaultNodeHome)
|
||||
err := executor.Execute()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// func newApp(logger log.Logger, db dbm.DB, traceStore io.Writer) abci.Application {
|
||||
// return emintapp.NewEthermintApp(logger, db)
|
||||
// }
|
||||
|
||||
// func exportAppStateAndTMValidators(
|
||||
// logger log.Logger, db dbm.DB, traceStore io.Writer, height int64, forZeroHeight bool, jailWhiteList []string,
|
||||
// ) (json.RawMessage, []tmtypes.GenesisValidator, error) {
|
||||
|
||||
// // if height != -1 {
|
||||
// // emintApp := emintapp.NewEthermintApp(logger, db)
|
||||
// // err := emintApp.LoadHeight(height)
|
||||
// // if err != nil {
|
||||
// // return nil, nil, err
|
||||
// // }
|
||||
// // return emintApp.ExportAppStateAndValidators(forZeroHeight, jailWhiteList)
|
||||
// // }
|
||||
|
||||
// // emintApp := emintapp.NewEthermintApp(logger, db)
|
||||
|
||||
// // return emintApp.ExportAppStateAndValidators(forZeroHeight, jailWhiteList)
|
||||
// // TODO: Unstub method
|
||||
// return json.RawMessage{}, []tmtypes.GenesisValidator{}, nil
|
||||
// }
|
||||
|
1
go.mod
1
go.mod
@ -14,6 +14,7 @@ require (
|
||||
github.com/golangci/golangci-lint v1.17.1 // indirect
|
||||
github.com/google/uuid v1.0.0 // indirect
|
||||
github.com/gordonklaus/ineffassign v0.0.0-20190601041439-ed7b1b5ee0f8 // indirect
|
||||
github.com/gorilla/mux v1.7.0
|
||||
github.com/hashicorp/golang-lru v0.5.0 // indirect
|
||||
github.com/huin/goupnp v1.0.0 // indirect
|
||||
github.com/influxdata/influxdb v1.7.7 // indirect
|
||||
|
Loading…
Reference in New Issue
Block a user