mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-03-30 15:08:33 +00:00
10 Commits
Author | SHA1 | Message | Date | |
---|---|---|---|---|
![]() |
369a3bac09
|
Limit block mass instead of merge set limit + Introduce SigOpCount to TransactionInput (#1790)
* Update constants * Add to transaction SigOpCount * Update mass calculation, and move it from InContext to InIsolation * Update block validation accordingly * Add SigOpCount validation during TransactionInContext * Remove checking of mass vs maxMassAcceptedByBlock from consensusStateManager * Update mining manager with latest changes * Add SigOpCount to MsgTx.Copy() * Fix initTestTransactionAcceptanceDataForClone * Fix all tests in transaction_equal_clone_test.go * Fix TestBlockMass * Fix tests in transactionvalidator package * Add SigOpCount to sighash * Fix TestPruningDepth * Fix problems in libkaspawalelt * Fix integration tests * Fix CalculateSignatureHash tests * Remove remaining places talking about block size * Add sanity check to checkBlockMass to make sure all transactions have their mass filled * always add own sigOpCount to sigHash * Update protowire/rpc.md * Start working on removing any remaining reference to block/tx size * Update rpc transaction verbose data to include mass rather then size * Convert verboseData and block size check to mass * Remove remaining usages of tx size in mempool * Move transactionEstimatedSerializedSize to transactionvalidator * Add PopulateMass to fakeRelayInvsContext * Move PopulateMass to beggining of ValidateAndInsertTransaction + fix in it * Assign mass a new number for backward-compatibility |
||
![]() |
798c5fab7d
|
Add allowOrphans to rpcclient.SubmitTransaction (#1765) | ||
![]() |
c13a4d90ed
|
Mempool redesign (#1752)
* Added model and stubs for all main methods * Add constructors to all main objects * Implement BlockCandidateTransactions * implement expireOldTransactions and expireOrphanTransactions * Rename isHighPriority to neverExpires * Add stub for checkDoubleSpends * Revert "Rename isHighPriority to neverExpires" This reverts commit b2da9a4a00c02fb380d2518cf54fa16257bd8423. * Imeplement transactionsOrderedByFeeRate * Orphan maps should be idToOrphan * Add error.go to mempool * Invert the condition for banning when mempool rejects a transaction * Move all model objects to model package * Implement getParentsInPool * Implemented mempoolUTXOSet.addTransaction * Implement removeTransaction, remove sanity checks * Implemented mempoolUTXOSet.checkDoubleSpends * Implemented removeOrphan * Implement removeOrphan * Implement maybeAddOrphan and AddOrphan * Implemented processOrphansAfterAcceptedTransaction * Implement transactionsPool.addTransaction * Implement RemoveTransaction * If a transaction was removed from the mempool - update it's redeemers in orphan pool as well * Use maximumOrphanTransactionCount * Add allowOrphans to ValidateAndInsertTransaction stub * Implement validateTransaction functions * Implement fillInputs * Implement ValidateAndInsertTransaction * Implement HandleNewBlockTransactions * Implement missing mempool interface methods * Add comments to exported functions * Call ValidateTransactionInIsolation where needed * Implement RevalidateHighPriorityTransactions * Rewire kaspad to use new mempool, and fix compilation errors * Update rebroadcast logic to use new structure * Handle non-standard transaction errors properly * Add mutex to mempool * bugfix: GetTransaction panics when ok is false * properly calculate targetBlocksPerSecond in config.go * Fix various lint errors and tests * Fix expected text in test for duplicate transactions * Skip the coinbase transaction in HandleNewBlockTransactions * Unorphan the correct transactions * Call ValidateTransactionAndPopulateWithConsensusData on unorphanTransaction * Re-apply policy_test as check_transactions_standard_test * removeTransaction: Remove redeemers in orphan pool as well * Remove redundant check for uint64 < 0 * Export and rename isDust -> IsTransactionOutputDust to allow usage by rothschild * Add allowOrphan to SubmitTransaction RPC request * Remove all implementation from mempool.go * tidy go mod * Don't pass acceptedOrphans to handleNewBlockTransactions * Use t.Errorf in stead of t.Fatalf * Remove minimum relay fee from TestDust, as it's no longer configurable * Add separate VirtualDAASCore method for faster retrieval where it's repeated multiple times * Broadcast all transactions that were accepted * Don't re-use GetVirtualDAAScore in GetVirtualInfo - this causes a deadlock * Use real transaction count, and not Orphan * Get mempool config from outside, incorporating values received from cli * Use MinRelayFee and MaxOrphanTxs from global kaspad config * Add explanation for the seemingly redundant check for transaction version in checkTransactionStandard * Update some comment * Convert creation of acceptedTransactions to a single line * Move mempoolUTXOSet out of checkDoubleSpends * Add test for attempt to insert double spend into mempool * fillInputs: Skip check for coinbase - it's always false in mempool * Clarify comment about removeRedeemers when removing random orphan * Don't remove high-priority transactions in limitTransactionCount * Use mempool.removeTransaction in limitTransactionCount * Add mutex comment to handleNewBlockTransactions * Return error from limitTransactionCount * Pluralize the map types * mempoolUTXOSet.removeTransaction: Don't restore utxo if it was not created in mempool * Don't evacuate from orphanPool high-priority transactions * Disallow double-spends in orphan pool * Don't use exported (and locking) methods from inside mempool * Check for double spends in mempool during revalidateTransaction * Add checkOrphanDuplicate * Add orphan to acceptedOrphans, not current * Add TestHighPriorityTransactions * Fix off-by-one error in limitTransactionCount * Add TestRevalidateHighPriorityTransactions * Remove checkDoubleSpends from revalidateTransaction * Fix TestRevalidateHighPriorityTransactions * Move check for MaximumOrphanCount to beggining of maybeAddOrphan * Rename all map type to singulateToSingularMap * limitOrphanPool only after the orphan was added * TestDoubleSpendInMempool: use createChildTxWhenParentTxWasAddedByConsensus instead of createTransactionWithUTXOEntry * Fix some comments * Have separate min/max transaction versions for mempool * Add comment on defaultMaximumOrphanTransactionCount to keep it small as long as we have recursion * Fix comment * Rename: createChildTxWhenParentTxWasAddedByConsensus -> createChildTxWhereParentTxWasAddedByConsensus * Handle error from createChildTxWhereParentTxWasAddedByConsensus * Rename createChildTxWhereParentTxWasAddedByConsensus -> createChildAndParentTxsAndAddParentToConsensus * Convert all MaximumXXX constants to uint64 * Add comment * remove mutex comments |
||
![]() |
c5b0394bbc
|
In RPC, use RPCTransactions and RPCBlocks instead of TransactionMessages and BlockMessages (#1609)
* Replace BlockMessage with RpcBlock in rpc.proto. * Convert everything in kaspad to use RPCBlocks and fix tests. * Fix compilation errors in stability tests and the miner. * Update TransactionVerboseData in rpc.proto. * Update TransactionVerboseData in the rest of kaspad. * Make golint happy. * Include RpcTransactionVerboseData in RpcTransaction instead of the other way around. * Regenerate rpc.pb.go after merge. * Update appmessage types. * Update appmessage request and response types. * Reimplement conversion functions between appmessage.RPCTransaction and protowire.RpcTransaction. * Extract RpcBlockHeader toAppMessage/fromAppMessage out of RpcBlock. * Fix compilation errors in getBlock, getBlocks, and submitBlock. * Fix compilation errors in getMempoolEntry. * Fix compilation errors in notifyBlockAdded. * Update verbosedata.go. * Fix compilation errors in getBlock and getBlocks. * Fix compilation errors in getBlocks tests. * Fix conversions between getBlocks message types. * Fix integration tests. * Fix a comment. * Add selectedParent to the verbose block response. |
||
![]() |
d9449a32b8
|
Use DAA score where needed (#1602)
* Replace blue score with DAA score in UTXO entries * Use DAA score for coinbase maturity * Use DAA score for sequence lock * Fix calcBlockSubsidy to use DAA score * Don't pay to blocks that are not included in the DAA added blocks, and bestow red blocks reward to the merging block * Fix TestGetPruningPointUTXOs * Fix TestTransactionAcceptance * Fix TestChainedTransactions * Fix TestVirtualDiff * Fix TestBlockWindow * Fix TestPruning * Use NewFromSlice instead of manually creating the hash set * Add assert * Add comment * Remove redundant call to UpdateDAADataAndReturnDifficultyBits * Add RequiredDifficulty, rename UpdateDAADataAndReturnDifficultyBits to StageDAADataAndReturnRequiredDifficulty and add comments * Make buildUTXOInvalidHeader get bits as an argument * Fix comments |
||
![]() |
53781eed4d
|
Remove payload hash (#1583)
* Remove payload hash * Fix tests |
||
![]() |
8a309a7d2a
|
Upgradability mechanisms script version (#1313)
* '' * '' * '' * Changes genesis block version to 0. * a * a * All tests are done. * All tests passed for changed block version from int32 to uint16 * Adds validation of rejecting blocks with unknown versions. * Changes txn version from int32 to uint16. * . * Adds comments to exported functions. * Change functions name from ConvertFromRpcScriptPubKeyToRPCScriptPubKey to ConvertFromAppMsgRPCScriptPubKeyToRPCScriptPubKey and from ConvertFromRPCScriptPubKeyToRpcScriptPubKey to ConvertFromRPCScriptPubKeyToAppMsgRPCScriptPubKey * change comment to "ScriptPublicKey represents a Kaspad ScriptPublicKey" * delete part (tx.Version < 0) that cannot be exist on the if statement. * Revert protobuf version. * Fix a comment. * Fix a comment. * Rename a variable. * Rename a variable. * Remove a const. * Rename a type. * Rename a field. * Rename a field. * Remove commented-out code. * Remove dangerous nil case in DomainTransactionOutput.Clone(). * Remove a constant. * Fix a string. * Fix wrong totalScriptPubKeySize in transactionMassStandalonePart. * Remove a constant. * Remove an unused error. * Fix a serialization error. * Specify version types to be uint16 explicitly. * Use constants.ScriptPublicKeyVersion. * Fix a bad test. * Remove some whitespace. * Add a case to utxoEntry.Equal(). * Rename scriptPubKey to scriptPublicKey. * Remove a TODO. * Rename constants. * Rename a variable. * Add version to parseShortForm. Co-authored-by: tal <tal@daglabs.com> Co-authored-by: stasatdaglabs <stas@daglabs.com> |
||
![]() |
053bb351b5
|
[NOD-1597] Implement a UTXO index (#1221)
* [NOD-1579] Rename AcceptedTxIDs to AcceptedTransactionIDs. * [NOD-1579] Add InsertBlockResult to ValidateAndInsertBlock results. * [NOD-1593] Rename InsertBlockResult to BlockInsertionResult. * [NOD-1593] Add SelectedParentChainChanges to AddBlockToVirtual's result. * [NOD-1593] Implement findSelectedParentChainChanges. * [NOD-1593] Implement TestFindSelectedParentChainChanges. * [NOD-1593] Fix a string. * [NOD-1593] Finish implementing TestFindSelectedParentChainChanges. * [NOD-1593] Fix merge errors. * [NOD-1597] Begin implementing UTXOIndex. * [NOD-1597] Connect UTXOIndex to RPC. * [NOD-1597] Connect Consensus to UTXOIndex. * [NOD-1597] Add AcceptanceData to BlockInfo. * [NOD-1597] Implement UTXOIndex.Update(). * [NOD-1597] Implement add(), remove(), and discard() in utxoIndexStore. * [NOD-1597] Add error cases to add() and remove(). * [NOD-1597] Add special cases to add() and remove(). * [NOD-1597] Implement commit. * [NOD-1597] Add a mutex around UTXOIndex.Update(). * [NOD-1597] Return changes to the UTXO from Update(). * [NOD-1597] Add NotifyUTXOsChangedRequestMessage and related structs. * [NOD-1597] Implement HandleNotifyUTXOsChanged. * [NOD-1597] Begin implementing TestUTXOIndex. * [NOD-1597] Implement RegisterForUTXOsChangedNotifications. * [NOD-1597] Fix bad transaction.ID usage. * [NOD-1597] Implement convertUTXOChangesToUTXOsChangedNotification. * [NOD-1597] Make UTXOsChangedNotificationMessage.Removed UTXOsByAddressesEntry instead of just RPCOutpoint so that the client can discern which address was the UTXO removed for. * [NOD-1597] Collect outpoints in TestUTXOIndex. * [NOD-1597] Rename RPC stuff. * [NOD-1597] Add messages for GetUTXOsByAddresses. * [NOD-1597] Implement HandleGetUTXOsByAddresses. * [NOD-1597] Implement GetUTXOsByAddresses. * [NOD-1597] Implement UTXOs(). * [NOD-1597] Implement getUTXOOutpointEntryPairs(). * [NOD-1597] Expand TestUTXOIndex. * [NOD-1597] Convert SubmitTransaction to use RPCTransaction instead of MsgTx. * [NOD-1597] Finish implementing TestUTXOIndex. * [NOD-1597] Add messages for GetVirtualSelectedParentBlueScore. * [NOD-1597] Implement HandleGetVirtualSelectedParentBlueScore and GetVirtualSelectedParentBlueScore. * [NOD-1597] Implement TestVirtualSelectedParentBlueScore. * [NOD-1597] Implement NotifyVirtualSelectedParentBlueScoreChanged. * [NOD-1597] Expand TestVirtualSelectedParentBlueScore. * [NOD-1597] Implement notifyVirtualSelectedParentBlueScoreChanged. * [NOD-1597] Make go lint happy. * [NOD-1593] Fix merge errors. * [NOD-1593] Rename findSelectedParentChainChanges to calculateSelectedParentChainChanges. * [NOD-1593] Expand TestCalculateSelectedParentChainChanges. * [NOD-1597] Add logs to utxoindex.go. * [NOD-1597] Add logs to utxoindex/store.go. * [NOD-1597] Add logs to RPCManager.NotifyXXX functions. * [NOD-1597] Ignore transactions that aren't accepted. * [NOD-1597] Use GetBlockAcceptanceData instead of GetBlockInfo. * [NOD-1597] Convert scriptPublicKey to string directly, instead of using hex. * [NOD-1597] Add a comment. * [NOD-1597] Guard against calling utxoindex methods when utxoindex is turned off. * [NOD-1597] Add lock to UTXOs. * [NOD-1597] Guard against calls to getUTXOOutpointEntryPairs when staging isn't empty. |
||
![]() |
281944762d
|
[NOD-1500] Glue between domain and application (#1007)
* [NOD-1500] Added Domain type and Constructor * [NOD-1500] Replaced dag+txpool with domain in flowContext * [NOD-1500] Replaced dag+txpool with domain in flowContext * [NOD-1500] Converters: domain objects from/to appmessage * [NOD-1500] Convert hashes to DomainHashes in appmessages * [NOD-1500] Remove references to daghash in dagconfig * [NOD-1500] Fixed all appmessage usages of hashes * [NOD-1500] Update all RPC to use domain * [NOD-1500] Big chunk of protocol flows re-wired to domain * [NOD-1500] Finished re-wiring all protocol flows to new Domain * [NOD-1500] Fix some mempool and kaspaminer compilation errors * [NOD-1500] Deleted util/{block,tx,daghash} and dbaccess * [NOD-1500] util.CoinbaseTransactionIndex -> transactionhelper.CoinbaseTransactionIndex * [NOD-1500] Fix txsigner * [NOD-1500] Removed all references to util/subnetworkid * [NOD-1500] Update RpcGetBlock related messages * [NOD-1500] Many more compilation fixes * [NOD-1500] Return full list of missing blocks for orphan resolution * [NOD-1500] Fixed handshake * [NOD-1500] Fixed flowcontext compilation * [NOD-1500] Update users of StartIBDIfRequired to handle error * [NOD-1500] Removed some more fields from RPC * [NOD-1500] Fix the getBlockTemplate flow * [NOD-1500] Fix HandleGetCurrentNetwork * [NOD-1500] Remove redundant code * [NOD-1500] Remove obsolete notifications * [NOD-1500] Split MiningManager and Consensus to separate fields in Domain * [NOD-1500] Update two wrong references to location of txscript * [NOD-1500] Added comments * [NOD-1500] Fix some tests * [NOD-1500] Removed serialization logic from appmessage * [NOD-1500] Rename database/serialization/messages.proto to dbobjects.proto * [NOD-1500] Delete integration tests * [NOD-1500] Remove txsort * [NOD-1500] Fix tiny bug * [NOD-1500] Remove rogue dependancy on bchd * [NOD-1500] Some stylistic fixes |
||
![]() |
4c915f12b7
|
[NOD-1319] Reimplement kaspad's RPC in gRPC (#914)
* [NOD-1319] Create the protorpc package. * [NOD-1319] Use a general ClientStream in closeSend. * [NOD-1319] Decouple p2pServer from gRPCServer. * [NOD-1319] Begin implementing rpcServer. * [NOD-1319] Move grpcStream to grpc_connection.go. * [NOD-1319] Fold the rpc messages.proto into a common message.proto. * [NOD-1319] Remove code duplication in MessageStream. * [NOD-1319] Rename methods in netadapter. * [NOD-1319] Rename message_xxx to p2p_xxx. * [NOD-1319] Section off p2p messages from rpc messages in messages.proto. * [NOD-1319] Split toPayload to a p2p part and and rpc part. * [NOD-1319] Rename msgxxx.go to p2p_msgxx.go in the appmessage package. * [NOD-1319] Implement GetCurrentVersionRequestMessage and GetCurrentVersionResponseMessage. * [NOD-1319] Implement toAppMessage and fromAppMessage for getCurrentNetwork * [NOD-1319] Make a temporary workaround so that tests pass. * [NOD-1319] Begin implementing the rpc manager. * [NOD-1319] Implement an initial routerInitializer for rpc. * [NOD-1319] Rename the spawn in routerInitializer. * [NOD-1319] Implement an RPC context. * [NOD-1319] Move the actual handlers to a separate package. * [NOD-1319] Use the correct value for the GetCurrentNetwork response. * [NOD-1319] Fix some names. * [NOD-1319] Begin implementing a cli rpc client. * [NOD-1319] Implement connecting to the RPC server. * [NOD-1319] Make sure that connecting to the server and sending/receiving messages works. * [NOD-1319] Make kaspactl2 speak in json strings. * [NOD-1319] Finish implementing kaspactl2. * [NOD-1319] Remove debug messages. * [NOD-1319] Properly handle errors in rpc.go. * [NOD-1319] Move the grpc client to a separate package. * [NOD-1319] Extract Post out of PostString. * [NOD-1319] Implement PostAppMessage. * [NOD-1319] Stub out submitBlock. * [NOD-1319] Stub out getBlockTemplate. * [NOD-1319] Combine request and reponse files. * [NOD-1319] Implement submitBlock. * [NOD-1319] Implement returning errors from RPC. * [NOD-1319] Begin implementing getBlockTemplate. * [NOD-1319] Add missing field in GetBlockTemplateRequestMessage. * [NOD-1319] Implement a minimal getBlockTemplate. * [NOD-1319] Add getBlockTemplate stuff to grpc. * [NOD-1319] Implement the rest of getBlockTemplate. * [NOD-1319] Add block/transaction added handlers to the protocol manager. * [NOD-1319] Implement NotifyTransactionAddedToMempool. * [NOD-1319] Implement NotifyBlockAddedToDAG. * [NOD-1319] Connect block/transaction added handlers. * [NOD-1319] Add notifyBlockAdded. * [NOD-1319] Add a notification system. * [NOD-1319] Improve the notification system. * [NOD-1319] Add a block added listener stub. * [NOD-1319] Add BlockAddedNotificationMessage. * [NOD-1319] Finish implementing HandleNotifyBlockAdded. * [NOD-1319] Println instead of Print in kaspactl2. * [NOD-1319] Remove unused flags in kaspactl2. * [NOD-1319] Make kaspaminer work with the new RPC. * [NOD-1319] Fix a bad log. * [NOD-1319] Make kaspaminer work. * [NOD-1319] Disconnect the old RPC. * [NOD-1319] Move grpcclient.go. * [NOD-1319] Begin generalizing the rpcClient. * [NOD-1319] Move errors to the side of the payload. * [NOD-1319] Add errors to appmessage. * [NOD-1319] Move AttachRouter to grpcclient. * [NOD-1319] Fix kaspaminer not handling responses. * [NOD-1319] Properly handle blockAddedNotifications. * [NOD-1319] Move errors into individual response objects. * [NOD-1319] Begin replacing the RPC client in the integration tests. * [NOD-1319] Implement GetPeerAddresses. * [NOD-1319] Implement GetPeerAddresses. * [NOD-1319] Fix setOnBlockAddedHandler. * [NOD-1319] Remove the old kaspactl. * [NOD-1319] Move ConvertGetBlockTemplateResultToBlock to the mining package. * [NOD-1319] Implement getSelectedTipHash. * [NOD-1319] Simplify testRPCRouter. * [NOD-1319] Write stubs for the required test RPC commands. * [NOD-1319] Implement a minimal getMempoolEntry. * [NOD-1319] Implement a minimal getMempoolEntry. * [NOD-1319] Implement getConnectedPeerInfo. * [NOD-1319] Delete the old RPC. * [NOD-1319] Fix a fromAppMessage. * [NOD-1319] Implement connectToPeer. * [NOD-1319] Fix a bug in registerForBlockAddedNotifications. * [NOD-1319] Fix a deadlock in closing notification listeners. * [NOD-1319] Fix merge errors. * [NOD-1319] Fix an import. * [NOD-1319] Properly handle errors in grpcclient. * [NOD-1319] Fix TestIBD. * [NOD-1319] Prevent kaspaminer from running when not connected. * [NOD-1319] Implement sendRawTransaction. * [NOD-1319] Implement sendRawTransaction in the client. * [NOD-1319] Extract a general RPC client from the integration test RPC client. * [NOD-1319] Use the general RPC client for the miner. * [NOD-1319] Move the rpcclient package out of netadapter. * [NOD-1319] Normalize onBlockAdded. * [NOD-1319] Begin implementing notifyChainChanged. * [NOD-1319] Implement the model for notifyChainChanged. * [NOD-1319] Implement conversions for notifyChainChanged. * [NOD-1319] Implement HandleNotifyChainChanged. * [NOD-1319] Normalize notifications. * [NOD-1319] Implement RegisterForChainChangedNotifications. * [NOD-1319] Begin connecting blockdag's chain-changed notification with the RPC. * [NOD-1319] Finish implementing notifyChainChanged. * [NOD-1319] Implement getBlockHex. * [NOD-1319] Rename getBlockHex to getBlock. * [NOD-1319] Implement the verbose model for getBlock. * [NOD-1319] Implement buildBlockVerboseData. * [NOD-1319] Implement buildTransactionVerboseData. * [NOD-1319] Move verboseData stuff to verbosedata.go. * [NOD-1319] Add includeTransactionVerboseData. * [NOD-1319] Begin implementing getSubnetwork. * [NOD-1319] Finish implementing getSubnetwork. * [NOD-1319] Begin implementing getChainFromBlock. * [NOD-1319] Finish implementing getChainFromBlock. * [NOD-1319] Begin implementing getBlocks. * [NOD-1319] Finish implementing getBlocks. * [NOD-1319] Fix bad responses in HandleNotifyChainChanged. * [NOD-1319] Fix bugs in verbosedata.go. * [NOD-1319] Fix more bugs in verbosedata.go. * [NOD-1319] Make go vet happy. * [NOD-1319] Extract handleBlockDAGNotifications to a method. * [NOD-1319] Add a newline. * [NOD-1319] Use peers instead of connections to check if connected. * [NOD-1319] Add a comment. * [NOD-1319] Lock the dag lock in getBlock. * [NOD-1319] Rename netAdapter.connections to p2pConnections. * [NOD-1319] In protowire, rename wireXXX to protoXXX. * [NOD-1319] Rename PostString to PostJSON. * [NOD-1319] Disallow empty transactions in SendRawTransaction. * [NOD-1319] Disallow empty blocks in SubmitBlocks. * [NOD-1319] Add SetLogger. * [NOD-1319] Fix an error message. * [NOD-1319] Fix an error message. * [NOD-1319] Rename testTimeout to rpcTimeout. * [NOD-1319] Rename SendRawTransaction to SubmitTransaction. * [NOD-1319] Rename ConnectToPeer to AddPeer. * [NOD-1319] Add missing longPollID to request. * [NOD-1319] Rename ChainChangedChainBlock to ChainBlock. * [NOD-1319] Rename Vin and Vout. * [NOD-1319] Implement RPCErrorf. * [NOD-1319] Fix RPCErrorf's comment. * [NOD-1319] Remove unused flags in kaspaminer. |