aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/vm/governance.go35
-rw-r--r--dex/app.go9
-rw-r--r--dex/governance.go6
-rw-r--r--params/config.go6
-rw-r--r--params/gen_dexcon_config.go6
-rw-r--r--test/genesis.json3
6 files changed, 52 insertions, 13 deletions
diff --git a/core/vm/governance.go b/core/vm/governance.go
index 3570482dc..b36c01e43 100644
--- a/core/vm/governance.go
+++ b/core/vm/governance.go
@@ -202,6 +202,20 @@ const abiJSON = `
{
"constant": true,
"inputs": [],
+ "name": "blockGasLimit",
+ "outputs": [
+ {
+ "name": "",
+ "type": "uint256"
+ }
+ ],
+ "payable": false,
+ "stateMutability": "view",
+ "type": "function"
+ },
+ {
+ "constant": true,
+ "inputs": [],
"name": "roundInterval",
"outputs": [
{
@@ -426,6 +440,10 @@ const abiJSON = `
"type": "uint256"
},
{
+ "name": "BlockGasLimit",
+ "type": "uint256"
+ },
+ {
"name": "NumChains",
"type": "uint256"
},
@@ -705,6 +723,12 @@ func RunGovernanceContract(evm *EVM, input []byte, contract *Contract) (
// Solidity auto generated methods.
// --------------------------------
+ case "blockGasLimit":
+ res, err := method.Outputs.Pack(g.state.BlockGasLimit())
+ if err != nil {
+ return nil, errExecutionReverted
+ }
+ return res, nil
case "blockReward":
res, err := method.Outputs.Pack(g.state.BlockReward())
if err != nil {
@@ -889,6 +913,7 @@ const (
dkgFinalizedsCountLoc
ownerLoc
blockRewardLoc
+ blockGasLimitLoc
numChainsLoc
lambdaBALoc
lambdaDKGLoc
@@ -1224,6 +1249,14 @@ func (s *GovernanceStateHelper) SetBlockReward(reward *big.Int) {
s.setStateBigInt(big.NewInt(blockRewardLoc), reward)
}
+// uint256 public blockGasLimit;
+func (s *GovernanceStateHelper) BlockGasLimit() *big.Int {
+ return s.getStateBigInt(big.NewInt(blockGasLimitLoc))
+}
+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))
@@ -1289,6 +1322,7 @@ func (s *GovernanceStateHelper) Stake(addr common.Address, publicKey []byte, sta
func (s *GovernanceStateHelper) Configuration() *params.DexconConfig {
return &params.DexconConfig{
BlockReward: s.getStateBigInt(big.NewInt(blockRewardLoc)),
+ BlockGasLimit: uint64(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(),
@@ -1305,6 +1339,7 @@ func (s *GovernanceStateHelper) Configuration() *params.DexconConfig {
// UpdateConfiguration updates system configuration.
func (s *GovernanceStateHelper) UpdateConfiguration(cfg *params.DexconConfig) {
s.setStateBigInt(big.NewInt(blockRewardLoc), cfg.BlockReward)
+ 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)))
diff --git a/dex/app.go b/dex/app.go
index a226aaa0c..b325f44d0 100644
--- a/dex/app.go
+++ b/dex/app.go
@@ -411,11 +411,10 @@ func (d *DexconApp) BlockDelivered(blockHash coreCommon.Hash, result coreTypes.F
}
newBlock := types.NewBlock(&types.Header{
- Number: new(big.Int).SetUint64(result.Height),
- Time: big.NewInt(result.Timestamp.Unix()),
- Coinbase: common.BytesToAddress(block.ProposerID.Bytes()),
- // TODO(bojie): fix it
- GasLimit: 8000000,
+ Number: new(big.Int).SetUint64(result.Height),
+ Time: big.NewInt(result.Timestamp.Unix()),
+ Coinbase: common.BytesToAddress(block.ProposerID.Bytes()),
+ GasLimit: d.gov.DexconConfiguration(block.Position.Round).BlockGasLimit,
Difficulty: big.NewInt(1),
Round: block.Position.Round,
DexconMeta: dexconMeta,
diff --git a/dex/governance.go b/dex/governance.go
index 69c1e217f..bbb34ca50 100644
--- a/dex/governance.go
+++ b/dex/governance.go
@@ -87,12 +87,6 @@ func (d *DexconGovernance) DexconConfiguration(round uint64) *params.DexconConfi
// Configuration returns the system configuration for consensus core to use.
func (d *DexconGovernance) Configuration(round uint64) *coreTypes.Config {
- // Configuration in round r is activiated on round r + 2.
- if round < 2 {
- round = 0
- } else {
- round -= 2
- }
s := d.getGovStateAtRound(round)
c := s.Configuration()
diff --git a/params/config.go b/params/config.go
index 3e9db27f2..11d25f9ef 100644
--- a/params/config.go
+++ b/params/config.go
@@ -55,6 +55,7 @@ var (
GenesisCRSText: "In DEXON, we trust.",
Owner: common.HexToAddress("7C3c31B19395A5e2627F921Cc2802560B71f1caB"),
BlockReward: big.NewInt(1e18),
+ BlockGasLimit: 80000000,
NumChains: 4,
LambdaBA: 250,
LambdaDKG: 2500,
@@ -93,6 +94,7 @@ var (
GenesisCRSText: "In DEXON, we trust.",
Owner: common.HexToAddress("7C3c31B19395A5e2627F921Cc2802560B71f1caB"),
BlockReward: big.NewInt(1e18),
+ BlockGasLimit: 80000000,
NumChains: 4,
LambdaBA: 250,
LambdaDKG: 2500,
@@ -202,6 +204,7 @@ type DexconConfig struct {
GenesisCRSText string `json:"genesisCRSText"`
Owner common.Address `json:"owner"`
BlockReward *big.Int `json:"blockReward"`
+ BlockGasLimit uint64 `json:"blockGasLimit"`
NumChains uint32 `json:"numChains"`
LambdaBA uint64 `json:"lambdaBA"`
LambdaDKG uint64 `json:"lambdaDKG"`
@@ -220,10 +223,11 @@ type dexconConfigSpecMarshaling struct {
// String implements the stringer interface, returning the consensus engine details.
func (d *DexconConfig) String() string {
- return fmt.Sprintf("{GenesisCRSText: %v Owner: %v BlockReward: %v NumChains: %v LambdaBA: %v LambdaDKG: %v K: %v PhiRatio: %v NotarySetSize: %v DKGSetSize: %v RoundInterval: %v MinBlockInterval: %v MaxBlockInterval: %v BlockReward: %v",
+ return fmt.Sprintf("{GenesisCRSText: %v Owner: %v BlockReward: %v BlockGasLimit: %v NumChains: %v LambdaBA: %v LambdaDKG: %v K: %v PhiRatio: %v NotarySetSize: %v DKGSetSize: %v RoundInterval: %v MinBlockInterval: %v MaxBlockInterval: %v BlockReward: %v",
d.GenesisCRSText,
d.Owner,
d.BlockReward,
+ d.BlockGasLimit,
d.NumChains,
d.LambdaBA,
d.LambdaDKG,
diff --git a/params/gen_dexcon_config.go b/params/gen_dexcon_config.go
index f81951140..f378b4588 100644
--- a/params/gen_dexcon_config.go
+++ b/params/gen_dexcon_config.go
@@ -18,6 +18,7 @@ func (d DexconConfig) MarshalJSON() ([]byte, error) {
GenesisCRSText string `json:"genesisCRSText"`
Owner common.Address `json:"owner"`
BlockReward *math.HexOrDecimal256 `json:"blockReward"`
+ BlockGasLimit uint64 `json:"blockGasLimit"`
NumChains uint32 `json:"numChains"`
LambdaBA uint64 `json:"lambdaBA"`
LambdaDKG uint64 `json:"lambdaDKG"`
@@ -33,6 +34,7 @@ func (d DexconConfig) MarshalJSON() ([]byte, error) {
enc.GenesisCRSText = d.GenesisCRSText
enc.Owner = d.Owner
enc.BlockReward = (*math.HexOrDecimal256)(d.BlockReward)
+ enc.BlockGasLimit = d.BlockGasLimit
enc.NumChains = d.NumChains
enc.LambdaBA = d.LambdaBA
enc.LambdaDKG = d.LambdaDKG
@@ -52,6 +54,7 @@ func (d *DexconConfig) UnmarshalJSON(input []byte) error {
GenesisCRSText *string `json:"genesisCRSText"`
Owner *common.Address `json:"owner"`
BlockReward *math.HexOrDecimal256 `json:"blockReward"`
+ BlockGasLimit *uint64 `json:"blockGasLimit"`
NumChains *uint32 `json:"numChains"`
LambdaBA *uint64 `json:"lambdaBA"`
LambdaDKG *uint64 `json:"lambdaDKG"`
@@ -76,6 +79,9 @@ func (d *DexconConfig) UnmarshalJSON(input []byte) error {
if dec.BlockReward != nil {
d.BlockReward = (*big.Int)(dec.BlockReward)
}
+ if dec.BlockGasLimit != nil {
+ d.BlockGasLimit = *dec.BlockGasLimit
+ }
if dec.NumChains != nil {
d.NumChains = *dec.NumChains
}
diff --git a/test/genesis.json b/test/genesis.json
index 23c8fc3d8..6ad621c6d 100644
--- a/test/genesis.json
+++ b/test/genesis.json
@@ -10,6 +10,7 @@
"genesisCRSText": "In DEXON, we trust.",
"owner": "0xBF8C48A620bacc46907f9B89732D25E47A2D7Cf7",
"blockReward": "1000000000000000000",
+ "blockGasLimit": 80000000,
"numChains": 4,
"lambdaBA": 250,
"lambdaDKG": 4000,
@@ -17,7 +18,7 @@
"phiRatio": 667000,
"notarySetSize": 4,
"dkgSetSize": 4,
- "roundInterval": 300000,
+ "roundInterval": 600000,
"minBlockInterval": 900,
"maxBlockInterval": 1100
}