aboutsummaryrefslogtreecommitdiffstats
path: root/dex
diff options
context:
space:
mode:
authorWei-Ning Huang <w@dexon.org>2019-01-13 16:21:17 +0800
committerWei-Ning Huang <w@dexon.org>2019-03-12 12:19:09 +0800
commitba71563f6844a574bdfa9da5585bdae4a9958677 (patch)
treebf474a36438acec5a799f1777de15ac7341bb359 /dex
parentcae038236416efd8a3436664024f9cadee741512 (diff)
downloaddexon-ba71563f6844a574bdfa9da5585bdae4a9958677.tar.gz
dexon-ba71563f6844a574bdfa9da5585bdae4a9958677.tar.zst
dexon-ba71563f6844a574bdfa9da5585bdae4a9958677.zip
consensus: implement DEXON cryptoeconomics v4.0 (#145)
Diffstat (limited to 'dex')
-rw-r--r--dex/app_test.go22
-rw-r--r--dex/backend.go2
-rw-r--r--dex/governance.go4
3 files changed, 20 insertions, 8 deletions
diff --git a/dex/app_test.go b/dex/app_test.go
index f4cc2fd9a..c79dbc42c 100644
--- a/dex/app_test.go
+++ b/dex/app_test.go
@@ -494,9 +494,21 @@ func TestNumChainsChange(t *testing.T) {
// Update config in round 1 and height 1.
// Config will affect in round 3.
input, err := abiObject.Pack("updateConfiguration",
- new(big.Int).Mul(big.NewInt(1e18), big.NewInt(1e4)), big.NewInt(2000),
- big.NewInt(1e17), big.NewInt(9000000), big.NewInt(3), big.NewInt(500), big.NewInt(5000),
- big.NewInt(1), big.NewInt(700000), big.NewInt(5), big.NewInt(5), big.NewInt(700000), big.NewInt(1000),
+ new(big.Int).Mul(big.NewInt(1e18), big.NewInt(1e4)),
+ big.NewInt(2000),
+ big.NewInt(0.1875*1e8),
+ big.NewInt(1e18),
+ big.NewInt(1e18),
+ big.NewInt(9000000),
+ big.NewInt(3),
+ big.NewInt(500),
+ big.NewInt(5000),
+ big.NewInt(1),
+ big.NewInt(700000),
+ big.NewInt(5),
+ big.NewInt(5),
+ big.NewInt(700000),
+ big.NewInt(1000),
[]*big.Int{big.NewInt(1), big.NewInt(1), big.NewInt(1)})
if err != nil {
t.Errorf("updateConfiguration abiObject pack error: %v", err)
@@ -686,7 +698,7 @@ func newTestDexonWithGenesis(allocKey *ecdsa.PrivateKey) (*Dexon, error) {
dex.APIBackend = &DexAPIBackend{dex, nil}
dex.governance = NewDexconGovernance(dex.APIBackend, dex.chainConfig, config.PrivateKey)
- engine.SetConfigFetcher(dex.governance)
+ engine.SetGovStateFetcher(dex.governance)
dex.app = NewDexconApp(dex.txPool, dex.blockchain, dex.governance, db, &config)
return dex, nil
@@ -748,7 +760,7 @@ func prepareData(dex *Dexon, key *ecdsa.PrivateKey, startNonce, txNum int) (
func prepareConfirmedBlockWithTxAndData(dex *Dexon, key *ecdsa.PrivateKey, data [][]byte, round uint64) (
Block *coreTypes.Block, err error) {
address := crypto.PubkeyToAddress(key.PublicKey)
- numChains := dex.governance.GetConfigHelper(round).Configuration().NumChains
+ numChains := dex.governance.GetGovStateHelperAtRound(round).Configuration().NumChains
chainID := new(big.Int).Mod(address.Big(), big.NewInt(int64(numChains)))
for _, d := range data {
diff --git a/dex/backend.go b/dex/backend.go
index c7e0773ad..88cfa3033 100644
--- a/dex/backend.go
+++ b/dex/backend.go
@@ -160,7 +160,7 @@ func New(ctx *node.ServiceContext, config *Config) (*Dexon, error) {
dex.app = NewDexconApp(dex.txPool, dex.blockchain, dex.governance, chainDb, config)
// Set config fetcher so engine can fetch current system configuration from state.
- engine.SetConfigFetcher(dex.governance)
+ engine.SetGovStateFetcher(dex.governance)
dMoment := time.Unix(config.DMoment, int64(0))
log.Info("DEXON Consensus DMoment", "time", dMoment)
diff --git a/dex/governance.go b/dex/governance.go
index ec029f2f1..0d5a7c926 100644
--- a/dex/governance.go
+++ b/dex/governance.go
@@ -68,7 +68,7 @@ func NewDexconGovernance(backend *DexAPIBackend, chainConfig *params.ChainConfig
// DexconConfiguration return raw config in state.
func (d *DexconGovernance) DexconConfiguration(round uint64) *params.DexconConfig {
- return d.GetConfigHelper(round).Configuration()
+ return d.GetGovStateHelperAtRound(round).Configuration()
}
func (d *DexconGovernance) sendGovTx(ctx context.Context, data []byte) error {
@@ -136,7 +136,7 @@ func (d *DexconGovernance) ProposeCRS(round uint64, signedCRS []byte) {
// NodeSet returns the current node set.
func (d *DexconGovernance) NodeSet(round uint64) []coreCrypto.PublicKey {
- s := d.GetConfigHelper(round)
+ s := d.GetGovStateHelperAtRound(round)
var pks []coreCrypto.PublicKey
for _, n := range s.QualifiedNodes() {