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

add tx decoder #2415

Merged
merged 5 commits into from
Apr 3, 2024
Merged

add tx decoder #2415

merged 5 commits into from
Apr 3, 2024

Conversation

trajan0x
Copy link
Contributor

@trajan0x trajan0x commented Apr 1, 2024

Description

Adds tx decoder

Summary by CodeRabbit

  • New Features
    • Improved transaction decoding tool to display transaction details like type, gas, value, and nonce in a user-friendly format.

Copy link
Contributor

coderabbitai bot commented Apr 1, 2024

Warning

Rate Limit Exceeded

@trajan0x has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 7 minutes and 28 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.
Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.
Please see our FAQ for further information.

Commits Files that changed from the base of the PR and between 4ecb8dc and 86d197b.

Walkthrough

The update introduces a script named txdecoder.sh, designed to decode Ethereum transaction hashes. It leverages cast dt for decoding and jq for presenting the transaction data in a readable format. Additionally, it extracts and processes key transaction details such as type, gas, value, nonce, and fees, converting some values for enhanced clarity.

Changes

File Change Summary
contrib/scripts/txdecoder.sh New script for decoding transaction hashes, formatting output, and extracting specific transaction details.

🐇✨
In the realm of code, a script was born,
To decode the hashes, with ease it's sworn.
From chaos to clarity, it brings light,
Unraveling data, making the complex bright.
A rabbit's touch, so deft and keen—
In strings of code, magic is seen.
🌟🌿

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/coderabbit-overrides.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: 2

Review Status

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between 4fbad16 and 9dfd33c.
Files selected for processing (1)
  • contrib/scripts/txdecoder.sh (1 hunks)
Additional Context Used
Additional comments not posted (1)
contrib/scripts/txdecoder.sh (1)

22-22: The conversion for the type field using cast --to-dec might not be appropriate, as type is typically not a numeric value that requires decimal conversion. It's important to ensure that the conversion logic aligns with the expected data types and formats of the transaction fields.

Consider reviewing the conversion logic for the type field to ensure it's meaningful and relevant.

Comment on lines 22 to 27
echo "Type: $(cast --to-dec $type)" # This specific conversion might not make sense for 'type', as it's not a value field.
echo "Gas: $(cast --to-dec $gas)"
echo "Value: $(cast --to-unit $value ether)"
echo "Nonce: $(cast --to-dec $nonce)"
echo "MaxPriorityFeePerGas: $(cast --to-unit $maxPriorityFeePerGas gwei)"
echo "MaxFeePerGas: $(cast --to-unit $maxFeePerGas gwei)"
Copy link
Contributor

Choose a reason for hiding this comment

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

To ensure the script's stability and prevent potential issues with globbing and word splitting, it's advisable to double-quote variables in all command substitutions.

- echo "Type: $(cast --to-dec $type)"
- echo "Gas: $(cast --to-dec $gas)"
- echo "Value: $(cast --to-unit $value ether)"
- echo "Nonce: $(cast --to-dec $nonce)"
- echo "MaxPriorityFeePerGas: $(cast --to-unit $maxPriorityFeePerGas gwei)"
- echo "MaxFeePerGas: $(cast --to-unit $maxFeePerGas gwei)"
+ echo "Type: $(cast --to-dec "$type")"
+ echo "Gas: $(cast --to-dec "$gas")"
+ echo "Value: $(cast --to-unit "$value" ether)"
+ echo "Nonce: $(cast --to-dec "$nonce")"
+ echo "MaxPriorityFeePerGas: $(cast --to-unit "$maxPriorityFeePerGas" gwei)"
+ echo "MaxFeePerGas: $(cast --to-unit "$maxFeePerGas" gwei)"

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.

Suggested change
echo "Type: $(cast --to-dec $type)" # This specific conversion might not make sense for 'type', as it's not a value field.
echo "Gas: $(cast --to-dec $gas)"
echo "Value: $(cast --to-unit $value ether)"
echo "Nonce: $(cast --to-dec $nonce)"
echo "MaxPriorityFeePerGas: $(cast --to-unit $maxPriorityFeePerGas gwei)"
echo "MaxFeePerGas: $(cast --to-unit $maxFeePerGas gwei)"
echo "Type: $(cast --to-dec "$type")" # This specific conversion might not make sense for 'type', as it's not a value field.
echo "Gas: $(cast --to-dec "$gas")"
echo "Value: $(cast --to-unit "$value" ether)"
echo "Nonce: $(cast --to-dec "$nonce")"
echo "MaxPriorityFeePerGas: $(cast --to-unit "$maxPriorityFeePerGas" gwei)"
echo "MaxFeePerGas: $(cast --to-unit "$maxFeePerGas" gwei)"

Copy link

cloudflare-workers-and-pages bot commented Apr 1, 2024

Deploying sanguine-fe with  Cloudflare Pages  Cloudflare Pages

Latest commit: 86d197b
Status:🚫  Build failed.

View logs

@trajan0x trajan0x marked this pull request as draft April 2, 2024 21:41
@github-actions github-actions bot added the M-ci Module: CI label Apr 3, 2024
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

Review Status

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between 9dfd33c and 4ecb8dc.
Files selected for processing (1)
  • contrib/scripts/txdecoder.sh (1 hunks)

rawTx=$1

# Decode the transaction using cast dt and store the result in a variable
decodedTx=$(cast dt $rawTx)
Copy link
Contributor

Choose a reason for hiding this comment

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

To prevent globbing and word splitting, double-quote variables in command substitutions.

- decodedTx=$(cast dt $rawTx)
+ decodedTx=$(cast dt "$rawTx")

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.

Suggested change
decodedTx=$(cast dt $rawTx)
decodedTx=$(cast dt "$rawTx")

type=$(echo "$decodedTx" | jq -r '.type')

# Convert the type from hexadecimal to decimal
txType=$(cast --to-dec $type)
Copy link
Contributor

Choose a reason for hiding this comment

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

Double-quote variables to prevent globbing and word splitting.

- txType=$(cast --to-dec $type)
+ txType=$(cast --to-dec "$type")

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.

Suggested change
txType=$(cast --to-dec $type)
txType=$(cast --to-dec "$type")

Comment on lines +25 to +27
echo "Gas: $(cast --to-dec $gas)"
echo "Value: $(cast --to-unit $value ether)"
echo "Nonce: $(cast --to-dec $nonce)"
Copy link
Contributor

Choose a reason for hiding this comment

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

Ensure variables are double-quoted in command substitutions to prevent globbing and word splitting.

- echo "Gas: $(cast --to-dec $gas)"
- echo "Value: $(cast --to-unit $value ether)"
- echo "Nonce: $(cast --to-dec $nonce)"
+ echo "Gas: $(cast --to-dec "$gas")"
+ echo "Value: $(cast --to-unit "$value" ether)"
+ echo "Nonce: $(cast --to-dec "$nonce")"

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.

Suggested change
echo "Gas: $(cast --to-dec $gas)"
echo "Value: $(cast --to-unit $value ether)"
echo "Nonce: $(cast --to-dec $nonce)"
echo "Gas: $(cast --to-dec "$gas")"
echo "Value: $(cast --to-unit "$value" ether)"
echo "Nonce: $(cast --to-dec "$nonce")"

if [[ "$txType" == "0" ]]; then
# Transaction type 0 specific field
gasPrice=$(echo "$decodedTx" | jq -r '.gasPrice')
echo "GasPrice: $(cast --to-unit $gasPrice gwei)"
Copy link
Contributor

Choose a reason for hiding this comment

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

Double-quote variables in command substitutions to avoid globbing and word splitting.

- echo "GasPrice: $(cast --to-unit $gasPrice gwei)"
+ echo "GasPrice: $(cast --to-unit "$gasPrice" gwei)"

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.

Suggested change
echo "GasPrice: $(cast --to-unit $gasPrice gwei)"
echo "GasPrice: $(cast --to-unit "$gasPrice" gwei)"

Comment on lines +38 to +39
echo "MaxPriorityFeePerGas: $(cast --to-unit $maxPriorityFeePerGas gwei)"
echo "MaxFeePerGas: $(cast --to-unit $maxFeePerGas gwei)"
Copy link
Contributor

Choose a reason for hiding this comment

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

Prevent globbing and word splitting by double-quoting variables in command substitutions.

- echo "MaxPriorityFeePerGas: $(cast --to-unit $maxPriorityFeePerGas gwei)"
- echo "MaxFeePerGas: $(cast --to-unit $maxFeePerGas gwei)"
+ echo "MaxPriorityFeePerGas: $(cast --to-unit "$maxPriorityFeePerGas" gwei)"
+ echo "MaxFeePerGas: $(cast --to-unit "$maxFeePerGas" gwei)"

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.

Suggested change
echo "MaxPriorityFeePerGas: $(cast --to-unit $maxPriorityFeePerGas gwei)"
echo "MaxFeePerGas: $(cast --to-unit $maxFeePerGas gwei)"
echo "MaxPriorityFeePerGas: $(cast --to-unit "$maxPriorityFeePerGas" gwei)"
echo "MaxFeePerGas: $(cast --to-unit "$maxFeePerGas" gwei)"

@trajan0x trajan0x marked this pull request as ready for review April 3, 2024 05:03
@trajan0x trajan0x merged commit 690c538 into master Apr 3, 2024
26 of 27 checks passed
@trajan0x trajan0x deleted the fix/aurelius-decoder branch April 3, 2024 05:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
M-ci Module: CI size/xs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants