refactor cache cleanup logic in UpdateContextForReplacedHeader - #7825
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors UpdateContextForReplacedHeader to avoid unnecessary (and potentially harmful) cache cleanup when the current execution result matches the execution result that will be set, and updates unit tests accordingly.
Changes:
- Make cache cleanup conditional on the current execution result being non-nil and having a different header hash than the target execution result.
- Adjust an existing test to ensure cache cleanup is exercised by using a different current execution result hash.
- Add a new test verifying cache cleanup is skipped when current and target execution results share the same header hash.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
process/common.go |
Adds a guard to only clean caches when replacing with a different execution result (by header hash). |
process/common_test.go |
Updates/extends tests to cover both “cleanup called” and “cleanup skipped” scenarios. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "github.com/multiversx/mx-chain-go/storage" | ||
|
|
||
| "github.com/multiversx/mx-chain-go/common" | ||
| "github.com/multiversx/mx-chain-go/dataRetriever" | ||
| "github.com/multiversx/mx-chain-go/state" |
There was a problem hiding this comment.
Import grouping: github.com/multiversx/mx-chain-go/storage is split into its own import block, while other files keep all mx-chain-go/... imports together (e.g. process/interface.go). Consider grouping storage with the other mx-chain-go imports to match the repository convention and avoid goimports/gofmt churn.
| "github.com/multiversx/mx-chain-go/storage" | |
| "github.com/multiversx/mx-chain-go/common" | |
| "github.com/multiversx/mx-chain-go/dataRetriever" | |
| "github.com/multiversx/mx-chain-go/state" | |
| "github.com/multiversx/mx-chain-go/common" | |
| "github.com/multiversx/mx-chain-go/dataRetriever" | |
| "github.com/multiversx/mx-chain-go/state" | |
| "github.com/multiversx/mx-chain-go/storage" |
Reasoning behind the pull request
Proposed changes
Testing procedure
Pre-requisites
Based on the Contributing Guidelines the PR author and the reviewers must check the following requirements are met:
featbranch created?featbranch merging, do all satellite projects have a proper tag insidego.mod?