aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2019-01-28 13:43:05 +0800
committerWei-Ning Huang <w@byzantine-lab.io>2019-06-12 17:27:22 +0800
commitc3fede5add8b5b926f613241208a1cf9b0696874 (patch)
treee813591b731123c59d651687d3216bf328fe004f
parent05d4b99e029f263b69deaf2bd9f98f3dc355ec81 (diff)
downloadgo-tangerine-c3fede5add8b5b926f613241208a1cf9b0696874.tar
go-tangerine-c3fede5add8b5b926f613241208a1cf9b0696874.tar.gz
go-tangerine-c3fede5add8b5b926f613241208a1cf9b0696874.tar.bz2
go-tangerine-c3fede5add8b5b926f613241208a1cf9b0696874.tar.lz
go-tangerine-c3fede5add8b5b926f613241208a1cf9b0696874.tar.xz
go-tangerine-c3fede5add8b5b926f613241208a1cf9b0696874.tar.zst
go-tangerine-c3fede5add8b5b926f613241208a1cf9b0696874.zip
core/vm: modify Withdrawn event and add NodeRemoved event (#179)
* core/vm: add delegatorAddr to withdrawn event * core/vm: update gov abi * core/vm: add NodeRemoved event
-rw-r--r--core/vm/oracle_contract_abi.go17
-rw-r--r--core/vm/oracle_contracts.go18
2 files changed, 31 insertions, 4 deletions
diff --git a/core/vm/oracle_contract_abi.go b/core/vm/oracle_contract_abi.go
index 1c630c1c8..0f771a1a9 100644
--- a/core/vm/oracle_contract_abi.go
+++ b/core/vm/oracle_contract_abi.go
@@ -673,6 +673,18 @@ const GovernanceABIJSON = `
"indexed": true,
"name": "NodeAddress",
"type": "address"
+ }
+ ],
+ "name": "NodeRemoved",
+ "type": "event"
+ },
+ {
+ "anonymous": false,
+ "inputs": [
+ {
+ "indexed": true,
+ "name": "NodeAddress",
+ "type": "address"
},
{
"indexed": true,
@@ -719,6 +731,11 @@ const GovernanceABIJSON = `
"type": "address"
},
{
+ "indexed": true,
+ "name": "DelegatorAddress",
+ "type": "address"
+ },
+ {
"indexed": false,
"name": "Amount",
"type": "uint256"
diff --git a/core/vm/oracle_contracts.go b/core/vm/oracle_contracts.go
index 5f83ca68f..8e276f97c 100644
--- a/core/vm/oracle_contracts.go
+++ b/core/vm/oracle_contracts.go
@@ -967,6 +967,15 @@ func (s *GovernanceStateHelper) emitUnstaked(nodeAddr common.Address) {
})
}
+// event NodeRemoved(address indexed NodeAddress);
+func (s *GovernanceStateHelper) emitNodeRemoved(nodeAddr common.Address) {
+ s.StateDB.AddLog(&types.Log{
+ Address: GovernanceContractAddress,
+ Topics: []common.Hash{GovernanceABI.Events["NodeRemoved"].Id(), nodeAddr.Hash()},
+ Data: []byte{},
+ })
+}
+
// event Delegated(address indexed NodeAddress, address indexed DelegatorAddress, uint256 Amount);
func (s *GovernanceStateHelper) emitDelegated(nodeAddr, delegatorAddr common.Address, amount *big.Int) {
s.StateDB.AddLog(&types.Log{
@@ -985,11 +994,11 @@ func (s *GovernanceStateHelper) emitUndelegated(nodeAddr, delegatorAddr common.A
})
}
-// event Withdrawn(address indexed NodeAddress, uint256 Amount);
-func (s *GovernanceStateHelper) emitWithdrawn(nodeAddr common.Address, amount *big.Int) {
+// event Withdrawn(address indexed NodeAddress, address indexed DelegatorAddress, uint256 Amount);
+func (s *GovernanceStateHelper) emitWithdrawn(nodeAddr common.Address, delegatorAddr common.Address, amount *big.Int) {
s.StateDB.AddLog(&types.Log{
Address: GovernanceContractAddress,
- Topics: []common.Hash{GovernanceABI.Events["Withdrawn"].Id(), nodeAddr.Hash()},
+ Topics: []common.Hash{GovernanceABI.Events["Withdrawn"].Id(), nodeAddr.Hash(), delegatorAddr.Hash()},
Data: common.BigToHash(amount).Bytes(),
})
}
@@ -1460,7 +1469,7 @@ func (g *GovernanceContract) withdraw(nodeAddr common.Address) ([]byte, error) {
return nil, errExecutionReverted
}
- g.state.emitWithdrawn(nodeAddr, delegator.Value)
+ g.state.emitWithdrawn(nodeAddr, delegator.Owner, delegator.Value)
// We are the last delegator to withdraw the fund, remove the node info.
if g.state.LenDelegators(nodeAddr).Cmp(big.NewInt(0)) == 0 {
@@ -1477,6 +1486,7 @@ func (g *GovernanceContract) withdraw(nodeAddr common.Address) ([]byte, error) {
}
g.state.DeleteNodesOffsetByAddress(nodeAddr)
g.state.PopLastNode()
+ g.state.emitNodeRemoved(nodeAddr)
}
return g.useGas(100000)