aboutsummaryrefslogtreecommitdiffstats
path: root/core/vm
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2019-02-22 13:14:55 +0800
committerWei-Ning Huang <w@dexon.org>2019-04-09 21:32:57 +0800
commit11e2de8c43f867764d4dd1146d467cb6e9bf114b (patch)
treefb821d64098f7c62dabf879f9edfc4490b033a58 /core/vm
parentaf12f1f869609d2f3acf27c9315b6bbe816d9761 (diff)
downloaddexon-11e2de8c43f867764d4dd1146d467cb6e9bf114b.tar.gz
dexon-11e2de8c43f867764d4dd1146d467cb6e9bf114b.tar.zst
dexon-11e2de8c43f867764d4dd1146d467cb6e9bf114b.zip
core: Remove K, Phi and NumChains from Governance (#198)
* change default sync_core.sh * vendor: sync to latest core * core: Remove K, Phi and NumChain
Diffstat (limited to 'core/vm')
-rw-r--r--core/vm/oracle_contract_abi.go78
-rw-r--r--core/vm/oracle_contracts.go70
-rw-r--r--core/vm/oracle_contracts_test.go42
3 files changed, 29 insertions, 161 deletions
diff --git a/core/vm/oracle_contract_abi.go b/core/vm/oracle_contract_abi.go
index 5c6f2a711..fde973203 100644
--- a/core/vm/oracle_contract_abi.go
+++ b/core/vm/oracle_contract_abi.go
@@ -239,20 +239,6 @@ const GovernanceABIJSON = `
},
{
"constant": true,
- "inputs": [],
- "name": "phiRatio",
- "outputs": [
- {
- "name": "",
- "type": "uint256"
- }
- ],
- "payable": false,
- "stateMutability": "view",
- "type": "function"
- },
- {
- "constant": true,
"inputs": [
{
"name": "",
@@ -373,12 +359,17 @@ const GovernanceABIJSON = `
},
{
"constant": true,
- "inputs": [],
- "name": "roundInterval",
+ "inputs": [
+ {
+ "name": "",
+ "type": "address"
+ }
+ ],
+ "name": "nodesOffsetByAddress",
"outputs": [
{
"name": "",
- "type": "uint256"
+ "type": "int256"
}
],
"payable": false,
@@ -387,17 +378,12 @@ const GovernanceABIJSON = `
},
{
"constant": true,
- "inputs": [
- {
- "name": "",
- "type": "address"
- }
- ],
- "name": "nodesOffsetByAddress",
+ "inputs": [],
+ "name": "roundLength",
"outputs": [
{
"name": "",
- "type": "int256"
+ "type": "uint256"
}
],
"payable": false,
@@ -533,20 +519,6 @@ const GovernanceABIJSON = `
},
{
"constant": true,
- "inputs": [],
- "name": "k",
- "outputs": [
- {
- "name": "",
- "type": "uint256"
- }
- ],
- "payable": false,
- "stateMutability": "view",
- "type": "function"
- },
- {
- "constant": true,
"inputs": [
{
"name": "",
@@ -594,20 +566,6 @@ const GovernanceABIJSON = `
{
"constant": true,
"inputs": [],
- "name": "numChains",
- "outputs": [
- {
- "name": "",
- "type": "uint256"
- }
- ],
- "payable": false,
- "stateMutability": "view",
- "type": "function"
- },
- {
- "constant": true,
- "inputs": [],
"name": "lockupPeriod",
"outputs": [
{
@@ -871,10 +829,6 @@ const GovernanceABIJSON = `
"type": "uint256"
},
{
- "name": "NumChains",
- "type": "uint256"
- },
- {
"name": "LambdaBA",
"type": "uint256"
},
@@ -883,14 +837,6 @@ const GovernanceABIJSON = `
"type": "uint256"
},
{
- "name": "K",
- "type": "uint256"
- },
- {
- "name": "PhiRatio",
- "type": "uint256"
- },
- {
"name": "NotarySetSize",
"type": "uint256"
},
@@ -899,7 +845,7 @@ const GovernanceABIJSON = `
"type": "uint256"
},
{
- "name": "RoundInterval",
+ "name": "RoundLength",
"type": "uint256"
},
{
diff --git a/core/vm/oracle_contracts.go b/core/vm/oracle_contracts.go
index e060312e5..1eeb57a5a 100644
--- a/core/vm/oracle_contracts.go
+++ b/core/vm/oracle_contracts.go
@@ -74,14 +74,11 @@ const (
nextHalvingSupplyLoc
lastHalvedAmountLoc
blockGasLimitLoc
- numChainsLoc
lambdaBALoc
lambdaDKGLoc
- kLoc
- phiRatioLoc
notarySetSizeLoc
dkgSetSizeLoc
- roundIntervalLoc
+ roundLengthLoc
minBlockIntervalLoc
fineValuesLoc
finedRecordsLoc
@@ -820,11 +817,6 @@ func (s *GovernanceStateHelper) SetBlockGasLimit(reward *big.Int) {
s.setStateBigInt(big.NewInt(blockGasLimitLoc), reward)
}
-// uint256 public numChains;
-func (s *GovernanceStateHelper) NumChains() *big.Int {
- return s.getStateBigInt(big.NewInt(numChainsLoc))
-}
-
// uint256 public lambdaBA;
func (s *GovernanceStateHelper) LambdaBA() *big.Int {
return s.getStateBigInt(big.NewInt(lambdaBALoc))
@@ -835,16 +827,6 @@ func (s *GovernanceStateHelper) LambdaDKG() *big.Int {
return s.getStateBigInt(big.NewInt(lambdaDKGLoc))
}
-// uint256 public k;
-func (s *GovernanceStateHelper) K() *big.Int {
- return s.getStateBigInt(big.NewInt(kLoc))
-}
-
-// uint256 public phiRatio; // stored as PhiRatio * 10^6
-func (s *GovernanceStateHelper) PhiRatio() *big.Int {
- return s.getStateBigInt(big.NewInt(phiRatioLoc))
-}
-
// uint256 public notarySetSize;
func (s *GovernanceStateHelper) NotarySetSize() *big.Int {
return s.getStateBigInt(big.NewInt(notarySetSizeLoc))
@@ -855,9 +837,9 @@ func (s *GovernanceStateHelper) DKGSetSize() *big.Int {
return s.getStateBigInt(big.NewInt(dkgSetSizeLoc))
}
-// uint256 public roundInterval;
-func (s *GovernanceStateHelper) RoundInterval() *big.Int {
- return s.getStateBigInt(big.NewInt(roundIntervalLoc))
+// uint256 public roundLength;
+func (s *GovernanceStateHelper) RoundLength() *big.Int {
+ return s.getStateBigInt(big.NewInt(roundLengthLoc))
}
// uint256 public minBlockInterval;
@@ -959,14 +941,11 @@ func (s *GovernanceStateHelper) Configuration() *params.DexconConfig {
NextHalvingSupply: s.getStateBigInt(big.NewInt(nextHalvingSupplyLoc)),
LastHalvedAmount: s.getStateBigInt(big.NewInt(lastHalvedAmountLoc)),
BlockGasLimit: s.getStateBigInt(big.NewInt(blockGasLimitLoc)).Uint64(),
- NumChains: uint32(s.getStateBigInt(big.NewInt(numChainsLoc)).Uint64()),
LambdaBA: s.getStateBigInt(big.NewInt(lambdaBALoc)).Uint64(),
LambdaDKG: s.getStateBigInt(big.NewInt(lambdaDKGLoc)).Uint64(),
- K: uint32(s.getStateBigInt(big.NewInt(kLoc)).Uint64()),
- PhiRatio: float32(s.getStateBigInt(big.NewInt(phiRatioLoc)).Uint64()) / decimalMultiplier,
NotarySetSize: uint32(s.getStateBigInt(big.NewInt(notarySetSizeLoc)).Uint64()),
DKGSetSize: uint32(s.getStateBigInt(big.NewInt(dkgSetSizeLoc)).Uint64()),
- RoundInterval: s.getStateBigInt(big.NewInt(roundIntervalLoc)).Uint64(),
+ RoundLength: s.getStateBigInt(big.NewInt(roundLengthLoc)).Uint64(),
MinBlockInterval: s.getStateBigInt(big.NewInt(minBlockIntervalLoc)).Uint64(),
FineValues: s.FineValues(),
}
@@ -980,14 +959,11 @@ func (s *GovernanceStateHelper) UpdateConfiguration(cfg *params.DexconConfig) {
s.setStateBigInt(big.NewInt(nextHalvingSupplyLoc), cfg.NextHalvingSupply)
s.setStateBigInt(big.NewInt(lastHalvedAmountLoc), cfg.LastHalvedAmount)
s.setStateBigInt(big.NewInt(blockGasLimitLoc), big.NewInt(int64(cfg.BlockGasLimit)))
- s.setStateBigInt(big.NewInt(numChainsLoc), big.NewInt(int64(cfg.NumChains)))
s.setStateBigInt(big.NewInt(lambdaBALoc), big.NewInt(int64(cfg.LambdaBA)))
s.setStateBigInt(big.NewInt(lambdaDKGLoc), big.NewInt(int64(cfg.LambdaDKG)))
- s.setStateBigInt(big.NewInt(kLoc), big.NewInt(int64(cfg.K)))
- s.setStateBigInt(big.NewInt(phiRatioLoc), big.NewInt(int64(cfg.PhiRatio*decimalMultiplier)))
s.setStateBigInt(big.NewInt(notarySetSizeLoc), big.NewInt(int64(cfg.NotarySetSize)))
s.setStateBigInt(big.NewInt(dkgSetSizeLoc), big.NewInt(int64(cfg.DKGSetSize)))
- s.setStateBigInt(big.NewInt(roundIntervalLoc), big.NewInt(int64(cfg.RoundInterval)))
+ s.setStateBigInt(big.NewInt(roundLengthLoc), big.NewInt(int64(cfg.RoundLength)))
s.setStateBigInt(big.NewInt(minBlockIntervalLoc), big.NewInt(int64(cfg.MinBlockInterval)))
s.SetFineValues(cfg.FineValues)
}
@@ -996,14 +972,11 @@ type rawConfigStruct struct {
MinStake *big.Int
LockupPeriod *big.Int
BlockGasLimit *big.Int
- NumChains *big.Int
LambdaBA *big.Int
LambdaDKG *big.Int
- K *big.Int
- PhiRatio *big.Int
NotarySetSize *big.Int
DKGSetSize *big.Int
- RoundInterval *big.Int
+ RoundLength *big.Int
MinBlockInterval *big.Int
FineValues []*big.Int
}
@@ -1013,14 +986,11 @@ func (s *GovernanceStateHelper) UpdateConfigurationRaw(cfg *rawConfigStruct) {
s.setStateBigInt(big.NewInt(minStakeLoc), cfg.MinStake)
s.setStateBigInt(big.NewInt(lockupPeriodLoc), cfg.LockupPeriod)
s.setStateBigInt(big.NewInt(blockGasLimitLoc), cfg.BlockGasLimit)
- s.setStateBigInt(big.NewInt(numChainsLoc), cfg.NumChains)
s.setStateBigInt(big.NewInt(lambdaBALoc), cfg.LambdaBA)
s.setStateBigInt(big.NewInt(lambdaDKGLoc), cfg.LambdaDKG)
- s.setStateBigInt(big.NewInt(kLoc), cfg.K)
- s.setStateBigInt(big.NewInt(phiRatioLoc), cfg.PhiRatio)
s.setStateBigInt(big.NewInt(notarySetSizeLoc), cfg.NotarySetSize)
s.setStateBigInt(big.NewInt(dkgSetSizeLoc), cfg.DKGSetSize)
- s.setStateBigInt(big.NewInt(roundIntervalLoc), cfg.RoundInterval)
+ s.setStateBigInt(big.NewInt(roundLengthLoc), cfg.RoundLength)
s.setStateBigInt(big.NewInt(minBlockIntervalLoc), cfg.MinBlockInterval)
s.SetFineValues(cfg.FineValues)
}
@@ -1853,7 +1823,7 @@ func (g *GovernanceContract) resetDKG(newSignedCRS []byte) ([]byte, error) {
}
config := gs.Configuration()
- targetBlockNum := new(big.Int).SetUint64(config.RoundInterval / config.MinBlockInterval)
+ targetBlockNum := new(big.Int).SetUint64(config.RoundLength)
targetBlockNum.Mul(targetBlockNum, target)
targetBlockNum.Quo(targetBlockNum, big.NewInt(100))
targetBlockNum.Add(targetBlockNum, roundHeight)
@@ -2227,12 +2197,6 @@ func (g *GovernanceContract) Run(evm *EVM, input []byte, contract *Contract) (re
return nil, errExecutionReverted
}
return res, nil
- case "k":
- res, err := method.Outputs.Pack(g.state.K())
- if err != nil {
- return nil, errExecutionReverted
- }
- return res, nil
case "lambdaBA":
res, err := method.Outputs.Pack(g.state.LambdaBA())
if err != nil {
@@ -2281,12 +2245,6 @@ func (g *GovernanceContract) Run(evm *EVM, input []byte, contract *Contract) (re
return nil, errExecutionReverted
}
return res, nil
- case "numChains":
- res, err := method.Outputs.Pack(g.state.NumChains())
- if err != nil {
- return nil, errExecutionReverted
- }
- return res, nil
case "nodes":
index := new(big.Int)
if err := method.Inputs.Unpack(&index, arguments); err != nil {
@@ -2332,12 +2290,6 @@ func (g *GovernanceContract) Run(evm *EVM, input []byte, contract *Contract) (re
return nil, errExecutionReverted
}
return res, nil
- case "phiRatio":
- res, err := method.Outputs.Pack(g.state.PhiRatio())
- if err != nil {
- return nil, errExecutionReverted
- }
- return res, nil
case "roundHeight":
round := new(big.Int)
if err := method.Inputs.Unpack(&round, arguments); err != nil {
@@ -2348,8 +2300,8 @@ func (g *GovernanceContract) Run(evm *EVM, input []byte, contract *Contract) (re
return nil, errExecutionReverted
}
return res, nil
- case "roundInterval":
- res, err := method.Outputs.Pack(g.state.RoundInterval())
+ case "roundLength":
+ res, err := method.Outputs.Pack(g.state.RoundLength())
if err != nil {
return nil, errExecutionReverted
}
diff --git a/core/vm/oracle_contracts_test.go b/core/vm/oracle_contracts_test.go
index 654070c57..dd17dddea 100644
--- a/core/vm/oracle_contracts_test.go
+++ b/core/vm/oracle_contracts_test.go
@@ -648,14 +648,11 @@ func (g *OracleContractsTestSuite) TestUpdateConfiguration() {
new(big.Int).Mul(big.NewInt(1e18), big.NewInt(1e6)),
big.NewInt(1000),
big.NewInt(8000000),
- big.NewInt(6),
big.NewInt(250),
big.NewInt(2500),
- big.NewInt(0),
- big.NewInt(667000),
big.NewInt(4),
big.NewInt(4),
- big.NewInt(600000),
+ big.NewInt(600),
big.NewInt(900),
[]*big.Int{big.NewInt(1), big.NewInt(1), big.NewInt(1)})
g.Require().NoError(err)
@@ -720,15 +717,6 @@ func (g *OracleContractsTestSuite) TestConfigurationReading() {
g.Require().NoError(err)
g.Require().Equal(g.config.BlockGasLimit, value.Uint64())
- // NumChains.
- input, err = GovernanceABI.ABI.Pack("numChains")
- g.Require().NoError(err)
- res, err = g.call(GovernanceContractAddress, addr, input, big.NewInt(0))
- g.Require().NoError(err)
- err = GovernanceABI.ABI.Unpack(&value, "numChains", res)
- g.Require().NoError(err)
- g.Require().Equal(g.config.NumChains, uint32(value.Uint64()))
-
// LambdaBA.
input, err = GovernanceABI.ABI.Pack("lambdaBA")
g.Require().NoError(err)
@@ -747,24 +735,6 @@ func (g *OracleContractsTestSuite) TestConfigurationReading() {
g.Require().NoError(err)
g.Require().Equal(g.config.LambdaDKG, value.Uint64())
- // K.
- input, err = GovernanceABI.ABI.Pack("k")
- g.Require().NoError(err)
- res, err = g.call(GovernanceContractAddress, addr, input, big.NewInt(0))
- g.Require().NoError(err)
- err = GovernanceABI.ABI.Unpack(&value, "k", res)
- g.Require().NoError(err)
- g.Require().Equal(g.config.K, uint32(value.Uint64()))
-
- // PhiRatio.
- input, err = GovernanceABI.ABI.Pack("phiRatio")
- g.Require().NoError(err)
- res, err = g.call(GovernanceContractAddress, addr, input, big.NewInt(0))
- g.Require().NoError(err)
- err = GovernanceABI.ABI.Unpack(&value, "phiRatio", res)
- g.Require().NoError(err)
- g.Require().Equal(g.config.PhiRatio, float32(value.Uint64())/decimalMultiplier)
-
// NotarySetSize.
input, err = GovernanceABI.ABI.Pack("notarySetSize")
g.Require().NoError(err)
@@ -783,14 +753,14 @@ func (g *OracleContractsTestSuite) TestConfigurationReading() {
g.Require().NoError(err)
g.Require().Equal(g.config.DKGSetSize, uint32(value.Uint64()))
- // RoundInterval.
- input, err = GovernanceABI.ABI.Pack("roundInterval")
+ // RoundLength.
+ input, err = GovernanceABI.ABI.Pack("roundLength")
g.Require().NoError(err)
res, err = g.call(GovernanceContractAddress, addr, input, big.NewInt(0))
g.Require().NoError(err)
- err = GovernanceABI.ABI.Unpack(&value, "roundInterval", res)
+ err = GovernanceABI.ABI.Unpack(&value, "roundLength", res)
g.Require().NoError(err)
- g.Require().Equal(g.config.RoundInterval, value.Uint64())
+ g.Require().Equal(g.config.RoundLength, value.Uint64())
// MinBlockInterval.
input, err = GovernanceABI.ABI.Pack("minBlockInterval")
@@ -1187,7 +1157,7 @@ func (g *OracleContractsTestSuite) TestResetDKG() {
}
// Fill data for previous rounds.
- roundHeight := int64(g.config.RoundInterval / g.config.MinBlockInterval)
+ roundHeight := int64(g.config.RoundLength)
round := 3
for i := 0; i <= round; i++ {
// Prepare CRS.