-
Notifications
You must be signed in to change notification settings - Fork 268
Adding move precompiled support #3385
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
base: master
Are you sure you want to change the base?
Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
b503b83 to
161ecdb
Compare
fmacleal
left a comment
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.
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); |
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.
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?
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.
Really good catch!
rskj-core/src/main/java/org/ethereum/vm/OverrideablePrecompiledContracts.java
Show resolved
Hide resolved
rskj-core/src/test/java/co/rsk/rpc/modules/eth/DefaultStateOverrideApplierTest.java
Outdated
Show resolved
Hide resolved
rskj-core/src/test/java/co/rsk/rpc/modules/eth/DefaultStateOverrideApplierTest.java
Outdated
Show resolved
Hide resolved
rskj-core/src/test/java/co/rsk/rpc/modules/eth/DefaultStateOverrideApplierTest.java
Show resolved
Hide resolved
rskj-core/src/test/java/co/rsk/rpc/modules/eth/EthModuleTest.java
Outdated
Show resolved
Hide resolved
79d18ef to
57eaac0
Compare
eda076b to
0f47d4c
Compare
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.
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
OverrideablePrecompiledContractswrapper to manage temporary precompile relocations - Extended
AccountOverrideto supportmovePrecompileToAddressparameter - 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.
rskj-core/src/test/resources/dsl/eth_module/test_state_override_move_precompiled.txt
Outdated
Show resolved
Hide resolved
| private boolean isMovableContract(RskAddress contractAddress) { | ||
| byte[] addressBytes = contractAddress.getBytes(); | ||
| return !Arrays.equals(BRIDGE_ADDR.getBytes(), addressBytes) && !Arrays.equals(REMASC_ADDR.getBytes(), addressBytes); | ||
| } |
Copilot
AI
Nov 26, 2025
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.
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.
rskj-core/src/main/java/org/ethereum/vm/OverrideablePrecompiledContracts.java
Show resolved
Hide resolved
rskj-core/src/main/java/co/rsk/rpc/modules/eth/DefaultStateOverrideApplier.java
Outdated
Show resolved
Hide resolved
|
|
||
| @Test | ||
| void testCall_whenCalledWithAccountOverrideOverPrecompileContractAddress_throwsExceptionAsExpected() { | ||
| void testCall_whenCalledWithAccountOverrideOverPrecompileContractAddressAndStateIsOverridden_throwsExceptionAsExpected() { |
Copilot
AI
Nov 26, 2025
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.
[nitpick] The test method name is very long (113 characters). Consider a more concise name like testCall_accountOverrideOnPrecompileWithState_throwsException to improve readability.
| void testCall_whenCalledWithAccountOverrideOverPrecompileContractAddressAndStateIsOverridden_throwsExceptionAsExpected() { | |
| void testCall_accountOverrideOnPrecompileWithState_throwsException() { |
fmacleal
left a comment
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.
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.
rskj-core/src/main/java/co/rsk/rpc/modules/eth/AccountOverride.java
Outdated
Show resolved
Hide resolved
rskj-core/src/main/java/co/rsk/rpc/modules/eth/AccountOverride.java
Outdated
Show resolved
Hide resolved
rskj-core/src/main/java/org/ethereum/vm/OverrideablePrecompiledContracts.java
Show resolved
Hide resolved
rskj-core/src/main/java/co/rsk/rpc/modules/eth/DefaultStateOverrideApplier.java
Fixed
Show fixed
Hide fixed
3a3f0f6 to
7dab9b6
Compare
fmacleal
left a comment
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.
Thanks for having addressed the last issues Naza,
Good job!
7d10218 to
fff34f0
Compare
|
fmacleal
left a comment
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.
Good job, thanks for the latest changes!



Description
Motivation and Context
How Has This Been Tested?
Types of changes
Checklist: