autonity

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2020 License: GPL-3.0, GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Participant uint8 = iota
	Stakeholder
	Validator
)
View Source
const (

	// gauge to track stake and balance in ETH for user.
	UserMetricIDTemplate = "contract/user/%s/%s/%s"

	// gauge which track the min gas price in GWei.
	GlobalMetricIDGasPrice = "contract/global/mingasprice"

	// gauge which track the global state supply in ETH.
	GlobalMetricIDStakeSupply = "contract/global/stakesupply"

	// gauge which track the network operator balance in ETH.
	GlobalOperatorBalanceMetricID = "contract/global/operator/balance"

	// gauge tracks the fraction of reward per block for stakeholders.
	BlockRewardDistributionMetricIDTemplate = "contract/block/%v/user/%s/%s/reward"

	// gauge tracks the reward/transactionfee of a specific block.
	BlockRewardBlockMetricID = "contract/block/%v/reward"

	RoleUnknown     = "unknown"
	RoleValidator   = "validator"
	RoleStakeHolder = "stakeholder"
	RoleParticipant = "participant"
	/*
		counter metrics which counts reward distribution for per block, cannot hold these counters from block0 to
		infinite block number in memory, so we apply a height/time window to keep the counters in reasonable range, for
		those counter which reported to TSDB could be removed for memory recycle.
		template: contract/block/number/user/common.address/[validator|stakeholder|participant]/reward
	*/
	BlockRewardHeightWindow          = 3600 // 1 hour time window to keep those counters in memory.
	BlockRewardHeightWindowStepRange = 600  // each 10 minutes to shrink the window.
)
View Source
const ABISPEC = "ABISPEC"

Variables

View Source
var ContractAddress = crypto.CreateAddress(Deployer, 0)
View Source
var Deployer = common.Address{}
View Source
var ErrAutonityContract = errors.New("could not call Autonity contract")
View Source
var ErrWrongParameter = errors.New("wrong parameter")

Functions

func DeployContract

func DeployContract(abi *abi.ABI, autonityConfig *params.AutonityContractGenesis, evm *vm.EVM) error

Types

type Blockchainer

type Blockchainer interface {
	UpdateEnodeWhitelist(newWhitelist *types.Nodes)
	ReadEnodeWhitelist() *types.Nodes

	PutKeyValue(key []byte, value []byte) error
}

type Contract

type Contract struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewAutonityContract

func NewAutonityContract(
	bc Blockchainer,
	operator common.Address,
	minGasPrice uint64,
	ABI string,
	evmProvider EVMProvider,
) (*Contract, error)

func (*Contract) ABI

func (ac *Contract) ABI() *abi.ABI

ABI returns the current autonity contract's ABI

func (*Contract) AutonityContractCall

func (ac *Contract) AutonityContractCall(statedb *state.StateDB, header *types.Header, function string, result interface{}, args ...interface{}) error

AutonityContractCall calls the specified function of the autonity contract with the given args, and returns the output unpacked into the result interface.

func (*Contract) CallContractFunc

func (ac *Contract) CallContractFunc(statedb *state.StateDB, header *types.Header, function string, packedArgs []byte) ([]byte, error)

CallContractFunc creates an evm object, uses it to call the specified function of the autonity contract with packedArgs and returns the packed result. If there is an error making the evm call it will be returned. Callers should use the autonity contract ABI to pack and unpack the args and result.

func (*Contract) FinalizeAndGetCommittee

func (ac *Contract) FinalizeAndGetCommittee(transactions types.Transactions, receipts types.Receipts, header *types.Header, statedb *state.StateDB) (types.Committee, *types.Receipt, error)

func (*Contract) GetCommittee

func (ac *Contract) GetCommittee(header *types.Header, statedb *state.StateDB) (types.Committee, error)

func (*Contract) GetMinimumGasPrice

func (ac *Contract) GetMinimumGasPrice(block *types.Block, db *state.StateDB) (uint64, error)

func (*Contract) GetProposerFromAC

func (ac *Contract) GetProposerFromAC(header *types.Header, db *state.StateDB, height uint64, round int64) common.Address

func (*Contract) GetWhitelist

func (ac *Contract) GetWhitelist(block *types.Block, db *state.StateDB) (*types.Nodes, error)

func (*Contract) MeasureMetricsOfNetworkEconomic

func (ac *Contract) MeasureMetricsOfNetworkEconomic(header *types.Header, stateDB *state.StateDB) error

measure metrics of user's meta data by regarding of network economic.

func (*Contract) SetMinimumGasPrice

func (ac *Contract) SetMinimumGasPrice(block *types.Block, db *state.StateDB, price *big.Int) error

func (*Contract) StringABI

func (ac *Contract) StringABI() string

StringABI returns the current autonity contract ABI in string format

func (*Contract) UpdateEnodesWhitelist

func (ac *Contract) UpdateEnodesWhitelist(state *state.StateDB, block *types.Block) error

type ContractState

type ContractState struct {
	Users           []common.Address `abi:"users"`
	Enodes          []string         `abi:"enodes"`
	Types           []*big.Int       `abi:"types"`
	Stakes          []*big.Int       `abi:"stakes"`
	CommissionRates []*big.Int       `abi:"commisionrates"`
	Operator        common.Address   `abi:"operator"`
	Deployer        common.Address   `abi:"deployer"`
	MinGasPrice     *big.Int         `abi:"mingasprice"`
	BondingPeriod   *big.Int         `abi:"bondingperiod"`
}

* ContractState is a unified structure to represent the autonity contract state. * By using a unified structure, the new state meta introduced in the Autonity.sol * should be synced with this structure.

type EVMProvider

type EVMProvider interface {
	EVM(header *types.Header, origin common.Address, statedb *state.StateDB) *vm.EVM
}

EVMProvider provides a new evm. This allows us to decouple the contract from *params.ChainConfig which is required to build a new evm.

type EconomicMetaData

type EconomicMetaData struct {
	Accounts    []common.Address `abi:"accounts"`
	Usertypes   []uint8          `abi:"usertypes"`
	Stakes      []*big.Int       `abi:"stakes"`
	Mingasprice *big.Int         `abi:"mingasprice"`
	Stakesupply *big.Int         `abi:"stakesupply"`
}

refer to autonity contract abt spec, keep in same meta.

type EconomicMetrics

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

func (*EconomicMetrics) SubmitEconomicMetrics

func (em *EconomicMetrics) SubmitEconomicMetrics(v *EconomicMetaData, stateDB *state.StateDB, height uint64, operator common.Address)

measure metrics of user's meta data by regarding of network economic.

func (*EconomicMetrics) SubmitRewardDistributionMetrics

func (em *EconomicMetrics) SubmitRewardDistributionMetrics(v *RewardDistributionMetaData, height uint64)

type RewardDistributionMetaData

type RewardDistributionMetaData struct {
	Result          bool             `abi:"result"`
	Holders         []common.Address `abi:"stakeholders"`
	Rewardfractions []*big.Int       `abi:"rewardfractions"`
	Amount          *big.Int         `abi:"amount"`
}

refer to autonity contract abi spec, keep in same meta.

Jump to

Keyboard shortcuts

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