Blockchain and Mining
Last updated
Last updated
The Arcturus blockchain is in many ways similar to the Bitcoin blockchain, although it does have some differences. The main difference between Arcturus and Bitcoin with regard to the blockchain architecture is that, unlike Bitcoin, Arcturus blocks contain a copy of both the transaction list and the most recent state. Additionally, two other values, the block number and the difficulty, are also stored in the block. The basic block validation algorithm in Arcturus is as follows:
Check if the previous block referenced exists and is valid.
Check that the timestamp of the block is greater than that of the referenced previous block and less than 15 minutes into the future.
Check that the block number, difficulty, transaction root, uncle root, and gas limit (various low-level Arcturus-specific concepts) are valid.
Check that the proof-of-work on the block is valid.
Let be the state at the end of the previous block.
Let be the block's transaction list, with transactions. For all in , set . If any applications return an error, or if the total gas consumed in the block up until this point exceeds the , return an error.
Let be , bur adding the block reward paid to the miner.
Check if the Merkle tree root of the state is equal to the final state root provided in the block header. If it is, the block is valid; otherwise, it is not valid.
The approach may seem highly inefficient at first glance because it needs to store the entire state with each block, but in reality, efficiency should be comparable to that of Bitcoin. The reason is that the state is stored in the tree structure, and after every block, only a small part of the tree needs to be changed. Thus, in general, between two adjacent blocks, the vast majority of the tree should be the same, and therefore the data can be stored once and referenced twice using pointers (i.e., hashes of subtrees).
A special kind of tree known as a "Patricia tree" is used to accomplish this, including a modification to the Merkle tree concept that allows for nodes to be inserted and deleted, and not just changed, efficiently. Additionally, because all of the state information is part of the last block, there is no need to store the entire blockchain history - a strategy which, if it could be applied to Bitcoin, can be calculated to provide 5-20x savings in space.
A commonly asked question is "where" contract code is executed in terms of physical hardware. This has a simple answer: the process of executing contract code is part of the definition of the state transition function, which is part of the block validation algorithm, so if a transaction is added into block B, the code execution spawned by that transaction will be executed by all nodes, now and in the future, that download and validate block B.