systemcontract

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: May 3, 2022 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const AddressListABI = `` /* 1663-byte string literal not displayed */
View Source
const DevMappingPosition = 2

DevMappingPosition is the position of the state variable `devs`. Since the state variables are as follows:

bool public initialized;
bool public devVerifyEnabled;
address public admin;
address public pendingAdmin;

mapping(address => bool) private devs;

//NOTE: make sure this list is not too large!
address[] blacksFrom;
address[] blacksTo;
mapping(address => uint256) blacksFromMap;      // address => index+1
mapping(address => uint256) blacksToMap;        // address => index+1

uint256 public blackLastUpdatedNumber; // last block number when the black list is updated
uint256 public rulesLastUpdatedNumber;  // last block number when the rules are updated
// event check rules
EventCheckRule[] rules;
mapping(bytes32 => mapping(uint128 => uint256)) rulesMap;   // eventSig => checkIdx => indexInArray+1

according to [Layout of State Variables in Storage](https://docs.soliditylang.org/en/v0.8.4/internals/layout_in_storage.html), and after optimizer enabled, the `initialized`, `enabled` and `admin` will be packed, and stores at slot 0, `pendingAdmin` stores at slot 1, so the position for `devs` is 2.

View Source
const MigrateABI = `` /* 283-byte string literal not displayed */
View Source
const NodeVotesABI = `` /* 11179-byte string literal not displayed */
View Source
const ProposalsABI = `` /* 158-byte string literal not displayed */
View Source
const SysGovABI = `` /* 970-byte string literal not displayed */
View Source
const SystemRewardsABI = `` /* 10785-byte string literal not displayed */
View Source
const ValidatorProposalsABI = `` /* 12267-byte string literal not displayed */

ValidatorProposalsABI `Proposals` contract in systemContracts

View Source
const ValidatorsABI = `` /* 14272-byte string literal not displayed */

ValidatorsABI contains all methods to interactive with validator contracts.

Variables

View Source
var (
	BlackLastUpdatedNumberPosition = common.BytesToHash([]byte{0x07})
	RulesLastUpdatedNumberPosition = common.BytesToHash([]byte{0x08})
)
View Source
var (
	ValidatorsContractName         = "Validators"
	ValidatorProposalsContractName = "ValidatorProposals"
	NodeVotesContractName          = "NodeVotes"
	SystemRewardsContractName      = "SystemRewards"
	MigrateContractName            = "Migrate"

	ProposalsContractName   = "Proposals"
	AddressListContractName = "address_list"
	SysGovContractName      = "governance"

	ValidatorsContractAddr         = common.HexToAddress("0x0000000000000000000000000000000000fff001")
	ValidatorProposalsContractAddr = common.HexToAddress("0x0000000000000000000000000000000000fff002")
	NodeVotesContractAddr          = common.HexToAddress("0x0000000000000000000000000000000000fff003")
	SystemRewardsContractAddr      = common.HexToAddress("0x0000000000000000000000000000000000fff004")
	MigrateContractAddr            = common.HexToAddress("0x0000000000000000000000000000000000fff005")

	ProposalsContractAddr   = common.HexToAddress("0x0000000000000000000000000000000000fff006")
	AddressListContractAddr = common.HexToAddress("0x0000000000000000000000000000000000fff007")
	SysGovContractAddr      = common.HexToAddress("0x0000000000000000000000000000000000fff008")

	// SysGovToAddr is the To address for the system governance transaction, NOT contract address
	SysGovToAddr = common.HexToAddress("0x000000000000000000000000000000000000ffff")
)
View Source
var (
	InitRate    = uint8(100)
	InitDeposit = new(big.Int).Mul(big.NewInt(1e18), big.NewInt(40000000))
	InitName    = "dxc-validator-1"      // max bytes length: 100
	InitDetails = "initialize validator" // max bytes length: 10000
)

using for Validators contract's initialize

View Source
var (
	DevAdmin = common.HexToAddress("0xfd85c4d409a2625f9e18b3bb8182bc48f20603a4")
)
View Source
var MigrateOwner = common.HexToAddress("0x3fe93764c06bb5d712b73ad2a385b168d69d3984")

Functions

func GetInteractiveABI

func GetInteractiveABI() map[string]abi.ABI

func GetValidatorAddr

func GetValidatorAddr(blockNum *big.Int, config *params.ChainConfig) *common.Address

func InitMigrateAddrBalance

func InitMigrateAddrBalance() ([]common.Address, []*big.Int)

Types

type Base

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

func NewBase

func NewBase() *Base

NewBase return Base contract instance

func (*Base) GetBaseInfos

func (b *Base) GetBaseInfos(statedb *state.StateDB, header *types.Header, chainContext core.ChainContext, config *params.ChainConfig) (map[string]interface{}, error)

type EpochInfo

type EpochInfo struct {
	BlockReward       *big.Int
	Tvl               *big.Int
	ValidatorCount    *big.Int
	EffictiveValCount *big.Int
}

EpochInfo struct `epoch` in SystemRewards contract

type MigrateAddrBalance

type MigrateAddrBalance struct {
	Address common.Address        `json:"address"`
	Balance *math.HexOrDecimal256 `json:"balance"`
}

type NodeVotes

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

func NewNodeVotes

func NewNodeVotes() *NodeVotes

NewNodeVotes return Proposals contract instance

func (*NodeVotes) PendingVoteRedeem

func (n *NodeVotes) PendingVoteRedeem(statedb *state.StateDB, header *types.Header, chainContext core.ChainContext, config *params.ChainConfig, val common.Address, voter common.Address) (*big.Int, error)

PendingVoteRedeem function PendingRedeem

func (*NodeVotes) PendingVoteReward

func (n *NodeVotes) PendingVoteReward(statedb *state.StateDB, header *types.Header, chainContext core.ChainContext, config *params.ChainConfig, val common.Address, voter common.Address) (*big.Int, error)

PendingVoteReward function pendingReward

func (*NodeVotes) TotalVotes

func (n *NodeVotes) TotalVotes(statedb *state.StateDB, header *types.Header, chainContext core.ChainContext, config *params.ChainConfig) (*big.Int, error)

TotalVotes function totalVotes

func (*NodeVotes) VoteListLength

func (n *NodeVotes) VoteListLength(statedb *state.StateDB, header *types.Header, chainContext core.ChainContext, config *params.ChainConfig, voter common.Address) (*big.Int, error)

VoteListLength function VoteListLength

func (*NodeVotes) VotesRewardRedeemInfo

func (n *NodeVotes) VotesRewardRedeemInfo(statedb *state.StateDB, header *types.Header, chainContext core.ChainContext, config *params.ChainConfig, val common.Address, voter common.Address) (*VotesRewardRedeemInfo, error)

VotesRewardRedeemInfo function votesRewardRedeemInfo

func (*NodeVotes) VotesRewardRedeemInfoWithPage

func (n *NodeVotes) VotesRewardRedeemInfoWithPage(statedb *state.StateDB, header *types.Header, chainContext core.ChainContext, config *params.ChainConfig, voter common.Address, page *big.Int, size *big.Int) ([]VotesRewardRedeemInfo, error)

VotesRewardRedeemInfoWithPage function votesRewardRedeemInfoWithPage

type ProposalInfo

type ProposalInfo struct {
	Id          [4]byte
	Proposer    common.Address
	PType       uint8
	Deposit     *big.Int
	Rate        uint8
	Name        string
	Details     string
	InitBlock   *big.Int
	Guarantee   common.Address
	UpdateBlock *big.Int
	Status      uint8
}

type Proposals

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

func NewProposals

func NewProposals() *Proposals

NewProposals return Proposals contract instance

func (*Proposals) AddressProposalCount

func (p *Proposals) AddressProposalCount(statedb *state.StateDB, header *types.Header, chainContext core.ChainContext, config *params.ChainConfig, addr common.Address) (*big.Int, error)

AddressProposalCount function AddressProposalCount

func (*Proposals) AddressProposalSets

func (p *Proposals) AddressProposalSets(statedb *state.StateDB, header *types.Header, chainContext core.ChainContext, config *params.ChainConfig, addr common.Address, page *big.Int, size *big.Int) ([][4]byte, error)

AddressProposalSets function AddressProposalSets

func (*Proposals) AddressProposals

func (p *Proposals) AddressProposals(statedb *state.StateDB, header *types.Header, chainContext core.ChainContext, config *params.ChainConfig, addr common.Address, page *big.Int, size *big.Int) ([]ProposalInfo, error)

AddressProposals function AddressProposals

func (*Proposals) AllProposalSets

func (p *Proposals) AllProposalSets(statedb *state.StateDB, header *types.Header, chainContext core.ChainContext, config *params.ChainConfig, page *big.Int, size *big.Int) ([][4]byte, error)

AllProposalSets function AllProposalSets

func (*Proposals) AllProposals

func (p *Proposals) AllProposals(statedb *state.StateDB, header *types.Header, chainContext core.ChainContext, config *params.ChainConfig, page *big.Int, size *big.Int) ([]ProposalInfo, error)

AllProposals function AllProposals

func (*Proposals) GetProposal

func (p *Proposals) GetProposal(statedb *state.StateDB, header *types.Header, chainContext core.ChainContext, config *params.ChainConfig, id string) (*ProposalInfo, error)

GetProposal function GetProposal

func (*Proposals) ProposalCount

func (p *Proposals) ProposalCount(statedb *state.StateDB, header *types.Header, chainContext core.ChainContext, config *params.ChainConfig) (*big.Int, error)

ProposalCount function ProposalCount

type Punish

type Punish struct {
	Count         *big.Int
	PunishBlocks  []*big.Int
	KickoutBlocks []*big.Int
	BurnRewards   []*big.Int
}

type Reward

type Reward struct {
	ValidatorReward  *big.Int
	DelegatorsReward *big.Int
	Rate             uint8
}

type SysRewardsInfo

type SysRewardsInfo struct {
	Epochs            []*big.Int
	ValidatorRewards  []*big.Int
	DelegatorsRewards []*big.Int
	Rates             []uint8
	PendingReward     *big.Int
	FrozenReward      *big.Int
	RewardPerVote     *big.Int
}

type SystemRewards

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

func NewSystemRewards

func NewSystemRewards() *SystemRewards

NewSystemRewards return SystemRewards contract instance

func (*SystemRewards) GetEpochInfo

func (s *SystemRewards) GetEpochInfo(statedb *state.StateDB, header *types.Header, chainContext core.ChainContext, config *params.ChainConfig, epoch *big.Int) (*EpochInfo, error)

GetEpochInfo return epoch info

func (*SystemRewards) GetValRewardInfoByEpoch

func (s *SystemRewards) GetValRewardInfoByEpoch(statedb *state.StateDB, header *types.Header, chainContext core.ChainContext, config *params.ChainConfig, addr common.Address, epoch *big.Int) (*Reward, error)

GetValRewardInfoByEpoch return the address and the epoch reward info

func (*SystemRewards) KickoutInfo

func (s *SystemRewards) KickoutInfo(statedb *state.StateDB, header *types.Header, chainContext core.ChainContext, config *params.ChainConfig, epoch *big.Int) ([]common.Address, error)

KickoutInfo return kickout addresses in epoch

func (*SystemRewards) PendingValidatorReward

func (s *SystemRewards) PendingValidatorReward(statedb *state.StateDB, header *types.Header, chainContext core.ChainContext, config *params.ChainConfig, addr common.Address) (*big.Int, *big.Int, error)

PendingValidatorReward return the address reward

func (*SystemRewards) PunishInfo

func (s *SystemRewards) PunishInfo(statedb *state.StateDB, header *types.Header, chainContext core.ChainContext, config *params.ChainConfig, addr common.Address, epoch *big.Int) (*Punish, error)

PunishInfo punishInfo function of systemRewards contract

func (*SystemRewards) ValidatorRewardsInfo

func (s *SystemRewards) ValidatorRewardsInfo(statedb *state.StateDB, header *types.Header, chainContext core.ChainContext, config *params.ChainConfig, addr common.Address) (*SysRewardsInfo, error)

ValidatorRewardsInfo return the address sys rewards

type Validator

type Validator struct {
	Status                  uint8
	Deposit                 *big.Int
	Rate                    uint8
	Name                    string
	Details                 string
	Votes                   *big.Int
	UnstakeLockingEndBlock  *big.Int
	RateSettLockingEndBlock *big.Int
}

type Validators

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

func NewValidators

func NewValidators() *Validators

func (*Validators) CancelQueueValidatorsLength

func (v *Validators) CancelQueueValidatorsLength(statedb *state.StateDB, header *types.Header, chainContext core.ChainContext, config *params.ChainConfig) (*big.Int, error)

CancelQueueValidatorsLength function CancelQueueValidatorsLength

func (*Validators) EffictiveValsLength

func (v *Validators) EffictiveValsLength(statedb *state.StateDB, header *types.Header, chainContext core.ChainContext, config *params.ChainConfig) (*big.Int, error)

EffictiveValsLength function EffictiveValsLength

func (*Validators) GetCancelQueueValidators

func (v *Validators) GetCancelQueueValidators(statedb *state.StateDB, header *types.Header, chainContext core.ChainContext, config *params.ChainConfig) ([]common.Address, error)

GetCancelQueueValidators get canceling queue validators

func (*Validators) GetCurrentEpochValidators

func (v *Validators) GetCurrentEpochValidators(statedb *state.StateDB, header *types.Header, chainContext core.ChainContext, config *params.ChainConfig) ([]common.Address, error)

func (*Validators) GetEffictiveValidatorsWithPage

func (v *Validators) GetEffictiveValidatorsWithPage(statedb *state.StateDB, header *types.Header, chainContext core.ChainContext, config *params.ChainConfig, page *big.Int, size *big.Int) ([]common.Address, error)

func (*Validators) GetInvalidValidatorsWithPage

func (v *Validators) GetInvalidValidatorsWithPage(statedb *state.StateDB, header *types.Header, chainContext core.ChainContext, config *params.ChainConfig, page *big.Int, size *big.Int) ([]common.Address, error)

GetInvalidValidatorsWithPage get invalid validators

func (*Validators) GetValidator

func (v *Validators) GetValidator(statedb *state.StateDB, header *types.Header, chainContext core.ChainContext, config *params.ChainConfig, addr common.Address) (*Validator, error)

GetValidator function GetValidator

func (*Validators) GetValidatorVoters

func (v *Validators) GetValidatorVoters(statedb *state.StateDB, header *types.Header, chainContext core.ChainContext, config *params.ChainConfig, addr common.Address, page *big.Int, size *big.Int) ([]common.Address, error)

GetValidatorVoters get the address voters

func (*Validators) InvalidValsLength

func (v *Validators) InvalidValsLength(statedb *state.StateDB, header *types.Header, chainContext core.ChainContext, config *params.ChainConfig) (*big.Int, error)

InvalidValsLength function InvalidValsLength

func (*Validators) IsEffictiveValidator

func (v *Validators) IsEffictiveValidator(statedb *state.StateDB, header *types.Header, chainContext core.ChainContext, config *params.ChainConfig, addr common.Address) (bool, error)

IsEffictiveValidator function IsEffictiveValidator

func (*Validators) TotalDeposit

func (v *Validators) TotalDeposit(statedb *state.StateDB, header *types.Header, chainContext core.ChainContext, config *params.ChainConfig) (*big.Int, error)

TotalDeposit function TotalDeposit

func (*Validators) ValidatorVotersLength

func (v *Validators) ValidatorVotersLength(statedb *state.StateDB, header *types.Header, chainContext core.ChainContext, config *params.ChainConfig, addr common.Address) (*big.Int, error)

ValidatorVotersLength function validatorVotersLength

type VotesRewardRedeemInfo

type VotesRewardRedeemInfo struct {
	Validator           common.Address
	ValidatorName       string
	ValidatorRate       uint8
	ValidatorTotalVotes *big.Int
	Amount              *big.Int
	PendingReward       *big.Int
	PendingRedeem       *big.Int
	LockRedeemEpochs    []*big.Int
	LockRedeemVotes     []*big.Int
}

Jump to

Keyboard shortcuts

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