Skip to content

Fix premine reward height validation#12

Open
NateIsern wants to merge 1 commit into
mainfrom
codex/fix-off-by-one-consensus-subsidy-bug
Open

Fix premine reward height validation#12
NateIsern wants to merge 1 commit into
mainfrom
codex/fix-off-by-one-consensus-subsidy-bug

Conversation

@NateIsern

Copy link
Copy Markdown
Member

Motivation

  • Correct an off-by-one in reward validation that shifted the 5,000,000 FAIR premine from block 1 to block 2, which could allow an early block producer to claim the premine or cause consensus splits.

Description

  • Compute the expected mint using the current block height in ConnectBlock by replacing GetBlockValue(pindex->pprev->nHeight) with GetBlockValue(pindex->nHeight) in src/main.cpp so the premine at height 1 is validated at height 1.
  • Extend the subsidy unit test in src/test/main_tests.cpp to assert that block 2 returns the regular 10 FAIR subsidy (and leave existing checks for block 0 and block 1 intact).

Testing

  • Ran git diff --check, which reported no issues (success).
  • Ran ./autogen.sh in this environment which failed due to missing aclocal, so a full build or unit test execution was not possible here (failure).

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant