types

package
v0.0.0-...-7ece11e Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2023 License: MIT Imports: 17 Imported by: 4

Documentation ¶

Index ¶

Constants ¶

View Source
const (
	SHARD_BLOCK_VERSION         = 1
	BFT_VERSION                 = 1
	MULTI_VIEW_VERSION          = 2
	SHARD_SFV2_VERSION          = 3
	SHARD_SFV3_VERSION          = 5
	LEMMA2_VERSION              = 6
	BLOCK_PRODUCINGV3_VERSION   = 7
	INSTANT_FINALITY_VERSION    = 8
	INSTANT_FINALITY_VERSION_V2 = 9
	ADJUST_BLOCKTIME_VERSION    = 10
)

Variables ¶

This section is empty.

Functions ¶

func BuildKeccak256MerkleTree ¶

func BuildKeccak256MerkleTree(data [][]byte) [][]byte

BuildKeccak256MerkleTree creates a merkle tree using Keccak256 hash func. This merkle tree is used for storing all beacon (and bridge) data to relay them to Ethereum.

func CalcMerkleRoot ¶

func CalcMerkleRoot(txns []metadata.Transaction) common.Hash

func CreateAllCrossShardBlock ¶

func CreateAllCrossShardBlock(shardBlock *ShardBlock, activeShards int) map[byte]*CrossShardBlock

func CreateShardTxRoot ¶

func CreateShardTxRoot(txList []metadata.Transaction) ([]common.Hash, []common.Hash)

====================New Merkle Tree================ CreateShardTxRoot create root hash for cross shard transaction this root hash will be used be received shard

func GetKeccak256MerkleProofFromTree ¶

func GetKeccak256MerkleProofFromTree(merkles [][]byte, id int) ([][]byte, []bool)

func GetKeccak256MerkleRoot ¶

func GetKeccak256MerkleRoot(data [][]byte) []byte

func GetMerklePathCrossShard ¶

func GetMerklePathCrossShard(txList []metadata.Transaction, shardID byte) (merklePathShard []common.Hash, merkleShardRoot common.Hash)

func NextPowerOfTwo ¶

func NextPowerOfTwo(n int) int

nextPowerOfTwo returns the next highest power of two from a given number if it is not already a power of two. This is a helper function used during the calculation of a merkle tree.

func VerifyCrossShardBlockUTXO ¶

func VerifyCrossShardBlockUTXO(block *CrossShardBlock) bool

VerifyCrossShardBlockUTXO Calculate Final Hash as Hash of:

  1. CrossTransactionFinalHash
  2. TxTokenDataVoutFinalHash
  3. CrossTxTokenPrivacyData

These hashes will be calculated as comment in getCrossShardDataHash function

Types ¶

type BeaconBlock ¶

type BeaconBlock struct {
	ValidationData string `json:"ValidationData"`
	Body           BeaconBody
	Header         BeaconHeader
}

func NewBeaconBlock ¶

func NewBeaconBlock() *BeaconBlock

func (*BeaconBlock) AddValidationField ¶

func (beaconBlock *BeaconBlock) AddValidationField(validationData string)

func (BeaconBlock) BodyHash ¶

func (beaconBlock BeaconBlock) BodyHash() common.Hash

func (BeaconBlock) CommitteeFromBlock ¶

func (beaconBlock BeaconBlock) CommitteeFromBlock() common.Hash

func (BeaconBlock) FullHashString ¶

func (beaconBlock BeaconBlock) FullHashString() string

func (*BeaconBlock) GetAggregateRootHash ¶

func (beaconBlock *BeaconBlock) GetAggregateRootHash() common.Hash

func (BeaconBlock) GetBeaconHeight ¶

func (beaconBlock BeaconBlock) GetBeaconHeight() uint64

func (BeaconBlock) GetConsensusType ¶

func (beaconBlock BeaconBlock) GetConsensusType() string

func (BeaconBlock) GetCurrentEpoch ¶

func (beaconBlock BeaconBlock) GetCurrentEpoch() uint64

func (BeaconBlock) GetFinalityHeight ¶

func (beaconBlock BeaconBlock) GetFinalityHeight() uint64

func (BeaconBlock) GetHeight ¶

func (beaconBlock BeaconBlock) GetHeight() uint64

func (BeaconBlock) GetInstructions ¶

func (beaconBlock BeaconBlock) GetInstructions() [][]string

func (*BeaconBlock) GetPrevHash ¶

func (beaconBlock *BeaconBlock) GetPrevHash() common.Hash

func (*BeaconBlock) GetProduceTime ¶

func (beaconBlock *BeaconBlock) GetProduceTime() int64

func (BeaconBlock) GetProducer ¶

func (beaconBlock BeaconBlock) GetProducer() string

func (BeaconBlock) GetProducerPubKeyStr ¶

func (beaconBlock BeaconBlock) GetProducerPubKeyStr() string

func (*BeaconBlock) GetProposeTime ¶

func (beaconBlock *BeaconBlock) GetProposeTime() int64

func (*BeaconBlock) GetProposer ¶

func (beaconBlock *BeaconBlock) GetProposer() string

func (BeaconBlock) GetRound ¶

func (beaconBlock BeaconBlock) GetRound() int

func (BeaconBlock) GetRoundKey ¶

func (beaconBlock BeaconBlock) GetRoundKey() string

func (BeaconBlock) GetShardID ¶

func (beaconBlock BeaconBlock) GetShardID() int

func (BeaconBlock) GetValidationField ¶

func (beaconBlock BeaconBlock) GetValidationField() string

func (*BeaconBlock) GetVersion ¶

func (beaconBlock *BeaconBlock) GetVersion() int

func (BeaconBlock) Hash ¶

func (beaconBlock BeaconBlock) Hash() *common.Hash

func (BeaconBlock) ProposeHash ¶

func (beaconBlock BeaconBlock) ProposeHash() *common.Hash

propose hash of beacon contain consensus info

func (*BeaconBlock) SetValidationField ¶

func (beaconBlock *BeaconBlock) SetValidationField(valData string)

func (BeaconBlock) Type ¶

func (beaconBlock BeaconBlock) Type() string

func (*BeaconBlock) UnmarshalJSON ¶

func (beaconBlock *BeaconBlock) UnmarshalJSON(data []byte) error

type BeaconBody ¶

type BeaconBody struct {
	// Shard State extract from shard to beacon block
	// Store all shard state == store content of all shard to beacon block
	ShardState   map[byte][]ShardState
	Instructions [][]string
}

func NewBeaconBody ¶

func NewBeaconBody(shardState map[byte][]ShardState, instructions [][]string) BeaconBody

func (BeaconBody) Hash ¶

func (beaconBody BeaconBody) Hash() common.Hash

func (*BeaconBody) SetInstructions ¶

func (b *BeaconBody) SetInstructions(inst [][]string)

type BeaconHeader ¶

type BeaconHeader struct {
	Version           int         `json:"Version"`
	Height            uint64      `json:"Height"`
	Epoch             uint64      `json:"Epoch"`
	Round             int         `json:"Round"`
	Timestamp         int64       `json:"Timestamp"`
	PreviousBlockHash common.Hash `json:"PreviousBlockHash"`
	InstructionHash   common.Hash `json:"InstructionHash"` // hash of all parameters == hash of instruction
	ShardStateHash    common.Hash `json:"ShardStateHash"`  // each shard will have a list of blockHash, shardRoot is hash of all list
	// Merkle root of all instructions (using Keccak256 hash func) to relay to Ethreum
	// This obsoletes InstructionHash but for simplicity, we keep it for now
	InstructionMerkleRoot           common.Hash `json:"InstructionMerkleRoot"`
	BeaconCommitteeAndValidatorRoot common.Hash `json:"BeaconCommitteeAndValidatorRoot"` //Build from two list: BeaconCommittee + BeaconPendingValidator
	BeaconCandidateRoot             common.Hash `json:"BeaconCandidateRoot"`             // CandidateBeaconWaitingForCurrentRandom + CandidateBeaconWaitingForNextRandom
	ShardCandidateRoot              common.Hash `json:"ShardCandidateRoot"`              // CandidateShardWaitingForCurrentRandom + CandidateShardWaitingForNextRandom
	ShardCommitteeAndValidatorRoot  common.Hash `json:"ShardCommitteeAndValidatorRoot"`
	AutoStakingRoot                 common.Hash `json:"AutoStakingRoot"`
	ShardSyncValidatorRoot          common.Hash `json:"ShardSyncValidatorRoot"`
	ConsensusType                   string      `json:"ConsensusType"`
	Producer                        string      `json:"Producer"`
	ProducerPubKeyStr               string      `json:"ProducerPubKeyStr"`

	//for version 2
	Proposer    string `json:"Proposer"`
	ProposeTime int64  `json:"ProposeTime"`

	//for version 6
	FinalityHeight uint64 `json:"FinalityHeight"`

	//for version 8, instant finality
	ProcessBridgeFromBlock *uint64 `json:"integer,omitempty"`

	//for beacon committee flow
	PreviousValidationData string `json:"PrevValData,omitempty"`
}

func NewBeaconHeader ¶

func NewBeaconHeader(version int, height uint64, epoch uint64, round int, timestamp int64, previousBlockHash common.Hash, consensusType string, producer string, producerPubKeyStr string, preValData string) BeaconHeader

func (*BeaconHeader) AddBeaconHeaderHash ¶

func (beaconHeader *BeaconHeader) AddBeaconHeaderHash(
	instructionHash common.Hash,
	shardStateHash common.Hash,
	instructionMerkleRoot []byte,
	beaconCommitteeAndValidatorRoot common.Hash,
	beaconCandidateRoot common.Hash,
	shardCandidateRoot common.Hash,
	shardCommitteeAndValidatorRoot common.Hash,
	autoStakingRoot common.Hash,
	shardSyncValidatorRoot common.Hash)

func (*BeaconHeader) Hash ¶

func (header *BeaconHeader) Hash() common.Hash

func (*BeaconHeader) MetaHash ¶

func (header *BeaconHeader) MetaHash() common.Hash

func (*BeaconHeader) ProposeHash ¶

func (beaconHeader *BeaconHeader) ProposeHash() common.Hash

type BlockConsensusData ¶

type BlockConsensusData struct {
	BlockHash      common.Hash
	BlockHeight    uint64
	FinalityHeight uint64
	Proposer       string
	ProposerTime   int64
	ValidationData string
}

type BlockInterface ¶

type BlockInterface interface {
	GetVersion() int
	GetHeight() uint64
	GetBeaconHeight() uint64
	Hash() *common.Hash
	ProposeHash() *common.Hash
	FullHashString() string //hash-proposehash
	//AddValidationField(validateData string) error
	GetProducer() string
	GetProduceTime() int64
	GetProposeTime() int64
	GetProposer() string
	GetValidationField() string
	SetValidationField(string)
	GetRound() int
	GetRoundKey() string
	GetInstructions() [][]string
	GetConsensusType() string
	GetCurrentEpoch() uint64
	GetPrevHash() common.Hash
	Type() string
	CommitteeFromBlock() common.Hash
	BodyHash() common.Hash
	GetAggregateRootHash() common.Hash
	GetFinalityHeight() uint64
	GetShardID() int
}

type BlockPoolInterface ¶

type BlockPoolInterface interface {
	GetPrevHash() common.Hash
	Hash() *common.Hash
	GetHeight() uint64
	GetShardID() int
	GetRound() int
	FullHashString() string //hash-proposehash
}

type ContentCrossShardTokenPrivacyData ¶

type ContentCrossShardTokenPrivacyData struct {
	OutputCoin     []coin.Coin
	PropertyID     common.Hash // = hash of TxCustomTokenprivacy data
	PropertyName   string
	PropertySymbol string
	Type           int    // action type
	Mintable       bool   // default false
	Amount         uint64 // init amount
}

func CloneTxTokenPrivacyDataForCrossShard ¶

func CloneTxTokenPrivacyDataForCrossShard(txTokenPrivacyData transaction.TxTokenData) ContentCrossShardTokenPrivacyData

func GetCrossShardData ¶

func GetCrossShardData(txList []metadata.Transaction, shardID byte) ([]privacy.Coin, []ContentCrossShardTokenPrivacyData, error)

getCrossShardData get cross data (send to a shard) from list of transaction: 1. (Privacy) PRV: Output coin 2. Tx Custom Token: Tx Token Data 3. Privacy Custom Token: Token Data + Output coin

func (ContentCrossShardTokenPrivacyData) Bytes ¶

func (contentCrossShardTokenPrivacyData ContentCrossShardTokenPrivacyData) Bytes() []byte

func (ContentCrossShardTokenPrivacyData) Hash ¶

func (contentCrossShardTokenPrivacyData ContentCrossShardTokenPrivacyData) Hash() common.Hash

func (*ContentCrossShardTokenPrivacyData) UnmarshalJSON ¶

func (contentCrossShardTokenPrivacyData *ContentCrossShardTokenPrivacyData) UnmarshalJSON(data []byte) error

type CrossOutputCoin ¶

type CrossOutputCoin struct {
	BlockHeight uint64
	BlockHash   common.Hash
	OutputCoin  []coin.Coin
}

func (CrossOutputCoin) Hash ¶

func (crossOutputCoin CrossOutputCoin) Hash() common.Hash

func (*CrossOutputCoin) UnmarshalJSON ¶

func (crossOutputCoin *CrossOutputCoin) UnmarshalJSON(data []byte) error

type CrossShardBlock ¶

type CrossShardBlock struct {
	ValidationData  string `json:"ValidationData"`
	Header          ShardHeader
	ToShardID       byte
	MerklePathShard []common.Hash
	// Cross Shard data for PRV
	CrossOutputCoin []privacy.Coin
	// Cross Shard For Custom token privacy
	CrossTxTokenPrivacyData []ContentCrossShardTokenPrivacyData
}

func CreateCrossShardBlock ¶

func CreateCrossShardBlock(shardBlock *ShardBlock, shardID byte) (*CrossShardBlock, error)

func NewCrossShardBlock ¶

func NewCrossShardBlock() *CrossShardBlock

func (*CrossShardBlock) AddValidationField ¶

func (block *CrossShardBlock) AddValidationField(validationData string)

func (CrossShardBlock) BodyHash ¶

func (block CrossShardBlock) BodyHash() common.Hash

func (CrossShardBlock) CommitteeFromBlock ¶

func (crossShardBlock CrossShardBlock) CommitteeFromBlock() common.Hash

func (CrossShardBlock) FullHashString ¶

func (block CrossShardBlock) FullHashString() string

func (*CrossShardBlock) GetAggregateRootHash ¶

func (crossShardBlock *CrossShardBlock) GetAggregateRootHash() common.Hash

func (CrossShardBlock) GetBeaconHeight ¶

func (block CrossShardBlock) GetBeaconHeight() uint64

func (CrossShardBlock) GetConsensusType ¶

func (block CrossShardBlock) GetConsensusType() string

func (CrossShardBlock) GetCurrentEpoch ¶

func (crossShardBlock CrossShardBlock) GetCurrentEpoch() uint64

func (*CrossShardBlock) GetFinalityHeight ¶

func (crossShardBlock *CrossShardBlock) GetFinalityHeight() uint64

func (CrossShardBlock) GetHeight ¶

func (block CrossShardBlock) GetHeight() uint64

func (CrossShardBlock) GetInstructions ¶

func (block CrossShardBlock) GetInstructions() [][]string

func (CrossShardBlock) GetPrevHash ¶

func (crossShardBlock CrossShardBlock) GetPrevHash() common.Hash

func (CrossShardBlock) GetProduceTime ¶

func (crossShardBlock CrossShardBlock) GetProduceTime() int64

func (CrossShardBlock) GetProducer ¶

func (block CrossShardBlock) GetProducer() string

func (CrossShardBlock) GetProposeTime ¶

func (crossShardBlock CrossShardBlock) GetProposeTime() int64

func (CrossShardBlock) GetProposer ¶

func (crossShardBlock CrossShardBlock) GetProposer() string

func (CrossShardBlock) GetRound ¶

func (block CrossShardBlock) GetRound() int

func (CrossShardBlock) GetRoundKey ¶

func (block CrossShardBlock) GetRoundKey() string

func (CrossShardBlock) GetShardID ¶

func (block CrossShardBlock) GetShardID() int

func (CrossShardBlock) GetValidationField ¶

func (block CrossShardBlock) GetValidationField() string

func (CrossShardBlock) GetVersion ¶

func (block CrossShardBlock) GetVersion() int

func (*CrossShardBlock) Hash ¶

func (crossShardBlock *CrossShardBlock) Hash() *common.Hash

func (CrossShardBlock) ProposeHash ¶

func (block CrossShardBlock) ProposeHash() *common.Hash

consensus interface

func (CrossShardBlock) SetValidationField ¶

func (block CrossShardBlock) SetValidationField(string)

func (CrossShardBlock) Type ¶

func (block CrossShardBlock) Type() string

func (*CrossShardBlock) UnmarshalJSON ¶

func (crossShardBlock *CrossShardBlock) UnmarshalJSON(data []byte) error

type CrossShardTokenPrivacyMetaData ¶

type CrossShardTokenPrivacyMetaData struct {
	TokenID        common.Hash
	PropertyName   string
	PropertySymbol string
	Type           int    // action type
	Mintable       bool   // default false
	Amount         uint64 // init amount
}

type CrossTokenPrivacyData ¶

type CrossTokenPrivacyData struct {
	BlockHeight      uint64
	BlockHash        common.Hash
	TokenPrivacyData []ContentCrossShardTokenPrivacyData
}

type CrossTransaction ¶

type CrossTransaction struct {
	BlockHeight      uint64
	BlockHash        common.Hash
	TokenPrivacyData []ContentCrossShardTokenPrivacyData
	OutputCoin       []coin.Coin
}

func (CrossTransaction) Bytes ¶

func (crossTransaction CrossTransaction) Bytes() []byte

func (CrossTransaction) Hash ¶

func (crossTransaction CrossTransaction) Hash() common.Hash

func (*CrossTransaction) UnmarshalJSON ¶

func (crossTransaction *CrossTransaction) UnmarshalJSON(data []byte) error

type Merkle ¶

type Merkle struct {
}

func (Merkle) BuildMerkleTreeOfHashes ¶

func (merkle Merkle) BuildMerkleTreeOfHashes(shardsHash []*common.Hash, length int) []*common.Hash

func (Merkle) BuildMerkleTreeOfHashes2 ¶

func (merkle Merkle) BuildMerkleTreeOfHashes2(shardsHashes []common.Hash, length int) []common.Hash

func (Merkle) BuildMerkleTreeStore ¶

func (merkle Merkle) BuildMerkleTreeStore(transactions []metadata.Transaction) []*common.Hash

BuildMerkleTreeStore creates a merkle tree from a slice of transactions, stores it using a linear array, and returns a slice of the backing array. A linear array was chosen as opposed to an actual tree structure since it uses about half as much memory. The following describes a merkle tree and how it is stored in a linear array.

A merkle tree is a tree in which every non-leaf node is the hash of its children nodes. A diagram depicting how this works for Incognito transactions where h(x) is a double sha256 follows:

         root = h1234 = h(h12 + h34)
        /                           \
  h12 = h(h1 + h2)            h34 = h(h3 + h4)
   /            \              /            \
h1 = h(tx1)  h2 = h(tx2)    h3 = h(tx3)  h4 = h(tx4)

The above stored as a linear array is as follows:

[h1 h2 h3 h4 h12 h34 root]

As the above shows, the merkle root is always the last element in the array.

The number of inputs is not always a power of two which results in a balanced tree structure as above. In that case, parent nodes with no children are also zero and parent nodes with only a single left node are calculated by concatenating the left node with itself before hashing. Since this function uses nodes that are pointers to the hashes, empty nodes will be nil.

The additional bool parameter indicates if we are generating the merkle tree using witness transaction id's rather than regular transaction id's. This also presents an additional case wherein the wtxid of the salary transaction is the zeroHash.

func (Merkle) GetMerklePathForCrossShard ¶

func (merkle Merkle) GetMerklePathForCrossShard(length int, merkleTree []common.Hash, shardID byte) (merklePathShard []common.Hash, merkleShardRoot common.Hash)

func (Merkle) VerifyMerkleRootFromMerklePath ¶

func (merkle Merkle) VerifyMerkleRootFromMerklePath(leaf common.Hash, merklePath []common.Hash, merkleRoot common.Hash, receiverShardID byte) bool

func (Merkle) VerifyMerkleRootOfHashes ¶

func (merkle Merkle) VerifyMerkleRootOfHashes(merkleTree []*common.Hash, merkleRoot *common.Hash, length int) bool

func (Merkle) VerifyMerkleRootOfHashes2 ¶

func (merkle Merkle) VerifyMerkleRootOfHashes2(merkleTree []common.Hash, merkleRoot common.Hash, length int) bool

type ShardBlock ¶

type ShardBlock struct {
	ValidationData string `json:"ValidationData"`
	Body           ShardBody
	Header         ShardHeader
}

func NewShardBlock ¶

func NewShardBlock() *ShardBlock

func NewShardBlockFull ¶

func NewShardBlockFull(header ShardHeader, body ShardBody) *ShardBlock

func NewShardBlockWithBody ¶

func NewShardBlockWithBody(body ShardBody) *ShardBlock

func NewShardBlockWithHeader ¶

func NewShardBlockWithHeader(header ShardHeader) *ShardBlock

func (*ShardBlock) AddTransaction ¶

func (shardBlock *ShardBlock) AddTransaction(tx metadata.Transaction) error

func (*ShardBlock) AddValidationField ¶

func (block *ShardBlock) AddValidationField(validationData string)

func (ShardBlock) BodyHash ¶

func (block ShardBlock) BodyHash() common.Hash

func (*ShardBlock) BuildShardBlockBody ¶

func (shardBlock *ShardBlock) BuildShardBlockBody(instructions [][]string, crossTransaction map[byte][]CrossTransaction, transactions []metadata.Transaction)

func (*ShardBlock) CommitteeFromBlock ¶

func (shardBlock *ShardBlock) CommitteeFromBlock() common.Hash

func (ShardBlock) FullHashString ¶

func (shardBlock ShardBlock) FullHashString() string

func (*ShardBlock) GetAggregateRootHash ¶

func (shardBlock *ShardBlock) GetAggregateRootHash() common.Hash

func (ShardBlock) GetBeaconHeight ¶

func (block ShardBlock) GetBeaconHeight() uint64

func (ShardBlock) GetConsensusType ¶

func (block ShardBlock) GetConsensusType() string

func (ShardBlock) GetCurrentEpoch ¶

func (block ShardBlock) GetCurrentEpoch() uint64

func (ShardBlock) GetFinalityHeight ¶

func (shardBlock ShardBlock) GetFinalityHeight() uint64

func (ShardBlock) GetHeight ¶

func (block ShardBlock) GetHeight() uint64

func (ShardBlock) GetInstructions ¶

func (block ShardBlock) GetInstructions() [][]string

func (*ShardBlock) GetPrevHash ¶

func (shardBlock *ShardBlock) GetPrevHash() common.Hash

func (*ShardBlock) GetProduceTime ¶

func (shardBlock *ShardBlock) GetProduceTime() int64

func (ShardBlock) GetProducer ¶

func (block ShardBlock) GetProducer() string

func (ShardBlock) GetProducerPubKeyStr ¶

func (block ShardBlock) GetProducerPubKeyStr() string

func (*ShardBlock) GetProposeTime ¶

func (shardBlock *ShardBlock) GetProposeTime() int64

func (*ShardBlock) GetProposer ¶

func (shardBlock *ShardBlock) GetProposer() string

func (ShardBlock) GetRound ¶

func (block ShardBlock) GetRound() int

func (ShardBlock) GetRoundKey ¶

func (block ShardBlock) GetRoundKey() string

func (*ShardBlock) GetShardID ¶

func (shardBlock *ShardBlock) GetShardID() int

func (ShardBlock) GetValidationField ¶

func (block ShardBlock) GetValidationField() string

func (ShardBlock) GetVersion ¶

func (block ShardBlock) GetVersion() int

func (ShardBlock) Hash ¶

func (shardBlock ShardBlock) Hash() *common.Hash

func (ShardBlock) ProposeHash ¶

func (shardBlock ShardBlock) ProposeHash() *common.Hash

hash related to consensus

func (*ShardBlock) SetValidationField ¶

func (block *ShardBlock) SetValidationField(valData string)

func (ShardBlock) Type ¶

func (block ShardBlock) Type() string

func (*ShardBlock) UnmarshalJSON ¶

func (shardBlock *ShardBlock) UnmarshalJSON(data []byte) error

type ShardBody ¶

type ShardBody struct {
	Instructions      [][]string
	CrossTransactions map[byte][]CrossTransaction //CrossOutputCoin from all other shard
	Transactions      []metadata.Transaction
}

func (ShardBody) ExtractIncomingCrossShardMap ¶

func (shardBody ShardBody) ExtractIncomingCrossShardMap() (map[byte][]common.Hash, error)

func (ShardBody) ExtractOutgoingCrossShardMap ¶

func (shardBody ShardBody) ExtractOutgoingCrossShardMap() (map[byte][]common.Hash, error)

func (ShardBody) Hash ¶

func (shardBody ShardBody) Hash() common.Hash

func (*ShardBody) UnmarshalJSON ¶

func (shardBody *ShardBody) UnmarshalJSON(data []byte) error

Customize UnmarshalJSON to parse list TxNormal because we have many types of block, so we can need to customize data from marshal from json string to build a block

type ShardHeader ¶

type ShardHeader struct {
	Producer              string                 `json:"Producer"`
	ProducerPubKeyStr     string                 `json:"ProducerPubKeyStr"`
	ShardID               byte                   `json:"ShardID"`               // shard ID which block belong to
	Version               int                    `json:"Version"`               // version of block structure
	PreviousBlockHash     common.Hash            `json:"PreviousBlockHash"`     // previous block hash or Parent block hash
	Height                uint64                 `json:"Height"`                // block height
	Round                 int                    `json:"Round"`                 // bpft consensus round
	Epoch                 uint64                 `json:"Epoch"`                 // epoch of block (according to current beacon height)
	CrossShardBitMap      []byte                 `json:"CrossShardBitMap"`      // crossShards bitmap for beacon
	BeaconHeight          uint64                 `json:"BeaconHeight"`          // beacon check point height
	BeaconHash            common.Hash            `json:"BeaconHash"`            // beacon check point hash
	TotalTxsFee           map[common.Hash]uint64 `json:"TotalTxsFee"`           // fee of all txs in block
	ConsensusType         string                 `json:"ConsensusType"`         // consensus type, by which this block is produced
	Timestamp             int64                  `json:"Timestamp"`             // timestamp of block
	TxRoot                common.Hash            `json:"TxRoot"`                // Transaction root created from transaction in shard
	ShardTxRoot           common.Hash            `json:"ShardTxRoot"`           // output root created for other shard
	CrossTransactionRoot  common.Hash            `json:"CrossTransactionRoot"`  // transaction root created from transaction of micro shard to shard block (from other shard)
	InstructionsRoot      common.Hash            `json:"InstructionsRoot"`      // actions root created from Instructions and Metadata of transaction
	CommitteeRoot         common.Hash            `json:"CommitteeRoot"`         // hash from public key list of all committees designated to create this block
	PendingValidatorRoot  common.Hash            `json:"PendingValidatorRoot"`  // hash from public key list of all pending validators designated to this ShardID
	StakingTxRoot         common.Hash            `json:"StakingTxRoot"`         // hash from staking transaction map in shard best state
	InstructionMerkleRoot common.Hash            `json:"InstructionMerkleRoot"` // Merkle root of all instructions (using Keccak256 hash func) to relay to Ethreum

	//for version >= 2
	Proposer    string
	ProposeTime int64

	//for version >= 3
	CommitteeFromBlock common.Hash `json:"CommitteeFromBlock"` // Block Hash Of Swapped Committees Block

	//for version 6
	FinalityHeight uint64 `json:"FinalityHeight"`
}

func (*ShardHeader) Hash ¶

func (shardHeader *ShardHeader) Hash() common.Hash

func (*ShardHeader) MetaHash ¶

func (shardHeader *ShardHeader) MetaHash() common.Hash

func (*ShardHeader) ProposeHash ¶

func (shardHeader *ShardHeader) ProposeHash() common.Hash

func (*ShardHeader) String ¶

func (shardHeader *ShardHeader) String() string

type ShardState ¶

type ShardState struct {
	ValidationData         string
	PreviousValidationData string
	CommitteeFromBlock     common.Hash
	Height                 uint64
	Hash                   common.Hash
	CrossShard             []byte //In this state, shard i send cross shard tx to which shard
	ProposerTime           int64
	Version                int
}

func NewShardState ¶

func NewShardState(validationData string,
	prevValidationData string,
	committeeFromBlock common.Hash,
	height uint64,
	hash common.Hash,
	crossShard []byte,
	proposerTime int64,
	version int,
) ShardState

Directories ¶

Path Synopsis

Jump to

Keyboard shortcuts

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