aboutsummaryrefslogtreecommitdiffstats
path: root/core/vm/governance.go
diff options
context:
space:
mode:
authorWei-Ning Huang <w@dexon.org>2019-01-24 15:05:24 +0800
committerWei-Ning Huang <w@dexon.org>2019-03-12 12:19:09 +0800
commit6c3d02b7c43ee470938fb929f60336d151cf25ca (patch)
tree842113610aae4631622cc1052d7d00e8befc9d8b /core/vm/governance.go
parentdf60600936084e5c0b795c1a53dd65fa778b37be (diff)
downloaddexon-6c3d02b7c43ee470938fb929f60336d151cf25ca.tar
dexon-6c3d02b7c43ee470938fb929f60336d151cf25ca.tar.gz
dexon-6c3d02b7c43ee470938fb929f60336d151cf25ca.tar.bz2
dexon-6c3d02b7c43ee470938fb929f60336d151cf25ca.tar.lz
dexon-6c3d02b7c43ee470938fb929f60336d151cf25ca.tar.xz
dexon-6c3d02b7c43ee470938fb929f60336d151cf25ca.tar.zst
dexon-6c3d02b7c43ee470938fb929f60336d151cf25ca.zip
consensus: dexcon: snapshot round height when finalizing block (#170)
Instead of having BP to send a tx to register the round height, just modify the state when finalizing block.
Diffstat (limited to 'core/vm/governance.go')
-rw-r--r--core/vm/governance.go48
1 files changed, 0 insertions, 48 deletions
diff --git a/core/vm/governance.go b/core/vm/governance.go
index a0014005d..b400ba61b 100644
--- a/core/vm/governance.go
+++ b/core/vm/governance.go
@@ -196,15 +196,6 @@ func RunGovernanceContract(evm *EVM, input []byte, contract *Contract) (ret []by
return nil, errExecutionReverted
}
return g.stake(args.PublicKey, args.Name, args.Email, args.Location, args.Url)
- case "snapshotRound":
- args := struct {
- Round *big.Int
- Height *big.Int
- }{}
- if err := method.Inputs.Unpack(&args, arguments); err != nil {
- return nil, errExecutionReverted
- }
- return g.snapshotRound(args.Round, args.Height)
case "transferOwnership":
var newOwner common.Address
if err := method.Inputs.Unpack(&newOwner, arguments); err != nil {
@@ -711,9 +702,6 @@ func (s *GovernanceStateHelper) appendTo2DByteArray(pos, index *big.Int, data []
}
// uint256[] public roundHeight;
-func (s *GovernanceStateHelper) LenRoundHeight() *big.Int {
- return s.getStateBigInt(big.NewInt(roundHeightLoc))
-}
func (s *GovernanceStateHelper) RoundHeight(round *big.Int) *big.Int {
baseLoc := s.getSlotLoc(big.NewInt(roundHeightLoc))
loc := new(big.Int).Add(baseLoc, round)
@@ -2169,31 +2157,6 @@ func (g *GovernanceContract) transferOwnership(newOwner common.Address) ([]byte,
return nil, nil
}
-func (g *GovernanceContract) snapshotRound(round, height *big.Int) ([]byte, error) {
- // Validate if this mapping is correct. Only block proposer need to verify this.
- if g.evm.IsBlockProposer() {
- realHeight, ok := g.evm.GetRoundHeight(round.Uint64())
- if !ok {
- return g.penalize()
- }
-
- if height.Cmp(new(big.Int).SetUint64(realHeight)) != 0 {
- return g.penalize()
- }
- }
-
- // Only allow updating the next round.
- nextRound := g.state.LenRoundHeight()
- if round.Cmp(nextRound) != 0 {
- // No need to penalize, since the only possibility at this point is the
- // round height is already snapshoted.
- return nil, errExecutionReverted
- }
-
- g.state.PushRoundHeight(height)
- return nil, nil
-}
-
func PackProposeCRS(round uint64, signedCRS []byte) ([]byte, error) {
method := GovernanceContractName2Method["proposeCRS"]
res, err := method.Inputs.Pack(big.NewInt(int64(round)), signedCRS)
@@ -2204,17 +2167,6 @@ func PackProposeCRS(round uint64, signedCRS []byte) ([]byte, error) {
return data, nil
}
-func PackNotifyRoundHeight(targetRound, consensusHeight uint64) ([]byte, error) {
- method := GovernanceContractName2Method["snapshotRound"]
- res, err := method.Inputs.Pack(
- big.NewInt(int64(targetRound)), big.NewInt(int64(consensusHeight)))
- if err != nil {
- return nil, err
- }
- data := append(method.Id(), res...)
- return data, nil
-}
-
func PackAddDKGMasterPublicKey(round uint64, mpk *dkgTypes.MasterPublicKey) ([]byte, error) {
method := GovernanceContractName2Method["addDKGMasterPublicKey"]
encoded, err := rlp.EncodeToBytes(mpk)