native

package
v0.0.0-...-886a677 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2024 License: MIT Imports: 52 Imported by: 3

Documentation

Overview

Package native contains Neo native contracts.

Index

Constants

View Source
const (
	ManagementContractID = -1

	// PrefixContract is a prefix used to store contract states inside Management native contract.
	PrefixContract = 8
)
View Source
const (

	// NEOTotalSupply is the total amount of NEO in the system.
	NEOTotalSupply = 100000000
	// DefaultRegisterPrice is the default price for candidate register.
	DefaultRegisterPrice = 1000 * GASFactor
)
View Source
const (

	// DefaultOracleRequestPrice is the default amount GAS needed for an oracle request.
	DefaultOracleRequestPrice = 5000_0000

	// MinimumResponseGas is the minimum response fee permitted for a request.
	MinimumResponseGas = 10_000_000
)
View Source
const (

	// DefaultStoragePrice is the price to pay for 1 byte of storage.
	DefaultStoragePrice = 100000
)
View Source
const (

	// DesignationEventName is the name of the designation event.
	DesignationEventName = "Designation"
)
View Source
const GASFactor = NEOTotalSupply

GASFactor is a divisor for finding GAS integral value.

Variables

View Source
var (
	ErrAlreadyDesignated = errors.New("already designated given role at current block")
	ErrEmptyNodeList     = errors.New("node list is empty")
	ErrInvalidIndex      = errors.New("invalid index")
	ErrInvalidRole       = errors.New("invalid role")
	ErrLargeNodeList     = errors.New("node list is too large")
	ErrNoBlock           = errors.New("no persisting block in the context")
)

Various errors.

View Source
var (
	ErrBigArgument      = errors.New("some of the arguments are invalid")
	ErrInvalidWitness   = errors.New("witness check failed")
	ErrLowResponseGas   = errors.New("not enough gas for response")
	ErrNotEnoughGas     = errors.New("gas limit exceeded")
	ErrRequestNotFound  = errors.New("oracle request not found")
	ErrResponseNotFound = errors.New("oracle response not found")
)

Various validation errors.

View Source
var (
	// ErrInvalidBase is returned when the base is invalid.
	ErrInvalidBase = errors.New("invalid base")
	// ErrInvalidFormat is returned when the string is not a number.
	ErrInvalidFormat = errors.New("invalid format")
	// ErrTooBigInput is returned when the input exceeds the size limit.
	ErrTooBigInput = errors.New("input is too big")
)

Functions

func Call

func Call(ic *interop.Context) error

Call calls the specified native contract method.

func CreateOracleResponseScript

func CreateOracleResponseScript(nativeOracleHash util.Uint160) []byte

CreateOracleResponseScript returns a script that is used to create the native Oracle response.

func GetContract

func GetContract(d *dao.Simple, hash util.Uint160) (*state.Contract, error)

GetContract returns a contract with the given hash from the given DAO.

func GetContractByID

func GetContractByID(d *dao.Simple, id int32) (*state.Contract, error)

GetContractByID returns a contract with the given ID from the given DAO.

func GetContractScriptHash

func GetContractScriptHash(d *dao.Simple, id int32) (util.Uint160, error)

GetContractScriptHash returns a contract hash associated with the given ID from the given DAO.

func Keccak256

func Keccak256(data []byte) util.Uint256

Keccak256 hashes the incoming byte slice using the keccak256 algorithm.

func MakeContractKey

func MakeContractKey(h util.Uint160) []byte

MakeContractKey creates a key from the account script hash.

func OnPersist

func OnPersist(ic *interop.Context) error

OnPersist calls OnPersist methods for all native contracts.

func PostPersist

func PostPersist(ic *interop.Context) error

PostPersist calls PostPersist methods for all native contracts.

func PutContractState

func PutContractState(d *dao.Simple, cs *state.Contract) error

PutContractState saves given contract state into given DAO.

Types

type Contracts

type Contracts struct {
	Management *Management
	Ledger     *Ledger
	NEO        *NEO
	GAS        *GAS
	Policy     *Policy
	Oracle     *Oracle
	Designate  *Designate
	Notary     *Notary
	Crypto     *Crypto
	Std        *Std
	Contracts  []interop.Contract
	// contains filtered or unexported fields
}

Contracts is a set of registered native contracts.

func NewContracts

func NewContracts(cfg config.ProtocolConfiguration) *Contracts

NewContracts returns a new set of native contracts with new GAS, NEO, Policy, Oracle, Designate and (optional) Notary contracts.

func (*Contracts) ByHash

func (cs *Contracts) ByHash(h util.Uint160) interop.Contract

ByHash returns a native contract with the specified hash.

func (*Contracts) ByName

func (cs *Contracts) ByName(name string) interop.Contract

ByName returns a native contract with the specified name.

func (*Contracts) GetPersistScript

func (cs *Contracts) GetPersistScript() []byte

GetPersistScript returns a VM script calling "onPersist" syscall for native contracts.

func (*Contracts) GetPostPersistScript

func (cs *Contracts) GetPostPersistScript() []byte

GetPostPersistScript returns a VM script calling "postPersist" syscall for native contracts.

type Crypto

type Crypto struct {
	interop.ContractMD
}

Crypto represents CryptoLib contract.

func (*Crypto) ActiveIn

func (c *Crypto) ActiveIn() *config.Hardfork

ActiveIn implements the Contract interface.

func (*Crypto) Initialize

func (c *Crypto) Initialize(ic *interop.Context, hf *config.Hardfork, newMD *interop.HFSpecificContractMD) error

Initialize implements the Contract interface.

func (*Crypto) InitializeCache

func (c *Crypto) InitializeCache(blockHeight uint32, d *dao.Simple) error

InitializeCache implements the Contract interface.

func (*Crypto) Metadata

func (c *Crypto) Metadata() *interop.ContractMD

Metadata implements the Contract interface.

func (*Crypto) OnPersist

func (c *Crypto) OnPersist(ic *interop.Context) error

OnPersist implements the Contract interface.

func (*Crypto) PostPersist

func (c *Crypto) PostPersist(ic *interop.Context) error

PostPersist implements the Contract interface.

type Designate

type Designate struct {
	interop.ContractMD
	NEO *NEO

	OracleService atomic.Value
	// NotaryService represents a Notary node module.
	NotaryService atomic.Value
	// StateRootService represents a StateRoot node module.
	StateRootService *stateroot.Module
	// contains filtered or unexported fields
}

Designate represents a designation contract.

func (*Designate) ActiveIn

func (s *Designate) ActiveIn() *config.Hardfork

ActiveIn implements the Contract interface.

func (*Designate) DesignateAsRole

func (s *Designate) DesignateAsRole(ic *interop.Context, r noderoles.Role, pubs keys.PublicKeys) error

DesignateAsRole sets nodes for role r.

func (*Designate) GetDesignatedByRole

func (s *Designate) GetDesignatedByRole(d *dao.Simple, r noderoles.Role, index uint32) (keys.PublicKeys, uint32, error)

GetDesignatedByRole returns nodes for role r.

func (*Designate) GetLastDesignatedHash

func (s *Designate) GetLastDesignatedHash(d *dao.Simple, r noderoles.Role) (util.Uint160, error)

GetLastDesignatedHash returns the last designated hash of the given role.

func (*Designate) Initialize

func (s *Designate) Initialize(ic *interop.Context, hf *config.Hardfork, newMD *interop.HFSpecificContractMD) error

Initialize initializes Designation contract. It is called once at native Management's OnPersist at the genesis block, and we can't properly fill the cache at this point, as there are no roles data in the storage.

func (*Designate) InitializeCache

func (s *Designate) InitializeCache(blockHeight uint32, d *dao.Simple) error

InitializeCache fills native Designate cache from DAO. It is called at non-zero height, thus we can fetch the roles data right from the storage.

func (*Designate) Metadata

func (s *Designate) Metadata() *interop.ContractMD

Metadata returns contract metadata.

func (*Designate) OnPersist

func (s *Designate) OnPersist(ic *interop.Context) error

OnPersist implements the Contract interface.

func (*Designate) PostPersist

func (s *Designate) PostPersist(ic *interop.Context) error

PostPersist implements the Contract interface.

type DesignationCache

type DesignationCache struct {
	// contains filtered or unexported fields
}

func (*DesignationCache) Copy

Copy implements NativeContractCache interface.

type GAS

type GAS struct {
	NEO    *NEO
	Policy *Policy
	// contains filtered or unexported fields
}

GAS represents GAS native contract.

func (*GAS) ActiveIn

func (g *GAS) ActiveIn() *config.Hardfork

ActiveIn implements the Contract interface.

func (*GAS) BalanceOf

func (g *GAS) BalanceOf(d *dao.Simple, acc util.Uint160) *big.Int

BalanceOf returns native GAS token balance for the acc.

func (*GAS) Decimals

func (c *GAS) Decimals(_ *interop.Context, _ []stackitem.Item) stackitem.Item

func (*GAS) Initialize

func (g *GAS) Initialize(ic *interop.Context, hf *config.Hardfork, newMD *interop.HFSpecificContractMD) error

Initialize initializes a GAS contract.

func (*GAS) InitializeCache

func (g *GAS) InitializeCache(blockHeight uint32, d *dao.Simple) error

InitializeCache implements the Contract interface.

func (*GAS) Metadata

func (c *GAS) Metadata() *interop.ContractMD

func (*GAS) OnPersist

func (g *GAS) OnPersist(ic *interop.Context) error

OnPersist implements the Contract interface.

func (*GAS) PostPersist

func (g *GAS) PostPersist(ic *interop.Context) error

PostPersist implements the Contract interface.

func (*GAS) Symbol

func (c *GAS) Symbol(_ *interop.Context, _ []stackitem.Item) stackitem.Item

func (*GAS) TotalSupply

func (c *GAS) TotalSupply(ic *interop.Context, _ []stackitem.Item) stackitem.Item

func (*GAS) Transfer

func (c *GAS) Transfer(ic *interop.Context, args []stackitem.Item) stackitem.Item

func (*GAS) TransferInternal

func (c *GAS) TransferInternal(ic *interop.Context, from, to util.Uint160, amount *big.Int, data stackitem.Item) error

TransferInternal transfers NEO across accounts.

type HashFunc

type HashFunc func([]byte) util.Uint256

HashFunc is a delegate representing a hasher function with 256 bytes output length.

type IDList

type IDList []uint64

IDList is a list of oracle request IDs.

func (*IDList) FromStackItem

func (l *IDList) FromStackItem(it stackitem.Item) error

FromStackItem implements stackitem.Convertible.

func (*IDList) Remove

func (l *IDList) Remove(id uint64) bool

Remove removes id from the list.

func (IDList) ToStackItem

func (l IDList) ToStackItem() (stackitem.Item, error)

ToStackItem implements stackitem.Convertible. It never returns an error.

type Ledger

type Ledger struct {
	interop.ContractMD
}

Ledger provides an interface to blocks/transactions storage for smart contracts. It's not a part of the proper chain's state, so it's just a proxy between regular Blockchain/DAO interface and smart contracts.

func (*Ledger) ActiveIn

func (l *Ledger) ActiveIn() *config.Hardfork

ActiveIn implements the Contract interface.

func (*Ledger) Initialize

func (l *Ledger) Initialize(ic *interop.Context, hf *config.Hardfork, newMD *interop.HFSpecificContractMD) error

Initialize implements the Contract interface.

func (*Ledger) InitializeCache

func (l *Ledger) InitializeCache(blockHeight uint32, d *dao.Simple) error

InitializeCache implements the Contract interface.

func (*Ledger) Metadata

func (l *Ledger) Metadata() *interop.ContractMD

Metadata implements the Contract interface.

func (*Ledger) OnPersist

func (l *Ledger) OnPersist(ic *interop.Context) error

OnPersist implements the Contract interface.

func (*Ledger) PostPersist

func (l *Ledger) PostPersist(ic *interop.Context) error

PostPersist implements the Contract interface.

type Management

type Management struct {
	interop.ContractMD
	NEO    *NEO
	Policy *Policy
}

Management is a contract-managing native contract.

func (*Management) ActiveIn

func (m *Management) ActiveIn() *config.Hardfork

ActiveIn implements the Contract interface.

func (*Management) Deploy

func (m *Management) Deploy(ic *interop.Context, sender util.Uint160, neff *nef.File, manif *manifest.Manifest) (*state.Contract, error)

Deploy creates a contract's hash/ID and saves a new contract into the given DAO. It doesn't run _deploy method and doesn't emit notification.

func (*Management) Destroy

func (m *Management) Destroy(d *dao.Simple, hash util.Uint160) error

Destroy drops the given contract from DAO along with its storage. It doesn't emit notification.

func (*Management) GetNEP11Contracts

func (m *Management) GetNEP11Contracts(d *dao.Simple) []util.Uint160

GetNEP11Contracts returns hashes of all deployed contracts that support NEP-11 standard. The list is updated every PostPersist, so until PostPersist is called, the result for the previous block is returned.

func (*Management) GetNEP17Contracts

func (m *Management) GetNEP17Contracts(d *dao.Simple) []util.Uint160

GetNEP17Contracts returns hashes of all deployed contracts that support NEP-17 standard. The list is updated every PostPersist, so until PostPersist is called, the result for the previous block is returned.

func (*Management) Initialize

func (m *Management) Initialize(ic *interop.Context, hf *config.Hardfork, newMD *interop.HFSpecificContractMD) error

Initialize implements the Contract interface.

func (*Management) InitializeCache

func (m *Management) InitializeCache(blockHeight uint32, d *dao.Simple) error

InitializeCache initializes contract cache with the proper values from storage. Cache initialization should be done apart from Initialize because Initialize is called only when deploying native contracts.

func (*Management) Metadata

func (m *Management) Metadata() *interop.ContractMD

Metadata implements the Contract interface.

func (*Management) OnPersist

func (m *Management) OnPersist(ic *interop.Context) error

OnPersist implements the Contract interface.

func (*Management) PostPersist

func (m *Management) PostPersist(ic *interop.Context) error

PostPersist implements the Contract interface.

func (*Management) Update

func (m *Management) Update(ic *interop.Context, hash util.Uint160, neff *nef.File, manif *manifest.Manifest) (*state.Contract, error)

Update updates contract's script and/or manifest in the given DAO. It doesn't run _deploy method and doesn't emit notification.

type ManagementCache

type ManagementCache struct {
	// contains filtered or unexported fields
}

func (*ManagementCache) Copy

Copy implements NativeContractCache interface.

type NEO

type NEO struct {
	GAS    *GAS
	Policy *Policy
	// contains filtered or unexported fields
}

NEO represents NEO native contract.

func (*NEO) ActiveIn

func (n *NEO) ActiveIn() *config.Hardfork

ActiveIn implements the Contract interface.

func (*NEO) BalanceOf

func (n *NEO) BalanceOf(d *dao.Simple, acc util.Uint160) (*big.Int, uint32)

BalanceOf returns native NEO token balance for the acc.

func (*NEO) CalculateBonus

func (n *NEO) CalculateBonus(ic *interop.Context, acc util.Uint160, end uint32) (*big.Int, error)

CalculateBonus calculates amount of gas generated for holding value NEO from start to end block and having voted for active committee member.

func (*NEO) CalculateNEOHolderReward

func (n *NEO) CalculateNEOHolderReward(d *dao.Simple, value *big.Int, start, end uint32) (*big.Int, error)

CalculateNEOHolderReward return GAS reward for holding `value` of NEO from start to end block.

func (*NEO) ComputeNextBlockValidators

func (n *NEO) ComputeNextBlockValidators(d *dao.Simple) keys.PublicKeys

ComputeNextBlockValidators computes an actual list of current validators that is relevant for the latest processed dBFT epoch and based on the changes made by register/unregister/vote calls during the latest epoch. Note: this method isn't actually "computes" new committee list and calculates new validators list from it. Instead, it uses cache, and the cache itself is updated during the PostPersist of the last block of every epoch.

func (*NEO) Decimals

func (c *NEO) Decimals(_ *interop.Context, _ []stackitem.Item) stackitem.Item

func (*NEO) GetCandidates

func (n *NEO) GetCandidates(d *dao.Simple) ([]state.Validator, error)

GetCandidates returns current registered validators list with keys and votes.

func (*NEO) GetCommitteeAddress

func (n *NEO) GetCommitteeAddress(d *dao.Simple) util.Uint160

GetCommitteeAddress returns address of the committee.

func (*NEO) GetCommitteeMembers

func (n *NEO) GetCommitteeMembers(d *dao.Simple) keys.PublicKeys

GetCommitteeMembers returns public keys of nodes in committee using cached value.

func (*NEO) GetGASPerBlock

func (n *NEO) GetGASPerBlock(d *dao.Simple, index uint32) *big.Int

GetGASPerBlock returns gas generated for block with provided index.

func (*NEO) GetNextBlockValidatorsInternal

func (n *NEO) GetNextBlockValidatorsInternal(d *dao.Simple) keys.PublicKeys

GetNextBlockValidatorsInternal returns next block validators.

func (*NEO) Initialize

func (n *NEO) Initialize(ic *interop.Context, hf *config.Hardfork, newMD *interop.HFSpecificContractMD) error

Initialize initializes a NEO contract.

func (*NEO) InitializeCache

func (n *NEO) InitializeCache(blockHeight uint32, d *dao.Simple) error

InitializeCache initializes all NEO cache with the proper values from the storage. Cache initialization should be done apart from Initialize because Initialize is called only when deploying native contracts. InitializeCache implements the Contract interface.

func (*NEO) Metadata

func (c *NEO) Metadata() *interop.ContractMD

func (*NEO) ModifyAccountVotes

func (n *NEO) ModifyAccountVotes(acc *state.NEOBalance, d *dao.Simple, value *big.Int, isNewVote bool) error

ModifyAccountVotes modifies votes of the specified account by value (can be negative). typ specifies if this modify is occurring during transfer or vote (with old or new validator).

func (*NEO) OnPersist

func (n *NEO) OnPersist(ic *interop.Context) error

OnPersist implements the Contract interface.

func (*NEO) PostPersist

func (n *NEO) PostPersist(ic *interop.Context) error

PostPersist implements the Contract interface.

func (*NEO) RegisterCandidateInternal

func (n *NEO) RegisterCandidateInternal(ic *interop.Context, pub *keys.PublicKey) error

RegisterCandidateInternal registers pub as a new candidate.

func (*NEO) SetGASPerBlock

func (n *NEO) SetGASPerBlock(ic *interop.Context, index uint32, gas *big.Int) error

SetGASPerBlock sets gas generated for blocks after index.

func (*NEO) Symbol

func (c *NEO) Symbol(_ *interop.Context, _ []stackitem.Item) stackitem.Item

func (*NEO) TotalSupply

func (c *NEO) TotalSupply(ic *interop.Context, _ []stackitem.Item) stackitem.Item

func (*NEO) Transfer

func (c *NEO) Transfer(ic *interop.Context, args []stackitem.Item) stackitem.Item

func (*NEO) TransferInternal

func (c *NEO) TransferInternal(ic *interop.Context, from, to util.Uint160, amount *big.Int, data stackitem.Item) error

TransferInternal transfers NEO across accounts.

func (*NEO) UnregisterCandidateInternal

func (n *NEO) UnregisterCandidateInternal(ic *interop.Context, pub *keys.PublicKey) error

UnregisterCandidateInternal unregisters pub as a candidate.

func (*NEO) VoteInternal

func (n *NEO) VoteInternal(ic *interop.Context, h util.Uint160, pub *keys.PublicKey) error

VoteInternal votes from account h for validarors specified in pubs.

type NamedCurveHash

type NamedCurveHash byte

NamedCurveHash identifies a pair of named elliptic curve and hash function.

const (
	Secp256k1Sha256    NamedCurveHash = 22
	Secp256r1Sha256    NamedCurveHash = 23
	Secp256k1Keccak256 NamedCurveHash = 122
	Secp256r1Keccak256 NamedCurveHash = 123
)

Various pairs of named elliptic curves and hash functions.

type NeoCache

type NeoCache struct {
	// contains filtered or unexported fields
}

func (*NeoCache) Copy

func (c *NeoCache) Copy() dao.NativeContractCache

Copy implements NativeContractCache interface.

type NodeList

type NodeList keys.PublicKeys

NodeList represents a list of oracle nodes.

func (*NodeList) FromStackItem

func (l *NodeList) FromStackItem(it stackitem.Item) error

FromStackItem implements stackitem.Convertible.

func (NodeList) ToStackItem

func (l NodeList) ToStackItem() (stackitem.Item, error)

ToStackItem implements stackitem.Convertible. It never returns an error.

type Notary

type Notary struct {
	interop.ContractMD
	GAS    *GAS
	NEO    *NEO
	Desig  *Designate
	Policy *Policy
}

Notary represents Notary native contract.

func (*Notary) ActiveIn

func (n *Notary) ActiveIn() *config.Hardfork

ActiveIn implements the Contract interface.

func (*Notary) BalanceOf

func (n *Notary) BalanceOf(dao *dao.Simple, acc util.Uint160) *big.Int

BalanceOf is an internal representation of `balanceOf` Notary method.

func (*Notary) ExpirationOf

func (n *Notary) ExpirationOf(dao *dao.Simple, acc util.Uint160) uint32

ExpirationOf is an internal representation of `expirationOf` Notary method.

func (*Notary) GetDepositFor

func (n *Notary) GetDepositFor(dao *dao.Simple, acc util.Uint160) *state.Deposit

GetDepositFor returns state.Deposit for the account specified. It returns nil in case the deposit is not found in the storage and panics in case of any other error.

func (*Notary) GetMaxNotValidBeforeDelta

func (n *Notary) GetMaxNotValidBeforeDelta(dao *dao.Simple) uint32

GetMaxNotValidBeforeDelta is an internal representation of Notary getMaxNotValidBeforeDelta method.

func (*Notary) GetNotaryNodes

func (n *Notary) GetNotaryNodes(d *dao.Simple) (keys.PublicKeys, error)

GetNotaryNodes returns public keys of notary nodes.

func (*Notary) Initialize

func (n *Notary) Initialize(ic *interop.Context, hf *config.Hardfork, newMD *interop.HFSpecificContractMD) error

Initialize initializes Notary native contract and implements the Contract interface.

func (*Notary) InitializeCache

func (n *Notary) InitializeCache(blockHeight uint32, d *dao.Simple) error

func (*Notary) Metadata

func (n *Notary) Metadata() *interop.ContractMD

Metadata implements the Contract interface.

func (*Notary) OnPersist

func (n *Notary) OnPersist(ic *interop.Context) error

OnPersist implements the Contract interface.

func (*Notary) PostPersist

func (n *Notary) PostPersist(ic *interop.Context) error

PostPersist implements the Contract interface.

type NotaryCache

type NotaryCache struct {
	// contains filtered or unexported fields
}

func (*NotaryCache) Copy

Copy implements NativeContractCache interface.

type NotaryService

type NotaryService interface {
	UpdateNotaryNodes(pubs keys.PublicKeys)
}

NotaryService is a Notary module interface.

type Oracle

type Oracle struct {
	interop.ContractMD
	GAS *GAS
	NEO *NEO

	Desig *Designate

	// Module is an oracle module capable of talking with the external world.
	Module atomic.Value
	// contains filtered or unexported fields
}

Oracle represents Oracle native contract.

func (*Oracle) ActiveIn

func (o *Oracle) ActiveIn() *config.Hardfork

ActiveIn implements the Contract interface.

func (*Oracle) FinishInternal

func (o *Oracle) FinishInternal(ic *interop.Context) error

FinishInternal processes an oracle response.

func (*Oracle) GetIDListInternal

func (o *Oracle) GetIDListInternal(d *dao.Simple, url string) (*IDList, error)

GetIDListInternal returns the request by ID and key under which it is stored.

func (*Oracle) GetOracleNodes

func (o *Oracle) GetOracleNodes(d *dao.Simple) (keys.PublicKeys, error)

GetOracleNodes returns public keys of oracle nodes.

func (*Oracle) GetOracleResponseScript

func (o *Oracle) GetOracleResponseScript() []byte

GetOracleResponseScript returns a script for the transaction with an oracle response.

func (*Oracle) GetRequestInternal

func (o *Oracle) GetRequestInternal(d *dao.Simple, id uint64) (*state.OracleRequest, error)

GetRequestInternal returns the request by ID and key under which it is stored.

func (*Oracle) GetRequests

func (o *Oracle) GetRequests(d *dao.Simple) (map[uint64]*state.OracleRequest, error)

GetRequests returns all requests which have not been finished yet.

func (*Oracle) GetScriptHash

func (o *Oracle) GetScriptHash(d *dao.Simple) (util.Uint160, error)

GetScriptHash returns script hash of oracle nodes.

func (*Oracle) Initialize

func (o *Oracle) Initialize(ic *interop.Context, hf *config.Hardfork, newMD *interop.HFSpecificContractMD) error

Initialize initializes an Oracle contract.

func (*Oracle) InitializeCache

func (o *Oracle) InitializeCache(blockHeight uint32, d *dao.Simple) error

func (*Oracle) Metadata

func (o *Oracle) Metadata() *interop.ContractMD

Metadata returns contract metadata.

func (*Oracle) OnPersist

func (o *Oracle) OnPersist(ic *interop.Context) error

OnPersist implements the Contract interface.

func (*Oracle) PostPersist

func (o *Oracle) PostPersist(ic *interop.Context) error

PostPersist represents `postPersist` method.

func (*Oracle) PutRequestInternal

func (o *Oracle) PutRequestInternal(id uint64, req *state.OracleRequest, d *dao.Simple) error

PutRequestInternal puts the oracle request with the specified id to d.

func (*Oracle) RequestInternal

func (o *Oracle) RequestInternal(ic *interop.Context, url string, filter *string, cb string, userData stackitem.Item, gas *big.Int) error

RequestInternal processes an oracle request.

type OracleCache

type OracleCache struct {
	// contains filtered or unexported fields
}

func (*OracleCache) Copy

Copy implements NativeContractCache interface.

type OracleService

type OracleService interface {
	// AddRequests processes new requests.
	AddRequests(map[uint64]*state.OracleRequest)
	// RemoveRequests removes already processed requests.
	RemoveRequests([]uint64)
	// UpdateOracleNodes updates oracle nodes.
	UpdateOracleNodes(keys.PublicKeys)
	// UpdateNativeContract updates oracle contract native script and hash.
	UpdateNativeContract([]byte, []byte, util.Uint160, int)
	// Start runs oracle module.
	Start()
	// Shutdown shutdowns oracle module.
	Shutdown()
}

OracleService specifies oracle module interface.

type Policy

type Policy struct {
	interop.ContractMD
	NEO *NEO
	// contains filtered or unexported fields
}

Policy represents Policy native contract.

func (*Policy) ActiveIn

func (p *Policy) ActiveIn() *config.Hardfork

ActiveIn implements the Contract interface.

func (*Policy) CheckPolicy

func (p *Policy) CheckPolicy(d *dao.Simple, tx *transaction.Transaction) error

CheckPolicy checks whether a transaction conforms to the current policy restrictions, like not being signed by a blocked account or not exceeding the block-level system fee limit.

func (*Policy) GetAttributeFeeInternal

func (p *Policy) GetAttributeFeeInternal(d *dao.Simple, t transaction.AttrType) int64

GetAttributeFeeInternal returns required transaction's attribute fee.

func (*Policy) GetExecFeeFactorInternal

func (p *Policy) GetExecFeeFactorInternal(d *dao.Simple) int64

GetExecFeeFactorInternal returns current execution fee factor.

func (*Policy) GetFeePerByteInternal

func (p *Policy) GetFeePerByteInternal(dao *dao.Simple) int64

GetFeePerByteInternal returns required transaction's fee per byte.

func (*Policy) GetMaxVerificationGas

func (p *Policy) GetMaxVerificationGas(dao *dao.Simple) int64

GetMaxVerificationGas returns the maximum gas allowed to be burned during verification.

func (*Policy) GetStoragePriceInternal

func (p *Policy) GetStoragePriceInternal(d *dao.Simple) int64

GetStoragePriceInternal returns current execution fee factor.

func (*Policy) Initialize

func (p *Policy) Initialize(ic *interop.Context, hf *config.Hardfork, newMD *interop.HFSpecificContractMD) error

Initialize initializes Policy native contract and implements the Contract interface.

func (*Policy) InitializeCache

func (p *Policy) InitializeCache(blockHeight uint32, d *dao.Simple) error

func (*Policy) IsBlocked

func (p *Policy) IsBlocked(dao *dao.Simple, hash util.Uint160) bool

IsBlocked checks whether provided account is blocked. Normally it uses Policy cache, falling back to the DB queries when Policy cache is not available yet (the only case is native cache initialization pipeline, where native Neo cache is being initialized before the Policy's one).

func (*Policy) Metadata

func (p *Policy) Metadata() *interop.ContractMD

Metadata implements the Contract interface.

func (*Policy) OnPersist

func (p *Policy) OnPersist(ic *interop.Context) error

OnPersist implements Contract interface.

func (*Policy) PostPersist

func (p *Policy) PostPersist(ic *interop.Context) error

PostPersist implements Contract interface.

type PolicyCache

type PolicyCache struct {
	// contains filtered or unexported fields
}

func (*PolicyCache) Copy

Copy implements NativeContractCache interface.

type Std

type Std struct {
	interop.ContractMD
}

Std represents an StdLib contract.

func (*Std) ActiveIn

func (s *Std) ActiveIn() *config.Hardfork

ActiveIn implements the Contract interface.

func (*Std) Initialize

func (s *Std) Initialize(ic *interop.Context, hf *config.Hardfork, newMD *interop.HFSpecificContractMD) error

Initialize implements the Contract interface.

func (*Std) InitializeCache

func (s *Std) InitializeCache(blockHeight uint32, d *dao.Simple) error

InitializeCache implements the Contract interface.

func (*Std) Metadata

func (s *Std) Metadata() *interop.ContractMD

Metadata implements the Contract interface.

func (*Std) OnPersist

func (s *Std) OnPersist(ic *interop.Context) error

OnPersist implements the Contract interface.

func (*Std) PostPersist

func (s *Std) PostPersist(ic *interop.Context) error

PostPersist implements the Contract interface.

Directories

Path Synopsis
native_test
package nativehashes contains hashes of all native contracts in their LE and Uint160 representation.
package nativehashes contains hashes of all native contracts in their LE and Uint160 representation.

Jump to

Keyboard shortcuts

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