systemcontract

package
v1.0.0-release Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2022 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Earth = "Earth"
)
View Source
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

func CallContract(ctx *CallContext, to common.Address, data []byte) (ret []byte, err error)

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

func DoubleSignPunish(ctx *CallContext, punishHash common.Hash, validator common.Address) error

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

func ExecuteProposalWithGivenEVM(evm *vm.EVM, prop *Proposal, gas uint64) (ret []byte, err error)

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

func WrapVMError(err error, ret []byte) error

WrapVMError wraps vm error with readable reason

Types

type AddrAscend

type AddrAscend []common.Address

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 Hardfork

type Hardfork struct {
	Name   string
	Number *big.Int
}

Hardfork conbines name and number

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

Jump to

Keyboard shortcuts

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