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

fix(devnet): better support of multiple preconfs in blocks #162

Merged
merged 19 commits into from
Jul 25, 2024

Conversation

thedevbirb
Copy link
Contributor

@thedevbirb thedevbirb commented Jul 24, 2024

This PR introduces a better support for multiple (>2) preconfirmations in a block, which was mostly not working before. This has been achieved with the following steps:

  1. The dependency https://github.com/ferranbt/fastssz has been updated after the fix to multiproof verifcation code: Fix(multiproofs verification): don't skip visiting intermediate hashes  ferranbt/fastssz#173
  2. Allow devnet spammer to send multiple preconfs at the same time using the --count flag; an appropriate justfile command has been introduced
  3. A deterministic ordering logic for unindexed preconfirmations has been introduced: such transactions are put at the bottom of the block but in order to satisfy protocol rules they have been ordered by nonce ascending, and in case two preconfs have the same nonce, their hashes are compared.
  4. This ordering logic influences the way merkle multiproofs are created and verified. In particular, it is enforced that generalised indices must be sorted in ascending order, and both the relay and MEV-Boost fork order the constraints according to rule above when verifying

The code has been tested in the follwing scenarios:

  • regular transactions, remote builder
  • 6 blob transactions with 1 blob each, remote builder
  • regular transactions, local builder
  • 6 blob transactions with 1 blob each, local builder

closes #148

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Enhanced preconfirmation commands to allow specification of the number of preconfirmations to send.
    • Introduced support for sending multiple transactions simultaneously via a new command-line option.
  • Enhancements

    • Increased default capacity for commitments per slot to improve performance.
    • Updated gas limits for transactions to reflect more realistic consumption.
  • Dependency Updates

    • Upgraded Go version used in Dockerfiles and modules.
    • Updated and added dependencies in various modules for improved functionality.
  • Refactor

    • Improved constraints processing with new structured types, enhancing clarity and performance in the codebase.
  • Tests

    • Introduced a new test for validating the parsing of transaction constraints to ensure functionality integrity.

Copy link
Contributor

coderabbitai bot commented Jul 24, 2024

Walkthrough

The recent updates enhance various components of the project, focusing on improved transaction handling and configuration adjustments. The functionality for sending preconfirmations has been refined with new count parameters, allowing users to specify the number of preconfirmations. Additionally, configuration values and dependencies have been updated to improve performance and scalability. Collectively, these changes streamline operations and strengthen the overall robustness of the system.

Changes

File(s) Change Summary
Justfile Updated send-preconf and send-blob-preconf commands to include a count parameter for specifying the number of preconfirmations to send.
bolt-sidecar/src/config/mod.rs Increased max_commitments_per_slot default value from 6 to 128 for improved capacity.
bolt-spammer/src/main.rs, bolt-spammer/src/utils.rs Enhanced main function to support multiple transactions with a new count command-line option; reduced gas limits in generate_random_tx and generate_random_blob_tx.
builder/Dockerfile, builder/Dockerfile.alltools Updated base image from golang:1.21-alpine to golang:1.22-alpine.
builder/builder/utils.go Renamed parameter in CalculateMerkleMultiProofs for clarity and reorganized constraint handling.
builder/go.mod, mev-boost/go.mod, mev-boost-relay/go.mod Updated Go version and modified dependencies, including the addition of github.com/emicklei/dot.
mev-boost-relay/services/api/proofs.go, mev-boost-relay/services/api/service.go Modified verifyInclusionProof to improve constraint management; updated updateRedisBidWithProofs to use HashToConstraintDecoded.
mev-boost-relay/services/api/types.go Introduced new type alias HashToConstraintDecoded and ConstraintDecoded struct for better constraint management.
mev-boost/server/constraints.go Updated ConstraintCache to use gethCommon.Hash and added new types for handling constraints.
mev-boost/server/service.go Enhanced verifyInclusionProof method to improve handling of inclusion constraints.
mev-boost/server/constraints_test.go Newly introduced test for validating transaction constraint parsing, ensuring integrity in decoding and handling transactions.

Assessment against linked issues

Objective Addressed Explanation
Investigate and resolve merkle multiproof verification issues (#148)
Ensure that constraints are parsed and validated correctly (#148)
Improve performance and scalability in handling constraints (#148)

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>.
    • 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.

@thedevbirb thedevbirb changed the title chore(devnet): update fastssz + better testing of multiple preconfs feat(devnet): better support of multiple preconfs in blocks Jul 24, 2024
@thedevbirb thedevbirb added C: mev-boost Component: mev-boost C: mev-boost-relay Component: mev-boost-relay C: block-builder Component: block builder A: devnet Area: devnet T: bug Type: Bug labels Jul 24, 2024
@thedevbirb thedevbirb changed the title feat(devnet): better support of multiple preconfs in blocks fix(devnet): better support of multiple preconfs in blocks Jul 24, 2024
@thedevbirb thedevbirb marked this pull request as ready for review July 24, 2024 14:07
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 (1)
mev-boost/server/service.go (1)

Line range hint 399-407:
Increment loop variable only once.

The loop variable i should be incremented only once per iteration.

-	leaves[i] = txHashTreeRoot[:]
-	i++
+	leaves[i] = txHashTreeRoot[:]
Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between 95a64f8 and 9afc973.

Files ignored due to path filters (3)
  • builder/go.sum is excluded by !**/*.sum
  • mev-boost-relay/go.sum is excluded by !**/*.sum
  • mev-boost/go.sum is excluded by !**/*.sum
Files selected for processing (18)
  • Justfile (2 hunks)
  • bolt-sidecar/src/config/mod.rs (1 hunks)
  • bolt-spammer/src/main.rs (2 hunks)
  • bolt-spammer/src/utils.rs (2 hunks)
  • builder/Dockerfile (1 hunks)
  • builder/Dockerfile.alltools (1 hunks)
  • builder/builder/utils.go (2 hunks)
  • builder/core/types/constraints.go (2 hunks)
  • builder/go.mod (3 hunks)
  • builder/miner/worker.go (2 hunks)
  • mev-boost-relay/go.mod (2 hunks)
  • mev-boost-relay/services/api/proofs.go (2 hunks)
  • mev-boost-relay/services/api/service.go (1 hunks)
  • mev-boost-relay/services/api/types.go (2 hunks)
  • mev-boost/Dockerfile (2 hunks)
  • mev-boost/go.mod (3 hunks)
  • mev-boost/server/constraints.go (5 hunks)
  • mev-boost/server/service.go (2 hunks)
Additional comments not posted (45)
mev-boost/Dockerfile (1)

2-2: Verify compatibility with the new base image.

The base image has been updated from golang:1.21-alpine to golang:1.22-alpine. Ensure that the new Go version does not introduce any breaking changes or incompatibilities.

Verification successful

Compatibility with Go 1.22 verified.

The go.mod files for the relevant modules (builder, mev-boost, mev-boost-relay) specify go 1.22, indicating that the codebase is intended to be compatible with Go 1.22. No immediate concerns regarding dependencies were found.

  • builder/go.mod
  • mev-boost/go.mod
  • mev-boost-relay/go.mod
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify compatibility with the new base image.

# Test: Build the Docker image and run the application. Expect: No errors.
docker build -t mev-boost-test -f mev-boost/Dockerfile .
docker run --rm mev-boost-test /app/mev-boost --version

Length of output: 264


Script:

#!/bin/bash
# Search for Go version-specific code or dependencies in the codebase.
rg 'go1\.(2[0-2]|1[0-9])' .

# Locate the go.mod file to check for any specific version constraints or dependencies.
fd go.mod

Length of output: 2451


Script:

#!/bin/bash
# Inspect the go.mod files for version constraints and dependencies.

# Output the contents of the go.mod files to check for any specific version constraints or dependencies.
cat builder/go.mod
cat mev-boost/go.mod
cat mev-boost-relay/go.mod

Length of output: 17614

builder/Dockerfile.alltools (1)

7-7: Verify compatibility with the new base image.

The base image has been updated from golang:1.21-alpine to golang:1.22-alpine. Ensure that the new Go version does not introduce any breaking changes or incompatibilities.

Verification successful

The verification confirms compatibility with the new base image.

The upgrade from golang:1.21-alpine to golang:1.22-alpine does not introduce any breaking changes or incompatibilities based on the codebase analysis.

  • The codebase does not contain Go version-specific dependencies or build constraints related to Go 1.21.
  • No Go version-specific features or APIs that might be impacted by the upgrade were found.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify compatibility with the new base image.

# Test: Build the Docker image and run the application. Expect: No errors.
docker build -t geth-alltools-test -f builder/Dockerfile.alltools .
docker run --rm geth-alltools-test /usr/local/bin/geth version

Length of output: 282


Script:

#!/bin/bash
# Description: Check for Go version-specific features or dependencies in the codebase that might be impacted by the upgrade to Go 1.22.

# Find all Go module files to check for dependencies that might be affected by Go version changes.
fd -e go.mod --exec cat {} \;

# Search for any Go version-specific build constraints in the codebase.
rg '// +build go1.21' -A 2

Length of output: 63


Script:

#!/bin/bash
# Description: Check for Go version-specific features or APIs used in the codebase that might be impacted by the upgrade to Go 1.22.

# Search for Go version-specific features or APIs in the codebase.
rg 'go1\.21' -A 2

Length of output: 1802

builder/Dockerfile (1)

7-7: Verify compatibility with the new base image.

The base image has been updated from golang:1.21-alpine to golang:1.22-alpine. Ensure that the new Go version does not introduce any breaking changes or incompatibilities.

bolt-spammer/src/utils.rs (2)

22-22: LGTM! The gas limit change is appropriate.

The new gas limit of 21,000 is more realistic for standard ETH transfers.


41-41: LGTM! The gas limit change is appropriate.

The new gas limit of 42,000 is more realistic for blob transactions.

mev-boost-relay/services/api/proofs.go (3)

27-28: Parsing constraints decoded.

The ParseConstraintsDecoded function is used to parse the new hashToConstraints input. Ensure that this function is correctly implemented and used.


31-31: Initializing leaves array.

The leaves array is initialized with the length of the parsed constraints. Ensure that this initialization is correct and efficient.


38-38: Marshalling transaction without blob.

The transaction is marshalled without the blob sidecar. Ensure that this operation is correct and efficient.

builder/core/types/constraints.go (6)

4-4: Importing sort package.

The sort package is imported for sorting operations. Ensure that the import is necessary and used correctly.


34-42: Processing constraints and accumulating gas requirements.

The function processes constraints and accumulates their gas requirements. Ensure that this logic is correct and efficient.


44-49: Sorting constraints by index.

The indexed constraints are sorted in ascending order. Ensure that the sorting operation is correct and efficient.


50-59: Sorting unindexed constraints by nonce and hash.

The unindexed constraints are sorted first by nonce and then by hash. Ensure that the sorting operation is correct and efficient.


61-61: Returning processed constraints and gas requirements.

The function returns the processed constraints and their gas requirements. Ensure that the returned values are correct and used appropriately.


26-26: New function ParseConstraintsDecoded added.

The function processes constraints and returns multiple outputs. Ensure that the function is correctly implemented and used.

mev-boost-relay/services/api/types.go (3)

48-48: LGTM!

The type alias HashToConstraintDecoded is straightforward and correctly defined.


49-52: LGTM!

The struct ConstraintDecoded is well-defined and correctly encapsulates the necessary fields.


55-92: LGTM!

The function ParseConstraintsDecoded is well-structured and follows a clear logic for sorting and concatenating constraints. The use of slices and sorting functions is appropriate.

bolt-spammer/src/main.rs (2)

36-37: LGTM!

The new field count in the struct Opts is appropriately defined with the correct attributes for command-line parsing.


58-98: LGTM!

The changes to the main function are well-structured and correctly implement the logic for sending multiple transactions. The use of the loop and the increment of the nonce are appropriate.

mev-boost/go.mod (3)

3-3: LGTM!

The update to the Go version from 1.21 to 1.22 is appropriate and ensures compatibility with newer features and improvements.


72-72: LGTM!

The update to the fastssz dependency is likely to include bug fixes or enhancements relevant to serialization in the context of Ethereum-related operations.


31-31: LGTM!

The addition of the dot dependency suggests an expansion of functionality, potentially related to graph representation or visualization.

mev-boost/server/constraints.go (8)

4-8: LGTM! Import statements updated correctly.

The addition of the slices package and aliasing common as gethCommon are appropriate for the changes made in the file.


46-46: LGTM! Updated ConstraintCache struct for consistency.

The constraints field now uses gethCommon.Hash, ensuring uniformity in hash type usage.


52-52: LGTM! Updated NewConstraintCache function for consistency.

The cache now uses gethCommon.Hash, aligning with the updated ConstraintCache struct.


61-61: LGTM! Updated AddInclusionConstraint method for consistency.

The method now uses gethCommon.Hash, ensuring uniformity in hash type usage.


84-84: LGTM! Updated AddInclusionConstraints method for consistency.

The method now uses gethCommon.Hash, ensuring uniformity in hash type usage.


101-101: LGTM! Updated Get method for consistency.

The method now returns a map with gethCommon.Hash, aligning with the updated ConstraintCache struct.


106-106: LGTM! Updated FindTransactionByHash method for consistency.

The method now uses gethCommon.Hash, ensuring uniformity in hash type usage.


123-161: LGTM! Added ParseConstraintsDecoded function.

The function is well-structured and efficiently processes and sorts constraints using modern Go practices.

mev-boost-relay/go.mod (2)

48-48: LGTM! Added new indirect dependency.

The addition of github.com/emicklei/dot v1.6.2 might introduce useful functionality related to dot language parsing or graph visualization.


95-95: LGTM! Updated dependency version.

The update to github.com/ferranbt/fastssz from v0.1.3 to v0.1.4-0.20240724090034-31cd371f8688 likely includes important improvements or new features.

Justfile (2)

113-122: LGTM! Added send-preconf-count function.

The function is well-structured and extends the existing functionality to support multiple preconfirmations using the --count parameter.


133-143: LGTM! Added send-blob-preconf-count function.

The function is well-structured and extends the existing functionality to support multiple blob preconfirmations using the --count parameter.

builder/builder/utils.go (3)

159-160: Improved parameter naming.

Renaming the parameter from constraints to HashToConstraintDecoded enhances readability and clarity.


161-162: Efficient constraint handling.

The logic for parsing and concatenating constraints improves the organization and handling of constraints within the function.


192-193: Simplified loop declaration.

Using the index variable i directly in the loop declaration simplifies the control flow and enhances readability.

builder/go.mod (3)

3-3: Go version update.

Updating the Go version from 1.20 to 1.22 ensures the project benefits from the latest features, performance improvements, and bug fixes.


29-29: Dependency update.

Updating the fastssz dependency to a newer version may include important fixes or performance improvements.


89-89: New indirect dependency.

The addition of the github.com/emicklei/dot dependency suggests new functionality or features that require this package.

bolt-sidecar/src/config/mod.rs (1)

149-149: Increased default value for max_commitments_per_slot.

Increasing the default value from 6 to 128 significantly enhances the capacity for commitments per slot, likely improving performance and scalability.

mev-boost/server/service.go (2)

346-348: Log a warning when no constraints are found for the slot.

The log message provides useful feedback when constraints are absent, improving error handling.


386-398: Optimize transaction encoding.

The TODO comment suggests optimizing the transaction encoding process to avoid unnecessary unmarshalling and marshalling.

-	// TODO: this is pretty inefficient, we should work with the transaction already
-	// parsed without the blob here to avoid unmarshalling and marshalling again

Likely invalid or redundant comment.

builder/miner/worker.go (2)

1036-1039: Encapsulate constraint parsing logic in types.ParseConstraintsDecoded.

The refactoring to use types.ParseConstraintsDecoded(constraints) improves code readability and maintainability. Ensure that ParseConstraintsDecoded handles all edge cases correctly.


1164-1164: Use common.Shift for removing elements.

The change from common.Pop to common.Shift implies a shift in the method of accessing elements, potentially altering the order in which constraints are processed. Verify that this change does not introduce any unintended side effects.

mev-boost/server/service.go Show resolved Hide resolved
mev-boost/server/service.go Outdated Show resolved Hide resolved
builder/builder/utils.go Show resolved Hide resolved
mev-boost-relay/services/api/service.go Show resolved Hide resolved
mev-boost-relay/services/api/service.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: 1

Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between 9afc973 and 9bf439c.

Files selected for processing (2)
  • builder/builder/utils.go (2 hunks)
  • mev-boost/server/service.go (2 hunks)
Additional comments not posted (9)
builder/builder/utils.go (5)

159-159: Parameter name change improves clarity

The parameter constraints has been renamed to HashToConstraintDecoded, which clarifies its role in the function.


161-162: Efficiently parse and concatenate constraints

The function now parses HashToConstraintDecoded into constraintsOrderedByIndex and constraintsWithoutIndex, and concatenates them into a single constraints slice. This improves the organization of constraint handling.


192-193: Directly reference transactions for accuracy

The loop now directly references the transaction (tx) associated with the constraint, which increases the accuracy of the transaction verification against payloadTransactions.


195-197: Error handling for missing preconfirmed transactions

The error logging within the loop has been updated to reflect the new variable names, ensuring that error messages are both consistent and informative. Specifically, the error messages now reference tx.Hash() instead of the previous hash, providing clearer context when a preconfirmed transaction is not found.


204-204: Redundant increment statement

The increment statement i++ is redundant as the loop declaration already handles the index increment.

-		i++

Likely invalid or redundant comment.

mev-boost/server/service.go (4)

346-346: Check for existence of inclusion constraints

A new check has been introduced to verify the existence of inclusion constraints linked to a specific slot, with a warning logged if none are found. This addition improves the robustness of error handling by offering clearer feedback when constraints are missing.


367-381: Organized mapping structure for constraints

The logic for processing the inclusion constraints has been restructured. The previous implementation directly created a slice of byte arrays (leaves) from the inclusion constraints. This has been replaced by a more organized mapping structure, hashToConstraint, which links transaction hashes to their decoded constraints. This change enhances the organization of constraints and facilitates subsequent processing by parsing the decoded constraints into a structured format.


386-393: Optimize transaction processing

The transaction unmarshalling process has been updated to ensure that each constraint's transaction is unmarshalled and stored in the new mapping. The error handling during unmarshalling remains intact, ensuring that any encountered issues are logged appropriately.


384-385: Remove redundant line

The line initializing the leaves slice is redundant and can be removed.

-	leaves := make([][]byte, len(constraints))

Likely invalid or redundant comment.

mev-boost/server/service.go Show resolved Hide resolved
Copy link
Collaborator

@merklefruit merklefruit left a comment

Choose a reason for hiding this comment

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

Great! A couple small changes, and then we can test this on Helder IMO!

Justfile Outdated Show resolved Hide resolved
.await?;

info!("Response: {:?}", response.text().await?);
for i in 0..opts.count {
Copy link
Collaborator

Choose a reason for hiding this comment

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

there is no delay between spamming? should we do something like 100 ms? just an idea

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For the devnet I think there is no reason to add a delay, but yeah I should bring these changes for helder testnet and it might be worth to add configurable delay between preconfs, with a 100ms default

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, should I do that for Helder or wait for #163 to be done?

Copy link
Collaborator

Choose a reason for hiding this comment

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

waiting is fine, it's not a priority

Comment on lines +123 to +127
// ParseConstraintsDecoded receives a map of constraints and
// - creates a slice of constraints sorted by index
// - creates a slice of constraints without index sorted by nonce and hash
// Returns the concatenation of the slices
func ParseConstraintsDecoded(constraints HashToConstraintDecoded) []*ConstraintDecoded {
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you add a test for this fn? either in the relay or mev-boost is fine

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done! Lmk if it's good enough

Copy link
Collaborator

Choose a reason for hiding this comment

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

beautiful!

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

Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between 9bf439c and c24d017.

Files selected for processing (1)
  • Justfile (1 hunks)
Additional comments not posted (1)
Justfile (1)

115-123: Good enhancement! Consider setting a default value for the count parameter.

The addition of the count parameter improves the flexibility of the command. To ensure clarity, consider setting a default value for the count parameter within the command itself.

- send-blob-preconf count='1':
+ send-blob-preconf count='1'='1':

Likely invalid or redundant comment.

Justfile 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 c24d017 and 880cc52.

Files selected for processing (1)
  • mev-boost/server/constraints_test.go (1 hunks)
Additional comments not posted (3)
mev-boost/server/constraints_test.go (3)

11-22: LGTM! Initialization of raw transaction data is clear and well-documented.

The raw transaction data is correctly initialized and documented with comments.


26-44: LGTM! Decoding process and error handling are correct.

The decoding process uses hex.DecodeString and tx.UnmarshalBinary, followed by error handling with require.NoError. The logic for setting the index for the first two transactions is correct.


46-52: LGTM! Verification process is clear and correctly validates the expected values.

The verification process checks the nonce and hash values of the parsed constraints using require.Equal.

Copy link
Collaborator

@merklefruit merklefruit left a comment

Choose a reason for hiding this comment

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

looks gucci to me

Copy link
Contributor

@mempirate mempirate left a comment

Choose a reason for hiding this comment

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

LGTM!

@thedevbirb thedevbirb merged commit 6205121 into unstable Jul 25, 2024
2 checks passed
@thedevbirb thedevbirb deleted the chore/devnet/multiproofs-update branch July 25, 2024 07:56
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: 5

Outside diff range comments (1)
mev-boost-relay/services/api/proofs.go (1)

Line range hint 46-50:
Handle potential errors in HashTreeRoot.

The function should log the error with more context to aid debugging.

-    if err != nil {
-        return ErrInvalidRoot
-    }
+    if err != nil {
+        log.WithError(err).WithField("index", i).Error("error computing hash tree root")
+        return ErrInvalidRoot
+    }
Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between 880cc52 and fc92eca.

Files selected for processing (1)
  • mev-boost-relay/services/api/proofs.go (2 hunks)

Comment on lines +22 to +24
//
// NOTE: assumes constraints transactions are already without blobs
func verifyInclusionProof(log *logrus.Entry, transactionsRoot phase0.Root, proof *common.InclusionProof, hashToConstraints HashToConstraintDecoded) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Clarify the note about blobs.

The note about constraints transactions being without blobs should be clarified or moved to a more appropriate place in the documentation.

-// NOTE: assumes constraints transactions are already without blobs
+// NOTE: This function assumes that the constraints transactions are already without blobs.
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
//
// NOTE: assumes constraints transactions are already without blobs
func verifyInclusionProof(log *logrus.Entry, transactionsRoot phase0.Root, proof *common.InclusionProof, hashToConstraints HashToConstraintDecoded) error {
//
// NOTE: This function assumes that the constraints transactions are already without blobs.
func verifyInclusionProof(log *logrus.Entry, transactionsRoot phase0.Root, proof *common.InclusionProof, hashToConstraints HashToConstraintDecoded) error {

Comment on lines +33 to 35
for i, constraint := range constraints {
if constraint == nil {
return ErrNilConstraint
Copy link
Contributor

Choose a reason for hiding this comment

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

Handle potential nil constraints.

The loop checks for nil constraints, but it should log the error with more context to aid debugging.

-    if constraint == nil {
-        return ErrNilConstraint
-    }
+    if constraint == nil {
+        log.WithField("index", i).Error("nil constraint found")
+        return ErrNilConstraint
+    }
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
for i, constraint := range constraints {
if constraint == nil {
return ErrNilConstraint
for i, constraint := range constraints {
if constraint == nil {
log.WithField("index", i).Error("nil constraint found")
return ErrNilConstraint
}

Comment on lines +40 to 45
encoded, err := constraint.Tx.MarshalBinary()
if err != nil {
log.WithError(err).Error("error marshalling transaction without blob tx sidecar")
return err
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Improve error logging for marshalling transactions.

When logging errors, include the index of the constraint to provide more context.

-    log.WithError(err).Error("error marshalling transaction without blob tx sidecar")
+    log.WithError(err).WithField("index", i).Error("error marshalling transaction without blob tx sidecar")
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
encoded, err := constraint.Tx.MarshalBinary()
if err != nil {
log.WithError(err).Error("error marshalling transaction without blob tx sidecar")
return err
}
encoded, err := constraint.Tx.MarshalBinary()
if (err != nil) {
log.WithError(err).WithField("index", i).Error("error marshalling transaction without blob tx sidecar")
return err
}

func verifyInclusionProof(log *logrus.Entry, transactionsRoot phase0.Root, proof *common.InclusionProof, constraints map[phase0.Hash32]*Constraint) error {
//
// NOTE: assumes constraints transactions are already without blobs
func verifyInclusionProof(log *logrus.Entry, transactionsRoot phase0.Root, proof *common.InclusionProof, hashToConstraints HashToConstraintDecoded) error {
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 the function call to use hashToConstraints.

Ensure that all calls to verifyInclusionProof are updated to use the new hashToConstraints parameter instead of the old constraints parameter.

  • mev-boost/server/service.go
  • mev-boost-relay/services/api/service.go
Analysis chain

Update the function call to use hashToConstraints.

Ensure that all calls to verifyInclusionProof are updated to use the new hashToConstraints parameter instead of the old constraints parameter.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the updated `verifyInclusionProof` function.

# Test: Search for the function usage. Expect: Only occurances of the new signature.
rg --type go -A 5 $'verifyInclusionProof'

Length of output: 2270

Comment on lines +29 to +30
constraints := ParseConstraintsDecoded(hashToConstraints)

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

Ensure ParseConstraintsDecoded handles errors.

The function ParseConstraintsDecoded in mev-boost-relay/services/api/types.go does not handle any potential errors during parsing and sorting. Consider adding error handling to ensure robustness.

  • mev-boost-relay/services/api/types.go: ParseConstraintsDecoded
Analysis chain

Ensure ParseConstraintsDecoded handles errors.

The function ParseConstraintsDecoded should handle any potential errors during parsing. Verify its implementation to ensure robustness.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of `ParseConstraintsDecoded`.

# Test: Search for the implementation of `ParseConstraintsDecoded`. Expect: Proper error handling.
rg --type go 'func ParseConstraintsDecoded'

Length of output: 456


Script:

#!/bin/bash
# Extract the full implementation of `ParseConstraintsDecoded` from `mev-boost-relay/services/api/types.go`
rg --type go -A 20 'func ParseConstraintsDecoded' mev-boost-relay/services/api/types.go

Length of output: 1005


Script:

#!/bin/bash
# Extract the full implementation of `ParseConstraintsDecoded` from `mev-boost-relay/services/api/types.go`
rg --type go -A 50 'func ParseConstraintsDecoded' mev-boost-relay/services/api/types.go

Length of output: 1450

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A: devnet Area: devnet C: block-builder Component: block builder C: mev-boost Component: mev-boost C: mev-boost-relay Component: mev-boost-relay T: bug Type: Bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: merkle multiproof verification
3 participants