kaspad/blockdag
Ori Newman d3b1953deb
[NOD-848] optimize utxo diffs serialize allocations (#666)
* [NOD-848] Optimize allocations when serializing UTXO diffs

* [NOD-848] Use same UTXO serialization everywhere, and use compression as well

* [NOD-848] Fix usage of wrong buffer

* [NOD-848] Fix tests

* [NOD-848] Fix wire tests

* [NOD-848] Fix tests

* [NOD-848] Remove VLQ

* [NOD-848] Fix comments

* [NOD-848] Add varint for big endian encoding

* [NOD-848] In TestVarIntWire, assume the expected decoded value is the same as the serialization input

* [NOD-848] Serialize outpoint index with big endian varint

* [NOD-848] Remove p2pk from compression support

* [NOD-848] Fix comments

* [NOD-848] Remove p2pk from decompression support

* [NOD-848] Make entry compression optional

* [NOD-848] Fix tests

* [NOD-848] Fix comments and var names

* [NOD-848] Remove UTXO compression

* [NOD-848] Fix tests

* [NOD-848] Remove big endian varint

* [NOD-848] Fix comments

* [NOD-848] Rename ReadVarIntLittleEndian->ReadVarInt and fix WriteVarInt comment

* [NOD-848] Add outpointIndexByteOrder variable

* [NOD-848] Remove redundant comment

* [NOD-848] Fix outpointMaxSerializeSize to the correct value

* [NOD-848] Move subBuffer to utils
2020-03-24 16:44:41 +02:00
..
2020-02-24 09:19:44 +02:00
2020-01-02 16:57:43 +02:00
2020-02-24 09:19:44 +02:00
2020-02-24 09:19:44 +02:00

blockchain

ISC License GoDoc

Package blockdag implements Kaspa block handling, organization of the blockDAG, block sorting and UTXO-set maintenance. The test coverage is currently only around 75%, but will be increasing over time.

Kaspad BlockDAG Processing Overview

Before a block is allowed into the block DAG, it must go through an intensive series of validation rules. The following list serves as a general outline of those rules to provide some intuition into what is going on under the hood, but is by no means exhaustive:

  • Reject duplicate blocks
  • Perform a series of sanity checks on the block and its transactions such as verifying proof of work, timestamps, number and character of transactions, transaction amounts, script complexity, and merkle root calculations
  • Save the most recent orphan blocks for a limited time in case their parent blocks become available.
  • Save blocks from the future for delayed processing
  • Stop processing if the block is an orphan or delayed as the rest of the processing depends on the block's position within the block chain
  • Make sure the block does not violate finality rules
  • Perform a series of more thorough checks that depend on the block's position within the blockDAG such as verifying block difficulties adhere to difficulty retarget rules, timestamps are after the median of the last several blocks, all transactions are finalized, checkpoint blocks match, and block versions are in line with the previous blocks
  • Determine how the block fits into the DAG and perform different actions accordingly
  • Run the transaction scripts to verify the spender is allowed to spend the coins
  • Run GhostDAG to fit the block in a canonical sorting
  • Build the block's UTXO Set, as well as update the global UTXO Set accordingly
  • Insert the block into the block database