Skip to content

Commit 893c419

Browse files
committed
init vote and freeze tip
1 parent a73b884 commit 893c419

File tree

2 files changed

+144
-0
lines changed

2 files changed

+144
-0
lines changed

tip-156.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
```
2+
tip: 156
3+
title: Vote instructions in TVM
4+
author: taihao.fu@gmail.com
5+
status: Draft
6+
type: Standards Track
7+
category : Core
8+
created: 2020-06-03
9+
10+
```
11+
12+
## Simple Summary
13+
14+
To provide vote related operations in TVM.
15+
16+
## Abstract
17+
18+
Vote & withdrawBalance operation in system contract are introduced, smart contract can vote for witness and get reward from the system.
19+
20+
## Motivation
21+
22+
Common user can vote for activated witness to get block reward. However, none privatekey accounts, like smart contracts, can't get benefit from this incentive mechanism. This TIP provide instructions to implement the incentive functionalities.
23+
24+
## Specification
25+
26+
The following instructions are introduced:
27+
28+
### `0xd9`: `VOTE`
29+
30+
The `VOTE` takes 4 operands pop up from stack:
31+
`witnessOffset`: witness information offset.
32+
`witnessSize`: witness information size.
33+
`tronPowerOffset`: tron power information.
34+
`tronPowerSize`: tron power information array size.
35+
36+
TVM will get sr array from memory by using `witnessOffset` and `witnessSize`.
37+
TVM will get tron power nubmer array from memory by using `tronPowerOffset` and `tronPowerSize`.
38+
39+
Execute vote function and push 0 to stack if fail, push 1 otherwize.
40+
41+
### `0xda`: `WITHDRAWBALANCE`
42+
43+
The `WITHDRAWBALANCE` takes 1 operand from stack.
44+
`accountAddress`: target account address.
45+
46+
Execute withdraw function and push 0 to stack if fail, push 1 otherwise.
47+
48+
### `0xdb`: `REWARDBALANCE`
49+
50+
The `REWARDBALANCE` takes 1 operand from stack.
51+
`accountAddress`: target account address.
52+
53+
Push the block reward balance of the target address to stack.
54+
55+
### `0xdc`: `ISWITNESS`
56+
57+
The `ISWITNESS` takes 1 operand from stack.
58+
`accountAddress`: target account address.
59+
60+
Push 0 if target address is not a witness, otherwise push 1.
61+
62+
## Rationale
63+
64+
`VOTE` tier.ExtTier
65+
`WITHDRAWBALANCE` tier.ExtTier
66+
`REWARDBALANCE` tier.ExtTier
67+
`ISWITNESS` tier.ExtTier

tip-157.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
```
2+
tip: 156
3+
title: Freeze instructions in TVM
4+
author: taihao.fu@gmail.com
5+
status: Draft
6+
type: Standards Track
7+
category : Core
8+
created: 2020-06-03
9+
10+
```
11+
12+
## Simple Summary
13+
14+
To provide freeze related operations in TVM.
15+
16+
## Abstract
17+
18+
Freeze & Unfreeze operation in system contract are introduced, smart contract can freeze and get resource from the system.
19+
20+
## Motivation
21+
22+
Common user can freeze TRX to get resource, such as TRON power, bandwidth, energy. However, none privatekey accounts, like smart contracts, can't get al resources from the staking mechanism. This TIP provide instructions to get resource, so that smart contracts can provide tron power for voting and aslo provide resource delegation to others.
23+
24+
## Specification
25+
26+
The following instructions are introduced:
27+
28+
### `0xd5`: `FREEZE`
29+
30+
The `FREEZE` takes 4 operands pop up from stack:
31+
`delegatedAddress`: the target address to delegate frozen TRX generated resource to.
32+
`freezeAmount`: TRX amount to freeze in SUN.
33+
`day`: time duration willing to freeze TRX in day.
34+
`resourceType`: 0 as bandwidth, 1 as energy.
35+
36+
Execute freeze function and push 0 to stack if fail, push 1 otherwize.
37+
38+
### `0xd6`: `UNFREEZE`
39+
40+
The `UNFREEZE` takes 2 operands from stack.
41+
`delegatedAddress`: the target address to delegate frozen TRX generated resource to.
42+
`resourceType`: 0 as bandwidth, 1 as energy.
43+
44+
Execute UNFREEZE function and push 0 to stack if fail, push 1 otherwise.
45+
46+
### `0xd7`: `BANDWIDTHVAlUE`
47+
48+
The `BANDWIDTHVAlUE` takes 1 operand from stack.
49+
`accountAddress`: target account address.
50+
51+
Push current frozen generated bandwidth value of the target address to stack.
52+
53+
### `0xd8`: `ENERGYVALUE`
54+
55+
The `ENERGYVALUE` takes 1 operand from stack.
56+
`accountAddress`: target account address.
57+
58+
Push current frozen generated energy value of the target address to stack.
59+
60+
## Rationale
61+
62+
### Tier
63+
64+
`FREEZE` tier.ExtTier
65+
`UNFREEZE` tier.ExtTier
66+
`BANDWIDTHVAlUE` tier.ExtTier
67+
`ENERGYVALUE` tier.ExtTier
68+
69+
### Selfdestruct
70+
71+
When selfdestruct is executed, 2 cases need to be considered:
72+
73+
1. Any type of account A delegates its resource to contract B and B selfdestruct itself to address C.
74+
Now, C should preserve the delegated resource from A.
75+
76+
2. Contract A delegates its resource to any type of account B and A selfdestruct itself to address C.
77+
Now, C should preserve the privilege that delegate resource to B. C can't unfreeze its delegation with B until frozen time exceed to the expiration date,.

0 commit comments

Comments
 (0)