Documentation ¶
Index ¶
- Constants
- func BuildKeccak256MerkleTree(data [][]byte) [][]byte
- func CalcMerkleRoot(txns []metadata.Transaction) common.Hash
- func CreateAllCrossShardBlock(shardBlock *ShardBlock, activeShards int) map[byte]*CrossShardBlock
- func CreateShardTxRoot(txList []metadata.Transaction) ([]common.Hash, []common.Hash)
- func GetKeccak256MerkleProofFromTree(merkles [][]byte, id int) ([][]byte, []bool)
- func GetKeccak256MerkleRoot(data [][]byte) []byte
- func GetMerklePathCrossShard(txList []metadata.Transaction, shardID byte) (merklePathShard []common.Hash, merkleShardRoot common.Hash)
- func NextPowerOfTwo(n int) int
- func VerifyCrossShardBlockUTXO(block *CrossShardBlock) bool
- type BeaconBlock
- func (beaconBlock *BeaconBlock) AddValidationField(validationData string)
- func (beaconBlock BeaconBlock) BodyHash() common.Hash
- func (beaconBlock BeaconBlock) CommitteeFromBlock() common.Hash
- func (beaconBlock BeaconBlock) FullHashString() string
- func (beaconBlock *BeaconBlock) GetAggregateRootHash() common.Hash
- func (beaconBlock BeaconBlock) GetBeaconHeight() uint64
- func (beaconBlock BeaconBlock) GetConsensusType() string
- func (beaconBlock BeaconBlock) GetCurrentEpoch() uint64
- func (beaconBlock BeaconBlock) GetFinalityHeight() uint64
- func (beaconBlock BeaconBlock) GetHeight() uint64
- func (beaconBlock BeaconBlock) GetInstructions() [][]string
- func (beaconBlock *BeaconBlock) GetPrevHash() common.Hash
- func (beaconBlock *BeaconBlock) GetProduceTime() int64
- func (beaconBlock BeaconBlock) GetProducer() string
- func (beaconBlock BeaconBlock) GetProducerPubKeyStr() string
- func (beaconBlock *BeaconBlock) GetProposeTime() int64
- func (beaconBlock *BeaconBlock) GetProposer() string
- func (beaconBlock BeaconBlock) GetRound() int
- func (beaconBlock BeaconBlock) GetRoundKey() string
- func (beaconBlock BeaconBlock) GetShardID() int
- func (beaconBlock BeaconBlock) GetValidationField() string
- func (beaconBlock *BeaconBlock) GetVersion() int
- func (beaconBlock BeaconBlock) Hash() *common.Hash
- func (beaconBlock BeaconBlock) ProposeHash() *common.Hash
- func (beaconBlock *BeaconBlock) SetValidationField(valData string)
- func (beaconBlock BeaconBlock) Type() string
- func (beaconBlock *BeaconBlock) UnmarshalJSON(data []byte) error
- type BeaconBody
- type BeaconHeader
- type BlockConsensusData
- type BlockInterface
- type BlockPoolInterface
- type ContentCrossShardTokenPrivacyData
- type CrossOutputCoin
- type CrossShardBlock
- func (block *CrossShardBlock) AddValidationField(validationData string)
- func (block CrossShardBlock) BodyHash() common.Hash
- func (crossShardBlock CrossShardBlock) CommitteeFromBlock() common.Hash
- func (block CrossShardBlock) FullHashString() string
- func (crossShardBlock *CrossShardBlock) GetAggregateRootHash() common.Hash
- func (block CrossShardBlock) GetBeaconHeight() uint64
- func (block CrossShardBlock) GetConsensusType() string
- func (crossShardBlock CrossShardBlock) GetCurrentEpoch() uint64
- func (crossShardBlock *CrossShardBlock) GetFinalityHeight() uint64
- func (block CrossShardBlock) GetHeight() uint64
- func (block CrossShardBlock) GetInstructions() [][]string
- func (crossShardBlock CrossShardBlock) GetPrevHash() common.Hash
- func (crossShardBlock CrossShardBlock) GetProduceTime() int64
- func (block CrossShardBlock) GetProducer() string
- func (crossShardBlock CrossShardBlock) GetProposeTime() int64
- func (crossShardBlock CrossShardBlock) GetProposer() string
- func (block CrossShardBlock) GetRound() int
- func (block CrossShardBlock) GetRoundKey() string
- func (block CrossShardBlock) GetShardID() int
- func (block CrossShardBlock) GetValidationField() string
- func (block CrossShardBlock) GetVersion() int
- func (crossShardBlock *CrossShardBlock) Hash() *common.Hash
- func (block CrossShardBlock) ProposeHash() *common.Hash
- func (block CrossShardBlock) SetValidationField(string)
- func (block CrossShardBlock) Type() string
- func (crossShardBlock *CrossShardBlock) UnmarshalJSON(data []byte) error
- type CrossShardTokenPrivacyMetaData
- type CrossTokenPrivacyData
- type CrossTransaction
- type Merkle
- func (merkle Merkle) BuildMerkleTreeOfHashes(shardsHash []*common.Hash, length int) []*common.Hash
- func (merkle Merkle) BuildMerkleTreeOfHashes2(shardsHashes []common.Hash, length int) []common.Hash
- func (merkle Merkle) BuildMerkleTreeStore(transactions []metadata.Transaction) []*common.Hash
- func (merkle Merkle) GetMerklePathForCrossShard(length int, merkleTree []common.Hash, shardID byte) (merklePathShard []common.Hash, merkleShardRoot common.Hash)
- func (merkle Merkle) VerifyMerkleRootFromMerklePath(leaf common.Hash, merklePath []common.Hash, merkleRoot common.Hash, ...) bool
- func (merkle Merkle) VerifyMerkleRootOfHashes(merkleTree []*common.Hash, merkleRoot *common.Hash, length int) bool
- func (merkle Merkle) VerifyMerkleRootOfHashes2(merkleTree []common.Hash, merkleRoot common.Hash, length int) bool
- type ShardBlock
- func (shardBlock *ShardBlock) AddTransaction(tx metadata.Transaction) error
- func (block *ShardBlock) AddValidationField(validationData string)
- func (block ShardBlock) BodyHash() common.Hash
- func (shardBlock *ShardBlock) BuildShardBlockBody(instructions [][]string, crossTransaction map[byte][]CrossTransaction, ...)
- func (shardBlock *ShardBlock) CommitteeFromBlock() common.Hash
- func (shardBlock ShardBlock) FullHashString() string
- func (shardBlock *ShardBlock) GetAggregateRootHash() common.Hash
- func (block ShardBlock) GetBeaconHeight() uint64
- func (block ShardBlock) GetConsensusType() string
- func (block ShardBlock) GetCurrentEpoch() uint64
- func (shardBlock ShardBlock) GetFinalityHeight() uint64
- func (block ShardBlock) GetHeight() uint64
- func (block ShardBlock) GetInstructions() [][]string
- func (shardBlock *ShardBlock) GetPrevHash() common.Hash
- func (shardBlock *ShardBlock) GetProduceTime() int64
- func (block ShardBlock) GetProducer() string
- func (block ShardBlock) GetProducerPubKeyStr() string
- func (shardBlock *ShardBlock) GetProposeTime() int64
- func (shardBlock *ShardBlock) GetProposer() string
- func (block ShardBlock) GetRound() int
- func (block ShardBlock) GetRoundKey() string
- func (shardBlock *ShardBlock) GetShardID() int
- func (block ShardBlock) GetValidationField() string
- func (block ShardBlock) GetVersion() int
- func (shardBlock ShardBlock) Hash() *common.Hash
- func (shardBlock ShardBlock) ProposeHash() *common.Hash
- func (block *ShardBlock) SetValidationField(valData string)
- func (block ShardBlock) Type() string
- func (shardBlock *ShardBlock) UnmarshalJSON(data []byte) error
- type ShardBody
- type ShardHeader
- type ShardState
Constants ¶
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 ¶
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 ¶
====================New Merkle Tree================ CreateShardTxRoot create root hash for cross shard transaction this root hash will be used be received shard
func GetKeccak256MerkleRoot ¶
func NextPowerOfTwo ¶
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:
- CrossTransactionFinalHash
- TxTokenDataVoutFinalHash
- 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 (*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 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 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 ¶
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 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) BuildMerkleTreeOfHashes2 ¶
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) VerifyMerkleRootFromMerklePath ¶
func (Merkle) VerifyMerkleRootOfHashes ¶
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) ExtractOutgoingCrossShardMap ¶
func (*ShardBody) UnmarshalJSON ¶
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