iiss

package
v0.9.6 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2021 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Overview

* Copyright 2020 ICON Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.

Index

Constants

View Source
const (
	DayBlock     = 24 * 60 * 60 / 2
	DayPerMonth  = 30
	MonthBlock   = DayBlock * DayPerMonth
	MonthPerYear = 12
	YearBlock    = MonthBlock * MonthPerYear

	IScoreICXRatio        = 1_000
	VotedRewardMultiplier = 100
	RrepMultiplier        = 3      // rrep = rrep + eep + dbp = 3 * rrep
	RrepDivider           = 10_000 // rrep(10_000) = 100.00%, rrep(200) = 2.00%
)
View Source
const (
	InitialIRep = 50_000 // in icx, not loop
	MinIRep     = 10_000
)
View Source
const CodeOffsetForICON = 100
View Source
const (
	CriticalCalculatorError = errors.CodeCritical + CodeOffsetForICON + iota
)
View Source
const InitBlockHeight = -1
View Source
const IrepInflationLimit = 14 // 14%

Variables

View Source
var (
	BigIntIScoreICXRatio = big.NewInt(int64(IScoreICXRatio))
)
View Source
var BigIntInitialIRep = new(big.Int).Mul(new(big.Int).SetInt64(InitialIRep), icutils.BigIntICX)
View Source
var BigIntMinIRep = new(big.Int).Mul(new(big.Int).SetInt64(MinIRep), icutils.BigIntICX)

Functions

func GetIssueData added in v0.9.6

func GetIssueData(es *ExtensionStateImpl) (*IssuePRepJSON, *IssueResultJSON)

GetIssueData return issue information for base TX

func NewExtensionSnapshot added in v0.9.6

func NewExtensionSnapshot(database db.Database, hash []byte) state.ExtensionSnapshot

func NewExtensionSnapshotWithBuilder added in v0.9.6

func NewExtensionSnapshotWithBuilder(builder merkle.Builder, raw []byte) state.ExtensionSnapshot

func RegisterBaseTx

func RegisterBaseTx()

func RegulateIssueInfo added in v0.9.6

func RegulateIssueInfo(issue *icstate.Issue, iScore *big.Int, additionalReward *big.Int)

RegulateIssueInfo regulate icx issue amount with previous period data.

Types

type Calculator added in v0.9.6

type Calculator struct {
	// contains filtered or unexported fields
}

func NewCalculator added in v0.9.6

func NewCalculator() *Calculator

func (*Calculator) Back added in v0.9.6

func (c *Calculator) Back() *icstage.Snapshot

func (*Calculator) Base added in v0.9.6

func (c *Calculator) Base() *icreward.Snapshot

func (*Calculator) CheckToRun added in v0.9.6

func (c *Calculator) CheckToRun(ess state.ExtensionSnapshot) bool

func (*Calculator) IsCalcDone added in v0.9.6

func (c *Calculator) IsCalcDone(blockHeight int64) bool

func (*Calculator) Result added in v0.9.6

func (c *Calculator) Result() *icreward.Snapshot

func (*Calculator) Run added in v0.9.6

func (c *Calculator) Run(ess state.ExtensionSnapshot, logger log.Logger) (err error)

func (*Calculator) StartHeight added in v0.9.6

func (c *Calculator) StartHeight() int64

func (*Calculator) Temp added in v0.9.6

func (c *Calculator) Temp() *icreward.State

func (*Calculator) TotalReward added in v0.9.6

func (c *Calculator) TotalReward() *big.Int

type ExtensionSnapshotImpl added in v0.9.6

type ExtensionSnapshotImpl struct {
	// contains filtered or unexported fields
}

func (*ExtensionSnapshotImpl) Bytes added in v0.9.6

func (s *ExtensionSnapshotImpl) Bytes() []byte

func (*ExtensionSnapshotImpl) Flush added in v0.9.6

func (s *ExtensionSnapshotImpl) Flush() error

func (*ExtensionSnapshotImpl) NewState added in v0.9.6

func (s *ExtensionSnapshotImpl) NewState(readonly bool) state.ExtensionState

func (*ExtensionSnapshotImpl) RLPDecodeSelf added in v0.9.6

func (s *ExtensionSnapshotImpl) RLPDecodeSelf(d codec.Decoder) error

func (*ExtensionSnapshotImpl) RLPEncodeSelf added in v0.9.6

func (s *ExtensionSnapshotImpl) RLPEncodeSelf(e codec.Encoder) error

type ExtensionStateImpl added in v0.9.6

type ExtensionStateImpl struct {
	State  *icstate.State
	Front  *icstage.State
	Back   *icstage.State
	Reward *icreward.State
	// contains filtered or unexported fields
}

func (*ExtensionStateImpl) AddEventBond added in v0.9.6

func (s *ExtensionStateImpl) AddEventBond(blockHeight int64, from module.Address, delta map[string]*big.Int) (err error)

func (*ExtensionStateImpl) CalculationBlockHeight added in v0.9.6

func (s *ExtensionStateImpl) CalculationBlockHeight() int64

func (*ExtensionStateImpl) ClearCache added in v0.9.6

func (s *ExtensionStateImpl) ClearCache()

func (*ExtensionStateImpl) DisqualifyPRep added in v0.9.6

func (s *ExtensionStateImpl) DisqualifyPRep(owner module.Address) error

func (*ExtensionStateImpl) GenesisTerm added in v0.9.6

func (s *ExtensionStateImpl) GenesisTerm(blockHeight int64, revision int) error

func (*ExtensionStateImpl) GetAccount added in v0.9.6

func (s *ExtensionStateImpl) GetAccount(address module.Address) *icstate.Account

func (*ExtensionStateImpl) GetBondRequirement added in v0.9.6

func (s *ExtensionStateImpl) GetBondRequirement() int64

func (*ExtensionStateImpl) GetBonderList added in v0.9.6

func (s *ExtensionStateImpl) GetBonderList(address module.Address) (map[string]interface{}, error)

func (*ExtensionStateImpl) GetMainPRepsInJSON added in v0.9.6

func (s *ExtensionStateImpl) GetMainPRepsInJSON(blockHeight int64) (map[string]interface{}, error)

func (*ExtensionStateImpl) GetNetworkValueInJSON added in v0.9.6

func (s *ExtensionStateImpl) GetNetworkValueInJSON() (map[string]interface{}, error)

func (*ExtensionStateImpl) GetPRepInJSON added in v0.9.6

func (s *ExtensionStateImpl) GetPRepInJSON(address module.Address, blockHeight int64) (map[string]interface{}, error)

func (*ExtensionStateImpl) GetPRepManagerInJSON added in v0.9.6

func (s *ExtensionStateImpl) GetPRepManagerInJSON() map[string]interface{}

func (*ExtensionStateImpl) GetPRepStatsInJSON added in v0.9.6

func (s *ExtensionStateImpl) GetPRepStatsInJSON(blockHeight int64) (map[string]interface{}, error)

func (*ExtensionStateImpl) GetPRepTermInJSON added in v0.9.6

func (s *ExtensionStateImpl) GetPRepTermInJSON() (map[string]interface{}, error)

func (*ExtensionStateImpl) GetPRepsInJSON added in v0.9.6

func (s *ExtensionStateImpl) GetPRepsInJSON(blockHeight int64, start, end int) (map[string]interface{}, error)

func (*ExtensionStateImpl) GetSnapshot added in v0.9.6

func (s *ExtensionStateImpl) GetSnapshot() state.ExtensionSnapshot

func (*ExtensionStateImpl) GetSubPRepsInJSON added in v0.9.6

func (s *ExtensionStateImpl) GetSubPRepsInJSON(blockHeight int64) (map[string]interface{}, error)

func (*ExtensionStateImpl) GetTotalDelegated added in v0.9.6

func (s *ExtensionStateImpl) GetTotalDelegated() *big.Int

func (*ExtensionStateImpl) GetUnbondingTimerState added in v0.9.6

func (s *ExtensionStateImpl) GetUnbondingTimerState(height int64, createIfNotExist bool) *icstate.Timer

func (*ExtensionStateImpl) GetUnstakingTimerState added in v0.9.6

func (s *ExtensionStateImpl) GetUnstakingTimerState(height int64, createIfNotExist bool) *icstate.Timer

func (*ExtensionStateImpl) HandleTimerJob added in v0.9.6

func (s *ExtensionStateImpl) HandleTimerJob(wc state.WorldContext) (err error)

func (*ExtensionStateImpl) IsDecentralized added in v0.9.6

func (s *ExtensionStateImpl) IsDecentralized() bool

func (*ExtensionStateImpl) Logger added in v0.9.6

func (s *ExtensionStateImpl) Logger() log.Logger

func (*ExtensionStateImpl) NewCalculation added in v0.9.6

func (s *ExtensionStateImpl) NewCalculation(term *icstate.Term, calculator *Calculator) error

func (*ExtensionStateImpl) OnExecutionEnd added in v0.9.6

func (s *ExtensionStateImpl) OnExecutionEnd(wc state.WorldContext, calculator *Calculator) error

func (*ExtensionStateImpl) PrevCalculationBlockHeight added in v0.9.6

func (s *ExtensionStateImpl) PrevCalculationBlockHeight() int64

func (*ExtensionStateImpl) RegisterPRep added in v0.9.6

func (s *ExtensionStateImpl) RegisterPRep(regInfo *RegInfo, irep *big.Int) error

func (*ExtensionStateImpl) Reset added in v0.9.6

func (s *ExtensionStateImpl) Reset(isnapshot state.ExtensionSnapshot)

func (*ExtensionStateImpl) SetBond added in v0.9.6

func (*ExtensionStateImpl) SetBonderList added in v0.9.6

func (s *ExtensionStateImpl) SetBonderList(from module.Address, bl icstate.BonderList) error

func (*ExtensionStateImpl) SetDelegation added in v0.9.6

func (*ExtensionStateImpl) SetGovernanceVariables added in v0.9.6

func (s *ExtensionStateImpl) SetGovernanceVariables(from module.Address, irep *big.Int, blockHeight int64) error

func (*ExtensionStateImpl) SetLogger added in v0.9.6

func (s *ExtensionStateImpl) SetLogger(logger log.Logger)

func (*ExtensionStateImpl) SetPRep added in v0.9.6

func (s *ExtensionStateImpl) SetPRep(regInfo *RegInfo) error

func (*ExtensionStateImpl) UnregisterPRep added in v0.9.6

func (s *ExtensionStateImpl) UnregisterPRep(cc contract.CallContext, owner module.Address) error

func (*ExtensionStateImpl) UpdateBlockVoteStats added in v0.9.6

func (s *ExtensionStateImpl) UpdateBlockVoteStats(
	cc contract.CallContext, owner module.Address, voted bool) error

func (*ExtensionStateImpl) UpdateIssueInfo added in v0.9.6

func (s *ExtensionStateImpl) UpdateIssueInfo(reward *big.Int, isDecentralized bool, additionalReward *big.Int) error

func (*ExtensionStateImpl) UpdateIssueInfoFee added in v0.9.6

func (s *ExtensionStateImpl) UpdateIssueInfoFee(fee *big.Int) error

func (*ExtensionStateImpl) ValidateIRep added in v0.9.6

func (s *ExtensionStateImpl) ValidateIRep(oldIRep, newIRep *big.Int, prevSetIRepHeight int64) error

type IssuePRepJSON added in v0.9.6

type IssuePRepJSON struct {
	IRep            *common.HexInt `json:"irep"`
	RRep            *common.HexInt `json:"rrep"`
	TotalDelegation *common.HexInt `json:"totalDelegation"`
	Value           *common.HexInt `json:"value"`
}

type IssueResultJSON added in v0.9.6

type IssueResultJSON struct {
	ByFee           *common.HexInt `json:"coveredByFee"`
	ByOverIssuedICX *common.HexInt `json:"coveredByOverIssuedICX"`
	Issue           *common.HexInt `json:"issue"`
}

func (*IssueResultJSON) GetTotalReward added in v0.9.6

func (i *IssueResultJSON) GetTotalReward() *big.Int

type PRep added in v0.9.6

type PRep struct {
	*icstate.PRepBase
	*icstate.PRepStatus
}

func (*PRep) Clone added in v0.9.6

func (p *PRep) Clone() *PRep

func (*PRep) Owner added in v0.9.6

func (p *PRep) Owner() module.Address

func (*PRep) ToJSON added in v0.9.6

func (p *PRep) ToJSON(blockHeight int64, bondRequirement int64) map[string]interface{}

type PRepManager added in v0.9.6

type PRepManager struct {
	// contains filtered or unexported fields
}

Manage PRepBase, PRepStatus and ActivePRep

func (*PRepManager) CalculateIRep added in v0.9.6

func (pm *PRepManager) CalculateIRep(revision int) *big.Int

func (*PRepManager) CalculateRRep added in v0.9.6

func (pm *PRepManager) CalculateRRep(totalSupply *big.Int, revision int) *big.Int

func (*PRepManager) ChangeBond added in v0.9.6

func (pm *PRepManager) ChangeBond(oBonds, nBonds icstate.Bonds) (map[string]*big.Int, error)

func (*PRepManager) ChangeDelegation added in v0.9.6

func (pm *PRepManager) ChangeDelegation(od, nd icstate.Delegations) (map[string]*big.Int, error)

func (*PRepManager) ChangeGrade added in v0.9.6

func (pm *PRepManager) ChangeGrade(owner module.Address, grade icstate.Grade) error

func (*PRepManager) DisqualifyPRep added in v0.9.6

func (pm *PRepManager) DisqualifyPRep(owner module.Address) error

func (*PRepManager) GetNodeByOwner added in v0.9.6

func (pm *PRepManager) GetNodeByOwner(owner module.Address) module.Address

func (*PRepManager) GetOwnerByNode added in v0.9.6

func (pm *PRepManager) GetOwnerByNode(node module.Address) module.Address

func (*PRepManager) GetPRepByIndex added in v0.9.6

func (pm *PRepManager) GetPRepByIndex(i int) *PRep

func (*PRepManager) GetPRepByNode added in v0.9.6

func (pm *PRepManager) GetPRepByNode(node module.Address) *PRep

func (*PRepManager) GetPRepByOwner added in v0.9.6

func (pm *PRepManager) GetPRepByOwner(owner module.Address) *PRep

func (*PRepManager) GetPRepSize added in v0.9.6

func (pm *PRepManager) GetPRepSize(grade icstate.Grade) int

func (*PRepManager) GetPRepStatsInJSON added in v0.9.6

func (pm *PRepManager) GetPRepStatsInJSON(blockHeight int64) (map[string]interface{}, error)

func (*PRepManager) GetPRepsInJSON added in v0.9.6

func (pm *PRepManager) GetPRepsInJSON(blockHeight int64, start, end int) (map[string]interface{}, error)

func (*PRepManager) GetTotalBondedDelegation added in v0.9.6

func (pm *PRepManager) GetTotalBondedDelegation(br int64) *big.Int

func (*PRepManager) GetValidators added in v0.9.6

func (pm *PRepManager) GetValidators(term *icstate.Term) ([]module.Validator, error)

func (*PRepManager) ImposePenalty added in v0.9.6

func (pm *PRepManager) ImposePenalty(owner module.Address, blockHeight int64) error

Grade change, LastState to icstate.None

func (*PRepManager) OnTermEnd added in v0.9.6

func (pm *PRepManager) OnTermEnd(mainPRepCount, subPRepCount int, blockHeight int64) error

func (*PRepManager) RegisterPRep added in v0.9.6

func (pm *PRepManager) RegisterPRep(regInfo *RegInfo, irep *big.Int) error

func (*PRepManager) SetPRep added in v0.9.6

func (pm *PRepManager) SetPRep(regInfo *RegInfo) error

func (*PRepManager) ShiftVPenaltyMaskByNode added in v0.9.6

func (pm *PRepManager) ShiftVPenaltyMaskByNode(node module.Address) error

func (*PRepManager) Size added in v0.9.6

func (pm *PRepManager) Size() int

func (*PRepManager) Slash added in v0.9.6

func (pm *PRepManager) Slash(owner module.Address, amount *big.Int) error

Slash handles to reduce PRepStatus.bonded and PRepManager.totalBonded Do not change PRep grade here Caution: amount should not include the amount from unbonded

func (*PRepManager) Sort added in v0.9.6

func (pm *PRepManager) Sort()

Sort preps in descending order by bonded delegation

func (*PRepManager) ToJSON added in v0.9.6

func (pm *PRepManager) ToJSON(totalStake *big.Int) map[string]interface{}

func (*PRepManager) TotalBonded added in v0.9.6

func (pm *PRepManager) TotalBonded() *big.Int

TotalBonded returns the sum of PRep.Bonded()

func (*PRepManager) TotalDelegated added in v0.9.6

func (pm *PRepManager) TotalDelegated() *big.Int

TotalDelegated returns the sum of PRep.Delegated()

func (*PRepManager) UnregisterPRep added in v0.9.6

func (pm *PRepManager) UnregisterPRep(owner module.Address) error

func (*PRepManager) UpdateBlockVoteStats added in v0.9.6

func (pm *PRepManager) UpdateBlockVoteStats(owner module.Address, voted bool, blockHeight int64) error

UpdateBlockVoteStats updates PRepLastState based on ConsensusInfo

type RegInfo added in v0.9.6

type RegInfo struct {
	// contains filtered or unexported fields
}

func NewRegInfo added in v0.9.6

func NewRegInfo(city, country, details, email, name, p2pEndpoint, website string, node, owner module.Address) *RegInfo

func (*RegInfo) String added in v0.9.6

func (r *RegInfo) String() string

func (*RegInfo) UpdateRegInfo added in v0.9.6

func (r *RegInfo) UpdateRegInfo(prepInfo *icstate.PRepBase)

func (*RegInfo) Validate added in v0.9.6

func (r *RegInfo) Validate(revision int) error

type RewardType added in v0.9.6

type RewardType int
const (
	TypeBlockProduce RewardType = iota
	TypeVoted
	TypeVoting
)

type ValidatorItem added in v0.9.6

type ValidatorItem struct {
	// contains filtered or unexported fields
}

func (*ValidatorItem) Address added in v0.9.6

func (vi *ValidatorItem) Address() module.Address

func (*ValidatorItem) IsAdded added in v0.9.6

func (vi *ValidatorItem) IsAdded() bool

func (*ValidatorItem) ResetFlags added in v0.9.6

func (vi *ValidatorItem) ResetFlags()

type ValidatorItemIterator added in v0.9.6

type ValidatorItemIterator interface {
	Has() bool
	Next() error
	Get() (*ValidatorItem, error)
}

type ValidatorManager added in v0.9.6

type ValidatorManager struct {
	icutils.Immutable
	// contains filtered or unexported fields
}

func NewValidatorManager added in v0.9.6

func NewValidatorManager() *ValidatorManager

func (*ValidatorManager) Add added in v0.9.6

func (vm *ValidatorManager) Add(node module.Address) error

func (*ValidatorManager) Bytes added in v0.9.6

func (vm *ValidatorManager) Bytes() []byte

func (*ValidatorManager) Clear added in v0.9.6

func (vm *ValidatorManager) Clear() error

func (*ValidatorManager) Flush added in v0.9.6

func (vm *ValidatorManager) Flush() error

func (*ValidatorManager) Get added in v0.9.6

func (vm *ValidatorManager) Get(idx int) (*ValidatorItem, bool)

func (*ValidatorManager) GetValidators added in v0.9.6

func (vm *ValidatorManager) GetValidators() ([]module.Validator, error)

func (*ValidatorManager) Hash added in v0.9.6

func (vm *ValidatorManager) Hash() []byte

func (*ValidatorManager) IndexOf added in v0.9.6

func (vm *ValidatorManager) IndexOf(address module.Address) int

func (*ValidatorManager) Init added in v0.9.6

func (vm *ValidatorManager) Init(pm *PRepManager, term *icstate.Term) error

func (*ValidatorManager) IsUpdated added in v0.9.6

func (vm *ValidatorManager) IsUpdated() bool

func (*ValidatorManager) Iterator added in v0.9.6

func (vm *ValidatorManager) Iterator() *viIterator

func (*ValidatorManager) Len added in v0.9.6

func (vm *ValidatorManager) Len() int

func (*ValidatorManager) Load added in v0.9.6

func (vm *ValidatorManager) Load(pm *PRepManager, term *icstate.Term) error

func (*ValidatorManager) PRepSnapshotIndex added in v0.9.6

func (vm *ValidatorManager) PRepSnapshotIndex() int

func (*ValidatorManager) Remove added in v0.9.6

func (vm *ValidatorManager) Remove(node module.Address) error

func (*ValidatorManager) Replace added in v0.9.6

func (vm *ValidatorManager) Replace(oldNode, newNode module.Address) error

Replace is used for node address change

func (*ValidatorManager) ResetUpdated added in v0.9.6

func (vm *ValidatorManager) ResetUpdated()

func (*ValidatorManager) SetPRepSnapshotIndex added in v0.9.6

func (vm *ValidatorManager) SetPRepSnapshotIndex(idx int)

func (*ValidatorManager) SetUpdated added in v0.9.6

func (vm *ValidatorManager) SetUpdated(on bool)

func (*ValidatorManager) String added in v0.9.6

func (vm *ValidatorManager) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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