diff options
author | Wei-Ning Huang <w@dexon.org> | 2019-01-13 16:21:17 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@dexon.org> | 2019-01-14 15:27:28 +0800 |
commit | 501d1e0b9280ebc824e22c3d91439ca91247861b (patch) | |
tree | f2fe337e6e12b347f6ed63e531a98908fe276056 /dex | |
parent | 646d6d4c77e0726d82cb016e12aab8edaccb7e95 (diff) | |
download | dexon-501d1e0b9280ebc824e22c3d91439ca91247861b.tar dexon-501d1e0b9280ebc824e22c3d91439ca91247861b.tar.gz dexon-501d1e0b9280ebc824e22c3d91439ca91247861b.tar.bz2 dexon-501d1e0b9280ebc824e22c3d91439ca91247861b.tar.lz dexon-501d1e0b9280ebc824e22c3d91439ca91247861b.tar.xz dexon-501d1e0b9280ebc824e22c3d91439ca91247861b.tar.zst dexon-501d1e0b9280ebc824e22c3d91439ca91247861b.zip |
consensus: implement DEXON cryptoeconomics v4.0 (#145)
Diffstat (limited to 'dex')
-rw-r--r-- | dex/app_test.go | 22 | ||||
-rw-r--r-- | dex/backend.go | 2 | ||||
-rw-r--r-- | dex/governance.go | 4 |
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 992f71709..b4b4ea2aa 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() { |