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

Upgrade Go-Ethereum to v1.11.6 #1865

Merged
merged 6 commits into from
Jan 14, 2024
Merged

Upgrade Go-Ethereum to v1.11.6 #1865

merged 6 commits into from
Jan 14, 2024

Conversation

trajan0x
Copy link
Contributor

@trajan0x trajan0x commented Jan 14, 2024

Description

Upgrade part 2 (in pursuit of #1767)

Summary by CodeRabbit

  • New Features

    • Enhanced the blockchain configuration for newer hardfork standards.
    • Improved simulated backend with additional parameters for more precise testing scenarios.
  • Bug Fixes

    • Fixed issues with incorrect method calls and parameter types in testing suites.
    • Updated transaction handling logic for better signer recovery.
  • Refactor

    • Streamlined gas pricing methods to align with updated blockchain configurations.
  • Documentation

    • No user-facing documentation changes noted.
  • Style

    • No user-facing style changes noted.
  • Tests

    • Altered test backends to reflect new return values and parameter requirements.
  • Chores

    • Updated internal utility functions to work with new data structures.
  • Revert

    • No reverts applicable to end-user functionality.

Copy link
Contributor

coderabbitai bot commented Jan 14, 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 2 minutes and 36 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 266b11a and 512c648.

Walkthrough

The recent changes across various files seem to focus on updating the handling of Ethereum Improvement Proposals (EIPs), particularly the removal of EIP150Hash references and adjustments to accommodate new parameters in simulated backends. There's also a shift from using interfaces to pointers for transactions, changes in the test suite to reflect updates in numerical types, and an enhancement in the transaction recovery process.

Changes

File Path Change Summary
ethergo/backends/anvil/hardfork.go
ethergo/chain/client/config.go
Removed references to EIP150Hash for certain hardforks and in config assignments.
ethergo/backends/simulated/multibackend/chainid.go
ethergo/deployer/deployed_contract.go
ethergo/util/converter.go
Removed EIP150Hash parameter, updated methods to use non-interface types (msg.From() to msg.From, etc.).
ethergo/backends/simulated/multibackend/simulated_gen.go
ethergo/backends/simulated/multibackend/simulated_gen_test.go
Added parameters to methods, updated numerical method calls (NumberU64() to Number.Uint64()).
ethergo/chain/gas/londinium/config_test.go
ethergo/chain/gas/londinium/gasprice_test.go
Changed type from int to uint64 for history fields, modified methods to use different functions.
ethergo/chain/gas/london/oracle_backend.go Included block.BaseFee() in method arguments.
ethergo/submitter/db/txdb/store.go Enhanced transaction recovery logic by using a new types.Transaction to recover signer.

Poem

🐇 "In the realm of code, changes abound,
🌿 EIPs refined, and types unwound.
🛠️ From interfaces to pointers, we leap,
🎉 A rabbit's cheer, for code so sleek!"

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-tests for this file.
  • 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 tests 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 from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @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.
  • The JSON schema for the configuration file is available here.
  • 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

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

@github-actions github-actions bot added go Pull requests that update Go code size/m labels Jan 14, 2024
Copy link

codecov bot commented Jan 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (70296e8) 51.62991% compared to head (512c648) 51.77254%.

Additional details and impacted files
@@                 Coverage Diff                 @@
##              master       #1865         +/-   ##
===================================================
+ Coverage   51.62991%   51.77254%   +0.14262%     
===================================================
  Files            409         409                 
  Lines          28069       28067          -2     
  Branches         307         307                 
===================================================
+ Hits           14492       14531         +39     
+ Misses         12159       12125         -34     
+ Partials        1418        1411          -7     
Flag Coverage Δ
agents 47.65491% <ø> (+0.20541%) ⬆️
cctp-relayer 63.00863% <ø> (ø)
core 65.34532% <ø> (+1.02165%) ⬆️
ethergo 60.88010% <100.00000%> (+0.04133%) ⬆️
explorer 24.80881% <ø> (ø)
git-changes-action 53.94265% <ø> (ø)
omnirpc 53.23194% <ø> (+0.07605%) ⬆️
promexporter 74.80916% <ø> (ø)
release-copier-action 19.33333% <ø> (ø)
rfq 40.54291% <ø> (ø)
scribe 52.21130% <ø> (ø)
sinner 64.60481% <ø> (ø)
terraform-provider-helmproxy 16.98113% <ø> (ø)
terraform-provider-kubeproxy 22.83737% <ø> (ø)
tools 21.98661% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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.

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 70296e8 and 36cc617.
Files ignored due to path filters (23)
  • agents/go.mod is excluded by: !**/*.mod
  • agents/go.sum is excluded by: !**/*.sum
  • contrib/git-changes-action/go.sum is excluded by: !**/*.sum
  • contrib/promexporter/go.mod is excluded by: !**/*.mod
  • contrib/promexporter/go.sum is excluded by: !**/*.sum
  • contrib/terraform-provider-helmproxy/go.sum is excluded by: !**/*.sum
  • contrib/terraform-provider-kubeproxy/go.sum is excluded by: !**/*.sum
  • ethergo/go.mod is excluded by: !**/*.mod
  • ethergo/go.sum is excluded by: !**/*.sum
  • go.work.sum is excluded by: !**/*.sum
  • services/cctp-relayer/go.mod is excluded by: !**/*.mod
  • services/cctp-relayer/go.sum is excluded by: !**/*.sum
  • services/explorer/go.mod is excluded by: !**/*.mod
  • services/explorer/go.sum is excluded by: !**/*.sum
  • services/omnirpc/go.mod is excluded by: !**/*.mod
  • services/omnirpc/go.sum is excluded by: !**/*.sum
  • services/rfq/go.mod is excluded by: !**/*.mod
  • services/rfq/go.sum is excluded by: !**/*.sum
  • services/scribe/go.mod is excluded by: !**/*.mod
  • services/scribe/go.sum is excluded by: !**/*.sum
  • services/sinner/go.mod is excluded by: !**/*.mod
  • services/sinner/go.sum is excluded by: !**/*.sum
  • tools/go.sum is excluded by: !**/*.sum
Files selected for processing (11)
  • ethergo/backends/anvil/hardfork.go (1 hunks)
  • ethergo/backends/simulated/multibackend/chainid.go (2 hunks)
  • ethergo/backends/simulated/multibackend/simulated_gen.go (11 hunks)
  • ethergo/backends/simulated/multibackend/simulated_gen_test.go (3 hunks)
  • ethergo/chain/client/config.go (2 hunks)
  • ethergo/chain/gas/londinium/config_test.go (1 hunks)
  • ethergo/chain/gas/londinium/gasprice_test.go (1 hunks)
  • ethergo/chain/gas/london/oracle_backend.go (1 hunks)
  • ethergo/deployer/deployed_contract.go (2 hunks)
  • ethergo/submitter/db/txdb/store.go (1 hunks)
  • ethergo/util/converter.go (2 hunks)
Files skipped from review due to trivial changes (1)
  • ethergo/chain/client/config.go
Additional comments: 14
ethergo/util/converter.go (1)
  • 11-18: The TxToCall function has been updated to accept a pointer to types.Transaction instead of the Transaction interface. This change is consistent with the PR objectives and the AI-generated summary. The update from rawMsg.From() to rawMsg.From is also in line with the changes in the Ethereum library, where From is now a field rather than a method. The removal of the Transaction interface and its methods is not shown in the diff, but it is mentioned in the summary and is a logical simplification if the interface is no longer needed.
ethergo/chain/gas/londinium/config_test.go (1)
  • 17-18: The change from int to uint64 for MaxHeaderHistory and MaxBlockHistory in the TestLondoniumConfig function is consistent with the PR objectives to update types for gas pricing configuration. This change likely reflects a necessary update to align with the newer version of Go-Ethereum where these fields are expected to be uint64.
ethergo/deployer/deployed_contract.go (2)
  • 6-6: The addition of the ethCore package import is consistent with the changes in the NewDeployedContract function, where ethCore.TransactionToMessage is used.

  • 41-41: The change from msg.From() to msg.From is consistent with the updates in the Ethereum library, where From is now a field rather than a method. This change is necessary to align with the updated method signatures in the Go-Ethereum library.

ethergo/chain/gas/london/oracle_backend.go (1)
  • 67-67: The addition of block.BaseFee() as an argument to the DeriveFields function call in the GetReceipts method is consistent with the PR objectives to align with updated Ethereum protocol specifications, specifically the inclusion of the base fee in the derivation of receipt fields.
ethergo/backends/simulated/multibackend/chainid.go (1)
  • 64-64: The change in the NewSimulatedBackendWithConfig function to use blockchain.GetBlock instead of blockchain.CurrentBlock for the rollback method call is not explicitly mentioned in the PR objectives or the AI-generated summary. However, this change seems to be a logical update to ensure that the correct block is used for rollback operations, potentially improving the accuracy of the simulated backend.
ethergo/chain/gas/londinium/gasprice_test.go (2)
  • 45-45: The change in the HeaderByNumber method to return b.chain.CurrentBlock() directly is a simplification that removes unnecessary indirection. This change is not explicitly mentioned in the PR objectives or the AI-generated summary, but it seems to be a minor refactor for clarity.

  • 52-52: The change in the BlockByNumber method to use b.chain.GetBlockByHash(b.chain.CurrentBlock().Hash()) instead of directly returning b.chain.CurrentBlock() is not explicitly mentioned in the PR objectives or the AI-generated summary. This change seems to ensure that the method returns a block by its hash, which could be a necessary update for internal consistency within the test backend.

ethergo/submitter/db/txdb/store.go (1)
  • 264-267: The logic for handling transactions has been updated to unmarshal a new types.Transaction object and recover the signer from the transaction. This change is consistent with the PR objectives to improve transaction handling. The use of util.TxToCall to recover the signer suggests a more robust approach to transaction processing.
ethergo/backends/simulated/multibackend/simulated_gen.go (1)
  • 610-610: The callContract method has been updated to accept a header *types.Header instead of a block *types.Block. This change aligns with the PR objectives to enhance backend simulation capabilities. Ensure that all calls to this method have been updated accordingly.
ethergo/backends/simulated/multibackend/simulated_gen_test.go (4)
  • 1194-1194: The test TestFork is checking the chain length after a reorg, which is a valid test case. However, the actual implementation of the test is not visible in the provided code. Ensure that the logic within the test correctly handles the reorg scenario as described in the comments.

  • 1204-1204: Similar to the previous comment, the test TestFork is mentioned, but the implementation details are not provided. Ensure that the test logic is correctly implemented to validate the chain length after a reorg.

  • 1349-1349: The comment at line 1349 indicates the start of a test case TestCommitReturnValue. The test seems to be checking the return value of the Commit function. Ensure that the test case includes assertions to validate that the Commit function returns the correct block hash after a new block is committed to the blockchain.

  • 1191-1197: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [1194-1204]

The tests TestFork, TestForkLogsReborn, TestForkResendTx, TestCommitReturnValue, and TestAdjustTimeAfterFork are all crucial for ensuring the correctness of the simulated backend after a fork. It is important to verify that these tests cover all edge cases and that the assertions within these tests are robust enough to catch any potential issues with the backend's behavior after a fork.

Also applies to: 1349-1349

Comment on lines +143 to +146
header := b.blockchain.CurrentBlock()
block := b.blockchain.GetBlock(header.Hash(), header.Number.Uint64())

b.rollback(block)
Copy link
Contributor

Choose a reason for hiding this comment

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

The Rollback method now takes additional parameters header *types.Header and block *types.Block, but the implementation still uses the current block from the blockchain. This change is inconsistent with the method signature and should be corrected to use the passed-in parameters.

func (b *SimulatedBackend) Rollback(header *types.Header, block *types.Block) {
	b.mu.Lock()
	defer b.mu.Unlock()

-	header := b.blockchain.CurrentBlock()
-	block := b.blockchain.GetBlock(header.Hash(), header.Number.Uint64())

	b.rollback(block)
}

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
header := b.blockchain.CurrentBlock()
block := b.blockchain.GetBlock(header.Hash(), header.Number.Uint64())
b.rollback(block)
func (b *SimulatedBackend) Rollback(header *types.Header, block *types.Block) {
b.mu.Lock()
defer b.mu.Unlock()
b.rollback(block)
}

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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 36cc617 and 910de8f.
Files selected for processing (3)
  • services/scribe/api/data_test.go (2 hunks)
  • services/scribe/graphql/server/graph/queries.resolvers.go (2 hunks)
  • services/scribe/graphql/server/graph/utils.go (2 hunks)
Additional comments: 7
services/scribe/graphql/server/graph/utils.go (2)
  • 6-6: The import of ethCore from github.com/ethereum/go-ethereum/core is correctly added to support the new usage of TransactionToMessage.

  • 85-86: The change from ethTx.Tx.AsMessage to ethCore.TransactionToMessage is consistent with the upgrade to Go-Ethereum v1.11.6, which likely deprecated the old method in favor of the new one. Ensure that the rest of the codebase has been updated to reflect this change where necessary.

Verification successful

The search for the TransactionToMessage method usage within Go files has yielded several results, indicating that the new method has been adopted in various parts of the codebase. This confirms that the transition from the old Tx.AsMessage method to the new TransactionToMessage method has been implemented in multiple locations.

Given this information, it appears that the change from ethTx.Tx.AsMessage to ethCore.TransactionToMessage has been successfully applied where necessary in the codebase, in line with the upgrade to Go-Ethereum v1.11.6.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for the old `AsMessage` method usage to ensure it's been replaced everywhere.
rg --type go 'Tx.AsMessage'

Length of output: 27



Script:

#!/bin/bash
# Search for the new `TransactionToMessage` method usage to confirm its adoption in the codebase.
rg --type go 'TransactionToMessage'

Length of output: 815

services/scribe/graphql/server/graph/queries.resolvers.go (3)
  • 10-10: The import of ethCore from github.com/ethereum/go-ethereum/core is correctly added to support the new usage of TransactionToMessage.

  • 178-178: The change from Tx.AsMessage to ethCore.TransactionToMessage is consistent with the upgrade to Go-Ethereum v1.11.6. Ensure that the rest of the codebase has been updated to reflect this change where necessary.

Verification successful

The search for the new ethCore.TransactionToMessage method usage has yielded several results, indicating that this method is indeed being used in various parts of the codebase. This confirms that the change from Tx.AsMessage to ethCore.TransactionToMessage has been adopted in multiple files, which is consistent with the upgrade to Go-Ethereum v1.11.6 as mentioned in the review comment.

Given this information, the review comment suggesting to ensure that the rest of the codebase has been updated to reflect this change where necessary is consistent with the findings from the executed scripts.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for the old `AsMessage` method usage to ensure it's been replaced everywhere.
rg --type go 'Tx.AsMessage'

Length of output: 27



Script:

#!/bin/bash
# Search for the new `TransactionToMessage` method usage to confirm it has been adopted.
rg --type go 'ethCore.TransactionToMessage'

Length of output: 823

* 183-183: The update from `msgFrom.From().String()` to `msgFrom.From.String()` is a minor change that reflects a change in the API. This should be correct assuming the `TransactionToMessage` now returns a `Message` struct with a direct `From` field instead of a method.
services/scribe/api/data_test.go (2)
  • 6-6: The import of ethCore from github.com/ethereum/go-ethereum/core is correctly added to support the new usage of TransactionToMessage in tests.

  • 178-179: The change from tx.AsMessage to ethCore.TransactionToMessage in the TestTransactionDataEquality function is consistent with the upgrade to Go-Ethereum v1.11.6. This change should be reflected in all tests that previously used the old method.

Verification successful

The shell script executed a broader search for the .AsMessage method usage in Go test files and did not produce any output. This indicates that there are no instances of .AsMessage being used in the test files, which supports the review comment that the method has been replaced consistently with ethCore.TransactionToMessage in the context of the upgrade to Go-Ethereum v1.11.6.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for the old `AsMessage` method usage in tests to ensure it's been replaced everywhere.
rg --type go 'Tx.AsMessage' --glob '*_test.go'

Length of output: 46



Script:

#!/bin/bash
# Broaden the search for the `AsMessage` method usage in tests to ensure it's been replaced everywhere.
rg --type go '\.AsMessage' --glob '*_test.go'

Length of output: 47

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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 910de8f and 69316f4.
Files selected for processing (1)
  • ethergo/submitter/db_test.go (1 hunks)
Additional comments: 1
ethergo/submitter/db_test.go (1)
  • 102-102: The util.TxToCall function has been updated to accept tx.Transaction instead of just tx. Ensure that all calls to util.TxToCall throughout the codebase have been updated to match the new signature.

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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 69316f4 and 266b11a.
Files ignored due to path filters (7)
  • contrib/git-changes-action/go.mod is excluded by: !**/*.mod
  • contrib/git-changes-action/go.sum is excluded by: !**/*.sum
  • core/go.mod is excluded by: !**/*.mod
  • core/go.sum is excluded by: !**/*.sum
  • go.work.sum is excluded by: !**/*.sum
  • tools/go.mod is excluded by: !**/*.mod
  • tools/go.sum is excluded by: !**/*.sum
Files selected for processing (1)
  • ethergo/submitter/db/txdb/store.go (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • ethergo/submitter/db/txdb/store.go

@trajan0x
Copy link
Contributor Author

image

appears to be the issue right now, if I had to guess, this has something to do w/ tx receipt returned by simulated backend.

@trajan0x trajan0x merged commit 4c40345 into master Jan 14, 2024
70 checks passed
@trajan0x trajan0x deleted the fix/upgrade-go branch January 14, 2024 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
go Pull requests that update Go code size/m
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant