aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWei-Ning Huang <w@byzantine-lab.io>2019-08-27 23:42:58 +0800
committerWei-Ning Huang <w@byzantine-lab.io>2019-09-17 16:57:31 +0800
commit0c18330437a5efc236602fb6f9ede57e6f17828b (patch)
treeccb67ef27b208a3d7b69dce3ae35f9852b3045ac
parent8d2396a5aa3f9963369a7d37128447b5be20903b (diff)
downloadgo-tangerine-0c18330437a5efc236602fb6f9ede57e6f17828b.tar
go-tangerine-0c18330437a5efc236602fb6f9ede57e6f17828b.tar.gz
go-tangerine-0c18330437a5efc236602fb6f9ede57e6f17828b.tar.bz2
go-tangerine-0c18330437a5efc236602fb6f9ede57e6f17828b.tar.lz
go-tangerine-0c18330437a5efc236602fb6f9ede57e6f17828b.tar.xz
go-tangerine-0c18330437a5efc236602fb6f9ede57e6f17828b.tar.zst
go-tangerine-0c18330437a5efc236602fb6f9ede57e6f17828b.zip
Revert "core: consider reset round when getting config state"
This reverts commit 01cb8de88b0697879cc366e3ee962c9523dfcc14.
-rw-r--r--core/governance.go2
-rw-r--r--core/vm/oracle_contracts.go2
-rw-r--r--core/vm/utils.go40
3 files changed, 9 insertions, 35 deletions
diff --git a/core/governance.go b/core/governance.go
index 8cfed5e13..8bad0ca98 100644
--- a/core/governance.go
+++ b/core/governance.go
@@ -110,7 +110,7 @@ func (g *Governance) GetStateForDKGAtRound(round uint64) (*vm.GovernanceState, e
if round == dkgRound {
return gs, nil
}
- return g.util.GetRoundState(round)
+ return g.util.GetStateAtRound(round)
}
func (g *Governance) CRSRound() uint64 {
diff --git a/core/vm/oracle_contracts.go b/core/vm/oracle_contracts.go
index f30ed3bdb..10c8da424 100644
--- a/core/vm/oracle_contracts.go
+++ b/core/vm/oracle_contracts.go
@@ -2299,7 +2299,7 @@ func (g *GovernanceContract) resetDKG(newSignedCRS []byte) ([]byte, error) {
g.fineFailStopDKG(nackThreshold)
// Update CRS.
- state, err := g.util.GetRoundState(round.Uint64())
+ state, err := g.util.GetStateAtRound(round.Uint64())
if err != nil {
return nil, errExecutionReverted
}
diff --git a/core/vm/utils.go b/core/vm/utils.go
index 5ccc47867..0cc6343cc 100644
--- a/core/vm/utils.go
+++ b/core/vm/utils.go
@@ -28,7 +28,7 @@ func (g GovUtil) GetRoundHeight(round uint64) uint64 {
return gs.RoundHeight(big.NewInt(int64(round))).Uint64()
}
-func (g GovUtil) GetRoundState(round uint64) (*GovernanceState, error) {
+func (g GovUtil) GetStateAtRound(round uint64) (*GovernanceState, error) {
height := g.GetRoundHeight(round)
if round != 0 && height == 0 {
@@ -44,38 +44,12 @@ func (g GovUtil) GetRoundState(round uint64) (*GovernanceState, error) {
}
func (g GovUtil) GetConfigState(round uint64) (*GovernanceState, error) {
- headState, err := g.Intf.GetHeadGovState()
- if err != nil {
- return nil, err
- }
-
if round < dexCore.ConfigRoundShift {
- return g.GetRoundState(0)
- }
-
- resetCount := headState.DKGResetCount(new(big.Int).SetUint64(round)).Uint64()
-
- // If we are resetting more round then ConfigRoundShift, we need to get the
- // state of (resetCount - ConfigRoundShift) instead.
- if resetCount >= dexCore.ConfigRoundShift {
- shift := resetCount - dexCore.ConfigRoundShift
-
- prevConfigState, err := g.GetConfigState(round - 1)
- if err != nil {
- log.Error("Failed to get previous round config state", "round", round-1)
- return nil, err
- }
-
- height := g.GetRoundHeight(round-1) + shift*prevConfigState.RoundLength().Uint64()
- s, err := g.Intf.StateAt(height)
- if err != nil {
- log.Error("Failed to get state", "height", height)
- return nil, err
- }
- return &GovernanceState{StateDB: s}, nil
+ round = 0
+ } else {
+ round -= dexCore.ConfigRoundShift
}
-
- return g.GetRoundState(round - dexCore.ConfigRoundShift)
+ return g.GetStateAtRound(round)
}
func (g *GovUtil) CRSRound() uint64 {
@@ -88,7 +62,7 @@ func (g *GovUtil) CRSRound() uint64 {
func (g GovUtil) CRS(round uint64) common.Hash {
if round <= dexCore.DKGDelayRound {
- s, err := g.GetRoundState(0)
+ s, err := g.GetStateAtRound(0)
if err != nil {
return common.Hash{}
}
@@ -109,7 +83,7 @@ func (g GovUtil) CRS(round uint64) common.Hash {
return common.Hash{}
}
} else {
- s, err = g.GetRoundState(round)
+ s, err = g.GetStateAtRound(round)
if err != nil {
return common.Hash{}
}