Documentation ¶
Index ¶
- Variables
- type ArgBlockChainHook
- type BlockChainHookCounter
- type BlockChainHookImpl
- func (bh *BlockChainHookImpl) ApplyFiltersOnCodeMetadata(codeMetadata vmcommon.CodeMetadata) vmcommon.CodeMetadata
- func (bh *BlockChainHookImpl) ClearCompiledCodes()
- func (bh *BlockChainHookImpl) Close() error
- func (bh *BlockChainHookImpl) CurrentEpoch() uint32
- func (bh *BlockChainHookImpl) CurrentNonce() uint64
- func (bh *BlockChainHookImpl) CurrentRandomSeed() []byte
- func (bh *BlockChainHookImpl) CurrentRound() uint64
- func (bh *BlockChainHookImpl) CurrentTimeStamp() uint64
- func (bh *BlockChainHookImpl) DeleteCompiledCode(codeHash []byte)
- func (bh *BlockChainHookImpl) EpochConfirmed(epoch uint32, _ uint64)
- func (bh *BlockChainHookImpl) FilterCodeMetadataForUpgrade(input []byte) ([]byte, error)
- func (bh *BlockChainHookImpl) GasScheduleChange(gasSchedule map[string]map[string]uint64)
- func (bh *BlockChainHookImpl) GetAllState(_ []byte) (map[string][]byte, error)
- func (bh *BlockChainHookImpl) GetBlockhash(nonce uint64) ([]byte, error)
- func (bh *BlockChainHookImpl) GetBuiltinFunctionNames() vmcommon.FunctionNames
- func (bh *BlockChainHookImpl) GetBuiltinFunctionsContainer() vmcommon.BuiltInFunctionContainer
- func (bh *BlockChainHookImpl) GetCode(account vmcommon.UserAccountHandler) []byte
- func (bh *BlockChainHookImpl) GetCompiledCode(codeHash []byte) (bool, []byte)
- func (bh *BlockChainHookImpl) GetCounterValues() map[string]uint64
- func (bh *BlockChainHookImpl) GetESDTToken(address []byte, tokenID []byte, nonce uint64) (*esdt.ESDigitalToken, error)
- func (bh *BlockChainHookImpl) GetShardOfAddress(address []byte) uint32
- func (bh *BlockChainHookImpl) GetSnapshot() int
- func (bh *BlockChainHookImpl) GetStateRootHash() []byte
- func (bh *BlockChainHookImpl) GetStorageData(accountAddress []byte, index []byte) ([]byte, uint32, error)
- func (bh *BlockChainHookImpl) GetUserAccount(address []byte) (vmcommon.UserAccountHandler, error)
- func (bh *BlockChainHookImpl) IsInterfaceNil() bool
- func (bh *BlockChainHookImpl) IsLimitedTransfer(tokenID []byte) bool
- func (bh *BlockChainHookImpl) IsPaused(tokenID []byte) bool
- func (bh *BlockChainHookImpl) IsPayable(sndAddress []byte, recvAddress []byte) (bool, error)
- func (bh *BlockChainHookImpl) IsSmartContract(address []byte) bool
- func (bh *BlockChainHookImpl) LastEpoch() uint32
- func (bh *BlockChainHookImpl) LastNonce() uint64
- func (bh *BlockChainHookImpl) LastRandomSeed() []byte
- func (bh *BlockChainHookImpl) LastRound() uint64
- func (bh *BlockChainHookImpl) LastTimeStamp() uint64
- func (bh *BlockChainHookImpl) NewAddress(creatorAddress []byte, creatorNonce uint64, vmType []byte) ([]byte, error)
- func (bh *BlockChainHookImpl) NumberOfShards() uint32
- func (bh *BlockChainHookImpl) ProcessBuiltInFunction(input *vmcommon.ContractCallInput) (*vmcommon.VMOutput, error)
- func (bh *BlockChainHookImpl) ResetCounters()
- func (bh *BlockChainHookImpl) RevertToSnapshot(snapshot int) error
- func (bh *BlockChainHookImpl) SaveCompiledCode(codeHash []byte, code []byte)
- func (bh *BlockChainHookImpl) SaveNFTMetaDataToSystemAccount(tx data.TransactionHandler) error
- func (bh *BlockChainHookImpl) SetCurrentHeader(hdr data.HeaderHandler)
- type VMCryptoHook
- func (vmch *VMCryptoHook) Ecrecover(_ []byte, _ []byte, _ []byte, _ []byte) ([]byte, error)
- func (vmch *VMCryptoHook) IsInterfaceNil() bool
- func (vmch *VMCryptoHook) Keccak256(data []byte) ([]byte, error)
- func (vmch *VMCryptoHook) Ripemd160(data []byte) ([]byte, error)
- func (vmch *VMCryptoHook) Sha256(data []byte) ([]byte, error)
Constants ¶
This section is empty.
Variables ¶
var ErrAddressLengthNotCorrect = errors.New("address length is not correct")
ErrAddressLengthNotCorrect signals that an account does not have the correct address
var ErrEmptyCode = errors.New("empty code in provided smart contract holding account")
ErrEmptyCode signals that an account does not contain code
var ErrNilBlockchainHookCounter = errors.New("nil blockchain hook counter")
ErrNilBlockchainHookCounter signals that a nil blockchain hook counter was provided
var ErrNotImplemented = errors.New("not implemented")
ErrNotImplemented signals that a functionality can not be used as it is not implemented
var ErrVMTypeLengthIsNotCorrect = errors.New("vm type length is not correct")
ErrVMTypeLengthIsNotCorrect signals that the vm type length is not correct
Functions ¶
This section is empty.
Types ¶
type ArgBlockChainHook ¶
type ArgBlockChainHook struct { Accounts state.AccountsAdapter PubkeyConv core.PubkeyConverter StorageService dataRetriever.StorageService DataPool dataRetriever.PoolsHolder BlockChain data.ChainHandler ShardCoordinator sharding.Coordinator Marshalizer marshal.Marshalizer Uint64Converter typeConverters.Uint64ByteSliceConverter BuiltInFunctions vmcommon.BuiltInFunctionContainer NFTStorageHandler vmcommon.SimpleESDTNFTStorageHandler GlobalSettingsHandler vmcommon.ESDTGlobalSettingsHandler CompiledSCPool storage.Cacher ConfigSCStorage config.StorageConfig EnableEpochs config.EnableEpochs EpochNotifier vmcommon.EpochNotifier EnableEpochsHandler common.EnableEpochsHandler WorkingDir string NilCompiledSCStore bool GasSchedule core.GasScheduleNotifier Counter BlockChainHookCounter }
ArgBlockChainHook represents the arguments structure for the blockchain hook
type BlockChainHookCounter ¶
type BlockChainHookCounter interface { ProcessCrtNumberOfTrieReadsCounter() error ProcessMaxBuiltInCounters(input *vmcommon.ContractCallInput) error ResetCounters() SetMaximumValues(mapsOfValues map[string]uint64) GetCounterValues() map[string]uint64 IsInterfaceNil() bool }
BlockChainHookCounter defines the operations of a blockchain hook counter handler
type BlockChainHookImpl ¶
type BlockChainHookImpl struct {
// contains filtered or unexported fields
}
BlockChainHookImpl is a wrapper over AccountsAdapter that satisfy vmcommon.BlockchainHook interface
func NewBlockChainHookImpl ¶
func NewBlockChainHookImpl( args ArgBlockChainHook, ) (*BlockChainHookImpl, error)
NewBlockChainHookImpl creates a new BlockChainHookImpl instance
func (*BlockChainHookImpl) ApplyFiltersOnCodeMetadata ¶
func (bh *BlockChainHookImpl) ApplyFiltersOnCodeMetadata(codeMetadata vmcommon.CodeMetadata) vmcommon.CodeMetadata
ApplyFiltersOnCodeMetadata will apply all known filters on the provided code metadata value
func (*BlockChainHookImpl) ClearCompiledCodes ¶
func (bh *BlockChainHookImpl) ClearCompiledCodes()
ClearCompiledCodes deletes the compiled codes from storage and cache
func (*BlockChainHookImpl) Close ¶
func (bh *BlockChainHookImpl) Close() error
Close closes/cleans up the blockchain hook
func (*BlockChainHookImpl) CurrentEpoch ¶
func (bh *BlockChainHookImpl) CurrentEpoch() uint32
CurrentEpoch returns the current epoch
func (*BlockChainHookImpl) CurrentNonce ¶
func (bh *BlockChainHookImpl) CurrentNonce() uint64
CurrentNonce returns the nonce from the current block
func (*BlockChainHookImpl) CurrentRandomSeed ¶
func (bh *BlockChainHookImpl) CurrentRandomSeed() []byte
CurrentRandomSeed returns the random seed from the current header
func (*BlockChainHookImpl) CurrentRound ¶
func (bh *BlockChainHookImpl) CurrentRound() uint64
CurrentRound returns the round from the current block
func (*BlockChainHookImpl) CurrentTimeStamp ¶
func (bh *BlockChainHookImpl) CurrentTimeStamp() uint64
CurrentTimeStamp return the timestamp from the current block
func (*BlockChainHookImpl) DeleteCompiledCode ¶
func (bh *BlockChainHookImpl) DeleteCompiledCode(codeHash []byte)
DeleteCompiledCode deletes the compiled code from storage and cache
func (*BlockChainHookImpl) EpochConfirmed ¶
func (bh *BlockChainHookImpl) EpochConfirmed(epoch uint32, _ uint64)
EpochConfirmed is called whenever a new epoch is confirmed
func (*BlockChainHookImpl) FilterCodeMetadataForUpgrade ¶
func (bh *BlockChainHookImpl) FilterCodeMetadataForUpgrade(input []byte) ([]byte, error)
FilterCodeMetadataForUpgrade will filter the provided input bytes as a correctly constructed vmcommon.CodeMetadata bytes taking into account the activation flags for the future flags. This should be used in the upgrade SC process
func (*BlockChainHookImpl) GasScheduleChange ¶
func (bh *BlockChainHookImpl) GasScheduleChange(gasSchedule map[string]map[string]uint64)
GasScheduleChange sets the new gas schedule where it is needed
func (*BlockChainHookImpl) GetAllState ¶
func (bh *BlockChainHookImpl) GetAllState(_ []byte) (map[string][]byte, error)
GetAllState returns the underlying state of a given account TODO remove this func completely
func (*BlockChainHookImpl) GetBlockhash ¶
func (bh *BlockChainHookImpl) GetBlockhash(nonce uint64) ([]byte, error)
GetBlockhash returns the header hash for a requested nonce delta
func (*BlockChainHookImpl) GetBuiltinFunctionNames ¶
func (bh *BlockChainHookImpl) GetBuiltinFunctionNames() vmcommon.FunctionNames
GetBuiltinFunctionNames returns the built-in function names
func (*BlockChainHookImpl) GetBuiltinFunctionsContainer ¶
func (bh *BlockChainHookImpl) GetBuiltinFunctionsContainer() vmcommon.BuiltInFunctionContainer
GetBuiltinFunctionsContainer returns the built-in functions container
func (*BlockChainHookImpl) GetCode ¶
func (bh *BlockChainHookImpl) GetCode(account vmcommon.UserAccountHandler) []byte
GetCode returns the code for the given account
func (*BlockChainHookImpl) GetCompiledCode ¶
func (bh *BlockChainHookImpl) GetCompiledCode(codeHash []byte) (bool, []byte)
GetCompiledCode returns the compiled code if it is found in the cache or storage
func (*BlockChainHookImpl) GetCounterValues ¶
func (bh *BlockChainHookImpl) GetCounterValues() map[string]uint64
GetCounterValues returns the current counter values
func (*BlockChainHookImpl) GetESDTToken ¶
func (bh *BlockChainHookImpl) GetESDTToken(address []byte, tokenID []byte, nonce uint64) (*esdt.ESDigitalToken, error)
GetESDTToken returns the unmarshalled esdt data for the given key
func (*BlockChainHookImpl) GetShardOfAddress ¶
func (bh *BlockChainHookImpl) GetShardOfAddress(address []byte) uint32
GetShardOfAddress is the hook that returns the shard of a given address
func (*BlockChainHookImpl) GetSnapshot ¶
func (bh *BlockChainHookImpl) GetSnapshot() int
GetSnapshot gets the number of entries in the journal as a snapshot id
func (*BlockChainHookImpl) GetStateRootHash ¶
func (bh *BlockChainHookImpl) GetStateRootHash() []byte
GetStateRootHash returns the state root hash from the last committed block
func (*BlockChainHookImpl) GetStorageData ¶
func (bh *BlockChainHookImpl) GetStorageData(accountAddress []byte, index []byte) ([]byte, uint32, error)
GetStorageData returns the storage value of a variable held in account's data trie
func (*BlockChainHookImpl) GetUserAccount ¶
func (bh *BlockChainHookImpl) GetUserAccount(address []byte) (vmcommon.UserAccountHandler, error)
GetUserAccount returns the balance of a shard account
func (*BlockChainHookImpl) IsInterfaceNil ¶
func (bh *BlockChainHookImpl) IsInterfaceNil() bool
IsInterfaceNil returns true if there is no value under the interface
func (*BlockChainHookImpl) IsLimitedTransfer ¶
func (bh *BlockChainHookImpl) IsLimitedTransfer(tokenID []byte) bool
IsLimitedTransfer returns true if the transfers
func (*BlockChainHookImpl) IsPaused ¶
func (bh *BlockChainHookImpl) IsPaused(tokenID []byte) bool
IsPaused returns true if the transfers for the given token ID are paused
func (*BlockChainHookImpl) IsPayable ¶
func (bh *BlockChainHookImpl) IsPayable(sndAddress []byte, recvAddress []byte) (bool, error)
IsPayable checks whether the provided address can receive ERD or not
func (*BlockChainHookImpl) IsSmartContract ¶
func (bh *BlockChainHookImpl) IsSmartContract(address []byte) bool
IsSmartContract returns whether the address points to a smart contract
func (*BlockChainHookImpl) LastEpoch ¶
func (bh *BlockChainHookImpl) LastEpoch() uint32
LastEpoch returns the epoch from the last committed block
func (*BlockChainHookImpl) LastNonce ¶
func (bh *BlockChainHookImpl) LastNonce() uint64
LastNonce returns the nonce from the last committed block
func (*BlockChainHookImpl) LastRandomSeed ¶
func (bh *BlockChainHookImpl) LastRandomSeed() []byte
LastRandomSeed returns the random seed from the last committed block
func (*BlockChainHookImpl) LastRound ¶
func (bh *BlockChainHookImpl) LastRound() uint64
LastRound returns the round from the last committed block
func (*BlockChainHookImpl) LastTimeStamp ¶
func (bh *BlockChainHookImpl) LastTimeStamp() uint64
LastTimeStamp returns the timeStamp from the last committed block
func (*BlockChainHookImpl) NewAddress ¶
func (bh *BlockChainHookImpl) NewAddress(creatorAddress []byte, creatorNonce uint64, vmType []byte) ([]byte, error)
NewAddress is a hook which creates a new smart contract address from the creators address and nonce The address is created by applied keccak256 on the appended value off creator address and nonce Prefix mask is applied for first 8 bytes 0, and for bytes 9-10 - VM type Suffix mask is applied - last 2 bytes are for the shard ID - mask is applied as suffix mask
func (*BlockChainHookImpl) NumberOfShards ¶
func (bh *BlockChainHookImpl) NumberOfShards() uint32
NumberOfShards returns the number of shards
func (*BlockChainHookImpl) ProcessBuiltInFunction ¶
func (bh *BlockChainHookImpl) ProcessBuiltInFunction(input *vmcommon.ContractCallInput) (*vmcommon.VMOutput, error)
ProcessBuiltInFunction is the hook through which a smart contract can execute a built-in function
func (*BlockChainHookImpl) ResetCounters ¶
func (bh *BlockChainHookImpl) ResetCounters()
ResetCounters resets the state counters for the blockchain hook
func (*BlockChainHookImpl) RevertToSnapshot ¶
func (bh *BlockChainHookImpl) RevertToSnapshot(snapshot int) error
RevertToSnapshot reverts snapshots up to the specified one
func (*BlockChainHookImpl) SaveCompiledCode ¶
func (bh *BlockChainHookImpl) SaveCompiledCode(codeHash []byte, code []byte)
SaveCompiledCode saves the compiled code to cache and storage
func (*BlockChainHookImpl) SaveNFTMetaDataToSystemAccount ¶
func (bh *BlockChainHookImpl) SaveNFTMetaDataToSystemAccount(tx data.TransactionHandler) error
SaveNFTMetaDataToSystemAccount will save NFT meta-data to system account for the given transaction
func (*BlockChainHookImpl) SetCurrentHeader ¶
func (bh *BlockChainHookImpl) SetCurrentHeader(hdr data.HeaderHandler)
SetCurrentHeader sets current header to be used by smart contracts
type VMCryptoHook ¶
type VMCryptoHook struct { }
VMCryptoHook is a wrapper used in vm implementation
func NewVMCryptoHook ¶
func NewVMCryptoHook() *VMCryptoHook
NewVMCryptoHook creates a new instance of a vm crypto hook
func (*VMCryptoHook) Ecrecover ¶
Ecrecover calculates the corresponding Ethereum address for the public key which created the given signature https://ewasm.readthedocs.io/en/mkdocs/system_contracts/
func (*VMCryptoHook) IsInterfaceNil ¶
func (vmch *VMCryptoHook) IsInterfaceNil() bool
IsInterfaceNil returns true if the underlying object is nil
func (*VMCryptoHook) Keccak256 ¶
func (vmch *VMCryptoHook) Keccak256(data []byte) ([]byte, error)
Keccak256 returns a keccak 256 hash of the input string. Should return in hex format.