Skip to content

Conversation

@nagarev
Copy link
Contributor

@nagarev nagarev commented Nov 6, 2025

Description

Motivation and Context

How Has This Been Tested?

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • Tests for the changes have been added (for bug fixes / features)
  • Requires Activation Code (Hard Fork)
  • Other information:

@github-actions
Copy link

github-actions bot commented Nov 6, 2025

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@nagarev nagarev force-pushed the nagarev/state-override-move-precompiled branch 2 times, most recently from b503b83 to 161ecdb Compare November 14, 2025 03:38
@nagarev nagarev marked this pull request as ready for review November 14, 2025 13:36
Copy link
Collaborator

@fmacleal fmacleal left a comment

Choose a reason for hiding this comment

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

Very good job! I liked the refactor, the tests and the way you implemented the logic.

I have a few comments, but nothing big. Well done. 🙂

Block block = result.getBlock();

MutableRepository mutableRepository = prepareRepository(result, block, shouldPerformStateOverride, accountOverrideList);
OverrideablePrecompiledContracts overrideablePrecompiledContracts = new OverrideablePrecompiledContracts(precompiledContracts);
Copy link
Collaborator

Choose a reason for hiding this comment

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

suggestion:

Since this is always the same, because the list of PrecompiledContracts doesn't change, maybe we could initialize this object just once in the constructor when the EthModule is initialized. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Really good catch!

@fmacleal fmacleal force-pushed the nagarev/state-override-move-precompiled branch from 79d18ef to 57eaac0 Compare November 18, 2025 18:06
@nagarev nagarev force-pushed the nagarev/state-override-move-precompiled branch 2 times, most recently from eda076b to 0f47d4c Compare November 24, 2025 19:44
@fmacleal fmacleal requested a review from Copilot November 26, 2025 13:39
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds support for moving precompiled contracts to different addresses using state override functionality. The key feature allows callers to temporarily relocate precompiled contracts (like the Identity/datacopy precompile) to alternative addresses during eth_call operations for testing and simulation purposes.

Key Changes:

  • Introduced OverrideablePrecompiledContracts wrapper to manage temporary precompile relocations
  • Extended AccountOverride to support movePrecompileToAddress parameter
  • Updated state override application logic to handle precompile movement
  • Added restrictions preventing movement of critical precompiles (Bridge, REMASC)

Reviewed changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
OverrideablePrecompiledContracts.java New class that wraps PrecompiledContracts and manages address overrides for precompiled contracts
AccountOverride.java Added movePrecompileToAddress field and validation logic to prevent moving critical contracts
DefaultStateOverrideApplier.java Updated to handle precompile movement and track state override operations
EthModule.java Modified to use OverrideablePrecompiledContracts and pass through override context
ReversibleTransactionExecutor.java Extended to accept and propagate precompiled contracts parameter
TransactionExecutorFactory.java Added overloads to support optional PrecompiledContracts parameter
Test files Updated test instantiations to use OverrideablePrecompiledContracts wrapper
DSL test file New test scenario validating precompile movement functionality

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 188 to 191
private boolean isMovableContract(RskAddress contractAddress) {
byte[] addressBytes = contractAddress.getBytes();
return !Arrays.equals(BRIDGE_ADDR.getBytes(), addressBytes) && !Arrays.equals(REMASC_ADDR.getBytes(), addressBytes);
}
Copy link

Copilot AI Nov 26, 2025

Choose a reason for hiding this comment

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

The method calls getBytes() on BRIDGE_ADDR and REMASC_ADDR constants for every invocation. Consider caching these byte arrays as static final fields to avoid repeated array allocations.

Copilot uses AI. Check for mistakes.

@Test
void testCall_whenCalledWithAccountOverrideOverPrecompileContractAddress_throwsExceptionAsExpected() {
void testCall_whenCalledWithAccountOverrideOverPrecompileContractAddressAndStateIsOverridden_throwsExceptionAsExpected() {
Copy link

Copilot AI Nov 26, 2025

Choose a reason for hiding this comment

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

[nitpick] The test method name is very long (113 characters). Consider a more concise name like testCall_accountOverrideOnPrecompileWithState_throwsException to improve readability.

Suggested change
void testCall_whenCalledWithAccountOverrideOverPrecompileContractAddressAndStateIsOverridden_throwsExceptionAsExpected() {
void testCall_accountOverrideOnPrecompileWithState_throwsException() {

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

@fmacleal fmacleal left a comment

Choose a reason for hiding this comment

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

Good job!

Although, I still have some comments on regards of where you added the verification for the movable precompiled contracts.

I would it to the StateOverride classes, like DefaultStateOverrideApplier or OverrideablePrecompiledContract. They should hold the business logic. I see the AccountOverride more like a DTO object that shouldn't hold these kinds of logic.

@nagarev nagarev force-pushed the nagarev/state-override-move-precompiled branch from 3a3f0f6 to 7dab9b6 Compare November 28, 2025 13:52
fmacleal
fmacleal previously approved these changes Nov 28, 2025
Copy link
Collaborator

@fmacleal fmacleal left a comment

Choose a reason for hiding this comment

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

Thanks for having addressed the last issues Naza,

Good job!

@nagarev nagarev force-pushed the nagarev/state-override-move-precompiled branch from 7d10218 to fff34f0 Compare November 28, 2025 16:08
@sonarqubecloud
Copy link

Copy link
Collaborator

@fmacleal fmacleal left a comment

Choose a reason for hiding this comment

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

Good job, thanks for the latest changes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants