Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

isValid() does not verify mining reward amount or enforce a single reward transaction per block

已关闭 适合新手
#35 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
72/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
java
领域
blockchain

调研方向

阅读 Transaction 中的 Blockchain.isValid() 和 Transaction.NETWORK;issue 指出了缺失的检查,README 定义了 50 coin 的奖励。追踪区块如何提供其交易,然后更新验证逻辑,使每个区块最多包含一笔网络交易,且其金额等于 MINING_REWARD。当金额被篡改或奖励重复时,isValid() 会返回 false,而有效挖出的区块仍能通过验证,即视为完成。

由索引模型根据 Issue 内容生成。

描述

Description

In mini-chain, mining rewards are issued with Transaction.NETWORK ("network") as the sender.

Under Transaction.hasValidSignature():

public boolean hasValidSignature() {
    if (NETWORK.equals(from)) return true;
    ...

Transactions from "network" bypass digital signature checks by design because there is no private key for the network.

However, in Blockchain.isValid(), there is no validation verifying the mining reward amount or the count of reward transactions:

  1. A block's mining reward can be altered from MINING_REWARD (50) to an arbitrary amount (e.g. 1,000,000 coins).
  2. A block can contain multiple "network" reward transactions.

When a block's reward transaction is tampered with, the Merkle root recalculated, and the block re-mined to meet the difficulty target (as demonstrated in Menu Option 7), isValid() still returns true because:

  • The recalculated Merkle root matches block.getMerkleRoot().
  • The re-mined block hash meets the difficulty target.
  • tx.hasValidSignature() returns true for "network" without validating that the amount equals MINING_REWARD.
Expected Behavior

According to the README:

  • "Mining: A mined block holds all waiting payments plus a 50 coin reward for the miner."
  • "Validation: isValid() returns false if anything in any mined block was changed..."

isValid() should verify that in each mined block:

  1. There is at most one transaction from Transaction.NETWORK.
  2. Any transaction from Transaction.NETWORK has tx.amount() == MINING_REWARD.

If either invariant is violated, isValid() should return false.

主要语言
Java
星标
0
派生
3
平均合并
1 天 18 小时
30 天内合并 PR
14

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 有 Pull Request 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

techcsispit/mini-chain 的其他 Issue

查看 techcsispit/mini-chain 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。