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

Testnet release #414

Merged
merged 4 commits into from
Aug 14, 2024
Merged

Testnet release #414

merged 4 commits into from
Aug 14, 2024

Conversation

devbugging
Copy link
Contributor

@devbugging devbugging commented Aug 1, 2024

DO NOT MERGE

This branch prepares the codebase for test net launch.

Most importantly it removes all the code that was used to handle breaking changes on previewnet.

This branch should be only merged when we create a special branch for preivewnet, this will be done at the time of testnet launch.

Summary by CodeRabbit

  • New Features

    • Streamlined handling of block and receipt data, enhancing clarity and reliability.
    • Improved error handling for decoding transactions and receipts, providing more informative messages.
  • Bug Fixes

    • Removed legacy code that could cause inconsistencies in block and transaction processing.
  • Documentation

    • Enhanced readability and organization of configuration setups in tests.
  • Refactor

    • Simplified the structure of various models and APIs, removing unnecessary fields and methods for a cleaner implementation.

@devbugging devbugging self-assigned this Aug 1, 2024
Copy link
Contributor

coderabbitai bot commented Aug 1, 2024

Walkthrough

The recent changes across the codebase focus on streamlining blockchain management, simplifying configuration handling, and enhancing error reporting. Temporary structures and legacy code have been removed, indicating a shift towards a more stable implementation. Key modifications include the elimination of outdated block version handling and adjustments in transaction unmarshalling, all aimed at improving code clarity and reliability while ensuring a more robust blockchain API.

Changes

Files Change Summary
api/api.go Modified block handling logic in GetBlockByNumber and removed timestamp fixes from prepareBlockResponse, simplifying data preparation and improving clarity.
bootstrap/bootstrap.go Removed temporary assignment of DirectCallHashCalculationBlockHeightChange, indicating a change in variable management.
config/config.go Removed HashCalculationHeightChange field and its command-line flag, streamlining configuration.
models/block.go Eliminated multiple block versions and outdated decoding logic, removed Hash method, revised constants, simplifying block management and error handling.
models/receipt.go Removed StorageReceiptV0 struct and its conversion method, reflecting a design shift and streamlining code.
models/transaction.go Simplified DirectCall by removing blockHeight, adjusting hashing logic, and updating unmarshalling functions for cleaner implementation.
models/transaction_test.go Updated tests to reflect changes in UnmarshalTransaction, removing complex scenarios related to DirectCallHashCalculationBlockHeightChange.
storage/pebble/receipts.go Streamlined receipt decoding logic and improved error handling, removing outdated code related to older receipt formats.
storage/pebble/transactions.go Removed logic fetching EVM height in transaction retrieval, simplifying unmarshalling behavior.
tests/helpers.go Reformatted configuration struct for improved readability without altering functionality.
tests/web3js/eth_non_interactive_test.js Removed timestamp assertion in tests, indicating a change in validation logic for block properties.

Sequence Diagram(s)

sequenceDiagram
    participant API
    participant Block
    participant Transaction

    API->>Block: Request Block Data
    Block-->>API: Return Block Data
    API->>Transaction: Unmarshal Transaction
    Transaction-->>API: Return Unmarshalled Transaction
    API-->>Client: Send Response
Loading

🐇 "In the meadow where code does play,
Changes hop along, brightening the day.
With legacy structures now out of sight,
The path ahead feels wonderfully right!
Simplifications bloom, errors take flight,
In this code garden, all feels just right!"
🌼✨

Warning

Review ran into problems

Problems (1)
  • Git: Failed to clone repository. Please contact CodeRabbit support.

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.

# Conflicts:
#	config/config.go
#	tests/helpers.go
#	tests/web3js/eth_logs_filtering_test.js
# Conflicts:
#	config/config.go
@devbugging devbugging marked this pull request as ready for review August 14, 2024 15:11
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: CHILL

Commits

Files that changed from the base of the PR and between da8fc09 and d003e8a.

Files selected for processing (11)
  • api/api.go (2 hunks)
  • bootstrap/bootstrap.go (1 hunks)
  • config/config.go (2 hunks)
  • models/block.go (3 hunks)
  • models/receipt.go (1 hunks)
  • models/transaction.go (3 hunks)
  • models/transaction_test.go (3 hunks)
  • storage/pebble/receipts.go (3 hunks)
  • storage/pebble/transactions.go (2 hunks)
  • tests/helpers.go (1 hunks)
  • tests/web3js/eth_non_interactive_test.js (1 hunks)
Files skipped from review due to trivial changes (4)
  • bootstrap/bootstrap.go
  • config/config.go
  • models/receipt.go
  • tests/helpers.go
Additional comments not posted (13)
storage/pebble/transactions.go (1)

50-50: Verify the impact of removing EVM height retrieval.

The removal of EVM height retrieval in the Get method simplifies the code but may affect areas where EVM height was used. Ensure that this change does not impact the functionality that depends on EVM height.

Verification successful

No Impact from Removing EVM Height Retrieval in Get Method

The removal of EVM height retrieval from the Get method in storage/pebble/transactions.go does not impact other parts of the codebase. The search did not reveal any dependencies on EVM height related to this method.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the impact of removing EVM height retrieval in the `Get` method.

# Test: Search for usage of the `Get` method to identify dependencies on EVM height.
rg --type go -A 5 $'Get('

Length of output: 85


Script:

#!/bin/bash
# Description: Verify the impact of removing EVM height retrieval in the `Get` method.

# Corrected Test: Search for usage of the `Get` method to identify dependencies on EVM height.
rg --type go -A 5 'Get('

Length of output: 85


Script:

#!/bin/bash
# Description: Verify the impact of removing EVM height retrieval in the `Get` method.

# Corrected Test: Search for usage of the `Get` method to identify dependencies on EVM height.
rg --type go -A 5 'Get'

Length of output: 94041

models/block.go (2)

31-31: Verify the new error handling in NewBlockFromBytes.

The error handling in NewBlockFromBytes has been simplified. Ensure that this change does not affect areas that relied on the previous fallback mechanism for decoding.


16-17: Verify the impact of removing block number constants.

The removal of SafeBlockNumber, FinalizedBlockNumber, and PendingBlockNumber simplifies the model but may affect code that relies on these constants. Ensure that this change does not impact functionality.

storage/pebble/receipts.go (2)

205-205: Confirm improved error handling in BloomsForBlockRange.

The error handling in BloomsForBlockRange has been improved. Confirm that this change provides clearer error messages without affecting functionality.


129-130: ```shell
#!/bin/bash

Description: Correctly search for usage of getByBlockHeight to identify dependencies on legacy receipt handling.

Test: Search for usage of getByBlockHeight with corrected regex syntax.

rg --type go -A 5 'getByBlockHeight('


</blockquote></details>
<details>
<summary>models/transaction.go (3)</summary><blockquote>

Line range hint `45-46`: **Simplification of `DirectCall` struct.**

The removal of the `blockHeight` field from the `DirectCall` struct simplifies the structure and reduces complexity. Ensure that any dependent logic is correctly updated.

---

Line range hint `74-76`: **Streamlined `Hash` method.**

The `Hash` method now directly relies on `DirectCall.Hash()`, removing conditional logic. This change simplifies the hashing logic and aligns with the overall goal of reducing complexity.

---

`226-233`: **Updated `UnmarshalTransaction` function signature.**

The removal of the `blockHeight` parameter simplifies the function's signature and logic. Ensure that all calls to this function are updated to reflect the new signature.

<details>
<summary>Verification successful</summary>



---

<!-- [monologue]
[task review_file_1/1 function 1/1]
[observations] The `ast-grep` results show the definition of `UnmarshalTransaction` in `models/transaction.go` with the updated signature. Calls to this function are found in `models/transaction_test.go`, both using the new signature without the `blockHeight` parameter.
[analysis] The function `UnmarshalTransaction` has been correctly updated, and all identified calls to it in the test file reflect the new signature. This aligns with the review comment's requirement to ensure all calls are updated.
[actions] Since the function and its calls are consistent with the new signature, I will mark this verification as successful.
-->

**All calls to `UnmarshalTransaction` are updated to the new signature.** The function definition and all identified calls in the codebase reflect the updated signature without the `blockHeight` parameter. No further action is needed. 

</details>


<details>
<summary>Scripts executed</summary>

The following scripts were executed for the analysis:

Script:

```shell
#!/bin/bash
# Description: Verify all calls to `UnmarshalTransaction` are updated to reflect the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type go -A 3 $'UnmarshalTransaction('

Length of output: 136


Script:

#!/bin/bash
# Description: Verify the function definition and all calls to `UnmarshalTransaction` are updated to reflect the new signature.

# Search for the function definition of `UnmarshalTransaction`
ast-grep --lang go --pattern 'func UnmarshalTransaction($_) ($_, error) { $$$ }'

# Search for all calls to `UnmarshalTransaction`
ast-grep --lang go --pattern 'UnmarshalTransaction($_)'

Length of output: 1280

tests/web3js/eth_non_interactive_test.js (1)

Line range hint 29-29: Removal of timestamp assertion.

The removal of the assertion checking the block's timestamp suggests a change in the testing strategy or expectations. Verify that this aligns with the intended behavior of the system.

models/transaction_test.go (2)

188-188: Updated UnmarshalTransaction test cases.

The test cases for UnmarshalTransaction have been updated to reflect the new function signature without the blockHeight argument. Ensure that the test coverage remains comprehensive.

#!/bin/bash
# Description: Verify test coverage for `UnmarshalTransaction` without `blockHeight`.

# Test: Check for test cases that cover various scenarios for `UnmarshalTransaction`.
rg --type go 'Test_UnmarshalTransaction' -A 10

242-242: Ensure comprehensive testing for DirectCall.

The test case for DirectCall in UnmarshalTransaction has been updated. Verify that all relevant scenarios are still covered.

#!/bin/bash
# Description: Verify comprehensive testing for `DirectCall` in `UnmarshalTransaction`.

# Test: Check for test cases that cover `DirectCall` scenarios in `UnmarshalTransaction`.
rg --type go 'Test_UnmarshalTransaction' -A 20
api/api.go (2)

Line range hint 223-235:
Comment removal approved.

The removal of the comment related to the PreviewNet workaround is appropriate, given the PR's objective of cleaning up previewnet-related code.


Line range hint 400-414:
Timestamp handling changes approved.

The removal of the temporary timestamp fix suggests a transition to a more stable mechanism, aligning with the PR's objectives.

Ensure that the new timestamp handling mechanism is correctly implemented and tested.

Copy link
Collaborator

@m-Peter m-Peter left a comment

Choose a reason for hiding this comment

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

Nice cleanup 💯💯

@devbugging devbugging merged commit 29a3b57 into main Aug 14, 2024
2 checks passed
@m-Peter m-Peter deleted the testnet branch August 22, 2024 08:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

2 participants