diff options
author | Wei-Ning Huang <w@dexon.org> | 2018-10-31 14:00:13 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@dexon.org> | 2019-04-09 21:32:52 +0800 |
commit | 89b4e46f7c319e48425fc0a3af810f66d6778a1e (patch) | |
tree | 1bf02bfa8b0c18a7894e953170ef16677d53fc2a /core | |
parent | 080b562fc0dc529c09b64fb4acc654987d3d1eb6 (diff) | |
download | dexon-89b4e46f7c319e48425fc0a3af810f66d6778a1e.tar.gz dexon-89b4e46f7c319e48425fc0a3af810f66d6778a1e.tar.zst dexon-89b4e46f7c319e48425fc0a3af810f66d6778a1e.zip |
dex: add block gas limit into governance
Diffstat (limited to 'core')
-rw-r--r-- | core/vm/governance.go | 35 |
1 files changed, 35 insertions, 0 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 ¶ms.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))) |