Skip to content

revive: Precompiles should return dummy code when queried #9001

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

Merged
merged 13 commits into from
Jun 30, 2025
Merged

Conversation

athei
Copy link
Member

@athei athei commented Jun 26, 2025

Fixes paritytech/contract-issues#111

This fixes both the RPC and the opcodes EXTCODESIZE and EXTCODEHASH.

Also removed the disabled host function is_contract. Contracts do use EXTCODESIZE to determine if something is a contract exclusively.

Need to add some differential tests to our test suite to make sure that the RPC matches geth behaviour:

On kitchensink:

# primitive precompiles should not return error but 0x
$ cast code 0x0000000000000000000000000000000000000001
0x

# this is the erc pre-compile
$ cast code 0x0000000000000000000000000000000000010000
0x60006000fd

@athei athei requested a review from pgherveou June 26, 2025 15:06
@athei athei added the A4-backport-stable2506 Pull request must be backported to the stable2506 release branch label Jun 26, 2025
@pgherveou
Copy link
Contributor

Why would This

cast code 0x0000000000000000000000000000000000010000
0x60006000fd

return something different than the 0x1 - 0x9 precompiles

Are there example of precompiles on ethereum that returns something else than 0x

@athei
Copy link
Member Author

athei commented Jun 26, 2025

Why would This

cast code 0x0000000000000000000000000000000000010000 0x60006000fd

return something different than the 0x1 - 0x9 precompiles

Because we access those pre-compiles via a Solidity interface. As opposed via YUL assembly as we do for 0x1-0x9 pre-compiles. And Solidity does emit checks if a contract exists via EXTCODESIZE before calling it into it. Depending on version and function return type. So without this change Solidity will not be able to call them.

Are there example of precompiles on ethereum that returns something else than 0x

Not on main net. Because those are all accessed via assembly circumventing Solidity.

@athei
Copy link
Member Author

athei commented Jun 26, 2025

/cmd prdoc --audience runtime_dev

@athei athei added T7-smart_contracts This PR/Issue is related to smart contracts. and removed A4-backport-stable2506 Pull request must be backported to the stable2506 release branch labels Jun 26, 2025
@pgherveou
Copy link
Contributor

added tests paritytech/evm-test-suite#100

@athei athei requested review from a team as code owners June 27, 2025 13:03
@athei
Copy link
Member Author

athei commented Jun 28, 2025

Test suite seems to fail due to this bug: paritytech/revive#344

But there is no released version with the fix, yet. @xermicus

@xermicus
Copy link
Member

I'll try to cut a release with the fix right now.

@xermicus
Copy link
Member

@athei athei enabled auto-merge June 29, 2025 22:44
@athei athei disabled auto-merge June 29, 2025 22:45
@athei athei added this pull request to the merge queue Jun 30, 2025
Merged via the queue into master with commit 3515d4a Jun 30, 2025
239 of 241 checks passed
@athei athei deleted the at/precompaddr branch June 30, 2025 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T7-smart_contracts This PR/Issue is related to smart contracts.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Precompiles size should not be zero
3 participants