diff options
-rw-r--r-- | cmd/geth/config.go | 19 | ||||
-rw-r--r-- | cmd/utils/flags.go | 50 | ||||
-rw-r--r-- | consensus/dexcon/dexcon.go | 4 | ||||
-rw-r--r-- | dex/app.go | 26 | ||||
-rw-r--r-- | dex/backend.go | 16 | ||||
-rw-r--r-- | dex/config.go | 45 | ||||
-rw-r--r-- | dex/governance.go | 3 |
7 files changed, 37 insertions, 126 deletions
diff --git a/cmd/geth/config.go b/cmd/geth/config.go index f1e281196..6e37fd397 100644 --- a/cmd/geth/config.go +++ b/cmd/geth/config.go @@ -20,7 +20,6 @@ import ( "bufio" "errors" "fmt" - "math/big" "os" "reflect" "unicode" @@ -29,7 +28,7 @@ import ( "github.com/ethereum/go-ethereum/cmd/utils" "github.com/ethereum/go-ethereum/dashboard" - "github.com/ethereum/go-ethereum/eth" + "github.com/ethereum/go-ethereum/dex" "github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/params" whisper "github.com/ethereum/go-ethereum/whisper/whisperv6" @@ -75,7 +74,7 @@ type ethstatsConfig struct { } type gethConfig struct { - Eth eth.Config + Dex dex.Config Shh whisper.Config Node node.Config Ethstats ethstatsConfig @@ -110,7 +109,7 @@ func defaultNodeConfig() node.Config { func makeConfigNode(ctx *cli.Context) (*node.Node, gethConfig) { // Load defaults. cfg := gethConfig{ - Eth: eth.DefaultConfig, + Dex: dex.DefaultConfig, Shh: whisper.DefaultConfig, Node: defaultNodeConfig(), Dashboard: dashboard.DefaultConfig, @@ -129,7 +128,7 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, gethConfig) { if err != nil { utils.Fatalf("Failed to create the protocol stack: %v", err) } - utils.SetEthConfig(ctx, stack, &cfg.Eth) + utils.SetDexConfig(ctx, stack, &cfg.Dex) if ctx.GlobalIsSet(utils.EthStatsURLFlag.Name) { cfg.Ethstats.URL = ctx.GlobalString(utils.EthStatsURLFlag.Name) } @@ -152,10 +151,8 @@ func enableWhisper(ctx *cli.Context) bool { func makeFullNode(ctx *cli.Context) *node.Node { stack, cfg := makeConfigNode(ctx) - if ctx.GlobalIsSet(utils.ConstantinopleOverrideFlag.Name) { - cfg.Eth.ConstantinopleOverride = new(big.Int).SetUint64(ctx.GlobalUint64(utils.ConstantinopleOverrideFlag.Name)) - } - utils.RegisterEthService(stack, &cfg.Eth) + + utils.RegisterDexService(stack, &cfg.Dex) if ctx.GlobalBool(utils.DashboardEnabledFlag.Name) { utils.RegisterDashboardService(stack, &cfg.Dashboard, gitCommit) @@ -188,8 +185,8 @@ func dumpConfig(ctx *cli.Context) error { _, cfg := makeConfigNode(ctx) comment := "" - if cfg.Eth.Genesis != nil { - cfg.Eth.Genesis = nil + if cfg.Dex.Genesis != nil { + cfg.Dex.Genesis = nil comment += "# Note: this config doesn't contain the genesis block.\n\n" } diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index b75a67ca5..c9f81b400 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -1175,18 +1175,15 @@ func SetShhConfig(ctx *cli.Context, stack *node.Node, cfg *whisper.Config) { } } -// SetEthConfig applies eth-related command line flags to the config. -func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) { +// SetDexConfig applies eth-related command line flags to the config. +func SetDexConfig(ctx *cli.Context, stack *node.Node, cfg *dex.Config) { // Avoid conflicting network flags checkExclusive(ctx, DeveloperFlag, TestnetFlag, RinkebyFlag, GoerliFlag) checkExclusive(ctx, LightServFlag, SyncModeFlag, "light") ks := stack.AccountManager().Backends(keystore.KeyStoreType)[0].(*keystore.KeyStore) - setEtherbase(ctx, ks, cfg) setGPO(ctx, &cfg.GPO) setTxPool(ctx, &cfg.TxPool) - setEthash(ctx, cfg) - setWhitelist(ctx, cfg) if ctx.GlobalIsSet(SyncModeFlag.Name) { cfg.SyncMode = *GlobalTextMarshaler(ctx, SyncModeFlag.Name).(*downloader.SyncMode) @@ -1216,39 +1213,9 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) { if ctx.GlobalIsSet(CacheFlag.Name) || ctx.GlobalIsSet(CacheGCFlag.Name) { cfg.TrieDirtyCache = ctx.GlobalInt(CacheFlag.Name) * ctx.GlobalInt(CacheGCFlag.Name) / 100 } - if ctx.GlobalIsSet(MinerNotifyFlag.Name) { - cfg.MinerNotify = strings.Split(ctx.GlobalString(MinerNotifyFlag.Name), ",") - } if ctx.GlobalIsSet(DocRootFlag.Name) { cfg.DocRoot = ctx.GlobalString(DocRootFlag.Name) } - if ctx.GlobalIsSet(MinerLegacyExtraDataFlag.Name) { - cfg.MinerExtraData = []byte(ctx.GlobalString(MinerLegacyExtraDataFlag.Name)) - } - if ctx.GlobalIsSet(MinerExtraDataFlag.Name) { - cfg.MinerExtraData = []byte(ctx.GlobalString(MinerExtraDataFlag.Name)) - } - if ctx.GlobalIsSet(MinerLegacyGasTargetFlag.Name) { - cfg.MinerGasFloor = ctx.GlobalUint64(MinerLegacyGasTargetFlag.Name) - } - if ctx.GlobalIsSet(MinerGasTargetFlag.Name) { - cfg.MinerGasFloor = ctx.GlobalUint64(MinerGasTargetFlag.Name) - } - if ctx.GlobalIsSet(MinerGasLimitFlag.Name) { - cfg.MinerGasCeil = ctx.GlobalUint64(MinerGasLimitFlag.Name) - } - if ctx.GlobalIsSet(MinerLegacyGasPriceFlag.Name) { - cfg.MinerGasPrice = GlobalBig(ctx, MinerLegacyGasPriceFlag.Name) - } - if ctx.GlobalIsSet(MinerGasPriceFlag.Name) { - cfg.MinerGasPrice = GlobalBig(ctx, MinerGasPriceFlag.Name) - } - if ctx.GlobalIsSet(MinerRecommitIntervalFlag.Name) { - cfg.MinerRecommit = ctx.Duration(MinerRecommitIntervalFlag.Name) - } - if ctx.GlobalIsSet(MinerNoVerfiyFlag.Name) { - cfg.MinerNoverify = ctx.Bool(MinerNoVerfiyFlag.Name) - } if ctx.GlobalIsSet(VMEnableDebugFlag.Name) { // TODO(fjl): force-enable this in --dev mode cfg.EnablePreimageRecording = ctx.GlobalBool(VMEnableDebugFlag.Name) @@ -1305,9 +1272,6 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) { log.Info("Using developer account", "address", developer.Address) cfg.Genesis = core.DeveloperGenesisBlock(uint64(ctx.GlobalInt(DeveloperPeriodFlag.Name)), developer.Address) - if !ctx.GlobalIsSet(MinerGasPriceFlag.Name) && !ctx.GlobalIsSet(MinerLegacyGasPriceFlag.Name) { - cfg.MinerGasPrice = big.NewInt(1) - } } // TODO(fjl): move trie cache generations into config if gen := ctx.GlobalInt(TrieCacheGenFlag.Name); gen > 0 { @@ -1322,13 +1286,13 @@ func SetDashboardConfig(ctx *cli.Context, cfg *dashboard.Config) { cfg.Refresh = ctx.GlobalDuration(DashboardRefreshFlag.Name) } -// RegisterEthService adds an Ethereum client to the stack. -func RegisterEthService(stack *node.Node, cfg *eth.Config) { +// RegisterDexService adds an Dexon client to the stack. +func RegisterDexService(stack *node.Node, cfg *dex.Config) { var err error if cfg.SyncMode == downloader.LightSync { - err = stack.Register(func(ctx *node.ServiceContext) (node.Service, error) { - return les.New(ctx, cfg) - }) + //err = stack.Register(func(ctx *node.ServiceContext) (node.Service, error) { + // return les.New(ctx, cfg) + //}) } else { err = stack.Register(func(ctx *node.ServiceContext) (node.Service, error) { fullNode, err := dex.New(ctx, cfg) diff --git a/consensus/dexcon/dexcon.go b/consensus/dexcon/dexcon.go index bbdd06ed8..2f9eaa046 100644 --- a/consensus/dexcon/dexcon.go +++ b/consensus/dexcon/dexcon.go @@ -27,6 +27,10 @@ import ( "github.com/ethereum/go-ethereum/rpc" ) +// Config is the configuration for DEXON consensus. +type Config struct { +} + // Dexcon is a delegated proof-of-stake consensus engine. type Dexcon struct { config *params.DexconConfig diff --git a/dex/app.go b/dex/app.go index f87f669fb..21857f3c6 100644 --- a/dex/app.go +++ b/dex/app.go @@ -18,9 +18,6 @@ package dex import ( - "time" - - "github.com/dexon-foundation/dexon-consensus-core/common" "github.com/dexon-foundation/dexon-consensus-core/core/types" "github.com/ethereum/go-ethereum/core" @@ -45,26 +42,13 @@ func (d *DexconApp) PreparePayload(position types.Position) []byte { return nil } -// VerifyPayloads verifies if the payloads are valid. -func (d *DexconApp) VerifyPayloads(payloads []byte) bool { +// VerifyPayload verifies if the payloads are valid. +func (d *DexconApp) VerifyPayload(payload []byte) bool { return true } -// BlockConfirmed is called when a block is confirmed and added to lattice. -func (d *DexconApp) BlockConfirmed(block *types.Block) { -} - -// StronglyAcked is called when a block is strongly acked. -func (d *DexconApp) StronglyAcked(blockHash common.Hash) { -} - -// TotalOrderingDeliver is called when the total ordering algorithm deliver -// a set of block. -func (d *DexconApp) TotalOrderingDeliver(blockHashes common.Hashes, early bool) { -} - -// DeliverBlock is called when a block is add to the compaction chain. -func (d *DexconApp) DeliverBlock(blockHash common.Hash, timestamp time.Time) { +// BlockDelivered is called when a block is add to the compaction chain. +func (d *DexconApp) BlockDelivered(block types.Block) { } // BlockProcessedChan returns a channel to receive the block hashes that have @@ -74,5 +58,5 @@ func (d *DexconApp) BlockProcessedChan() <-chan types.WitnessResult { } // WitnessAckDeliver is called when a notary ack is created. -func (d *DexconApp) WitnessAckDeliver(notaryAck *types.WitnessAck) { +func (d *DexconApp) WitnessAckDelivered(notaryAck *types.WitnessAck) { } diff --git a/dex/backend.go b/dex/backend.go index c313f590b..1da083984 100644 --- a/dex/backend.go +++ b/dex/backend.go @@ -18,20 +18,15 @@ package dex import ( - "math/big" - "sync" - dexCore "github.com/dexon-foundation/dexon-consensus-core/core" "github.com/dexon-foundation/dexon-consensus-core/core/blockdb" ethCrypto "github.com/dexon-foundation/dexon-consensus-core/crypto/eth" "github.com/dexon-foundation/dexon/internal/ethapi" "github.com/ethereum/go-ethereum/accounts" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/consensus" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/bloombits" - "github.com/ethereum/go-ethereum/eth" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/node" @@ -42,7 +37,7 @@ import ( // Dexon implementes the DEXON fullnode service. type Dexon struct { - config *eth.Config + config *Config chainConfig *params.ChainConfig // Channel for shutting down the service @@ -60,9 +55,6 @@ type Dexon struct { bloomRequests chan chan *bloombits.Retrieval // Channel receiving bloom data retrieval requests bloomIndexer *core.ChainIndexer // Bloom indexer operating during block imports - gasPrice *big.Int - etherbase common.Address - // Dexon consensus. app *DexconApp governance *DexconGovernance @@ -72,11 +64,9 @@ type Dexon struct { networkID uint64 netRPCService *ethapi.PublicNetAPI - - lock sync.RWMutex // Protects the variadic fields (e.g. gas price and etherbase) } -func New(ctx *node.ServiceContext, config *eth.Config) (*Dexon, error) { +func New(ctx *node.ServiceContext, config *Config) (*Dexon, error) { // Consensus. db, err := blockdb.NewLevelDBBackedBlockDB("main.blockdb") if err != nil { @@ -100,8 +90,6 @@ func New(ctx *node.ServiceContext, config *eth.Config) (*Dexon, error) { accountManager: ctx.AccountManager, shutdownChan: make(chan bool), networkID: config.NetworkId, - gasPrice: config.MinerGasPrice, - etherbase: config.Etherbase, bloomRequests: make(chan chan *bloombits.Retrieval), app: app, governance: gov, diff --git a/dex/config.go b/dex/config.go index 629e29120..d383c17df 100644 --- a/dex/config.go +++ b/dex/config.go @@ -17,42 +17,28 @@ package dex import ( - "math/big" "os" "os/user" "path/filepath" "runtime" "time" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/ethereum/go-ethereum/consensus/ethash" + "github.com/ethereum/go-ethereum/consensus/dexcon" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/eth/downloader" "github.com/ethereum/go-ethereum/eth/gasprice" - "github.com/ethereum/go-ethereum/params" ) // DefaultConfig contains default settings for use on the Ethereum main net. var DefaultConfig = Config{ - SyncMode: downloader.FastSync, - Ethash: ethash.Config{ - CacheDir: "ethash", - CachesInMem: 2, - CachesOnDisk: 3, - DatasetsInMem: 1, - DatasetsOnDisk: 2, - }, + SyncMode: downloader.FastSync, + Dexcon: dexcon.Config{}, NetworkId: 1, LightPeers: 100, DatabaseCache: 768, TrieCleanCache: 256, TrieDirtyCache: 256, TrieTimeout: 60 * time.Minute, - MinerGasFloor: 8000000, - MinerGasCeil: 8000000, - MinerGasPrice: big.NewInt(params.GWei), - MinerRecommit: 3 * time.Second, TxPool: core.DefaultTxPoolConfig, GPO: gasprice.Config{ @@ -69,13 +55,13 @@ func init() { } } if runtime.GOOS == "windows" { - DefaultConfig.Ethash.DatasetDir = filepath.Join(home, "AppData", "Ethash") + DefaultConfig.DatabaseDir = filepath.Join(home, "AppData", "Dexcon") } else { - DefaultConfig.Ethash.DatasetDir = filepath.Join(home, ".ethash") + DefaultConfig.DatabaseDir = filepath.Join(home, ".dexcon") } } -//go:generate gencodec -type Config -field-override configMarshaling -formats toml -out gen_config.go +//go:generate gencodec -type Config -formats toml -out gen_config.go type Config struct { // The genesis block, which is inserted if the database is empty. @@ -95,22 +81,13 @@ type Config struct { SkipBcVersionCheck bool `toml:"-"` DatabaseHandles int `toml:"-"` DatabaseCache int + DatabaseDir string TrieCleanCache int TrieDirtyCache int TrieTimeout time.Duration - // Mining-related options - Etherbase common.Address `toml:",omitempty"` - MinerNotify []string `toml:",omitempty"` - MinerExtraData []byte `toml:",omitempty"` - MinerGasFloor uint64 - MinerGasCeil uint64 - MinerGasPrice *big.Int - MinerRecommit time.Duration - MinerNoverify bool - - // Ethash options - Ethash ethash.Config + // Dexcon options + Dexcon dexcon.Config // Transaction pool options TxPool core.TxPoolConfig @@ -129,7 +106,3 @@ type Config struct { // Type of the EVM interpreter ("" for default) EVMInterpreter string } - -type configMarshaling struct { - MinerExtraData hexutil.Bytes -} diff --git a/dex/governance.go b/dex/governance.go index 0ef0b56db..fd52a8697 100644 --- a/dex/governance.go +++ b/dex/governance.go @@ -14,7 +14,8 @@ func NewDexconGovernance() *DexconGovernance { } // GetValidatorSet returns the current notary set. -func (d *DexconGovernance) GetNotarySet() map[types.NodeID]struct{} { +func (d *DexconGovernance) GetNotarySet( + blockHeight uint64) map[types.NodeID]struct{} { return make(map[types.NodeID]struct{}) } |