aboutsummaryrefslogtreecommitdiffstats
path: root/dex
diff options
context:
space:
mode:
authorWei-Ning Huang <w@dexon.org>2018-10-19 18:52:38 +0800
committerWei-Ning Huang <w@dexon.org>2019-04-09 21:32:50 +0800
commit00e8f2d99b3c6b27d8047712baf5bbb6150dc273 (patch)
treeb36879b60e89210e664a7007d08fcd5a990e613d /dex
parentb52b1b2106f075260674660638aa60fe5ec81f87 (diff)
downloaddexon-00e8f2d99b3c6b27d8047712baf5bbb6150dc273.tar
dexon-00e8f2d99b3c6b27d8047712baf5bbb6150dc273.tar.gz
dexon-00e8f2d99b3c6b27d8047712baf5bbb6150dc273.tar.bz2
dexon-00e8f2d99b3c6b27d8047712baf5bbb6150dc273.tar.lz
dexon-00e8f2d99b3c6b27d8047712baf5bbb6150dc273.tar.xz
dexon-00e8f2d99b3c6b27d8047712baf5bbb6150dc273.tar.zst
dexon-00e8f2d99b3c6b27d8047712baf5bbb6150dc273.zip
consensus: dexcon: fetch config from state
Diffstat (limited to 'dex')
-rw-r--r--dex/app.go1
-rw-r--r--dex/backend.go8
-rw-r--r--dex/config.go5
-rw-r--r--dex/governance.go8
4 files changed, 15 insertions, 7 deletions
diff --git a/dex/app.go b/dex/app.go
index 317711e94..ab23301d5 100644
--- a/dex/app.go
+++ b/dex/app.go
@@ -223,6 +223,7 @@ func (d *DexconApp) BlockDelivered(blockHash coreCommon.Hash, result coreTypes.F
Number: new(big.Int).SetUint64(result.Height),
Time: big.NewInt(result.Timestamp.Unix()),
Coinbase: common.BytesToAddress(block.ProposerID.Bytes()),
+ Position: block.Position,
WitnessHeight: block.Witness.Height,
WitnessRoot: witnessData.Root,
WitnessReceiptHash: witnessData.ReceiptHash,
diff --git a/dex/backend.go b/dex/backend.go
index 7a23ba80b..2f6d8a8e5 100644
--- a/dex/backend.go
+++ b/dex/backend.go
@@ -110,6 +110,8 @@ func New(ctx *node.ServiceContext, config *Config) (*Dexon, error) {
}
rawdb.WriteDatabaseVersion(chainDb, core.BlockChainVersion)
}
+ engine := dexcon.New()
+
dex := &Dexon{
config: config,
chainDb: chainDb,
@@ -121,7 +123,7 @@ func New(ctx *node.ServiceContext, config *Config) (*Dexon, error) {
bloomRequests: make(chan chan *bloombits.Retrieval),
bloomIndexer: NewBloomIndexer(chainDb, params.BloomBitsBlocks, params.BloomConfirms),
blockdb: db,
- engine: dexcon.New(chainConfig.Dexcon),
+ engine: engine,
}
var (
@@ -154,9 +156,13 @@ func New(ctx *node.ServiceContext, config *Config) (*Dexon, error) {
}
dex.APIBackend.gpo = gasprice.NewOracle(dex.APIBackend, gpoParams)
+ // Dexcon related objects.
dex.governance = NewDexconGovernance(dex.APIBackend, dex.chainConfig, config.PrivateKey)
dex.app = NewDexconApp(dex.txPool, dex.blockchain, dex.governance, chainDb, config, vmConfig)
+ // Set config fetcher so engine can fetch current system configuration from state.
+ engine.SetConfigFetcher(dex.governance)
+
pm, err := NewProtocolManager(dex.chainConfig, config.SyncMode,
config.NetworkId, dex.eventMux, dex.txPool, dex.engine, dex.blockchain,
chainDb, dex.governance)
diff --git a/dex/config.go b/dex/config.go
index a3b682de0..5eff28022 100644
--- a/dex/config.go
+++ b/dex/config.go
@@ -25,7 +25,6 @@ import (
"runtime"
"time"
- "github.com/dexon-foundation/dexon/consensus/dexcon"
"github.com/dexon-foundation/dexon/core"
"github.com/dexon-foundation/dexon/dex/gasprice"
"github.com/dexon-foundation/dexon/eth/downloader"
@@ -35,7 +34,6 @@ import (
// DefaultConfig contains default settings for use on the Ethereum main net.
var DefaultConfig = Config{
SyncMode: downloader.FastSync,
- Dexcon: dexcon.Config{},
NetworkId: 1,
LightPeers: 100,
DatabaseCache: 768,
@@ -102,9 +100,6 @@ type Config struct {
GasCeil uint64
GasLimitTolerance uint64
- // Dexcon options
- Dexcon dexcon.Config
-
// Transaction pool options
TxPool core.TxPoolConfig
diff --git a/dex/governance.go b/dex/governance.go
index 4ec69c2d6..50ab7ee14 100644
--- a/dex/governance.go
+++ b/dex/governance.go
@@ -79,7 +79,13 @@ func (d *DexconGovernance) getGovStateAtRound(round uint64) *vm.GovernanceStateH
return &vm.GovernanceStateHelper{state}
}
-// Configuration return the total ordering K constant.
+// DexconConfiguration return raw config in state.
+func (d *DexconGovernance) DexconConfiguration(round uint64) *params.DexconConfig {
+ s := d.getGovStateAtRound(round)
+ return s.Configuration()
+}
+
+// Configuration returns the system configuration for consensus core to use.
func (d *DexconGovernance) Configuration(round uint64) *coreTypes.Config {
s := d.getGovStateAtRound(round)
c := s.Configuration()