Skip to content

add ability to decode ecotone scalar values into components #10547

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

Merged

Conversation

roberto-bayardo
Copy link
Collaborator

Description

ecotone-scalar is a script that is used to compute the post-Ecotone "scalar" value from its components. This PR extends this script with the ability to do the opposite: take a post-Ecotone scalar and output its components.

Tests

Verified decoding of a previously encoded value produces the expected matching output:

> ./main --scalar 1101 --blob-scalar 659851
# base fee scalar     : 1101
# blob base fee scalar: 659851
# v1 hex encoding  : 0x010000000000000000000000000000000000000000000000000a118b0000044d
# uint value for the 'scalar' parameter in SystemConfigProxy.setGasConfig():
452312848583266388373324160190187140051835877600158453279134021569375896653

> ./main --decode 452312848583266388373324160190187140051835877600158453279134021569375896653
# base fee scalar     : 1101
# blob base fee scalar: 659851
# v1 hex encoding  : 0x010000000000000000000000000000000000000000000000000a118b0000044d
# uint value for the 'scalar' parameter in SystemConfigProxy.setGasConfig():
452312848583266388373324160190187140051835877600158453279134021569375896653

@roberto-bayardo roberto-bayardo requested a review from a team as a code owner May 15, 2024 00:51
@roberto-bayardo roberto-bayardo requested a review from ajsutton May 15, 2024 00:51
Copy link
Contributor

coderabbitai bot commented May 15, 2024

Walkthrough

Walkthrough

The recent updates introduce a new decode variable in the main function of main.go to handle decoding of uint256 post-ecotone scalar values. This allows the program to either decode the scalar value or encode it into a byte array based on the presence of the decode variable. Additionally, the error message in the DecodeScalar function within types.go has been refined to display the scalar value in hexadecimal format for better clarity.

Changes

File Path Change Summary
op-chain-ops/cmd/ecotone-scalar/main.go Added a decode variable to handle decoding of uint256 post-ecotone scalar values.
op-service/eth/types.go Modified the DecodeScalar function to print scalar values in hexadecimal format in errors.

Recent Review Details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits Files that changed from the base of the PR and between b123e13 and 3accc8f.
Files selected for processing (2)
  • op-chain-ops/cmd/ecotone-scalar/main.go (2 hunks)
  • op-service/eth/types.go (1 hunks)
Additional comments not posted (4)
op-chain-ops/cmd/ecotone-scalar/main.go (3)

16-16: The description for the decode flag is clear and concise. Ensure that the usage message is updated to reflect the new flag.


33-61: The decoding logic is well-implemented with appropriate error handling. Ensure that the eth.DecodeScalar function is thoroughly tested.


62-65: The encoding logic is consistent with the decoding logic. Ensure that both encoding and decoding functions are covered by unit tests.

op-service/eth/types.go (1)

428-428: Updating the error message to display the hexadecimal representation of the scalar value improves clarity. Ensure that this change is reflected in any related documentation or logs.


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.

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 a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

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

CodeRabbit Configration 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
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

Copy link
Contributor

@tynes tynes left a comment

Choose a reason for hiding this comment

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

Generally looks good to me, haven't tested it

@ajsutton ajsutton added this pull request to the merge queue May 16, 2024
Merged via the queue into ethereum-optimism:develop with commit c4b37bf May 16, 2024
roberto-bayardo pushed a commit that referenced this pull request May 16, 2024
ecotone-scalar was updated in #10547 to support value decoding but didn't include an update to this documentation.
github-merge-queue bot pushed a commit that referenced this pull request May 21, 2024
* Update README.md to describe new ecotone-scalar decode flag

ecotone-scalar was updated in #10547 to support value decoding but didn't include an update to this documentation.

* allow non-decimal scalar values to decode
rdovgan pushed a commit to rdovgan/optimism that referenced this pull request Jun 24, 2024
…-optimism#10565)

* Update README.md to describe new ecotone-scalar decode flag

ecotone-scalar was updated in ethereum-optimism#10547 to support value decoding but didn't include an update to this documentation.

* allow non-decimal scalar values to decode
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.

3 participants