-
Notifications
You must be signed in to change notification settings - Fork 10
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
Local register index and state re-execution #553
Conversation
# Conflicts: # storage/pebble/ledger.go
# Conflicts: # models/receipt.go # models/transaction.go
# Conflicts: # bootstrap/bootstrap.go # go.mod # go.sum # models/receipt.go # models/transaction.go # tests/go.mod # tests/go.sum # tests/helpers.go
…o gregor/local-state/progress
Improve error handling on the local state
There was a problem hiding this 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
Outside diff range and nitpick comments (2)
services/requester/remote_client.go (1)
Line range hint
104-194
: Consider refactoring the function into smaller, focused functions.The
NewRemote
function is quite lengthy and performs multiple responsibilities, such as verifying the COA account balance, creating an emulator configuration, setting up a cache, and creating a COA resource. Consider extracting these responsibilities into separate functions for better readability and maintainability.services/requester/client_handler_test.go (1)
40-42
: Refactor repeated logger initialization into a helper function.The logger initialization code is duplicated across multiple test functions. Consider refactoring it into a helper function to reduce code duplication and enhance maintainability.
Add a helper function at the beginning of the file:
func newTestLogger(buf *bytes.Buffer) zerolog.Logger { return zerolog.New(buf).With().Timestamp().Logger() }Then, replace the logger initialization in each test function:
-var buf bytes.Buffer -logger := zerolog.New(&buf).With().Timestamp().Logger() +var buf bytes.Buffer +logger := newTestLogger(&buf)Also applies to: 62-64, 84-86, 106-108, 128-130, 150-152, 172-174, 195-197, 218-220, 241-243
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (2)
go.sum
is excluded by!**/*.sum
tests/go.sum
is excluded by!**/*.sum
Files selected for processing (5)
- go.mod (1 hunks)
- services/requester/client_handler.go (1 hunks)
- services/requester/client_handler_test.go (1 hunks)
- services/requester/remote_client.go (25 hunks)
- tests/go.mod (2 hunks)
Files skipped from review as they are similar to previous changes (3)
- go.mod
- services/requester/client_handler.go
- tests/go.mod
Additional comments not posted (14)
services/requester/remote_client.go (14)
Line range hint
85-102
: LGTM!The
RemoteClient
struct is well-defined with appropriate fields for its functionality.
Line range hint
196-253
: LGTM!The
SendRawTransaction
function performs appropriate validations on the EVM transaction, handles errors, and correctly builds and sends the Flow transaction.
Line range hint
255-303
: LGTM!The
buildTransaction
function correctly creates a Flow transaction with the provided script and arguments, sets the necessary transaction fields, and signs it with the configured COA account. The use of concurrency to retrieve the latest block and signer network information is a good optimization.
Line range hint
305-345
: LGTM!The
GetBalance
function correctly retrieves the balance of an EVM address at a specific EVM height by executing a Cadence script. It performs the necessary type conversions and handles errors appropriately.
Line range hint
347-394
: LGTM!The
GetNonce
function correctly retrieves the nonce of an EVM address at a specific EVM height by executing a Cadence script. It performs the necessary type conversions and handles errors appropriately.
Line range hint
396-421
: LGTM!The
stateAt
function correctly retrieves the EVM state at a specific EVM height by creating a remote ledger and a new state database. It performs the necessary height conversion and handles errors appropriately.
Line range hint
423-431
: LGTM!The
GetStorageAt
function correctly retrieves the storage value of an EVM address at a specific EVM height and storage hash. It uses thestateAt
function to retrieve the state database and handles errors appropriately.
Line range hint
433-482
: LGTM!The
Call
function correctly executes an EVM call at a specific EVM height by executing a Cadence script. It performs the necessary type conversions and handles errors appropriately.
Line range hint
484-538
: LGTM!The
EstimateGas
function correctly estimates the gas consumption of an EVM transaction at a specific EVM height by executing a Cadence script. It performs the necessary type conversions and handles errors appropriately.
Line range hint
540-588
: LGTM!The
GetCode
function correctly retrieves the code of an EVM address at a specific EVM height by executing a Cadence script. It performs the necessary type conversions and handles errors appropriately.
Line range hint
590-614
: LGTM!The
GetLatestEVMHeight
function correctly retrieves the latest EVM height by executing a Cadence script. It handles errors appropriately and returns the result as a uint64.
Line range hint
616-641
: LGTM!The
getSignerNetworkInfo
function correctly retrieves the signer account information from the network and returns the key index and sequence number of the signer. It handles errors appropriately and returns informative error messages.
Line range hint
643-661
: LGTM!The
replaceAddresses
function correctly replaces the import statements and COA address in the provided script based on the network configuration. It retrieves the system contracts for the configured Flow network ID and replaces the addresses appropriately.
663-669
: LGTM!The
evmToCadenceHeight
function correctly converts an EVM height to a Cadence height using theblocks
storage. It handles errors appropriately and returns informative error messages.
func containsLogMessage(logOutput, message string) bool { | ||
return bytes.Contains([]byte(logOutput), []byte(message)) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the unused helper function containsLogMessage
.
The function containsLogMessage
is defined but not used anywhere in the code. Removing unused code helps improve maintainability and readability.
Apply this diff to remove the unused function:
-// Helper function to check if log output contains a specific message
-func containsLogMessage(logOutput, message string) bool {
- return bytes.Contains([]byte(logOutput), []byte(message))
-}
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.
func containsLogMessage(logOutput, message string) bool { | |
return bytes.Contains([]byte(logOutput), []byte(message)) | |
} |
Improve client result compare
Make state index more robust and able to sync
Closing in favor of: #635 |
Closes: #322 #450 #451 #452
Includes PRs
#550
#546
#542
#541
#540
#537
This is a feature branch that contains work from multiple PRs to implement local register index along with the state re-execution.
It's still in draft because further testing is needed and we should also include the checksum to validate the local state after each transaction is executed, that is depending on the PR onflow/flow-go#6456 those checksum should be used to validate the state instead of the receipt checking which is currently done.
For contributor use:
master
branchFiles changed
in the Github PR explorerSummary by CodeRabbit
Release Notes
New Features
ClientHandler
for managing EVM operations, enhancing local and remote client interactions.State
field in theBootstrap
struct for state indexing management.BlockState
for robust transaction execution and state management.Bug Fixes
Documentation
Tests
handleCall
function to validate local and remote call handling.Chores
go.mod
file for improved functionality and stability.