diff options
author | Wei-Ning Huang <w@dexon.org> | 2018-10-31 14:00:13 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@dexon.org> | 2018-12-19 20:54:27 +0800 |
commit | c6e94db9e999211c8564969e113d43a907a55835 (patch) | |
tree | 04171d286c99594ee8eef1d63a3efd2a7d89fca7 /core | |
parent | ad92c958334faeba42a3007f29f50c4f253411c1 (diff) | |
download | dexon-c6e94db9e999211c8564969e113d43a907a55835.tar dexon-c6e94db9e999211c8564969e113d43a907a55835.tar.gz dexon-c6e94db9e999211c8564969e113d43a907a55835.tar.bz2 dexon-c6e94db9e999211c8564969e113d43a907a55835.tar.lz dexon-c6e94db9e999211c8564969e113d43a907a55835.tar.xz dexon-c6e94db9e999211c8564969e113d43a907a55835.tar.zst dexon-c6e94db9e999211c8564969e113d43a907a55835.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))) |