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

feat(payload): Move to holiman lib #1821

Merged
merged 5 commits into from
Jul 30, 2024
Merged

feat(payload): Move to holiman lib #1821

merged 5 commits into from
Jul 30, 2024

Conversation

itsdevbear
Copy link
Contributor

@itsdevbear itsdevbear commented Jul 30, 2024

Summary by CodeRabbit

  • New Features

    • Introduced a new BaseFeePerGas field to the BeaconBlock, enhancing transaction cost management.
    • Updated initialization of BaseFeePerGas across various structures to improve handling of transaction fees.
  • Bug Fixes

    • Improved error handling in the ExecutionPayloadHeader and ExecutionPayload structs by transitioning to pointer types.
  • Documentation

    • Enhanced clarity in the handling of base fee values through updated method signatures and initialization methods.
  • Chores

    • Refactored dependency management for libraries related to handling large integers, ensuring more direct and clear references.
  • Tests

    • Adjusted test cases to align with the new pointer types and handling for BaseFeePerGas, enhancing the robustness of the test suite.

@itsdevbear itsdevbear requested a review from ocnc as a code owner July 30, 2024 19:58
Copy link
Contributor

coderabbitai bot commented Jul 30, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

The recent changes enhance the handling of the BaseFeePerGas field across multiple files, transitioning from value types to pointer types for improved memory management and flexibility. Functions and structures have been updated to reflect this shift, which enhances error handling and data representation in blockchain applications. Additionally, several redundant methods were removed, streamlining the codebase while preserving functionality.

Changes

Files Change Summary
mod/chain-spec/pkg/chain/chain_spec.go Minor whitespace cleanup in Spec interface; no functional changes.
mod/cli/pkg/commands/genesis/payload.go, mod/consensus-types/pkg/genesis/genesis.go Updated BaseFeePerGas initialization from math.MustNewU256LFromBigInt to math.NewU256FromBigInt for improved error handling.
mod/consensus-types/go.mod, mod/engine-primitives/go.mod Added direct dependency on github.com/holiman/uint256 v1.3.0, improving clarity and management of dependencies.
mod/consensus-types/pkg/types/block_test.go, mod/consensus-types/pkg/types/body_test.go Introduced BaseFeePerGas field in BeaconBlock and ExecutionPayload; initialized with math.NewU256(0).
mod/consensus-types/pkg/types/payload.go, mod/consensus-types/pkg/types/payload_header.go Changed BaseFeePerGas from math.Wei to *math.U256, affecting serialization and JSON methods.
mod/engine-primitives/pkg/engine-primitives/mocks/built_execution_payload_env.mock.go Updated mock methods to use *uint256.Int instead of math.U256L, enhancing type safety and memory efficiency.
mod/engine-primitives/pkg/engine-primitives/payload_env.go, mod/engine-primitives/pkg/engine-primitives/requests.go Changed GetValue and GetBaseFeePerGas methods to return pointers to math.U256, simplifying handling of large values.
mod/primitives/pkg/math/u256.go Refactored U256 type to be an alias of uint256.Int and removed unnecessary methods, streamlining the implementation.
mod/primitives/pkg/math/u64.go Removed unused methods from U64 type and updated Gwei.ToWei to return *U256 instead of *big.Int.
testing/quick/compare_test.go Updated test to initialize BaseFeePerGas using math.NewU256(123), improving precision handling.

Poem

🐰 In fields of code where bunnies play,
We’ve tidied up, hooray, hooray!
With pointers now, our fees take flight,
Memory saved, oh what a sight!
Happy hops and joyful cheer,
A cleaner path, let’s all draw near!
🌼✨


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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 Jul 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (main@a9255e3). Learn more about missing BASE report.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1821   +/-   ##
=======================================
  Coverage        ?   32.45%           
=======================================
  Files           ?        7           
  Lines           ?      114           
  Branches        ?       19           
=======================================
  Hits            ?       37           
  Misses          ?       76           
  Partials        ?        1           

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: 3

Outside diff range comments (1)
mod/engine-primitives/pkg/engine-primitives/payload_env_test.go (1)

[!TIP]
Codebase Verification

Ensure test coverage is maintained.

The removal of the TestExecutionPayloadEnvelope function has significantly reduced the test coverage for the ExecutionPayloadEnvelope struct. No equivalent tests were found elsewhere in the codebase. Please add tests to cover the functionality of the ExecutionPayloadEnvelope struct to maintain adequate test coverage.

  • Files to review:
    • mod/engine-primitives/pkg/engine-primitives/payload_env_test.go
Analysis chain

Line range hint 1-1:
Ensure test coverage is maintained.

The removal of the TestExecutionPayloadEnvelope function significantly reduces the test coverage for the ExecutionPayloadEnvelope struct. Confirm if the tests have been relocated or if the functionality is no longer necessary.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify if the `TestExecutionPayloadEnvelope` function or equivalent tests exist elsewhere in the codebase.

# Test: Search for the test function. Expect: Occurrences of similar or equivalent tests.
rg --type go 'TestExecutionPayloadEnvelope'

Length of output: 43


Script:

#!/bin/bash
# Description: Verify if the `ExecutionPayloadEnvelope` struct is being tested elsewhere in the codebase.

# Test: Search for references to `ExecutionPayloadEnvelope` in test files.
rg --type go 'ExecutionPayloadEnvelope' -g '*_test.go'

Length of output: 54


Script:

#!/bin/bash
# Description: Verify if the `ExecutionPayloadEnvelope` struct is referenced elsewhere in the codebase.

# Test: Search for references to `ExecutionPayloadEnvelope` in the entire codebase.
rg --type go 'ExecutionPayloadEnvelope'

Length of output: 1388

Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between a9255e3 and e9a76f5.

Files selected for processing (23)
  • mod/chain-spec/pkg/chain/chain_spec.go (1 hunks)
  • mod/cli/pkg/commands/genesis/payload.go (1 hunks)
  • mod/consensus-types/go.mod (2 hunks)
  • mod/consensus-types/pkg/genesis/genesis.go (1 hunks)
  • mod/consensus-types/pkg/state/deneb/deneb_test.go (2 hunks)
  • mod/consensus-types/pkg/types/block_test.go (1 hunks)
  • mod/consensus-types/pkg/types/body_test.go (1 hunks)
  • mod/consensus-types/pkg/types/payload.go (8 hunks)
  • mod/consensus-types/pkg/types/payload_header.go (8 hunks)
  • mod/consensus-types/pkg/types/payload_header_test.go (3 hunks)
  • mod/consensus-types/pkg/types/payload_test.go (3 hunks)
  • mod/engine-primitives/go.mod (2 hunks)
  • mod/engine-primitives/pkg/engine-primitives/mocks/built_execution_payload_env.mock.go (3 hunks)
  • mod/engine-primitives/pkg/engine-primitives/payload_env.go (3 hunks)
  • mod/engine-primitives/pkg/engine-primitives/payload_env_test.go (2 hunks)
  • mod/engine-primitives/pkg/engine-primitives/requests.go (3 hunks)
  • mod/engine-primitives/pkg/engine-primitives/requests_test.go (1 hunks)
  • mod/execution/pkg/engine/types.go (1 hunks)
  • mod/primitives/pkg/math/u256.go (1 hunks)
  • mod/primitives/pkg/math/u64.go (3 hunks)
  • mod/primitives/pkg/math/u64_test.go (2 hunks)
  • mod/state-transition/pkg/core/types.go (1 hunks)
  • testing/quick/compare_test.go (2 hunks)
Additional comments not posted (42)
mod/primitives/pkg/math/u256.go (3)

34-34: Refactoring: Simplified type definition.

The U256 type is now an alias for uint256.Int, simplifying its declaration and usage.


37-38: New constructor function: NewU256.

The NewU256 function creates a new U256 from a uint64, leveraging uint256.NewInt.


42-43: New constructor function: NewU256FromBigInt.

The NewU256FromBigInt function facilitates creating a U256 from a big.Int, using uint256.MustFromBig.

mod/execution/pkg/engine/types.go (1)

43-43: Refactor: Changed return type for GetBaseFeePerGas.

The return type of the GetBaseFeePerGas method in the ExecutionPayload interface has been changed to *math.U256. This change improves memory efficiency and flexibility but requires handling potential nil values.

mod/engine-primitives/pkg/engine-primitives/payload_env.go (2)

76-76: LGTM! But verify all usages of the GetValue method.

The change to use a pointer type aligns with the updated field type and method signature.

Ensure that all usages of the GetValue method in the ExecutionPayloadEnvelope struct are updated accordingly.


60-60: LGTM! But verify all usages of the BlockValue field.

The change to use a pointer type aligns with the updated method signature and can improve memory efficiency.

Ensure that all usages of the BlockValue field in the ExecutionPayloadEnvelope struct are updated accordingly.

testing/quick/compare_test.go (2)

57-57: LGTM! But verify the initialization of BaseFeePerGas.

The change aligns with the new type for BaseFeePerGas and likely enhances precision.

Ensure that the initialization of the BaseFeePerGas field using math.NewU256(123) is correct and consistent throughout the codebase.


65-65: LGTM! But verify the processing of BaseFeePerGas.

The change aligns with the new type for BaseFeePerGas and likely improves handling of large numbers.

Ensure that the processing of the BaseFeePerGas field using SetFromBig(payload.BaseFeePerGas.ToBig()) is correct and consistent throughout the codebase.

mod/engine-primitives/go.mod (1)

11-11: LGTM!

The change ensures explicit inclusion of the required version of uint256, likely to utilize its functionalities for handling large integers. This improves clarity and maintainability of the module's dependencies.

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

31-44: LGTM!

The initialization of BaseFeePerGas using math.NewU256(0) enhances the functionality of the ExecutionPayload by setting a meaningful default value.

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

12-12: Dependency added: github.com/holiman/uint256 v1.3.0

The addition of this dependency as a direct requirement enhances the module's functionality related to handling large unsigned integers.

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

154-154: Simplified initialization of BaseFeePerGas.

The change from math.MustNewU256LFromBigInt to math.NewU256FromBigInt simplifies the initialization process and enhances maintainability.

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

55-55: LGTM! The addition of BaseFeePerGas is appropriate.

The BaseFeePerGas field has been correctly added and initialized with math.NewU256(0).

mod/engine-primitives/pkg/engine-primitives/requests_test.go (1)

72-73: LGTM! The return type change to *math.U256 is appropriate.

The method GetBaseFeePerGas now returns a pointer to math.U256, which is consistent with better memory management practices.

mod/consensus-types/pkg/state/deneb/deneb_test.go (1)

99-99: LGTM! The initialization of BaseFeePerGas with math.NewU256(3906250) is appropriate.

The use of math.NewU256 for BaseFeePerGas is consistent with better numerical handling practices.

mod/cli/pkg/commands/genesis/payload.go (1)

179-179: Verify the change in error handling for BaseFeePerGas.

The change from math.MustNewU256LFromBigInt to math.NewU256FromBigInt suggests a change in error handling. Ensure that the new method handles errors gracefully and does not introduce any unexpected behavior.

mod/engine-primitives/pkg/engine-primitives/mocks/built_execution_payload_env.mock.go (2)

154-154: LGTM! But verify the usage of Return in the codebase.

The change to return a *uint256.Int instead of math.U256L is approved.

However, ensure that all function calls to Return are updated to handle the new return type.


159-159: LGTM! But verify the usage of RunAndReturn in the codebase.

The change to return a *uint256.Int instead of math.U256L is approved.

However, ensure that all function calls to RunAndReturn are updated to handle the new return type.

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

163-163: LGTM! But verify the correct handling of the new return type.

The change to return a pointer improves memory efficiency and allows for nil values. Ensure that all usages of GetBaseFeePerGas handle the new pointer type correctly.

Verification successful

LGTM! The new pointer return type is handled correctly.

The change to return a pointer improves memory efficiency and allows for nil values. All usages of GetBaseFeePerGas handle the new pointer type correctly.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that all usages of `GetBaseFeePerGas` handle the new pointer type correctly.

# Test: Search for the function usage. Expect: Correct handling of the new pointer type.
rg --type go -A 5 $'GetBaseFeePerGas'

Length of output: 6718


Script:

#!/bin/bash
# Description: Verify that all usages of `GetBaseFeePerGas` handle the new pointer type correctly.

# Test: Search for the function usage and check for proper handling of the pointer type.
rg --type go -A 5 'GetBaseFeePerGas' | grep -E '(\*|\&|\.)'

Length of output: 6708

mod/engine-primitives/pkg/engine-primitives/requests.go (2)

49-49: LGTM! But verify the correct handling of the new return type.

The change to return a pointer improves memory efficiency and allows for nil values. Ensure that all usages of GetBaseFeePerGas handle the new pointer type correctly.


89-89: LGTM! But verify the correct handling of the new return type.

The change to return a pointer improves memory efficiency and allows for nil values. Ensure that all usages of GetBaseFeePerGas handle the new pointer type correctly.

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

60-60: LGTM! But verify the correct initialization of the BaseFeePerGas field.

The change to use a pointer type for BaseFeePerGas is correctly reflected in the function. Ensure that the field is initialized correctly throughout the codebase.

Verification successful

The BaseFeePerGas field is correctly initialized throughout the codebase.

The initialization of the BaseFeePerGas field is consistent and correct, using methods that return a pointer to math.U256.

  • mod/consensus-types/pkg/types/payload_test.go
  • mod/engine-primitives/pkg/engine-primitives/requests.go
  • mod/cli/pkg/commands/genesis/payload.go
  • mod/consensus-types/pkg/state/deneb/deneb_test.go
  • mod/consensus-types/pkg/types/block_test.go
  • mod/consensus-types/pkg/types/body_test.go
  • mod/consensus-types/pkg/types/payload_header_test.go
  • mod/consensus-types/pkg/genesis/genesis.go
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the `BaseFeePerGas` field is initialized correctly throughout the codebase.

# Test: Search for the initialization of `BaseFeePerGas`. Expect: Correct initialization with pointer type.
rg --type go -A 5 $'BaseFeePerGas'

Length of output: 21008


194-194: LGTM! But verify the correct handling of the new pointer type in the test function.

The change to use a pointer type for BaseFeePerGas is correctly reflected in the test function. Ensure that the new pointer type is handled correctly in all test cases.


134-134: LGTM! But verify the correct handling of the new pointer type in the test function.

The change to use a pointer type for BaseFeePerGas is correctly reflected in the test function. Ensure that the new pointer type is handled correctly in all test cases.

Verification successful

The new pointer type for BaseFeePerGas is handled correctly in the test cases.

The test cases involving BaseFeePerGas correctly handle the new pointer type, ensuring that the field is set and verified as a pointer.

  • testing/quick/compare_test.go
  • mod/consensus-types/pkg/types/payload_test.go
  • mod/engine-primitives/pkg/engine-primitives/requests_test.go
  • mod/consensus-types/pkg/types/payload_header_test.go
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the new pointer type for `BaseFeePerGas` is handled correctly in all test cases.

# Test: Search for the test cases involving `BaseFeePerGas`. Expect: Correct handling of the new pointer type.
rg --type go -A 5 $'BaseFeePerGas'

Length of output: 21008

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

42-45: LGTM! Initialization changes improve test robustness.

The initialization of StateRoot, ReceiptsRoot, LogsBloom, and Random with 123 byte arrays provides more meaningful default values for testing. The change of BaseFeePerGas to a pointer type aligns with the new representation of gas fees.


80-80: LGTM! Assertion change aligns with new initialization.

The assertion for GetBaseFeePerGas has been updated to check against math.NewU256(1), aligning with the new initialization of BaseFeePerGas as a pointer type.


119-122: LGTM! Initialization change improves test robustness.

Initializing the unmarshalled variable with new(types.ExecutionPayloadHeader).Empty(version.Deneb) ensures that it is properly initialized before deserialization, improving the robustness of the test.


51-51: Verify the function usage in the codebase.

Ensure that all function calls to generateExecutionPayloadHeader are updated to handle the new initialization values, especially the pointer type for BaseFeePerGas.

Verification successful

Function usage verified.

All instances of generateExecutionPayloadHeader correctly handle the initialization of BaseFeePerGas as a pointer type.

  • mod/consensus-types/pkg/types/payload_header_test.go
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `generateExecutionPayloadHeader` are updated to handle the new initialization values.

# Test: Search for the function usage. Expect: Only occurrences of the new initialization values.
rg --type go -A 5 $'generateExecutionPayloadHeader'

Length of output: 9655


Script:

#!/bin/bash
# Extract the full definition of the `generateExecutionPayloadHeader` function
ast-grep --lang go --pattern $'func generateExecutionPayloadHeader() *types.ExecutionPayloadHeader {
  $$$
}' --json

# Extract the usage context of `generateExecutionPayloadHeader` to verify initialization
rg --type go -A 10 -B 5 'generateExecutionPayloadHeader'

Length of output: 22091

mod/primitives/pkg/math/u64_test.go (1)

Line range hint 1-1:
Verify if TestU64 functionality is covered elsewhere.

The removal of the TestU64 function suggests a shift in focus away from validating the math.U64 type's characteristics within this context. Ensure that these tests are either covered elsewhere or deemed unnecessary.

Verification successful

Verify if TestU64 functionality is covered elsewhere.

The TestU64 functionality is covered by other specific tests such as TestU64_MarshalSSZ, TestU64_UnmarshalSSZ, TestU64_RoundTripSSZ, TestU64_MarshalText, TestU64_UnmarshalJSON, TestU64_NextPowerOfTwo, and others in the same file.

  • mod/primitives/pkg/math/u64_test.go: Multiple functions testing various aspects of math.U64.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify if the `TestU64` functionality is covered elsewhere.

# Test: Search for the `TestU64` function usage. Expect: Occurrences of similar tests elsewhere.
rg --type go -A 5 $'TestU64'

Length of output: 5194

mod/chain-spec/pkg/chain/chain_spec.go (1)

Line range hint 1-1:
LGTM! Minor cleanup enhances readability.

The removal of the blank line from the Spec interface definition enhances readability and maintainability without affecting functionality.

mod/consensus-types/pkg/types/payload_header.go (6)

71-71: LGTM!

The change to use *uint256.Int for BaseFeePerGas improves memory management and flexibility.


141-141: LGTM!

The update to use ssz.DefineUint256 for BaseFeePerGas ensures proper serialization of the new type.


242-246: LGTM!

Marshaling BaseFeePerGas before adding it to the hash walker ensures consistent serialization.


290-290: LGTM!

Updating the BaseFeePerGas field type to *math.U256 in the MarshalJSON method aligns with the new type.


334-334: LGTM!

Updating the BaseFeePerGas field type to *math.U256 in the UnmarshalJSON method ensures correct handling during unmarshaling.


525-525: LGTM!

Returning a pointer to math.U256 in the GetBaseFeePerGas method allows for more efficient handling of the value.

mod/consensus-types/pkg/types/payload.go (6)

66-66: LGTM!

The change to use *math.U256 for BaseFeePerGas improves memory management and flexibility.


112-112: LGTM!

The update to use ssz.DefineUint256 for BaseFeePerGas ensures proper serialization of the new type.


213-217: LGTM!

Marshaling BaseFeePerGas before adding it to the hash walker ensures consistent serialization.


291-291: LGTM!

Updating the BaseFeePerGas field type to *math.U256 in the MarshalJSON method aligns with the new type.


338-338: LGTM!

Updating the BaseFeePerGas field type to *math.U256 in the UnmarshalJSON method ensures correct handling during unmarshaling.


526-526: LGTM!

Returning a pointer to math.U256 in the GetBaseFeePerGas method allows for more efficient handling of the value.

@@ -31,7 +31,7 @@ type BuiltExecutionPayloadEnv[ExecutionPayloadT any] interface {
// GetExecutionPayload retrieves the associated execution payload.
GetExecutionPayload() ExecutionPayloadT
// GetValue returns the Wei value of the block in the execution payload.
GetValue() math.Wei
GetValue() *math.U256
Copy link
Contributor

Choose a reason for hiding this comment

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

Tip

Codebase Verification

Inconsistent GetValue Implementations Detected

The GetValue method has varying return types across different files, including *math.U256 and *uint256.Int. Please update all implementations of the GetValue method to return *math.U256 to ensure consistency.

  • mod/primitives/pkg/encoding/ssz/schema/field.go: func (f Field[T]) GetValue() T
  • mod/engine-primitives/pkg/engine-primitives/payload_env.go: func (e *ExecutionPayloadEnvelope[ExecutionPayloadT, BlobsBundleT]) GetValue() *math.U256
  • mod/engine-primitives/pkg/engine-primitives/mocks/built_execution_payload_env.mock.go: func (_m *BuiltExecutionPayloadEnv[ExecutionPayloadT]) GetValue() *uint256.Int

Please verify and update the return types accordingly.

Analysis chain

LGTM! But verify all implementations and usages of the GetValue method.

The change to return a pointer type enhances memory efficiency and flexibility.

Ensure that all implementations and usages of the GetValue method in the BuiltExecutionPayloadEnv interface are updated accordingly.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all implementations and usages of the `GetValue` method in the `BuiltExecutionPayloadEnv` interface.

# Test: Search for the method implementations and usages. Expect: Only occurrences of the new signature.
rg --type go -A 5 $'GetValue() *math.U256'

Length of output: 43


Script:

#!/bin/bash
# Description: Verify all implementations and usages of the `GetValue` method in the `BuiltExecutionPayloadEnv` interface.

# Test: Search for all occurrences of the `GetValue` method, regardless of return type.
rg --type go -A 5 'GetValue()'

Length of output: 7126

Comment on lines +206 to +207
func (u Gwei) ToWei() *U256 {
return (&U256{}).Mul(NewU256(uint64(u)), NewU256(GweiPerWei))
Copy link
Contributor

Choose a reason for hiding this comment

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

Tip

Codebase Verification

Update test cases to handle new return type *U256

The test cases in mod/primitives/pkg/math/u64_test.go expect the ToWei function to return a *big.Int, but the function now returns a *U256. Update the test cases to handle the new return type.

  • File: mod/primitives/pkg/math/u64_test.go
    • Lines: 7, 10, 15
Analysis chain

LGTM! But verify the usage of ToWei in the codebase.

The change to return a *U256 instead of a *big.Int is approved.

However, ensure that all function calls to ToWei are updated to handle the new return type.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `ToWei` are updated to handle the new return type.

# Test: Search for the function usage. Expect: Only occurrences of the new return type.
rg --type go 'ToWei' -A 5

Length of output: 954

Comment on lines +118 to +130
func (_m *BuiltExecutionPayloadEnv[ExecutionPayloadT]) GetValue() *uint256.Int {
ret := _m.Called()

if len(ret) == 0 {
panic("no return value specified for GetValue")
}

var r0 math.U256L
if rf, ok := ret.Get(0).(func() math.U256L); ok {
var r0 *uint256.Int
if rf, ok := ret.Get(0).(func() *uint256.Int); ok {
r0 = rf()
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(math.U256L)
r0 = ret.Get(0).(*uint256.Int)
Copy link
Contributor

Choose a reason for hiding this comment

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

Tip

Codebase Verification

Inconsistent return type for GetValue function

The GetValue function in payload_env.go still returns *math.U256, which is inconsistent with the mock implementation returning *uint256.Int.

  • File: mod/engine-primitives/pkg/engine-primitives/payload_env.go
    • Lines:
      // GetValue returns the Wei value of the block in the execution payload.
      GetValue() *math.U256
      ...
      // GetValue returns the value of the ExecutionPayloadEnvelope.
      func (e *ExecutionPayloadEnvelope[
          ExecutionPayloadT, BlobsBundleT,
      ]) GetValue() *math.U256 {
          return e.BlockValue
      }

Please update the return type of GetValue in payload_env.go to *uint256.Int to ensure consistency across the codebase.

Analysis chain

LGTM! But verify the usage of GetValue in the codebase.

The change to return a *uint256.Int instead of math.U256L is approved.

However, ensure that all function calls to GetValue are updated to handle the new return type.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `GetValue` are updated to handle the new return type.

# Test: Search for the function usage. Expect: Only occurrences of the new return type.
rg --type go 'GetValue' -A 5

Length of output: 7122

@itsdevbear itsdevbear merged commit 00ac327 into main Jul 30, 2024
15 of 16 checks passed
@itsdevbear itsdevbear deleted the bet123113223 branch July 30, 2024 20:12
itsdevbear added a commit that referenced this pull request Aug 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant