-
Notifications
You must be signed in to change notification settings - Fork 382
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: Longer package Path Spend More Gas [investigate] #2736
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅ 📢 Thoughts on this report? Let us know! |
No decision was reached yesterday. I still think making people pay more simply because of the longer username is unfair, but I do agree that shorter paths are more readable. Maybe a good compromise would be to only count gas for the part after |
This PR is stale because it has been open 3 months with no activity. Remove stale label or comment or this will be closed in 3 months. |
I'm a bot that assists the Gno Core team in maintaining this repository. My role is to ensure that contributors understand and follow our guidelines, helping to streamline the development process. The following requirements must be fulfilled before a pull request can be merged. These requirements are defined in this configuration file. Automated Checks🟢 Maintainers must be able to edit this pull request Manual ChecksNo manual checks match this pull request. Debug
|
Description
This PR address the process of identifying and resolviong the cause of gas usage variations during deployment based on the length of package path.
Testing Process
To identify the cause, I conducted tests using txtar testscript. I used the following script, chainging only the length of the package path for check.
Even when an out of gas error occured, the only function visible in the stack trace was the
ExecSignAndBroadcast
function inmaketx.go
file. Therefore, I added additional debugging lines to trace which function were being called.Cause Identification
While running the test script, I discovered that the
NewAnteHandler
function was being called repeatedly. This function contains the following line, whereTxSizeCostPerByte
is set a default value of 10:I added a debugging line like below:
func NewAnteHandler(ak AccountKeeper, bank BankKeeperI, sigGasConsumer SignatureVerificationGasConsumer, opts AnteOptions) sdk.AnteHandler { // ... newCtx.GasMeter().ConsumeGas(params.TxSizeCostPerByte*store.Gas(len(newCtx.TxBytes())), "txSize") + println("xxxxxxxx ante gas consumed", newCtx.GasMeter().GasConsumed()) // ... }
Output
I executed the script while chainging the pacakge path to make have different lengths and confirmed that the gas amount changed according to the length of
TxBytes()
as follows:Case 1: Package path length 22 (gno.land/p/demo/foo/aa)
TxSizeCosePerByte
NewAnteHandler
callCase 2: Package path length 23 (gno.land/p/demo/foo/aaa)
TxSizeCosePerByte
NewAnteHandler
callWe can observe that as the length of the package path increases, so does the gas usage. However, since gas usage is calculated based on the length of the transaction data obtained through the
TxBytes
method, we can hypothesize that it is also affected by the length of the contract content, not only the package path.[TODO]
Related Issue
#2083
Contributors' checklist...
BREAKING CHANGE: xxx
message was included in the description