-
Notifications
You must be signed in to change notification settings - Fork 5k
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
Invalid gas check #4557
Comments
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. If you believe this was a mistake, please comment. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. If you believe this was a mistake, please comment. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. If you believe this was a mistake, please comment. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. If you believe this was a mistake, please comment. |
Hey there, apologies it's taken us so long to take a look at this, we've been working on a rewrite of the library ( I'm not 100% sure how to handle this issue since the team has decided to only make necessary changes and security patches to The following check: (!gasProvided || gasProvided !== receipt.gasUsed) is part of a series of checks that get executed when a transaction receipt is received from the confirmation polling Web3 does after sending a transaction. (!gasProvided || gasProvided !== utils.toHex(receipt.gasUsed)) However, this seems to be a naive approach as #3175 points out that @gabmontes Suggested updating the check to: (!gasProvided || gasProvided !== utils.numberToHex(receipt.gasUsed) || !isContractCall || (isContractCall && receipt.events)) but this doesn't address the "perfect gas" issue either Keeping what @nivida mentioned in mind here:
I think the following refactor is a bit better: if (!receipt.outOfGas &&
(
(receipt.status === true || receipt.status === '0x1') ||
(
(receipt.status === null || typeof receipt.status === 'undefined') &&
(!gasProvided || gasProvided !== utils.toHex(receipt.gasUsed))
)
)
) {} but it still doesn't cover pre-Byzantimum transactions that have "perfect gas". We could add the additional checks @gabmontes mentioned for Contract calls and events: So, the decision to be made: Do we update the the checks how I've proposed (and hope we don't miss an edge case), does someone have a better idea (or see holes in my proposed logic), or do we keep the code as is since it doesn't seem to be affecting other users and @gabmontes seems to have a workaround in place for his use? |
Hello @gabmontes, I wanted to let you know that we will not be including this in 1.x, but will investigate further and look to implement in 4.x. |
In |
Is there an existing issue for this?
Current Behavior
As discussed eons ago in #2381, the gas check done in core-methods is still incorrect. See:
https://github.com/ChainSafe/web3.js/blob/a1c7d71973ec17f9287fbea8939e64a80e589fc6/packages/web3-core-method/src/index.js#L423
While
gasProvided
is an hex string,receipt.gasUsed
is a number so the check will always fail.The check was fixed in #3123 but later reverted in c3bfcac.
Expected Behavior
The comparison to be done apples-to-apples :)
Steps to Reproduce
The easiest is to just send a transaction, break with the debugger at the mentioned line and check the types.
Web3.js Version
1.5.3
Environment
Anything Else?
Wondering if there is any difference between Geth and other implementations, service providers, etc.
The text was updated successfully, but these errors were encountered: