Documentation
¶
Index ¶
- Constants
- func CheckForHeightBlock(blockStash *BlockStash, height uint32) int
- func CheckForHeightCommitteeCheck(committeeCheckStash *CommitteeCheckStash, height uint32) int
- func CheckForHeightStateTransition(statestash *StateStash, height uint32) int
- func CheckForHeightTransactionAssignment(transactionAssignmentStash *TransactionAssignmentStash, height uint32) int
- func Decode(encodedData []byte, sliceSize int) (data [][]byte)
- func Encode(data [][]byte, sliceSize int) []byte
- func RandomBytes() []byte
- func RandomBytesWithLength(length int) []byte
- func ReturnBlockHashesForHeight(blockStash *BlockStash, height uint32) [][32]byte
- func SerializeHashContent(data interface{}) (hash [32]byte)
- type AccTx
- type Account
- type AggDataTx
- func (*AggDataTx) Decode(encodedTx []byte) *AggDataTx
- func (tx *AggDataTx) Encode() (encodedTx []byte)
- func (tx *AggDataTx) Hash() (hash [32]byte)
- func (tx *AggDataTx) Receiver() [32]byte
- func (tx *AggDataTx) Sender() [32]byte
- func (tx *AggDataTx) Size() uint64
- func (tx AggDataTx) String() string
- func (tx *AggDataTx) TxFee() uint64
- type AggTx
- type Block
- func (block *Block) Decode(encoded []byte) (b *Block)
- func (block *Block) Encode() []byte
- func (block *Block) EncodeHeader() []byte
- func (block *Block) GetBloomFilterSize() uint64
- func (block *Block) GetBodySize() uint64
- func (block *Block) GetHeaderSize() uint64
- func (block *Block) GetSize() uint64
- func (block *Block) GetTxDataSize() uint64
- func (block *Block) HashBlock() [32]byte
- func (block *Block) HashBlockWithoutMerkleRoot() [32]byte
- func (block *Block) InitBloomFilter(txPubKeys [][32]byte)
- func (block Block) String() string
- type BlockStash
- type ByteArray
- type Change
- type CommitteeCheck
- func NewCommitteeCheck(height int, sender [32]byte, committeeProof [crypto.COMM_PROOF_LENGTH]byte, ...) *CommitteeCheck
- func ReturnCommitteeCheckForHeight(committeeCheckStash *CommitteeCheckStash, height uint32) []*CommitteeCheck
- func ReturnCommitteeCheckForPosition(committeeCheckStash *CommitteeCheckStash, position int) (committeeCheckHash [32]byte, committeeCheck *CommitteeCheck)
- type CommitteeCheckStash
- type CommitteeTx
- func (*CommitteeTx) Decode(encoded []byte) (tx *CommitteeTx)
- func (tx *CommitteeTx) Encode() (encodedTx []byte)
- func (tx *CommitteeTx) Hash() (hash [32]byte)
- func (tx *CommitteeTx) Receiver() [32]byte
- func (tx *CommitteeTx) Sender() [32]byte
- func (tx *CommitteeTx) Size() uint64
- func (tx CommitteeTx) String() string
- func (tx *CommitteeTx) TxFee() uint64
- type ConfigTx
- func (*ConfigTx) Decode(encodedTx []byte) (tx *ConfigTx)
- func (tx *ConfigTx) Encode() (encodedTx []byte)
- func (tx *ConfigTx) Hash() (hash [32]byte)
- func (tx *ConfigTx) Receiver() [32]byte
- func (tx *ConfigTx) Sender() [32]byte
- func (tx *ConfigTx) Size() uint64
- func (tx ConfigTx) String() string
- func (tx *ConfigTx) TxFee() uint64
- type Context
- func (c *Context) GetAddress() [64]byte
- func (c *Context) GetAmount() uint64
- func (c *Context) GetBalance() uint64
- func (c *Context) GetContract() []byte
- func (c *Context) GetContractVariable(index int) ([]byte, error)
- func (c *Context) GetFee() uint64
- func (c *Context) GetIssuer() [32]byte
- func (c *Context) GetSender() [32]byte
- func (c *Context) GetSig1() [64]byte
- func (c *Context) GetTransactionData() []byte
- func (c *Context) PersistChanges()
- func (c *Context) SetContractVariable(index int, value []byte) error
- type ContractTx
- type DataSummary
- type DataTx
- func (*DataTx) Decode(encodedTx []byte) *DataTx
- func (tx *DataTx) Encode() (encodedTx []byte)
- func (tx *DataTx) Hash() (hash [32]byte)
- func (tx *DataTx) Receiver() [32]byte
- func (tx *DataTx) Sender() [32]byte
- func (tx *DataTx) Size() uint64
- func (tx DataTx) String() string
- func (tx *DataTx) TxFee() uint64
- type EpochBlock
- func (epochBlock *EpochBlock) Decode(encoded []byte) (b *EpochBlock)
- func (epochBlock *EpochBlock) Encode() []byte
- func (epochBlock *EpochBlock) EncodeHeader() []byte
- func (epochBlock *EpochBlock) HashEpochBlock() [32]byte
- func (epochBlock EpochBlock) String() string
- func (epochBlock EpochBlock) StringPrevHashes() (prevHashes string)
- func (epochBlock EpochBlock) StringState() (state string)
- type FineTx
- func (*FineTx) Decode(encodedTx []byte) *FineTx
- func (tx *FineTx) Encode() (encodedTx []byte)
- func (tx *FineTx) Hash() (hash [32]byte)
- func (tx *FineTx) Receiver() [32]byte
- func (tx *FineTx) Sender() [32]byte
- func (tx *FineTx) Size() uint64
- func (tx FineTx) String() string
- func (tx *FineTx) TxFee() uint64
- type FundsTx
- func (tx *FundsTx) Copy() (newTx *FundsTx)
- func (*FundsTx) Decode(encodedTx []byte) *FundsTx
- func (tx *FundsTx) Encode() (encodedTx []byte)
- func (tx *FundsTx) Hash() (hash [32]byte)
- func (tx *FundsTx) Receiver() [32]byte
- func (tx *FundsTx) Sender() [32]byte
- func (tx *FundsTx) Size() uint64
- func (tx FundsTx) String() string
- func (tx *FundsTx) TxFee() uint64
- type Genesis
- type KeyAssignment
- type KeyBlock
- type KeyCheck
- type KeyState
- type MerkleTree
- type Node
- type RelativeAccount
- type RelativeState
- type StakeTx
- func (*StakeTx) Decode(encodedTx []byte) (tx *StakeTx)
- func (tx *StakeTx) Encode() (encodedTx []byte)
- func (tx *StakeTx) Hash() (hash [32]byte)
- func (tx *StakeTx) Receiver() [32]byte
- func (tx *StakeTx) Sender() [32]byte
- func (tx *StakeTx) Size() uint64
- func (tx StakeTx) String() string
- func (tx *StakeTx) TxFee() uint64
- type StateStash
- type StateTransition
- func NewStateTransition(stateChange map[[32]byte]*RelativeAccount, height int, shardid int, ...) *StateTransition
- func ReturnStateTransitionForHeight(statestash *StateStash, height uint32) []*StateTransition
- func ReturnStateTransitionForPosition(stateStash *StateStash, position int) (stateHash [32]byte, stateTransition *StateTransition)
- type Transaction
- type TransactionAssignment
- type TransactionAssignmentStash
- type ValShardMapping
- func (valMapping *ValShardMapping) Decode(encoded []byte) (valMappingDecoded *ValShardMapping)
- func (valMapping *ValShardMapping) Encode() []byte
- func (valMapping *ValShardMapping) GetSize() int
- func (valMapping *ValShardMapping) HashMapping() [32]byte
- func (valMapping ValShardMapping) String() string
- type ValueAssignment
- type ValueBlock
- type ValueCheck
- type ValueState
Constants ¶
const ( HASH_LEN = 32 HEIGHT_LEN = 4 //All fixed sizes form the Block struct are 254 MIN_BLOCKSIZE = 393 + crypto.COMM_PROOF_LENGTH + 1 // = 650 bytes MIN_BLOCKHEADER_SIZE = 104 BLOOM_FILTER_ERROR_RATE = 0.1 )
const ( CONFIGTX_SIZE = 83 BLOCK_SIZE_ID = 1 DIFF_INTERVAL_ID = 2 FEE_MINIMUM_ID = 3 BLOCK_INTERVAL_ID = 4 BLOCK_REWARD_ID = 5 STAKING_MINIMUM_ID = 6 WAITING_MINIMUM_ID = 7 ACCEPTANCE_TIME_DIFF_ID = 8 SLASHING_WINDOW_SIZE_ID = 9 SLASHING_REWARD_ID = 10 MIN_BLOCK_SIZE = 1000 //1KB MAX_BLOCK_SIZE = 100000000 //100MB MIN_DIFF_INTERVAL = 3 //amount in seconds MAX_DIFF_INTERVAL = 9223372036854775807 MIN_FEE_MINIMUM = 0 MAX_FEE_MINIMUM = 9223372036854775807 MIN_BLOCK_INTERVAL = 3 //30 seconds MAX_BLOCK_INTERVAL = 86400 //24 hours MIN_BLOCK_REWARD = 0 MAX_BLOCK_REWARD = 1152921504606846976 //2^60 MIN_STAKING_MINIMUM = 5 //minimum number of coins for staking MAX_STAKING_MINIMUM = 9223372036854775807 //2^60 MIN_WAITING_TIME = 0 //number of blocks that must a new validator must wait before it can start validating MAX_WAITING_TIME = 100000 MIN_ACCEPTANCE_TIME_DIFF = 0 //semi-synchronous time difference between local clock of validators MAX_ACCEPTANCE_TIME_DIFF = 60 //1min MIN_SLASHING_WINDOW_SIZE = 0 //window size where a node has to commit itself to a competing branch in case of a fork MAX_SLASHING_WINDOW_SIZE = 10000 //1000 Blocks (totally random) MIN_SLASHING_REWARD = 0 // reward for providing a valid slashing proof MAX_SLASHING_REWARD = 1152921504606846976 //2^60 )
const (
ACCTX_SIZE = 169
)
const ( //TODO recalculate AGGDATATX_SIZE = 0 //Only constant Values --> Without To, From & AggregatedTxSlice )
const (
AGGTX_SIZE = 85 //Only constant Values --> Without To, From & AggregatedTxSlice
)
const (
//TODO Recalculate
COMMITTEETX_SIZE = 0
)
const (
CONTRACTTX_SIZE = 201
)
const (
//TODO calculate
DATATX_SIZE = 0
)
const (
FINETX_SIZE = 246 //Todo recalculate
)
const (
FUNDSTX_SIZE = 246
)
const (
STAKETX_SIZE = 106 + crypto.COMM_KEY_LENGTH
)
Variables ¶
This section is empty.
Functions ¶
func CheckForHeightBlock ¶
func CheckForHeightBlock(blockStash *BlockStash, height uint32) int
This function counts how many blocks in the stash have some predefined height
func CheckForHeightCommitteeCheck ¶
func CheckForHeightCommitteeCheck(committeeCheckStash *CommitteeCheckStash, height uint32) int
This function counts how many state transisitions in the stash have some predefined height
func CheckForHeightStateTransition ¶
func CheckForHeightStateTransition(statestash *StateStash, height uint32) int
This function counts how many state transisitions in the stash have some predefined height
func CheckForHeightTransactionAssignment ¶
func CheckForHeightTransactionAssignment(transactionAssignmentStash *TransactionAssignmentStash, height uint32) int
This function counts how many transaction assignments in the stash have some predefined height
func RandomBytes ¶
func RandomBytes() []byte
func RandomBytesWithLength ¶
func ReturnBlockHashesForHeight ¶
func ReturnBlockHashesForHeight(blockStash *BlockStash, height uint32) [][32]byte
func SerializeHashContent ¶
func SerializeHashContent(data interface{}) (hash [32]byte)
Serializes the input and returns the sha3 hash function applied on ths input
Types ¶
type AccTx ¶
type AccTx struct {
Header byte
Issuer [32]byte
Fee uint64
PubKey [64]byte
Sig [64]byte
Contract []byte
ContractVariables []ByteArray
}
func ConstrAccTx ¶
type Account ¶
type Account struct {
Address [64]byte // 64 Byte
Issuer [32]byte // 32 Byte
Balance uint64 // 8 Byte
TxCnt uint32 // 4 Byte
IsStaking bool // 1 Byte
IsCommittee bool // 1 Byte
CommitmentKey [crypto.COMM_KEY_LENGTH]byte // represents the modulus N of the RSA public key
CommitteeKey [crypto.COMM_KEY_LENGTH]byte // represents the modulus N of the RSA public key
StakingBlockHeight uint32 // 4 Byte
Contract []byte // Arbitrary length
ContractVariables []ByteArray // Arbitrary length
}
func NewAccount ¶
type AggDataTx ¶
type AggDataTx struct {
Fee uint64
//only one sender for each aggregated data transaction
From [32]byte
To [][32]byte
AggregatedDataTx [][32]byte
Data [][]byte
}
func ConstrAggDataTx ¶
type AggTx ¶
type AggTx struct {
Amount uint64
Fee uint64
From [][32]byte
To [][32]byte
AggregatedTxSlice [][32]byte
//says if the AggTx has been aggregated into another AggTx. not needed anymore.
Aggregated bool
Block [32]byte //This saves the blockHashWithoutTransactions into which the transaction was usually validated. Needed for rollback.
MerkleRoot [32]byte
}
func ConstrAggTx ¶
type Block ¶
type Block struct {
//Header
Header byte
ShardId int
Hash [32]byte
PrevHash [32]byte
// HashWithoutTx [32]byte //valid hash once all tx are aggregated
// PrevHashWithoutTx [32]byte //valid hash of ancestor once all tx are aggregated
NrConfigTx uint8
NrElementsBF uint16
BloomFilter *bloom.BloomFilter //8 byte
Height uint32
Beneficiary [32]byte
//Body
Nonce [8]byte
Timestamp int64
MerkleRoot [32]byte
NrAccTx uint16
NrFundsTx uint16
NrStakeTx uint16
NrCommitteeTx uint16
NrAggTx uint16
NrDataTx uint16
NrAggDataTx uint16
NrFineTx uint16
SlashedAddress [32]byte
CommitmentProof [crypto.COMM_PROOF_LENGTH]byte
ConflictingBlockHash1 [32]byte
ConflictingBlockHash2 [32]byte
// ConflictingBlockHashWithoutTx1 [32]byte
// ConflictingBlockHashWithoutTx2 [32]byte
StateCopy map[[32]byte]*Account //won't be serialized, just keeping track of local state changes
ContractTxData [][32]byte
AccTxData [][32]byte
FundsTxData [][32]byte
DataTxData [][32]byte
ConfigTxData [][32]byte
StakeTxData [][32]byte
CommitteeTxData [][32]byte
AggTxData [][32]byte
AggDataTxData [][32]byte
FineTxData [][32]byte
}
func ReturnBlockForPosition ¶
func ReturnBlockForPosition(blockStash *BlockStash, position int) (stateHash [32]byte, block *Block)
func ReturnBlockStashForHeight ¶
func ReturnBlockStashForHeight(blockStash *BlockStash, height uint32) []*Block
func (*Block) EncodeHeader ¶
func (*Block) GetBloomFilterSize ¶
func (*Block) GetBodySize ¶
func (*Block) GetHeaderSize ¶
func (*Block) GetTxDataSize ¶
func (*Block) HashBlockWithoutMerkleRoot ¶
func (*Block) InitBloomFilter ¶
type BlockStash ¶
type BlockStash struct {
M map[KeyBlock]ValueBlock
Keys []KeyBlock
}
func NewShardBlockStash ¶
func NewShardBlockStash() *BlockStash
func (*BlockStash) BlockIncluded ¶
func (m *BlockStash) BlockIncluded(k KeyBlock) bool
func (*BlockStash) DeleteFirstEntry ¶
func (m *BlockStash) DeleteFirstEntry()
This function includes a key and tracks its order in the slice. No need to put the lock because it is used from the calling function
func (*BlockStash) Set ¶
func (m *BlockStash) Set(k KeyBlock, v ValueBlock)
This function includes a key and tracks its order in the slice
type CommitteeCheck ¶
type CommitteeCheck struct {
Height int
Sender [32]byte
CommitteeProof [crypto.COMM_PROOF_LENGTH]byte
SlashedAddressesCommittee [][32]byte
SlashedAddressesShards [][32]byte
}
func NewCommitteeCheck ¶
func NewCommitteeCheck(height int, sender [32]byte, committeeProof [crypto.COMM_PROOF_LENGTH]byte, slashedAddressesCommittee [][32]byte, slashedAddressesShards [][32]byte) *CommitteeCheck
func ReturnCommitteeCheckForHeight ¶
func ReturnCommitteeCheckForHeight(committeeCheckStash *CommitteeCheckStash, height uint32) []*CommitteeCheck
func ReturnCommitteeCheckForPosition ¶
func ReturnCommitteeCheckForPosition(committeeCheckStash *CommitteeCheckStash, position int) (committeeCheckHash [32]byte, committeeCheck *CommitteeCheck)
func (*CommitteeCheck) DecodeCommitteeCheck ¶
func (*CommitteeCheck) DecodeCommitteeCheck(encoded []byte) (ta *CommitteeCheck)
func (*CommitteeCheck) EncodeCommitteeCheck ¶
func (cc *CommitteeCheck) EncodeCommitteeCheck() []byte
func (*CommitteeCheck) HashCommitteCheck ¶
func (cc *CommitteeCheck) HashCommitteCheck() [32]byte
type CommitteeCheckStash ¶
type CommitteeCheckStash struct {
M map[KeyCheck]ValueCheck
Keys []KeyCheck
}
func NewCommitteeCheckStash ¶
func NewCommitteeCheckStash() *CommitteeCheckStash
func (*CommitteeCheckStash) CommitteeCheckIncluded ¶
func (m *CommitteeCheckStash) CommitteeCheckIncluded(k KeyCheck) bool
func (*CommitteeCheckStash) DeleteFirstEntry ¶
func (m *CommitteeCheckStash) DeleteFirstEntry()
This function includes a key and tracks its order in the slice. No need to put the lock because it is used from the calling function
func (*CommitteeCheckStash) Set ¶
func (m *CommitteeCheckStash) Set(k KeyCheck, v ValueCheck)
This function includes a key and tracks its order in the slice
type CommitteeTx ¶
type CommitteeTx struct {
Header byte // 1 Byte
Fee uint64 // 8 Byte
IsCommittee bool // 1 Byte
Account [64]byte // 64 Byte
Issuer [32]byte // 32 Byte
Sig [64]byte // 64 Byte
CommitteeKey [crypto.COMM_KEY_LENGTH]byte // the modulus N of the RSA public key
}
func ConstrCommitteeTx ¶
func ConstrCommitteeTx(header byte, fee uint64, isCommittee bool, account [64]byte, signKey *ecdsa.PrivateKey, commPubKey *rsa.PublicKey) (tx *CommitteeTx, err error)
func (*CommitteeTx) Decode ¶
func (*CommitteeTx) Decode(encoded []byte) (tx *CommitteeTx)
func (*CommitteeTx) Encode ¶
func (tx *CommitteeTx) Encode() (encodedTx []byte)
func (*CommitteeTx) Hash ¶
func (tx *CommitteeTx) Hash() (hash [32]byte)
func (*CommitteeTx) Receiver ¶
func (tx *CommitteeTx) Receiver() [32]byte
func (*CommitteeTx) Sender ¶
func (tx *CommitteeTx) Sender() [32]byte
func (*CommitteeTx) Size ¶
func (tx *CommitteeTx) Size() uint64
func (CommitteeTx) String ¶
func (tx CommitteeTx) String() string
func (*CommitteeTx) TxFee ¶
func (tx *CommitteeTx) TxFee() uint64
type ConfigTx ¶
func ConstrConfigTx ¶
type Context ¶
func NewContext ¶
func (*Context) GetAddress ¶
func (*Context) GetBalance ¶
func (*Context) GetContract ¶
func (*Context) GetContractVariable ¶
func (*Context) GetTransactionData ¶
func (*Context) PersistChanges ¶
func (c *Context) PersistChanges()
type ContractTx ¶
type ContractTx struct {
Header byte
Issuer [64]byte
Fee uint64
PubKey [64]byte
Sig [64]byte
Contract []byte
ContractVariables []ByteArray
}
func ConstrContractTx ¶
func ConstrContractTx(header byte, fee uint64, issuerSigKey *ecdsa.PrivateKey, contract []byte, contractVariables []ByteArray) (tx *ContractTx, newContractKey *ecdsa.PrivateKey, err error)
func (*ContractTx) Decode ¶
func (*ContractTx) Decode(encoded []byte) (tx *ContractTx)
func (*ContractTx) Encode ¶
func (tx *ContractTx) Encode() []byte
func (*ContractTx) Hash ¶
func (tx *ContractTx) Hash() [32]byte
func (*ContractTx) Size ¶
func (tx *ContractTx) Size() uint64
func (ContractTx) String ¶
func (tx ContractTx) String() string
func (*ContractTx) TxFee ¶
func (tx *ContractTx) TxFee() uint64
type DataSummary ¶
Seperate data type to keep it more expandable Data summary data type stores information about all data that has been sent from a particular address
func NewDataSummary ¶
func NewDataSummary(address [32]byte) *DataSummary
func (*DataSummary) Decode ¶
func (*DataSummary) Decode(encoded []byte) (ds *DataSummary)
func (*DataSummary) Encode ¶
func (ds *DataSummary) Encode() []byte
func (*DataSummary) Hash ¶
func (ds *DataSummary) Hash() [32]byte
Address is the unique identifier of a data summary
func (DataSummary) String ¶
func (ds DataSummary) String() string
type DataTx ¶
type DataTx struct {
Header byte
Fee uint64
TxCnt uint32
TimeStamp int64
From [32]byte
To [32]byte
Sig1 [64]byte
Sig2 [64]byte
Data []byte
}
func ConstrDataTx ¶
type EpochBlock ¶
type EpochBlock struct {
//Header
Header byte
Hash [32]byte
PrevShardHashes [][32]byte
Height uint32
//Body
Timestamp int64
MerkleRoot [32]byte
MerklePatriciaRoot [32]byte
CommitmentProof [crypto.COMM_PROOF_LENGTH]byte
State map[[32]byte]*Account
ValMapping *ValShardMapping
CommitteeLeader [32]byte //hash of the wallet of the chosen committee leader
NofShards int
Beneficiary [32]byte
}
func NewEpochBlock ¶
func NewEpochBlock(prevShardHashes [][32]byte, height uint32) *EpochBlock
func (*EpochBlock) Decode ¶
func (epochBlock *EpochBlock) Decode(encoded []byte) (b *EpochBlock)
func (*EpochBlock) Encode ¶
func (epochBlock *EpochBlock) Encode() []byte
func (*EpochBlock) EncodeHeader ¶
func (epochBlock *EpochBlock) EncodeHeader() []byte
func (*EpochBlock) HashEpochBlock ¶
func (epochBlock *EpochBlock) HashEpochBlock() [32]byte
func (EpochBlock) String ¶
func (epochBlock EpochBlock) String() string
func (EpochBlock) StringPrevHashes ¶
func (epochBlock EpochBlock) StringPrevHashes() (prevHashes string)
func (EpochBlock) StringState ¶
func (epochBlock EpochBlock) StringState() (state string)
type FineTx ¶
type FineTx struct {
Header byte
Amount uint64
Fee uint64
From [32]byte
To [32]byte
Sig [64]byte
TimeStamp int64
}
func ConstrFineTx ¶
type FundsTx ¶
type FundsTx struct {
Header byte
Amount uint64
Fee uint64
TxCnt uint32
TimeStamp int64
From [32]byte
To [32]byte
Sig1 [64]byte
Sig2 [64]byte
//says if the fundsTx has been aggregated into an aggtx. This boolean isn't needed in the current version
Aggregated bool
Block [32]byte //This saves the blockHashWithoutTransactions into which the transaction was usually validated. Needed for rollback.
Data []byte
}
func ConstrFundsTx ¶
type Genesis ¶
type Genesis struct {
RootAddress [64]byte
RootCommitment [crypto.COMM_KEY_LENGTH]byte
FirstCommitteeAddress [64]byte
FirstCommitteeKey [crypto.COMM_KEY_LENGTH]byte
}
func NewGenesis ¶
func NewGenesis(rootAddress [64]byte, rootCommitment [crypto.COMM_KEY_LENGTH]byte, firstCommitteeAddress [64]byte, firstCommitteeKey [crypto.COMM_KEY_LENGTH]byte) Genesis
type KeyAssignment ¶
type KeyAssignment [32]byte // Key: Hash of the committee check
This datastructe maintains a map of the form int - *TransactionAssignment. It stores the committee checks received from other committee members. This datastructure will be queried at every blockheight to check if every one played according to the rules. Because we need to remove the first element of this datastructure and map access is random in Go, we additionally have a slice datastructure which keeps track of the order of the included transaction assignment. Such that, using the slice structure, we can remove the first received block once this stash gets full
type KeyBlock ¶
type KeyBlock [32]byte // Key: Hash of the block
This datastructe maintains a map of the form [32]byte - *Block. It stores the blcoks received from the shards. This datastructure will be queried after every epoch block to check if we can continue to the next epoch. Because we need to remove the first element of this datastructure and map access is random in Go, we additionally have a slice datastructure which keeps track of the order of the included state transition. Such that, using the slice structure, we can remove the first received block once this stash gets full
type KeyCheck ¶
type KeyCheck [32]byte // Key: Hash of the committee check
This datastructe maintains a map of the form [32]byte - *CommitteeCheck. It stores the committee checks received from other committee members. This datastructure will be queried at every blockheight to check if every one played according to the rules. Because we need to remove the first element of this datastructure and map access is random in Go, we additionally have a slice datastructure which keeps track of the order of the included commitee check. Such that, using the slice structure, we can remove the first received block once this stash gets full
type KeyState ¶
type KeyState [32]byte // Key: Hash of the block
This datastructe maintains a map of the form [32]byte - *StateTransition. It stores the state transitions received from other shards. This datastructure will be queried at every blockheight to check if we can continue mining the next block. Because we need to remove the first element of this datastructure and map access is random in Go, we additionally have a slice datastructure which keeps track of the order of the included state transition. Such that, using the slice structure, we can remove the first received block once this stash gets full
type MerkleTree ¶
MerkleTree is the container for the tree. It holds a pointer to the root of the tree, a list of pointers to the leaf nodes, and the merkle root.
func BuildAggTxMerkleTree ¶
func BuildAggTxMerkleTree(txHashes [][32]byte) *MerkleTree
func BuildMerkleTree ¶
func BuildMerkleTree(b *Block) *MerkleTree
func (*MerkleTree) MerkleRoot ¶
func (m *MerkleTree) MerkleRoot() [32]byte
MerkleRoot returns the unverified Merkle Root (hash of the root node) of the tree.
func (*MerkleTree) String ¶
func (m *MerkleTree) String() string
String returns a string representation of the tree. Only leaf nodes are included in the output.
func (*MerkleTree) VerifyTree ¶
func (m *MerkleTree) VerifyTree() bool
VerifyTree verify tree validates the hashes at each level of the tree and returns true if the resulting hash at the root of the tree matches the resulting root hash; returns false otherwise.
type Node ¶
type Node struct {
Parent *Node
Left *Node
Right *Node
Hash [32]byte
// contains filtered or unexported fields
}
Node represents a node, root, or leaf in the tree. It stores pointers to its immediate relationships, a hash, the content stored if it is a leaf, and other metadata.
func GetIntermediate ¶
VerifyContent indicates whether a given content is in the tree and the hashes are valid for that content. Returns true if the expected Merkle Root is equivalent to the Merkle root calculated on the critical path for a given content. Returns true if valid and false otherwise.
func GetLeaf ¶
func GetLeaf(merkleTree *MerkleTree, leafHash [32]byte) *Node
type RelativeAccount ¶
type RelativeAccount struct {
Address [64]byte // 64 Byte
Issuer [32]byte // 32 Byte Changed to streamline
Balance int64 // 8 Byte
TxCnt int32 // 4 Byte
IsStaking bool // 1 Byte
IsCommittee bool
CommitmentKey [crypto.COMM_KEY_LENGTH]byte // represents the modulus N of the RSA public key
CommitteeKey [crypto.COMM_KEY_LENGTH]byte // represents the modulus N of the RSA public key
StakingBlockHeight int32 // 4 Byte
Contract []byte // Arbitrary length
ContractVariables []ByteArray // Arbitrary length
}
*
This datastructure keeps track of relative change in the account information during the creation of a block
func NewRelativeAccount ¶
func NewRelativeAccount(address [64]byte, issuer [32]byte, balance int64, isStaking bool, isCommittee bool, commitmentKey [crypto.COMM_KEY_LENGTH]byte, committeeKey [crypto.COMM_KEY_LENGTH]byte, contract []byte, contractVariables []ByteArray) RelativeAccount
func (*RelativeAccount) Decode ¶
func (*RelativeAccount) Decode(encoded []byte) (acc *RelativeAccount)
func (*RelativeAccount) Encode ¶
func (acc *RelativeAccount) Encode() []byte
func (*RelativeAccount) Hash ¶
func (acc *RelativeAccount) Hash() [32]byte
func (RelativeAccount) String ¶
func (acc RelativeAccount) String() string
type RelativeState ¶
type RelativeState struct {
RelativeState map[[32]byte]*RelativeAccount
ShardID int
//The beneficiary is the beneficiary of the block which was used as the basis to create this relative state
Beneficiary [32]byte
}
This structure is very similar to the state transition. However, it only serves as a validation element. Therefore, it does not require a hash, serializer, deserializer or Commitment Proof.
func NewRelativeState ¶
func NewRelativeState(stateChange map[[32]byte]*RelativeAccount, shardid int, beneficiary [32]byte) *RelativeState
type StakeTx ¶
type StakeTx struct {
Header byte // 1 Byte
Fee uint64 // 8 Byte
IsStaking bool // 1 Byte
Account [32]byte // 32 Byte
Sig [64]byte // 64 Byte
CommitmentKey [crypto.COMM_KEY_LENGTH]byte // the modulus N of the RSA public key
}
func ConstrStakeTx ¶
type StateStash ¶
type StateStash struct {
M map[KeyState]ValueState
Keys []KeyState
}
func NewStateStash ¶
func NewStateStash() *StateStash
func (*StateStash) DeleteFirstEntry ¶
func (m *StateStash) DeleteFirstEntry()
This function includes a key and tracks its order in the slice. No need to put the lock because it is used from the calling function
func (*StateStash) Set ¶
func (m *StateStash) Set(k KeyState, v ValueState)
This function includes a key and tracks its order in the slice
func (*StateStash) StateTransitionIncluded ¶
func (m *StateStash) StateTransitionIncluded(k KeyState) bool
type StateTransition ¶
type StateTransition struct {
RelativeStateChange map[[32]byte]*RelativeAccount //changed to 32 Byte for streamlining
Height int
ShardID int
CommitmentProof [crypto.COMM_KEY_LENGTH]byte
}
*
The State Transition is the main data type needed in the synchronisation mechnism. It contains all data needed to update the local state with the state of the other shards and free the Mempool from already validated transactions.
func NewStateTransition ¶
func NewStateTransition(stateChange map[[32]byte]*RelativeAccount, height int, shardid int, commProof [crypto.COMM_KEY_LENGTH]byte) *StateTransition
func ReturnStateTransitionForHeight ¶
func ReturnStateTransitionForHeight(statestash *StateStash, height uint32) []*StateTransition
func ReturnStateTransitionForPosition ¶
func ReturnStateTransitionForPosition(stateStash *StateStash, position int) (stateHash [32]byte, stateTransition *StateTransition)
func (*StateTransition) DecodeTransition ¶
func (*StateTransition) DecodeTransition(encoded []byte) (st *StateTransition)
func (*StateTransition) EncodeTransition ¶
func (st *StateTransition) EncodeTransition() []byte
func (*StateTransition) HashTransition ¶
func (st *StateTransition) HashTransition() [32]byte
type Transaction ¶
type TransactionAssignment ¶
type TransactionAssignment struct {
Height int
ShardID int
CommitteeProof [crypto.COMM_PROOF_LENGTH]byte
AccTxs []*AccTx
StakeTxs []*StakeTx
CommitteeTxs []*CommitteeTx
FundsTxs []*FundsTx
DataTxs []*DataTx
FineTxs []*FineTx
}
func NewTransactionAssignment ¶
func NewTransactionAssignment(height int, shardid int, committeeProof [crypto.COMM_PROOF_LENGTH]byte, accTxs []*AccTx, stakeTxs []*StakeTx, committeeTxs []*CommitteeTx, fundsTxs []*FundsTx, dataTxs []*DataTx, fineTxs []*FineTx) *TransactionAssignment
func ReturnTransactionAssignmentForHeight ¶
func ReturnTransactionAssignmentForHeight(transactionAssignmentStash *TransactionAssignmentStash, height uint32) []*TransactionAssignment
func (*TransactionAssignment) DecodeTransactionAssignment ¶
func (*TransactionAssignment) DecodeTransactionAssignment(encoded []byte) (ta *TransactionAssignment)
func (*TransactionAssignment) EncodeTransactionAssignment ¶
func (ta *TransactionAssignment) EncodeTransactionAssignment() []byte
func (*TransactionAssignment) HashTransactionAssignment ¶
func (ta *TransactionAssignment) HashTransactionAssignment() [32]byte
type TransactionAssignmentStash ¶
type TransactionAssignmentStash struct {
M map[KeyAssignment]ValueAssignment
Keys []KeyAssignment
}
func NewTransactionAssignmentStash ¶
func NewTransactionAssignmentStash() *TransactionAssignmentStash
func (*TransactionAssignmentStash) DeleteFirstEntry ¶
func (m *TransactionAssignmentStash) DeleteFirstEntry()
This function includes a key and tracks its order in the slice. No need to put the lock because it is used from the calling function
func (*TransactionAssignmentStash) Set ¶
func (m *TransactionAssignmentStash) Set(k KeyAssignment, v ValueAssignment)
This function includes a key and tracks its order in the slice
func (*TransactionAssignmentStash) TransactionAssignmentIncluded ¶
func (m *TransactionAssignmentStash) TransactionAssignmentIncluded(k KeyAssignment) bool
type ValShardMapping ¶
func NewMapping ¶
func NewMapping() *ValShardMapping
func (*ValShardMapping) Decode ¶
func (valMapping *ValShardMapping) Decode(encoded []byte) (valMappingDecoded *ValShardMapping)
func (*ValShardMapping) Encode ¶
func (valMapping *ValShardMapping) Encode() []byte
func (*ValShardMapping) GetSize ¶
func (valMapping *ValShardMapping) GetSize() int
func (*ValShardMapping) HashMapping ¶
func (valMapping *ValShardMapping) HashMapping() [32]byte
func (ValShardMapping) String ¶
func (valMapping ValShardMapping) String() string
type ValueAssignment ¶
type ValueAssignment *TransactionAssignment // Value: Transaction Assignment
type ValueBlock ¶
type ValueBlock *Block // Value: Block
type ValueCheck ¶
type ValueCheck *CommitteeCheck // Value: CommitteeCheck
type ValueState ¶
type ValueState *StateTransition // Value: Block
Source Files
¶
- account.go
- acctx.go
- aggdatatx.go
- aggtx.go
- block.go
- byteArray.go
- committee_check.go
- committeetx.go
- configtx.go
- contracttx.go
- data_summary.go
- datatx.go
- epoch_block.go
- finetx.go
- fundstx.go
- genesis.go
- merkletree.go
- received_block_stash.go
- received_committee_check_stash.go
- received_state_stash.go
- received_transaction_assignment_stash.go
- relative_account.go
- staketx.go
- transaction.go
- transaction_assignment.go
- utils.go
- val_shard_mapping.go
- vm_context.go