Documentation ¶
Index ¶
- Constants
- Variables
- func AddBalance(db dbInterface, id *types.TokenTypeId, amount *big.Int)
- func CalcQuotaUsed(useQuota bool, quotaTotal, quotaAddition, quotaLeft uint64, err error) (q uint64, qUsed uint64)
- func CheckFork(db dbInterface, f func(uint64) bool) bool
- func DataGasCost(data []byte, gasTable *GasTable) (uint64, error)
- func DealWithErr(v interface{})
- func FirstToLower(str string) string
- func GetCodeFromCreateContractData(data []byte, snapshotHeight uint64) []byte
- func GetConfirmTimeFromCreateContractData(data []byte) uint8
- func GetContractCode(db CommonDb, addr *types.Address, status GlobalStatus) ([]byte, []byte)
- func GetContractTypeFromCreateContractData(data []byte) uint8
- func GetCreateContractData(bytecode []byte, contractType uint8, confirmTimes uint8, seedCount uint8, ...) []byte
- func GetGidFromCreateContractData(data []byte) types.Gid
- func GetQuotaRatioFromCreateContractData(data []byte, snapshotHeight uint64) uint8
- func GetSeedCountFromCreateContractData(data []byte) uint8
- func GetValue(db dbInterface, key []byte) []byte
- func IntrinsicGasCost(data []byte, baseGas uint64, confirmTime uint8, gasTable *GasTable) (uint64, error)
- func IsDelegateGid(gid types.Gid) bool
- func IsExistContractType(contractType uint8) bool
- func IsPoW(block *ledger.AccountBlock) bool
- func IsSnapshotGid(gid types.Gid) bool
- func IsUserAccount(addr types.Address) bool
- func IsValidQuotaRatio(quotaRatio uint8) bool
- func IsViteToken(tokenId types.TokenTypeId) bool
- func MakeSendBlock(fromAddress types.Address, toAddress types.Address, blockType byte, ...) *ledger.AccountBlock
- func MultipleCost(cost uint64, quotaRatio uint8) (uint64, error)
- func NewContractAddress(accountAddress types.Address, accountBlockHeight uint64, ...) types.Address
- func NewLog(c abi.ABIContract, name string, params ...interface{}) *ledger.VmLog
- func PackContractCode(contractType uint8, code []byte) []byte
- func PrintMap(m map[string][]byte) string
- func SetValue(db dbInterface, key []byte, value []byte)
- func SubBalance(db dbInterface, id *types.TokenTypeId, amount *big.Int)
- func TxGasCost(data []byte, gasTable *GasTable) (uint64, error)
- func UseQuota(quotaLeft, cost uint64) (uint64, error)
- func UseQuotaWithFlag(quotaLeft, cost uint64, flag bool) (uint64, error)
- type CommonDb
- type ConsensusReader
- type GasTable
- type GlobalStatus
- type SBPStatReader
- type VMConsensusReader
- func (r *VMConsensusReader) GetConsensusDetailByDay(startIndex, endIndex uint64) ([]*core.DayStats, error)
- func (r *VMConsensusReader) GetEndTimeByIndex(index uint64) int64
- func (r *VMConsensusReader) GetIndexByEndTime(t int64, genesisTime int64) (uint64, int64, bool)
- func (r *VMConsensusReader) GetIndexByStartTime(t int64, genesisTime int64) (uint64, int64, bool)
- func (r *VMConsensusReader) GetIndexByTime(t int64, genesisTime int64) uint64
- type VMError
Constants ¶
View Source
const ( CommonQuotaRatio uint8 = 10 QuotaRatioDivision uint64 = 10 OneRound uint64 = 75 )
Variables ¶
View Source
var ( AttovPerVite = big.NewInt(1e18) CreateContractDataLengthMin = 13 CreateContractDataLengthMinRand = 14 )
View Source
var ( ErrInvalidMethodParam = VMError{"invalid method param", false} ErrInvalidQuotaRatio = VMError{"invalid quota ratio", false} ErrRewardIsNotDrained = VMError{"reward is not drained", false} ErrInsufficientBalance = VMError{"insufficient balance for transfer", false} ErrCalcPoWTwice = VMError{"calc PoW twice referring to one snapshot block", false} ErrAbiMethodNotFound = VMError{"abi: method not found", false} ErrInvalidConfirmTime = VMError{"invalid confirm time", false} ErrInvalidSeedCount = VMError{"invalid seed count", false} ErrAddressNotMatch = VMError{"current address not match", false} ErrTransactionTypeNotSupport = VMError{"transaction type not supported", false} ErrVersionNotSupport = VMError{"feature not supported in current snapshot height", false} ErrBlockTypeNotSupported = VMError{"block type not supported", true} ErrDataNotExist = VMError{"data not exist", false} ErrContractNotExists = VMError{"contract not exists", false} ErrNoReliableStatus = VMError{"no reliable status", false} ErrAddressCollision = VMError{"contract address collision", false} ErrIdCollision = VMError{"id collision", false} ErrRewardNotDue = VMError{"reward not due", false} ErrExecutionReverted = VMError{"execution reverted", false} ErrDepth = VMError{"max call depth exceeded", false} ErrGasUintOverflow = VMError{"gas uint64 overflow", true} ErrMemSizeOverflow = VMError{"memory size uint64 overflow", true} ErrReturnDataOutOfBounds = VMError{"vm: return data out of bounds", true} ErrBlockQuotaLimitReached = VMError{"quota limit for block reached", true} ErrAccountQuotaLimitReached = VMError{"quota limit for account reached", true} ErrOutOfQuota = VMError{"out of quota", true} ErrInvalidUnconfirmedQuota = VMError{"calc quota failed, invalid unconfirmed quota", true} ErrStackLimitReached = VMError{"stack limit reached", true} ErrStackUnderflow = VMError{"stack underflow", true} ErrInvalidJumpDestination = VMError{"invalid jump destination", true} ErrInvalidOpCode = VMError{"invalid opcode", true} ErrChainForked = VMError{"chain forked", false} ErrContractCreationFail = VMError{"contract creation failed", false} ErrExecutionCanceled = VMError{"vm execution canceled", false} )
View Source
var (
SolidityPPContractType uint8 = 1
)
Functions ¶
func AddBalance ¶
func AddBalance(db dbInterface, id *types.TokenTypeId, amount *big.Int)
func CalcQuotaUsed ¶
func DealWithErr ¶
func DealWithErr(v interface{})
DealWithErr panics if err is not nil. Used when chain forked or db error.
func FirstToLower ¶
func GetCodeFromCreateContractData ¶ added in v1.2.0
func GetContractCode ¶ added in v1.2.0
func GetContractTypeFromCreateContractData ¶ added in v1.2.0
func GetCreateContractData ¶ added in v1.2.0
func GetGidFromCreateContractData ¶ added in v1.2.0
func IntrinsicGasCost ¶
func IsDelegateGid ¶
func IsExistContractType ¶ added in v1.2.0
func IsPoW ¶
func IsPoW(block *ledger.AccountBlock) bool
func IsSnapshotGid ¶
func IsUserAccount ¶ added in v1.2.0
func IsValidQuotaRatio ¶
func IsViteToken ¶
func IsViteToken(tokenId types.TokenTypeId) bool
func MakeSendBlock ¶
func NewContractAddress ¶ added in v1.2.0
func NewLog ¶ added in v1.3.0
func NewLog(c abi.ABIContract, name string, params ...interface{}) *ledger.VmLog
func PackContractCode ¶ added in v1.2.0
func SubBalance ¶
func SubBalance(db dbInterface, id *types.TokenTypeId, amount *big.Int)
Types ¶
type ConsensusReader ¶
type ConsensusReader interface { GetIndexByStartTime(t int64, genesisTime int64) (startIndex uint64, startTime int64, drained bool) GetIndexByEndTime(t int64, genesisTime int64) (endIndex uint64, endTime int64, withinADay bool) GetIndexByTime(t int64, genesisTime int64) uint64 GetEndTimeByIndex(index uint64) int64 GetConsensusDetailByDay(startIndex, endIndex uint64) ([]*core.DayStats, error) }
type GasTable ¶
type GasTable struct { AddGas uint64 MulGas uint64 SubGas uint64 DivGas uint64 SdivGas uint64 ModGas uint64 SmodGas uint64 AddmodGas uint64 MulmodGas uint64 ExpGas uint64 ExpByteGas uint64 SignextendGas uint64 LtGas uint64 GtGas uint64 SltGas uint64 SgtGas uint64 EqGas uint64 IszeroGas uint64 AndGas uint64 OrGas uint64 XorGas uint64 NotGas uint64 ByteGas uint64 ShlGas uint64 ShrGas uint64 SarGas uint64 Blake2bGas uint64 Blake2bWordGas uint64 AddressGas uint64 BalanceGas uint64 CallerGas uint64 CallvalueGas uint64 CalldataloadGas uint64 CalldatasizeGas uint64 CalldatacopyGas uint64 MemcopyWordGas uint64 CodesizeGas uint64 CodeCopyGas uint64 ReturndatasizeGas uint64 ReturndatacopyGas uint64 TimestampGas uint64 HeightGas uint64 TokenidGas uint64 AccountheightGas uint64 PrevhashGas uint64 FromhashGas uint64 SeedGas uint64 RandomGas uint64 PopGas uint64 MloadGas uint64 MstoreGas uint64 Mstore8Gas uint64 SloadGas uint64 SstoreResetGas uint64 SstoreInitGas uint64 SstoreCleanGas uint64 SstoreNoopGas uint64 SstoreMemGas uint64 JumpGas uint64 JumpiGas uint64 PcGas uint64 MsizeGas uint64 JumpdestGas uint64 PushGas uint64 DupGas uint64 SwapGas uint64 LogGas uint64 LogTopicGas uint64 LogDataGas uint64 CallMinusGas uint64 MemGasDivision uint64 ConfirmTimeGas uint64 CodeGas uint64 MemGas uint64 TxGas uint64 TxDataGas uint64 CreateTxRequestGas uint64 CreateTxResponseGas uint64 RegisterGas uint64 UpdateRegistrationGas uint64 CancelRegisterGas uint64 RewardGas uint64 VoteGas uint64 CancelVoteGas uint64 PledgeGas uint64 CancelPledgeGas uint64 AgentPledgeGas uint64 AgentCancelPledgeGas uint64 MintGas uint64 IssueGas uint64 BurnGas uint64 TransferOwnerGas uint64 ChangeTokenTypeGas uint64 GetTokenInfoGas uint64 DexFundDepositGas uint64 DexFundWithdrawGas uint64 DexFundOpenNewMarketGas uint64 DexFundPlaceOrderGas uint64 DexFundSettleOrdersGas uint64 DexFundTriggerPeriodJobGas uint64 DexFundStakeForMiningGas uint64 DexFundStakeForVipGas uint64 DexFundStakeForSuperVIPGas uint64 DexFundDelegateStakeCallbackGas uint64 DexFundCancelDelegateStakeCallbackGas uint64 DexFundGetTokenInfoCallbackGas uint64 DexFundAdminConfigGas uint64 DexFundTradeAdminConfigGas uint64 DexFundMarketAdminConfigGas uint64 DexFundTransferTokenOwnershipGas uint64 DexFundNotifyTimeGas uint64 DexFundCreateNewInviterGas uint64 DexFundBindInviteCodeGas uint64 DexFundEndorseVxGas uint64 DexFundSettleMakerMinedVxGas uint64 DexFundConfigMarketAgentsGas uint64 DexFunPlaceAgentOrderGas uint64 }
func GasTableByHeight ¶
type GlobalStatus ¶
type GlobalStatus interface { Seed() (uint64, error) // Random number, returns same number Random() (uint64, error) // Random number, returns different number every time calls SnapshotBlock() *ledger.SnapshotBlock // Confirm snapshot block of send block }
Only exitst in contract receive block
type SBPStatReader ¶
type VMConsensusReader ¶
type VMConsensusReader struct {
// contains filtered or unexported fields
}
func NewVmConsensusReader ¶
func NewVmConsensusReader(sr SBPStatReader) *VMConsensusReader
func (*VMConsensusReader) GetConsensusDetailByDay ¶
func (r *VMConsensusReader) GetConsensusDetailByDay(startIndex, endIndex uint64) ([]*core.DayStats, error)
func (*VMConsensusReader) GetEndTimeByIndex ¶
func (r *VMConsensusReader) GetEndTimeByIndex(index uint64) int64
func (*VMConsensusReader) GetIndexByEndTime ¶
get first index before t and index start time if t <= genesis time + 24h, return index 0, within one day if t ∈ (genesis time + 24h, genesis time + 48h], return index 0
func (*VMConsensusReader) GetIndexByStartTime ¶
index 0 : (genesis time, genesis time + 24h] index 1: (genesis time + 24h, genesis time + 48h] get first index after t and index start time if t == -1, reward drained if t == 0, return index 0 if t ∈ (genesis time, genesis time + 24h], return index 1
func (*VMConsensusReader) GetIndexByTime ¶
func (r *VMConsensusReader) GetIndexByTime(t int64, genesisTime int64) uint64
Click to show internal directories.
Click to hide internal directories.