diff options
author | Wei-Ning Huang <w@dexon.org> | 2018-10-31 14:00:13 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@dexon.org> | 2019-03-12 12:19:09 +0800 |
commit | 3d61c2bd98c4f22c05585ed5448eb02b87e38869 (patch) | |
tree | 2e307739fb67d92a851e4fba212222385479dbcb /core/vm | |
parent | 53af3aa918f2d870b834952d14cf14efc365aca2 (diff) | |
download | dexon-3d61c2bd98c4f22c05585ed5448eb02b87e38869.tar dexon-3d61c2bd98c4f22c05585ed5448eb02b87e38869.tar.gz dexon-3d61c2bd98c4f22c05585ed5448eb02b87e38869.tar.bz2 dexon-3d61c2bd98c4f22c05585ed5448eb02b87e38869.tar.lz dexon-3d61c2bd98c4f22c05585ed5448eb02b87e38869.tar.xz dexon-3d61c2bd98c4f22c05585ed5448eb02b87e38869.tar.zst dexon-3d61c2bd98c4f22c05585ed5448eb02b87e38869.zip |
dex: add block gas limit into governance
Diffstat (limited to 'core/vm')
-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))) |