aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorWei-Ning Huang <w@dexon.org>2018-10-19 16:31:44 +0800
committerWei-Ning Huang <w@byzantine-lab.io>2019-06-12 17:23:39 +0800
commit93563f41410b964454f23229cfabe1ec1ba735f5 (patch)
tree4fbae033c7abf67076e5e04fd43a3931c8525392 /core
parent9ec8fa02e86e992f8dc6a1f230b2e406178f24de (diff)
downloadgo-tangerine-93563f41410b964454f23229cfabe1ec1ba735f5.tar
go-tangerine-93563f41410b964454f23229cfabe1ec1ba735f5.tar.gz
go-tangerine-93563f41410b964454f23229cfabe1ec1ba735f5.tar.bz2
go-tangerine-93563f41410b964454f23229cfabe1ec1ba735f5.tar.lz
go-tangerine-93563f41410b964454f23229cfabe1ec1ba735f5.tar.xz
go-tangerine-93563f41410b964454f23229cfabe1ec1ba735f5.tar.zst
go-tangerine-93563f41410b964454f23229cfabe1ec1ba735f5.zip
core: vm: add blockReward to governance
Diffstat (limited to 'core')
-rw-r--r--core/genesis.go8
-rw-r--r--core/vm/governance.go35
2 files changed, 39 insertions, 4 deletions
diff --git a/core/genesis.go b/core/genesis.go
index c9f4e2499..4d3edb3e8 100644
--- a/core/genesis.go
+++ b/core/genesis.go
@@ -276,16 +276,16 @@ func (g *Genesis) ToBlock(db ethdb.Database) *types.Block {
govStateHelper.Stake(addr, account.PublicKey, account.Staked)
}
}
+ // Genesis CRS.
+ crs := crypto.Keccak256([]byte(g.Config.Dexcon.GenesisCRSText))
+ govStateHelper.PushCRS(common.BytesToHash(crs))
+
// Owner.
govStateHelper.SetOwner(g.Config.Dexcon.Owner)
// Governance configuration.
govStateHelper.UpdateConfiguration(g.Config.Dexcon)
- // Genesis CRS.
- crs := crypto.Keccak256([]byte(g.Config.Dexcon.GenesisCRSText))
- govStateHelper.PushCRS(common.BytesToHash(crs))
-
root := statedb.IntermediateRoot(false)
head := &types.Header{
Number: new(big.Int).SetUint64(g.Number),
diff --git a/core/vm/governance.go b/core/vm/governance.go
index 2e07ba3eb..b2bb531f2 100644
--- a/core/vm/governance.go
+++ b/core/vm/governance.go
@@ -42,6 +42,20 @@ const abiJSON = `
[
{
"constant": true,
+ "inputs": [],
+ "name": "blockReward",
+ "outputs": [
+ {
+ "name": "",
+ "type": "uint256"
+ }
+ ],
+ "payable": false,
+ "stateMutability": "view",
+ "type": "function"
+ },
+ {
+ "constant": true,
"inputs": [
{
"name": "",
@@ -407,6 +421,10 @@ const abiJSON = `
"constant": false,
"inputs": [
{
+ "name": "BlockReward",
+ "type": "uint256"
+ },
+ {
"name": "NumChains",
"type": "uint256"
},
@@ -679,6 +697,12 @@ func RunGovernanceContract(evm *EVM, input []byte, contract *Contract) (
// Solidity auto generated methods.
// --------------------------------
+ case "blockReward":
+ res, err := method.Outputs.Pack(g.state.BlockReward())
+ if err != nil {
+ return nil, errExecutionReverted
+ }
+ return res, nil
case "crs":
round := new(big.Int)
if err := method.Inputs.Unpack(&round, arguments); err != nil {
@@ -856,6 +880,7 @@ const (
dkgFinailizedLoc
dkgFinalizedsCountLoc
ownerLoc
+ blockRewardLoc
numChainsLoc
lambdaBALoc
lambdaDKGLoc
@@ -1183,6 +1208,14 @@ func (s *GovernanceStateHelper) SetOwner(newOwner common.Address) {
s.setState(common.BigToHash(big.NewInt(ownerLoc)), newOwner.Hash())
}
+// uint256 public blockReward;
+func (s *GovernanceStateHelper) BlockReward() *big.Int {
+ return s.getStateBigInt(big.NewInt(blockRewardLoc))
+}
+func (s *GovernanceStateHelper) SetBlockReward(reward *big.Int) {
+ s.setStateBigInt(big.NewInt(blockRewardLoc), reward)
+}
+
// uint256 public numChains;
func (s *GovernanceStateHelper) NumChains() *big.Int {
return s.getStateBigInt(big.NewInt(numChainsLoc))
@@ -1247,6 +1280,7 @@ func (s *GovernanceStateHelper) Stake(addr common.Address, publicKey []byte, sta
// Configuration returns the current configuration.
func (s *GovernanceStateHelper) Configuration() *params.DexconConfig {
return &params.DexconConfig{
+ BlockReward: s.getStateBigInt(big.NewInt(blockRewardLoc)),
NumChains: uint32(s.getStateBigInt(big.NewInt(numChainsLoc)).Uint64()),
LambdaBA: s.getStateBigInt(big.NewInt(lambdaBALoc)).Uint64(),
LambdaDKG: s.getStateBigInt(big.NewInt(lambdaDKGLoc)).Uint64(),
@@ -1262,6 +1296,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(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)))