aboutsummaryrefslogtreecommitdiffstats
path: root/core/vm
diff options
context:
space:
mode:
authorWei-Ning Huang <w@dexon.org>2018-10-31 14:00:13 +0800
committerWei-Ning Huang <w@byzantine-lab.io>2019-06-12 17:27:17 +0800
commit0cbf04193ea79661f191cdaaca8f179d8b5db999 (patch)
tree07be18996fb0524204cd4f58567297350fae933a /core/vm
parent0f189998574d54b8e2d64642b6b689f35a09d23a (diff)
downloadgo-tangerine-0cbf04193ea79661f191cdaaca8f179d8b5db999.tar
go-tangerine-0cbf04193ea79661f191cdaaca8f179d8b5db999.tar.gz
go-tangerine-0cbf04193ea79661f191cdaaca8f179d8b5db999.tar.bz2
go-tangerine-0cbf04193ea79661f191cdaaca8f179d8b5db999.tar.lz
go-tangerine-0cbf04193ea79661f191cdaaca8f179d8b5db999.tar.xz
go-tangerine-0cbf04193ea79661f191cdaaca8f179d8b5db999.tar.zst
go-tangerine-0cbf04193ea79661f191cdaaca8f179d8b5db999.zip
dex: add block gas limit into governance
Diffstat (limited to 'core/vm')
-rw-r--r--core/vm/governance.go35
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 &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)))