autonity

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 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 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 {
	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) 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(chainConfig *params.ChainConfig, header *types.Header, statedb *state.StateDB) 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(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) GetProposerFromAC added in v0.5.0

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 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) 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 EVMProvider added in v0.5.0

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 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