autonity

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 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 ErrAutonityContract = errors.New("could not call Autonity contract")
View Source
var ErrWrongParameter = errors.New("wrong parameter")

Functions

This section is empty.

Types

type Blockchainer

type Blockchainer interface {
	ChainContext
	GetVMConfig() *vm.Config
	Config() *params.ChainConfig

	UpdateEnodeWhitelist(newWhitelist *types.Nodes)
	ReadEnodeWhitelist() *types.Nodes

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

type ChainContext

type ChainContext interface {
	// Engine retrieves the chain's consensus engine.
	Engine() consensus.Engine

	// GetHeader returns the hash corresponding to their hash.
	GetHeader(common.Hash, uint64) *types.Header
}

type Contract

type Contract struct {
	GetHashFn func(ref *types.Header, chain ChainContext) func(n uint64) common.Hash
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewAutonityContract

func NewAutonityContract(
	bc Blockchainer,
	canTransfer func(db vm.StateDB, addr common.Address, amount *big.Int) bool,
	transfer func(db vm.StateDB, sender, recipient common.Address, amount *big.Int),
	GetHashFn func(ref *types.Header, chain ChainContext) func(n uint64) common.Hash,
) *Contract

func (*Contract) Address

func (ac *Contract) Address() common.Address

func (*Contract) AutonityContractCall added in v0.4.0

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

func (*Contract) DeployAutonityContract

func (ac *Contract) DeployAutonityContract(chain consensus.ChainReader, header *types.Header, statedb *state.StateDB) (common.Address, error)

deployContract deploys the contract contained within the genesis field bytecode

func (*Contract) FinalizeAndGetCommittee added in v0.4.0

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

func (*Contract) GetCommittee added in v0.4.0

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

func (*Contract) GetContractABI added in v0.4.0

func (ac *Contract) GetContractABI() string

func (*Contract) GetMinimumGasPrice

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

func (*Contract) GetWhitelist

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

func (*Contract) MeasureMetricsOfNetworkEconomic added in v0.4.0

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

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) UpdateAutonityContract added in v0.4.0

func (ac *Contract) UpdateAutonityContract(header *types.Header, statedb *state.StateDB, bytecode string, abi string, state []byte) error

func (*Contract) UpdateEnodesWhitelist

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

type ContractState added in v0.4.0

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 EconomicMetaData added in v0.4.0

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

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

type EconomicMetrics added in v0.4.0

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

func (*EconomicMetrics) SubmitEconomicMetrics added in v0.4.0

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 added in v0.4.0

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

type RewardDistributionMetaData added in v0.4.0

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