diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000000..d653d1c4b9 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,2 @@ +[*.py] +max_line_length = 79 diff --git a/pyproject.toml b/pyproject.toml index 2f74c4be6c..218fdafc40 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -45,6 +45,7 @@ transform = [ "docc.python.transform", "docc.verbatim.transform", "docc.mistletoe.transform", + "docc.mistletoe.reference", "ethereum_spec_tools.docc.fix-indexes", "ethereum_spec_tools.docc.minimize-diffs", "docc.references.index", diff --git a/setup.cfg b/setup.cfg index 04d0109fca..609820a8c0 100644 --- a/setup.cfg +++ b/setup.cfg @@ -158,7 +158,7 @@ lint = flake8-spellcheck==0.28.0 doc = - docc>=0.1.0,<0.2.0 + docc>=0.2.0,<0.3.0 fladrif>=0.2.0,<0.3.0 optimized = diff --git a/src/ethereum/__init__.py b/src/ethereum/__init__.py index 7cfd43d838..f7eeebb47c 100644 --- a/src/ethereum/__init__.py +++ b/src/ethereum/__init__.py @@ -1,6 +1,6 @@ """ -Ethereum Specification -^^^^^^^^^^^^^^^^^^^^^^ +### Introduction + Seeing as internet connections have been vastly expanding across the world, spreading information has become as cheap as ever. Bitcoin, for example, has demonstrated the possibility of creating a decentralized, diff --git a/src/ethereum/arrow_glacier/__init__.py b/src/ethereum/arrow_glacier/__init__.py index b073990630..c2508b1d44 100644 --- a/src/ethereum/arrow_glacier/__init__.py +++ b/src/ethereum/arrow_glacier/__init__.py @@ -1,8 +1,6 @@ """ -Ethereum Arrow Glacier Hardfork -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -The Twelfth Ethereum hardfork. +The Arrow Glacier fork delays the difficulty bomb. There are no other changes +in this fork. """ from ethereum.fork_criteria import ByBlockNumber diff --git a/src/ethereum/arrow_glacier/utils/__init__.py b/src/ethereum/arrow_glacier/utils/__init__.py index 460b8bbb5d..224a4d269b 100644 --- a/src/ethereum/arrow_glacier/utils/__init__.py +++ b/src/ethereum/arrow_glacier/utils/__init__.py @@ -1,13 +1,3 @@ """ -Hardfork Utility Functions -^^^^^^^^^^^^^^^^^^^^^^^^^^ - -.. contents:: Table of Contents - :backlinks: none - :local: - -Introduction ------------- - -Utility functions used in this arrow_glacier version of specification. +Utility functions unique to this particular fork. """ diff --git a/src/ethereum/berlin/__init__.py b/src/ethereum/berlin/__init__.py index 2e8c0bd747..aede445333 100644 --- a/src/ethereum/berlin/__init__.py +++ b/src/ethereum/berlin/__init__.py @@ -1,8 +1,7 @@ """ -Ethereum Berlin Hardfork -^^^^^^^^^^^^^^^^^^^^^^^^ - -The Tenth Ethereum hardfork. +The Berlin fork adjusts the gas costs of the `ModExp` precompile and several +state access EVM instructions, introduces typed transaction envelopes along +with the first new transaction type—optional access lists. """ from ethereum.fork_criteria import ByBlockNumber diff --git a/src/ethereum/berlin/utils/__init__.py b/src/ethereum/berlin/utils/__init__.py index 6c8323cf54..224a4d269b 100644 --- a/src/ethereum/berlin/utils/__init__.py +++ b/src/ethereum/berlin/utils/__init__.py @@ -1,13 +1,3 @@ """ -Hardfork Utility Functions -^^^^^^^^^^^^^^^^^^^^^^^^^^ - -.. contents:: Table of Contents - :backlinks: none - :local: - -Introduction ------------- - -Utility functions used in this berlin version of specification. +Utility functions unique to this particular fork. """ diff --git a/src/ethereum/byzantium/__init__.py b/src/ethereum/byzantium/__init__.py index ca105eb4e8..c989263c80 100644 --- a/src/ethereum/byzantium/__init__.py +++ b/src/ethereum/byzantium/__init__.py @@ -1,8 +1,7 @@ """ -Ethereum Byzantium Hardfork -^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -The sixth Ethereum hardfork. +The Byzantium fork reduces the mining rewards, delays the difficulty bomb, +lets contracts make non-state-changing calls to other contracts, and adds +cryptographic primitives for layer 2 scaling. """ from ethereum.fork_criteria import ByBlockNumber diff --git a/src/ethereum/byzantium/utils/__init__.py b/src/ethereum/byzantium/utils/__init__.py index 472ef6c5de..224a4d269b 100644 --- a/src/ethereum/byzantium/utils/__init__.py +++ b/src/ethereum/byzantium/utils/__init__.py @@ -1,13 +1,3 @@ """ -Hardfork Utility Functions -^^^^^^^^^^^^^^^^^^^^^^^^^^ - -.. contents:: Table of Contents - :backlinks: none - :local: - -Introduction ------------- - -Utility functions used in this byzantium version of specification. +Utility functions unique to this particular fork. """ diff --git a/src/ethereum/constantinople/__init__.py b/src/ethereum/constantinople/__init__.py index 460ee1f78d..97610486ed 100644 --- a/src/ethereum/constantinople/__init__.py +++ b/src/ethereum/constantinople/__init__.py @@ -1,8 +1,7 @@ """ -Ethereum Constantinople Hardfork -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -The Seventh Ethereum hardfork. +The Constantinople fork reduces mining rewards, delays the difficulty bomb, +and introduces new EVM instructions for logical shifts, counterfactual +contract deployment, and computing bytecode hashes. """ from ethereum.fork_criteria import ByBlockNumber diff --git a/src/ethereum/constantinople/utils/__init__.py b/src/ethereum/constantinople/utils/__init__.py index ba6f9044df..224a4d269b 100644 --- a/src/ethereum/constantinople/utils/__init__.py +++ b/src/ethereum/constantinople/utils/__init__.py @@ -1,13 +1,3 @@ """ -Hardfork Utility Functions -^^^^^^^^^^^^^^^^^^^^^^^^^^ - -.. contents:: Table of Contents - :backlinks: none - :local: - -Introduction ------------- - -Utility functions used in this constantinople version of specification. +Utility functions unique to this particular fork. """ diff --git a/src/ethereum/crypto/__init__.py b/src/ethereum/crypto/__init__.py index 317d50571a..e676f81b3f 100644 --- a/src/ethereum/crypto/__init__.py +++ b/src/ethereum/crypto/__init__.py @@ -1,13 +1,3 @@ """ -Cryptographic Functions -^^^^^^^^^^^^^^^^^^^^^^^ - -.. contents:: Table of Contents - :backlinks: none - :local: - -Introduction ------------- - -Cryptographic primatives used in Ethereum. +Cryptographic primitives used in Ethereum. """ diff --git a/src/ethereum/dao_fork/__init__.py b/src/ethereum/dao_fork/__init__.py index b40f133907..c05bdd1d10 100644 --- a/src/ethereum/dao_fork/__init__.py +++ b/src/ethereum/dao_fork/__init__.py @@ -1,8 +1,7 @@ """ -Ethereum Dao Hardfork -^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -The third Ethereum hardfork. +The DAO Fork is a response to a smart contract exploit known as the 2016 DAO +Attack where a vulnerable contract was drained of its ether. This fork recovers +the stolen funds into a new contract. """ from ethereum.fork_criteria import ByBlockNumber diff --git a/src/ethereum/dao_fork/utils/__init__.py b/src/ethereum/dao_fork/utils/__init__.py index 94a87d541c..224a4d269b 100644 --- a/src/ethereum/dao_fork/utils/__init__.py +++ b/src/ethereum/dao_fork/utils/__init__.py @@ -1,13 +1,3 @@ """ -Hardfork Utility Functions -^^^^^^^^^^^^^^^^^^^^^^^^^^ - -.. contents:: Table of Contents - :backlinks: none - :local: - -Introduction ------------- - -Utility functions used in this Dao Fork version of specification. +Utility functions unique to this particular fork. """ diff --git a/src/ethereum/ethash.py b/src/ethereum/ethash.py index 10d6156d0d..454d75db60 100644 --- a/src/ethereum/ethash.py +++ b/src/ethereum/ethash.py @@ -1,15 +1,29 @@ """ -Ethash Functions -^^^^^^^^^^^^^^^^ - -.. contents:: Table of Contents - :backlinks: none - :local: - -Introduction ------------- - -Ethash algorithm related functionalities. +Ethash is a proof-of-work algorithm designed to be [ASIC] resistant through +[memory hardness][mem-hard]. + +To achieve memory hardness, computing Ethash requires access to subsets of a +large structure. The particular subsets chosen are based on the nonce and block +header, while the set itself is changed every [`epoch`]. + +At a high level, the Ethash algorithm is as follows: + +1. Create a **seed** value, generated with [`generate_seed`] and based on the + preceding block numbers. +1. From the seed, compute a pseudorandom **cache** with [`generate_cache`]. +1. From the cache, generate a **dataset** with [`generate_dataset`]. The + dataset grows over time based on [`DATASET_EPOCH_GROWTH_SIZE`]. +1. Miners hash slices of the dataset together, which is where the memory + hardness is introduced. Verification of the proof-of-work only requires the + cache to be able to recompute a much smaller subset of the full dataset. + +[`DATASET_EPOCH_GROWTH_SIZE`]: ref:ethereum.ethash.DATASET_EPOCH_GROWTH_SIZE +[`generate_dataset`]: ref:ethereum.ethash.generate_dataset +[`generate_cache`]: ref:ethereum.ethash.generate_cache +[`generate_seed`]: ref:ethereum.ethash.generate_seed +[`epoch`]: ref:ethereum.ethash.epoch +[ASIC]: https://en.wikipedia.org/wiki/Application-specific_integrated_circuit +[mem-hard]: https://en.wikipedia.org/wiki/Memory-hard_function """ from typing import Callable, Tuple, Union @@ -24,31 +38,95 @@ ) EPOCH_SIZE = 30000 +""" +Number of blocks before a dataset needs to be regenerated (known as an +"epoch".) See [`epoch`]. + +[`epoch`]: ref:ethereum.ethash.epoch +""" + INITIAL_CACHE_SIZE = 2**24 +""" +Size of the cache (in bytes) during the first epoch. Each subsequent epoch's +cache roughly grows by [`CACHE_EPOCH_GROWTH_SIZE`] bytes. See [`cache_size`]. + +[`CACHE_EPOCH_GROWTH_SIZE`]: ref:ethereum.ethash.CACHE_EPOCH_GROWTH_SIZE +[`cache_size`]: ref:ethereum.ethash.cache_size +""" + CACHE_EPOCH_GROWTH_SIZE = 2**17 +""" +After the first epoch, the cache size grows by roughly this amount. See +[`cache_size`]. + +[`cache_size`]: ref:ethereum.ethash.cache_size +""" + INITIAL_DATASET_SIZE = 2**30 +""" +Size of the dataset (in bytes) during the first epoch. Each subsequent epoch's +dataset roughly grows by [`DATASET_EPOCH_GROWTH_SIZE`] bytes. See +[`dataset_size`]. + +[`DATASET_EPOCH_GROWTH_SIZE`]: ref:ethereum.ethash.DATASET_EPOCH_GROWTH_SIZE +[`dataset_size`]: ref:ethereum.ethash.dataset_size +""" + DATASET_EPOCH_GROWTH_SIZE = 2**23 +""" +After the first epoch, the dataset size grows by roughly this amount. See +[`dataset_size`]. + +[`dataset_size`]: ref:ethereum.ethash.dataset_size +""" + HASH_BYTES = 64 +""" +Length of a hash, in bytes. +""" + MIX_BYTES = 128 +""" +Width of mix, in bytes. See [`generate_dataset_item`]. + +[`generate_dataset_item`]: ref:ethereum.ethash.generate_dataset_item +""" + CACHE_ROUNDS = 3 +""" +Number of times to repeat the [`keccak512`] step while generating the hash. See +[`generate_cache`]. + +[`keccak512`]: ref:ethereum.crypto.hash.keccak512 +[`generate_cache`]: ref:ethereum.ethash.generate_cache +""" + DATASET_PARENTS = 256 +""" +Number of parents of each dataset element. See [`generate_dataset_item`]. + +[`generate_dataset_item`]: ref:ethereum.ethash.generate_dataset_item +""" + HASHIMOTO_ACCESSES = 64 +""" +Number of accesses in the [`hashimoto`] loop. + +[`hashimoto`]: ref:ethereum.ethash.hashimoto +""" def epoch(block_number: Uint) -> Uint: """ Obtain the epoch number to which the block identified by `block_number` - belongs. + belongs. The first epoch is numbered zero. - Parameters - ---------- - block_number : - The number of the block of interest. + An Ethash epoch is a fixed number of blocks ([`EPOCH_SIZE`]) long, during + which the dataset remains constant. At the end of each epoch, the dataset + is generated anew. See [`generate_dataset`]. - Returns - ------- - epoch_number : `Uint` - The epoch number to which the passed in block belongs. + [`EPOCH_SIZE`]: ref:ethereum.ethash.EPOCH_SIZE + [`generate_dataset`]: ref:ethereum.ethash.generate_dataset """ return block_number // EPOCH_SIZE @@ -58,15 +136,18 @@ def cache_size(block_number: Uint) -> Uint: Obtain the cache size (in bytes) of the epoch to which `block_number` belongs. - Parameters - ---------- - block_number : - The number of the block of interest. + See [`INITIAL_CACHE_SIZE`] and [`CACHE_EPOCH_GROWTH_SIZE`] for the initial + size and linear growth rate, respectively. The cache is generated in + [`generate_cache`]. + + The actual cache size is smaller than simply multiplying + `CACHE_EPOCH_GROWTH_SIZE` by the epoch number to minimize the risk of + unintended cyclic behavior. It is defined as the highest prime number below + what linear growth would calculate. - Returns - ------- - cache_size_bytes : `Uint` - The cache size in bytes for the passed in block. + [`INITIAL_CACHE_SIZE`]: ref:ethereum.ethash.INITIAL_CACHE_SIZE + [`CACHE_EPOCH_GROWTH_SIZE`]: ref:ethereum.ethash.CACHE_EPOCH_GROWTH_SIZE + [`generate_cache`]: ref:ethereum.ethash.generate_cache """ size = INITIAL_CACHE_SIZE + (CACHE_EPOCH_GROWTH_SIZE * epoch(block_number)) size -= HASH_BYTES @@ -81,15 +162,20 @@ def dataset_size(block_number: Uint) -> Uint: Obtain the dataset size (in bytes) of the epoch to which `block_number` belongs. - Parameters - ---------- - block_number : - The number of the block of interest. + See [`INITIAL_DATASET_SIZE`] and [`DATASET_EPOCH_GROWTH_SIZE`][ds] for the + initial size and linear growth rate, respectively. The complete dataset is + generated in [`generate_dataset`], while the slices used in verification + are generated in [`generate_dataset_item`]. + + The actual dataset size is smaller than simply multiplying + `DATASET_EPOCH_GROWTH_SIZE` by the epoch number to minimize the risk of + unintended cyclic behavior. It is defined as the highest prime number below + what linear growth would calculate. - Returns - ------- - dataset_size_bytes : `Uint` - The dataset size in bytes for the passed in block. + [`INITIAL_DATASET_SIZE`]: ref:ethereum.ethash.INITIAL_DATASET_SIZE + [ds]: ref:ethereum.ethash.DATASET_EPOCH_GROWTH_SIZE + [`generate_dataset`]: ref:ethereum.ethash.generate_dataset + [`generate_dataset_item`]: ref:ethereum.ethash.generate_dataset_item """ size = INITIAL_DATASET_SIZE + ( DATASET_EPOCH_GROWTH_SIZE * epoch(block_number) @@ -104,17 +190,9 @@ def dataset_size(block_number: Uint) -> Uint: def generate_seed(block_number: Uint) -> Hash32: """ Obtain the cache generation seed for the block identified by - `block_number`. + `block_number`. See [`generate_cache`]. - Parameters - ---------- - block_number : - The number of the block of interest. - - Returns - ------- - seed : `Hash32` - The cache generation seed for the passed in block. + [`generate_cache`]: ref:ethereum.ethash.generate_cache """ epoch_number = epoch(block_number) @@ -128,18 +206,16 @@ def generate_seed(block_number: Uint) -> Hash32: def generate_cache(block_number: Uint) -> Tuple[Tuple[U32, ...], ...]: """ - Generate the cache for the block identified by `block_number`. This cache - would later be used to generate the full dataset. - - Parameters - ---------- - block_number : - The number of the block of interest. - - Returns - ------- - cache : `Tuple[Tuple[U32, ...], ...]` - The cache generated for the passed in block. + Generate the cache for the block identified by `block_number`. See + [`generate_dataset`] for how the cache is used. + + The cache is generated in two steps: filling the array with a chain of + [`keccak512`] hashes, then running two rounds of Sergio Demian Lerner's + [RandMemoHash] on those bytes. + + [`keccak512`]: ref:ethereum.crypto.hash.keccak512 + [`generate_dataset`]: ref:ethereum.ethash.generate_dataset + [RandMemoHash]: http://www.hashcash.org/papers/memohash.pdf """ seed = generate_seed(block_number) cache_size_bytes = cache_size(block_number) @@ -147,11 +223,9 @@ def generate_cache(block_number: Uint) -> Tuple[Tuple[U32, ...], ...]: cache_size_words = cache_size_bytes // HASH_BYTES cache = [keccak512(seed)] - previous_cache_item = cache[0] - for _ in range(1, cache_size_words): - cache_item = keccak512(previous_cache_item) + for index in range(1, cache_size_words): + cache_item = keccak512(cache[index - 1]) cache.append(cache_item) - previous_cache_item = cache_item for _ in range(CACHE_ROUNDS): for index in range(cache_size_words): @@ -175,26 +249,21 @@ def generate_cache(block_number: Uint) -> Tuple[Tuple[U32, ...], ...]: def fnv(a: Union[Uint, U32], b: Union[Uint, U32]) -> U32: """ - FNV algorithm is inspired by the FNV hash, which in some cases is used - as a non-associative substitute for XOR. + A non-associative substitute for XOR, inspired by the [FNV] hash by Fowler, + Noll, and Vo. See [`fnv_hash`], [`generate_dataset_item`], and + [`hashimoto`]. Note that here we multiply the prime with the full 32-bit input, in - contrast with the FNV-1 spec which multiplies the prime with - one byte (octet) in turn. - - Parameters - ---------- - a: - The first data point. - b : - The second data point. - - Returns - ------- - modified_mix_integers : `U32` - The result of performing fnv on the passed in data points. + contrast with the [FNV-1] spec which multiplies the prime with one byte + (octet) in turn. + + [`hashimoto`]: ref:ethereum.ethash.hashimoto + [`generate_dataset_item`]: ref:ethereum.ethash.generate_dataset_item + [`fnv_hash`]: ref:ethereum.ethash.fnv_hash + [FNV]: https://w.wiki/XKZ + [FNV-1]: http://www.isthe.com/chongo/tech/comp/fnv/#FNV-1 """ - # This is a faster way of doing [number % (2 ** 32)] + # This is a faster way of doing `number % (2 ** 32)`. result = ((Uint(a) * 0x01000193) ^ Uint(b)) & U32_MAX_VALUE return U32(result) @@ -203,20 +272,12 @@ def fnv_hash( mix_integers: Tuple[U32, ...], data: Tuple[U32, ...] ) -> Tuple[U32, ...]: """ - FNV Hash mixes in data into mix using the ethash fnv method. - - Parameters - ---------- - mix_integers: - Mix data in the form of a sequence of U32. - data : - The data (sequence of U32) to be hashed into the mix. - - Returns - ------- - modified_mix_integers : `Tuple[U32, ...]` - The result of performing the fnv hash on the mix and the passed in - data. + Combines `data` into `mix_integers` using [`fnv`]. See [`hashimoto`] and + [`generate_dataset_item`]. + + [`hashimoto`]: ref:ethereum.ethash.hashimoto + [`generate_dataset_item`]: ref:ethereum.ethash.generate_dataset_item + [`fnv`]: ref:ethereum.ethash.fnv """ return tuple( fnv(mix_integers[i], data[i]) for i in range(len(mix_integers)) @@ -227,22 +288,16 @@ def generate_dataset_item( cache: Tuple[Tuple[U32, ...], ...], index: Uint ) -> Hash64: """ - Generate a particular dataset item 0-indexed by `index` using `cache`. - Each dataset item is a byte stream of 64 bytes or a stream of 16 uint32 - numbers. - - Parameters - ---------- - cache: - The cache from which a subset of items will be used to generate the - dataset item. - index : - The index of the dataset item to generate. - - Returns - ------- - dataset_item : `Hash64` - The generated dataset item for passed index. + Generate a particular dataset item 0-indexed by `index` by hashing + pseudorandomly-selected entries from `cache` together. See [`fnv`] and + [`fnv_hash`] for the digest function, [`generate_cache`] for generating + `cache`, and [`generate_dataset`] for the full dataset generation + algorithm. + + [`fnv`]: ref:ethereum.ethash.fnv + [`fnv_hash`]: ref:ethereum.ethash.fnv_hash + [`generate_dataset`]: ref:ethereum.ethash.generate_dataset + [`generate_cache`]: ref:ethereum.ethash.generate_cache """ mix = keccak512( ( @@ -267,18 +322,8 @@ def generate_dataset(block_number: Uint) -> Tuple[Hash64, ...]: """ Generate the full dataset for the block identified by `block_number`. - This function is present only for demonstration purposes, as it will take - a long time to execute. - - Parameters - ---------- - block_number : - The number of the block of interest. - - Returns - ------- - dataset : `Tuple[Hash64, ...]` - The dataset generated for the passed in block. + This function is present only for demonstration purposes. It is not used + while validating blocks. """ dataset_size_bytes: Uint = dataset_size(block_number) cache: Tuple[Tuple[U32, ...], ...] = generate_cache(block_number) @@ -300,25 +345,22 @@ def hashimoto( Obtain the mix digest and the final value for a header, by aggregating data from the full dataset. - Parameters - ---------- - header_hash : - The PoW valid rlp hash of a header. - nonce : - The propogated nonce for the given block. - dataset_size : - Dataset size for the epoch to which the current block belongs to. - fetch_dataset_item : - The function which will be used to obtain a specific dataset item - from an index. - - Returns - ------- - mix_digest : `bytes` - The mix digest generated from the header hash and propogated nonce. - result : `Hash32` - The final result obtained which will be checked for leading zeros (in - byte representation) in correspondance with the block difficulty. + #### Parameters + + - `header_hash` is a valid [RLP hash] of a block header. + - `nonce` is the propagated nonce for the given block. + - `dataset_size` is the size of the dataset. See [`dataset_size`]. + - `fetch_dataset_item` is a function that retrieves a specific dataset item + based on its index. + + #### Returns + + - The mix digest generated from the header hash and propagated nonce. + - The final result obtained which will be checked for leading zeros (in + byte representation) in correspondence with the block difficulty. + + [RLP hash]: ref:ethereum.rlp.rlp_hash + [`dataset_size`]: ref:ethereum.ethash.dataset_size """ nonce_le = bytes(reversed(nonce)) seed_hash = keccak512(header_hash + nonce_le) @@ -356,44 +398,29 @@ def hashimoto_light( dataset_size: Uint, ) -> Tuple[bytes, Hash32]: """ - Run the hashimoto algorithm by generating dataset item using the cache + Run the [`hashimoto`] algorithm by generating dataset item using the cache instead of loading the full dataset into main memory. - Parameters - ---------- - header_hash : - The PoW valid rlp hash of a header. - nonce : - The propogated nonce for the given block. - cache: - The generated cache for the epoch to which the current block belongs - to. - dataset_size : - Dataset size for the epoch to which the current block belongs to. - - Returns - ------- - mix_digest : `bytes` - The mix digest generated from the header hash and propogated nonce. - result : `Hash32` - The final result obtained which will be checked for leading zeros (in - byte representation) in correspondance with the block difficulty. + #### Parameters + + - `header_hash` is a valid [RLP hash] of a block header. + - `nonce` is the propagated nonce for the given block. + - `cache` is the cache generated by [`generate_cache`]. + - `dataset_size` is the size of the dataset. See [`dataset_size`]. + + #### Returns + + - The mix digest generated from the header hash and propagated nonce. + - The final result obtained which will be checked for leading zeros (in + byte representation) in correspondence with the block difficulty. + + [RLP hash]: ref:ethereum.rlp.rlp_hash + [`dataset_size`]: ref:ethereum.ethash.dataset_size + [`generate_cache`]: ref:ethereum.ethash.generate_cache + [`hashimoto`]: ref:ethereum.ethash.hashimoto """ def fetch_dataset_item(index: Uint) -> Tuple[U32, ...]: - """ - Generate dataset item (as tuple of U32 numbers) from cache. - - Parameters - ---------- - index : - The index of the dataset item to generate. - - Returns - ------- - dataset_item : `Tuple[U32, ...]` - The generated dataset item for passed index. - """ item: Hash64 = generate_dataset_item(cache, index) return le_bytes_to_uint32_sequence(item) diff --git a/src/ethereum/frontier/__init__.py b/src/ethereum/frontier/__init__.py index 12d502babf..3a7fed59eb 100644 --- a/src/ethereum/frontier/__init__.py +++ b/src/ethereum/frontier/__init__.py @@ -1,8 +1,5 @@ """ -Ethereum Frontier Hardfork -^^^^^^^^^^^^^^^^^^^^^^^^^^ - -The first Ethereum hardfork. +Frontier is the first production-ready iteration of the Ethereum protocol. """ from ethereum.fork_criteria import ByBlockNumber diff --git a/src/ethereum/frontier/utils/__init__.py b/src/ethereum/frontier/utils/__init__.py index ca47178201..224a4d269b 100644 --- a/src/ethereum/frontier/utils/__init__.py +++ b/src/ethereum/frontier/utils/__init__.py @@ -1,13 +1,3 @@ """ -Hardfork Utility Functions -^^^^^^^^^^^^^^^^^^^^^^^^^^ - -.. contents:: Table of Contents - :backlinks: none - :local: - -Introduction ------------- - -Utility functions used in this frontier version of specification. +Utility functions unique to this particular fork. """ diff --git a/src/ethereum/gray_glacier/__init__.py b/src/ethereum/gray_glacier/__init__.py index 072c7ab9db..6bade27f32 100644 --- a/src/ethereum/gray_glacier/__init__.py +++ b/src/ethereum/gray_glacier/__init__.py @@ -1,8 +1,6 @@ """ -Ethereum Gray Glacier Hardfork -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -The Thirteenth Ethereum hardfork. +The Gray Glacier fork delays the difficulty bomb. There are no other changes +in this fork. """ from ethereum.fork_criteria import ByBlockNumber diff --git a/src/ethereum/gray_glacier/utils/__init__.py b/src/ethereum/gray_glacier/utils/__init__.py index 2327892b80..224a4d269b 100644 --- a/src/ethereum/gray_glacier/utils/__init__.py +++ b/src/ethereum/gray_glacier/utils/__init__.py @@ -1,13 +1,3 @@ """ -Hardfork Utility Functions -^^^^^^^^^^^^^^^^^^^^^^^^^^ - -.. contents:: Table of Contents - :backlinks: none - :local: - -Introduction ------------- - -Utility functions used in this gray_glacier version of specification. +Utility functions unique to this particular fork. """ diff --git a/src/ethereum/homestead/__init__.py b/src/ethereum/homestead/__init__.py index db6dae24bd..8fa64173b0 100644 --- a/src/ethereum/homestead/__init__.py +++ b/src/ethereum/homestead/__init__.py @@ -1,8 +1,8 @@ """ -Ethereum Homestead Hardfork -^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -The second Ethereum hardfork. +The Homestead fork increases the gas cost of creating contracts, restricts the +range of valid ECDSA signatures for transactions (but not precompiles), tweaks +the behavior of contract creation with insufficient gas, delays the +difficulty bomb, and adds an improved delegate call EVM instruction. """ from ethereum.fork_criteria import ByBlockNumber diff --git a/src/ethereum/homestead/utils/__init__.py b/src/ethereum/homestead/utils/__init__.py index fbac7607e7..224a4d269b 100644 --- a/src/ethereum/homestead/utils/__init__.py +++ b/src/ethereum/homestead/utils/__init__.py @@ -1,13 +1,3 @@ """ -Hardfork Utility Functions -^^^^^^^^^^^^^^^^^^^^^^^^^^ - -.. contents:: Table of Contents - :backlinks: none - :local: - -Introduction ------------- - -Utility functions used in this homestead version of specification. +Utility functions unique to this particular fork. """ diff --git a/src/ethereum/istanbul/__init__.py b/src/ethereum/istanbul/__init__.py index b9c574119a..b681c62a7a 100644 --- a/src/ethereum/istanbul/__init__.py +++ b/src/ethereum/istanbul/__init__.py @@ -1,8 +1,7 @@ """ -Ethereum Istanbul Hardfork -^^^^^^^^^^^^^^^^^^^^^^^^^^ - -The Eighth Ethereum hardfork. +The Istanbul fork makes changes to the gas costs of EVM instructions and data, +adds a cryptographic primitive, and introduces an instruction to fetch the +current chain identifier. """ from ethereum.fork_criteria import ByBlockNumber diff --git a/src/ethereum/istanbul/utils/__init__.py b/src/ethereum/istanbul/utils/__init__.py index d406d543a1..224a4d269b 100644 --- a/src/ethereum/istanbul/utils/__init__.py +++ b/src/ethereum/istanbul/utils/__init__.py @@ -1,13 +1,3 @@ """ -Hardfork Utility Functions -^^^^^^^^^^^^^^^^^^^^^^^^^^ - -.. contents:: Table of Contents - :backlinks: none - :local: - -Introduction ------------- - -Utility functions used in this istanbul version of specification. +Utility functions unique to this particular fork. """ diff --git a/src/ethereum/london/__init__.py b/src/ethereum/london/__init__.py index 83042aeef3..9c63e1112b 100644 --- a/src/ethereum/london/__init__.py +++ b/src/ethereum/london/__init__.py @@ -1,8 +1,6 @@ """ -Ethereum London Hardfork -^^^^^^^^^^^^^^^^^^^^^^^^ - -The Eleventh Ethereum hardfork. +The London fork overhauls the transaction fee market, changes gas refunds, +reserves a contract prefix for future use, and delays the difficulty bomb. """ from ethereum.fork_criteria import ByBlockNumber diff --git a/src/ethereum/london/utils/__init__.py b/src/ethereum/london/utils/__init__.py index c992f3f130..224a4d269b 100644 --- a/src/ethereum/london/utils/__init__.py +++ b/src/ethereum/london/utils/__init__.py @@ -1,13 +1,3 @@ """ -Hardfork Utility Functions -^^^^^^^^^^^^^^^^^^^^^^^^^^ - -.. contents:: Table of Contents - :backlinks: none - :local: - -Introduction ------------- - -Utility functions used in this london version of specification. +Utility functions unique to this particular fork. """ diff --git a/src/ethereum/muir_glacier/__init__.py b/src/ethereum/muir_glacier/__init__.py index f4e15c41cc..5dab5b3ab9 100644 --- a/src/ethereum/muir_glacier/__init__.py +++ b/src/ethereum/muir_glacier/__init__.py @@ -1,8 +1,6 @@ """ -Ethereum Muir Glacier Hardfork -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -The Ninth Ethereum hardfork. +The Muir Glacier fork delays the difficulty bomb. There are no other changes +in this fork. """ from ethereum.fork_criteria import ByBlockNumber diff --git a/src/ethereum/muir_glacier/utils/__init__.py b/src/ethereum/muir_glacier/utils/__init__.py index 796d16fb68..224a4d269b 100644 --- a/src/ethereum/muir_glacier/utils/__init__.py +++ b/src/ethereum/muir_glacier/utils/__init__.py @@ -1,13 +1,3 @@ """ -Hardfork Utility Functions -^^^^^^^^^^^^^^^^^^^^^^^^^^ - -.. contents:: Table of Contents - :backlinks: none - :local: - -Introduction ------------- - -Utility functions used in this muir_glacier version of specification. +Utility functions unique to this particular fork. """ diff --git a/src/ethereum/paris/__init__.py b/src/ethereum/paris/__init__.py index 2717efce5f..37f14d7923 100644 --- a/src/ethereum/paris/__init__.py +++ b/src/ethereum/paris/__init__.py @@ -1,8 +1,10 @@ """ -Ethereum Paris Hardfork -^^^^^^^^^^^^^^^^^^^^^^^ +The Paris fork transitions Ethereum from a proof-of-work consensus model to a +proof-of-stake one. This fork is often referred to as "The Merge" because it +marks the integration of the [consensus layer] with the execution layer +(defined in this project.) -The Fourteenth Ethereum hardfork. +[consensus layer]: https://github.com/ethereum/consensus-specs """ from ethereum.fork_criteria import ByBlockNumber diff --git a/src/ethereum/paris/utils/__init__.py b/src/ethereum/paris/utils/__init__.py index f64befb3eb..224a4d269b 100644 --- a/src/ethereum/paris/utils/__init__.py +++ b/src/ethereum/paris/utils/__init__.py @@ -1,13 +1,3 @@ """ -Hardfork Utility Functions -^^^^^^^^^^^^^^^^^^^^^^^^^^ - -.. contents:: Table of Contents - :backlinks: none - :local: - -Introduction ------------- - -Utility functions used in this paris version of specification. +Utility functions unique to this particular fork. """ diff --git a/src/ethereum/shanghai/__init__.py b/src/ethereum/shanghai/__init__.py index e7b44b575b..b13a98bb29 100644 --- a/src/ethereum/shanghai/__init__.py +++ b/src/ethereum/shanghai/__init__.py @@ -1,8 +1,7 @@ """ -Ethereum Shanghai Hardfork -^^^^^^^^^^^^^^^^^^^^^^^^^^ - -The Fourteenth Ethereum hardfork. +The Shanghai fork brings staking withdrawals to the execution layer, adds a +push-zero EVM instruction, limits the maximum size of initialization +bytecode, and deprecates the self-destruct EVM instruction. """ from ethereum.fork_criteria import ByTimestamp diff --git a/src/ethereum/shanghai/utils/__init__.py b/src/ethereum/shanghai/utils/__init__.py index b368798746..224a4d269b 100644 --- a/src/ethereum/shanghai/utils/__init__.py +++ b/src/ethereum/shanghai/utils/__init__.py @@ -1,13 +1,3 @@ """ -Hardfork Utility Functions -^^^^^^^^^^^^^^^^^^^^^^^^^^ - -.. contents:: Table of Contents - :backlinks: none - :local: - -Introduction ------------- - -Utility functions used in this shanghai version of specification. +Utility functions unique to this particular fork. """ diff --git a/src/ethereum/spurious_dragon/__init__.py b/src/ethereum/spurious_dragon/__init__.py index 964103ac22..2835fe52ef 100644 --- a/src/ethereum/spurious_dragon/__init__.py +++ b/src/ethereum/spurious_dragon/__init__.py @@ -1,8 +1,9 @@ """ -Ethereum Spurious Dragon Hardfork -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -The fifth Ethereum hardfork. +The Spurious Dragon fork is the second of two forks responding to a +denial-of-service attack on the Ethereum network. It tunes the prices of EVM +instructions, adds protection against replaying transaction on different +chains, limits the maximum size of contract code, and enables the removal of +empty accounts. """ from ethereum.fork_criteria import ByBlockNumber diff --git a/src/ethereum/spurious_dragon/utils/__init__.py b/src/ethereum/spurious_dragon/utils/__init__.py index 1a1ec3e39b..224a4d269b 100644 --- a/src/ethereum/spurious_dragon/utils/__init__.py +++ b/src/ethereum/spurious_dragon/utils/__init__.py @@ -1,13 +1,3 @@ """ -Hardfork Utility Functions -^^^^^^^^^^^^^^^^^^^^^^^^^^ - -.. contents:: Table of Contents - :backlinks: none - :local: - -Introduction ------------- - -Utility functions used in this spurious dragon version of specification. +Utility functions unique to this particular fork. """ diff --git a/src/ethereum/tangerine_whistle/__init__.py b/src/ethereum/tangerine_whistle/__init__.py index a4ac4a1f76..a8e1c4574e 100644 --- a/src/ethereum/tangerine_whistle/__init__.py +++ b/src/ethereum/tangerine_whistle/__init__.py @@ -1,8 +1,8 @@ """ -Ethereum Tangerine Whistle Hardfork -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -The fourth Ethereum hardfork. +The Tangerine Whistle fork is the first of two forks responding to a +denial-of-service attack on the Ethereum network. It tunes the price of various +EVM instructions, and reduces the state size by removing a number of empty +accounts. """ from ethereum.fork_criteria import ByBlockNumber diff --git a/src/ethereum/tangerine_whistle/utils/__init__.py b/src/ethereum/tangerine_whistle/utils/__init__.py index d70f2c885e..224a4d269b 100644 --- a/src/ethereum/tangerine_whistle/utils/__init__.py +++ b/src/ethereum/tangerine_whistle/utils/__init__.py @@ -1,13 +1,3 @@ """ -Hardfork Utility Functions -^^^^^^^^^^^^^^^^^^^^^^^^^^ - -.. contents:: Table of Contents - :backlinks: none - :local: - -Introduction ------------- - -Utility functions used in this tangerine whistle version of specification. +Utility functions unique to this particular fork. """ diff --git a/src/ethereum/utils/__init__.py b/src/ethereum/utils/__init__.py index c5aca36680..0996b4c3b4 100644 --- a/src/ethereum/utils/__init__.py +++ b/src/ethereum/utils/__init__.py @@ -1,13 +1,3 @@ """ -Utility Functions -^^^^^^^^^^^^^^^^^ - -.. contents:: Table of Contents - :backlinks: none - :local: - -Introduction ------------- - Utility functions used in this specification. """