-
Notifications
You must be signed in to change notification settings - Fork 3
feature: block production #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]>
Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]>
Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]>
Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]>
| BOOST_ASSERT_MSG(enc_res.has_value(), | ||
| "Header should be encoded errorless"); | ||
| hash_opt.emplace(hasher.blake2b_256(enc_res.value())); | ||
| hash_opt.emplace(hasher.sha2_256(enc_res.value())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| hash_opt.emplace(hasher.sha2_256(enc_res.value())); | |
| hash_opt.emplace(ssz::hash_tree_root(*this)); |
| std::size_t operator()(const lean::BlockIndex &s) const noexcept { | ||
| std::size_t h = std::hash<lean::Slot>{}(s.slot); | ||
| for (auto b : s.hash) { | ||
| h ^= std::hash<std::uint8_t>{}(b) + 0x9e3779b97f4a7c15ULL + (h << 6) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
boost::hash_combine?
| Default = 0, ///< Default space used for general-purpose storage | ||
| LookupKey, ///< Space used for mapping lookup keys | ||
| Default = 0, ///< Default space used for general-purpose storage | ||
| SlotToHashes, ///< Space used for mapping lookup keys |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it store "best" chain (map<slot, hash>),
or would it also store unfinalized forks (map<(slot, hash), is_best>)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it store "one-to-multiple" records
Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]>
Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces block production capabilities to the lean Ethereum client, implementing a basic block production pipeline without the full block tree yet. The changes span multiple modules including cryptography, storage, blockchain management, and introduce a new production module.
- Adds SHA-256 hashing support and simplifies the hasher interface by commenting out unused hash functions
- Implements block tree structure with cached tree management for efficient block organization
- Introduces production module with slot-based block generation and timeline management
Reviewed Changes
Copilot reviewed 80 out of 88 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/blockchain/block_storage_test.cpp | Updates test cases to use SHA-256 instead of blake2b and fixes storage space references |
| tests/mock/crypto/hasher_mock.hpp | Comments out unused hash function mocks, keeping only SHA-256 |
| src/types/* | Adds new type definitions for blocks, headers, and blockchain primitives |
| src/crypto/hasher* | Implements SHA-256 hashing and comments out unused hash functions |
| src/blockchain/impl/* | Implements block tree, storage utilities, and cached tree management |
| src/modules/production/* | New production module for block generation with slot-based timeline |
| src/app/impl/timeline_impl.* | Implements timeline management for slot progression |
| src/storage/spaces.hpp | Updates storage space names from LookupKey to SlotToHashes |
Comments suppressed due to low confidence (1)
src/modules/shared/prodution_types.tmp.hpp:1
- There's a typo in the filename. 'prodution_types' should be 'production_types'.
/**
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| #pragma once | ||
|
|
||
| #include <lean_types/chekpoint.hpp> | ||
| #include <types/chekpoint.hpp> |
Copilot
AI
Sep 5, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a typo in the include path. 'chekpoint' should be 'checkpoint'.
| #include <types/chekpoint.hpp> | |
| #include <types/checkpoint.hpp> |
| BlockHeader header; | ||
| header.slot = 1; | ||
| header.parent_root = genesis_block_hash; | ||
| header.body_root = {};//ssz::hash_tree_root(body); |
Copilot
AI
Sep 5, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The commented code should either be implemented or removed. Having commented production code reduces maintainability.
| header.body_root = {};//ssz::hash_tree_root(body); | |
| header.body_root = {}; |
| header.slot = block.slot; | ||
| header.proposer_index = block.proposer_index; | ||
| header.parent_root = block.parent_root; | ||
| header.state_root = block.state_root; |
Copilot
AI
Sep 5, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The commented code indicates incomplete implementation. Either implement the SSZ hash tree root calculation or add a TODO comment explaining why it's postponed.
| logger_); | ||
|
|
||
| options.create_missing_column_families = true; | ||
|
|
Copilot
AI
Sep 5, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The removed conditional check if (no_db_presented) means the database will always be opened, which might not be the intended behavior. Consider adding a comment explaining why this condition was removed.
without block tree yet