models

package
v0.0.0-...-a968a3f Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2022 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Number of bytes occupied by event type
	EventTypeLength = 2

	// delta pool related
	MaxPopOfOneShardDelta = 10 // Delta number threshold per chain

	MaxTxCountPerBlock = 2000 // The maximum number of transactions packed in a block
	// The maximum number of deltas that can be merged in each block is twice the maximum number of TX
	MaxDeltasPerBlock = int(MaxTxCountPerBlock) << 1

	// compatible with Ethereum's transaction hash, pay attention to the tx.Hash() and tx.HashValue()
	// methods when upgrading the version
	ETHHashTxVersion      = 2
	NewBaseChainTxVersion = 3
	// There is a bug in V0, which leads to insufficient amount when creating or invoking the
	// contract, and the transaction will be packaged, but the nonce value does not increase
	TxVersion = NewBaseChainTxVersion
	// V0's BlockSummary.Hash Only a through transmission of BlockHash, can't reflect the location
	// information of the block, and can't complete the proof of cross chain. V1 adds chainid and
	// height to hash
	SummaryVersion = 1
)
View Source
const (
	MinDataNodes = 1
	MinBootNodes = 1
	MinAdmins    = 3
)
View Source
const (
	StartMsg = "start"
	StopMsg  = "stop"
)
View Source
const (
	LegacyTxType = iota
	AccessListTxType
	DynamicFeeTxType
)
View Source
const (
	// ReceiptStatusFailed is the status code of a transaction if execution failed.
	ReceiptStatusFailed = uint64(0)

	// ReceiptStatusSuccessful is the status code of a transaction if execution succeeded.
	ReceiptStatusSuccessful = uint64(1)
)
View Source
const (
	MaxPenalizedTime  = 3      // After the penalty exceeds this number of times, the pledge percentage is cleared to 0
	WithdrawDelayEras = 2      // Withdraw lags 2 eras
	MinConsensusRR    = 10000  // Lower limit of consensus node pledges, (202012: from 50000->10000)
	MaxConsensusRR    = 10000  // The consensus node pledges is calculated at most according to this,(202012: from 50000->10000)
	ConsensusRRUnit   = 1000   // each rr unit a consensus node pledge has, get a unit reward. Consensus.(Node.RR/RRUnit*UnitReward)
	MinDataRR         = 50000  // Lower limit of data node pledges, (202012: from 200000->50000)
	MaxDataRR         = 500000 // The data node pledges is calculated at most according to this, (202012: from 200000->50000, 202101: from 50000->500000)
	DataRRUnit        = 50000  // each rr unit a data node pledge has, get a unit reward. DataNode.(Node.RR/RRUnit*UnitReward)

	MinRewardBalance = 100000 // A balance limit of reward account to stop process reward request
)
View Source
const (
	PocDeadlineAddrName            = "pocdeadline"
	PocTryNewBlockContractAddrName = "poctrynewblockcontract"
	PocTryNewBlockMethodName       = "poctrynewblockmethod"
	PocDeadlinePrefixName          = "pocdeadlineprefix"
	PocDeadlineAbiJson             = "pocdeadlineabijson"
	PocBindAddrName                = "pocbind"
	PocBindPrefixName              = "pocbindprefix"
	PocBindAbiJson                 = "pocbindabijson"

	// // PosCommNodeRewardName = "poscommnodereward"
	// PosCommNodeRewardName = "poscommnodereward1w.202012"
	PosCommNodeRewardName = "poscommnodereward1k.202107"
	PosDataNodeRewardName = "posdatanodereward5w.202012"
	GasLimitName          = "gaslimit"
	GasPriceName          = "gasprice"
	RRStatusAuth          = "rrstatusauth"

	ManagedCommNodeIdsName = "managedcommnodeids"
)
View Source
const RRInfoVersion = 2

RRInfoVersion:1: NodeCount, 2: statue

Variables

View Source
var (
	TypeOfAccountPtr      = reflect.TypeOf((*Account)(nil))
	TypeOfAccountDeltaPtr = reflect.TypeOf((*AccountDelta)(nil))
)
View Source
var (
	// build-in accounts
	// MainAccountAddr private key: 684b01785f1deae43c5cac91d75305bff4665a1b9ae7efea020aeb4ae50c77cc
	MainAccountAddr              = common.HexToAddress("3461c3beb33b646d1174551209377960cbce5259")
	AddressOfChainInfoManage     = common.BytesToAddress([]byte{1, 0, 0})
	AddressOfManageChains        = common.BytesToAddress([]byte{1, 1, 0})
	AddressOfChainSettings       = common.BytesToAddress([]byte{1, 0, 1})
	AddressOfNewChainSettings    = common.BytesToAddress([]byte{1, 1, 1})
	AddressOfRequiredReserve     = common.BytesToAddress([]byte{1, 0, 2})
	AddressOfPenalty             = common.BytesToAddress([]byte{1, 0, 3})
	AddressOfManageCommittee     = common.BytesToAddress([]byte{1, 0, 4})
	AddressOfWriteCashCheck      = common.BytesToAddress([]byte{2, 0, 0})
	AddressOfCashCashCheck       = common.BytesToAddress([]byte{3, 0, 0})
	AddressOfCancelCashCheck     = common.BytesToAddress([]byte{4, 0, 0})
	AddressOfCurrencyExchanger   = common.BytesToAddress([]byte{5, 0, 0})
	AddressOfLocalCurrencyMinter = common.BytesToAddress([]byte{5, 0, 1})
	AddressOfTryPocFrom          = common.BytesToAddress([]byte{6, 0, 0})
	AddressOfRewardFrom          = common.HexToAddress("1111111111111111111111111111111111111111") // reward account
	AddressOfBlackHole           = common.HexToAddress("2222222222222222222222222222222222222222") // melt down currency
	// AddressOfRewardForGenesis private key: 01972b6aaa9f577ea0d6e32b63c3d138ff53db953e223ecd03d84cdc9c26e877
	AddressOfRewardForGenesis = common.HexToAddress("0xbb72feb361a0a383777fac3d6ac230d7d7586694") // binding account of genesis nodes
	// AddressOfGasReward private key: ab66fab847b6d15356d2257281fefb1920ca6f56a7bc44d699b5e82e9c133a94
	AddressOfGasReward = common.HexToAddress("0xd82a6555eaaaa022e89be40cffe4b7506112c04e") // gas fee account
)
View Source
var (
	ErrIllegalChainID  = errors.New("illegal chain id")
	ErrDelayEpochNum   = errors.New("delay epoch num")
	ErrDelayBlockNum   = errors.New("delay block num")
	ErrWrongState      = errors.New("wrong state")
	ErrShouldIgnore    = errors.New("should ignore this error")
	ErrWrongEvent      = errors.New("wrong event")
	ErrNeedBuffer      = errors.New("need to buf")
	ErrBufferByState   = errors.New("bufferred by state")
	ErrNoMatching      = errors.New("no matching event")
	ErrConsensusFailed = errors.New("consensus failed")
	ErrHeightExceeded  = errors.New("height exceeded")
)
View Source
var (
	BigShannon = big.NewInt(1000000000)
	BigTKM     = big.NewInt(0).Mul(BigShannon, BigShannon)
	BigBillion = big.NewInt(0).Mul(BigShannon, BigTKM)

	SystemNoticer Noticer
)
View Source
var (
	RawDataPool = sync.Pool{
		New: func() interface{} {
			return new(RawDataObj)
		},
	}

	QueueObjPool = sync.Pool{
		New: func() interface{} {
			return new(QueueObj)
		},
	}

	TypeOfContextPtr = reflect.TypeOf((*Context)(nil))
)
View Source
var (
	MinConsensusRRBig  = new(big.Int).Mul(big.NewInt(MinConsensusRR), BigTKM) // Pledge threshold for consensus nodes
	MaxConsensusRRBig  = new(big.Int).Mul(big.NewInt(MaxConsensusRR), BigTKM)
	ConsensusRRUnitBig = new(big.Int).Mul(big.NewInt(ConsensusRRUnit), BigTKM)
	MinDataRRBig       = new(big.Int).Mul(big.NewInt(MinDataRR), BigTKM) // Pledge threshold for data node
	MaxDataRRBig       = new(big.Int).Mul(big.NewInt(MaxDataRR), BigTKM)
	DataRRUnitBig      = new(big.Int).Mul(big.NewInt(DataRRUnit), BigTKM)

	MinRewardBalanceBig = new(big.Int).Mul(big.NewInt(MinRewardBalance), BigTKM)

	ErrLittleEra     = errors.New("era lesser than trie era")
	ErrMuchBigEra    = errors.New("era much bigger than trie era")
	ErrNeedSwitchEra = errors.New("need to switch era")
)
View Source
var (
	ErrInvalidSig         = errors.New("invalid transaction v, r, s values")
	ErrTxTypeNotSupported = errors.New("transaction type not supported")
)
View Source
var (
	ErrDuplicatedDeltaFrom = errors.New("duplicated deltas")
)
View Source
var (
	ErrDuplicatedEvent = errors.New("duplicated event found")
)
View Source
var (
	ErrMainChainOnly = errors.New("supported by main chain only")
)
View Source
var (
	ErrUnrecognized = errors.New("unrecognized")
)
View Source
var (
	EventProcs = newEventOperations()
)
View Source
var TypeOfLongStoragePtr = reflect.TypeOf((*LongValue)(nil))
View Source
var TypeOfTransactionPtr = reflect.TypeOf((*Transaction)(nil))
View Source
var VMPlugin *plugin.Plugin

Functions

func DecodeSignature

func DecodeSignature(sig []byte) (r, s, v *big.Int)

func DeleteReceipts

func DeleteReceipts(db dataBase.Database, hash common.Hash, number uint64)

DeleteReceipts removes all receipt data associated with a block hash.

func ETHChainID

func ETHChainID(tkmChainID common.ChainID, txVersion uint16) uint64

func ETHChainIDBig

func ETHChainIDBig(tkmChainID common.ChainID, txVersion uint16) *big.Int

func FindObjectTypeByEventType

func FindObjectTypeByEventType(eventType EventType) (t reflect.Type, ok bool)

func FromETHChainID

func FromETHChainID(ethChainId *big.Int) (common.ChainID, error)

func GetHistoryRoot

func GetHistoryRoot(holder DataHolder, height common.Height) ([]byte, error)

func HashSliceValueDecoder

func HashSliceValueDecoder(r io.Reader) (o interface{}, err error)

func HashSliceValueEncoder

func HashSliceValueEncoder(o interface{}, w io.Writer) error

func HashSliceValueExpander

func HashSliceValueExpander(hashBytes []byte, adpater db.DataAdapter) (valueBytes []byte, err error)

It's just a hash value, and the hash value is key, so you don't need to save it

func HashSliceValueHasher

func HashSliceValueHasher(value interface{}, valueBytes []byte) (hashBytes []byte, err error)

Only hash is reserved. The data of CashCheck is provided by the client, so the value itself is the hash value

func IsControlEvent

func IsControlEvent(eventType EventType) bool

func ListOperatorFuncs

func ListOperatorFuncs(eventType EventType, opTypes ...OperatorType) []reflect.Value

func NewIdentifier

func NewIdentifier(priv []byte) (common.Identifier, error)

func NewIdentifierByHex

func NewIdentifierByHex(privHexString string) (common.Identifier, error)

func NewNodeIdentifier

func NewNodeIdentifier(priv []byte) (common.NodeIdentifier, error)

func NewNodeIdentifierByHex

func NewNodeIdentifierByHex(privHexString string) (common.NodeIdentifier, error)

func NewNodeIdentifierByHexWithoutError

func NewNodeIdentifierByHexWithoutError(privHexString string) common.NodeIdentifier

func NewUnknownEventTypeError

func NewUnknownEventTypeError(typ reflect.Type) error

func ParseToAddress

func ParseToAddress(bitLength uint, shardPos uint16, nodePos uint16, index uint64) (addr common.Address)

Deprecated

func PreelectSeed

func PreelectSeed(seed common.Seed, blockHash common.Hash) common.Seed

func RRDepositRequestHash

func RRDepositRequestHash(nodeId common.NodeID, nodeType common.NodeType,
	bindAddr common.Address, nonce uint64, amount *big.Int) []byte

func ReachCommit

func ReachCommit(commSize, committed int) bool

func ReachConfirm

func ReachConfirm(commSize, confirmed int) bool

func ReachPrepare

func ReachPrepare(commSize, prepared int) bool

func RegisterControlEvent

func RegisterControlEvent(eventType EventType)

func RegisterEvents

func RegisterEvents(eventMap map[EventType]reflect.Type, nameMap map[EventType]string)

func RegisterOperator

func RegisterOperator(operator Operator)

func RegisterQueueInfo

func RegisterQueueInfo(name string, workerSize int, queueLength int, higherTypes []EventType, eventTypes ...EventType)

func ReleaseQueueObj

func ReleaseQueueObj(obj *QueueObj)

func ReleaseRawData

func ReleaseRawData(rawData *RawDataObj)

func SCLongStorageKey

func SCLongStorageKey(addr common.Address, name []byte) common.Hash

The Key in LongStorage is composed of account address and additional value (generally attribute name), used for system contracts usually

func SCLongStorageKey2

func SCLongStorageKey2(addr common.Address, name string) common.Hash

func TransactionStringForHash

func TransactionStringForHash(chainid common.ChainID, from *common.Address, to *common.Address, nonce uint64,
	uselocal bool, val *big.Int, input []byte, extra []byte) string

func UnmarshalEvent

func UnmarshalEvent(eventType EventType, body []byte) (interface{}, error)

func VerifyVrfResult

func VerifyVrfResult(event VrfResulter, seed common.Seed) error

func WriteReceipts

func WriteReceipts(db dataBase.Database, receipts Receipts) ([]byte, error)

WriteReceipts stores all the transaction receipts belonging to a block.

Types

type AccessList

type AccessList []AccessTuple

AccessList is an EIP-2930 access list.

func (AccessList) StorageKeys

func (al AccessList) StorageKeys() int

StorageKeys returns the total number of storage keys in the access list.

type AccessListTx

type AccessListTx struct {
	ChainID    *big.Int        // destination chain ID
	Nonce      uint64          // nonce of sender account
	GasPrice   *big.Int        // wei per gas
	Gas        uint64          // gas limit
	To         *common.Address `rlp:"nil"` // nil means contract creation
	Value      *big.Int        // wei amount
	Data       []byte          // contract invocation input data
	AccessList AccessList      // EIP-2930 access list
	V, R, S    *big.Int        // signature values
}

AccessListTx is the data of EIP-2930 access list transactions.

func (*AccessListTx) TxType

func (tx *AccessListTx) TxType() byte

TxType accessors for innerTx.

type AccessTuple

type AccessTuple struct {
	Address     common.Address `json:"address"        gencodec:"required"`
	StorageKeys []common.Hash  `json:"storageKeys"    gencodec:"required"`
}

AccessTuple is the element type of an access list.

type Account

type Account struct {
	Addr            common.Address `json:"address"`         // account address
	Nonce           uint64         `json:"nonce"`           // next transaction nonce
	Balance         *big.Int       `json:"balance"`         // basic currency, never be nil
	LocalCurrency   *big.Int       `json:"localCurrency"`   // local currency (if exist), could be nil
	StorageRoot     []byte         `json:"storageRoot"`     // storage for contract,Trie(key: Hash, value: Hash)
	CodeHash        []byte         `json:"codeHash"`        // hash of contract code
	LongStorageRoot []byte         `json:"longStorageRoot"` // more complex storage for contract, Trie(key: Hash, value: []byte)
}

1. currency type can be determinded in a normal transfer, default is basic currency 2. in contract calling, value type can be determinded. solidity contract can only use local currency if it has a local currency in the chain.

func NewAccount

func NewAccount(addr common.Address, balance *big.Int) *Account

func (*Account) AddLocalCurrency

func (a *Account) AddLocalCurrency(amount *big.Int) error

func (*Account) Address

func (a *Account) Address() common.Address

func (*Account) Clone

func (a *Account) Clone() *Account

func (*Account) HashValue

func (a *Account) HashValue() ([]byte, error)

for compatible with old version, if there's no local currency and LongStorage, hash should same with the hash of old version account. TODO delete compatible when restart the chain with new version

func (*Account) IsUserContract

func (a *Account) IsUserContract() bool

func (*Account) String

func (a *Account) String() string

type AccountDelta

type AccountDelta struct {
	Addr          common.Address
	Delta         *big.Int // Balance modification
	CurrencyDelta *big.Int // LocalCurrency modification (if has)
}

func NewAccountDelta

func NewAccountDelta(addr common.Address, delta *big.Int, currencyDelta *big.Int) *AccountDelta

func (*AccountDelta) Add

func (d *AccountDelta) Add(delta *big.Int)

func (*AccountDelta) AddCurrency

func (d *AccountDelta) AddCurrency(delta *big.Int)

func (*AccountDelta) Address

func (d *AccountDelta) Address() common.Address

func (*AccountDelta) HashValue

func (d *AccountDelta) HashValue() ([]byte, error)

TODO delete compatible when restart the chain with new version

func (*AccountDelta) String

func (d *AccountDelta) String() string

type AccountDeltaFromTrie

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

func NewAccountDeltaFromTrie

func NewAccountDeltaFromTrie(dbase db.Database) *AccountDeltaFromTrie

func (*AccountDeltaFromTrie) FromDeltaFroms

func (d *AccountDeltaFromTrie) FromDeltaFroms(deltaFroms DeltaFroms) error

func (*AccountDeltaFromTrie) HashValue

func (d *AccountDeltaFromTrie) HashValue() (hashValue []byte, err error)

func (*AccountDeltaFromTrie) Put

func (d *AccountDeltaFromTrie) Put(shardId common.ChainID, height common.Height, t *trie.Trie) bool

func (*AccountDeltaFromTrie) ToDeltaFroms

func (d *AccountDeltaFromTrie) ToDeltaFroms() (DeltaFroms, error)

type AccountDeltaTrie

type AccountDeltaTrie struct {
	trie.SmallCombinedTrie
	// contains filtered or unexported fields
}

func NewAccountDeltaTrie

func NewAccountDeltaTrie(shardInfo common.ShardInfo, dbase db.Database) *AccountDeltaTrie

func (*AccountDeltaTrie) Delete

func (t *AccountDeltaTrie) Delete(key []byte) (changed bool, oldValue interface{})

func (*AccountDeltaTrie) Deserialization

func (t *AccountDeltaTrie) Deserialization(r io.Reader) (shouldBeNil bool, err error)

func (*AccountDeltaTrie) Get

func (t *AccountDeltaTrie) Get(key []byte) (value interface{}, ok bool)

func (*AccountDeltaTrie) GetExistenceProof

func (t *AccountDeltaTrie) GetExistenceProof(key []byte) (exist bool, proofs trie.ProofChain, err error)

func (*AccountDeltaTrie) GetProof

func (t *AccountDeltaTrie) GetProof(addrKey []byte) (interface{}, trie.ProofChain, bool)

func (t *AccountDeltaTrie) GetProof(addrKey []byte) (interface{}, common.ProofHash, bool) {

func (*AccountDeltaTrie) GetSub

func (t *AccountDeltaTrie) GetSub(id common.ChainID) (trie.ITrie, bool)

func (*AccountDeltaTrie) GetSubProof

func (t *AccountDeltaTrie) GetSubProof(id common.ChainID) (value trie.ITrie, proof trie.ProofChain, ok bool)

func (*AccountDeltaTrie) HashValue

func (t *AccountDeltaTrie) HashValue() (HashValue []byte, err error)

func (*AccountDeltaTrie) Put

func (t *AccountDeltaTrie) Put(key []byte, value interface{}) bool

Put key is Address

func (*AccountDeltaTrie) PutValue

func (t *AccountDeltaTrie) PutValue(value trie.TrieValue) bool

func (*AccountDeltaTrie) Reset

func (t *AccountDeltaTrie) Reset()

func (*AccountDeltaTrie) Serialization

func (t *AccountDeltaTrie) Serialization(w io.Writer) error

func (*AccountDeltaTrie) ValueIterator

func (t *AccountDeltaTrie) ValueIterator() trie.ValueIterator

type AccountState

type AccountState interface {
	Address() common.Address
	GetAccount() *Account
}

type Accounts

type Accounts []*Account

func (Accounts) Len

func (a Accounts) Len() int

func (Accounts) Less

func (a Accounts) Less(i, j int) bool

func (Accounts) Swap

func (a Accounts) Swap(i, j int)

type AttendanceRecord

type AttendanceRecord struct {
	Epoch      common.EpochNum // current epoch
	Attendance *big.Int        // Indicates by bit whether the corresponding data block is empty, Attendance.Bit(BlockNum)==1 is normal block and ==0 is empty block
	DataNodes  common.NodeIDs  // List of datanode nodeid in ascending order
	Stats      []int           // Stats of alive data nodes
	// contains filtered or unexported fields
}

Even if it is an empty block, the attendance table must be filled in. Otherwise, when the last block of epoch is an empty block, the data node will not be able to report the attendance table (the previous block cannot prove the attendance of the following block). Therefore, the empty block should not only fill in the attendance table, but also fill in the attendance hash in the header. In this way, the attendance table of each block is locked in the header, so there is no need to record blocknum separately

func NewAttendanceRecord

func NewAttendanceRecord(epoch common.EpochNum, dataNodes ...common.NodeID) *AttendanceRecord

func (*AttendanceRecord) AddDataNodeStat

func (a *AttendanceRecord) AddDataNodeStat(nodeId common.NodeID)

func (*AttendanceRecord) Formalize

func (a *AttendanceRecord) Formalize()

func (*AttendanceRecord) Hash

func (a *AttendanceRecord) Hash() (*common.Hash, error)

func (*AttendanceRecord) IsLegalFirst

func (a *AttendanceRecord) IsLegalFirst(datanodes common.NodeIDs) error

func (*AttendanceRecord) IsLegalNext

func (a *AttendanceRecord) IsLegalNext(next *AttendanceRecord) error

func (*AttendanceRecord) SetAbsentness

func (a *AttendanceRecord) SetAbsentness(epoch common.EpochNum, block common.BlockNum)

func (*AttendanceRecord) SetAttendance

func (a *AttendanceRecord) SetAttendance(epoch common.EpochNum, block common.BlockNum)

func (*AttendanceRecord) String

func (a *AttendanceRecord) String() string

type BlockAppendSuccess

type BlockAppendSuccess func(block *BlockEMessage, hashOfHeader []byte) error

type BlockBody

type BlockBody struct {
	NextCommittee     *Committee        // election results of the next committee
	NCMsg             []*ElectMessage   // election requests for chains (in main chain)
	DeltaFroms        DeltaFroms        // deltas merged to current shard
	Txs               []*Transaction    // transactions
	TxsPas            []*PubAndSig      // signatures corresponding to packaged transactions
	Deltas            []*AccountDelta   // the delta generated by packaged transactions on current shard needs to be sent to other shards
	Hds               []*BlockSummary   // block summary reported by children chains
	Attendance        *AttendanceRecord // attendance table of the current epoch
	RewardReqs        RewardRequests    // self-proving reward request of each chain received on the main chain
	ElectingResults   ChainElectResults // Since v1.5.0, a list of election results, it's a preelection when Epoch.IsNil()==true, others are local election (not provided at present)
	PreElectings      PreElectings      // Since v1.5.0, the list of preselections in progress, sorted by (expire, chainid)
	NextRealCommittee *Committee        // Since v1.5.0, when election finished, the result will be put into NextCommittee. If the election is failed, the current committee will continue to be used in the next epoch. At this time, the current committee needs to be written into this field, which can be brought with it when reporting.
	SeedFactor        SeedFactor        // Since v2.0.0, random factor of seed
}

func (*BlockBody) AttendanceRoot

func (bb *BlockBody) AttendanceRoot() (*common.Hash, error)

func (*BlockBody) ElectResultRoot

func (bb *BlockBody) ElectResultRoot() (*common.Hash, error)

func (*BlockBody) Formalize

func (bb *BlockBody) Formalize()

func (*BlockBody) HdsRoot

func (bb *BlockBody) HdsRoot() (*common.Hash, error)

func (*BlockBody) NextCommitteeRoot

func (bb *BlockBody) NextCommitteeRoot() (*common.Hash, error)

func (*BlockBody) PreElectRoot

func (bb *BlockBody) PreElectRoot() (*common.Hash, error)

func (*BlockBody) SeedFactorRoot

func (bb *BlockBody) SeedFactorRoot() (*common.Hash, error)

func (*BlockBody) TransactionsRoot

func (bb *BlockBody) TransactionsRoot() (*common.Hash, error)

type BlockChain

type BlockChain interface {
	CurrentBlock() *BlockEMessage
	Append(block *BlockEMessage, validator func(*BlockEMessage) error) (int, []byte, error)
	GetCurrentHeight() common.Height
	GetBlockHash(height common.Height) (*common.Hash, bool)
	GetBlock(height common.Height) (*BlockEMessage, error)
	GetHeader(height common.Height) (*BlockHeader, error)
	GetBlockByHash(hashOfHeader []byte) (*BlockEMessage, error)
	GetBlockTxIndexs(txHash []byte) (*TXIndex, error)
}

type BlockCursor

type BlockCursor struct {
	Height common.Height
	Hash   []byte
}

BlockCursor Cursor information used to record blocks, including block height and block hash

type BlockEMessage

type BlockEMessage struct {
	BlockHeader *BlockHeader
	BlockBody   *BlockBody
	BlockPass   PubAndSigs
}

func GenesisBlock

func GenesisBlock(id common.ChainID, holder DataHolder) *BlockEMessage

func NewEmptyBlock

func NewEmptyBlock(holder DataHolder, lastBlock *BlockEMessage, committeeHash *common.Hash) (*BlockEMessage, error)

func (*BlockEMessage) BlockNum

func (b *BlockEMessage) BlockNum() common.BlockNum

func (*BlockEMessage) CheckHashs

func (b *BlockEMessage) CheckHashs() error

CheckHashs Recalculate and verify the data in the header according to the body data, and return the corresponding error if it fails

func (*BlockEMessage) EpochNum

func (b *BlockEMessage) EpochNum() common.EpochNum

func (*BlockEMessage) EraString

func (b *BlockEMessage) EraString() string

func (*BlockEMessage) Formalize

func (b *BlockEMessage) Formalize()

func (*BlockEMessage) GetChainID

func (b *BlockEMessage) GetChainID() common.ChainID

func (*BlockEMessage) GetHeight

func (b *BlockEMessage) GetHeight() common.Height

func (*BlockEMessage) GetHistoryRoot

func (b *BlockEMessage) GetHistoryRoot() []byte

func (*BlockEMessage) Hash

func (b *BlockEMessage) Hash() common.Hash

func (*BlockEMessage) InfoString

func (b *BlockEMessage) InfoString() string

func (*BlockEMessage) String

func (b *BlockEMessage) String() string

type BlockHeader

type BlockHeader struct {
	PreviousHash   common.Hash    `json:"previoushash"` // the hash of the previous block header on current chain
	HashHistory    common.Hash    `json:"history"`      // hash of the history tree of hash for each block recorded in height order
	ChainID        common.ChainID `json:"chainid"`      // current chain id
	Height         common.Height  `json:"height"`       // height of current block
	Empty          bool           `json:"empty"`        // empty block
	ParentHeight   common.Height  `json:"-"`            // height of parent height, is 0 if current is main chain
	ParentHash     *common.Hash   `json:"-"`            // block hash of main chain block at ParentHeight, nil if current is main chain
	RewardAddress  common.Address `json:"-"`            // reward to
	AttendanceHash *common.Hash   `json:"-"`            // The current epoch attendance record hash
	RewardedCursor *common.Height `json:"-"`            // If the current chain is the reward chain, record start height of main chain when next reward issues

	CommitteeHash    *common.Hash   `json:"-"`    // current epoch Committee member trie root hash
	ElectedNextRoot  *common.Hash   `json:"-"`    // root hash of the election result of next epoch committee members
	NewCommitteeSeed *common.Seed   `json:"seed"` // Current election seeds, only in the main chain
	RREra            *common.EraNum `json:"-"`    // the era corresponding to the root of the current Required Reserve tree. When this value is inconsistent with the height of main chain, it indicates that a new RR tree needs to be calculated
	RRRoot           *common.Hash   `json:"-"`    // root hash of the Required Reserve tree in current era. Only in the reward chain and the main chain
	RRNextRoot       *common.Hash   `json:"-"`    // root hash of the Required Reserve tree in next era. Only in the reward chain and the main chain
	RRChangingRoot   *common.Hash   `json:"-"`    // changes waiting to be processed in current era

	MergedDeltaRoot  *common.Hash `json:"mergeroot"` // Root hash of the merged delta sent from other shards
	BalanceDeltaRoot *common.Hash `json:"deltaroot"` // Root hash of the generated deltas by this block which needs to be sent to the other shards
	StateRoot        common.Hash  `json:"stateroot"` // account on current chain state trie root hash
	ChainInfoRoot    *common.Hash `json:"-"`         // for main chain only: all chain info trie root hash
	WaterlinesRoot   *common.Hash `json:"-"`         // since v2.3.0, the waterlines of other shards to current chain after the execution of this block. nil represent all zeros. Because the value of the previous block needs to be inherited when the block is empty, values after block execution recorded.
	VCCRoot          *common.Hash `json:"-"`         // Root hash of transfer out check tree in business chain
	CashedRoot       *common.Hash `json:"-"`         // Root hash of transfer in check tree in business chain
	TransactionRoot  *common.Hash `json:"-"`         // transactions in current block trie root hash
	ReceiptRoot      *common.Hash `json:"-"`         // receipts for transactions in current block trie root hash
	HdsRoot          *common.Hash `json:"-"`         // if there's any child chain of current chain, this is the Merkle trie root hash generated by the reported block header information of the child chain in order

	TimeStamp uint64 `json:"timestamp"`

	ElectResultRoot *common.Hash `json:"-"` // Since v1.5.0, Election result hash root (including pre election and ordinary election, ordinary one has not been provided yet)
	PreElectRoot    *common.Hash `json:"-"` // Since v1.5.0, the root hash of current preelecting list sorted by (Expire, ChainID), only in the main chain
	FactorRoot      *common.Hash `json:"-"` // since v2.0.0, seed random factor hash
}

func GenesisHeader

func GenesisHeader(id common.ChainID, holder DataHolder) *BlockHeader

func NewEmptyHeader

func NewEmptyHeader(holder DataHolder, lastHeader *BlockHeader, committeeHash *common.Hash) (*BlockHeader, error)

func (*BlockHeader) Era

func (h *BlockHeader) Era() common.EraNum

func (BlockHeader) GetHeight

func (h BlockHeader) GetHeight() common.Height

func (*BlockHeader) GetHistoryRoot

func (h *BlockHeader) GetHistoryRoot() []byte

func (*BlockHeader) Hash

func (h *BlockHeader) Hash() common.Hash

func (*BlockHeader) HashValue

func (h *BlockHeader) HashValue() ([]byte, error)

func (*BlockHeader) InfoString

func (h *BlockHeader) InfoString() string

func (*BlockHeader) MakeProof

func (h *BlockHeader) MakeProof(typ trie.ProofType, proofChain *trie.ProofChain) (hashOfHeader []byte, err error)

func (*BlockHeader) Proof

func (h *BlockHeader) Proof(typ trie.ProofType) (hashOfHeader []byte, indexHash *common.Hash, proof *common.MerkleProofs, err error)

Proof generate proof from a specified field to block hash

func (*BlockHeader) String

func (h *BlockHeader) String() string

func (*BlockHeader) Summary

func (h *BlockHeader) Summary() string

type BlockHeight

type BlockHeight struct {
	ChainID common.ChainID
	Height  common.Height
}

To broadcast last height of the chain the current node recorded. Used to select the data node with the lowest height in the same chain ast the leader of synchronous data. The leader broadcasts the synchronization data. If everyone is highly consistent, everyone will send the same synchronization data FIXME: should use the data node with the highest height of data to be the leader. missing data

should be resync by sync procedure

func (*BlockHeight) GetBlockNum

func (bh *BlockHeight) GetBlockNum() common.BlockNum

func (*BlockHeight) GetChainID

func (bh *BlockHeight) GetChainID() common.ChainID

func (*BlockHeight) GetEpochNum

func (bh *BlockHeight) GetEpochNum() common.EpochNum

func (*BlockHeight) GetHeight

func (bh *BlockHeight) GetHeight() common.Height

func (BlockHeight) String

func (bh BlockHeight) String() string

type BlockHeighter

type BlockHeighter interface {
	GetHeight() common.Height
	Hash() common.Hash
}

type BlockReport

type BlockReport struct {
	ToChainId   common.ChainID
	BlockHeader *BlockHeader    // the header of the reporting block
	NextComm    *EpochCommittee // next committee when election finished
	BlockPass   []*PubAndSig    // signatures of committee members who comfirmed reporting block. can be changed to aggregate signature in the future
}

BlockReport report of Block

func (*BlockReport) DestChainID

func (r *BlockReport) DestChainID() common.ChainID

func (*BlockReport) GetChainID

func (r *BlockReport) GetChainID() common.ChainID

func (*BlockReport) Hash

func (r *BlockReport) Hash() common.Hash

func (*BlockReport) String

func (r *BlockReport) String() string

func (*BlockReport) Verify

func (r *BlockReport) Verify() error

type BlockRequest

type BlockRequest struct {
	ChainId common.ChainID
	Height  common.Height
	NodeId  common.NodeID
}

func (*BlockRequest) GetChainID

func (b *BlockRequest) GetChainID() common.ChainID

func (*BlockRequest) GetHeight

func (b *BlockRequest) GetHeight() common.Height

func (*BlockRequest) String

func (b *BlockRequest) String() string

type BlockSummary

type BlockSummary struct {
	ChainId   common.ChainID
	Height    common.Height
	BlockHash common.Hash
	// since v1.5.0, the election result of the next committee whill be packaged together.
	// Because only the data and comm node will receive the report and record the next committee
	// of the sub chain. Since the new elected node has already been synchronizing the main chain,
	// it will not synchronize the data again, then it will not be able to synchronize all the sub
	// chain committee information, resulting in the nodes missing the corresponding information
	// when the new epoch begins.
	NextComm *EpochCommittee
	// V0's BlockSummary.Hash is same with blockhash, which can't reflect the location information
	// of the block, and can't complete the proof of cross chain. V1 adds chainid and height to hash
	Version uint16
}

func (*BlockSummary) GetChainID

func (s *BlockSummary) GetChainID() common.ChainID

func (*BlockSummary) Hash

func (s *BlockSummary) Hash() common.Hash

func (*BlockSummary) HashValue

func (s *BlockSummary) HashValue() ([]byte, error)

func (*BlockSummary) String

func (s *BlockSummary) String() string

func (*BlockSummary) SummaryHash

func (s *BlockSummary) SummaryHash() ([]byte, error)

type CachedHeighter

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

func NewCacheHeighter

func NewCacheHeighter(event BlockHeighter, pub, sig []byte) *CachedHeighter

func (*CachedHeighter) GetHeight

func (h *CachedHeighter) GetHeight() common.Height

func (*CachedHeighter) GetObject

func (h *CachedHeighter) GetObject() BlockHeighter

func (*CachedHeighter) Hash

func (h *CachedHeighter) Hash() common.Hash

func (*CachedHeighter) PubAndSig

func (h *CachedHeighter) PubAndSig() (pub, sig []byte)

type CancelCashCheckRequest

type CancelCashCheckRequest struct {
	Check             *CashCheck      `json:"check"`           // cheque to be voided
	AbsenceChainID    common.ChainID  `json:"chain"`           // the target chain of the proof
	AbsenceHeight     common.Height   `json:"height"`          // block height of target chain which proof prove to
	AbsenceHeaderHash common.Hash     `json:"header"`          // the proof target hash of Proofs
	CCCProofs         trie.ProofChain `json:"absence"`         // CashedTrie's proof of non-existence of check
	Proofs            trie.ProofChain `json:"proofs"`          // from CashedTrie.Root Proof chain to the target of proof
	ConfirmedHeight   common.Height   `json:"confirmedHeight"` // the main chain block height which confirmed target block header
}

a valid cancel request must:

  1. CCCProofs.IsExist(Hash(Check))==false, means the check not cashed
  2. Proofs[0].PType==trie.ProofHeaderCCCRoot, to proof it's a CashedTrie proof
  3. Proofs[0].IsHeaderOf(Check.ToChain, AbsenceHeight)==true, to proof that the current proof is actually generated by the block of target height of the target chain
  4. AbsenceHeaderHash==Hash(Block(ChainID:MainChainID, Height:ConfirmedHeight)), the proof target is the main chain block hash at ConfirmedHeight
  5. Proofs.Proof(CCCProofs.ExistenceHash())==AbsenceHeaderHash, that is the proof required.

func (*CancelCashCheckRequest) String

func (c *CancelCashCheckRequest) String() string

func (*CancelCashCheckRequest) Verify

func (c *CancelCashCheckRequest) Verify(existence bool) (hashOfCheck []byte, hashOfTrie []byte, hashOfProof []byte, err error)

type CashCheck

type CashCheck struct {
	ParentChain  common.ChainID `json:"ParentChain"`  // parent of source chain
	IsShard      bool           `json:"IsShard"`      // whether the source chain is a sharding chain
	FromChain    common.ChainID `json:"FromChain"`    // id of source chain
	FromAddress  common.Address `json:"FromAddr"`     // address of source account
	Nonce        uint64         `json:"Nonce"`        // nonce of the tx to write the CashCheck
	ToChain      common.ChainID `json:"ToChain"`      // target chain id
	ToAddress    common.Address `json:"ToAddr"`       // address of the target account
	ExpireHeight common.Height  `json:"ExpireHeight"` // The expired height refers to that when the height of the target chain exceeds (excluding) this value, the check cannot be withdrawn and can only be returned
	UserLocal    bool           `json:"UseLocal"`     // true: local currency, false: basic currency, default is false
	Amount       *big.Int       `json:"Amount"`       // amount of the check
	CurrencyID   common.CoinID  `json:"CoinID"`       // Currency ID, new field, 0 when uselocal==false, currency ID when =true, and 0 for old version data
}

Verifiable Cash Check, for cross chain transfer In order to avoid synchronous recovery of ChainInfos in main chain when recovering data, the chain information is input by the user, and it is enough to check whether the local data is legal when executing (because even if the main chain data is not synchronized, the local chain information can still be known). If the input error can be retrieved through cancel

func (*CashCheck) Deserialization

func (c *CashCheck) Deserialization(r io.Reader) (shouldBeNil bool, err error)

func (*CashCheck) Equal

func (c *CashCheck) Equal(o *CashCheck) bool

func (*CashCheck) Serialization

func (c *CashCheck) Serialization(w io.Writer) error

4 bytes FromChain + 20 bytes FromAddress + 8 bytes Nonce + 4 bytes ToChain + 20 bytes ToAddress + 8 bytes ExpireHeight + 1 byte len(Amount.Bytes()) + Amount.Bytes() all BigEndian

func (*CashCheck) String

func (c *CashCheck) String() string

type CashRequest

type CashRequest struct {
	Check           *CashCheck      `json:"check"`  // check information to be cashed
	ProofedChainID  common.ChainID  `json:"chain"`  // the target chain of the proof (main chain)
	ProofHeight     common.Height   `json:"height"` // proof from check hash to block.hash of source chain, and then to main chain block.hash. this is the corresponding main chain block height
	ProofHeaderHash common.Hash     `json:"header"` // block hash which height is specified by ProofHeight
	Proofs          trie.ProofChain `json:"proofs"` // proof of check
}

Check cashing request object is generated by RPC interface and submitted to the target chain through TX. the whole transmission process uses the serialization of this object

func (*CashRequest) Verify

func (r *CashRequest) Verify() (hashOfCheck []byte, err error)

type ChainContext

type ChainContext interface {

	// GetHeader returns the hash corresponding to their hash.
	GetHeader(common.Hash, uint64) *BlockHeader
}

type ChainCurrencier

type ChainCurrencier interface {
	GlobalCurrencier
	// Whether there is a local currency, if so, the last one method will return the local currency
	// information. Otherwise, the latter one method return basic currency information
	HasLocalCurrency() bool
	// Return (local currency ID, local currency name), when the local currency ID==0, it is the
	// basic currency
	GetLocalCurrency() (common.CoinID, string)
	// Get the list of administrator public keys of the current chain. If there is a valid value,
	// the second return value will return true, otherwise it will return false
	GetAdmins() ([][]byte, bool)
	// Whether the current chain is a PoC (Proof of Capacity) chain
	IsPoc() bool
}

Used to determine whether there is a local currency in the current chain, and if so, what is the type of the local currency

type ChainCurrencierAdapter

type ChainCurrencierAdapter struct {
	GlobalCurrencier
	CID common.ChainID
}

func NewChainCurrencier

func NewChainCurrencier(global GlobalCurrencier, chainid common.ChainID) ChainCurrencierAdapter

func (ChainCurrencierAdapter) GetAdmins

func (a ChainCurrencierAdapter) GetAdmins() ([][]byte, bool)

func (ChainCurrencierAdapter) GetLocalCurrency

func (a ChainCurrencierAdapter) GetLocalCurrency() (common.CoinID, string)

func (ChainCurrencierAdapter) HasLocalCurrency

func (a ChainCurrencierAdapter) HasLocalCurrency() bool

func (ChainCurrencierAdapter) IsPoc

func (a ChainCurrencierAdapter) IsPoc() bool

type ChainElectResult

type ChainElectResult struct {
	ChainID common.ChainID  // Election chain
	Epoch   common.EpochNum // The Epoch where the election took place, the value of the pre-election is NilEpoch
	Results NodeResults
}

The compound data structure packed in the block, the memory and the form of the data set in the block

func (*ChainElectResult) HashValue

func (c *ChainElectResult) HashValue() ([]byte, error)

func (*ChainElectResult) ResultLen

func (c *ChainElectResult) ResultLen() int

func (*ChainElectResult) String

func (c *ChainElectResult) String() string

func (*ChainElectResult) Success

func (c *ChainElectResult) Success() bool

func (*ChainElectResult) ToCommittee

func (c *ChainElectResult) ToCommittee() *Committee

type ChainElectResults

type ChainElectResults []*ChainElectResult

func (ChainElectResults) HashValue

func (cs ChainElectResults) HashValue() ([]byte, error)

func (ChainElectResults) HavePreelects

func (cs ChainElectResults) HavePreelects() bool

Whether there is a pre-election result

func (ChainElectResults) Len

func (cs ChainElectResults) Len() int

func (ChainElectResults) Less

func (cs ChainElectResults) Less(i, j int) bool

func (ChainElectResults) Swap

func (cs ChainElectResults) Swap(i, j int)

func (ChainElectResults) ToMap

func (cs ChainElectResults) ToMap() map[common.ChainID]*ChainElectResult

type ChainEpochCommittee

type ChainEpochCommittee struct {
	ChainID common.ChainID
	Epoch   common.EpochNum
	Comm    *EpochCommittee
}

func (*ChainEpochCommittee) String

func (c *ChainEpochCommittee) String() string

type ChainEvent

type ChainEvent interface {
	GetChainID() common.ChainID
}

type ChainInfoChange

type ChainInfoChange struct {
	Sender common.Address // TX.From
	Nonce  uint64         // TX.Nonce, Sender + Nonce combination should prevent replay attacks
	Data   []byte         // information to be modified
}

func (*ChainInfoChange) Deserialization

func (s *ChainInfoChange) Deserialization(r io.Reader) (shouldBeNil bool, err error)

func (*ChainInfoChange) Serialization

func (s *ChainInfoChange) Serialization(w io.Writer) error

func (*ChainInfoChange) String

func (s *ChainInfoChange) String() string

type ChainSetting

type ChainSetting struct {
	Sender common.Address // Address of sender, should same with TX.From
	Nonce  uint64         // TX.Nonce, Sender+Nonce combination should prevent replay attacks
	Name   string         // setting name to be set
	Data   []byte         // setting value to be set
}

func (*ChainSetting) Deserialization

func (s *ChainSetting) Deserialization(r io.Reader) (shouldBeNil bool, err error)

func (*ChainSetting) Serialization

func (s *ChainSetting) Serialization(w io.Writer) error

func (*ChainSetting) String

func (s *ChainSetting) String() string

type ChainSnapshot

type ChainSnapshot struct {
	Height     common.Height    // current height
	Block      *BlockEMessage   // block of current height
	Waterlines []ShardWaterline // waterlines of shards at current height
	CheckEpoch bool             // whether to check epoch matchness
}

snapshot of chain status

func (*ChainSnapshot) String

func (ss *ChainSnapshot) String() string

type ChainStats

type ChainStats struct {
	CurrentHeight      uint64          `json:"currentheight"`      // current height of the chain
	SumTxCount         uint64          `json:"txcount"`            // The number of current chain transactions after this launch
	AllTps             uint64          `json:"tps"`                // Current chain TPS after this launch
	LastEpochTps       uint64          `json:"tpsLastEpoch"`       // TPS of the previous epoch after this launch
	LastNTps           uint64          `json:"tpsLastN"`           // TPS of previous %N blocks
	Lives              uint64          `json:"lives"`              // Running time after this launch (in seconds)
	AccountCount       uint64          `json:"accountcount"`       // 0
	EpochLength        uint64          `json:"epochlength"`        // The number of blocks in one epoch
	AvgEpochDuration   uint64          `json:"epochduration"`      // Average time of an epoch (in seconds)
	LastEpochDuration  uint64          `json:"lastepochduration"`  // The time spent in the last epoch (in seconds)
	LastNDuration      uint64          `json:"lastNduration"`      // Time spent in the previous %N blocks (in seconds)
	LastEpochBlockTime uint64          `json:"lastEpochBlockTime"` // The average block time of the last epcoh (in milliseconds)
	LastNBlockTime     uint64          `json:"lastNBlockTime"`     // Average block time of previous %N blocks (in milliseconds)
	N                  uint64          `json:"N"`                  // The value of N
	GasLimit           uint64          `json:"gaslimit"`           // Current chain default GasLimit
	GasPrice           string          `json:"gasprice"`           // Current chain default GasPrice
	CurrentComm        []common.NodeID `json:"currentcomm"`        // The node list of the current committee of the chain
	Version            string          `json:"version"`            // Version of current node
}

type ChainTrie

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

func NewChainTrie

func NewChainTrie(origin *trie.Trie) *ChainTrie

func (*ChainTrie) CheckPoint

func (c *ChainTrie) CheckPoint() (checkpoint int, root []byte, err error)

func (*ChainTrie) Commit

func (c *ChainTrie) Commit() error

func (*ChainTrie) Copy

func (c *ChainTrie) Copy() *ChainTrie

func (*ChainTrie) DeleteInfo

func (c *ChainTrie) DeleteInfo(id common.ChainID) (changed bool, oldInfo *common.ChainInfos, err error)

func (*ChainTrie) GenesisNodes

func (c *ChainTrie) GenesisNodes() map[common.NodeID]common.NodeType

According to ChainTrie data, all genesis consensus nodes and genesisi data nodes are obtained to generate the genesis required reserve tree

func (*ChainTrie) GetAllChainInfos

func (c *ChainTrie) GetAllChainInfos() []*common.ChainInfos

func (*ChainTrie) GetChainChildren

func (c *ChainTrie) GetChainChildren(id common.ChainID) common.ChainIDs

func (*ChainTrie) GetChainInfos

func (c *ChainTrie) GetChainInfos(id common.ChainID) (*common.ChainInfos, bool)

func (*ChainTrie) GetChainList

func (c *ChainTrie) GetChainList() common.ChainIDs

func (*ChainTrie) GetDataNodeList

func (c *ChainTrie) GetDataNodeList(id common.ChainID) common.NodeIDs

func (*ChainTrie) GetDataNodeMap

func (c *ChainTrie) GetDataNodeMap() map[common.ChainID]map[common.NodeID]struct{}

func (*ChainTrie) GetDataNodes

func (c *ChainTrie) GetDataNodes(id common.ChainID) (datas map[common.NodeID]struct{})

func (*ChainTrie) GetGenesisDataNodeList

func (c *ChainTrie) GetGenesisDataNodeList(id common.ChainID) common.NodeIDs

func (*ChainTrie) GetLiveChainInfos

func (c *ChainTrie) GetLiveChainInfos(id common.ChainID) (*common.ChainInfos, bool)

func (*ChainTrie) GetReportChildren

func (c *ChainTrie) GetReportChildren(id common.ChainID) common.ChainIDs

func (*ChainTrie) GetShardInfo

func (c *ChainTrie) GetShardInfo(id common.ChainID) (shardInfo common.ShardInfo)

func (*ChainTrie) GetVrfChainList

func (c *ChainTrie) GetVrfChainList() common.ChainIDs

func (*ChainTrie) HashValue

func (c *ChainTrie) HashValue() ([]byte, error)

func (*ChainTrie) IsInUsing

func (c *ChainTrie) IsInUsing(nid common.NodeID) (common.ChainID, bool)

Whether the node is the data node in use. If yes, the chain ID and true are returned; otherwise, chainid is meaningless and false returned

func (*ChainTrie) IsNoGas

func (c *ChainTrie) IsNoGas(chainId common.ChainID) (bool, common.ChainID)

Whether the chain does not need pay gas feed. If true, the second value returns the chain ID with the AttrNoGas attribute

func (*ChainTrie) PreCommit

func (c *ChainTrie) PreCommit() ([]byte, error)

func (*ChainTrie) PutInfo

func (c *ChainTrie) PutInfo(info *common.ChainInfos) error

func (*ChainTrie) RangeAllInfos

func (c *ChainTrie) RangeAllInfos(oneInfosCallback func(oneInfos *common.ChainInfos))

func (*ChainTrie) RevertTo

func (c *ChainTrie) RevertTo(checkpoint int, root []byte) error

func (*ChainTrie) Rollback

func (c *ChainTrie) Rollback()

func (*ChainTrie) SetTo

func (c *ChainTrie) SetTo(newTrie *trie.Trie) error

func (*ChainTrie) String

func (c *ChainTrie) String() string

type ChangeChainInfoRequest

type ChangeChainInfoRequest struct {
	Data *ChainInfoChange
	Sigs [][]byte // signature list
	Pubs [][]byte // public key list corresponding to signature one by one
}

func (*ChangeChainInfoRequest) DataDeserialize

func (s *ChangeChainInfoRequest) DataDeserialize(vr rtl.ValueReader) error

func (*ChangeChainInfoRequest) DataSerialize

func (s *ChangeChainInfoRequest) DataSerialize(w io.Writer) error

func (*ChangeChainInfoRequest) Deserialization

func (s *ChangeChainInfoRequest) Deserialization(r io.Reader) (shouldBeNil bool, err error)

func (*ChangeChainInfoRequest) GetData

func (s *ChangeChainInfoRequest) GetData() (o interface{}, exist bool)

func (*ChangeChainInfoRequest) GetPubs

func (s *ChangeChainInfoRequest) GetPubs() [][]byte

func (*ChangeChainInfoRequest) GetSigs

func (s *ChangeChainInfoRequest) GetSigs() [][]byte

func (*ChangeChainInfoRequest) Serialization

func (s *ChangeChainInfoRequest) Serialization(w io.Writer) error

func (*ChangeChainInfoRequest) SetPubs

func (s *ChangeChainInfoRequest) SetPubs(pubs [][]byte)

func (*ChangeChainInfoRequest) SetSigs

func (s *ChangeChainInfoRequest) SetSigs(sigs [][]byte)

func (*ChangeChainInfoRequest) String

func (s *ChangeChainInfoRequest) String() string

type CodeEntry

type CodeEntry struct {
	K common.Hash
	V []byte
}

type CommEntry

type CommEntry struct {
	ChainID common.ChainID
	Comm    *Committee
}

func (CommEntry) String

func (e CommEntry) String() string

type CommReport

type CommReport struct {
	ChainId   common.ChainID
	ToChainId common.ChainID
	EpochNum  common.EpochNum
	Comm      *Committee
}

func (*CommReport) GetChainID

func (r *CommReport) GetChainID() common.ChainID

func (*CommReport) Hash

func (r *CommReport) Hash() common.Hash

type CommitCallback

type CommitCallback func(block *BlockEMessage) error

When the data block is confirmed, the callback function executed after the transaction is executed. At this time the block has been confirmed by the committee and all nodes must execute

type Committee

type Committee struct {
	Members []common.NodeID
	// contains filtered or unexported fields
}

func NewCommittee

func NewCommittee() *Committee

func (*Committee) Add

func (c *Committee) Add(id common.NodeID)

func (*Committee) Clone

func (c *Committee) Clone() *Committee

func (*Committee) CopyMembers

func (c *Committee) CopyMembers(committee *Committee)

func (*Committee) Equals

func (c *Committee) Equals(o *Committee) bool

func (*Committee) FullString

func (c *Committee) FullString() string

func (*Committee) Hash

func (c *Committee) Hash() common.Hash

func (*Committee) Index

func (c *Committee) Index(id common.NodeID) common.CommID

func (*Committee) IsAvailable

func (c *Committee) IsAvailable() bool

func (*Committee) IsIn

func (c *Committee) IsIn(id common.NodeID) bool

func (*Committee) IsProposor

func (c *Committee) IsProposor(id common.NodeID, num common.BlockNum) bool

func (*Committee) ReachRequires

func (c *Committee) ReachRequires(ok int) bool

func (*Committee) Reset

func (c *Committee) Reset()

func (*Committee) SetMembers

func (c *Committee) SetMembers(ids common.NodeIDs) *Committee

func (*Committee) Size

func (c *Committee) Size() int

func (*Committee) String

func (c *Committee) String() string

type CompatibleAccount

type CompatibleAccount struct {
	Addr        common.Address
	Nonce       uint64
	Balance     *big.Int
	StorageRoot []byte
	CodeHash    []byte
}

type CompatibleDelta

type CompatibleDelta struct {
	Addr  common.Address
	Delta *big.Int
}

for compatible with old version hash of AccountDelta TODO delete compatible when restart the chain with new version

type ConnectedCallBackFunc

type ConnectedCallBackFunc func(id common.ChainID, netType common.NetType, server P2PServer)

type Context

type Context struct {
	Op        *OpSet
	Eventer   Eventer
	ChainInfo *common.ChainInfos
	ShardInfo common.ShardInfo
	Networker Networker
	Holder    DataHolder
	Engine    Engine

	// source of message
	Source Location

	// for test adapter
	// cengine   consensus.Engine
	// mainChain *consensus.MainChain
	Dmanager DataManager
	Nmanager NetworkManager

	WorkerName string
	Logger     logrus.FieldLogger
	PAS        *PubAndSig
}

func (*Context) ClearPAS

func (ctx *Context) ClearPAS()

clear public key and signature in context

func (*Context) Clone

func (ctx *Context) Clone() *Context

func (*Context) GetPAS

func (ctx *Context) GetPAS() ([]byte, []byte)

return public key bytes slice and signature bytes slice

func (*Context) SetPAS

func (ctx *Context) SetPAS(pub, sig []byte)

set public key and signature in context

func (*Context) String

func (ctx *Context) String() string

type DataHolder

type DataHolder interface {
	// GetChainInfo() *common.ChainInfos
	// GetShardInfo returns ShardInfo only if current chain is a shard chain
	GetShardInfo() common.ShardInfo
	GetChainInfoRoot() (*common.Hash, error)
	SetGenesisHeader(header *BlockHeader) error
	GetChainInfo() (*common.ChainInfos, bool)
	// ChainList() common.ChainIDs
	GetDataNodeList() common.NodeIDs
	IsDataNode() bool // is it the data node of current chain
	IsMemoNode() bool // is it the full node of current chain
	IncCount(height common.Height, timestamp uint64, count uint64)
	// FIXME: should not reture database to other layer
	GetDb() db.Database

	// GetBlockChain get BlockChain of current Chain
	GetBlockChain() BlockChain
	GetBlock(height common.Height) (*BlockEMessage, error)
	GetBlockByHash(hashOfHeader []byte) (*BlockEMessage, error)
	GetBlockWithUnverified(height common.Height) (*BlockEMessage, error)
	SaveUnverifiedBlock(block *BlockEMessage) error
	GetBlockHash(height common.Height) (*common.Hash, bool)
	GetHeader(height common.Height) (*BlockHeader, error)
	GetHistoryRoot(expectingHeight common.Height) ([]byte, error)
	// SaveRewardRequests(block *BlockEMessage, hashOfBlock []byte) error
	PutBlock(block *BlockEMessage, appendSuccessFunc BlockAppendSuccess) error

	CreateEmptyAccountTrie() *trie.Trie
	CreateAccountTrie(rootHash []byte) *trie.Trie
	RestoreHistoryTreeFromProofs(lastHeight common.Height, lastHeightHash []byte,
		proofs trie.ProofChain) (*trie.HistoryTree, error)
	CreateHistoryTree(root []byte, checkPrecedingNil bool) (*trie.HistoryTree, error)
	CreateEmptyVccOrigin() *trie.Trie
	CreateEmptyCashedOrigin() *trie.Trie
	SyncState(height common.Height, block *BlockEMessage, states *WholeWorld, logger logrus.FieldLogger) error
	SyncChains(chains *trie.Trie) error
	SyncAccTrie(height common.Height, accStates *trie.Trie) error
	SyncBlock(block *BlockEMessage) error
	// IsSynced returns 0 if the chain is not yet synced, and returns 1 if synced
	IsSynced() bool
	SetSynced()
	IsFull() bool
	StopSyncing()
	IsEmpty() bool
	IsExpectingEpoch(epoch common.EpochNum) error
	GetCurrentHeight() common.Height
	SetCurrentHeight(height common.Height)
	SetCurrentToHeight(height common.Height, hob common.Hash) error

	GetWorldStateRoot() ([]byte, error)
	SnapshotRoots() (snapshot *ChainSnapshot, err error)
	GetWorldStateStream(snapshot *ChainSnapshot) (accStream [][]byte,
		stoStream [][]byte, codeStream [][]byte, longStream [][]byte, deltaStream [][]byte, chainsStream []byte, err error)
	GetCashCheckState(vccRoot, cashedRoot []byte) (vccs, casheds [][]byte, err error)

	// GetTransactions returns transaction trie in specific block
	GetTransactions(height common.Height) (trie.ITrie, error)
	// GetReceipts returns receipt list in specific block by its receiptsHash
	GetReceiptsByRoot(receiptHash common.Hash) Receipts

	CallProcessTx(tx *Transaction, senderSig *PubAndSig, blockHeader *BlockHeader) (interface{}, error)

	ProposeData(froms DeltaFroms, header *BlockHeader, txs []*Transaction, pas []*PubAndSig) (result *ProposeResult, err error)

	CanBeAccept(reportChainID common.ChainID, height common.Height, hob []byte) error
	PrepareBlock(block *BlockEMessage) error
	ForceCommit() (err error)

	CreateRootDeltaTrie() *AccountDeltaTrie
	// RestoreDeltaTrieFromBlock recover complete AccountDeltaTrie from block。
	RestoreDeltaTrieFromBlock(block *BlockEMessage) (*AccountDeltaTrie, error)

	SaveReceivedDelta(fromID common.ChainID, height common.Height, deltas []*AccountDelta) (
		overflow bool, waterline common.Height, overflowed []*DeltaFrom, missing bool, missingLength int, err error)
	SaveDeltasGroup(fromID common.ChainID, group DeltasGroup) (overflow bool,
		waterline common.Height, overflowed []*DeltaFrom, missing bool, missingLength int, err error)

	CheckReceivedDelta(fromID common.ChainID, height common.Height) bool

	CreateAccountDeltaTrie() trie.ITrie
	PopDeltaFroms() DeltaFroms
	PutDeltaFroms(deltaFroms DeltaFroms)
	CreateDeltaFromTrie() *AccountDeltaFromTrie
	ShouldSendDelta() (A, B common.Height, confirmed common.Height, mainBlockSummary *HeaderSummary, err error)
	SetDeltaToBeSent(height common.Height)
	VerifyDeltasPack(pack *DeltasPack) error

	// Verifiable Cash Check Trie
	AddVCC(vcc *CashCheck) (hashOfVcc []byte, err error)
	DeleteVCC(vcc *CashCheck) (ok bool, hashOfVcc []byte, err error)
	VccProof(vcc *CashCheck) (height common.Height, proofChain trie.ProofChain, hashOfHeader []byte, err error)
	AddCCC(vcc *CashCheck, txHash *common.Hash) (hashOfVcc []byte, err error)
	CCCExsitenceProof(ccc *CashCheck) (height common.Height, existence bool, existProof trie.ProofChain,
		cashedRootProof trie.ProofChain, hashOfHeader []byte, err error)
	GetCCCRelativeTx(hashOfVcc []byte) (hashOfTx []byte, err error)

	CreateVCCTrie(root []byte) *trie.Trie
	CreateCCCTrie(root []byte) *trie.Trie

	GetAccount(addr *common.Address) (*Account, bool)
	GetCodeByHash(codeHash common.Hash) []byte
	GetGasSettings() (gasPrice *big.Int, gasLimit uint64)

	SwitchEpoch()
	HasChild() bool

	// Record the committee election result comm of chainid chain in epoch num. if comm is
	// not available, prev is the last effective committee.
	// Because the parent chain needs to keep the consensus committee information of the
	// sub chain, chainId is necessary.
	PutCommittee(chainId common.ChainID, num common.EpochNum, comm *Committee, prev *Committee) error
	GetCommittee(chainId common.ChainID, num common.EpochNum) (*Committee, error)
	GetEpochComm(chainId common.ChainID, num common.EpochNum) (*EpochCommittee, error)
	SyncCommittees(currentHeight common.Height) ([]*ChainEpochCommittee, error)

	PutHeaderSummaries(bock *BlockEMessage) error
	GetHeaderSummary(chainId common.ChainID, height common.Height) (*HeaderSummary, error)

	// Interfaces used to record whether messages have been processed
	Process(hash common.Hash) bool
	Processed(hash common.Hash) bool
	RemoveProcessed(hash common.Hash)
	ClearProcessed()

	AppendHistory(height common.Height, hash []byte) (newRoot []byte, err error)
	SetSyncFinish(height common.Height)
	GetSyncFinish() common.Height
	SetCursorManually(to common.Height) error
	GetStateDB() StateDB

	GetConsistantLong(addr common.Address, key common.Hash) []byte
	SetLongState(addr common.Address, key common.Hash, value []byte)

	// interfaces for chain management
	MCHAddBootNode(id common.ChainID, bootNode common.Dataserver) (errr error)
	MCHRemoveBootNode(id common.ChainID, nodeId common.NodeID) error
	MCHAddDataNode(id common.ChainID, nodeId common.NodeID) error
	MCHRemoveDataNode(id common.ChainID, nodeId common.NodeID) error
	MCHAddAdmin(id common.ChainID, adminPub []byte) error
	MCHDelAdmin(id common.ChainID, adminPub []byte) error
	MCHAttributes(id common.ChainID, isSet bool, attrs ...common.ChainAttr) error

	// interfaces for election
	GetPreElecting(id common.ChainID) *PreElecting
	PutPreElectResult(resulter ElectResulter)
	ProposePreElecting(height common.Height) (PreElectings, ChainElectResults)
	SetPreelectExamineResult(chainId common.ChainID, success bool) error
	SyncPreElection(electings PreElectings)
	MergeProof(key uint64, value []byte, proofs trie.ProofChain) error

	// interface for check nodes
	CacheAliveDataNode(id common.NodeID, height common.Height)
	LoadAliveDataNodes() common.NodeIDs
	ClearAliveDataNodes(height common.Height)
}

type DataManager

type DataManager interface {
	common.Service
	Eventer() Eventer
	SetChainStructs(chains *config.Config)
	InitOneChain(chainid common.ChainID) error
	CreateGenesisData(chainId common.ChainID) error
	CreateChainInfosOrigin(rootHash []byte) *trie.Trie
	GetChainInfos(id common.ChainID) (*common.ChainInfos, bool)
	IsInUsingDataNode(dataNodeId common.NodeID) (common.ChainID, bool)
	IsNoGasChain(chainId common.ChainID) (bool, common.ChainID)
	GetChainStats(id common.ChainID) (*ChainStats, error)
	DataNodeOf() common.ChainID
	IsDataNode() bool
	IsMemoNode() bool
	// Deprecated
	IsDataMemoNode() bool
	GetShardInfo(chainid common.ChainID) common.ShardInfo
	IsDataNodeOf(id common.ChainID) bool
	IsShard(id common.ChainID) bool
	HasAttribute(id common.ChainID, attr common.ChainAttr) bool
	IsLeaf(id common.ChainID) bool
	GetChainChildren(chainid common.ChainID) common.ChainIDs
	GetChainChildrenAndSelfInfos(chainid common.ChainID) []*common.ChainInfos
	GetDataNodes(id common.ChainID) map[common.NodeID]struct{}
	GetGenesisDataNodeList(id common.ChainID) common.NodeIDs
	GetDataNodeList(id common.ChainID) common.NodeIDs
	GetDataNodeIDs(chainId common.ChainID) common.NodeIDs // Return if there is a list of Genesis data nodes, otherwise return to the list of data nodes
	GetChainList() common.ChainIDs
	GetVrfChainList() common.ChainIDs
	GetAllChainInfos() []*common.ChainInfos
	GetGenesisNodes() map[common.NodeID]common.NodeType
	CreateTestAccount(chainid common.ChainID, addr common.Address, balance *big.Int, local *big.Int) error
	ForceCommit(chainid common.ChainID) error
	// GetAccount(addr *common.Address, chainID common.ChainID) (Account, bool)
	GetChainData(chainid common.ChainID) (DataHolder, error)
	GetMainChainLong(addr common.Address, key common.Hash) []byte
	GetChainLong(chainid common.ChainID, addr common.Address, key common.Hash) []byte
	RemoveChain(chainid common.ChainID)
	GetHeaderSummaries(chainid common.ChainID, height common.Height) ([]*HeaderSummary, error)

	SetCursorManually(to common.Height) error

	ReadOnly() DataManager
	GetStartNodes() common.NodeIDs
	AddStartNode(id common.NodeID)
	StartNodesSize() int
	AddLastComm(lastComm *LastCommEMessage) error
	ToStartComm(chainIds common.ChainIDs) (*StartCommEMessage, error)
	// cache seed
	SetSeed(epoch common.EpochNum, newseed *common.Seed) bool
	GetSeed() *common.Seed
	LastSeedUpdatedAt() common.EpochNum
	SaveCommitteeAt(at common.ChainID, commChain common.ChainID,
		epoch common.EpochNum, comm, prev *Committee) error
	GetCommitteeAt(at common.ChainID, commChain common.ChainID, epoch common.EpochNum) (*EpochCommittee, error)
}

func NewDManager

func NewDManager(dataPlugin *plugin.Plugin, path string, eventer Eventer) (DataManager, error)

type DataRequester

type DataRequester interface {
	DataSerialize(w io.Writer) error
	DataDeserialize(vr rtl.ValueReader) error
	GetData() (o interface{}, exist bool)
	GetSigs() [][]byte
	SetSigs(sigs [][]byte)
	GetPubs() [][]byte
	SetPubs(pubs [][]byte)
}

type DeltaFrom

type DeltaFrom struct {
	Key    DeltaFromKey
	Deltas []*AccountDelta
}

func (DeltaFrom) String

func (d DeltaFrom) String() string

type DeltaFromKey

type DeltaFromKey struct {
	ShardID common.ChainID
	Height  common.Height
}

func BytesToDeltaFromKey

func BytesToDeltaFromKey(bytes []byte) DeltaFromKey

func (DeltaFromKey) Bytes

func (d DeltaFromKey) Bytes() []byte

func (DeltaFromKey) Cmp

func (d DeltaFromKey) Cmp(to DeltaFromKey) int

func (DeltaFromKey) String

func (d DeltaFromKey) String() string

type DeltaFroms

type DeltaFroms []DeltaFrom

func (DeltaFroms) Len

func (f DeltaFroms) Len() int

func (DeltaFroms) Less

func (f DeltaFroms) Less(i, j int) bool

func (DeltaFroms) Summary

func (f DeltaFroms) Summary() string

func (DeltaFroms) Swap

func (f DeltaFroms) Swap(i, j int)

type DeltaRequestMessage

type DeltaRequestMessage struct {
	FromID common.ChainID // source chain of requested delta
	ToID   common.ChainID // target chain of requested delta
	Start  common.Height  // The starting height of the source chain where the requested delta is located
	Length int            // The number of delta requested, starting from start (including start)
}

func (*DeltaRequestMessage) A

func (m *DeltaRequestMessage) A() common.Height

func (*DeltaRequestMessage) B

func (m *DeltaRequestMessage) B() common.Height

func (*DeltaRequestMessage) DestChainID

func (m *DeltaRequestMessage) DestChainID() common.ChainID

func (*DeltaRequestMessage) GetChainID

func (m *DeltaRequestMessage) GetChainID() common.ChainID

func (*DeltaRequestMessage) String

func (m *DeltaRequestMessage) String() string

type DeltasGroup

type DeltasGroup []*OneDeltas

Pack deltas generated by multiple blocks together. It is sent to the target chain at one time. Proof chain:root of the trie generated with deltas in block A (1)-> A.BalanceDeltaRoot (2)-> A.BlockHeader.Hash

(3)-> current block B.HashHistory (4)-> B.BlockHeader.Hash
(5)-> (block C in main chain which confirmed block B).HdsRoot (6)-> C.BlockHeader.Hash

func (DeltasGroup) Len

func (g DeltasGroup) Len() int

func (DeltasGroup) Less

func (g DeltasGroup) Less(i, j int) bool

func (DeltasGroup) Summary

func (g DeltasGroup) Summary() string

func (DeltasGroup) Swap

func (g DeltasGroup) Swap(i, j int)

type DeltasPack

type DeltasPack struct {
	FromID        common.ChainID  // source chain id
	ToChainID     common.ChainID  // target shard id
	ProofedHeight common.Height   // block B of source shard was confirmed by the main chain
	ProofToMain   trie.ProofChain // proof from B.Hash to C.Hash
	MainHeight    common.Height   // the height of main chain block C which packed and confirmed block B
	Pack          DeltasGroup     // deltas of each block from source chain
}

ProofToMain.Proof(BlockHash of ProofedHeight) == BlockHash of MainHeight (5)(6)

func (*DeltasPack) DestChainID

func (d *DeltasPack) DestChainID() common.ChainID

func (*DeltasPack) GetChainID

func (d *DeltasPack) GetChainID() common.ChainID

func (*DeltasPack) String

func (d *DeltasPack) String() string

type DirectiveMsg

type DirectiveMsg interface {
	DestChainID() common.ChainID
}

type DummyCurrencier

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

func GetDummyCurrencier

func GetDummyCurrencier() *DummyCurrencier

func (*DummyCurrencier) GetAdminPrivs

func (d *DummyCurrencier) GetAdminPrivs() ([][]byte, bool)

func (*DummyCurrencier) GetAdmins

func (d *DummyCurrencier) GetAdmins() ([][]byte, bool)

func (*DummyCurrencier) GetChainAdminPrivs

func (d *DummyCurrencier) GetChainAdminPrivs(id common.ChainID) ([][]byte, bool)

func (*DummyCurrencier) GetChainAdmins

func (d *DummyCurrencier) GetChainAdmins(id common.ChainID) ([][]byte, bool)

func (*DummyCurrencier) GetChainLocalCurrencyInfo

func (d *DummyCurrencier) GetChainLocalCurrencyInfo(id common.ChainID) (common.CoinID, string)

func (*DummyCurrencier) GetCurrencyAdmins

func (d *DummyCurrencier) GetCurrencyAdmins() (privs, pubs [][]byte)

func (*DummyCurrencier) GetLocalCurrency

func (d *DummyCurrencier) GetLocalCurrency() (common.CoinID, string)

func (*DummyCurrencier) HasLocalCurrency

func (d *DummyCurrencier) HasLocalCurrency() bool

func (*DummyCurrencier) IsPoc

func (d *DummyCurrencier) IsPoc() bool

func (*DummyCurrencier) IsPocChain

func (d *DummyCurrencier) IsPocChain(chainid common.ChainID) bool

type DynamicFeeTx

type DynamicFeeTx struct {
	ChainID    *big.Int
	Nonce      uint64
	GasTipCap  *big.Int
	GasFeeCap  *big.Int
	Gas        uint64
	To         *common.Address `rlp:"nil"` // nil means contract creation
	Value      *big.Int
	Data       []byte
	AccessList AccessList

	// Signature values
	V *big.Int `json:"v" gencodec:"required"`
	R *big.Int `json:"r" gencodec:"required"`
	S *big.Int `json:"s" gencodec:"required"`
}

func (*DynamicFeeTx) TxType

func (tx *DynamicFeeTx) TxType() byte

TxType accessors for innerTx.

type EIP155Signer

type EIP155Signer struct {
}

EIP155Signer implements Signer using the EIP-155 rules. This accepts transactions which are replay-protected as well as unprotected homestead transactions.

func NewEIP155Signer

func NewEIP155Signer() EIP155Signer

func NewEIP155Signer(chainId *big.Int) EIP155Signer {

func (EIP155Signer) Equal

func (s EIP155Signer) Equal(s2 Signer) bool

func (EIP155Signer) Hash

func (s EIP155Signer) Hash(tx *ETHTransaction) common.Hash

Hash returns the hash to be signed by the sender. It does not uniquely identify the transaction.

func (EIP155Signer) HashGtkm

func (s EIP155Signer) HashGtkm(tx *Transaction) common.Hash

HashGtkm returns the hash to be signed by the sender. It does not uniquely identify the transaction.

func (EIP155Signer) HashGtkmWithSig

func (s EIP155Signer) HashGtkmWithSig(tx *Transaction) common.Hash

HashGtkmWithSig returns the hash to be signed by the sender. It does not uniquely identify the transaction.

func (EIP155Signer) RecoverSigAndPub

func (s EIP155Signer) RecoverSigAndPub(tx *ETHTransaction) (sig, pub []byte, err error)

func (EIP155Signer) Sender

func (s EIP155Signer) Sender(tx *ETHTransaction) (common.Address, error)

func (EIP155Signer) SignatureValues

func (s EIP155Signer) SignatureValues(tx *ETHTransaction, sig []byte) (R, S, V *big.Int, err error)

SignatureValues returns signature values. This signature needs to be in the [R || S || V] format where V is 0 or 1.

type ETHTransaction

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

ETHTransaction is an Ethereum transaction.

func NewContractCreation

func NewContractCreation(nonce uint64, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte) *ETHTransaction

NewContractCreation creates an unsigned legacy transaction. Deprecated: use NewTx instead.

func NewTransaction

func NewTransaction(nonce uint64, to common.Address, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte) *ETHTransaction

NewTransaction creates an unsigned legacy transaction. Deprecated: use NewTx instead.

func NewTx

func NewTx(inner TxData) *ETHTransaction

NewTx creates a new transaction.

func (*ETHTransaction) AccessList

func (tx *ETHTransaction) AccessList() AccessList

AccessList returns the access list of the transaction.

func (*ETHTransaction) ChainId

func (tx *ETHTransaction) ChainId() *big.Int

ChainId returns the EIP155 chain ID of the transaction. The return value will always be non-nil. For legacy transactions which are not replay-protected, the return value is zero.

func (*ETHTransaction) Data

func (tx *ETHTransaction) Data() []byte

Data returns the input data of the transaction.

func (*ETHTransaction) From

func (tx *ETHTransaction) From() *common.Address

func (*ETHTransaction) Gas

func (tx *ETHTransaction) Gas() uint64

Gas returns the gas limit of the transaction.

func (*ETHTransaction) GasFeeCap

func (tx *ETHTransaction) GasFeeCap() *big.Int

GasFeeCap returns the fee cap per gas of the transaction.

func (*ETHTransaction) GasPrice

func (tx *ETHTransaction) GasPrice() *big.Int

GasPrice returns the gas price of the transaction.

func (*ETHTransaction) GasTipCap

func (tx *ETHTransaction) GasTipCap() *big.Int

GasTipCap returns the gasTipCap per gas of the transaction.

func (*ETHTransaction) GetSigner

func (tx *ETHTransaction) GetSigner() Signer

func (*ETHTransaction) Hash

func (tx *ETHTransaction) Hash() common.Hash

func (*ETHTransaction) HashValue

func (tx *ETHTransaction) HashValue() ([]byte, error)

func (*ETHTransaction) MarshalBinary

func (tx *ETHTransaction) MarshalBinary() ([]byte, error)

func (*ETHTransaction) Nonce

func (tx *ETHTransaction) Nonce() uint64

Nonce returns the sender account nonce of the transaction.

func (*ETHTransaction) Protected

func (tx *ETHTransaction) Protected() bool

Protected says whether the transaction is replay-protected.

func (*ETHTransaction) RawSignatureValues

func (tx *ETHTransaction) RawSignatureValues() (v, r, s *big.Int)

func (*ETHTransaction) SigAndPub

func (tx *ETHTransaction) SigAndPub()

func (*ETHTransaction) To

func (tx *ETHTransaction) To() *common.Address

To returns the recipient address of the transaction. For contract-creation transactions, To returns nil.

func (*ETHTransaction) ToTransaction

func (tx *ETHTransaction) ToTransaction() (*Transaction, error)

func (*ETHTransaction) Type

func (tx *ETHTransaction) Type() uint8

Type returns the transaction type.

func (*ETHTransaction) UnmarshalBinary

func (tx *ETHTransaction) UnmarshalBinary(b []byte) error

func (*ETHTransaction) Value

func (tx *ETHTransaction) Value() *big.Int

Value returns the ether amount of the transaction.

type ElectCallback

type ElectCallback func(keepComm bool, oldcomm *Committee, newcomm *Committee)

type ElectMessage

type ElectMessage struct {
	// EpochNum is the current epoch number
	// I.e., the elected committee is for epoch EpochNum+1
	EpochNum     common.EpochNum `json:"epoch"` // 选举时所在epoch
	ElectChainID common.ChainID  `json:"chainid"`
}

func (*ElectMessage) GetChainID

func (p *ElectMessage) GetChainID() common.ChainID

func (*ElectMessage) Hash

func (p *ElectMessage) Hash() common.Hash

func (*ElectMessage) String

func (p *ElectMessage) String() string

type ElectResult

type ElectResult struct {
	NodeID   common.NodeID   // Node ID participating in the election
	ChainID  common.ChainID  // Election chain
	Epoch    common.EpochNum // Epoch of the election
	Sorthash *common.Hash    // The result of the VRF algorithm
	Proof    []byte          // Proof of VRF algorithm results
}

Election results in a unified format, used when transmitting separately In order to be compatible with VRFResultEMessage, the format is compatible

func (*ElectResult) FromResulter

func (r *ElectResult) FromResulter(resulter ElectResulter) *ElectResult

func (*ElectResult) GetChainID

func (r *ElectResult) GetChainID() common.ChainID

func (*ElectResult) GetElectingChainID

func (r *ElectResult) GetElectingChainID() common.ChainID

func (*ElectResult) GetEpochNum

func (r *ElectResult) GetEpochNum() common.EpochNum

func (*ElectResult) GetNodeID

func (r *ElectResult) GetNodeID() common.NodeID

func (*ElectResult) GetVrfResult

func (r *ElectResult) GetVrfResult() (*common.Hash, []byte, *common.Hash)

func (*ElectResult) IsPreElecting

func (r *ElectResult) IsPreElecting() bool

func (*ElectResult) String

func (r *ElectResult) String() string

func (*ElectResult) VrfVerify

func (r *ElectResult) VrfVerify(seed common.Seed) error

type ElectResulter

type ElectResulter interface {
	// The chain ID where the election occurs should be distinguished from the GetChainID()
	// method of the ChainEvent interface
	GetElectingChainID() common.ChainID
	// The Epoch where the election took place, the value of the pre-election is NilEpoch
	GetEpochNum() common.EpochNum
	VrfResulter
}

Election result interface

type ElectResults

type ElectResults []*ElectResult

func (ElectResults) HashValue

func (rs ElectResults) HashValue() ([]byte, error)

func (ElectResults) Len

func (rs ElectResults) Len() int

func (ElectResults) Less

func (rs ElectResults) Less(i, j int) bool

sorted by (ChainID, EpochNum, Sorthash, NodeID)

func (ElectResults) Swap

func (rs ElectResults) Swap(i, j int)

func (ElectResults) ToPreElectMap

func (rs ElectResults) ToPreElectMap() map[common.ChainID]map[common.NodeID]*ElectResult

type Elector

type Elector interface {
	// Returns whether the election of current chain is dynamic. False means that dynamic election is not needed
	IsDynamic() bool
	// Is the current node a legal candidate
	IsCandidate() bool
	// // Has the next election been completed
	// HasNextCommittee() bool
	// Filter for receiving block data
	BlockReceived(ctx *Context, block *BlockEMessage)
	// Filter for generating block data
	BlockGenerated(block *BlockEMessage) error
	// Set callback function after successful election
	RegisterElectedCallback(callback ElectCallback)
	// Election message processing
	Electioneer(ctx *Context, msg interface{}) error
	// Switch epoch, return whether switched to a new epoch with new committee
	SwitchEpoch(oldEpoch common.EpochNum) (keepComm bool)
	// Electing according to electMsg
	ElectToChain(ctx *Context, electMsg interface{}) error
	// Preelect according to electMsg
	PreElectToChain(ctx *Context, electMsg interface{}) error
	// Is the current node elected as the member of committee which specified by epoch number: epoch
	Chosen(ctx *Context, epoch common.EpochNum) bool
	// reset current elector
	Reset()
	// Returns committee of next epoch, return nil when the current election is not completed
	NextComm() *Committee
}

type Engine

type Engine interface {
	common.Service
	ChainComm(ChainID common.ChainID) (*Committee, error)
	ChainNextComm(ChainID common.ChainID) (*Committee, error)
	StartConsensus()
	CreateSubChain(chainID common.ChainID)
	InitSubChain(chainID common.ChainID) bool // If the creation is successful, true is returned, and false is returned from the existing subchains
	RemoveSubChain(chainID common.ChainID)
	SetChainComm(cid common.ChainID, nids *Committee) error
}

func NewConsensusEngine

func NewConsensusEngine(enginePlug *plugin.Plugin, eventer Eventer, nmanager NetworkManager,
	dmanager DataManager, conf *config.Config) Engine

type EntryHashHash

type EntryHashHash struct {
	K common.Hash
	V common.Hash
}

type EpochCommittee

type EpochCommittee struct {
	Result *Committee // actual election results
	Real   *Committee // the final result, if Result.IsAvailable()==false, then Real is the actual Committee. Otherwise, it is nil
}

func NewEpochComm

func NewEpochComm(result *Committee, current *Committee) *EpochCommittee

func (*EpochCommittee) Clone

func (c *EpochCommittee) Clone() *EpochCommittee

func (*EpochCommittee) Comm

func (c *EpochCommittee) Comm() *Committee

func (*EpochCommittee) Hash

func (c *EpochCommittee) Hash() common.Hash

func (*EpochCommittee) IsAvailable

func (c *EpochCommittee) IsAvailable() bool

func (*EpochCommittee) IsEmpty

func (c *EpochCommittee) IsEmpty() bool

func (*EpochCommittee) String

func (c *EpochCommittee) String() string

type Equaler

type Equaler interface {
	Equals(interface{}) bool
}

type EventType

type EventType uint16
const (
	// basic event types, the number of these types should not exceed 255, otherwise it will
	// confilict with consensus event
	TextEvent EventType = 0x0000 + iota
	ToOneEvent
	JustHashEvent
	WantDetailEvent
	TxEvent
	ReportBlockEvent
	ReportCommEvent
	BlockEvent
	StartEvent
	LastBlockEvent
	LastReportEvent
	SyncRequestEvent
	NeedCommitteeEvent
	RelayEvent
	StopEvent
	ShardDeltaEvent
	DeltaRequestEvent
	LastHeightEvent
	BlockRequestEvent
	SyncFinishEvent
	HistoryBlockEvent
	RewardRequestEvent
	RRProofsRequestEvent
	RRProofsMessageEvent
	ReportNodeInfoEvent
	LastCommEvent
	StartCommEvent
	StartConsEvent
	PreelectionStartEvent
	PreelectionConnectEvent
	PreelectionSyncEvent
	PreelectionExamineEvent
	PreelectionExitEvent
	MissingChainEvent
	SevereErrEvent
	DeltasPackEvent
	NodeStateEvent

	UNSETEVENT EventType = 0xFFFF // This is the last EventType, ADD A NEW EventType BEFORE THIS PLEASE.
)

func FindEventTypeByObjectType

func FindEventTypeByObjectType(typ reflect.Type) (t EventType, ok bool)

func ListRegisteredEvents

func ListRegisteredEvents() []EventType

func MarshalEvent

func MarshalEvent(m interface{}) (EventType, []byte, error)

func ToEventType

func ToEventType(b []byte) EventType

func (EventType) Bytes

func (t EventType) Bytes() (b []byte)

func (EventType) IsControl

func (t EventType) IsControl() bool

func (EventType) String

func (t EventType) String() string

type Eventer

type Eventer interface {
	common.Service
	PrintCounts()
	SetEngine(engine Engine)
	SetDataManager(manager DataManager)
	SetNetworkManager(manager NetworkManager)
	Shutdown()
	HasChainOpType(chainid common.ChainID, opType OperatorType) bool
	GetChainOpTypes(chainid common.ChainID) []OperatorType
	GetNodeOpTypes() map[common.ChainID][]string
	AddChainOpType(id common.ChainID, opType OperatorType)
	AppendChainOpType(id common.ChainID, opType OperatorType)
	RemoveChainOpType(id common.ChainID, opType OperatorType)
	ReplaceChainOpTypes(id common.ChainID, fromType OperatorType, toType OperatorType) bool
	ClearChainOpType(chainid common.ChainID)
	ResetToFailureOpType(chainid common.ChainID)
	RebuildContext(ctx *Context, newChainID common.ChainID) *Context
	SetEventThreshold(chainId common.ChainID, threshold interface{})
	PostMain(RawData)
	SyncPost(event interface{})
	Post(interface{})
	PostEvent(event interface{}, pub, sig []byte) error
	ExitChain(id common.ChainID) // exit from chain
	// check access permission
	CheckPermission(chainId common.ChainID, nodeId common.NodeID, netType common.NetType, proof []byte) error
}

func NewEventer

func NewEventer(eventerPlug *plugin.Plugin, queueSize, barrelSize, workerSize int, shutingdownFunc func(), isInComm IsInCommitteeFunc) Eventer

type ExchangerAdminData

type ExchangerAdminData struct {
	Sender       common.Address // Address of sender, should same with TX.From
	Nonce        uint64         // TX.Nonce, Sender+Nonce combination should prevent replay attacks
	NewRate      *big.Rat       // New consideration base currency: second currency
	NewNeedSigns int16          // During management operations, the number of valid signatures needs to be verified. <0 means no modification
	NewAdminPubs [][]byte       // The public key list of the administrator account, len(NewAdminPubs)==0 means no modification. Either don't change it, or change it all.
}

func (*ExchangerAdminData) Deserialization

func (c *ExchangerAdminData) Deserialization(r io.Reader) (shouldBeNil bool, err error)

func (*ExchangerAdminData) Serialization

func (c *ExchangerAdminData) Serialization(w io.Writer) error

func (*ExchangerAdminData) String

func (c *ExchangerAdminData) String() string

type ExchangerAdminRequest

type ExchangerAdminRequest struct {
	Data *ExchangerAdminData // The content of this management request
	SigsAndPubs
}

func (*ExchangerAdminRequest) DataDeserialize

func (c *ExchangerAdminRequest) DataDeserialize(vr rtl.ValueReader) error

func (*ExchangerAdminRequest) DataSerialize

func (c *ExchangerAdminRequest) DataSerialize(w io.Writer) error

func (*ExchangerAdminRequest) Deserialization

func (c *ExchangerAdminRequest) Deserialization(r io.Reader) (shouldBeNil bool, err error)

func (*ExchangerAdminRequest) GetData

func (c *ExchangerAdminRequest) GetData() (o interface{}, exist bool)

func (*ExchangerAdminRequest) Serialization

func (c *ExchangerAdminRequest) Serialization(w io.Writer) error

func (*ExchangerAdminRequest) String

func (c *ExchangerAdminRequest) String() string

type ExchangerWithdrawData

type ExchangerWithdrawData struct {
	RequestAddr common.Address // sender address
	Nonce       uint64         // nonce of the system contract
	WithdrawTo  common.Address // account address to receive the value
	UseLocal    bool           // true for local-currency, false for basic currency
	Value       *big.Int       // amount to withdraw
}

func (*ExchangerWithdrawData) Deserialization

func (d *ExchangerWithdrawData) Deserialization(r io.Reader) (shouldBeNil bool, err error)

func (*ExchangerWithdrawData) Serialization

func (d *ExchangerWithdrawData) Serialization(w io.Writer) error

func (*ExchangerWithdrawData) String

func (d *ExchangerWithdrawData) String() string

type ExchangerWithdrawRequest

type ExchangerWithdrawRequest struct {
	Data *ExchangerWithdrawData // The current withdraw data content
	SigsAndPubs
}

func (*ExchangerWithdrawRequest) DataDeserialize

func (c *ExchangerWithdrawRequest) DataDeserialize(vr rtl.ValueReader) error

func (*ExchangerWithdrawRequest) DataSerialize

func (c *ExchangerWithdrawRequest) DataSerialize(w io.Writer) error

func (*ExchangerWithdrawRequest) Deserialization

func (c *ExchangerWithdrawRequest) Deserialization(r io.Reader) (shouldBeNil bool, err error)

func (*ExchangerWithdrawRequest) GetData

func (c *ExchangerWithdrawRequest) GetData() (o interface{}, exist bool)

func (*ExchangerWithdrawRequest) Serialization

func (c *ExchangerWithdrawRequest) Serialization(w io.Writer) error

func (*ExchangerWithdrawRequest) String

func (c *ExchangerWithdrawRequest) String() string

type Extra

type Extra struct {
	Type       byte     `json:"type"`
	Gas        uint64   `json:"gas"`
	GasPrice   *big.Int `json:"gasPrice"` // wei per gas
	GasTipCap  *big.Int
	GasFeeCap  *big.Int
	AccessList AccessList
	V, R, S    *big.Int
	TkmExtra   []byte
}

func (*Extra) SetTkmExtra

func (x *Extra) SetTkmExtra(extra []byte) error

func (*Extra) String

func (x *Extra) String() string

type FrontierSigner

type FrontierSigner struct{}

func (FrontierSigner) ChainID

func (f FrontierSigner) ChainID() *big.Int

func (FrontierSigner) Equal

func (f FrontierSigner) Equal(s2 Signer) bool

func (FrontierSigner) Hash

func (f FrontierSigner) Hash(tx *ETHTransaction) common.Hash

Hash returns the hash to be signed by the sender. It does not uniquely identify the transaction.

func (FrontierSigner) HashGtkm

func (f FrontierSigner) HashGtkm(tx *Transaction) common.Hash

HashGtkm returns the hash to be signed by the sender. It does not uniquely identify the transaction.

func (FrontierSigner) HashGtkmWithSig

func (f FrontierSigner) HashGtkmWithSig(tx *Transaction) common.Hash

HashGtkm returns the hash to be signed by the sender. It does not uniquely identify the transaction.

func (FrontierSigner) RecoverSig

func (f FrontierSigner) RecoverSig(tx *ETHTransaction) (sig []byte)

func (FrontierSigner) RecoverSigAndPub

func (f FrontierSigner) RecoverSigAndPub(tx *ETHTransaction) (sig, pub []byte, err error)

func (FrontierSigner) Sender

func (f FrontierSigner) Sender(tx *ETHTransaction) (common.Address, error)

func (FrontierSigner) SignatureValues

func (f FrontierSigner) SignatureValues(tx *ETHTransaction, sig []byte) (r, s, v *big.Int, err error)

SignatureValues returns signature values. This signature needs to be in the [R || S || V] format where V is 0 or 1.

type GenerateCallback

type GenerateCallback func(header *BlockHeader, result *ProposeResult) error

When the data block is generated, after the transaction is executed, the callback function executed before the stateRoot is generated header: generating block header result: proposing data

type GlobalCurrencier

type GlobalCurrencier interface {
	// Query the chain currency by chain ID, and return (local currency ID, local currency name),
	// when the local currency ID==0, it is the basic currency, when there is no local currency,
	// CoinID returns 0
	GetChainLocalCurrencyInfo(chainID common.ChainID) (common.CoinID, string)
	// Get the list of administrator public keys of the specific chain. If there is a valid value,
	// the second return value will return true, otherwise it will return false
	GetChainAdmins(chainID common.ChainID) ([][]byte, bool)
	// Whether the specific chain is a PoC (Proof of Capacity) chain
	IsPocChain(chainID common.ChainID) bool
}

Global chain currency query

func NewGlobalCurrencierAdapter

func NewGlobalCurrencierAdapter(dmanager DataManager) GlobalCurrencier

type GlobalCurrencierAdapter

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

func (*GlobalCurrencierAdapter) GetChainAdmins

func (g *GlobalCurrencierAdapter) GetChainAdmins(chainID common.ChainID) ([][]byte, bool)

func (*GlobalCurrencierAdapter) GetChainLocalCurrencyInfo

func (g *GlobalCurrencierAdapter) GetChainLocalCurrencyInfo(chainID common.ChainID) (coinId common.CoinID, coinName string)

func (*GlobalCurrencierAdapter) IsPocChain

func (g *GlobalCurrencierAdapter) IsPocChain(chainID common.ChainID) bool

type HeaderSummary

type HeaderSummary struct {
	Header    *BlockHeader
	Summaries []*BlockSummary
}

func (*HeaderSummary) Find

func (s *HeaderSummary) Find(chainId common.ChainID, height common.Height) (index int, summary *BlockSummary)

func (*HeaderSummary) GetChainID

func (s *HeaderSummary) GetChainID() common.ChainID

func (*HeaderSummary) Hash

func (s *HeaderSummary) Hash() common.Hash

func (*HeaderSummary) HeaderProof

func (s *HeaderSummary) HeaderProof(hashOfHeader []byte, proofChain *trie.ProofChain) ([]byte, error)

HeaderProof Get the proof from a packaged HeaderSummary in the current block to the hash of this block

func (*HeaderSummary) String

func (s *HeaderSummary) String() string

type HeighterHashMap

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

HeighterHashMap Different objects with different hashs are allowed at the same height

func NewHeighterHashMap

func NewHeighterHashMap() *HeighterHashMap

func (*HeighterHashMap) ClearHeight

func (m *HeighterHashMap) ClearHeight(height common.Height) bool

func (*HeighterHashMap) Delete

func (m *HeighterHashMap) Delete(hob common.Hash) bool

func (*HeighterHashMap) Get

func (m *HeighterHashMap) Get(height common.Height) ([]BlockHeighter, bool)

func (*HeighterHashMap) MinHeight

func (m *HeighterHashMap) MinHeight() (common.Height, bool)

func (*HeighterHashMap) Peek

func (m *HeighterHashMap) Peek() (height common.Height, hob common.Hash, o BlockHeighter, exist bool)

func (*HeighterHashMap) PopIfEarlier

func (m *HeighterHashMap) PopIfEarlier(target common.Height) (height common.Height, hob common.Hash, o BlockHeighter, exist bool)

func (*HeighterHashMap) Put

func (m *HeighterHashMap) Put(heighter BlockHeighter) bool

func (*HeighterHashMap) Range

func (m *HeighterHashMap) Range(callback RangeBufferCallback) error

func (*HeighterHashMap) Size

func (m *HeighterHashMap) Size() int

func (*HeighterHashMap) String

func (m *HeighterHashMap) String() string

type HeighterSet

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

func NewHeighterSet

func NewHeighterSet() *HeighterSet

func (*HeighterSet) Len

func (s *HeighterSet) Len() int

func (*HeighterSet) Pop

func (s *HeighterSet) Pop() BlockHeighter

func (*HeighterSet) Put

func (s *HeighterSet) Put(x BlockHeighter) bool

func (*HeighterSet) String

func (s *HeighterSet) String() string

type HistoryBlock

type HistoryBlock struct {
	Block *BlockEMessage
}

func (*HistoryBlock) BlockNum

func (b *HistoryBlock) BlockNum() common.BlockNum

func (*HistoryBlock) EpochNum

func (b *HistoryBlock) EpochNum() common.EpochNum

func (*HistoryBlock) GetChainID

func (b *HistoryBlock) GetChainID() common.ChainID

func (*HistoryBlock) GetHeight

func (b *HistoryBlock) GetHeight() common.Height

func (*HistoryBlock) Hash

func (b *HistoryBlock) Hash() common.Hash

func (*HistoryBlock) String

func (b *HistoryBlock) String() string

type HomesteadSigner

type HomesteadSigner struct{ FrontierSigner }

HomesteadSigner HomesteadTransaction implements TransactionInterface using the homestead rules.

func (HomesteadSigner) ChainID

func (h HomesteadSigner) ChainID() *big.Int

func (HomesteadSigner) Equal

func (h HomesteadSigner) Equal(s2 Signer) bool

func (HomesteadSigner) RecoverSigAndPub

func (h HomesteadSigner) RecoverSigAndPub(tx *ETHTransaction) (sig, pub []byte, err error)

func (HomesteadSigner) Sender

func (h HomesteadSigner) Sender(tx *ETHTransaction) (common.Address, error)

func (HomesteadSigner) SignatureValues

func (h HomesteadSigner) SignatureValues(tx *ETHTransaction, sig []byte) (r, s, v *big.Int, err error)

SignatureValues returns signature values. This signature needs to be in the [R || S || V] format where V is 0 or 1.

type IsInCommitteeFunc

type IsInCommitteeFunc func(DataManager, common.Seed, [32]byte, common.ChainID, *RRInfo, byte, logrus.FieldLogger) bool

func LocateIsInCommittee

func LocateIsInCommittee(consensusPlugin *plugin.Plugin) IsInCommitteeFunc

type JustHashEMessage

type JustHashEMessage struct {
	Hash common.Hash // hash of eventLoad
}

type LastBlockMessage

type LastBlockMessage struct {
	BlockHeight
}

func (*LastBlockMessage) String

func (m *LastBlockMessage) String() string

type LastCommEMessage

type LastCommEMessage struct {
	Height common.Height
	Entry  CommEntry
}

When starting, each chain data node reports the last consensus committee to the main chain data node

func (*LastCommEMessage) GetChainID

func (l *LastCommEMessage) GetChainID() common.ChainID

func (*LastCommEMessage) String

func (l *LastCommEMessage) String() string

type LastHeightMessage

type LastHeightMessage struct {
	BlockHeight
	BlockHash common.Hash
}

func NewLastHeightMessage

func NewLastHeightMessage(chainId common.ChainID, height common.Height, hash common.Hash) *LastHeightMessage

func (*LastHeightMessage) String

func (h *LastHeightMessage) String() string

type LastReportMessage

type LastReportMessage struct {
	ChainID common.ChainID
	Height  common.Height
}

func (*LastReportMessage) DestChainID

func (m *LastReportMessage) DestChainID() common.ChainID

func (*LastReportMessage) GetBlockNum

func (m *LastReportMessage) GetBlockNum() common.BlockNum

func (*LastReportMessage) GetChainID

func (m *LastReportMessage) GetChainID() common.ChainID

func (*LastReportMessage) GetEpochNum

func (m *LastReportMessage) GetEpochNum() common.EpochNum

func (*LastReportMessage) GetHeight

func (m *LastReportMessage) GetHeight() common.Height

func (*LastReportMessage) String

func (m *LastReportMessage) String() string

type LegacyTx

type LegacyTx struct {
	Nonce    uint64          // nonce of sender account
	GasPrice *big.Int        // wei per gas
	Gas      uint64          // gas limit
	To       *common.Address `rlp:"nil"` // nil means contract creation
	Value    *big.Int        // wei amount
	Data     []byte          // contract invocation input data
	V, R, S  *big.Int        // signature values
}

LegacyTx is the transaction data of regular Ethereum transactions.

func (*LegacyTx) TxType

func (tx *LegacyTx) TxType() byte

accessors for innerTx.

type Location

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

func (Location) ChainID

func (l Location) ChainID() common.ChainID

func (Location) NetType

func (l Location) NetType() common.NetType

func (Location) NoWhere

func (l Location) NoWhere() bool

func (Location) NodeID

func (l Location) NodeID() *common.NodeID

func (*Location) SetChainID

func (l *Location) SetChainID(chainID common.ChainID)

func (*Location) SetNetType

func (l *Location) SetNetType(netType common.NetType)

func (*Location) SetNodeID

func (l *Location) SetNodeID(nid *common.NodeID)

func (Location) String

func (l Location) String() string

type Log

type Log struct {
	// Consensus fields:
	// address of the contract that generated the event
	Address common.Address `json:"address" gencodec:"required"`
	// list of topics provided by the contract.
	Topics []common.Hash `json:"topics" gencodec:"required"`
	// supplied by the contract, usually ABI-encoded
	Data []byte `json:"data" gencodec:"required"`

	// Derived fields. These fields are filled in by the node
	// but not secured by consensus.
	// block in which the transaction was included
	BlockNumber uint64 `json:"blockNumber" gencodec:"required"`
	// hash of the transaction
	TxHash common.Hash `json:"transactionHash" gencodec:"required"`
	// index of the transaction in the block
	TxIndex uint `json:"transactionIndex" gencodec:"required"`
	// index of the log in the receipt
	Index uint `json:"logIndex" gencodec:"required"`
	// hash of the block in which the transaction was included
	BlockHash *common.Hash `json:"blockHash"`
}

func (Log) MarshalJSON

func (l Log) MarshalJSON() ([]byte, error)

MarshalJSON marshals as JSON.

func (*Log) UnmarshalJSON

func (l *Log) UnmarshalJSON(input []byte) error

UnmarshalJSON unmarshals from JSON.

type LongEntry

type LongEntry struct {
	K common.Hash
	V []*LongValue
}

type LongValue

type LongValue struct {
	KeyHash common.Hash // long storage key
	Value   []byte      // long value,could be any type of data serialization, resolved by the upper business layer
}

func (*LongValue) HashValue

func (v *LongValue) HashValue() ([]byte, error)

func (*LongValue) Key

func (v *LongValue) Key() []byte

func (*LongValue) String

func (v *LongValue) String() string

type Message

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

Message EVM message

func NewMessage

func NewMessage(bodyhash common.Hash, txhash common.Hash, from common.Address, to *common.Address, nonce uint64, useLocal bool,
	amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte, checkNonce bool, senderSig *PubAndSig,
	multiSigs PubAndSigs, version uint16) Message

func (Message) AllValidSigns

func (m Message) AllValidSigns(callback func(pas *PubAndSig)) map[string]struct{}

AllValidSigns Traverse all the valid signatures without repetition, call the callback method, and return the map with the key as the public key of the valid signature

func (Message) CheckNonce

func (m Message) CheckNonce() bool

func (Message) Data

func (m Message) Data() []byte

func (Message) From

func (m Message) From() common.Address

func (Message) Gas

func (m Message) Gas() uint64

func (Message) GasPrice

func (m Message) GasPrice() *big.Int

func (Message) MultiSigs

func (m Message) MultiSigs() PubAndSigs

func (Message) Nonce

func (m Message) Nonce() uint64

func (Message) Sig

func (m Message) Sig() *PubAndSig

func (Message) SignedAddresses

func (m Message) SignedAddresses() map[common.Address]struct{}

SignedAddresses Returns the unordered list of addresses corresponding to all correctly signed public keys

func (Message) SignedPubs

func (m Message) SignedPubs() map[string]struct{}

SignedPubs Returns an unordered list of all correctly signed public keys

func (Message) To

func (m Message) To() *common.Address

func (Message) TxHash

func (m Message) TxHash() common.Hash

func (Message) UseLocal

func (m Message) UseLocal() bool

func (Message) Value

func (m Message) Value() *big.Int

func (Message) Version

func (m Message) Version() uint16

type MinterMintData

type MinterMintData struct {
	Sender common.Address // request from address
	Nonce  uint64         // nonce of sender can prevent replay attach
	Value  *big.Int       // request value
	To     common.Address // receive value address
}

func (*MinterMintData) Deserialization

func (d *MinterMintData) Deserialization(r io.Reader) (shouldBeNil bool, err error)

func (*MinterMintData) Serialization

func (d *MinterMintData) Serialization(w io.Writer) error

func (*MinterMintData) String

func (d *MinterMintData) String() string

type MinterMintReqeust

type MinterMintReqeust struct {
	Data *MinterMintData // request data
	SigsAndPubs
}

func (*MinterMintReqeust) DataDeserialize

func (c *MinterMintReqeust) DataDeserialize(vr rtl.ValueReader) error

func (*MinterMintReqeust) DataSerialize

func (c *MinterMintReqeust) DataSerialize(w io.Writer) error

func (*MinterMintReqeust) Deserialization

func (c *MinterMintReqeust) Deserialization(r io.Reader) (shouldBeNil bool, err error)

func (*MinterMintReqeust) GetData

func (c *MinterMintReqeust) GetData() (o interface{}, exist bool)

func (*MinterMintReqeust) Serialization

func (c *MinterMintReqeust) Serialization(w io.Writer) error

func (*MinterMintReqeust) String

func (c *MinterMintReqeust) String() string

type MissingChainEventMsg

type MissingChainEventMsg struct {
	ID common.ChainID
}

The system found a chain that did not exist

func (*MissingChainEventMsg) String

func (msg *MissingChainEventMsg) String() string

type MissingHeights

type MissingHeights map[common.ChainID][2]uint64

shardid -> [0]:start height, [1]:length of missing heights

func (MissingHeights) Get

func (m MissingHeights) Get(id common.ChainID) (start common.Height, length int, exist bool)

func (MissingHeights) IDs

func (m MissingHeights) IDs() common.ChainIDs

func (MissingHeights) MostUrgent

func (m MissingHeights) MostUrgent() (id common.ChainID, start common.Height, length int, exist bool)

func (MissingHeights) Put

func (m MissingHeights) Put(id common.ChainID, start common.Height, length int)

type NetworkManager

type NetworkManager interface {
	common.Service
	InitChain(id common.ChainID) error
	GetDataServer(chainId common.ChainID) *[]common.Dataserver
	GetNetworker(id common.ChainID) Networker
	BroadcastFull(info string, skip *common.NodeID, cid common.ChainID, ntp common.NetType,
		pb interface{}, pub, sig []byte) error
	BroadcastFullSync(info string, skip *common.NodeID, cid common.ChainID, ntp common.NetType,
		pb interface{}, pub, sig []byte) error
	SendToNode(info string, ntp common.NetType, chainId common.ChainID, to common.NodeIDs,
		pb interface{}, pub, sig []byte) error
	SendToPeer(info string, ntp common.NetType, chainId common.ChainID, toNodes common.NodeIDs,
		pb interface{}, pub, sig []byte) error
	SendToChain(info string, ntp common.NetType, fromChain common.ChainID, toChain common.ChainID,
		pb interface{}, pub, sig []byte) error
	Rand(size int, info string, chainId common.ChainID, ntp common.NetType, msg interface{}, pub, sig []byte,
		skips ...*common.NodeID) error
	GetChainNet(id common.ChainID, netType common.NetType) (map[common.NodeID]net.Addr, bool)
	StartConNet(networker Networker, chainid common.ChainID, netType common.NetType) (common.NodeID, error)
	CreateOrConnectNet(ntp common.NetType, bootChainID, localChandID common.ChainID) error
	IsBootNode(id common.ChainID) bool
	ClearNetWorker(id common.ChainID)
	InitNet(chaininfo *common.ChainInfos) error
	StopOneNet(cid common.ChainID, ntp common.NetType) (int, error)
	ResetNet(chainid common.ChainID, ntp common.NetType) error
	ConnectNet(chaininfo *common.ChainInfos) error
	Status()
}

type Networker

type Networker interface {
	// Create start a boot node
	Create(typ common.NetType, addr net.Addr, boots map[common.NodeID]net.Addr, infos []*common.ChainInfos, callback ConnectedCallBackFunc) error
	// Connect connect to p2p network with a boot node
	Connect(typ common.NetType, bootId common.ChainID, boots map[common.NodeID]net.Addr, infos []*common.ChainInfos, permission []byte, callback ConnectedCallBackFunc) error
	// Reset reset a boot node
	Reset(typ common.NetType, addr net.Addr, callback ConnectedCallBackFunc) error
	// Exit exit from current p2p network
	Exit(typ common.NetType) (int, error)
	// Check whether a certain net type exists
	IsIn(typ common.NetType) bool
	// Get chain id that the net worker belongs to
	GetChainID() common.ChainID
	// Set data net discovery table's tmpNodes
	SetTmpDataNodes(nt common.NetType)
	// Replace discovery table's dataNodes with tmpNodes
	ReplaceDataNodes(nt common.NetType)
	// Abandon useless peers
	AbandonUselessPeers(nt common.NetType)
	// broadcast asynchronized
	Broadcast(info string, typ common.NetType, msg interface{},
		pub, sig []byte, skips ...*common.NodeID) ([]byte, []byte, error)
	// SendToNode send a message to a specific node in p2p network
	SendToNode(info string, typ common.NetType, nodeids common.NodeIDs,
		msg interface{}, pub, sig []byte) ([]byte, []byte, error)
	SendToPeer(info string, typ common.NetType, nodeids common.NodeIDs,
		msg interface{}, pub, sig []byte) ([]byte, []byte, error)
	SendToChain(info string, typ common.NetType, chainid common.ChainID,
		msg interface{}, pub, sig []byte) ([]byte, []byte, error)
	Rand(size int, info string, typ common.NetType, msg interface{}, pub, sig []byte,
		skips ...*common.NodeID) ([]byte, []byte, error)
	// broadcast synchronized
	BroadcastSync(info string, typ common.NetType, msg interface{},
		pub, sig []byte, skips ...*common.NodeID) ([]byte, []byte, error)
}

type NodeResult

type NodeResult struct {
	NodeID     common.NodeID // The ID of the node participating in the election. For ManagedComm, only this field is needed, and the other fields are empty
	Sorthash   *common.Hash  // The result of the VRF algorithm
	Proof      []byte        // Proof of VRF algorithm results
	FactorHash *common.Hash  // since2.0.0 The node declares the hash of the random factor participating in the seed calculation
}

Because the ChainID/Epoch information is missing, it cannot be used alone and needs to be used in conjunction with ChainElectResult

func (*NodeResult) FromVrfResulter

func (n *NodeResult) FromVrfResulter(resulter VrfResulter) *NodeResult

func (*NodeResult) GetNodeID

func (n *NodeResult) GetNodeID() common.NodeID

func (*NodeResult) GetVrfResult

func (n *NodeResult) GetVrfResult() (sorthash *common.Hash, proof []byte, factorHash *common.Hash)

func (*NodeResult) String

func (n *NodeResult) String() string

func (*NodeResult) VrfVerify

func (n *NodeResult) VrfVerify(seed common.Seed) error

type NodeResults

type NodeResults []*NodeResult

func (NodeResults) Len

func (ns NodeResults) Len() int

func (NodeResults) Less

func (ns NodeResults) Less(i, j int) bool

func (NodeResults) ManagedCommVerifyAll

func (ns NodeResults) ManagedCommVerifyAll(nidHashes []common.Hash) error

func (NodeResults) Remove

func (ns NodeResults) Remove(os NodeResults) NodeResults

the difference of ns - os

func (NodeResults) Swap

func (ns NodeResults) Swap(i, j int)

func (NodeResults) ToMap

func (ns NodeResults) ToMap() map[common.NodeID]*NodeResult

func (NodeResults) VrfVerifyAll

func (ns NodeResults) VrfVerifyAll(seed common.Seed) error

type NodeState

type NodeState struct {
	NodeId    common.NodeID
	ChainId   common.ChainID
	Height    common.Height
	BlockSig  []byte
	Ip        string
	BasicPort uint16
	DataPort  uint16
	ConPort0  uint16
	ConPort1  uint16
}

func (*NodeState) GetChainID

func (b *NodeState) GetChainID() common.ChainID

func (*NodeState) Hash

func (b *NodeState) Hash() common.Hash

func (*NodeState) String

func (b *NodeState) String() string

type Noticer

type Noticer interface {
	common.Service
	CanPublish(block *BlockEMessage) bool
	Publish(block *BlockEMessage, receipts []*Receipt) error
}

func LoadNoticer

func LoadNoticer(sopath string, queueSize int, chainID common.ChainID, redisAddr string, redisPwd string,
	redisDB int, redisQueue string) Noticer

type OneDeltas

type OneDeltas struct {
	// the height of the block A where delta generated
	Height common.Height
	// All deltas in a block corresponding to a shard to another shard
	Deltas []*AccountDelta
	// The proof of this group of delta to the hash of block A at Height (1)(2)
	Proof trie.ProofChain
	// The proof to HashHistory of block B (specified by DeltasPack) used in this transmission (3).
	// You can use this proof.Key() judge the authenticity of Height. When Height==DeltasPack.ProofedHeight,
	// this proof is nil. At this time, verify with ProofedHeight in DeltasPack.
	// 到本次传输统一使用的块B(由DeltasPack指定)的HashHistory的证明(3)。可以用此proof.Key()判
	// 断Height的真实性。当Height==DeltasPack.ProofedHeight时,此证明为nil。此时与DeltasPack
	// 中的ProofedHeight做验证。
	HistoryProof trie.ProofChain
	// Proof from the HashHistory of block B to the Hash of block B (4).
	// When Height==DeltasPack.ProofedHeight, this proof is nil.
	// At this time, verify with ProofedHeight in DeltasPack.
	// 从块B的HashHistory到块B的Hash的证明(4)。当Height==DeltasPack.ProofedHeight时,此证明为nil。
	// 此时与DeltasPack中的ProofedHeight做验证。
	ProofToB trie.ProofChain
}

Proof.Proof(MerkleHash(Deltas)) == BlockHash of Height (1)(2) HistoryProof.Proof(BlockHash of Height) == BlockHash of DeltasPack.ProofedHeight (3)(4)

func (*OneDeltas) String

func (o *OneDeltas) String() string

type OpSet

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

func NewOpSet

func NewOpSet(ots []OperatorType) *OpSet

func (*OpSet) Has

func (s *OpSet) Has(opType OperatorType) bool

func (*OpSet) HasAny

func (s *OpSet) HasAny(opTypes ...OperatorType) bool

any one or more

type Operator

type Operator struct {
	Type       OperatorType
	Operations []interface{}
}

type OperatorType

type OperatorType byte
const (
	// The identity type of the node on the chain
	CtrlOp      OperatorType = iota // Control class. The context has no chain information when the control event is executed
	DataOp                          // Data node
	CommitteeOp                     // Consensus node
	InitialOp                       // Initial class of consensus node
	PreelectOp                      // Preelect class, higher than SPEC and lower than COMM
	SpectatorOp                     // Spectator class
	MemoOp                          // Full class
	StartOp                         // Starting class
	FailureOp                       // Failure class
)

func (OperatorType) String

func (o OperatorType) String() string

type P2PServer

type P2PServer interface {
	// get boot chain id
	BootChain() common.ChainID
	// discovery type is sort
	DiscoverTypeIsSRT() bool
	// set chains dataNodes to discovery table tmpNodes
	SetTmpDataNodes(infos []*common.ChainInfos)
	// replace discovery dataNodes with tmpNodes
	ReplaceDataNodes()
	// abandon useless peers in ChainToPeers
	AbandonUselessPeers()
	// start server
	Start() error
	// stop server
	Stop()
	// get the local nodeId
	NodeID() *common.NodeID
	// get the server local port
	LocalPort() uint16
	// broadcast message use goroutine
	BroadcastAsync(info string, msgv interface{}, pub, sig []byte, skips ...*common.NodeID) ([]byte, []byte, error)
	// send a message to oriented nodes
	SendToNode(info string, toNodes common.NodeIDs, pb interface{}, pub, sig []byte) ([]byte, []byte, error)
	// send a message to my peer
	SendToPeer(info string, toNodes common.NodeIDs, pb interface{}, pub, sig []byte) ([]byte, []byte, error)
	// send a message to another chain
	SendToChain(info string, chainid common.ChainID, pb interface{}, pub, sig []byte) ([]byte, []byte, error)
	// randomly select size peers to send messsages
	RandBroadcast(size int, info string, msgv interface{}, pub, sig []byte,
		skips ...*common.NodeID) ([]byte, []byte, error)
	// synchronous broadcast, others not specified are sent asynchronously
	BroadcastSync(info string, msgv interface{}, pub, sig []byte, skips ...*common.NodeID) ([]byte, []byte, error)
}

type PostState

type PostState struct {
	GasFee string `json:"fee"`
	Root   []byte `json:"root"`
}

record the transaction process result

func NewPostState

func NewPostState(gasFee *big.Int, root []byte) *PostState

func ParsePostState

func ParsePostState(bs []byte) *PostState

func (*PostState) Bytes

func (s *PostState) Bytes() ([]byte, error)

type PreElectPhase

type PreElectPhase byte
const (
	PECreating PreElectPhase = 0x0 + iota // new pre-election
	PEElecting                            // pre-electing
	PEStarting                            // starting
	PEExiting                             // exiting
)

Create pre-election stage: Create when the contract is successfully executed, enter the Creating

stage, broadcast and delete when proposing, there is no CachedHash at this time.

Pre-election phase: In the commit block phase, use block.PreElectings to overwrite the electings

in the cache, and clear the corresponding creating/results/elected cache.

For different stages:

Creating: Enter the Electing phase, add CachedHash, and generate a PreelectionStart control
          event, which is responsible for sending out the election information of this node
Electing: Add CachedHash
Starting: No need to deal with
Exiting: When the Starting timeout, switch to Exiting package, when receiving Exiting in the
         package, you need to send a control event to check whether the target chain is started,
         if not you need to exit

Pre-launch phase: When reaching Electing.Expire, if the election result is successful, enter the

Starting phase and pack

创建预选举阶段: 合约执行成功时创建,进入Creating阶段,打包时广播并删除,此时没有CachedHash。 预选举阶段: 在commit block阶段,使用block.PreElectings覆盖缓存中的electings, 并清除相应creating/results/elected缓存。针对不同阶段:

Creating: 进入Electing阶段,补CachedHash,并产生PreelectionStart控制消息,该消息负责向外发送本节点的参选信息
Electing: 补CachedHash
Starting: 无需处理
Exiting: 当Starting超时时,转为Exiting打包,接收到包中Exiting时,需要发送控制消息检查目标链是否启动了,没有启动需要退出

预启动阶段: 到达Electing.Expire时,如果选举结果成功,则进入Starting阶段并打包

func (PreElectPhase) String

func (p PreElectPhase) String() string

type PreElecting

type PreElecting struct {
	// Chain of pre-election
	ChainID common.ChainID
	// Current execution stage
	Phase PreElectPhase
	// Seed of main chain when pre-electing
	Seed *common.Seed
	// Count the number of election retrys, because the election may not be successful, and the
	// election can be automatically started again (3 times in total)
	Count int
	// The height of the main chain when the pre-election starts. Because the Hash value of the
	// current block is required when creating PreElecting, it cannot be stored in the object and
	// needs to be obtained from the data node when synchronizing data
	Start common.Height
	// The Hash of the main chain height block at startup has a value in the cache and is nil in
	// the BlockBody
	CachedHash *common.Hash
	// When the new chain is a ManagedComm chain, NidHashes saves the hash values of all authorized
	// node IDs, which are the basis for the pre-election. The election type can also be judged
	// based on whether this field is empty
	NidHashes []common.Hash
	// Electing phase: the height of the main chain at which the pre-election ends;
	// Starting phase: the height of the main chain at which consensus is initiated
	Expire common.Height
}

The pre-election records, generated by the contract call of creation of the chain or the start of the pre-election, are put into the block after the main chain is generated. The consensused pre-election, which is generated from the Start block of the main chain and continues until the Expire block, has been kept in the main chain block until it is deleted. Makes the pre-election well documented. And it is necessary to synchronize the preElectCache in the main chain DataHolder when the new node synchronizes the main chain data, because the seed required by the VRF algorithm will be recorded in the cache. 由创建链或启动预选举合约产生的预选举记录,在主链生成后放入块中,以此 发布经过共识的预选举,从主链的第Start块生成,一直持续到Expire块之后 被主链共识删除为止一直保存在主链块中。使得预选举有据可查。 且需要在新节点同步主链数据时将主链DataHolder中的preElectCache一起 同步,因为在cache中会记录VRF算法需要的seed。

func (*PreElecting) Clone

func (pe *PreElecting) Clone() *PreElecting

func (*PreElecting) Equals

func (pe *PreElecting) Equals(o *PreElecting) bool

func (*PreElecting) IsManagedComm

func (pe *PreElecting) IsManagedComm() bool

func (*PreElecting) IsValidManagedComm

func (pe *PreElecting) IsValidManagedComm() bool

func (*PreElecting) IsVrf

func (pe *PreElecting) IsVrf() bool

func (*PreElecting) PreSeed

func (pe *PreElecting) PreSeed() (*common.Seed, error)

func (*PreElecting) String

func (pe *PreElecting) String() string

func (*PreElecting) ToPack

func (pe *PreElecting) ToPack() *PreElecting

Generate objects for packaging, the pre-election information in the block does not include BlockHash

type PreElectings

type PreElectings []*PreElecting

Objects placed in the block, the ongoing pre-election list sorted by (Expire, ChainID), and generate MerkleTreeHash into the block header

func (PreElectings) Equals

func (p PreElectings) Equals(o PreElectings) bool

func (PreElectings) HashValue

func (p PreElectings) HashValue() ([]byte, error)

Calculate MerkelHash, need to sort before calling

func (PreElectings) Len

func (p PreElectings) Len() int

func (PreElectings) Less

func (p PreElectings) Less(i, j int) bool

func (PreElectings) Swap

func (p PreElectings) Swap(i, j int)

type PreelectionConnect

type PreelectionConnect struct {
	ChainID common.ChainID // The chain that needs to be connected after the pre-election
	Height  common.Height  // Record the height of the main chain generating the message, and to distinguish different events (to avoid Hash duplication)
	Comm    *Committee     // Committee after pre-election
}

Node internal control event. When the pre-election enters the startup phase, and the node is selected, this message is sent to connect to the network, and the corresponding identity of the chain is set to PREELECT Create at performing commitPreelects.checkElected when executing StateDB.Commit.

func (*PreelectionConnect) GetChainID

func (p *PreelectionConnect) GetChainID() common.ChainID

func (*PreelectionConnect) String

func (p *PreelectionConnect) String() string

type PreelectionExamine

type PreelectionExamine struct {
	ChainID common.ChainID
	Height  common.Height
}

Node internal control event, the consensus node checks whether the consensus is normal during the pre-election startup phase Create at preforming commitPreelects.checkElected when executing StateDB.Commit

func (PreelectionExamine) GetChainID

func (p PreelectionExamine) GetChainID() common.ChainID

func (*PreelectionExamine) String

func (p *PreelectionExamine) String() string

type PreelectionExit

type PreelectionExit struct {
	ChainID common.ChainID
	Height  common.Height
}

Node internal control event, consensus node found failure in the pre-election during the startup phase, exit the network, and close consensus Create at performing commitPreelects when executing StateDB.Commit. (Fault tolerance mechanism) or create at preforming commitPreelects.checkElected when executing StateDB.Commit

func (PreelectionExit) GetChainID

func (p PreelectionExit) GetChainID() common.ChainID

func (*PreelectionExit) String

func (p *PreelectionExit) String() string

type PreelectionStart

type PreelectionStart struct {
	ChainID      common.ChainID // the chain starting preelection
	ParentHeight common.Height  // the main chain height when starting the preelection
}

Node internal control event. When you need to start a preelection, just send a message to the queue Create at performing commitPreelects when executing StateDB.Commit.

func (*PreelectionStart) GetChainID

func (p *PreelectionStart) GetChainID() common.ChainID

func (*PreelectionStart) String

func (p *PreelectionStart) String() string

type PreelectionSync

type PreelectionSync struct {
	ChainID common.ChainID
	Height  common.Height
}

Node internal control event, the data node starts to broadcast synchronous data during the pre-election startup phase Create at preforming commitPreelects.checkElected when executing StateDB.Commit

func (PreelectionSync) GetChainID

func (p PreelectionSync) GetChainID() common.ChainID

func (*PreelectionSync) String

func (p *PreelectionSync) String() string

type ProposeResult

type ProposeResult struct {
	Processed      []*Transaction    // executed transactions
	ProcessedPas   []*PubAndSig      // the signatures corresponding to the executed transactions one by one
	StateRoot      []byte            // world state tree root hash after transaction execution
	DeltaTrie      *AccountDeltaTrie // DeltaTrie generated after transaction execution
	ReceiptsHash   []byte            // hash value of all executed transactions receipts
	VccRoot        []byte            // root hash of signed check tree
	CashedRoot     []byte            // root hash of cashed check tree
	RREra          common.EraNum     // current era of reward chain
	RRRoot         []byte            // root hash of required reserve tree at current era in reward chain
	RRNextRoot     []byte            // root hash of required reserve tree at next era in reward chain
	RRChangingRoot []byte            // root hash of modification request tree currently to be applied in reward chain
	ChainInfoRoot  []byte            // root hash of chain info tree in main chain
	WaterlinesRoot []byte            // merkle root hash of all waterline values of all shards after the completion of delta merge and transaction execution
}

type PubAndSig

type PubAndSig struct {
	PublicKey []byte
	Signature []byte
}

func (*PubAndSig) Clone

func (p *PubAndSig) Clone() *PubAndSig

func (*PubAndSig) Equals

func (p *PubAndSig) Equals(v interface{}) bool

func (*PubAndSig) FullString

func (p *PubAndSig) FullString() string

func (*PubAndSig) String

func (p *PubAndSig) String() string

type PubAndSigs

type PubAndSigs []*PubAndSig

func (PubAndSigs) Clone

func (ps PubAndSigs) Clone() PubAndSigs

func (PubAndSigs) Len

func (ps PubAndSigs) Len() int

func (PubAndSigs) Less

func (ps PubAndSigs) Less(i, j int) bool

sort by (public key, signature)

func (PubAndSigs) Swap

func (ps PubAndSigs) Swap(i, j int)

type QueueInfo

type QueueInfo struct {
	Name        string
	Types       []EventType // All event types supported by this queue
	HigherTypes []EventType // The event types with higher priority
	WorkerSize  int
	QueueLength int
}

queue information

func ListQueueInfos

func ListQueueInfos() []QueueInfo

func (QueueInfo) String

func (qi QueueInfo) String() string

type QueueInfos

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

func (*QueueInfos) Add

func (q *QueueInfos) Add(name string, workerSize int, queueLength int, higherTypes []EventType, eventTypes ...EventType)

func (*QueueInfos) ListInfos

func (q *QueueInfos) ListInfos() []QueueInfo

type QueueObj

type QueueObj struct {
	From      Location     // source of event
	EventType EventType    // event type
	H         *common.Hash // payload hash, hash(event body serialization, event type)
	V         interface{}  // event object
	P         []byte       // public key
	S         []byte       // signature of hash of the event: Sign(HashObject(V))
}

func NewQueueObj

func NewQueueObj(fromNodeID *common.NodeID, fromChainID common.ChainID, fromNetType common.NetType,
	eventType EventType, hashOfPayLoad *common.Hash, event interface{}, pub, sig []byte) *QueueObj

func (*QueueObj) String

func (r *QueueObj) String() string

type RRAType

type RRAType byte

Required Reserve Act Type

const (
	RRADeposit  RRAType = iota // Deposit
	RRAPenalty                 // Confiscation deposit
	RRAWithdraw                // Withdraw
	RRAStatus                  // NewStatus>0: RRInfo.Status |= uint16(NewStatus), NewStatus<0:RRInfo.Status &= (^uint16(-NewStatus))
	RRAMax                     // The valid value must be less than this value
)

func (RRAType) Compare

func (t RRAType) Compare(typ RRAType) int

Compare the priority of the two types, the higher the priority of the execution order, the smaller the Compare, the higher the execution priority

func (RRAType) String

func (t RRAType) String() string

func (RRAType) Valid

func (t RRAType) Valid() bool

type RRAct

type RRAct struct {
	Typ             RRAType        // Current operation type: deposit, withdraw, penalty
	Height          common.Height  // Block height at the time of request
	Amount          *big.Int       // Nil when withdrawing all, other positive numbers
	RelatingChainID common.ChainID // The chain id of the transaction executed that generated this action
	RelatingTxHash  common.Hash    // The transaction that caused this action (Deposit/Withdraw

}

Record changes for the same node, because all changes must be compatible, that is, NodeID/Addr must be equal, and effective Typ must also be equal, so these three pieces of information can only be recorded in RRC.

func NewRRAct

func NewRRAct(typ RRAType, height common.Height, amount *big.Int, id common.ChainID, txHash common.Hash) (*RRAct, error)

func (*RRAct) Clone

func (a *RRAct) Clone() *RRAct

func (*RRAct) String

func (a *RRAct) String() string

type RRC

type RRC struct {
	NodeIDHash common.Hash     // NodeID hash of the changing node
	Addr       common.Address  // Binding address
	Typ        common.NodeType // Node type
	Acts       []*RRAct        // Changing list according to the order of transaction execution, execute in the order of priority during execution
}

Required Reserve Change

func (*RRC) ApplyTo

func (rr *RRC) ApplyTo(info *RRInfo, stateDB StateDB) (
	changed bool, shouldRemove bool, newinfo *RRInfo, err error)

Apply the pledge change request to the corresponding required reserve information and return it. If the info parameter is nil, create a new info apply changes and return it

func (*RRC) CheckWithdraw

func (rr *RRC) CheckWithdraw(depositing *big.Int, amount *big.Int) error

Determine whether the withdrawing can be executed according to the Delta generated by the Act queue in the existing Changing and the amount of pledge to be redeemed reduced

func (*RRC) Compatible

func (rr *RRC) Compatible(nodeIdHash common.Hash, typ common.NodeType, addr common.Address, actType RRAType) bool

Check the modification to the same node, whether its nodeid/bindaddr and nodeType are the same

func (*RRC) Key

func (rr *RRC) Key() []byte

func (*RRC) MergeActs

func (rr *RRC) MergeActs()

Combine existing Act queues to avoid excessively long queues occupying resources

func (*RRC) String

func (rr *RRC) String() string

type RRInfo

type RRInfo struct {
	// The hash value of the NodeID of the node is used to store information in a more
	// private way. It can also reduce storage capacity
	NodeIDHash common.Hash
	// The main chain block height at the time of the last deposit
	Height common.Height
	// Which type of node, supports common.Consensus/common.Data
	Type common.NodeType
	// If it is not nil, it means that this deposit has been applied for withdrawing and
	// will no longer participate in the calculation. When the value >= the cycle currently
	// being calculated, execute the withdrawing
	WithdrawDemand *common.EraNum
	// Record the number of penalties, initially 0, +1 after each Penalty execution
	PenalizedTimes int
	// Pledge amount (the total pledge amount of this node, >= effective pledge amount)
	Amount *big.Int
	// The percentage of the effective pledge amount of the current node in the total
	// effective pledge. If it is nil, it indicates that the current pledge does not
	// account for the proportion. It may be waiting for withdrawing at this time.
	Ratio *big.Rat
	// Reward binding address
	RewardAddr common.Address
	// Since v1.3.4. When WithdrawDemand!=nil, record all pending withdrawing records. If it
	// exists, the withdrawing due in the list will be executed every era.
	Withdrawings Withdrawings
	// since v1.5.0. Version number, used for compatible
	Version uint16
	// since v1.5.0。Used to record a total of valid pledged consensus nodes, only valid
	// when Type==common.Consensus, others are 0
	NodeCount uint32
	// node status
	Status uint16
}

Required Reserve Information of the node

func CreateGenesisRRInfo

func CreateGenesisRRInfo(nodeIdHash common.Hash, nodeType common.NodeType) (*RRInfo, error)

func (*RRInfo) Available

func (r *RRInfo) Available() bool

func (*RRInfo) AvailableAmount

func (r *RRInfo) AvailableAmount(nodeType common.NodeType) *big.Int

Returns the pledge amount of the specified type of nodeType of the current node

func (*RRInfo) Clone

func (r *RRInfo) Clone() *RRInfo

func (*RRInfo) Compatible

func (r *RRInfo) Compatible(nodeIdHash common.Hash, typ common.NodeType, addr common.Address) bool

Compatibility check

func (*RRInfo) Depositing

func (r *RRInfo) Depositing() *big.Int

Return the pledge amount after subtracting the amount to be redeemed

func (*RRInfo) Expired

func (r *RRInfo) Expired(eraNum common.EraNum) bool

func (*RRInfo) HashValue

func (r *RRInfo) HashValue() ([]byte, error)

func (*RRInfo) InfoEquals

func (r *RRInfo) InfoEquals(v *RRInfo) bool

Compare the immutable information except Ratio and NodeCount

func (*RRInfo) Key

func (r *RRInfo) Key() []byte

func (*RRInfo) Shares

func (r *RRInfo) Shares() uint64

Returns the share of the current node in Consensus 0:has not, did not participate in the election N:Indicates that N deposits have been paid, and there is a N times chance of being selected

func (*RRInfo) String

func (r *RRInfo) String() string

func (*RRInfo) ValidAmount

func (r *RRInfo) ValidAmount() *big.Int

The current effective pledge amount (minus the part being redeemed)

type RRProofs

type RRProofs struct {
	Info  *RRInfo
	Proof trie.ProofChain
}

func (*RRProofs) Clone

func (p *RRProofs) Clone() *RRProofs

func (*RRProofs) PrintString

func (p *RRProofs) PrintString() string

func (*RRProofs) String

func (p *RRProofs) String() string

func (*RRProofs) VerifyProof

func (p *RRProofs) VerifyProof(nodeIdHash common.Hash, root common.Hash) error

type RRProofsMessage

type RRProofsMessage struct {
	NodeId   common.NodeID
	Era      common.EraNum
	RootHash common.Hash
	Proofs   *RRProofs
}

func (*RRProofsMessage) GetChainID

func (rm *RRProofsMessage) GetChainID() common.ChainID

func (*RRProofsMessage) String

func (rm *RRProofsMessage) String() string

type RRProofsRequest

type RRProofsRequest struct {
	ToChainId common.ChainID
	NodeId    common.NodeID
	Era       common.EraNum
	RootHash  common.Hash
}

func (*RRProofsRequest) GetChainID

func (rr *RRProofsRequest) GetChainID() common.ChainID

func (*RRProofsRequest) String

func (rr *RRProofsRequest) String() string

type RRStatus

type RRStatus uint16

func (RRStatus) Change

func (s RRStatus) Change(value *big.Int) (newStatus RRStatus, msg string, changed bool)

func (RRStatus) Match

func (s RRStatus) Match(bits uint16) bool

type RRStatusAct

type RRStatusAct big.Int

func (*RRStatusAct) Ignored

func (a *RRStatusAct) Ignored() bool

func (*RRStatusAct) Merge

func (a *RRStatusAct) Merge(b *RRStatusAct) error

func (*RRStatusAct) Todo

func (a *RRStatusAct) Todo() (act uint16, setOrClr bool)

type RRTries

type RRTries interface {
	Commit() error
	Rollback()
	MatchEra(era common.EraNum) error
	NextEra(toEra common.EraNum) (err error)
	PreCommitStatus() (era common.EraNum, rrRoot, nextRoot, changingRoot []byte, err error)
	Era() common.EraNum
	Deposit(fromChain common.ChainID, fromTxHash common.Hash, height common.Height, typ common.NodeType,
		nodeIdHash common.Hash, addr common.Address, amount *big.Int) error
	Withdraw(fromChain common.ChainID, fromTxHash common.Hash, height common.Height,
		nodeIdHash common.Hash, addr common.Address) error
	Penalty(fromChain common.ChainID, fromTxHash common.Hash, nodeIdHash common.Hash, amount *big.Int) error
	PreHashValue() (rrRoot, rrNextRoot, rrChangingRoot []byte, err error)
	PreCommit() (currentRoot, nextRoot, changingRoot []byte, err error)
}

type RangeBufferCallback

type RangeBufferCallback func(height common.Height, hob common.Hash,
	o BlockHeighter) (goon bool, nextHeight bool, err error)

RangeBufferCallback if need continue the range, goon return true if need step to next height, nextHeight return true

type RawData

type RawData interface {
	GetFrom() Location
	GetFromNodeID() *common.NodeID
	GetFromChainID() common.ChainID
	GetFromNetType() common.NetType
	GetEventType() EventType
	GetData() []byte
	GetObject() interface{}
	GetHash() *common.Hash
	GetPublicKey() []byte
	GetSignature() []byte
}

type RawDataObj

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

func NewRawData

func NewRawData(fromNodeID *common.NodeID, fromChainID common.ChainID,
	fromNetType common.NetType, eventType EventType, data, pub, sig []byte, dataHash *common.Hash, v interface{}) *RawDataObj

func (*RawDataObj) GetData

func (r *RawDataObj) GetData() []byte

func (*RawDataObj) GetEventType

func (r *RawDataObj) GetEventType() EventType

func (*RawDataObj) GetFrom

func (r *RawDataObj) GetFrom() Location

func (*RawDataObj) GetFromChainID

func (r *RawDataObj) GetFromChainID() common.ChainID

func (*RawDataObj) GetFromNetType

func (r *RawDataObj) GetFromNetType() common.NetType

func (*RawDataObj) GetFromNodeID

func (r *RawDataObj) GetFromNodeID() *common.NodeID

func (*RawDataObj) GetHash

func (r *RawDataObj) GetHash() *common.Hash

func (*RawDataObj) GetObject

func (r *RawDataObj) GetObject() interface{}

func (*RawDataObj) GetPublicKey

func (r *RawDataObj) GetPublicKey() []byte

func (*RawDataObj) GetSignature

func (r *RawDataObj) GetSignature() []byte

func (*RawDataObj) String

func (r *RawDataObj) String() string

type Receipt

type Receipt struct {
	// Consensus fields
	PostState         []byte `json:"root"` // It is used to record the information of transaction execution in JSON format, such as gas, cost "gas", and world state "root" after execution.
	Status            uint64 `json:"status"`
	CumulativeGasUsed uint64 `json:"cumulativeGasUsed" gencodec:"required"`
	Logs              []*Log `json:"logs" gencodec:"required"`

	// Implementation fields (don't reorder!)
	TxHash          common.Hash     `json:"transactionHash" gencodec:"required"`
	ContractAddress *common.Address `json:"contractAddress"`
	GasUsed         uint64          `json:"gasUsed" gencodec:"required"`
	Out             []byte          `json:"out" gencodec:"required"`
	Error           string          `json:"error"`
}

Receipt represents the results of a transaction.

func NewReceipt

func NewReceipt(gasFee *big.Int, root []byte, err error, cumulativeGasUsed uint64) *Receipt

NewReceipt creates a barebone transaction receipt, copying the init fields.

func ReadReceipt

func ReadReceipt(receipts Receipts, index int) (*Receipt, error)

ReadReceipt retrieves a specific transaction receipt from the database, along with its added positional metadata.

func (*Receipt) GasFeeString

func (r *Receipt) GasFeeString() string

func (*Receipt) GetPostRoot

func (r *Receipt) GetPostRoot() []byte

func (*Receipt) String

func (r *Receipt) String() string

type Receipts

type Receipts []*Receipt

func ReadReceipts

func ReadReceipts(db dataBase.Database, hash common.Hash) Receipts

ReadReceipts retrieves all the transaction receipts belonging to a block.

func (Receipts) Len

func (r Receipts) Len() int

Len returns the number of receipts in this list.

type RelayEventMsg

type RelayEventMsg struct {
	RType     RelayType
	FromChain common.ChainID
	ToChainID common.ChainID
	ToNetType common.NetType
	ToNodeID  *common.NodeID
	Msg       interface{}
	Pub       []byte
	Sig       []byte
}

RelayEvent Used to forward messages to other networks asynchronously

func (*RelayEventMsg) GetPubAndSig

func (msg *RelayEventMsg) GetPubAndSig() ([]byte, []byte)

func (*RelayEventMsg) String

func (msg *RelayEventMsg) String() string

type RelayType

type RelayType byte

Control class message, carefully forward on the network. The message body is not guaranteed to be serializable or deserialized. Because of the single execution, there is no need to check the repetition

const (
	// Data forwarding mode
	RelayBroadcast     RelayType = iota // broadcast
	RelaySendTo                         // Directional transmission to a specific node
	RelayRandBroadcast                  // Random sending
)

type ReportNodeInfoEMessage

type ReportNodeInfoEMessage struct {
	NodeID common.NodeID
}

func (*ReportNodeInfoEMessage) GetChainID

func (m *ReportNodeInfoEMessage) GetChainID() common.ChainID

func (*ReportNodeInfoEMessage) String

func (m *ReportNodeInfoEMessage) String() string

type RewardRequest

type RewardRequest struct {
	ChainId      common.ChainID
	CommitteePks [][]byte          // The public key list of the members of the current committee in the order of proposing
	Epoch        common.EpochNum   // Epoch where the reward is declared
	LastHeader   *BlockHeader      // The block header of the last block of the epoch declared
	Attendance   *AttendanceRecord // The attendance table of the last block, which contains the attendance records of the entire epoch
	PASs         PubAndSigs        // Signature list for the last block
}

func (*RewardRequest) DestChainID

func (a *RewardRequest) DestChainID() common.ChainID

func (*RewardRequest) Formalize

func (a *RewardRequest) Formalize()

func (*RewardRequest) GetChainID

func (a *RewardRequest) GetChainID() common.ChainID

func (*RewardRequest) Hash

func (a *RewardRequest) Hash() common.Hash

func (*RewardRequest) HashValue

func (a *RewardRequest) HashValue() ([]byte, error)

func (*RewardRequest) String

func (a *RewardRequest) String() string

type RewardRequests

type RewardRequests []*RewardRequest

func (RewardRequests) Len

func (rs RewardRequests) Len() int

func (RewardRequests) Less

func (rs RewardRequests) Less(i, j int) bool

func (RewardRequests) Swap

func (rs RewardRequests) Swap(i, j int)

type SeedFactor

type SeedFactor []byte

type SetChainSettingRequest

type SetChainSettingRequest struct {
	Data *ChainSetting // request content of setting
	Sigs [][]byte      // signature list
	Pubs [][]byte      // public key list corresponding to signature one by one
}

func (*SetChainSettingRequest) DataDeserialize

func (s *SetChainSettingRequest) DataDeserialize(vr rtl.ValueReader) error

func (*SetChainSettingRequest) DataSerialize

func (s *SetChainSettingRequest) DataSerialize(w io.Writer) error

func (*SetChainSettingRequest) Deserialization

func (s *SetChainSettingRequest) Deserialization(r io.Reader) (shouldBeNil bool, err error)

func (*SetChainSettingRequest) GetData

func (s *SetChainSettingRequest) GetData() (o interface{}, exist bool)

func (*SetChainSettingRequest) GetPubs

func (s *SetChainSettingRequest) GetPubs() [][]byte

func (*SetChainSettingRequest) GetSigs

func (s *SetChainSettingRequest) GetSigs() [][]byte

func (*SetChainSettingRequest) Serialization

func (s *SetChainSettingRequest) Serialization(w io.Writer) error

func (*SetChainSettingRequest) SetPubs

func (s *SetChainSettingRequest) SetPubs(pubs [][]byte)

func (*SetChainSettingRequest) SetSigs

func (s *SetChainSettingRequest) SetSigs(sigs [][]byte)

func (*SetChainSettingRequest) String

func (s *SetChainSettingRequest) String() string

type SevereErrorEventMsg

type SevereErrorEventMsg struct {
	ChainID common.ChainID
	Err     error
}

Unknown error found

func (*SevereErrorEventMsg) String

func (msg *SevereErrorEventMsg) String() string

type ShardDeltaMessage

type ShardDeltaMessage struct {
	ToChainID       common.ChainID
	FromBlockHeader *BlockHeader
	Proof           []common.Hash
	Deltas          []*AccountDelta
}

The shard chain is used to send to other shards the AccountDelta list processed by this shard should fall on the other shard. Including block header and the proof

func (*ShardDeltaMessage) DestChainID

func (m *ShardDeltaMessage) DestChainID() common.ChainID

func (*ShardDeltaMessage) GetChainID

func (m *ShardDeltaMessage) GetChainID() common.ChainID

func (*ShardDeltaMessage) String

func (m *ShardDeltaMessage) String() string

type ShardTransaction

type ShardTransaction struct {
	ToChainID common.ChainID
	Tx        *Transaction
}

func (*ShardTransaction) GetChainID

func (s *ShardTransaction) GetChainID() common.ChainID

type ShardWaterline

type ShardWaterline struct {
	ShardID common.ChainID // shard id
	Line    common.Height  // the height of the shard that deltas are to be merged next
}

func (ShardWaterline) Equals

func (s ShardWaterline) Equals(o ShardWaterline) bool

func (ShardWaterline) HashValue

func (s ShardWaterline) HashValue() ([]byte, error)

func (ShardWaterline) String

func (s ShardWaterline) String() string

type Signer

type Signer interface {
	// Sender returns the sender address of the transaction.
	Sender(tx *ETHTransaction) (common.Address, error)

	// SignatureValues returns the raw R, S, V values corresponding to the
	// given signature.
	SignatureValues(tx *ETHTransaction, sig []byte) (r, s, v *big.Int, err error)

	// Hash returns 'signature hash', i.e. the transaction hash that is signed by the
	// private key. This hash does not uniquely identify the transaction.
	Hash(tx *ETHTransaction) common.Hash
	HashGtkm(tx *Transaction) common.Hash
	HashGtkmWithSig(tx *Transaction) common.Hash
	// Equal returns true if the given signer is the same as the receiver.
	Equal(Signer) bool
	RecoverSigAndPub(tx *ETHTransaction) (sig, pub []byte, err error)
}

Signer encapsulates transaction signature handling. The name of this type is slightly misleading because Signers don't actually sign, they're just for validating and processing of signatures.

Note that this interface is not a stable API and may change at any time to accommodate new protocol rules.

var ETHSigner Signer = NewLondonSigner()

func NewEIP2930Signer

func NewEIP2930Signer() Signer

NewEIP2930Signer returns a signer that accepts EIP-2930 access list transactions, EIP-155 replay protected transactions, and legacy Homestead transactions.

func NewEIP2930Signer(chainId *big.Int) Signer {
	return eip2930Signer{NewEIP155Signer(chainId)}

func NewLondonSigner

func NewLondonSigner() Signer

NewLondonSigner returns a signer that accepts - EIP-1559 dynamic fee transactions - EIP-2930 access list transactions, - EIP-155 replay protected transactions, and - legacy Homestead transactions.

func NewLondonSigner(chainId *big.Int) Signer {
	return londonSigner{eip2930Signer{NewEIP155Signer(chainId)}}

type SigsAndPubs

type SigsAndPubs struct {
	Sigs [][]byte // signature list
	Pubs [][]byte // List of public keys corresponding to the signature list one-to-one
}

func (*SigsAndPubs) GetPubs

func (sp *SigsAndPubs) GetPubs() [][]byte

func (*SigsAndPubs) GetSigs

func (sp *SigsAndPubs) GetSigs() [][]byte

func (*SigsAndPubs) SetPubs

func (sp *SigsAndPubs) SetPubs(pubs [][]byte)

func (*SigsAndPubs) SetSigs

func (sp *SigsAndPubs) SetSigs(sigs [][]byte)

type Sourcer

type Sourcer interface {
	Source() common.NodeID
}

type StartCommEMessage

type StartCommEMessage struct {
	Comms []CommEntry
}

func (*StartCommEMessage) GetChainID

func (m *StartCommEMessage) GetChainID() common.ChainID

func (*StartCommEMessage) GetComm

func (m *StartCommEMessage) GetComm(id common.ChainID) *Committee

func (*StartCommEMessage) Hash

func (m *StartCommEMessage) Hash() common.Hash

func (*StartCommEMessage) String

func (m *StartCommEMessage) String() string

type StartConsEMessage

type StartConsEMessage struct {
	ChainID common.ChainID
	Height  common.Height
}

func (*StartConsEMessage) GetChainID

func (m *StartConsEMessage) GetChainID() common.ChainID

func (*StartConsEMessage) String

func (m *StartConsEMessage) String() string

type StartEMessage

type StartEMessage struct {
	Timestamp int64
	Signature []byte
}

func CreateStartMessage

func CreateStartMessage() (*StartEMessage, error)

func (*StartEMessage) GetChainID

func (m *StartEMessage) GetChainID() common.ChainID

func (*StartEMessage) String

func (m *StartEMessage) String() string

func (*StartEMessage) Verify

func (m *StartEMessage) Verify() error

type StateDB

type StateDB interface {
	// Whether there is a local currency, if so, the last one method will return the local currency
	// information. Otherwise, the latter one method return basic currency information
	HasLocalCurrency() bool
	GetChainLocalCurrencyInfo(chainID common.ChainID) (common.CoinID, string)
	// Get the list of administrator public keys of the current chain. If there is a valid value,
	// the second return value will return true, otherwise it will return false
	GetAdmins() ([][]byte, bool)
	ResetState(stateTrie *trie.Trie)

	CreateAccount(common.Address)

	HasToken(addr common.Address) bool

	NoBalance(addr common.Address) bool
	SubBalance(common.Address, *big.Int)
	AddBalance(common.Address, *big.Int)
	GetBalance(common.Address) *big.Int

	NoLocalCurrency(addr common.Address) bool
	SubLocalCurrency(common.Address, *big.Int)
	AddLocalCurrency(common.Address, *big.Int)
	GetLocalCurrency(common.Address) *big.Int

	GetNonce(common.Address) uint64
	SetNonce(common.Address, uint64)

	GetCodeHash(common.Address) common.Hash
	GetCode(common.Address) []byte
	SetCode(common.Address, []byte)
	GetCodeByHash(codeHash common.Hash) []byte
	GetCodeSize(common.Address) int

	AddRefund(uint64)
	SubRefund(uint64)
	GetRefund() uint64

	GetState(common.Address, common.Hash) common.Hash
	SetState(common.Address, common.Hash, common.Hash)

	GetLong(addr common.Address, key common.Hash) []byte
	GetConsistantLong(addr common.Address, key common.Hash) []byte
	SetLong(addr common.Address, key common.Hash, value []byte)

	GetLongAsObject(addr common.Address, key common.Hash, obj interface{}) error
	SetLongAsObject(addr common.Address, key common.Hash, obj interface{}) error

	Suicide(common.Address) bool
	HasSuicided(common.Address) bool

	// Exist reports whether the given account exists in state.
	// Notably this should also return true for suicided accounts.
	Exist(common.Address) bool
	Empty(common.Address) bool

	ClearObjectCache()

	RevertToSnapshot(int)
	Snapshot() int

	AddLog(common.Hash, uint, *Log)
	AddPreimage(common.Hash, []byte)

	GetOrNewStateObject(addr common.Address) AccountState

	GetLogs(hash common.Hash) []*Log

	Prepare(block *BlockEMessage, operations ...VerifyCallback) error
	// PreCommit(rootShouldBe []byte) ([]byte, error)
	Commit(block *BlockEMessage, verifies []VerifyCallback, commits []CommitCallback) error

	RestoreDeltasLocked()
	ListAllDeltaFroms() DeltaFroms
	PutAllDeltaFroms(deltaFroms DeltaFroms)
	SyncWaterlines(waterlines []ShardWaterline, logger logrus.FieldLogger)
	GetDeltaToBeSent() common.Height
	SetDeltaToBeSent(height common.Height)
	ProposeWaterlines() (Waterlines, error)

	GetOriginHash() ([]byte, error)
	DeltasSnapShot() []ShardWaterline
	SaveReceivedDelta(fromID common.ChainID, height common.Height, deltas []*AccountDelta) (
		overflow bool, waterline common.Height, overflowed []*DeltaFrom, missing bool,
		missingLength int, err error)
	SaveDeltasGroup(fromID common.ChainID, group DeltasGroup) (overflow bool,
		waterline common.Height, overflowed []*DeltaFrom, missing bool, missingLength int, err error)
	GetWaterLine(fromID common.ChainID) common.Height
	PopDeltaFroms() DeltaFroms
	ReadOnlyCall(tx *Transaction, senderSig *PubAndSig, blockHeader *BlockHeader) (interface{}, error)
	ReadOnly() StateDB
	Propose(froms DeltaFroms, deltaTrie *AccountDeltaTrie, txs []*Transaction, pas []*PubAndSig,
		header *BlockHeader, result *ProposeResult, operations ...GenerateCallback) (err error)
	ForceCommit() error
	GetOriginAccount(addr common.Address) (*Account, bool)
	CreateTestAccount(addr common.Address, balance *big.Int) error
	Rollback()
	GetSettingGasLimit(tx *Transaction) uint64
	GetSettingGasPrice(tx *Transaction) *big.Int
}

StateDB is an EVM database for full state querying.

func NewStateDB

func NewStateDB(chainID common.ChainID, shardInfo common.ShardInfo, t *trie.Trie, dbase db.Database,
	dmanager DataManager) StateDB

type StopEMessage

type StopEMessage struct {
	Timestamp int64
	Signature []byte
}

func CreateStopMessage

func CreateStopMessage() (*StopEMessage, error)

func (*StopEMessage) GetChainID

func (m *StopEMessage) GetChainID() common.ChainID

func (*StopEMessage) String

func (m *StopEMessage) String() string

func (*StopEMessage) Verify

func (m *StopEMessage) Verify() error

type StorageEntries

type StorageEntries []StorageEntry

func (StorageEntries) String

func (es StorageEntries) String() string

type StorageEntry

type StorageEntry struct {
	All int
	Num int
	K   common.Hash
	V   []EntryHashHash
}

func (StorageEntry) Count

func (e StorageEntry) Count() int

type StorageSize

type StorageSize float64

type SyncFinish

type SyncFinish struct {
	ChainID   common.ChainID
	NodeID    common.NodeID // Nodeid to request synchronization
	EndHeight common.Height
	Timestamp int
}

func (*SyncFinish) GetChainID

func (s *SyncFinish) GetChainID() common.ChainID

func (*SyncFinish) Source

func (s *SyncFinish) Source() common.NodeID

func (*SyncFinish) String

func (s *SyncFinish) String() string

type SyncRequest

type SyncRequest struct {
	ChainID     common.ChainID
	NodeID      common.NodeID // Nodeid to request synchronization
	ToNode      common.NodeID
	AllBlock    bool // true: indicates synchronization from the first block, false: Indicates that synchronization starts from the current state
	StartHeight common.Height
	RpcAddr     string
	Timestamp   int
}

func (*SyncRequest) GetChainID

func (s *SyncRequest) GetChainID() common.ChainID

func (*SyncRequest) Source

func (s *SyncRequest) Source() common.NodeID

func (*SyncRequest) String

func (s *SyncRequest) String() string

type TXIndex

type TXIndex struct {
	BlockHeight uint64
	BlockHash   common.Hash
	Index       uint32
}

TXIndex Transaction index

func NewTXIndex

func NewTXIndex(blockHeight uint64, blockHash common.Hash, index uint32) *TXIndex

func (*TXIndex) String

func (i *TXIndex) String() string

type TextEMessage

type TextEMessage struct {
	Body string
}

type ThresholdEvent

type ThresholdEvent interface {
	ChainEvent
	// Whether the current message can join the queue according to the threshold value, threshold can be nil
	Pass(threshold interface{}) bool
}

type ToOneEMessage

type ToOneEMessage struct {
	From        common.NodeID
	To          common.NodeID
	NeedRespond bool
	Type        EventType
	Body        []byte
}

func (*ToOneEMessage) Source

func (m *ToOneEMessage) Source() common.NodeID

type Transaction

type Transaction struct {
	ChainID   common.ChainID  `json:"chainID"`   // The chain ID that needs to process this transaction
	From      *common.Address `json:"from"`      // Address of transaction transmitter
	To        *common.Address `json:"to"`        // Address of transaction receiver
	Nonce     uint64          `json:"nonce"`     // Nonce of sender account
	UseLocal  bool            `json:"uselocal"`  // true: local currency,false: basic currency; default false
	Val       *big.Int        `json:"value"`     // Amount of the transaction
	Input     hexutil.Bytes   `json:"input"`     // Contract code/initial parameters when creating a contract, or input parameters when calling a contract
	Extra     hexutil.Bytes   `json:"extra"`     // Store transaction additional information
	Version   uint16          `json:"version"`   // Version number used to distinguish different execution methods when the transaction execution is incompatible due to upgrade
	MultiSigs PubAndSigs      `json:"multiSigs"` // The signatures used to sign this transaction will only be used when there are multiple signatures. The signature of the transaction sender is not here. Not included in Hash
	// contains filtered or unexported fields
}

func (*Transaction) AccessList

func (tx *Transaction) AccessList() AccessList

func (*Transaction) Clone

func (tx *Transaction) Clone() *Transaction

func (Transaction) DeprecatedHash

func (tx Transaction) DeprecatedHash() ([]byte, error)

DeprecatedHash TODO delete compatible when restart the chain with new version Deprecated

func (*Transaction) ETHChainID

func (tx *Transaction) ETHChainID() *big.Int

func (*Transaction) ExtraKeys

func (tx *Transaction) ExtraKeys() (extra *Extra)

EthKeys Type returns the ethtransaction type.

func (Transaction) FullString

func (tx Transaction) FullString() string

func (*Transaction) Gas

func (tx *Transaction) Gas() uint64

func (*Transaction) GasFeeCap

func (tx *Transaction) GasFeeCap() *big.Int

func (*Transaction) GasPrice

func (tx *Transaction) GasPrice() *big.Int

func (*Transaction) GasTipCap

func (tx *Transaction) GasTipCap() *big.Int

func (Transaction) GetChainID

func (tx Transaction) GetChainID() common.ChainID

func (*Transaction) GetTkmExtra

func (tx *Transaction) GetTkmExtra() []byte

func (*Transaction) Hash

func (tx *Transaction) Hash() common.Hash

func (Transaction) HashValue

func (tx Transaction) HashValue() ([]byte, error)

func (*Transaction) RawSignatureValues

func (tx *Transaction) RawSignatureValues() (v, r, s *big.Int)

func (*Transaction) SetExtraKeys

func (tx *Transaction) SetExtraKeys(extras *Extra) error

func (*Transaction) SetTkmExtra

func (tx *Transaction) SetTkmExtra(extra []byte) error

func (Transaction) String

func (tx Transaction) String() string

func (*Transaction) Type

func (tx *Transaction) Type() byte

Type returns the ethtransaction type of tx.

type TxData

type TxData interface {
	TxType() byte // returns the type ID
	// contains filtered or unexported methods
}

TxData This is implemented by DynamicFeeTx, LegacyTx and AccessListTx.

type VerifyCallback

type VerifyCallback func(block *BlockEMessage) error

The callback function executed after the transaction is executed when the data block is verified block: verifying block

type VrfResulter

type VrfResulter interface {
	GetNodeID() common.NodeID
	GetVrfResult() (sortHash *common.Hash, proof []byte, factorHash *common.Hash)
	VrfVerify(seed common.Seed) error
}

Election type interface based on VRF algorithm

type WantDetailEMessage

type WantDetailEMessage struct {
	Hash common.Hash // hash of eventLoad
}

type Waterlines

type Waterlines []ShardWaterline

It is used to save the ordered waterlines of all other shards in the same group after the execution of this block in this chain

func (Waterlines) Equals

func (ws Waterlines) Equals(os Waterlines) bool

func (Waterlines) HashValue

func (ws Waterlines) HashValue() ([]byte, error)

func (Waterlines) Len

func (ws Waterlines) Len() int

func (Waterlines) Less

func (ws Waterlines) Less(i, j int) bool

func (Waterlines) Swap

func (ws Waterlines) Swap(i, j int)

type WholeWorld

type WholeWorld struct {
	State        *trie.Trie
	Chains       *trie.Trie
	History      *trie.HistoryTree
	Waterlines   []ShardWaterline
	Vcc          *trie.Trie
	Cashed       *trie.Trie
	RREra        *common.EraNum
	RRCurrent    *trie.Trie
	RRNext       *trie.Trie
	RRChanging   *trie.Trie
	PreElectings PreElectings
}

func (*WholeWorld) String

func (ww *WholeWorld) String() string

type Withdrawing

type Withdrawing struct {
	Demand common.EraNum // Withdraw execution era (WithdrawDelayEras lagging after the application execution Era)
	Amount *big.Int      // Withdraw amount, if it is nil, it means all withdrawing
}

func (*Withdrawing) Equals

func (w *Withdrawing) Equals(o *Withdrawing) bool

func (*Withdrawing) Expired

func (w *Withdrawing) Expired(era common.EraNum) bool

func (*Withdrawing) String

func (w *Withdrawing) String() string

type Withdrawings

type Withdrawings []*Withdrawing

func (Withdrawings) All

func (ws Withdrawings) All() (withdrawing *big.Int, withdrawingAll bool)

The total amount withdrawing to be withdrawed in the current withdrawing list. If all withdrawing are made, withdrawingAll is true, and the withdrawing value is meaningless

func (Withdrawings) Clone

func (ws Withdrawings) Clone() Withdrawings

func (Withdrawings) Equals

func (ws Withdrawings) Equals(os Withdrawings) bool

func (Withdrawings) GetWithdrawing

func (ws Withdrawings) GetWithdrawing(expireEra common.EraNum) *Withdrawing

func (Withdrawings) Len

func (ws Withdrawings) Len() int

func (Withdrawings) Less

func (ws Withdrawings) Less(i, j int) bool

func (Withdrawings) String

func (ws Withdrawings) String() string

func (Withdrawings) Swap

func (ws Withdrawings) Swap(i, j int)

Jump to

Keyboard shortcuts

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