Documentation ¶
Index ¶
- Constants
- Variables
- func ApplyRelativeState(statePrev map[[32]byte]*protocol.Account, ...) (stateUpdated map[[32]byte]*protocol.Account)
- func BlockAlreadyInStash(slice []*protocol.Block, newBlockHash [32]byte) bool
- func BlockReadyToAggregate(block *protocol.Block) bool
- func DeleteAll()
- func DeleteAllDataTxBeforeAggregation()
- func DeleteAllFundsTxBeforeAggregation()
- func DeleteAllLastClosedBlock()
- func DeleteAllLastClosedEpochBlock() error
- func DeleteAllOpenTxAndReturnAllNotIncludedTxHashes(accTxs []*protocol.AccTx, stakeTxs []*protocol.StakeTx, ...) (notIncludedTxHashes [][32]byte)
- func DeleteBootstrapReceivedMempool()
- func DeleteClosedBlock(hash [32]byte)
- func DeleteClosedBlockWithoutTx(hash [32]byte)
- func DeleteClosedEpochBlock(hash [32]byte) error
- func DeleteClosedTx(transaction protocol.Transaction)
- func DeleteINVALIDOpenTx(transaction protocol.Transaction)
- func DeleteLastClosedBlock(hash [32]byte)
- func DeleteOpenBlock(hash [32]byte)
- func DeleteOpenEpochBlock(hash [32]byte) error
- func DeleteOpenTx(transaction protocol.Transaction)
- func GetAccTxPubKeys(accTxData [][32]byte) (accTxPubKeys [][32]byte)
- func GetAccount(hash [32]byte) (acc *protocol.Account, err error)
- func GetFundsTxPubKeys(fundsTxData [][32]byte) (fundsTxPubKeys [][32]byte)
- func GetMemPoolSize() int
- func GetRelativeState(statePrev map[[32]byte]protocol.Account, ...) (stateRel map[[32]byte]*protocol.RelativeAccount)
- func GetRelativeStateForCommittee(statePrev map[[32]byte]protocol.Account, ...) (stateRel map[[32]byte]*protocol.RelativeAccount)
- func GetRootAccount(hash [32]byte) (acc *protocol.Account, err error)
- func GetTxPubKeys(block *protocol.Block) (txPubKeys [][32]byte)
- func Init(dbname string, bootstrapIpport string)
- func InitLogger() *log.Logger
- func IsRootKey(hash [32]byte) bool
- func ReadAccount(pubKey [64]byte) (acc *protocol.Account, err error)
- func ReadAllAssignedTx() (allAssignedTxs []protocol.Transaction)
- func ReadAllBootstrapReceivedTransactions() (allOpenTxs []protocol.Transaction)
- func ReadAllClosedBlocks() (allClosedBlocks []*protocol.Block)
- func ReadAllClosedBlocksWithTransactions() (allClosedBlocks []*protocol.Block)
- func ReadAllClosedFundsAndAggTransactions() (allClosedTransactions []protocol.Transaction)
- func ReadAllDataSummary() []*protocol.DataSummary
- func ReadAllINVALIDOpenTx() (allOpenInvalidTxs []protocol.Transaction)
- func ReadAllOpenTxs() (allOpenTxs []protocol.Transaction)
- func ReadAssignedTx(hash [32]byte) (transaction protocol.Transaction)
- func ReadClosedBlock(hash [32]byte) (block *protocol.Block)
- func ReadClosedBlockWithoutTx(hash [32]byte) (block *protocol.Block)
- func ReadClosedEpochBlock(hash [32]byte) (epochBlock *protocol.EpochBlock)
- func ReadClosedTx(hash [32]byte) (transaction protocol.Transaction)
- func ReadDataTxBeforeAggregation() []*protocol.DataTx
- func ReadFirstEpochBlock() (firstEpochBlock *protocol.EpochBlock, err error)
- func ReadFundsTxBeforeAggregation() []*protocol.FundsTx
- func ReadGenesis() (genesis *protocol.Genesis, err error)
- func ReadINVALIDOpenTx(hash [32]byte) (transaction protocol.Transaction)
- func ReadLastClosedBlock() (block *protocol.Block)
- func ReadLastClosedEpochBlock() (epochBlock *protocol.EpochBlock)
- func ReadOpenBlock(hash [32]byte) (block *protocol.Block)
- func ReadOpenEpochBlock(hash [32]byte) (epochBlock *protocol.EpochBlock)
- func ReadOpenTx(hash [32]byte) (transaction protocol.Transaction)
- func ReadOpenTxHashToDelete(hash [32]byte) (contains bool)
- func ReadReceivedBlockStash() (receivedBlocks []*protocol.Block)
- func ReadStateTransitionFromOwnStash(height int) *protocol.StateTransition
- func ReadTxcntToTx(txCnt uint32) (transactions [][32]byte)
- func ResetOpenTxHashToDeleteMempool()
- func TearDown()
- func UpdateDataSummary(dataTxs []*protocol.DataTx) (err error)
- func WriteAllClosedTxAndReturnAlreadyClosedTxHashes(accTxs []*protocol.AccTx, stakeTxs []*protocol.StakeTx, ...) (alreadyIncludedTxHashes [][32]byte, err error)
- func WriteBootstrapTxReceived(transaction protocol.Transaction)
- func WriteClosedBlock(block *protocol.Block) (err error)
- func WriteClosedEpochBlock(epochBlock *protocol.EpochBlock) error
- func WriteClosedFundsTxFromAggTxSlice(transactions []protocol.FundsTx) (err error)
- func WriteClosedTx(transaction protocol.Transaction) (err error)
- func WriteDataSummary(ds *protocol.DataSummary) (err error)
- func WriteDataTxBeforeAggregation(transaction *protocol.DataTx)
- func WriteFirstEpochBlock(epochBlock *protocol.EpochBlock) error
- func WriteFundsTxBeforeAggregation(transaction *protocol.FundsTx)
- func WriteGenesis(genesis *protocol.Genesis) error
- func WriteINVALIDOpenTx(transaction protocol.Transaction)
- func WriteLastClosedBlock(block *protocol.Block) (err error)
- func WriteLastClosedEpochBlock(epochBlock *protocol.EpochBlock) (err error)
- func WriteOpenBlock(block *protocol.Block) (err error)
- func WriteOpenTx(transaction protocol.Transaction)
- func WriteOpenTxHashToDelete(hash [32]byte)
- func WriteToOwnStateTransitionkStash(st *protocol.StateTransition)
- func WriteToReceivedStash(block *protocol.Block)
- func WriteTxcntToTx(transaction *protocol.FundsTx)
- type ByHeight
Constants ¶
const ( ERROR_MSG = "Initiate storage aborted: " CLOSEDEPOCHBLOCK_BUCKET = "closedepochblocks" LASTCLOSEDEPOCHBLOCK_BUCKET = "lastclosedepochblocks" OPENEPOCHBLOCK_BUCKET = "openepochblock" GENESIS_BUCKET = "genesis" )
Variables ¶
var ( //don't get confused with the key of the account. State = make(map[[32]byte]*protocol.Account) //This map keeps track of the relative account adjustments within a shard, such as balance, txcount and stakingheight RelativeState = make(map[[32]byte]*protocol.RelativeAccount) OwnStateTransitionStash []*protocol.StateTransition RootKeys = make(map[[32]byte]*protocol.Account) //designed a new mempool for this use case AssignedTxMempool = make(map[[32]byte]protocol.Transaction) //map of transaction assignments for a given height. Key: ShardID. Value: Assignment AssignedTxMap = make(map[int]*protocol.TransactionAssignment) OwnCommitteeCheck *protocol.CommitteeCheck DifferentSenders = make(map[[32]byte]uint32) DifferentSendersData = make(map[[32]byte]uint32) DifferentReceivers = make(map[[32]byte]uint32) FundsTxBeforeAggregation = make([]*protocol.FundsTx, 0) DataTxBeforeAggregation = make([]*protocol.DataTx, 0) ReceivedBlockStash = make([]*protocol.Block, 0) TxcntToTxMap = make(map[uint32][][32]byte) ValidatorAccAddress [64]byte AllClosedBlocksAsc []*protocol.Block Bootstrap_Server string ReceivedBlockStashMutex = &sync.Mutex{} //Added by Kürsat ThisShardID int // ID of the shard this validator is assigned to ThisShardIDDelayed int ThisShardMap = make(map[int]int) EpochLength int ReceivedStateStash = protocol.NewStateStash() ReceivedShardBlockStash = protocol.NewShardBlockStash() ReceivedCommitteeCheckStash = protocol.NewCommitteeCheckStash() ReceivedTransactionAssignmentStash = protocol.NewTransactionAssignmentStash() IsCommittee bool AssignmentHeight int CommitteeLeader [32]byte CommitteePrivKey *rsa.PrivateKey CommitteeWalletPrivKey *ecdsa.PrivateKey )
Functions ¶
func ApplyRelativeState ¶
func ApplyRelativeState(statePrev map[[32]byte]*protocol.Account, stateRel map[[32]byte]*protocol.RelativeAccount) (stateUpdated map[[32]byte]*protocol.Account)
From Kürsat
func BlockAlreadyInStash ¶
func BlockReadyToAggregate ¶
TODO UNCOMMENT
func UpdateBlocksToBlocksWithoutTx(block *protocol.Block) (err error){
if BlockReadyToAggregate(block) { block.Aggregated = true WriteClosedBlockWithoutTx(block) DeleteClosedBlock(block.Hash) logger.Printf("UPDATE: Write (%x) into closedBlockWithoutTransactions-Bucket as (%x)", block.Hash[0:8], block.HashWithoutTx[0:8]) return err } return }
func DeleteAllDataTxBeforeAggregation ¶
func DeleteAllDataTxBeforeAggregation()
func DeleteAllFundsTxBeforeAggregation ¶
func DeleteAllFundsTxBeforeAggregation()
func DeleteAllLastClosedBlock ¶
func DeleteAllLastClosedBlock()
func DeleteAllLastClosedEpochBlock ¶
func DeleteAllLastClosedEpochBlock() error
func DeleteAllOpenTxAndReturnAllNotIncludedTxHashes ¶
func DeleteAllOpenTxAndReturnAllNotIncludedTxHashes(accTxs []*protocol.AccTx, stakeTxs []*protocol.StakeTx, committeeTxs []*protocol.CommitteeTx, fundsTxs []*protocol.FundsTx, aggTxs []*protocol.AggTx, dataTxs []*protocol.DataTx, aggDataTxs []*protocol.AggDataTx, fineTxs []*protocol.FineTx) (notIncludedTxHashes [][32]byte)
In this function, we detect whether the shard put a transaction in a block which wasn't part of the original TX assignment
func DeleteBootstrapReceivedMempool ¶
func DeleteBootstrapReceivedMempool()
func DeleteClosedBlock ¶
func DeleteClosedBlock(hash [32]byte)
func DeleteClosedBlockWithoutTx ¶
func DeleteClosedBlockWithoutTx(hash [32]byte)
func DeleteClosedEpochBlock ¶
func DeleteClosedTx ¶
func DeleteClosedTx(transaction protocol.Transaction)
func DeleteINVALIDOpenTx ¶
func DeleteINVALIDOpenTx(transaction protocol.Transaction)
func DeleteLastClosedBlock ¶
func DeleteLastClosedBlock(hash [32]byte)
func DeleteOpenBlock ¶
func DeleteOpenBlock(hash [32]byte)
There exist open/closed buckets and closed tx buckets for all types (open txs are in volatile storage)
func DeleteOpenEpochBlock ¶
func DeleteOpenTx ¶
func DeleteOpenTx(transaction protocol.Transaction)
func GetAccTxPubKeys ¶
Get all pubKey involved in AccTx
func GetAccount ¶
Needed by miner and p2p package
func GetFundsTxPubKeys ¶
Get all pubKey involved in FundsTx
func GetMemPoolSize ¶
func GetMemPoolSize() int
func GetRelativeState ¶
func GetRelativeStateForCommittee ¶
func GetRelativeStateForCommittee(statePrev map[[32]byte]protocol.Account, stateNow map[[32]byte]protocol.Account) (stateRel map[[32]byte]*protocol.RelativeAccount)
This function is needed because the state has a different role in the code now (it's not changed after block validation directly).
func GetTxPubKeys ¶
Get all pubKeys involved in AccTx, FundsTx of a given block
func InitLogger ¶
func ReadAllAssignedTx ¶
func ReadAllAssignedTx() (allAssignedTxs []protocol.Transaction)
func ReadAllBootstrapReceivedTransactions ¶
func ReadAllBootstrapReceivedTransactions() (allOpenTxs []protocol.Transaction)
func ReadAllClosedBlocks ¶
This method does read all blocks in closedBlocks & closedblockswithouttx.
func ReadAllClosedFundsAndAggTransactions ¶
func ReadAllClosedFundsAndAggTransactions() (allClosedTransactions []protocol.Transaction)
func ReadAllDataSummary ¶
func ReadAllDataSummary() []*protocol.DataSummary
func ReadAllINVALIDOpenTx ¶
func ReadAllINVALIDOpenTx() (allOpenInvalidTxs []protocol.Transaction)
func ReadAllOpenTxs ¶
func ReadAllOpenTxs() (allOpenTxs []protocol.Transaction)
Needed for the miner to prepare a new block
func ReadAssignedTx ¶
func ReadAssignedTx(hash [32]byte) (transaction protocol.Transaction)
func ReadClosedBlock ¶
func ReadClosedBlockWithoutTx ¶
This function does read all blocks without transactions inside.
func ReadClosedEpochBlock ¶
func ReadClosedEpochBlock(hash [32]byte) (epochBlock *protocol.EpochBlock)
func ReadClosedTx ¶
func ReadClosedTx(hash [32]byte) (transaction protocol.Transaction)
Personally I like it better to test (which tx type it is) here, and get returned the interface. Simplifies the code
func ReadFirstEpochBlock ¶
func ReadFirstEpochBlock() (firstEpochBlock *protocol.EpochBlock, err error)
func ReadGenesis ¶
func ReadINVALIDOpenTx ¶
func ReadINVALIDOpenTx(hash [32]byte) (transaction protocol.Transaction)
func ReadLastClosedBlock ¶
func ReadLastClosedEpochBlock ¶
func ReadLastClosedEpochBlock() (epochBlock *protocol.EpochBlock)
func ReadOpenBlock ¶
Always return nil if requested hash is not in the storage. This return value is then checked against by the caller
func ReadOpenEpochBlock ¶
func ReadOpenEpochBlock(hash [32]byte) (epochBlock *protocol.EpochBlock)
func ReadOpenTx ¶
func ReadOpenTx(hash [32]byte) (transaction protocol.Transaction)
func ReadOpenTxHashToDelete ¶
func ReadReceivedBlockStash ¶
func ReadStateTransitionFromOwnStash ¶
func ReadStateTransitionFromOwnStash(height int) *protocol.StateTransition
func ReadTxcntToTx ¶
func ResetOpenTxHashToDeleteMempool ¶
func ResetOpenTxHashToDeleteMempool()
func UpdateDataSummary ¶
func WriteAllClosedTxAndReturnAlreadyClosedTxHashes ¶
func WriteAllClosedTxAndReturnAlreadyClosedTxHashes(accTxs []*protocol.AccTx, stakeTxs []*protocol.StakeTx, committeeTxs []*protocol.CommitteeTx, fundsTxs []*protocol.FundsTx, aggTxs []*protocol.AggTx, dataTxs []*protocol.DataTx, aggDataTxs []*protocol.AggDataTx, fineTxs []*protocol.FineTx) (alreadyIncludedTxHashes [][32]byte, err error)
In this method, we can detect whether the transaction included in the block is already in closed storage. If it is already there, there are 2 options. Either the committee or the shard was malicious If bespoke transaction was in the transaction assignment, the committee leader was malicious If bespoke transaction was not in the transaction assignment, the shard was malicious To make the code more efficient and performant, the check of who is actually malicious will be conducted at a different part of the code
func WriteBootstrapTxReceived ¶
func WriteBootstrapTxReceived(transaction protocol.Transaction)
func WriteClosedBlock ¶
func WriteClosedEpochBlock ¶
func WriteClosedEpochBlock(epochBlock *protocol.EpochBlock) error
func WriteClosedTx ¶
func WriteClosedTx(transaction protocol.Transaction) (err error)
func WriteDataSummary ¶
func WriteDataSummary(ds *protocol.DataSummary) (err error)
func WriteFirstEpochBlock ¶
func WriteFirstEpochBlock(epochBlock *protocol.EpochBlock) error
func WriteGenesis ¶
func WriteINVALIDOpenTx ¶
func WriteINVALIDOpenTx(transaction protocol.Transaction)
func WriteLastClosedBlock ¶
TODO UNCOMMENT
func WriteClosedBlockWithoutTx(block *protocol.Block) (err error) {
err = db.Update(func(tx *bolt.Tx) error { b := tx.Bucket([]byte("closedblockswithouttx")) err := b.Put(block.HashWithoutTx[:], block.Encode()) return err }) return err }
func WriteLastClosedEpochBlock ¶
func WriteLastClosedEpochBlock(epochBlock *protocol.EpochBlock) (err error)
func WriteOpenBlock ¶
func WriteOpenTx ¶
func WriteOpenTx(transaction protocol.Transaction)
Changing the "tx" shortcut here and using "transaction" to distinguish between bolt's transactions write open tx doesnt allow for a tx to be added twice
func WriteOpenTxHashToDelete ¶
func WriteOpenTxHashToDelete(hash [32]byte)
func WriteToOwnStateTransitionkStash ¶
func WriteToOwnStateTransitionkStash(st *protocol.StateTransition)