Documentation
¶
Index ¶
- Constants
- func ApplySystemContractUpgrade(hardfork string, state *state.StateDB, header *types.Header, ...) (err error)
- func CallContract(ctx *CallContext, to common.Address, data []byte) (ret []byte, err error)
- func CallContractWithValue(ctx *CallContext, from common.Address, to common.Address, data []byte, ...) (ret []byte, err error)
- func DecreaseMissedBlocksCounter(ctx *CallContext) error
- func DistributeBlockFee(ctx *CallContext, fee *big.Int) error
- func DoubleSignPunish(ctx *CallContext, punishHash common.Hash, validator common.Address) error
- func DoubleSignPunishWithGivenEVM(evm *vm.EVM, from common.Address, punishHash common.Hash, ...) error
- func ExecuteProposal(ctx *CallContext, prop *Proposal) error
- func ExecuteProposalWithGivenEVM(evm *vm.EVM, prop *Proposal, gas uint64) (ret []byte, err error)
- func FinishProposalById(ctx *CallContext, id *big.Int) error
- func GetBlacksFrom(ctx *CallContext) ([]common.Address, error)
- func GetBlacksTo(ctx *CallContext) ([]common.Address, error)
- func GetPassedProposalCount(ctx *CallContext) (uint32, error)
- func GetRuleByIndex(ctx *CallContext, idx uint32) (common.Hash, int, common.AddressCheckType, error)
- func GetRulesLen(ctx *CallContext) (uint32, error)
- func GetTopValidators(ctx *CallContext) ([]common.Address, error)
- func IsDeveloperVerificationEnabled(state consensus.StateReader, height *big.Int, config *params.ChainConfig) bool
- func IsDoubleSignPunished(ctx *CallContext, punishHash common.Hash) (bool, error)
- func LastBlackUpdatedNumber(state consensus.StateReader, height *big.Int, config *params.ChainConfig) uint64
- func LastRulesUpdatedNumber(state consensus.StateReader, height *big.Int, config *params.ChainConfig) uint64
- func LazyPunish(ctx *CallContext, validator common.Address) error
- func UpdateActiveValidatorSet(ctx *CallContext, newValidators []common.Address) error
- func VMCallContract(evm *vm.EVM, from common.Address, to common.Address, data []byte, gas uint64) (ret []byte, err error)
- func WrapVMError(err error, ret []byte) error
- type AddrAscend
- type CallContext
- type Hardfork
- type IUpgradeAction
- type Proposal
- type SysContractV1HardFork
Constants ¶
const (
Earth = "Earth"
)
const (
SysContractV1Code = "" /* 52910-byte string literal not displayed */
)
Variables ¶
This section is empty.
Functions ¶
func ApplySystemContractUpgrade ¶
func ApplySystemContractUpgrade(hardfork string, state *state.StateDB, header *types.Header, chainContext core.ChainContext, config *params.ChainConfig) (err error)
ApplySystemContractUpgrade updates the system contract when hardfork happens NOTE: this function will always returl nil error in order to not break the consensus when fail
func CallContract ¶
CallContract executes transaction sent to system contracts.
func CallContractWithValue ¶
func CallContractWithValue(ctx *CallContext, from common.Address, to common.Address, data []byte, value *big.Int) (ret []byte, err error)
CallContract executes transaction sent to system contracts.
func DecreaseMissedBlocksCounter ¶
func DecreaseMissedBlocksCounter(ctx *CallContext) error
DecreaseMissedBlocksCounter return the result of calling method `decreaseMissedBlocksCounter` in Staking contract
func DistributeBlockFee ¶
func DistributeBlockFee(ctx *CallContext, fee *big.Int) error
DistributeBlockFee return the result of calling method `distributeBlockFee` in Staking contract
func DoubleSignPunish ¶
DoubleSignPunish return the result of calling method `doubleSignPunish` in Staking contract
func DoubleSignPunishWithGivenEVM ¶
func DoubleSignPunishWithGivenEVM(evm *vm.EVM, from common.Address, punishHash common.Hash, validator common.Address) error
DoubleSignPunishWithGivenEVM return the result of calling method `doubleSignPunish` in Staking contract with given EVM
func ExecuteProposal ¶
func ExecuteProposal(ctx *CallContext, prop *Proposal) error
ExecuteProposal executes proposal
func ExecuteProposalWithGivenEVM ¶
ExecuteProposalWithGivenEVM executes proposal by given evm
func FinishProposalById ¶
func FinishProposalById(ctx *CallContext, id *big.Int) error
FinishProposalById finish passed proposal by id
func GetBlacksFrom ¶
func GetBlacksFrom(ctx *CallContext) ([]common.Address, error)
GetBlacksFrom return the access tx-from list
func GetBlacksTo ¶
func GetBlacksTo(ctx *CallContext) ([]common.Address, error)
GetBlacksTo return access tx-to list
func GetPassedProposalCount ¶
func GetPassedProposalCount(ctx *CallContext) (uint32, error)
GetPassedProposalCount returns passed proposal count
func GetRuleByIndex ¶
func GetRuleByIndex(ctx *CallContext, idx uint32) (common.Hash, int, common.AddressCheckType, error)
GetRuleByIndex return event log rules
func GetRulesLen ¶
func GetRulesLen(ctx *CallContext) (uint32, error)
GetRulesLen return event log rules length
func GetTopValidators ¶
func GetTopValidators(ctx *CallContext) ([]common.Address, error)
GetTopValidators return the result of calling method `getTopValidators` in Staking contract
func IsDeveloperVerificationEnabled ¶
func IsDeveloperVerificationEnabled(state consensus.StateReader, height *big.Int, config *params.ChainConfig) bool
IsDeveloperVerificationEnabled Since the state variables are as follow:
bool public initialized; bool public enabled; address public admin; address public pendingAdmin; mapping(address => bool) private devs;
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, and the position for `devs` is 2.
func IsDoubleSignPunished ¶
func IsDoubleSignPunished(ctx *CallContext, punishHash common.Hash) (bool, error)
IsDoubleSignPunished return the result of calling method `isDoubleSignPunished` in Staking contract
func LastBlackUpdatedNumber ¶
func LastBlackUpdatedNumber(state consensus.StateReader, height *big.Int, config *params.ChainConfig) uint64
LastBlackUpdatedNumber returns LastBlackUpdatedNumber of address list
func LastRulesUpdatedNumber ¶
func LastRulesUpdatedNumber(state consensus.StateReader, height *big.Int, config *params.ChainConfig) uint64
LastRulesUpdatedNumber returns LastRulesUpdatedNumber of address list
func LazyPunish ¶
func LazyPunish(ctx *CallContext, validator common.Address) error
LazyPunish return the result of calling method `lazyPunish` in Staking contract
func UpdateActiveValidatorSet ¶
func UpdateActiveValidatorSet(ctx *CallContext, newValidators []common.Address) error
UpdateActiveValidatorSet return the result of calling method `updateActiveValidatorSet` in Staking contract
func VMCallContract ¶
func VMCallContract(evm *vm.EVM, from common.Address, to common.Address, data []byte, gas uint64) (ret []byte, err error)
VMCallContract executes transaction sent to system contracts with given EVM.
func WrapVMError ¶
WrapVMError wraps vm error with readable reason
Types ¶
type AddrAscend ¶
AddrAscend implements the sort interface to allow sorting a list of addresses
func (AddrAscend) Len ¶
func (s AddrAscend) Len() int
func (AddrAscend) Less ¶
func (s AddrAscend) Less(i, j int) bool
func (AddrAscend) Swap ¶
func (s AddrAscend) Swap(i, j int)
type CallContext ¶
type CallContext struct {
Statedb *state.StateDB
Header *types.Header
ChainContext core.ChainContext
ChainConfig *params.ChainConfig
}
func (*CallContext) GetContractAddress ¶
func (ctx *CallContext) GetContractAddress(contractName string) common.Address
func (*CallContext) GetContractVersion ¶
func (ctx *CallContext) GetContractVersion(contractName string) uint8
type IUpgradeAction ¶
type IUpgradeAction interface {
// GetName returns the name of the updated system contract
GetName() string
// DoUpdate is used to add/update system contracts as well as initialization
DoUpdate(state *state.StateDB, header *types.Header, chainContext core.ChainContext, config *params.ChainConfig) error
}
IUpgradeAction is the interface for system contracts upgrades
func EarthHardFork ¶
func EarthHardFork() []IUpgradeAction
type Proposal ¶
type Proposal struct {
Id *big.Int
Action *big.Int
From common.Address
To common.Address
Value *big.Int
Data []byte
}
func GetPassedProposalByIndex ¶
func GetPassedProposalByIndex(ctx *CallContext, idx uint32) (*Proposal, error)
GetPassedProposalByIndex returns passed proposal by index
type SysContractV1HardFork ¶
type SysContractV1HardFork struct {
}
func (*SysContractV1HardFork) DoUpdate ¶
func (s *SysContractV1HardFork) DoUpdate(state *state.StateDB, header *types.Header, chainContext core.ChainContext, config *params.ChainConfig) (err error)
func (*SysContractV1HardFork) GetName ¶
func (s *SysContractV1HardFork) GetName() string