Skip to content

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, ceyonur, darioush and michaelkaplan13 and removed request for a team September 17, 2024 14:42
Copy link

@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