Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(node-api): Introduce E2E tests for existing beacon endpoints #1983

Open
wants to merge 106 commits into
base: main
Choose a base branch
from

Conversation

nidhi-singh02
Copy link
Contributor

@nidhi-singh02 nidhi-singh02 commented Aug 29, 2024

Summary by CodeRabbit

  • New Features

    • Enhanced the Validator interface with new methods for retrieving validator attributes such as public key and effective balance.
    • Introduced multiple new getter methods for improved access to epoch-related data.
    • Added a new method to the WithdrawalCredentials mock for returning byte representations.
  • Improvements

    • Improved mock implementation to align with the updated Validator interface, enhancing testing capabilities.
    • Streamlined mock structure for easier interaction and testing.
    • Expanded validation capabilities by incorporating checks for validator statuses.
    • Enhanced type safety and clarity in the API's design regarding validators and their withdrawal credentials.

Copy link
Contributor

coderabbitai bot commented Aug 29, 2024

Walkthrough

This pull request introduces substantial modifications to the Validator mock implementation in the mod/node-api/backend/mocks/validator.mock.go file. Key changes include the removal of the GetWithdrawalCredentials method and its replacement with several new methods that provide specific functionalities related to the Validator interface. The logic for handling return values has been updated, and the overall structure of the mock class has been refined to facilitate easier testing and interaction with the mocked methods. Additional updates include enhancements to the WithdrawalCredentials mock and modifications to relevant interfaces.

Changes

File Path Change Summary
mod/node-api/backend/mocks/validator.mock.go Significant updates to the Validator mock, including the removal of GetWithdrawalCredentials and the addition of new methods: GetActivationEligibilityEpoch, GetActivationEpoch, GetEffectiveBalance, GetExitEpoch, GetPubkey, and GetWithdrawableEpoch. Updated helper methods and mock call types to align with new method signatures.
mod/node-api/backend/mocks/withdrawal_credentials.mock.go Introduced Bytes method to WithdrawalCredentials mock, along with related types and methods for managing return values in tests.
mod/node-api/backend/types.go Updated Validator and WithdrawalCredentials interfaces to remove outdated methods and add new ones, enhancing the specificity of the information provided by these interfaces.
mod/node-api/engines/echo/vaildator.go Added ValidateValidatorStatus function to enhance validation capabilities for validator statuses, with updates to the ConstructValidator function.
mod/node-core/pkg/components/interfaces.go Updated NodeAPIBackend, NodeAPIBeaconBackend, and ValidatorBackend interfaces to specify ValidatorT as types.Validator[WithdrawalCredentialsT], enhancing type specificity and clarity in method signatures.

Possibly related PRs

Suggested reviewers

  • itsdevbear
  • ocnc

🐰 In the meadow where data flows,
New structures rise, as knowledge grows.
With each change, a clearer view,
In the world of code, we're hopping through!
JSON shines, and types align,
In the beacon's light, our work's divine! 🌟


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

codecov bot commented Aug 29, 2024

Codecov Report

Attention: Patch coverage is 4.54545% with 147 lines in your changes missing coverage. Please review.

Project coverage is 24.66%. Comparing base (40325e2) to head (25af9f3).

Files with missing lines Patch % Lines
mod/node-api/handlers/beacon/types/response.go 0.00% 45 Missing ⚠️
testing/e2e/suite/types/consensus_client.go 0.00% 32 Missing ⚠️
mod/node-api/handlers/beacon/validators.go 0.00% 16 Missing ⚠️
mod/node-api/handlers/beacon/handler.go 0.00% 8 Missing ⚠️
mod/node-api/engines/echo/vaildator.go 0.00% 7 Missing ⚠️
mod/consensus-types/pkg/types/fork.go 14.28% 6 Missing ⚠️
mod/consensus-types/pkg/types/validator.go 50.00% 6 Missing ⚠️
mod/node-api/backend/validator.go 0.00% 6 Missing ⚠️
mod/node-api/handlers/beacon/routes.go 0.00% 5 Missing ⚠️
examples/berad/pkg/consensus-types/validator.go 0.00% 4 Missing ⚠️
... and 6 more
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1983      +/-   ##
==========================================
- Coverage   24.83%   24.66%   -0.18%     
==========================================
  Files         357      358       +1     
  Lines       16067    16179     +112     
  Branches       12       12              
==========================================
  Hits         3990     3990              
- Misses      11882    11994     +112     
  Partials      195      195              
Files with missing lines Coverage Δ
mod/node-api/handlers/beacon/header.go 0.00% <ø> (ø)
mod/node-api/handlers/beacon/block.go 0.00% <0.00%> (ø)
mod/node-api/handlers/beacon/genesis.go 0.00% <0.00%> (ø)
mod/node-core/pkg/components/api_handlers.go 0.00% <0.00%> (ø)
...onsensus-types/pkg/types/withdrawal_credentials.go 90.00% <0.00%> (-10.00%) ⬇️
mod/node-api/handlers/beacon/historical.go 0.00% <0.00%> (ø)
examples/berad/pkg/consensus-types/validator.go 0.00% <0.00%> (ø)
mod/node-api/handlers/beacon/randao.go 0.00% <0.00%> (ø)
mod/node-api/handlers/beacon/routes.go 0.00% <0.00%> (ø)
mod/consensus-types/pkg/types/fork.go 77.55% <14.28%> (-10.83%) ⬇️
... and 7 more

@nidhi-singh02 nidhi-singh02 force-pushed the e2e-node-api branch 5 times, most recently from 96daada to 633f2c5 Compare September 8, 2024 07:56
@nidhi-singh02 nidhi-singh02 marked this pull request as ready for review September 8, 2024 08:34
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 12

Outside diff range comments (2)
testing/e2e/e2e_api_test.go (2)

Line range hint 31-41: Centralized initialization logic in initBeaconTest enhances test maintainability.

The initBeaconTest function effectively centralizes the initialization logic for the beacon node API tests, ensuring that all tests start with the necessary prerequisites met. This approach reduces redundancy and improves the clarity of the test suite.

Consider adding error handling or a fallback mechanism for scenarios where the consensus client cannot be retrieved, to prevent tests from failing due to setup issues.


Line range hint 44-59: Well-structured test for beacon state root.

The TestBeaconStateRoot function is well-structured and effectively uses the initBeaconTest function to ensure a consistent test environment. The checks for the state root are comprehensive, ensuring that the API response meets the expected conditions.

Consider adding more detailed assertions to verify the correctness of the state root value, not just its presence, to enhance the robustness of the test.

Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between 74eea70 and 633f2c5.

Files ignored due to path filters (6)
  • beacond/go.sum is excluded by !**/*.sum
  • mod/cli/go.sum is excluded by !**/*.sum
  • mod/config/go.sum is excluded by !**/*.sum
  • mod/consensus/go.sum is excluded by !**/*.sum
  • mod/node-api/go.sum is excluded by !**/*.sum
  • mod/node-core/go.sum is excluded by !**/*.sum
Files selected for processing (21)
  • beacond/go.mod (1 hunks)
  • examples/berad/pkg/consensus-types/validator.go (1 hunks)
  • examples/berad/pkg/state-transition/state_processor.go (2 hunks)
  • mod/cli/go.mod (1 hunks)
  • mod/config/go.mod (1 hunks)
  • mod/consensus-types/pkg/types/fork.go (2 hunks)
  • mod/consensus-types/pkg/types/validator.go (1 hunks)
  • mod/consensus/go.mod (1 hunks)
  • mod/node-api/engines/echo/vaildator.go (2 hunks)
  • mod/node-api/go.mod (2 hunks)
  • mod/node-api/handlers/beacon/historical.go (2 hunks)
  • mod/node-api/handlers/beacon/randao.go (1 hunks)
  • mod/node-api/handlers/beacon/routes.go (1 hunks)
  • mod/node-api/handlers/beacon/types/request.go (1 hunks)
  • mod/node-api/handlers/beacon/types/response.go (1 hunks)
  • mod/node-api/handlers/beacon/validators.go (4 hunks)
  • mod/node-api/handlers/debug/routes.go (1 hunks)
  • mod/node-core/go.mod (1 hunks)
  • mod/state-transition/pkg/core/state_processor.go (2 hunks)
  • testing/e2e/e2e_api_test.go (3 hunks)
  • testing/e2e/suite/types/consensus_client.go (6 hunks)
Additional comments not posted (31)
mod/node-api/handlers/beacon/randao.go (1)

55-57: Structural enhancement approved.

The modification to encapsulate the randao variable within the RandaoData struct is a positive change, enhancing the clarity and maintainability of the code. Ensure that all components interacting with the GetRandao method are updated to handle the new structure.

Run the following script to verify the impact on related components:

Verification successful

Verification successful: No issues found with GetRandao changes.

The encapsulation of the randao variable within the RandaoData struct in the GetRandao function appears to be a localized change. The script output does not show any direct interactions with GetRandao beyond its definition and route assignment, indicating that the impact is limited to the handler itself. No further updates are necessary for related components.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all components interacting with `GetRandao` method.

# Test: Search for the method usage. Expect: Only occurrences of the new structure.
rg --type go -A 5 $'GetRandao'

Length of output: 21026

mod/node-api/handlers/beacon/types/response.go (1)

87-89: New data structure RandaoData approved.

The addition of the RandaoData struct is a positive change, enhancing the data model to accommodate new functionality related to RANDAO. Ensure that this new structure integrates seamlessly with existing data handling mechanisms.

mod/consensus-types/pkg/types/fork.go (4)

143-145: Approved: New getter method for PreviousVersion.

The addition of GetPreviousVersion enhances encapsulation by allowing external components to access the PreviousVersion field in a controlled manner.


147-149: Approved: New getter method for CurrentVersion.

The addition of GetCurrentVersion enhances encapsulation by allowing external components to access the CurrentVersion field in a controlled manner.


151-153: Approved: New getter method for Epoch.

The addition of GetEpoch enhances encapsulation by allowing external components to access the Epoch field in a controlled manner.


132-132: Verify the implementation of Epoch.Unwrap().

The change to use f.Epoch.Unwrap() in HashTreeRootWith suggests a move towards better encapsulation. Ensure that the Unwrap method is correctly implemented and does not introduce any unexpected behavior.

Verification successful

The use of f.Epoch.Unwrap() is correct.

The Epoch type is an alias for U64, which has an Unwrap method returning a uint64. This change aligns with the type definition and method implementation, ensuring proper encapsulation and type safety. No issues are introduced by this change.

  • Epoch is defined as U64 in mod/primitives/pkg/math/u64.go.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of `Epoch.Unwrap()` and its usage across the system.

# Test: Search for the `Unwrap` method implementation and its usage.
ast-grep --lang go --pattern $'func (Epoch) Unwrap() uint64 { $$$ }'

Length of output: 69


Script:

#!/bin/bash
# Search for the definition of the `Epoch` type to understand its structure.
ast-grep --lang go --pattern $'type Epoch struct { $$$ }'

# Search for all methods associated with the `Epoch` type to verify the existence of `Unwrap` or similar methods.
ast-grep --lang go --pattern $'func (e Epoch) $_() $_ { $$$ }'

Length of output: 122


Script:

#!/bin/bash
# Search for any type definitions related to `Epoch`, including type aliases.
ast-grep --lang go --pattern $'type Epoch $_ { $$$ }'

# Search for any functions or methods that might perform an operation similar to `Unwrap`.
rg 'func.*Unwrap' -A 3

Length of output: 1765


Script:

#!/bin/bash
# Search for the definition of `Epoch` to understand its relationship with other types like `U64`.
rg 'type Epoch' -A 3

# Verify if `Epoch` is an alias or has a conversion method to `U64`.
rg 'Epoch' -A 3

Length of output: 94133

mod/node-api/go.mod (2)

7-7: Approved: Addition of new dependency on consensus-types.

The addition of github.com/berachain/beacon-kit/mod/consensus-types is approved as it likely enhances the module's functionality with new consensus mechanisms or types. Ensure that this new dependency is correctly integrated and does not introduce any compatibility issues.

Verification successful

Verified: Successful integration of consensus-types dependency.

The new dependency github.com/berachain/beacon-kit/mod/consensus-types is extensively used across the codebase, indicating successful integration. It is present in various modules, including consensus, node-core, node-api, CLI, and testing, confirming its importance and proper incorporation into the project. No compatibility issues are evident from the current context.

  • Files using the dependency:
    • mod/consensus/pkg/cometbft/service/abci.go
    • mod/node-core/pkg/components/types.go
    • mod/node-api/handlers/beacon/historical.go
    • mod/cli/pkg/commands/genesis/collect.go
    • And many more...
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the integration of the new dependency `consensus-types`.

# Test: Search for the usage of `consensus-types` across the module.
rg --type go $'github.com/berachain/beacon-kit/mod/consensus-types'

Length of output: 4479


7-7: Verify the impact of removing golang.org/x/net.

The removal of golang.org/x/net could indicate a refactoring or a move towards alternative libraries for network operations. Verify that this change does not negatively impact the module's networking capabilities or introduce any unresolved dependencies.

Verification successful

Removal of golang.org/x/net is unlikely to impact networking capabilities.

The absence of direct references to golang.org/x/net and the presence of net/http in the codebase suggest that the module's networking capabilities remain intact. The functionality previously provided by golang.org/x/net is likely covered by net/http or other libraries. No unresolved dependencies or negative impacts were identified.

  • Ensure that all networking functionalities are tested to confirm this assumption.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the impact of removing `golang.org/x/net` on the module's networking capabilities.

# Test: Search for any unresolved dependencies or errors related to the removal.
rg --type go $'golang.org/x/net'

Length of output: 31


Script:

#!/bin/bash
# Description: Search for new dependencies or changes in networking-related code that might replace `golang.org/x/net`.

# Find new import statements in Go files that might indicate alternative networking libraries.
rg --type go '^import' -A 5

# Search for common networking-related functions or packages that might have been introduced.
rg --type go 'net/http|net.Dial|http.Client|http.Transport'

Length of output: 223390

mod/node-api/engines/echo/vaildator.go (4)

93-93: Skip: Existing comments still valid.

The existing comments on the use of constants in ValidateBlockID are still valid and applicable.


69-69: Approved: Addition of ValidateValidatorStatus to validators map.

The addition of ValidateValidatorStatus to the validators map in ConstructValidator is approved as it enhances the validation capabilities by including a new field, validator_status. Ensure that this new validator is correctly integrated and functions as expected.


83-86: Approved: Use of constants in ValidateStateID.

The update to use constants from the utils package in ValidateStateID improves maintainability and reduces the risk of errors. Ensure that these constants are correctly defined and used consistently across the module.

Verification successful

Verified: Constants in ValidateStateID are correctly defined and used.

The constants StateIDHead, StateIDGenesis, StateIDFinalized, and StateIDJustified are properly defined in mod/node-api/handlers/utils/constants.go and are used consistently across the module. This enhances maintainability and reduces potential errors.

  • Definitions found in mod/node-api/handlers/utils/constants.go.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correct usage and definition of constants used in `ValidateStateID`.

# Test: Search for the definition and usage of constants across the module.
rg --type go $'utils.StateIDHead|utils.StateIDGenesis|utils.StateIDFinalized|utils.StateIDJustified'

Length of output: 1170


Script:

#!/bin/bash
# Description: Search for the definition of constants used in `ValidateStateID`.

# Test: Locate the definition of the constants in the codebase.
rg --type go 'const StateIDHead|const StateIDGenesis|const StateIDFinalized|const StateIDJustified'

Length of output: 101


Script:

#!/bin/bash
# Description: Search for any mention of the constants used in `ValidateStateID`.

# Test: Locate any mention of the constants in the codebase.
rg --type go 'StateIDHead|StateIDGenesis|StateIDFinalized|StateIDJustified'

Length of output: 1580


93-95: Approved: Use of constants in ValidateBlockID.

The update to use constants from the utils package in ValidateBlockID improves maintainability and reduces the risk of errors. Ensure that these constants are correctly defined and used consistently across the module.

Verification successful

Verified: Constants are correctly defined and used.

The constants StateIDHead, StateIDGenesis, and StateIDFinalized are correctly defined in mod/node-api/handlers/utils/constants.go and are used consistently across the codebase. This update enhances maintainability and reduces the risk of errors.

  • Definitions found in mod/node-api/handlers/utils/constants.go.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correct usage and definition of constants used in `ValidateBlockID`.

# Test: Search for the definition and usage of constants across the module.
rg --type go $'utils.StateIDHead|utils.StateIDGenesis|utils.StateIDFinalized'

Length of output: 1005


Script:

#!/bin/bash
# Description: Search for the definition of constants used in `ValidateBlockID`.

# Test: Search for the definition of constants in the utils package.
rg --type go 'const StateIDHead|const StateIDGenesis|const StateIDFinalized'

Length of output: 78


Script:

#!/bin/bash
# Description: Search for any mention of the constants in the utils package or related files.

# Test: Search for any mention of the constants in the utils package.
rg --type go 'StateIDHead|StateIDGenesis|StateIDFinalized'

Length of output: 1347

mod/node-api/handlers/beacon/routes.go (1)

156-160: New route addition for block rewards is well-defined.

The new route addition at /eth/v1/beacon/rewards/blocks/:block_id using the GET method is correctly implemented with an appropriate handler function. This enhances the API's functionality by allowing clients to query rewards for individual blocks.

testing/e2e/suite/types/consensus_client.go (2)

158-218: New methods for Beacon node API interaction are correctly implemented.

The addition of methods like ABCIInfo, BeaconStateRoot, Fork, ValidatorBalances, Validators, and BeaconStateRandao enhances the functionality of the ConsensusClient. The consistent error handling for an uninitialized beaconClient is a good practice to prevent runtime errors.


44-44: Field renaming enhances clarity.

The renaming of Client to cometClient and BeaconKitNodeClient to beaconClient improves the readability and purpose of these fields. Ensure that these new names are consistently used throughout the file.

Also applies to: 47-47

Verification successful

Field renaming is consistent and correct.

The renaming of Client to cometClient and BeaconKitNodeClient to beaconClient has been applied consistently throughout the file. There are no remaining references to the old field names. This change enhances clarity and readability.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the consistent usage of renamed fields throughout the file.

# Test: Search for old field names. Expect: No occurrences.
rg --type go -A 5 $'Client|BeaconKitNodeClient' testing/e2e/suite/types/consensus_client.go

Length of output: 4458

mod/config/go.mod (1)

42-42: Dependency version updated for consensus-types.

The update of github.com/berachain/beacon-kit/mod/consensus-types to version v0.0.0-20240906211613-74eea7007e70 is noted. Ensure to verify the impact of this update on the application, particularly for any breaking changes or new features that might affect existing functionality.

examples/berad/pkg/consensus-types/validator.go (4)

40-40: JSON Serialization Tag Updated for WithdrawalCredentials

The JSON tag for WithdrawalCredentials has been updated to withdrawal_credentials to align with common JSON practices. Ensure that any consuming systems are updated to accommodate this change.

Run the following script to verify the impact on systems consuming this JSON:

Verification successful

JSON Tag Change Verified

The change to the JSON tag for WithdrawalCredentials from withdrawalCredentials to withdrawal_credentials has been correctly applied. There are no remaining occurrences of the old JSON tag in the context of JSON serialization. The variable names using withdrawalCredentials are unrelated to this change and do not impact the JSON output.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for occurrences of the old JSON tag to ensure it's updated.

# Test: Search for the old JSON tag. Expect: No occurrences.
rg --type go -A 5 $'withdrawalCredentials'

Length of output: 8694


42-42: JSON Serialization Tag Updated for EffectiveBalance

The JSON tag for EffectiveBalance has been updated to effective_balance to align with common JSON practices. Ensure that any consuming systems are updated to accommodate this change.

Run the following script to verify the impact on systems consuming this JSON:

Verification successful

JSON Serialization Tag Update Verified

The JSON tag for EffectiveBalance has been updated to effective_balance, and there are no occurrences of the old JSON tag effectiveBalance elsewhere in the codebase. This change is isolated to the file under review. Ensure that any external systems consuming this JSON output are updated to accommodate the new tag.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for occurrences of the old JSON tag to ensure it's updated.

# Test: Search for the old JSON tag. Expect: No occurrences.
rg --type go -A 5 $'effectiveBalance'

Length of output: 8749


46-46: JSON Serialization Tag Updated for ExitEpoch

The JSON tag for ExitEpoch has been updated to exit_epoch to align with common JSON practices. Ensure that any consuming systems are updated to accommodate this change.

Run the following script to verify the impact on systems consuming this JSON:

Verification successful

JSON Serialization Tag Updated for ExitEpoch

The JSON tag for ExitEpoch has been successfully updated to exit_epoch across the codebase. Ensure that any external systems consuming this JSON are updated to accommodate this change.

  • Occurrences of exit_epoch found in:
    • mod/consensus-types/pkg/types/validator.go
    • mod/node-api/handlers/beacon/validators.go
    • examples/berad/pkg/consensus-types/validator.go
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for occurrences of the old JSON tag to ensure it's updated.

# Test: Search for the old JSON tag. Expect: No occurrences.
rg --type go -A 5 $'exitEpoch'

Length of output: 29


Script:

#!/bin/bash
# Description: Search for occurrences of the new JSON tag to ensure it's used consistently.

# Test: Search for the new JSON tag. Expect: Occurrences in relevant files.
rg --type go -A 5 $'exit_epoch'

Length of output: 1604


48-48: JSON Serialization Tag Updated for WithdrawableEpoch

The JSON tag for WithdrawableEpoch has been updated to withdrawable_epoch to align with common JSON practices. Ensure that any consuming systems are updated to accommodate this change.

Run the following script to verify the impact on systems consuming this JSON:

Verification successful

JSON Tag Update Verified

The change of the JSON tag for WithdrawableEpoch from withdrawableEpoch to withdrawable_epoch has been verified. No occurrences of the old tag were found in the codebase, indicating that the update does not impact other parts of the code.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for occurrences of the old JSON tag to ensure it's updated.

# Test: Search for the old JSON tag. Expect: No occurrences.
rg --type go -A 5 $'withdrawableEpoch'

Length of output: 37


Script:

#!/bin/bash
# Description: Search for occurrences of the old JSON tag in all file types to ensure it's updated.

# Test: Search for the old JSON tag. Expect: No occurrences.
rg -A 5 'withdrawableEpoch'

Length of output: 27

mod/consensus/go.mod (1)

22-22: Dependency version updated.

The version of github.com/berachain/beacon-kit/mod/consensus-types has been updated. Ensure that this update is compatible with the rest of the project and does not introduce breaking changes.

Run the following script to verify the impact of the updated dependency across the project:

mod/node-core/go.mod (1)

28-28: Dependency version updated in node-core.

The version of github.com/berachain/beacon-kit/mod/consensus-types has been updated in the node-core module. Ensure that this update is compatible with the node-core functionalities and does not introduce breaking changes.

Run the following script to verify the impact of the updated dependency in the node-core module:

mod/cli/go.mod (1)

27-27: Dependency version updated in CLI module.

The version of github.com/berachain/beacon-kit/mod/consensus-types has been updated in the CLI module. Ensure that this update is compatible with the CLI functionalities and does not introduce breaking changes.

Run the following script to verify the impact of the updated dependency in the CLI module:

mod/state-transition/pkg/core/state_processor.go (1)

64-66: Enhancement to ForkT interface with new methods.

The addition of GetPreviousVersion(), GetCurrentVersion(), and GetEpoch() methods to the ForkT interface is a significant enhancement. These methods will provide crucial versioning and epoch information, which is essential for managing state transitions effectively.

Please ensure that all implementations of the ForkT interface are updated to include these new methods. This might require changes in other parts of the codebase where ForkT is implemented.

Also applies to: 122-124

beacond/go.mod (1)

32-32: Update to dependency version in go.mod.

The update of github.com/berachain/beacon-kit/mod/consensus-types to v0.0.0-20240906211613-74eea7007e70 is crucial for incorporating the latest improvements and fixes. Ensure that this update does not introduce compatibility issues with other parts of the project.

Please verify that all modules depending on consensus-types are compatible with this new version. This may involve checking for deprecated features or changes in the module's API.

examples/berad/pkg/state-transition/state_processor.go (1)

61-63: Enhancement to ForkT interface with new methods.

The addition of GetPreviousVersion(), GetCurrentVersion(), and GetEpoch() methods to the ForkT interface is a significant enhancement. These methods will provide crucial versioning and epoch information, which is essential for managing state transitions effectively.

Please ensure that all implementations of the ForkT interface are updated to include these new methods. This might require changes in other parts of the codebase where ForkT is implemented.

Also applies to: 117-119

mod/node-api/handlers/beacon/validators.go (2)

74-83: Well-defined CustomValidator struct.

The CustomValidator struct is well-defined with appropriate JSON tags for serialization. This struct will help in managing validator data effectively.


242-267: Good improvements in PostStateValidatorBalances.

The updates to PostStateValidatorBalances enhance error handling and request validation. The direct binding of request data and detailed logging are commendable. Ensure that all edge cases are handled appropriately in future updates.

mod/consensus-types/pkg/types/validator.go (3)

50-50: Correct JSON tag update for WithdrawalCredentials.

The update to the JSON tag from withdrawalCredentials to withdrawal_credentials aligns with common conventions and enhances clarity.


52-52: Correct JSON tag update for EffectiveBalance.

The update to the JSON tag from effectiveBalance to effective_balance is consistent and enhances the uniformity of the JSON representation.


57-63: Consistent JSON tag updates for epoch-related fields.

The updates to JSON tags for ActivationEligibilityEpoch, ActivationEpoch, ExitEpoch, and WithdrawableEpoch from camelCase to snake_case enhance clarity and consistency across the struct.

mod/node-api/handlers/debug/routes.go Outdated Show resolved Hide resolved
mod/node-api/handlers/beacon/historical.go Outdated Show resolved Hide resolved
mod/node-api/handlers/beacon/historical.go Outdated Show resolved Hide resolved
testing/e2e/e2e_api_test.go Outdated Show resolved Hide resolved
testing/e2e/e2e_api_test.go Outdated Show resolved Hide resolved
mod/node-api/handlers/beacon/types/request.go Show resolved Hide resolved
mod/node-api/handlers/beacon/validators.go Outdated Show resolved Hide resolved
mod/node-api/handlers/beacon/validators.go Outdated Show resolved Hide resolved
mod/node-api/handlers/beacon/validators.go Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between 633f2c5 and 1e0d0b0.

Files selected for processing (2)
  • mod/node-api/handlers/beacon/validators.go (4 hunks)
  • testing/e2e/e2e_api_test.go (3 hunks)
Additional context used
Learnings (1)
mod/node-api/handlers/beacon/validators.go (1)
Learnt from: nidhi-singh02
PR: berachain/beacon-kit#1983
File: mod/node-api/handlers/beacon/validators.go:129-156
Timestamp: 2024-09-08T08:56:55.131Z
Learning: The `convertValidator` function in `mod/node-api/handlers/beacon/validators.go` can be optimized by directly mapping fields from the original validator to the `CustomValidator` struct, avoiding the overhead of JSON marshaling and unmarshaling.
Additional comments not posted (10)
testing/e2e/e2e_api_test.go (6)

Line range hint 31-42: Centralized test initialization approved.

The initBeaconTest function centralizes the setup for beacon node API tests, which enhances maintainability and consistency across tests.


Line range hint 44-59: Test for beacon state root approved.

The TestBeaconStateRoot function correctly tests the beacon state root endpoint. Consider adding a comment explaining why IsZero is checked, to clarify its importance in the context of the test.


60-77: Detailed assertions in beacon fork test approved.

The TestBeaconFork function includes detailed assertions for fork versions and epoch, enhancing test robustness. Good implementation following previous feedback.


79-127: Comprehensive validator tests approved.

The TestBeaconValidators function thoroughly tests the validators' data. Consider adding tests for edge cases, such as invalid or out-of-range validator indices, to further enhance robustness.


130-150: Validator balances test approved.

The TestBeaconValidatorBalances function correctly checks for non-nil and positive balances. If possible, consider adding assertions for exact balance values to match expected outcomes based on test setup.


152-164: Randao test approved.

The TestBeaconRandao function correctly checks the Randao value for non-zero and correct length. Consider adding a comment explaining the significance of the 32-byte length check for clarity.

mod/node-api/handlers/beacon/validators.go (4)

72-84: New CustomValidator struct approved.

The CustomValidator struct is well-designed to encapsulate essential validator data, enhancing clarity and manageability of validator information.


130-155: Clarification needed on convertValidator implementation.

The convertValidator function appears to still use JSON marshaling and unmarshaling. If this is no longer necessary due to direct field mapping optimizations, consider removing these operations to enhance performance.


159-177: Hex field conversion function approved.

The convertHexFields function effectively converts hex fields to decimal strings, enhancing data readability. Consider adding more detailed error handling for specific hex format issues to further improve robustness.


179-196: Hex to decimal conversion function approved.

The hexToDecimalString function is well-implemented with thorough checks for input validity, ensuring accurate and robust data conversion.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between 1e0d0b0 and f6b1609.

Files selected for processing (1)
  • testing/e2e/e2e_api_test.go (3 hunks)
Additional comments not posted (6)
testing/e2e/e2e_api_test.go (6)

Line range hint 31-42: Well-implemented initialization function for beacon tests.

The initBeaconTest function centralizes the initialization logic for the beacon node API tests, ensuring a consistent test environment by waiting for a finalized block and verifying the availability of the consensus client. This is a crucial setup step for all subsequent tests.


Line range hint 44-59: Comprehensive test for beacon state root.

The TestBeaconStateRoot function effectively tests the beacon state root functionality, ensuring the state root is not nil and not zero. These checks are crucial for verifying the integrity of the state root.


60-89: Thorough test for beacon fork with detailed assertions.

The TestBeaconFork function effectively tests the beacon fork functionality, using detailed assertions to verify the correctness of PreviousVersion, CurrentVersion, and Epoch against expected values. This ensures the API response meets the expected conditions and enhances the robustness of the test.


91-140: Comprehensive test for beacon validators with detailed checks.

The TestBeaconValidators function effectively tests the beacon validators functionality, including detailed checks for validator attributes such as public keys, withdrawal credentials, and balances. These checks ensure the validator data is not only present but also valid and meaningful.


142-162: Effective test for beacon validator balances.

The TestBeaconValidatorBalances function effectively tests the beacon validator balances functionality, ensuring that balances exist for requested indices and are positive. These checks are crucial for verifying the financial integrity of validators.


164-184: Well-implemented test for beacon state Randao.

The TestBeaconRandao function effectively tests the beacon state Randao functionality, ensuring the Randao is 32 bytes long and not all zeros. These checks are crucial for verifying the randomness and integrity of the Randao value.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between f6b1609 and f5176dd.

Files selected for processing (1)
  • testing/e2e/e2e_api_test.go (3 hunks)
Additional comments not posted (6)
testing/e2e/e2e_api_test.go (6)

Line range hint 31-42: Initialization Function for Beacon Tests

The initBeaconTest function is a critical addition to the test suite, ensuring that a consensus client is properly initialized and a finalized block is awaited before any tests are run. This setup is crucial for the consistency and reliability of the tests.

  • Correctness: The function correctly waits for a finalized block and checks for errors, which is good practice.
  • Error Handling: Proper error handling with s.Require().NoError(err) ensures that the test fails early if the initialization does not proceed as expected.
  • Client Validation: The validation s.Require().NotNil(client) is essential to ensure that the test does not proceed with a nil client.

Overall, this function provides a robust foundation for the subsequent tests, ensuring that they operate in a consistent and controlled environment.


Line range hint 44-58: Test for Beacon State Root

This test function checks the beacon state root using the initialized client from initBeaconTest. It properly checks for non-nil responses and validates the state root is not zero, which is crucial for ensuring the integrity of the state root data.

  • Logic and Correctness: The logic to fetch and validate the state root is correctly implemented.
  • Error Handling: Comprehensive error handling with s.Require().NoError(err) and s.Require().NotEmpty(stateRootResp) ensures that any issues are caught early.
  • Validation of Data: The assertion s.Require().False(stateRootResp.Data.IsZero()) is a good practice to ensure the state root is not just present but valid.

This test is well-implemented and covers the necessary checks to validate the beacon state root effectively.


60-89: Comprehensive Test for Beacon Fork

The TestBeaconFork function effectively uses the initBeaconTest function to ensure a consistent test environment. The checks for the fork details are comprehensive, ensuring that the API response meets the expected conditions.

  • Detailed Assertions: The detailed assertions for PreviousVersion, CurrentVersion, and Epoch are well-placed and ensure that the fork data not only exists but matches expected values.
  • Error Handling: The use of s.Require().NoError(err) and s.Require().NotEmpty(stateForkResp) ensures that potential issues are caught early.
  • Validation of Data: The validation against expectedVersion and specific epoch values ensures the correctness of the data returned by the API.

This function is well-structured and robust, providing a thorough validation of the beacon fork details.


91-140: Effective Test for Beacon Validators

The TestBeaconValidators function is well-structured and effectively uses the initBeaconTest function to ensure a consistent test environment. The checks for the validators are comprehensive, ensuring that the API response meets the expected conditions.

  • Detailed Assertions: The detailed assertions for validator properties such as public key length, withdrawal credentials, and balances are crucial for verifying the integrity and correctness of the validator data.
  • Error Handling: Comprehensive error handling with s.Require().NoError(err) and s.Require().NotNil(validatorsResp) ensures that any issues are caught early.
  • Validation of Data: The use of s.Require().Len and s.Require().True for various validator attributes ensures that the data is not only present but adheres to expected constraints.

This function provides a robust test for the beacon validators, ensuring that the data returned by the API is valid and meaningful.


142-162: Thorough Test for Beacon Validator Balances

The TestBeaconValidatorBalances function effectively uses the initBeaconTest function to ensure a consistent test environment. The checks for the validator balances are comprehensive, ensuring that the API response meets the expected conditions.

  • Error Handling: The use of s.Require().NoError(err) and s.Require().NotNil(validatorBalancesResp) ensures that potential issues are caught early.
  • Validation of Data: The assertions for the existence and positivity of balances for each validator index are crucial for ensuring the integrity of the balance data.

This function is well-implemented, providing a thorough validation of the beacon validator balances.


164-184: Well-Implemented Test for Beacon State Randao

The TestBeaconRandao function is well-structured and effectively uses the initBeaconTest function to ensure a consistent test environment. The checks for the Randao response are comprehensive, ensuring that the API response meets the expected conditions.

  • Error Handling: The use of s.Require().NoError(err) and s.Require().NotNil(stateRandaoResp) ensures that potential issues are caught early.
  • Validation of Data: The assertions that the Randao is 32 bytes long and not all zeros are crucial for verifying the correctness of the Randao value.

This function is robust, providing a thorough validation of the beacon state Randao.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between f5176dd and 1aa75ff.

Files selected for processing (1)
  • mod/consensus-types/pkg/types/fork.go (2 hunks)
Additional comments not posted (4)
mod/consensus-types/pkg/types/fork.go (4)

132-132: Approved: Enhanced type safety in HashTreeRootWith.

The change from direct access to using f.Epoch.Unwrap() enhances type safety and encapsulation. It's recommended to add a comment explaining the use of Unwrap() for clarity.


147-150: Approved: Addition of GetPreviousVersion method.

This method enhances encapsulation by providing a controlled way of accessing the PreviousVersion field.


152-155: Approved: Addition of GetCurrentVersion method.

This method enhances encapsulation by providing a controlled way of accessing the CurrentVersion field.


157-160: Approved: Addition of GetEpoch method.

This method enhances encapsulation by providing a controlled way of accessing the Epoch field.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between 1aa75ff and 4aea9ce.

Files selected for processing (1)
  • mod/consensus-types/pkg/types/fork.go (1 hunks)
Additional comments not posted (2)
mod/consensus-types/pkg/types/fork.go (2)

148-150: Approved: New getter methods enhance encapsulation.

The addition of GetPreviousVersion, GetCurrentVersion, and GetEpoch methods is a positive change, promoting encapsulation and reducing direct access to struct fields. This aligns with good object-oriented design principles, enhancing the maintainability and robustness of the code.

Also applies to: 152-154, 157-159


132-132: Refactor suggestion: Confirm the safety of Epoch.Unwrap() usage.

The modification to use f.Epoch.Unwrap() in the HashTreeRootWith method enhances type safety by ensuring that Epoch is treated as a complex type. However, it's crucial to ensure that Unwrap() is safely implemented and does not lead to potential runtime errors, such as panics in cases where Epoch might not be properly initialized.

Please verify the implementation of Epoch.Unwrap() to ensure it handles all edge cases safely. Consider adding a check or default value inside Unwrap() to handle uninitialized or zero-value states.

calbera and others added 3 commits September 24, 2024 14:08
Signed-off-by: nidhi-singh02 <trippin@berachain.com>
Signed-off-by: nidhi-singh02 <trippin@berachain.com>
@nidhi-singh02 nidhi-singh02 marked this pull request as ready for review September 24, 2024 18:43
Signed-off-by: nidhi-singh02 <trippin@berachain.com>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 11

Outside diff range comments (3)
mod/consensus-types/pkg/types/withdrawal_credentials.go (1)

Line range hint 1-88: Consider addressing TODOs and planning for comprehensive refactoring.

While the new Bytes() method is a great addition, there are still several TODO comments in the file indicating potential future refactoring. It might be beneficial to create a comprehensive plan to address these TODOs and refactor the WithdrawalCredentials type.

Consider the following steps:

  1. Review all TODO comments and assess their relevance.
  2. Determine if the custom implementations of UnmarshalJSON, String, MarshalText, and UnmarshalText are still necessary.
  3. Evaluate if a more generic approach could be implemented to reduce code duplication.
  4. Consider how the new Bytes() method fits into the overall interface and if any other methods should be added or modified.

Creating a separate issue to track this refactoring effort could help ensure it's not overlooked in future development.

mod/consensus-types/go.mod (1)

Line range hint 3-3: Invalid Go version specified.

The Go version is set to 1.23.0, which is not a valid Go version as of September 2024. The latest stable version of Go is 1.21.x, and Go follows a specific versioning scheme (1.x for major versions).

Please update the Go version to a valid and appropriate version, such as 1.21.0 or the latest stable version available at the time of this PR.

-go 1.23.0
+go 1.21.0
mod/node-core/pkg/components/api_handlers.go (1)

Line range hint 175-181: Missing Type Parameter Declaration for WithdrawalCredentials

In the function ProvideNodeAPIProofHandler, the type parameter WithdrawalCredentials is used in NodeAPIBackend but is not declared in the function's type parameters. This will cause a compilation error.

Apply the following diff to declare WithdrawalCredentials in the function's type parameters:

 func ProvideNodeAPIProofHandler[
     BeaconBlockHeaderT BeaconBlockHeader[BeaconBlockHeaderT],
     BeaconStateT BeaconState[
         BeaconStateT, BeaconBlockHeaderT, BeaconStateMarshallableT,
         *Eth1Data, ExecutionPayloadHeaderT, *Fork, KVStoreT,
         *Validator, Validators, WithdrawalT,
     ],
     BeaconStateMarshallableT BeaconStateMarshallable[
         BeaconStateMarshallableT, BeaconBlockHeaderT, *Eth1Data,
         ExecutionPayloadHeaderT, *Fork, *Validator,
     ],
     ExecutionPayloadHeaderT ExecutionPayloadHeader[ExecutionPayloadHeaderT],
     KVStoreT any,
     NodeT any,
     NodeAPIContextT NodeAPIContext,
     WithdrawalT Withdrawal[WithdrawalT],
+    WithdrawalCredentials,
 ](b NodeAPIBackend[
     BeaconBlockHeaderT,
     BeaconStateT,
     *Fork,
     NodeT,
     *Validator,
     WithdrawalCredentials,
 ]) *proofapi.Handler[
     BeaconBlockHeaderT, BeaconStateT, BeaconStateMarshallableT,
     NodeAPIContextT, ExecutionPayloadHeaderT, *Validator,
 ] {
Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between e3cec53 and d525150.

Files ignored due to path filters (1)
  • mod/consensus-types/go.sum is excluded by !**/*.sum
Files selected for processing (16)
  • examples/berad/pkg/consensus-types/validator.go (2 hunks)
  • mod/consensus-types/go.mod (1 hunks)
  • mod/consensus-types/pkg/types/state_test.go (2 hunks)
  • mod/consensus-types/pkg/types/validator.go (7 hunks)
  • mod/consensus-types/pkg/types/withdrawal_credentials.go (1 hunks)
  • mod/node-api/backend/mocks/validator.mock.go (2 hunks)
  • mod/node-api/backend/mocks/withdrawal_credentials.mock.go (1 hunks)
  • mod/node-api/backend/types.go (3 hunks)
  • mod/node-api/backend/validator.go (3 hunks)
  • mod/node-api/handlers/beacon/backend.go (2 hunks)
  • mod/node-api/handlers/beacon/block.go (1 hunks)
  • mod/node-api/handlers/beacon/handler.go (1 hunks)
  • mod/node-api/handlers/beacon/types/response.go (3 hunks)
  • mod/node-api/handlers/beacon/types/types.go (1 hunks)
  • mod/node-core/pkg/components/api_handlers.go (3 hunks)
  • mod/node-core/pkg/components/interfaces.go (4 hunks)
Additional comments not posted (46)
mod/consensus-types/pkg/types/withdrawal_credentials.go (1)

85-88: LGTM! The new Bytes() method is a valuable addition.

The implementation of the Bytes() method is correct and efficient. The added comment clearly explains its purpose. This method aligns well with the existing methods and enhances the interface of the WithdrawalCredentials type.

It's great to see that the previous review comments have been addressed:

  1. A comment has been added to explain the purpose of the method.
  2. The method fits well with the existing structure and doesn't conflict with potential future refactoring indicated by the TODOs.
mod/node-api/backend/mocks/withdrawal_credentials.mock.go (5)

23-41: LGTM: Bytes() method implementation is correct and follows best practices.

The Bytes() method is well-implemented:

  • It correctly uses the Called() method to manage expectations.
  • The panic for no return value helps catch test misconfigurations.
  • The type assertion and conversion logic properly handles both func() []byte and []byte return types.

This implementation provides flexibility for various testing scenarios.


43-47: LGTM: WithdrawalCredentials_Bytes_Call struct is correctly defined.

The WithdrawalCredentials_Bytes_Call struct:

  • Properly embeds *mock.Call.
  • Follows the standard pattern for generated mocks.
  • Enhances type safety and improves IDE autocompletion for the Bytes() method calls in tests.

48-51: LGTM: Bytes() expectation helper method is correctly implemented.

The Bytes() method in WithdrawalCredentials_Expecter:

  • Properly sets up expectations for the Bytes() method.
  • Correctly uses the mock's On() method.
  • Returns the appropriate type for chaining method calls in tests.

This implementation enhances the usability of the mock in test scenarios.


53-68: LGTM: Run(), Return(), and RunAndReturn() methods are correctly implemented.

These methods in WithdrawalCredentials_Bytes_Call:

  • Properly wrap the underlying mock.Call methods.
  • Provide type safety and an improved API for setting up mock behaviors.
  • Correctly return *WithdrawalCredentials_Bytes_Call for method chaining.
  • The RunAndReturn() method appropriately handles function-based return value generation.

These implementations enhance the usability and type safety of the mock in test scenarios.


Line range hint 1-69: LGTM: Overall changes to the file are consistent and complete.

The additions to the withdrawal_credentials.mock.go file:

  • Are consistent with the existing code structure and patterns.
  • Properly implement the Bytes() method and its supporting types.
  • Maintain the overall structure and style of a generated mock file.

These changes enhance the mock's capabilities while maintaining consistency with the existing implementation.

mod/consensus-types/go.mod (1)

7-7: Dependency update looks good.

The update of github.com/berachain/beacon-kit/mod/errors to version v0.0.0-20240806211103-d1105603bfc0 is in line with the PR objectives. This change likely includes necessary updates or fixes for the error handling module.

mod/consensus-types/pkg/types/state_test.go (3)

81-84: Improved withdrawal credentials initialization.

The change from direct byte array assignment to using types.NewCredentialsFromExecutionAddress is a positive improvement. This approach enhances readability, maintainability, and potentially provides better type safety for credential creation.


93-96: Consistent application of improved withdrawal credentials initialization.

This change mirrors the improvement made to the first Validator instance, ensuring consistency in how withdrawal credentials are initialized across different validators. This uniform approach enhances the overall code quality and maintainability.


Line range hint 81-96: Summary: Enhancements align with E2E testing objectives.

The changes to the generateValidBeaconState function improve the test data generation process by using a more structured approach for initializing withdrawal credentials. These modifications enhance the quality of the test setup, which is crucial for effective E2E testing. The changes are confined to the test code and don't introduce any risks to the production codebase. This aligns well with the PR objectives of implementing robust E2E tests for the beacon endpoints.

examples/berad/pkg/consensus-types/validator.go (4)

237-245: LGTM: New getter methods added for ActivationEpoch and ExitEpoch

The addition of GetActivationEpoch() and GetExitEpoch() methods improves the API by providing explicit access to these fields. The implementation is correct and consistent with other methods in the struct.


44-44: LGTM: JSON field name updated to snake_case

The JSON tag for ActivationEpoch has been correctly updated to use snake_case ("activation_epoch"). This change improves consistency and follows common JSON naming conventions.

Please ensure that any systems consuming this JSON output are updated to handle the new field name. Run the following script to check for any remaining usage of the old field name:

#!/bin/bash
# Search for any remaining usage of the old JSON field name
rg --type go '"activationEpoch"'

42-42: LGTM: JSON field name updated to snake_case

The JSON tag for EffectiveBalance has been correctly updated to use snake_case ("effective_balance"). This change improves consistency and follows common JSON naming conventions.

Please ensure that any systems consuming this JSON output are updated to handle the new field name. Run the following script to check for any remaining usage of the old field name:


46-48: LGTM: JSON field names updated to snake_case

The JSON tags for ExitEpoch and WithdrawableEpoch have been correctly updated to use snake_case ("exit_epoch" and "withdrawable_epoch" respectively). These changes improve consistency and follow common JSON naming conventions.

Please ensure that any systems consuming this JSON output are updated to handle the new field names. Run the following script to check for any remaining usage of the old field names:

Verification successful

WithdrawalCredentialsT Correctly Included in All Backend Usages

All instances of Backend across the codebase have been updated to include WithdrawalCredentialsT, ensuring consistency and preventing type mismatches.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that all definitions of Backend include WithdrawalCredentialsT.

# Test: Search for Backend definitions missing WithdrawalCredentialsT. Expect: No matches found.
ast-grep --lang go --pattern $'Backend[
  $$$, ValidatorT, $$$
]' 

Length of output: 2289

mod/node-api/handlers/beacon/types/response.go (5)

64-72: Previous feedback on MarshalJSON method in ValidatorBalanceData is still applicable


83-93: Previous feedback on renaming validatorJSON to ValidatorJSON is still applicable


94-98: Previous feedback on renaming responseJSON to ResponseJSON is still applicable


101-133: Previous feedback on refactoring MarshalJSON method in ValidatorData is still applicable


159-165: Previous feedback on accessing embedded fields in ForkData.MarshalJSON is still applicable

mod/node-core/pkg/components/api_handlers.go (1)

Line range hint 175-181: Verify if WithdrawalCredentials Should Be Included in proofapi.Handler

The WithdrawalCredentials type parameter is included in NodeAPIBackend but not in proofapi.Handler. If WithdrawalCredentials are required in the proof API handler, consider adding it to the type parameters of proofapi.Handler to ensure consistency and correct functionality.

mod/node-api/backend/types.go (3)

28-28: Import of 'crypto' package is appropriate

The addition of the crypto package import is necessary for the use of crypto.BLSPubkey in the Validator interface.


128-143: Consider removing 'Get' prefixes from method names to follow Go conventions

As previously noted, Go conventions recommend omitting 'Get' prefixes from method names. Renaming methods like GetPubkey() to Pubkey() aligns with idiomatic Go practices and enhances code readability.


162-162: Documentation for Bytes() method added successfully

The added doc comment for the Bytes() method improves clarity and adheres to Go documentation standards.

mod/node-api/backend/mocks/validator.mock.go (2)

215-225: Ensure Proper Initialization in GetPubkey

In the GetPubkey method, if ret.Get(0) is nil, the variable r0 remains uninitialized, which could lead to unexpected behavior when r0 is returned. Consider initializing r0 explicitly to its zero value to ensure consistent function behavior.


27-206: Refactor to Reduce Code Duplication in Mock Methods

The mock methods such as GetActivationEligibilityEpoch, GetActivationEpoch, GetEffectiveBalance, GetExitEpoch, GetWithdrawableEpoch, and IsSlashed have similar structures with repeated code blocks. Extracting common logic into helper functions could reduce duplication and enhance maintainability. Since this is generated code, consider adjusting the code generator to produce more DRY (Don't Repeat Yourself) code.

Also applies to: 255-297, 344-384

mod/node-core/pkg/components/interfaces.go (3)

1087-1088: Restricting ValidatorT Type Parameter Reduces Interface Flexibility

As previously noted, constraining ValidatorT to types.Validator[WithdrawalCredentialsT] reduces the flexibility of the NodeAPIBackend interface. This change may limit future extensions or implementations that require different validator types or withdrawal credentials. Consider keeping ValidatorT as a generic type parameter to maintain modularity and reusability.


1162-1162: Function Signature Updated to Reflect Type Changes

The return type of ValidatorByID has been updated to *types.ValidatorData[ValidatorT, WithdrawalCredentialsT], which aligns with the new type constraints. This ensures consistency across the interface and clarity in the data structures being used.


1167-1167: Function Signature Updated to Reflect Type Changes

The return type of ValidatorsByIDs has been updated to []*types.ValidatorData[ValidatorT, WithdrawalCredentialsT], maintaining consistency with the updated type definitions. This change enhances type safety and clarity in the interface.

mod/consensus-types/pkg/types/validator.go Show resolved Hide resolved
mod/node-api/handlers/beacon/block.go Show resolved Hide resolved
mod/node-api/handlers/beacon/types/types.go Show resolved Hide resolved
mod/node-api/handlers/beacon/types/types.go Show resolved Hide resolved
mod/node-api/handlers/beacon/handler.go Show resolved Hide resolved
mod/node-api/backend/validator.go Show resolved Hide resolved
mod/node-core/pkg/components/api_handlers.go Show resolved Hide resolved
mod/node-core/pkg/components/api_handlers.go Show resolved Hide resolved
mod/node-api/backend/mocks/validator.mock.go Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

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

only suggestion is to clean up this file by maybe splitting up the different response types (and associated marshal functions if necessary) into different files

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. I would prefer doing refactoring in a separate PR. I don't want the diff to increase in current one. I hope it is okay.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here is the PR #2024 to address this comment.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between d525150 and c1c5e46.

📒 Files selected for processing (2)
  • mod/node-api/backend/mocks/validator.mock.go (2 hunks)
  • mod/node-api/backend/mocks/withdrawal_credentials.mock.go (1 hunks)
🔇 Additional comments (13)
mod/node-api/backend/mocks/withdrawal_credentials.mock.go (6)

23-41: LGTM: Bytes() method implementation is correct and follows best practices.

The Bytes() method is well-implemented, following the standard pattern for mock methods using the testify/mock package. It correctly handles different return value scenarios and includes appropriate panic handling for cases where no return value is specified.


43-46: LGTM: WithdrawalCredentials_Bytes_Call struct is correctly defined.

The WithdrawalCredentials_Bytes_Call struct is properly defined to provide type-specific methods for the Bytes() mock call. The embedding of *mock.Call allows it to inherit all necessary methods from the base Call type.


48-51: LGTM: Bytes() expectation helper method is correctly implemented.

The Bytes() method in the WithdrawalCredentials_Expecter struct is properly implemented as a helper to define expectations for the Bytes() method on the mock. It correctly uses the mock's On() method to set up the expectation.


53-58: LGTM: Run() method is correctly implemented for type-safe custom logic execution.

The Run() method of the WithdrawalCredentials_Bytes_Call struct is well-implemented. It allows for type-safe execution of custom logic during the mock call and correctly returns the call object for method chaining.


60-68: LGTM: Return() and RunAndReturn() methods are correctly implemented.

Both the Return() and RunAndReturn() methods of the WithdrawalCredentials_Bytes_Call struct are well-implemented. They allow for type-safe setting of return values for the mock call, either directly or through a function. Both methods correctly return the call object for method chaining, consistent with the testify/mock package's patterns.


23-69: Overall assessment: Excellent implementation of the Bytes() method mock.

The additions to the WithdrawalCredentials mock are well-implemented and follow best practices for mock objects using the testify/mock package. The new Bytes() method and its associated helper types and methods enhance the mock's functionality and provide type-safe ways to set expectations and return values. These changes will improve the testing capabilities for code that depends on the WithdrawalCredentials interface.

mod/node-api/backend/mocks/validator.mock.go (7)

7-8: Import Addition Approved

The addition of the bytes package import is appropriate and necessary for handling bytes.B48 types used in the mock methods.


27-44: Comment Previously Addressed: Handle Potential Nil Return Values

The issue regarding nil return values in GetActivationEligibilityEpoch has been previously discussed. The past review comment is still valid and applicable here.


72-88: Comment Previously Addressed: Handle Potential Nil Return Values

As with earlier methods, the concern about nil return values in GetActivationEpoch remains. The previous review comment applies to this code segment.


117-133: Comment Previously Addressed: Handle Potential Nil Return Values

The method GetEffectiveBalance may encounter issues with nil return values. This has been noted in prior reviews, and the comment remains pertinent.


162-178: Comment Previously Addressed: Handle Potential Nil Return Values

The potential for nil return values in GetExitEpoch has been previously highlighted. The existing review comment is still relevant.


207-225: Nil Check Implementation Consistent

The method GetPubkey includes a nil check before type assertion, ensuring safe handling of potential nil values. This implementation is correct and consistent with best practices.


255-270: Comment Previously Addressed: Handle Potential Nil Return Values

The concern regarding nil return values in GetWithdrawableEpoch is consistent with earlier methods. The previous review comment applies here as well.

mod/node-api/backend/mocks/validator.mock.go Show resolved Hide resolved
mod/node-api/backend/mocks/validator.mock.go Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range comments (1)
mod/node-api/engines/echo/vaildator.go (1)

Line range hint 146-166: LGTM! Consider extracting allowed statuses as a constant.

The ValidateValidatorStatus function correctly implements the validation logic for validator statuses according to the Eth Beacon Node API specs. Good job on using the validateAllowedStrings helper function for consistency.

For improved maintainability, consider extracting the allowedStatuses map as a package-level constant. This would make it easier to update the list of allowed statuses in the future and potentially reuse it in other parts of the code if needed.

Example:

var AllowedValidatorStatuses = map[string]bool{
    "pending_initialized": true,
    "pending_queued":      true,
    // ... other statuses ...
}

func ValidateValidatorStatus(fl validator.FieldLevel) bool {
    return validateAllowedStrings(fl.Field().String(), AllowedValidatorStatuses)
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between 30de37e and ea13e17.

📒 Files selected for processing (5)
  • mod/node-api/backend/mocks/validator.mock.go (2 hunks)
  • mod/node-api/backend/mocks/withdrawal_credentials.mock.go (1 hunks)
  • mod/node-api/backend/types.go (3 hunks)
  • mod/node-api/engines/echo/vaildator.go (1 hunks)
  • mod/node-core/pkg/components/interfaces.go (4 hunks)
🧰 Additional context used
📓 Learnings (1)
mod/node-api/backend/mocks/validator.mock.go (2)
Learnt from: nidhi-singh02
PR: berachain/beacon-kit#1983
File: mod/node-api/backend/mocks/validator.mock.go:299-315
Timestamp: 2024-09-30T07:19:39.490Z
Learning: Auto-generated mock files (e.g., files in `mod/**/mocks/` directories) should be ignored in code reviews.
Learnt from: nidhi-singh02
PR: berachain/beacon-kit#1983
File: mod/node-api/backend/mocks/validator.mock.go:299-315
Timestamp: 2024-10-08T15:37:30.097Z
Learning: Auto-generated mock files (e.g., files in `mod/**/mocks/` directories) should be ignored in code reviews.
🔇 Additional comments (17)
mod/node-api/backend/mocks/withdrawal_credentials.mock.go (6)

23-41: LGTM: Bytes method implementation looks correct and follows best practices.

The Bytes method is well-implemented, following the standard testify mock pattern. It includes proper error handling (panic for no return value) and flexibility in return types (direct byte slice or function returning byte slice). This implementation will facilitate effective testing of the WithdrawalCredentials interface.


43-46: LGTM: WithdrawalCredentials_Bytes_Call struct is correctly defined.

The WithdrawalCredentials_Bytes_Call struct is properly implemented to shadow the Run/Return methods with type-explicit versions for the Bytes method. This follows the testify mock pattern and will enhance type safety when setting up expectations for the Bytes method in tests.


48-51: LGTM: Bytes method in WithdrawalCredentials_Expecter is correctly implemented.

The Bytes method in the WithdrawalCredentials_Expecter struct is well-implemented. It follows the testify mock pattern for setting up expectations and returns the appropriate type (*WithdrawalCredentials_Bytes_Call). This will facilitate type-safe and easy-to-use expectation setup for the Bytes method in tests.


53-68: LGTM: Run, Return, and RunAndReturn methods are correctly implemented.

The Run, Return, and RunAndReturn methods for WithdrawalCredentials_Bytes_Call are well-implemented. They follow the testify mock pattern for type-safe method call expectations and provide flexibility in defining mock behavior. The use of method chaining (returning *WithdrawalCredentials_Bytes_Call) is a good practice that enhances the fluency of the mock API.


23-69: LGTM: Overall structure and consistency of the added code is excellent.

The new code for the Bytes method mock is well-structured and consistent with the existing mock implementation. It follows the established patterns for testify mocks, maintains consistent naming conventions, and integrates seamlessly with the existing code. This consistency will make the mock easy to use and understand for developers working with the WithdrawalCredentials interface.


Line range hint 1-69: Summary: Excellent implementation of the Bytes method mock.

The additions to the WithdrawalCredentials mock are well-implemented, following best practices for testify mocks. The new Bytes method and its supporting structures are consistent with the existing code and will enhance the testing capabilities for the WithdrawalCredentials interface. The implementation provides flexibility and type safety, which will contribute to more robust and maintainable tests.

mod/node-api/engines/echo/vaildator.go (2)

63-69: LGTM! Consider alphabetizing the validators map.

The addition of the "validator_status" validator is a good improvement to the validation capabilities. The implementation is consistent with the existing structure.

For better readability and easier maintenance, consider alphabetizing the entries in the validators map. This would make it easier to locate specific validators in the future.


Line range hint 1-236: Summary: Good addition to enhance validation capabilities

The changes in this file successfully introduce validation for validator statuses, which aligns well with the PR objectives of implementing E2E tests for existing beacon endpoints. This enhancement to the API's input validation is crucial for ensuring robust E2E testing.

The implementation is consistent with the existing code structure and follows good practices. The suggestions provided (alphabetizing the validators map and extracting allowed statuses as a constant) are minor improvements that could further enhance maintainability.

Overall, these changes contribute positively to the validation framework and support the goal of establishing a solid foundation for E2E testing.

mod/node-api/backend/types.go (3)

28-28: Import added for crypto package

The addition of the crypto package import is necessary for the crypto.BLSPubkey type used in the GetPubkey method.


128-143: New methods added to Validator interface enhance functionality

The inclusion of these methods provides detailed access to validator attributes, improving the interface's comprehensiveness and utility.


161-162: Bytes() method added to WithdrawalCredentials interface

The addition of the Bytes() method allows for retrieval of the raw byte representation of withdrawal credentials, complementing the existing functionality.

mod/node-api/backend/mocks/validator.mock.go (1)

Line range hint 1-400: Skipping review of auto-generated mock file as per previous learnings.

According to the learnings retrieved from long-term memory, auto-generated mock files (e.g., files in mod/**/mocks/ directories) should be ignored in code reviews.

mod/node-core/pkg/components/interfaces.go (5)

1088-1089: Enhancing type safety with WithdrawalCredentialsT

Introducing WithdrawalCredentialsT as a type parameter and defining ValidatorT as types.Validator[WithdrawalCredentialsT] improves type safety and clarity. This change ensures that validators are consistently associated with the correct withdrawal credentials throughout the interface.


1107-1109: Consistent update of NodeAPIBeaconBackend interface

The NodeAPIBeaconBackend interface now includes WithdrawalCredentialsT and specifies ValidatorT as types.Validator[WithdrawalCredentialsT]. This alignment with NodeAPIBackend enhances consistency and type safety across the codebase.


1115-1115: Update to ValidatorBackend interface

Updating the ValidatorBackend interface to include WithdrawalCredentialsT as a type parameter and defining ValidatorT accordingly improves specificity and ensures correct type associations in validator operations.


1157-1160: Refinement of type parameters in ValidatorBackend

The addition of WithdrawalCredentialsT and redefining ValidatorT as types.Validator[WithdrawalCredentialsT] enhances the interface's clarity. It ensures that methods handling validators correctly reference the associated withdrawal credentials type.


1163-1163: Updated return types in validator methods

The methods ValidatorByID and ValidatorsByIDs now return *types.ValidatorData[ValidatorT, WithdrawalCredentialsT], which ensures that the returned data includes the appropriate withdrawal credentials. This update enhances the precision and correctness of the returned validator information.

Also applies to: 1168-1168

Signed-off-by: Nidhi Singh <trippin@berachain.com>
Signed-off-by: nidhi-singh02 <trippin@berachain.com>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Outside diff range comments (2)
mod/node-api/engines/echo/vaildator.go (2)

Line range hint 131-131: Update comment to reference official specification

The comment references a HackMD URL, which may not be stable or permanent. Consider updating the comment to point to the official Ethereum Beacon Node API specifications for better longevity and clarity.


Line range hint 132-140: Move allowedStatuses to a package-level variable

Defining allowedStatuses within the ValidateValidatorStatus function causes the map to be recreated on each function call. To improve performance and reduce overhead, consider moving allowedStatuses to a package-level variable or constant.

Apply this change to refactor the code:

+var allowedValidatorStatuses = map[string]bool{
+	"pending_initialized": true,
+	"pending_queued":      true,
+	"active_ongoing":      true,
+	"active_exiting":      true,
+	"active_slashed":      true,
+	"exited_unslashed":    true,
+	"exited_slashed":      true,
+	"withdrawal_possible": true,
+	"withdrawal_done":     true,
+}

 func ValidateValidatorStatus(fl validator.FieldLevel) bool {
-	// Eth Beacon Node API specs: https://hackmd.io/ofFJ5gOmQpu1jjHilHbdQQ
-	allowedStatuses := map[string]bool{
-		"pending_initialized": true,
-		"pending_queued":      true,
-		"active_ongoing":      true,
-		"active_exiting":      true,
-		"active_slashed":      true,
-		"exited_unslashed":    true,
-		"exited_slashed":      true,
-		"withdrawal_possible": true,
-		"withdrawal_done":     true,
-	}
 	return validateAllowedStrings(fl.Field().String(), allowedValidatorStatuses)
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between ea13e17 and dccfde1.

📒 Files selected for processing (5)
  • mod/node-api/backend/mocks/validator.mock.go (2 hunks)
  • mod/node-api/backend/mocks/withdrawal_credentials.mock.go (1 hunks)
  • mod/node-api/backend/types.go (3 hunks)
  • mod/node-api/engines/echo/vaildator.go (1 hunks)
  • mod/node-core/pkg/components/interfaces.go (4 hunks)
🧰 Additional context used
📓 Learnings (1)
mod/node-api/backend/mocks/validator.mock.go (2)
Learnt from: nidhi-singh02
PR: berachain/beacon-kit#1983
File: mod/node-api/backend/mocks/validator.mock.go:299-315
Timestamp: 2024-09-30T07:19:39.490Z
Learning: Auto-generated mock files (e.g., files in `mod/**/mocks/` directories) should be ignored in code reviews.
Learnt from: nidhi-singh02
PR: berachain/beacon-kit#1983
File: mod/node-api/backend/mocks/validator.mock.go:299-315
Timestamp: 2024-10-08T15:37:30.097Z
Learning: Auto-generated mock files (e.g., files in `mod/**/mocks/` directories) should be ignored in code reviews.
🔇 Additional comments (9)
mod/node-api/backend/mocks/withdrawal_credentials.mock.go (3)

23-41: New Bytes method added to WithdrawalCredentials mock is appropriate

The Bytes method has been correctly added to the WithdrawalCredentials mock. This addition ensures that tests can accurately mock and verify calls to Bytes, enhancing test coverage and flexibility.


43-51: Helper methods for Bytes mock calls are properly implemented

The definitions of WithdrawalCredentials_Bytes_Call and the helper methods in the WithdrawalCredentials_Expecter are correctly set up. These allow for fluent expectation setting on the Bytes method within tests, aligning with the mockery framework's patterns.


53-68: Mock call handling for Bytes method is correctly structured

The implementations of Run, Return, and RunAndReturn methods for WithdrawalCredentials_Bytes_Call are properly designed. They provide the necessary interfaces to define custom behaviors and return values when the Bytes method is called, which is essential for comprehensive testing scenarios.

mod/node-api/engines/echo/vaildator.go (1)

63-69: Addition of validator_status validator

The inclusion of validator_status in the validators map enhances the validation capabilities and maintains consistency with existing validators.

mod/node-api/backend/types.go (3)

28-28: Approved

The addition of the crypto import is necessary for the GetPubkey() method in the Validator interface.


128-143: Method naming conventions: previous comments still apply

The previous review comment about removing 'Get' prefixes from method names to follow Go conventions is still applicable. Adhering to Go's naming conventions improves code readability and consistency.


161-162: Approved

The addition of the Bytes() method to the WithdrawalCredentials interface provides necessary functionality and is well-documented.

mod/node-api/backend/mocks/validator.mock.go (1)

Line range hint 1-384: Skipping Review of Auto-Generated Mock File

Based on previous learnings, auto-generated mock files located in mod/**/mocks/ directories are to be ignored during code reviews.

mod/node-core/pkg/components/interfaces.go (1)

1088-1089: Restricting WithdrawalCredentialsT type parameter reduces interface flexibility

By specifying WithdrawalCredentialsT as types.WithdrawalCredentials in the interfaces, you're limiting their flexibility to accept different implementations of withdrawal credentials. This reduces the generality of the interfaces and may hinder future extensions or implementations that require different withdrawal credential types. Consider keeping WithdrawalCredentialsT as a generic type parameter without constraining it to types.WithdrawalCredentials to maintain modularity and reusability.

Also applies to: 1107-1109, 1157-1160

mod/node-api/backend/types.go Show resolved Hide resolved
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.

E2E tests for existing endpoints related to beacon namespace
3 participants