diff options
author | Sonic <sonic@dexon.org> | 2018-11-13 17:51:27 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@dexon.org> | 2018-12-19 20:54:27 +0800 |
commit | 2cfbfbe4acf7f5adf61410f94e0b0f5a08638698 (patch) | |
tree | b01338bdb71fec6948d584696149096d85a2b89b /core | |
parent | f6c440bddb373ee6ceb02975d88f9becd5cb6136 (diff) | |
download | dexon-2cfbfbe4acf7f5adf61410f94e0b0f5a08638698.tar dexon-2cfbfbe4acf7f5adf61410f94e0b0f5a08638698.tar.gz dexon-2cfbfbe4acf7f5adf61410f94e0b0f5a08638698.tar.bz2 dexon-2cfbfbe4acf7f5adf61410f94e0b0f5a08638698.tar.lz dexon-2cfbfbe4acf7f5adf61410f94e0b0f5a08638698.tar.xz dexon-2cfbfbe4acf7f5adf61410f94e0b0f5a08638698.tar.zst dexon-2cfbfbe4acf7f5adf61410f94e0b0f5a08638698.zip |
core: push height of round 0 in genesis block (#17)
* core: push height of round 0 in genesis block
* vm: fix governance dispatch method name mismatch with abi
also rename RoundHeightLoc to roundHeightLoc
Diffstat (limited to 'core')
-rw-r--r-- | core/genesis.go | 3 | ||||
-rw-r--r-- | core/vm/governance.go | 16 |
2 files changed, 11 insertions, 8 deletions
diff --git a/core/genesis.go b/core/genesis.go index 245fe9fff..c598f1d16 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -306,6 +306,9 @@ func (g *Genesis) ToBlock(db ethdb.Database) *types.Block { crs := crypto.Keccak256([]byte(g.Config.Dexcon.GenesisCRSText)) govStateHelper.PushCRS(common.BytesToHash(crs)) + // Round 0 height. + govStateHelper.PushRoundHeight(big.NewInt(0)) + // Owner. govStateHelper.SetOwner(g.Config.Dexcon.Owner) diff --git a/core/vm/governance.go b/core/vm/governance.go index cc453ace7..49141761f 100644 --- a/core/vm/governance.go +++ b/core/vm/governance.go @@ -917,7 +917,7 @@ func RunGovernanceContract(evm *EVM, input []byte, contract *Contract) ( return nil, errExecutionReverted } return res, nil - case "RoundHeight": + case "roundHeight": round := new(big.Int) if err := method.Inputs.Unpack(&round, arguments); err != nil { return nil, errExecutionReverted @@ -939,7 +939,7 @@ func RunGovernanceContract(evm *EVM, input []byte, contract *Contract) ( // Storage position enums. const ( - RoundHeightLoc = iota + roundHeightLoc = iota nodesLoc offsetLoc crsLoc @@ -1096,21 +1096,21 @@ func (s *GovernanceStateHelper) appendTo2DByteArray(pos, index *big.Int, data [] s.writeBytes(elementLoc, data) } -// uint256[] public RoundHeight; +// uint256[] public roundHeight; func (s *GovernanceStateHelper) LenRoundHeight() *big.Int { - return s.getStateBigInt(big.NewInt(RoundHeightLoc)) + return s.getStateBigInt(big.NewInt(roundHeightLoc)) } func (s *GovernanceStateHelper) RoundHeight(round *big.Int) *big.Int { - baseLoc := s.getSlotLoc(big.NewInt(RoundHeightLoc)) + baseLoc := s.getSlotLoc(big.NewInt(roundHeightLoc)) loc := new(big.Int).Add(baseLoc, round) return s.getStateBigInt(loc) } func (s *GovernanceStateHelper) PushRoundHeight(height *big.Int) { // increase length by 1. - length := s.getStateBigInt(big.NewInt(RoundHeightLoc)) - s.setStateBigInt(big.NewInt(RoundHeightLoc), new(big.Int).Add(length, big.NewInt(1))) + length := s.getStateBigInt(big.NewInt(roundHeightLoc)) + s.setStateBigInt(big.NewInt(roundHeightLoc), new(big.Int).Add(length, big.NewInt(1))) - baseLoc := s.getSlotLoc(big.NewInt(RoundHeightLoc)) + baseLoc := s.getSlotLoc(big.NewInt(roundHeightLoc)) loc := new(big.Int).Add(baseLoc, length) s.setStateBigInt(loc, height) |