Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

オープン 初心者向け
#35 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
72/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
java
領域
blockchain

調査の方向性

Transaction 内の Blockchain.isValid() と Transaction.NETWORK を読みます。issue には不足しているチェックが示され、README には 50 coin の報酬が定義されています。ブロックがトランザクションをどのように公開するかを追い、その後、各ブロックにネットワークトランザクションが最大 1 つだけ含まれ、その金額が 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日 22時間
マージ済み PR(30日)
12

環境構築

  • Dockerfile・Docker Compose ファイルなし
  • プルリクエストのテンプレートあり
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

techcsispit/mini-chain のほかの issue

techcsispit/mini-chain の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。