Skip to content

fix: report absolute expected deposit index in ErrDepositIndexOutOfOrder#3091

Open
rachit77 wants to merge 2 commits intoberachain:mainfrom
rachit77:rachit77/fix-deposit-index-out-of-order-error-message
Open

fix: report absolute expected deposit index in ErrDepositIndexOutOfOrder#3091
rachit77 wants to merge 2 commits intoberachain:mainfrom
rachit77:rachit77/fix-deposit-index-out-of-order-error-message

Conversation

@rachit77
Copy link
Copy Markdown

Summary

  • ValidateNonGenesisDeposits was logging i (the zero-based loop counter) as the expected deposit index in the ErrDepositIndexOutOfOrder error message instead of depositIndex+uint64(i) (the absolute eth1 deposit index from state)
  • The validation logic itself was correct blocks were rejected properly only the diagnostic message was wrong
  • A chain 100 deposits in would report "expected index: 0" instead of "expected index: 100"

Test

  • Added TestDepositIndexOutOfOrderErrorMessage: seeds the deposit store with 6 entries, sets depositIndex=5 on the state directly, submits a deposit with index 0 (wrong), and asserts the error contains "expected index: 5" not "expected index: 0"

Copilot AI review requested due to automatic review settings April 23, 2026 06:01
@rachit77 rachit77 requested a review from a team as a code owner April 23, 2026 06:01
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes the ErrDepositIndexOutOfOrder diagnostic message in ValidateNonGenesisDeposits to report the absolute expected deposit index derived from the state (depositIndex + i) rather than the zero-based loop counter.

Changes:

  • Update ValidateNonGenesisDeposits to format expected index as depositIndex+uint64(i).
  • Add a regression test to assert the error message contains the absolute expected index.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
state-transition/core/validation_deposits.go Fixes the wrapped error message to report the correct absolute expected deposit index.
state-transition/core/validation_deposits_test.go Adds a regression test ensuring the error message includes the state-based expected index.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 33 to 35
"github.com/berachain/beacon-kit/primitives/constants"
core "github.com/berachain/beacon-kit/state-transition/core"
statetransition "github.com/berachain/beacon-kit/testing/state-transition"
Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant import alias: the imported package path ends in /state-transition/core and the package name is already core, so core ".../core" adds an unnecessary alias. This also deviates from existing usage in this repo (e.g., state-transition/core/core_test.go:38 imports it without an alias) and may be flagged by the importas linter in .golangci.yaml. Consider importing without the alias and keeping usages as core.<...> (they will continue to compile).

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed 1e9f395

@calbera calbera added the os-review Open source contribution to review label Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

os-review Open source contribution to review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants