Skip to content

Latest commit

 

History

History
93 lines (56 loc) · 2.24 KB

tip-156.md

File metadata and controls

93 lines (56 loc) · 2.24 KB
tip:  156
title: Vote instructions in TVM
author: taihao.fu@gmail.com
status: Draft
type: Standards Track
category : Core
created: 2020-06-03

Simple Summary

To provide vote related operations in TVM.

Abstract

Vote & withdrawReward operation in system contract are introduced, smart contract can vote for witness and get reward from the system.

Motivation

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.

Specification

The following instructions are introduced:

0xd9: VOTE

The VOTE takes 4 operands pop up from stack:

witnessOffset: witness information offset.

witnessSize: witness information size.

tronPowerOffset: tron power information.

tronPowerSize: tron power information array size.

TVM will get sr array from memory by using witnessOffset and witnessSize.

TVM will get tron power nubmer array from memory by using tronPowerOffset and tronPowerSize.

Execute vote function and push 0 to stack if fail, push 1 otherwize.

0xda: WITHDRAWREWARD

The WITHDRAWREWARD takes 1 operand from stack.

accountAddress: target account address.

Execute withdraw function and push 0 to stack if fail, push 1 otherwise.

0xdc: ISWITNESS

The ISWITNESS takes 1 operand from stack.

accountAddress: target account address.

Push 0 if target address is not a witness, otherwise push 1.

Result show in SystemLog

SystemLog is contains system level operation result in transactioninfo for a specific transaction.

A system log structure can be defined as below:

message SystemLog {
  enum operationType {
    VOTE = 1;
    WITHDRAWREWARD = 2;
  }
  bytes address = 1; // user address or contract address
  repeated bytes params = 2;
  // VOTE contains 2 parameters: VOTE(toAddress, TRONPowerValue);
  // WITHDRAWREWARD contains 1 parameter: WITHDRAWREWARD(toAddress);
  
  operationType type = 3;
}

Vote and withdraw infomation will be record in the SystemLog field in transactionInfo.

Rationale

VOTE tier.ExtTier

WITHDRAWREWARD tier.ExtTier

REWARDBALANCE tier.ExtTier

ISWITNESS tier.ExtTier