Skip to content

Instrument CREATE and CREATE2 gas func #489

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

Open
wants to merge 1 commit into
base: instrument_call_gas_func
Choose a base branch
from

Conversation

MishkaRogachev
Copy link
Contributor

@MishkaRogachev MishkaRogachev commented Jul 17, 2025

For NIT-3482

Instrument CREATE and CREATE2 opcode with multigas calculations:

  • Base gasCreate2 func
  • gasCreateEip3860 for EIP-3860 (introduce init code size)

Note: waits #486 to be merged, temporary points on instrument_call_gas_func branch

@cla-bot cla-bot bot added the s CLA signed label Jul 17, 2025
@MishkaRogachev MishkaRogachev changed the base branch from master to cbp-feature July 18, 2025 11:18
@MishkaRogachev MishkaRogachev changed the base branch from cbp-feature to instrument_call_gas_func July 18, 2025 11:19
@@ -327,15 +327,15 @@ func gasCreate2(evm *EVM, contract *Contract, stack *Stack, mem *Memory, memoryS
if wordGas, overflow = math.SafeMul(toWordSize(wordGas), params.Keccak256WordGas); overflow {
return multigas.ZeroGas(), 0, ErrGasUintOverflow
}
// TODO(NIT-3484): Update multi dimensional gas here
if gas, overflow = math.SafeAdd(gas, wordGas); overflow {
if overflow = multiGas.SafeIncrement(multigas.ResourceKindComputation, wordGas); overflow {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

CREATE / CREATE2 are pure computation cost:

Computation: initCodeCost + memExpansionCost + params.CreateGas + hashCost,

Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be an inline comment rather than a PR conversation comment?
Like we want the reasoning to be available to folks reading the code.

@MishkaRogachev MishkaRogachev marked this pull request as ready for review July 18, 2025 13:51
@@ -327,15 +327,15 @@ func gasCreate2(evm *EVM, contract *Contract, stack *Stack, mem *Memory, memoryS
if wordGas, overflow = math.SafeMul(toWordSize(wordGas), params.Keccak256WordGas); overflow {
return multigas.ZeroGas(), 0, ErrGasUintOverflow
}
// TODO(NIT-3484): Update multi dimensional gas here
if gas, overflow = math.SafeAdd(gas, wordGas); overflow {
if overflow = multiGas.SafeIncrement(multigas.ResourceKindComputation, wordGas); overflow {
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be an inline comment rather than a PR conversation comment?
Like we want the reasoning to be available to folks reading the code.

@eljobe eljobe assigned MishkaRogachev and unassigned eljobe Jul 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
s CLA signed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants