Skip to content
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

feat!: RulesHooks.CanCreateContract() accepts and returns gas #28

Merged
merged 5 commits into from
Sep 17, 2024

Conversation

ARR4N
Copy link
Collaborator

@ARR4N ARR4N commented Sep 16, 2024

Why this should be merged

Allows contract-creation allowlist hooks to consume all (or some) gas. The check is also placed equivalently to the deployer allowlist, to ensure parity with subnet-evm+coreth.

Closes #24

How this works

The hook is updated to accept gas and return gasRemaining in addition to any error. The NOOPHook simply echoes its incoming gas value.

CanCreateContract(_ *libevm.AddressContext, gas uint64, _ libevm.StateReader) (gasRemaining uint64, _ error)

The placement of the check is in keeping with the deployer allowlist, but not the IsProhibited() check. The latter is unnecessary as it checks that the 160-bit truncation of a keccak hash is not specific values1, the pre-images of which are unknown.

How this was tested

Footnotes

  1. Prohibited values are address(0) and the precompiles, which are all of the form 0x020000...00[x] where x is incrementing.

@ARR4N ARR4N marked this pull request as ready for review September 17, 2024 14:42
@ARR4N ARR4N requested review from a team, darioush, ceyonur and michaelkaplan13 and removed request for a team September 17, 2024 14:42
Copy link
Collaborator

@darioush darioush left a comment

Choose a reason for hiding this comment

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

If we drop the IsProhibited check, we can also default to consuming all gas.
But this is a nice feature so we can keep it for now

@ARR4N ARR4N merged commit 38eaaab into libevm Sep 17, 2024
3 checks passed
@ARR4N ARR4N deleted the arr4n/create-contract-allowlist-gas branch September 17, 2024 16:14
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.

CanCreateContract hook gas modification
2 participants