util

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2019 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TxGas                       uint64 = 21000 // Per transaction not creating a contract.
	PrecompiledContractsSendGas uint64 = 21068
	RefundGas                   uint64 = 21000
)

Variables

View Source
var (
	ErrInvalidMethodParam          = errors.New("invalid method param")
	ErrInsufficientBalance         = errors.New("insufficient balance for transfer")
	ErrContractAddressCreationFail = errors.New("contract address creation fail")
	ErrAddressCollision            = errors.New("contract address collision")
	ErrIdCollision                 = errors.New("id collision")
	ErrExecutionReverted           = errors.New("execution reverted")
	ErrGasUintOverflow             = errors.New("gas uint64 overflow")
	ErrMemSizeOverflow             = errors.New("memory size uint64 overflow")
	ErrReturnDataOutOfBounds       = errors.New("vm: return data out of bounds")
	ErrCalcPoWTwice                = errors.New("calc PoW twice referring to one snapshot block")
	ErrAbiMethodNotFound           = errors.New("abi: method not found")
	ErrDepth                       = errors.New("max call depth exceeded")

	ErrForked                     = errors.New("chain forked")
	ErrCalcPoWLimitReached        = errors.New("can not calc PoW in this block")
	ErrContractSendBlockRunFailed = errors.New("contract send block run failed")
	ErrVersionNotSupport          = errors.New("feature not supported in current snapshot height")
)
View Source
var (
	AttovPerVite = big.NewInt(1e18)
)
View Source
var (
	ErrOutOfQuota = errors.New("out of quota")
)
View Source
var (
	SolidityPPContractType = []byte{1}
)

Functions

func CalcQuotaUsed

func CalcQuotaUsed(quotaTotal, quotaAddition, quotaLeft, quotaRefund uint64, err error) uint64

func DataGasCost

func DataGasCost(data []byte) (uint64, error)

func GetCodeFromCreateContractData added in v1.2.0

func GetCodeFromCreateContractData(data []byte) []byte

func GetContractCode added in v1.2.0

func GetContractCode(db CommonDb, addr *types.Address) ([]byte, []byte)

func GetContractTypeFromCreateContractData added in v1.2.0

func GetContractTypeFromCreateContractData(data []byte) []byte

func GetCreateContractData added in v1.2.0

func GetCreateContractData(bytecode []byte, contractType []byte, gid types.Gid) []byte

func GetGidFromCreateContractData added in v1.2.0

func GetGidFromCreateContractData(data []byte) types.Gid

func IntrinsicGasCost

func IntrinsicGasCost(data []byte, isCreate bool) (uint64, error)

func IsExistContractType added in v1.2.0

func IsExistContractType(contractType []byte) bool

func IsSnapshotGid

func IsSnapshotGid(gid types.Gid) bool

func IsUserAccount added in v1.2.0

func IsUserAccount(db CommonDb, addr types.Address) bool

func IsViteToken

func IsViteToken(tokenId types.TokenTypeId) bool

func MakeSendBlock

func MakeSendBlock(block *ledger.AccountBlock, toAddress types.Address, blockType byte, amount *big.Int, tokenId types.TokenTypeId, height uint64, data []byte) *ledger.AccountBlock

func NewContractAddress added in v1.2.0

func NewContractAddress(accountAddress types.Address, accountBlockHeight uint64, prevBlockHash types.Hash, snapshotHash types.Hash) types.Address

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 PackContractCode(contractType, code []byte) []byte

func PrintMap added in v1.2.0

func PrintMap(m map[string][]byte) string

func UseQuota

func UseQuota(quotaLeft, cost uint64) (uint64, error)

func UseQuotaForData

func UseQuotaForData(data []byte, quotaLeft uint64) (uint64, error)

Types

type CommonDb added in v1.2.0

type CommonDb interface {
	GetContractCode(addr *types.Address) []byte
}

Jump to

Keyboard shortcuts

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