fix chain fundamentals#129
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review (2)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Zahnentferner
left a comment
There was a problem hiding this comment.
This PR made the difficulty logic significantly more obscure.
Considering MiniChain's educational goal, this obscurity is not desirable.
Also, the difficulty and target are being manipulated in strange ways, with some strange bounds and, apparently, strange handling of some corner cases. It is unclear why. Why can't this be simpler?
| with self._lock: | ||
| chain_list = self.chain | ||
| return sum(2 ** (block.difficulty or 1) for block in chain_list) | ||
| return sum((1 << 256) // (block.target + 1) for block in chain_list) |
There was a problem hiding this comment.
1 << 256 is a constant number. There is no need to be recalculating it here all the time.
| @@ -72,6 +72,14 @@ def __init__( | |||
| if self.receipt_root is None and self.receipts: | |||
| self.receipt_root = calculate_receipt_root(self.receipts) | |||
|
|
|||
There was a problem hiding this comment.
There seem to be many magic constants in this PR.
Addressed Issues:
Refactor core blockchain consensus, persistence, and smart contract execution
current_targetandavg_block_timevia chain replay on startup.sys.settracegas-metering, removing problematic multiprocessing IPC overhead and resolving deadlocks on Windows.ast.Multin the smart contract validation whitelist.difficultyserialization to prevent legacy block hash mismatches.Screenshots/Recordings:
TODO: If applicable, add screenshots or recordings that demonstrate the interface before and after the changes.
Additional Notes:
AI Usage Disclosure:
We encourage contributors to use AI tools responsibly when creating Pull Requests. While AI can be a valuable aid, it is essential to ensure that your contributions meet the task requirements, build successfully, include relevant tests, and pass all linters. Submissions that do not meet these standards may be closed without warning to maintain the quality and integrity of the project. Please take the time to understand the changes you are proposing and their impact. AI slop is strongly discouraged and may lead to banning and blocking. Do not spam our repos with AI slop.
Check one of the checkboxes below:
I have used the following AI models and tools: TODO
Checklist