Documentation
¶
Index ¶
- Constants
- Variables
- func DeployContract(abi *abi.ABI, autonityConfig *params.AutonityContractGenesis, evm *vm.EVM) error
- type Blockchainer
- type Contract
- func (ac *Contract) ABI() *abi.ABI
- func (ac *Contract) AutonityContractCall(statedb *state.StateDB, header *types.Header, function string, ...) error
- func (ac *Contract) CallContractFunc(statedb *state.StateDB, header *types.Header, function string, ...) ([]byte, error)
- func (ac *Contract) FinalizeAndGetCommittee(transactions types.Transactions, receipts types.Receipts, header *types.Header, ...) (types.Committee, *types.Receipt, error)
- func (ac *Contract) GetCommittee(header *types.Header, statedb *state.StateDB) (types.Committee, error)
- func (ac *Contract) GetMinimumGasPrice(block *types.Block, db *state.StateDB) (uint64, error)
- func (ac *Contract) GetProposerFromAC(header *types.Header, db *state.StateDB, height uint64, round int64) common.Address
- func (ac *Contract) GetWhitelist(block *types.Block, db *state.StateDB) (*types.Nodes, error)
- func (ac *Contract) MeasureMetricsOfNetworkEconomic(header *types.Header, stateDB *state.StateDB) error
- func (ac *Contract) SetMinimumGasPrice(block *types.Block, db *state.StateDB, price *big.Int) error
- func (ac *Contract) StringABI() string
- func (ac *Contract) UpdateEnodesWhitelist(state *state.StateDB, block *types.Block) error
- type ContractState
- type EVMProvider
- type EconomicMetaData
- type EconomicMetrics
- type RewardDistributionMetaData
Constants ¶
const ( Participant uint8 = iota Stakeholder Validator )
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. )
const ABISPEC = "ABISPEC"
Variables ¶
var ContractAddress = crypto.CreateAddress(Deployer, 0)
var Deployer = common.Address{}
var ErrAutonityContract = errors.New("could not call Autonity contract")
var ErrWrongParameter = errors.New("wrong parameter")
Functions ¶
func DeployContract ¶
Types ¶
type Blockchainer ¶
type Contract ¶
func NewAutonityContract ¶
func NewAutonityContract( bc Blockchainer, operator common.Address, minGasPrice uint64, ABI string, evmProvider EVMProvider, ) (*Contract, error)
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 (*Contract) GetCommittee ¶
func (*Contract) GetMinimumGasPrice ¶
func (*Contract) GetProposerFromAC ¶
func (*Contract) GetWhitelist ¶
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 ¶
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)