Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đã đóng Phù hợp với người mới
#35 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
72/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
java
Lĩnh vực
blockchain

Hướng nghiên cứu

Đọc Blockchain.isValid() và Transaction.NETWORK trong Transaction; issue chỉ ra các kiểm tra còn thiếu và README định nghĩa phần thưởng 50 coin. Theo dõi cách các block cung cấp các transaction của chúng, sau đó cập nhật bước xác thực để mỗi block có nhiều nhất một transaction mạng và số tiền của transaction đó bằng MINING_REWARD. Hoàn thành khi số tiền bị thay đổi và phần thưởng bị trùng khiến isValid() trả về false, trong khi các block được đào hợp lệ vẫn vượt qua bước kiểm tra.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Java
Star
0
Fork
3
Merge trung bình
1 ngày 18 giờ
Pull request đã merge (30 ngày)
14

Chuẩn bị môi trường

  • Không có Dockerfile hay tệp Docker Compose
  • Có mẫu pull request
  • Không có hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của techcsispit/mini-chain

Tất cả issue của techcsispit/mini-chain

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.