aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWei-Ning Huang <w@dexon.org>2019-03-28 13:28:01 +0800
committerWei-Ning Huang <w@byzantine-lab.io>2019-06-15 22:09:55 +0800
commitd2bfae48e7f490e803bf09579c021c7720159fc1 (patch)
treed5af513df18dff71ad1f2ad6788032fc00e614a6
parent8732c918f7b5d3dd9ac45b6e00995f5d74bc8a47 (diff)
downloadgo-tangerine-d2bfae48e7f490e803bf09579c021c7720159fc1.tar.gz
go-tangerine-d2bfae48e7f490e803bf09579c021c7720159fc1.tar.zst
go-tangerine-d2bfae48e7f490e803bf09579c021c7720159fc1.zip
core: vm: update set size on node info change (#307)
* core: vm: update set size on node info change * fix typo
-rw-r--r--core/vm/oracle_contracts.go12
1 files changed, 4 insertions, 8 deletions
diff --git a/core/vm/oracle_contracts.go b/core/vm/oracle_contracts.go
index d7c8ffae2..843b23d18 100644
--- a/core/vm/oracle_contracts.go
+++ b/core/vm/oracle_contracts.go
@@ -456,6 +456,9 @@ func (s *GovernanceState) UpdateNode(index *big.Int, n *nodeInfo) {
// UnstakedAt.
loc = new(big.Int).Add(elementBaseLoc, big.NewInt(9))
s.setStateBigInt(loc, n.UnstakedAt)
+
+ // Update set size.
+ s.CalNotarySetSize()
}
func (s *GovernanceState) PopLastNode() {
// Decrease length by 1.
@@ -1051,6 +1054,7 @@ func (s *GovernanceState) UpdateConfigurationRaw(cfg *rawConfigStruct) {
s.setStateBigInt(big.NewInt(minBlockIntervalLoc), cfg.MinBlockInterval)
s.SetFineValues(cfg.FineValues)
+ // Calculate set size.
s.CalNotarySetSize()
}
@@ -1609,8 +1613,6 @@ func (g *GovernanceContract) register(
if value.Cmp(big.NewInt(0)) > 0 {
g.state.IncTotalStaked(value)
g.state.emitStaked(caller, value)
-
- g.state.CalNotarySetSize()
}
return g.useGas(GovernanceActionGasCost)
}
@@ -1639,8 +1641,6 @@ func (g *GovernanceContract) stake() ([]byte, error) {
g.state.IncTotalStaked(value)
g.state.emitStaked(caller, value)
- g.state.CalNotarySetSize()
-
return g.useGas(GovernanceActionGasCost)
}
@@ -1675,8 +1675,6 @@ func (g *GovernanceContract) unstake(amount *big.Int) ([]byte, error) {
g.state.DecTotalStaked(amount)
g.state.emitUnstaked(caller, amount)
- g.state.CalNotarySetSize()
-
return g.useGas(GovernanceActionGasCost)
}
@@ -1755,8 +1753,6 @@ func (g *GovernanceContract) payFine(nodeAddr common.Address) ([]byte, error) {
g.state.emitFinePaid(nodeAddr, g.contract.Value())
- g.state.CalNotarySetSize()
-
return g.useGas(GovernanceActionGasCost)
}