Documentation ¶
Index ¶
- Constants
- Variables
- func CheckABI(b *Block, ctx *Context)
- func ContractInputsConv(Args []interface{}, rMethod reflect.Value) ([]reflect.Value, error)
- func ContractName(ClassID uint64) string
- func ContractType(ClassID uint64) string
- func EachAllAddressAmount(mp map[common.Address]*amount.Amount, ...) error
- func EachAllAddressBool(mp map[common.Address]bool, fn func(key common.Address, value bool) error) error
- func EachAllAddressBytes(mp map[common.Address][]byte, fn func(key common.Address, value []byte) error) error
- func EachAllAddressContractDefine(mp map[common.Address]*ContractDefine, ...) error
- func EachAllAddressUint32(mp map[common.Address]uint32, fn func(key common.Address, value uint32) error) error
- func EachAllAddressUint64(mp map[common.Address]uint64, fn func(key common.Address, value uint64) error) error
- func EachAllStringBool(mp map[string]bool, fn func(key string, value bool) error) error
- func EachAllStringBytes(mp map[string][]byte, fn func(key string, value []byte) error) error
- func EachAllTimeSlotMap(mp map[uint32]map[string]bool, ...) error
- func GetContractClassID(cont Contract) (string, uint64)
- func GetTxType(ctx *Context, tx *Transaction) (tp uint8, method string)
- func IsValidClassID(ClassID uint64) bool
- func MarshalAddressAmountMap(mp map[common.Address]*amount.Amount) ([]byte, error)
- func MarshalAddressBytesMap(mp map[common.Address][]byte) ([]byte, error)
- func MarshalID(height uint32, index uint16, n uint16) uint64
- func ParseTransactionID(TXID string) (uint32, uint16, error)
- func ParseTransactionIDBytes(bs []byte) (uint32, uint16, error)
- func RegisterContractType(cont Contract) (uint64, error)
- func SetLegacyCheckHeight(l uint32)
- func ToTimeSlot(timestamp uint64) uint32
- func TransactionID(Height uint32, Index uint16) string
- func TransactionIDBytes(Height uint32, Index uint16) []byte
- func TxArg(ctx *Context, tx *Transaction) (to common.Address, method string, data []interface{}, err error)
- func UnmarshalAddressAmountMap(bs []byte, mp map[common.Address]*amount.Amount) error
- func UnmarshalAddressBytesMap(bs []byte, mp map[common.Address][]byte) error
- func UnmarshalID(id uint64) (uint32, uint16, uint16)
- type Block
- type BlockSign
- type Body
- type ChargeFee
- type Context
- func (ctx *Context) AddAddrSeq(addr common.Address)
- func (ctx *Context) AddrSeq(addr common.Address) uint64
- func (ctx *Context) BasicFee() *amount.Amount
- func (ctx *Context) ChainID() *big.Int
- func (ctx *Context) Commit(sn int)
- func (ctx *Context) Contract(addr common.Address) (Contract, error)
- func (ctx *Context) ContractContext(cont Contract, from common.Address) *ContractContext
- func (ctx *Context) ContractContextFromAddress(cont, from common.Address) *ContractContext
- func (ctx *Context) ContractLoader(cont common.Address) ContractLoader
- func (ctx *Context) Data(cont common.Address, addr common.Address, name []byte) []byte
- func (ctx *Context) DeployContract(owner common.Address, ClassID uint64, Args []byte) (Contract, error)
- func (ctx *Context) DeployContractWithAddress(owner common.Address, ClassID uint64, addr common.Address, Args []byte) (Contract, error)
- func (ctx *Context) Dump() string
- func (ctx *Context) GetPCSize() uint64
- func (ctx *Context) Hash() hash.Hash256
- func (ctx *Context) IsAdmin(addr common.Address) bool
- func (ctx *Context) IsContract(addr common.Address) bool
- func (ctx *Context) IsGenerator(addr common.Address) bool
- func (ctx *Context) IsProcessReward() bool
- func (ctx *Context) IsUsedTimeSlot(slot uint32, key string) bool
- func (ctx *Context) LastTimestamp() uint64
- func (ctx *Context) MainToken() *common.Address
- func (ctx *Context) NextContext(LastHash hash.Hash256, Timestamp uint64) *Context
- func (ctx *Context) PrevHash() hash.Hash256
- func (ctx *Context) ProcessReward(inctx *Context, b *Block) (map[common.Address][]byte, error)
- func (ctx *Context) Revert(sn int)
- func (ctx *Context) SetAdmin(addr common.Address, is bool) error
- func (ctx *Context) SetBasicFee(fee *amount.Amount)
- func (ctx *Context) SetData(cont common.Address, addr common.Address, name []byte, value []byte)
- func (ctx *Context) SetGenerator(addr common.Address, is bool) error
- func (ctx *Context) SetMainToken(addr common.Address)
- func (ctx *Context) SetNonce(addr common.Address, nonce uint64)
- func (ctx *Context) Snapshot() int
- func (ctx *Context) StackSize() int
- func (ctx *Context) TargetHeight() uint32
- func (ctx *Context) Top() *ContextData
- func (ctx *Context) UseTimeSlot(slot uint32, key string) error
- func (ctx *Context) Version(h uint32) uint16
- func (ctx *Context) WriteDump() string
- type ContextData
- func (ctd *ContextData) AddAddrSeq(addr common.Address)
- func (ctd *ContextData) AddrSeq(addr common.Address) uint64
- func (ctd *ContextData) BasicFee() *amount.Amount
- func (ctd *ContextData) Contract(addr common.Address) (Contract, error)
- func (ctd *ContextData) Data(cont common.Address, addr common.Address, name []byte) []byte
- func (ctd *ContextData) DeployContract(sender common.Address, ClassID uint64, Args []byte) (Contract, error)
- func (ctd *ContextData) DeployContractWithAddress(sender common.Address, ClassID uint64, addr common.Address, Args []byte) (Contract, error)
- func (ctd *ContextData) Dump() string
- func (ctd *ContextData) GetPCSize() uint64
- func (ctd *ContextData) Hash() hash.Hash256
- func (ctd *ContextData) IsAdmin(addr common.Address) bool
- func (ctd *ContextData) IsContract(addr common.Address) bool
- func (ctd *ContextData) IsGenerator(addr common.Address) bool
- func (ctd *ContextData) IsUsedTimeSlot(slot uint32, key string) bool
- func (ctd *ContextData) MainToken() *common.Address
- func (ctd *ContextData) NextSeq() uint32
- func (ctd *ContextData) SetAdmin(addr common.Address, is bool) error
- func (ctd *ContextData) SetBasicFee(fee *amount.Amount)
- func (ctd *ContextData) SetData(cont common.Address, addr common.Address, name []byte, value []byte)
- func (ctd *ContextData) SetGenerator(addr common.Address, is bool) error
- func (ctd *ContextData) SetMainToken(addr common.Address)
- func (ctd *ContextData) SetNonce(addr common.Address, nonce uint64)
- func (ctd *ContextData) UnsafeBasicFee() *amount.Amount
- func (ctd *ContextData) UnsafeGetMainToken() *common.Address
- func (ctd *ContextData) UseTimeSlot(slot uint32, key string) error
- func (ctd *ContextData) WriteDump() string
- type Contract
- type ContractContext
- func (cc *ContractContext) AccountData(addr common.Address, name []byte) []byte
- func (cc *ContractContext) AddAddrSeq(addr common.Address)
- func (cc *ContractContext) AddrSeq(addr common.Address) uint64
- func (cc *ContractContext) ChainID() *big.Int
- func (cc *ContractContext) ContractData(name []byte) []byte
- func (cc *ContractContext) DeployContractWithAddress(owner common.Address, ClassID uint64, addr common.Address, Args []byte) (Contract, error)
- func (cc *ContractContext) EvmCall(caller vm.ContractRef, to common.Address, input []byte) ([]byte, uint64, error)
- func (cc *ContractContext) From() common.Address
- func (cc *ContractContext) Hash() hash.Hash256
- func (cc *ContractContext) IsContract(addr common.Address) bool
- func (cc *ContractContext) IsGenerator(addr common.Address) bool
- func (cc *ContractContext) IsUsedTimeSlot(slot uint32, key string) bool
- func (cc *ContractContext) LastTimestamp() uint64
- func (cc *ContractContext) MainToken() *common.Address
- func (cc *ContractContext) NextSeq() uint32
- func (cc *ContractContext) PrevHash() hash.Hash256
- func (cc *ContractContext) SetAccountData(addr common.Address, name []byte, value []byte)
- func (cc *ContractContext) SetContractData(name []byte, value []byte)
- func (cc *ContractContext) SetGenerator(addr common.Address, is bool) error
- func (cc *ContractContext) TargetHeight() uint32
- func (cc *ContractContext) Version(h uint32) uint16
- type ContractDefine
- type ContractLoader
- type Event
- type EventType
- type ExecFunc
- type Header
- type IEngin
- type IInteractor
- type InvokeableContract
- type Loader
- type MethodCallEvent
- type Process
- type Provider
- type Receipts
- type Service
- type ServiceBase
- type StateDB
- func (s *StateDB) AddAddressToAccessList(addr common.Address)
- func (s *StateDB) AddBalance(addr common.Address, amt *big.Int)
- func (s *StateDB) AddLog(log *etypes.Log)
- func (s *StateDB) AddPreimage(hash common.Hash, preimage []byte)
- func (s *StateDB) AddRefund(gas uint64)
- func (s *StateDB) AddSlotToAccessList(addr common.Address, slot common.Hash)
- func (s *StateDB) AddressInAccessList(addr common.Address) bool
- func (s *StateDB) BasicFee() *big.Int
- func (s *StateDB) ChainID() *big.Int
- func (s *StateDB) Copy() *StateDB
- func (s *StateDB) CreateAccount(addr common.Address)
- func (s *StateDB) Empty(addr common.Address) bool
- func (s *StateDB) Error() error
- func (s *StateDB) Exec(user common.Address, contAddr common.Address, input []byte, gas uint64) ([]byte, uint64, []*ctypes.Event, error)
- func (s *StateDB) Exist(addr common.Address) bool
- func (s *StateDB) Finalise(deleteEmptyObjects bool)
- func (db *StateDB) ForEachStorage(addr common.Address, cb func(key, value common.Hash) bool) error
- func (s *StateDB) GetBalance(addr common.Address) *big.Int
- func (s *StateDB) GetCode(addr common.Address) []byte
- func (s *StateDB) GetCodeHash(addr common.Address) common.Hash
- func (s *StateDB) GetCodeSize(addr common.Address) int
- func (s *StateDB) GetCommittedState(addr common.Address, hash common.Hash) common.Hash
- func (s *StateDB) GetLogs(hash common.Hash, blockHash common.Hash) []*etypes.Log
- func (s *StateDB) GetNonce(addr common.Address) uint64
- func (s *StateDB) GetProof(addr common.Address) ([][]byte, error)
- func (s *StateDB) GetProofByHash(addrHash common.Hash) ([][]byte, error)
- func (s *StateDB) GetRefund() uint64
- func (s *StateDB) GetState(addr common.Address, hash common.Hash) common.Hash
- func (s *StateDB) GetStorageProof(a common.Address, key common.Hash) ([][]byte, error)
- func (s *StateDB) HasSuicided(addr common.Address) bool
- func (s *StateDB) Hash() common.Hash
- func (s *StateDB) Height() uint32
- func (s *StateDB) IntermediateRoot(deleteEmptyObjects bool) common.Hash
- func (s *StateDB) IsEvmContract(addr common.Address) bool
- func (s *StateDB) IsExtContract(addr common.Address) bool
- func (s *StateDB) LastTimestamp() uint64
- func (s *StateDB) Logs() []*etypes.Log
- func (s *StateDB) Preimages() map[common.Hash][]byte
- func (s *StateDB) Prepare(thash common.Hash, ti int)
- func (s *StateDB) PrepareAccessList(sender common.Address, dst *common.Address, precompiles []common.Address, ...)
- func (s *StateDB) Revert(revid int)
- func (s *StateDB) RevertToSnapshot(revid int)
- func (s *StateDB) SetBalance(addr common.Address, amt *big.Int)
- func (s *StateDB) SetCode(addr common.Address, code []byte)
- func (s *StateDB) SetNonce(addr common.Address, nonce uint64)
- func (s *StateDB) SetState(addr common.Address, key, value common.Hash)
- func (s *StateDB) SetStorage(addr common.Address, storage map[common.Hash]common.Hash)
- func (s *StateDB) SlotInAccessList(addr common.Address, slot common.Hash) (addressPresent bool, slotPresent bool)
- func (s *StateDB) Snapshot() int
- func (s *StateDB) StartPrefetcher(namespace string)
- func (s *StateDB) StopPrefetcher()
- func (s *StateDB) SubBalance(addr common.Address, amt *big.Int)
- func (s *StateDB) SubRefund(gas uint64)
- func (s *StateDB) Suicide(addr common.Address) bool
- func (s *StateDB) TargetHeight() uint32
- func (s *StateDB) TxIndex() int
- type StateDBContext
- type Transaction
Constants ¶
const ( EventTagTxMsg = EventType(0x00) EventTagReward = EventType(0x01) EventTagCallHistory = EventType(0x02) EventTagTxFee = EventType(0x03) )
const ( Go uint8 = iota Js Evm )
Variables ¶
var ( ErrExistContractType = errors.New("exist contract type") ErrNotExistContract = errors.New("not exist contract") ErrInvalidClassID = errors.New("invalid class id") ErrInvalidContractTransactionID = errors.New("invalid contract transaction id") ErrInvalidTransactionCount = errors.New("invalid transaction count") ErrInvalidSignerCount = errors.New("invalid signer count") ErrInvalidSigner = errors.New("invalid signer") ErrDustAmount = errors.New("dust amount") ErrInvalidTransactionIDFormat = errors.New("invalid transaction id format") ErrUsedTimeSlot = errors.New("used timeslot") ErrInvalidTransactionTimeSlot = errors.New("invalid transaction timeslot") ErrAlreadyAdmin = errors.New("already admin") ErrInvalidAdmin = errors.New("invalid admin") ErrAlreadyGenerator = errors.New("already generator") ErrInvalidGenerator = errors.New("invalid generator") ErrDirtyContext = errors.New("dirty context") ErrInvalidContractMethod = errors.New("invalid contract method") ErrInvalidArguments = errors.New("invalid contract method arguments") ErrConstructorNotAllowd = errors.New("constructor not allowd") ErrOnlyFormulatorAllowed = errors.New("only formulator allowed") )
transaction errors
var (
String, _ = abi.NewType("string", "", nil)
Uint8, _ = abi.NewType("uint8", "", nil)
Uint256, _ = abi.NewType("uint256", "", nil)
Address, _ = abi.NewType("address", "", nil)
Bool, _ = abi.NewType("bool", "", nil)
)
var ExecLock sync.Mutex
Functions ¶
func ContractInputsConv ¶
func ContractName ¶
func ContractType ¶
func EachAllAddressAmount ¶
func EachAllAddressBool ¶
func EachAllAddressBytes ¶
func EachAllAddressContractDefine ¶
func EachAllAddressContractDefine(mp map[common.Address]*ContractDefine, fn func(key common.Address, cd *ContractDefine) error) error
func EachAllAddressUint32 ¶
func EachAllAddressUint64 ¶
func EachAllStringBool ¶
func EachAllStringBytes ¶
func EachAllTimeSlotMap ¶
func GetContractClassID ¶
func IsValidClassID ¶
func MarshalAddressAmountMap ¶
func MarshalAddressBytesMap ¶
func ParseTransactionID ¶
ParseTransactionID returns the id of the transaction
func ParseTransactionIDBytes ¶
ParseTransactionID returns the id of the transaction
func RegisterContractType ¶
IMPORTANT: RegisterContractType must be called only at initialization time and never have to called concurrently with CreateContract, IsValidClassID, ContractName functions
func SetLegacyCheckHeight ¶
func SetLegacyCheckHeight(l uint32)
func ToTimeSlot ¶
ToTimeSlot returns the timeslot of the timestamp
func TransactionID ¶
TransactionID returns the id of the transaction
func TransactionIDBytes ¶
TransactionIDBytes returns the id bytes of the transaction
Types ¶
type Body ¶
type ChargeFee ¶
type ChargeFee interface {
ChargeFee(cc *ContractContext, fee *amount.Amount) error
}
ChargeFee defines Chargeable Contract functions
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context is an intermediate in-memory state using the context data stack between blocks
func (*Context) AddAddrSeq ¶
AddAddrSeq update the sequence of the target account
func (*Context) ContractContext ¶
func (ctx *Context) ContractContext(cont Contract, from common.Address) *ContractContext
ContractContext returns a ContractContext
func (*Context) ContractContextFromAddress ¶
func (ctx *Context) ContractContextFromAddress(cont, from common.Address) *ContractContext
ContractContextFromAddress returns a ContractContext
func (*Context) ContractLoader ¶
func (ctx *Context) ContractLoader(cont common.Address) ContractLoader
ContractLoader returns a ContractLoader
func (*Context) DeployContract ¶
func (ctx *Context) DeployContract(owner common.Address, ClassID uint64, Args []byte) (Contract, error)
DeployContract deploy contract to the chain
func (*Context) DeployContractWithAddress ¶
func (ctx *Context) DeployContractWithAddress(owner common.Address, ClassID uint64, addr common.Address, Args []byte) (Contract, error)
DeployContract deploy contract to the chain with address
func (*Context) IsContract ¶
Contract returns the contract data
func (*Context) IsGenerator ¶
IsGenerator returns the account is generator or not
func (*Context) IsProcessReward ¶
IsProcessReward reeturns the reward is processed or not
func (*Context) IsUsedTimeSlot ¶
IsUsedTimeSlot returns timeslot is used or not
func (*Context) LastTimestamp ¶
LastTimestamp returns the prev timestamp of the chain
func (*Context) NextContext ¶
NextContext returns the next Context of the Context
func (*Context) ProcessReward ¶
ProcessReward returns processing the reward
func (*Context) SetBasicFee ¶
SetBasicFee update the basic fee
func (*Context) SetGenerator ¶
SetGenerator adds the account as a generator or not
func (*Context) SetMainToken ¶
func (*Context) TargetHeight ¶
TargetHeight returns the recorded target height when context generation
func (*Context) UseTimeSlot ¶
UseTimeSlot consumes timeslot
type ContextData ¶
type ContextData struct { Parent *ContextData AdminMap map[common.Address]bool DeletedAdminMap map[common.Address]bool AddrSeqMap map[common.Address]uint64 GeneratorMap map[common.Address]bool DeletedGeneratorMap map[common.Address]bool ContractDefineMap map[common.Address]*ContractDefine DataMap map[string][]byte DeletedDataMap map[string]bool TimeSlotMap map[uint32]map[string]bool // contains filtered or unexported fields }
ContextData is a state data of the context
func NewContextData ¶
func NewContextData(cache *contextCache, Parent *ContextData) *ContextData
NewContextData returns a ContextData
func (*ContextData) AddAddrSeq ¶
func (ctd *ContextData) AddAddrSeq(addr common.Address)
AddSeq update the sequence of the target address
func (*ContextData) AddrSeq ¶
func (ctd *ContextData) AddrSeq(addr common.Address) uint64
Seq returns the number of txs using the UseSeq flag of the address.
func (*ContextData) BasicFee ¶
func (ctd *ContextData) BasicFee() *amount.Amount
BasicFee returns the basic fee
func (*ContextData) Contract ¶
func (ctd *ContextData) Contract(addr common.Address) (Contract, error)
Contract returns the contract
func (*ContextData) DeployContract ¶
func (ctd *ContextData) DeployContract(sender common.Address, ClassID uint64, Args []byte) (Contract, error)
DeployContract deploy contract to the chain
func (*ContextData) DeployContractWithAddress ¶
func (ctd *ContextData) DeployContractWithAddress(sender common.Address, ClassID uint64, addr common.Address, Args []byte) (Contract, error)
DeployContract deploy contract to the chain with address
func (*ContextData) GetPCSize ¶
func (ctd *ContextData) GetPCSize() uint64
func (*ContextData) Hash ¶
func (ctd *ContextData) Hash() hash.Hash256
Hash returns the hash value of it
func (*ContextData) IsAdmin ¶
func (ctd *ContextData) IsAdmin(addr common.Address) bool
IsAdmin returns the account is admin or not
func (*ContextData) IsContract ¶
func (ctd *ContextData) IsContract(addr common.Address) bool
IsContract returns is the contract
func (*ContextData) IsGenerator ¶
func (ctd *ContextData) IsGenerator(addr common.Address) bool
IsGenerator returns the account is generator or not
func (*ContextData) IsUsedTimeSlot ¶
func (ctd *ContextData) IsUsedTimeSlot(slot uint32, key string) bool
IsUsedTimeSlot returns timeslot is used or not
func (*ContextData) MainToken ¶
func (ctd *ContextData) MainToken() *common.Address
MainToken returns the MainToken
func (*ContextData) NextSeq ¶
func (ctd *ContextData) NextSeq() uint32
NextSeq returns the next squence number
func (*ContextData) SetAdmin ¶
func (ctd *ContextData) SetAdmin(addr common.Address, is bool) error
SetAdmin adds the account as a admin or not
func (*ContextData) SetBasicFee ¶
func (ctd *ContextData) SetBasicFee(fee *amount.Amount)
SetBasicFee update the basic fee
func (*ContextData) SetData ¶
func (ctd *ContextData) SetData(cont common.Address, addr common.Address, name []byte, value []byte)
SetData inserts the data
func (*ContextData) SetGenerator ¶
func (ctd *ContextData) SetGenerator(addr common.Address, is bool) error
SetGenerator adds the account as a generator or not
func (*ContextData) SetMainToken ¶
func (ctd *ContextData) SetMainToken(addr common.Address)
SetMainToken is set the maintoken
func (*ContextData) SetNonce ¶
func (ctd *ContextData) SetNonce(addr common.Address, nonce uint64)
SetNonce update the sequence(nonce) of the target address
func (*ContextData) UnsafeBasicFee ¶
func (ctd *ContextData) UnsafeBasicFee() *amount.Amount
UnsafeBasicFee returns the basic fee
func (*ContextData) UnsafeGetMainToken ¶
func (ctd *ContextData) UnsafeGetMainToken() *common.Address
UnsafeGetMainToken returns the MainToken or nil
func (*ContextData) UseTimeSlot ¶
func (ctd *ContextData) UseTimeSlot(slot uint32, key string) error
UseTimeSlot consumes timeslot
func (*ContextData) WriteDump ¶
func (ctd *ContextData) WriteDump() string
Dump prints the context data
type Contract ¶
type Contract interface { Address() common.Address Master() common.Address Init(addr common.Address, master common.Address) OnCreate(cc *ContractContext, Args []byte) error OnReward(cc *ContractContext, b *Block, CountMap map[common.Address]uint32) (map[common.Address]*amount.Amount, error) Front() interface{} }
Contract defines chain Contract functions
func CreateContract ¶
func CreateContract(cd *ContractDefine) (Contract, error)
type ContractContext ¶
type ContractContext struct { Exec ExecFunc // contains filtered or unexported fields }
ContractContext is an context for the contract
func (*ContractContext) AccountData ¶
func (cc *ContractContext) AccountData(addr common.Address, name []byte) []byte
AccountData returns the account data from the top snapshot
func (*ContractContext) AddAddrSeq ¶
func (cc *ContractContext) AddAddrSeq(addr common.Address)
AddSeq update the sequence of the target account
func (*ContractContext) AddrSeq ¶
func (cc *ContractContext) AddrSeq(addr common.Address) uint64
Seq returns the sequence of the target account
func (*ContractContext) ChainID ¶
func (cc *ContractContext) ChainID() *big.Int
ChainID returns the id of the chain
func (*ContractContext) ContractData ¶
func (cc *ContractContext) ContractData(name []byte) []byte
ContractData returns the contract data from the top snapshot
func (*ContractContext) DeployContractWithAddress ¶
func (cc *ContractContext) DeployContractWithAddress(owner common.Address, ClassID uint64, addr common.Address, Args []byte) (Contract, error)
DeployContract deploy contract to the chain
func (*ContractContext) EvmCall ¶
func (cc *ContractContext) EvmCall(caller vm.ContractRef, to common.Address, input []byte) ([]byte, uint64, error)
EvmCall execute evm.Call function and returns result, usedGas, error
func (*ContractContext) From ¶
func (cc *ContractContext) From() common.Address
From returns current signer address
func (*ContractContext) Hash ¶
func (cc *ContractContext) Hash() hash.Hash256
Hash returns the hash value of it
func (*ContractContext) IsContract ¶
func (cc *ContractContext) IsContract(addr common.Address) bool
IsContract returns is the contract
func (*ContractContext) IsGenerator ¶
func (cc *ContractContext) IsGenerator(addr common.Address) bool
IsGenerator returns the account is generator or not
func (*ContractContext) IsUsedTimeSlot ¶
func (cc *ContractContext) IsUsedTimeSlot(slot uint32, key string) bool
IsUsedTimeSlot returns timeslot is used or not
func (*ContractContext) LastTimestamp ¶
func (cc *ContractContext) LastTimestamp() uint64
LastTimestamp returns the recorded prev timestamp when ContractContext generation
func (*ContractContext) MainToken ¶
func (cc *ContractContext) MainToken() *common.Address
MainToken returns the MainToken
func (*ContractContext) NextSeq ¶
func (cc *ContractContext) NextSeq() uint32
NextSeq returns the next squence number
func (*ContractContext) PrevHash ¶
func (cc *ContractContext) PrevHash() hash.Hash256
PrevHash returns the recorded prev hash when ContractContext generation
func (*ContractContext) SetAccountData ¶
func (cc *ContractContext) SetAccountData(addr common.Address, name []byte, value []byte)
SetAccountData inserts the account data to the top snapshot
func (*ContractContext) SetContractData ¶
func (cc *ContractContext) SetContractData(name []byte, value []byte)
SetContractData inserts the contract data to the top snapshot
func (*ContractContext) SetGenerator ¶
func (cc *ContractContext) SetGenerator(addr common.Address, is bool) error
SetGenerator adds the account as a generator or not only formulator contract can call
func (*ContractContext) TargetHeight ¶
func (cc *ContractContext) TargetHeight() uint32
TargetHeight returns the recorded target height when ContractContext generation
func (*ContractContext) Version ¶
func (cc *ContractContext) Version(h uint32) uint16
Version returns the version of the chain
type ContractDefine ¶
ContractDefine defines chain Contract functions
func (*ContractDefine) Clone ¶
func (s *ContractDefine) Clone() *ContractDefine
type ContractLoader ¶
type ContractLoader interface { Loader ContractData(name []byte) []byte AccountData(addr common.Address, name []byte) []byte }
ContractLoader defines functions that loads state data from the target chain
type ExecFunc ¶
type ExecFunc = func(Cc *ContractContext, Addr common.Address, MethodName string, Args []interface{}) ([]interface{}, error)
type Header ¶
type Header struct { ChainID *big.Int // ~=8byte Version uint16 // 2byte Height uint32 // 4byte PrevHash hash.Hash256 // 32byte LevelRootHash hash.Hash256 // 32byte ContextHash hash.Hash256 // 32byte TimeoutCount uint32 // 4byte Timestamp uint64 // 8byte Generator common.Address // 20byte Gas uint16 // 2byte ReceiptHash hash.Hash256 // 32byte }
type IInteractor ¶
type IInteractor interface { Distroy() Exec(Cc *ContractContext, Addr common.Address, MethodName string, Args []interface{}) ([]interface{}, error) EventList() []*ctypes.Event GasHistory() []uint64 AddEvent(*ctypes.Event) }
func NewInteractor ¶
func NewInteractor(ctx *Context, cont Contract, cc *ContractContext, TXID string, saveEvent bool) IInteractor
func NewInteractor2 ¶
func NewInteractor2(ctx *Context, cc *ContractContext, TXID string, saveEvent bool) IInteractor
type InvokeableContract ¶
type InvokeableContract interface {
ContractInvoke(cc *ContractContext, method string, params []interface{}) (interface{}, error)
}
type Loader ¶
type Loader interface { ChainID() *big.Int Version(uint32) uint16 TargetHeight() uint32 PrevHash() hash.Hash256 LastTimestamp() uint64 }
Loader defines functions that loads state data from the target chain
type MethodCallEvent ¶
type Provider ¶
type Provider interface { ChainID() *big.Int Version(uint32) uint16 Height() uint32 InitHeight() uint32 LastHash() hash.Hash256 LastTimestamp() uint64 Hash(uint32) (hash.Hash256, error) Header(uint32) (*Header, error) Block(uint32) (*Block, error) Receipts(uint32) (Receipts, error) AddrSeq(common.Address) uint64 Contract(addr common.Address) (Contract, error) }
Provider defines functions that loads chain data from the chain
type Receipts ¶
Receipts implements DerivableList for receipts.
func (*Receipts) DeriveReceiptFields ¶
func (rs *Receipts) DeriveReceiptFields(bHash common.Hash, number uint64, idx uint16, tx *etypes.Transaction, signer etypes.Signer) error
Receipt와 Log 데이터 중 일부를 block과 transaction 로부터 유추
type Service ¶
type Service interface { Name() string OnLoadChain(loader Loader) error OnBlockConnected(b *Block, loader Loader) OnTransactionInPoolExpired(txs []*Transaction) OnTransactionFail(height uint32, txs []*Transaction, err []error) }
Service defines service functions
type ServiceBase ¶
type ServiceBase struct{}
ServiceBase is a base handler of the chain service
func (*ServiceBase) OnBlockConnected ¶
func (s *ServiceBase) OnBlockConnected(b *Block, loader Loader)
OnBlockConnected called when a block is connected to the chain
func (*ServiceBase) OnLoadChain ¶
func (s *ServiceBase) OnLoadChain(loader Loader) error
OnLoadChain called when the chain loaded
func (*ServiceBase) OnTransactionFail ¶
func (s *ServiceBase) OnTransactionFail(height uint32, txs []*Transaction, err []error)
OnTransactionFail called when a transaction in pool is expired
func (*ServiceBase) OnTransactionInPoolExpired ¶
func (s *ServiceBase) OnTransactionInPoolExpired(txs []*Transaction)
OnTransactionInPoolExpired called when a transaction in pool is expired
type StateDB ¶
type StateDB struct {
// contains filtered or unexported fields
}
func NewStateDB ¶
func (*StateDB) AddAddressToAccessList ¶
AddAddressToAccessList adds the given address to the access list
func (*StateDB) AddBalance ¶
AddBalance adds amount to the account associated with addr.
func (*StateDB) AddPreimage ¶
AddPreimage records a SHA3 preimage seen by the VM.
func (*StateDB) AddSlotToAccessList ¶
AddSlotToAccessList adds the given (address, slot)-tuple to the access list
func (*StateDB) AddressInAccessList ¶
AddressInAccessList returns true if the given address is in the access list.
func (*StateDB) Copy ¶
Copy creates a deep, independent copy of the state. Snapshots of the copied state cannot be applied to the copy.
func (*StateDB) CreateAccount ¶
CreateAccount explicitly creates a state object. If a state object with the address already exists the balance is carried over to the new account.
CreateAccount is called during the EVM CREATE operation. The situation might arise that a contract does the following:
- sends funds to sha(account ++ (nonce + 1))
- tx_create(sha(account ++ nonce)) (note that this gets the address of 1)
Carrying over the balance ensures that Ether doesn't disappear.
func (*StateDB) Empty ¶
Empty returns whether the state object is either non-existent or empty according to the EIP161 specification (balance = nonce = code = 0)
func (*StateDB) Exec ¶
func (s *StateDB) Exec(user common.Address, contAddr common.Address, input []byte, gas uint64) ([]byte, uint64, []*ctypes.Event, error)
Exec executes the method of compiled contract in evm
func (*StateDB) Exist ¶
Exist reports whether the given account address exists in the state. Notably this also returns true for suicided accounts.
func (*StateDB) Finalise ¶
Finalise finalises the state by removing the s destructed objects and clears the journal as well as the refunds. Finalise, however, will not push any updates into the tries just yet. Only IntermediateRoot or Commit will do that.
func (*StateDB) ForEachStorage ¶
func (*StateDB) GetBalance ¶
GetBalance retrieves the balance from the given address or 0 if object not found
func (*StateDB) GetCommittedState ¶
GetCommittedState retrieves a value from the given account's committed storage trie.
func (*StateDB) GetProofByHash ¶
GetProofByHash returns the Merkle proof for a given account.
func (*StateDB) GetStorageProof ¶
GetStorageProof returns the Merkle proof for given storage slot.
func (*StateDB) IntermediateRoot ¶
IntermediateRoot computes the current root hash of the state trie. It is called in between transactions to get the root hash that goes into transaction receipts.
func (*StateDB) IsExtContract ¶
IsContract checks if the given address is contract one.
func (*StateDB) LastTimestamp ¶
LastTimestamp returns the prev timestamp of the chain
func (*StateDB) Prepare ¶
Prepare sets the current transaction hash and index which are used when the EVM emits new state logs.
func (*StateDB) PrepareAccessList ¶
func (s *StateDB) PrepareAccessList(sender common.Address, dst *common.Address, precompiles []common.Address, list etypes.AccessList)
PrepareAccessList handles the preparatory steps for executing a state transition with regards to both EIP-2929 and EIP-2930:
- Add sender to access list (2929) - Add destination to access list (2929) - Add precompiles to access list (2929) - Add the contents of the optional tx access list (2930)
This method should only be called if Berlin/2929+2930 is applicable at the current number.
func (*StateDB) RevertToSnapshot ¶
RevertToSnapshot reverts all state changes made since the given revision.
func (*StateDB) SetBalance ¶
SetBalance set amount of the account associated with addr.
func (*StateDB) SetCode ¶
SetCode save codeHash, size, code of the account(contract) associated with addr
func (*StateDB) SetStorage ¶
SetStorage replaces the entire storage for the specified account with given storage. This function should only be used for debugging.
func (*StateDB) SlotInAccessList ¶
func (s *StateDB) SlotInAccessList(addr common.Address, slot common.Hash) (addressPresent bool, slotPresent bool)
SlotInAccessList returns true if the given (address, slot)-tuple is in the access list.
func (*StateDB) StartPrefetcher ¶
StartPrefetcher initializes a new trie prefetcher to pull in nodes from the state trie concurrently while the state is mutated so that when we reach the commit phase, most of the needed data is already hot.
func (*StateDB) StopPrefetcher ¶
func (s *StateDB) StopPrefetcher()
StopPrefetcher terminates a running prefetcher and reports any leftover stats from the gathered metrics.
func (*StateDB) SubBalance ¶
SubBalance subtracts amount from the account associated with addr.
func (*StateDB) SubRefund ¶
SubRefund removes gas from the refund counter. This method will panic if the refund counter goes below zero
func (*StateDB) Suicide ¶
Suicide marks the given account as suicided. This clears the account balance.
The account's state object is still available until the state is committed, getStateObject will return a non-nil account after Suicide.
func (*StateDB) TargetHeight ¶
type StateDBContext ¶
type StateDBContext interface { ChainID() *big.Int TargetHeight() uint32 Hash() common.Hash AddrSeq(addr common.Address) uint64 SetNonce(addr common.Address, nonce uint64) Data(cont, addr common.Address, name []byte) []byte SetData(cont, addr common.Address, name, value []byte) IsContract(addr common.Address) bool Contract(addr common.Address) (Contract, error) ContractContext(cont Contract, from common.Address) *ContractContext Snapshot() int Revert(sn int) Commit(sn int) }
StateContext defines functions that Evm use as Database
type Transaction ¶
type Transaction struct { //Input data ChainID *big.Int Version uint16 Timestamp uint64 Seq uint64 To common.Address Method string Args []byte GasPrice *big.Int UseSeq bool IsEtherType bool //After exec tx data From common.Address VmType uint8 }
func NewTransaction ¶
func (*Transaction) HashSig ¶
func (s *Transaction) HashSig() (h hash.Hash256)
func (*Transaction) Message ¶
func (s *Transaction) Message() (h hash.Hash256)
Source Files ¶
- block.go
- block_body.go
- block_header.go
- block_sign.go
- context.go
- context_cache.go
- context_contract.go
- context_data.go
- contract.go
- contract_creator.go
- contract_define.go
- contract_engin.go
- errors.go
- event.go
- interactor.go
- loader.go
- loader_contract.go
- process.go
- provider.go
- receipts.go
- service.go
- state_context.go
- statedb.go
- transaction.go
- util.go