reward

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 29, 2022 License: LGPL-3.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// protect kblock size
	MaxNAutobidTx = meter.MaxNClausePerAutobidTx * 10
)
View Source
const (
	N = 24 // history buffer size

)

Variables

View Source
var (
	UnitWei  = big.NewInt(1e18)
	UnitKWei = big.NewInt(1e15)
	UnitMWei = big.NewInt(1e12)
	UnitGWei = big.NewInt(1e9)
)

Functions

func BuildAccountLockGoverningTx

func BuildAccountLockGoverningTx(chainTag byte, bestNum uint32, curEpoch uint32) *tx.Transaction

func BuildAuctionControlTx

func BuildAuctionControlTx(height, epoch uint64, chainTag byte, bestNum uint32, initialRelease float64, reservedPrice *big.Int, chain *chain.Chain) *tx.Transaction

func BuildAutobidData

func BuildAutobidData(autobid *RewardInfo) (ret []byte)

func BuildAutobidTx

func BuildAutobidTx(autobidList []*RewardInfo, chainTag byte, bestNum uint32) *tx.Transaction

func BuildAutobidTxs

func BuildAutobidTxs(autobidList []*RewardInfo, chainTag byte, bestNum uint32) tx.Transactions

func BuildMinerRewardTxs

func BuildMinerRewardTxs(rewards []powpool.PowReward, chainTag byte, bestNum uint32) tx.Transactions

func BuildStakingGoverningTx

func BuildStakingGoverningTx(distList []*RewardInfo, curEpoch uint32, chainTag byte, bestNum uint32) *tx.Transaction

for distribute validator rewards, recalc the delegates list ...

func BuildStatisticsTx

func BuildStatisticsTx(entries []*StatEntry, chainTag byte, bestNum uint32, curEpoch uint32) *tx.Transaction

create statistics transaction

func ComputeDoubleSigner

func ComputeDoubleSigner(common *types.ConsensusCommon, blocks []*block.Block, curEpoch uint32) ([]*doubleSignerInfo, error)

func ComputeEpochBaseReward

func ComputeEpochBaseReward(validatorBaseReward *big.Int) *big.Int

func ComputeEpochReleaseWithInflation

func ComputeEpochReleaseWithInflation(sequence uint64, lastAuction *auction.AuctionCB) (*big.Int, error)

calEpochReleaseWithInflation returns the release of MTRG for current epoch, it returns a 0 if curEpoch is less than startEpoch epochRelease = lastEpochRelease + lastEpochRelease * deltaRate whereas, deltaRate = inflationRate / 365 / nAuctionPerDay

func ComputeEpochTotalReward

func ComputeEpochTotalReward(benefitRatio *big.Int, nDays int, nAuctionPerDay int) (*big.Int, error)

func ComputeMissingLeader

func ComputeMissingLeader(validators []*types.Validator, actualMembers []types.CommitteeMember, curEpoch uint32) ([]*missingLeaderInfo, error)

func ComputeMissingProposer

func ComputeMissingProposer(validators []*types.Validator, actualMembers []types.CommitteeMember, blocks []*block.Block, curEpoch uint32) ([]*missingProposerInfo, error)

func ComputeMissingVoter

func ComputeMissingVoter(validators []*types.Validator, actualMembers []types.CommitteeMember, blocks []*block.Block) ([]*missingVoterInfo, error)

func FloatToBigInt

func FloatToBigInt(val float64) *big.Int

func GetValidatorBaseRewards

func GetValidatorBaseRewards(state *state.State) *big.Int

func GetValidatorBenefitRatio

func GetValidatorBenefitRatio(state *state.State) *big.Int

Types

type RewardInfo

type RewardInfo struct {
	Address meter.Address
	Amount  *big.Int
}

func (RewardInfo) String

func (r RewardInfo) String() string

type RewardMap

type RewardMap map[meter.Address]*RewardMapInfo

func ComputeRewardMap

func ComputeRewardMap(baseReward, totalRewards *big.Int, delegates []*types.Delegate, v3 bool) (RewardMap, error)

Epoch Reward includes these parts:

              |------ extra_reward -----|
|------|   |------------|   |---------------|
| base | + | commission | + | actual_reward |  =  each_reward
|------|   |------------|   |---------------|

such that: sum(extra_reward) = total_rewards - base * delegate_size commission = sum(extra_reward) * voting_power_ratio * commission_rate actual_reward = sum(extra_reward) * voting_power_ratio - commission delgate_reward = base + commission + actual_reward * delgate_share_ratio voter_reward = actual_reward * voter_share_ratio

Steps: 1. distributes the base reward (meter.ValidatorBaseReward) for each validator. If there is remainning 2. get the propotion reward for each validator based on the votingpower 3. each validator takes commission first 4. finally, distributor takes their propotions of rest

func ComputeRewardMapV2

func ComputeRewardMapV2(baseReward, totalRewards *big.Int, delegates []*types.Delegate, committeeMembers []*types.Validator) (RewardMap, error)

func ComputeRewardMapV3

func ComputeRewardMapV3(baseReward, totalRewards *big.Int, delegates []*types.Delegate, committeeMembers []*types.Validator) (RewardMap, error)

func (RewardMap) Add

func (rmap RewardMap) Add(dist, autobid *big.Int, addr meter.Address) error

func (RewardMap) GetAutobidList

func (rmap RewardMap) GetAutobidList() []*RewardInfo

func (RewardMap) GetDistList

func (rmap RewardMap) GetDistList() []*RewardInfo

func (RewardMap) ToList

func (rmap RewardMap) ToList() (*big.Int, *big.Int, []*RewardMapInfo)

type RewardMapInfo

type RewardMapInfo struct {
	Address       meter.Address
	DistAmount    *big.Int
	AutobidAmount *big.Int
}

// RewardMap

func (*RewardMapInfo) String

func (r *RewardMapInfo) String() string

type StatEntry

type StatEntry struct {
	Address    meter.Address
	Name       string
	PubKey     string
	Infraction staking.Infraction
}

func ComputeStatistics

func ComputeStatistics(lastKBlockHeight, height uint32, chain *chain.Chain, curCommittee *types.ValidatorSet, curActualCommittee []types.CommitteeMember, csCommon *types.ConsensusCommon, newCommittee bool, curEpoch uint32) ([]*StatEntry, error)

func (StatEntry) String

func (e StatEntry) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL