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

fix: CREATE-time PUSHn adds non-existent entries to witness #361

Merged

Conversation

gballet
Copy link
Owner

@gballet gballet commented Feb 5, 2024

PUSHn was calling touchCodeChunksRangeOnReadAndChargeGas whether it was in contract deployment mode or not, in order to make sure that any pushdata overflowing into the next chunks are also added to the witness.

The issue is that in the case of a contract deployment, the address that is used is that of the contract that is yet to be created. If, for whatever reason, the deployment code ends up being larger than the contract payload that is written to the state, more chunks will be added to the witness than needs to be. This also means that deployment code is more likely to run out of gas.

This fix simply checks that we are not in deployment mode before charging this cost.

@gballet gballet marked this pull request as ready for review February 5, 2024 16:53
@gballet gballet requested a review from jsign February 5, 2024 16:54
@@ -484,7 +484,7 @@ func TestProcessVerkle(t *testing.T) {
txCost1 := params.TxGas
txCost2 := params.TxGas
contractCreationCost := intrinsicContractCreationGas + uint64(7700 /* creation */ +2939 /* execution costs */)
codeWithExtCodeCopyGas := intrinsicCodeWithExtCodeCopyGas + uint64(7000 /* creation */ +315944 /* execution costs */)
codeWithExtCodeCopyGas := intrinsicCodeWithExtCodeCopyGas + uint64(7000 /* creation */ +299744 /* execution costs */)
Copy link
Owner Author

Choose a reason for hiding this comment

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

so I realized that I never worked out the actual cost breakdown, and this should be done. It's added to my GTD list for later 😁

@gballet gballet merged commit 7d866f0 into kaustinen-with-shapella Feb 5, 2024
2 of 3 checks passed
gballet added a commit that referenced this pull request May 7, 2024
* fix: CREATE-time PUSHn adds non-existent entries to witness

* this also affects CODECOPY

* fix: add code returned by CREATE* to the witness

* fix gas costs
gballet added a commit that referenced this pull request May 8, 2024
* fix: CREATE-time PUSHn adds non-existent entries to witness

* this also affects CODECOPY

* fix: add code returned by CREATE* to the witness

* fix gas costs
gballet added a commit that referenced this pull request May 8, 2024
* fix: CREATE-time PUSHn adds non-existent entries to witness

* this also affects CODECOPY

* fix: add code returned by CREATE* to the witness

* fix gas costs
gballet added a commit that referenced this pull request May 8, 2024
* fix: CREATE-time PUSHn adds non-existent entries to witness

* this also affects CODECOPY

* fix: add code returned by CREATE* to the witness

* fix gas costs
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.

None yet

2 participants