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: Smart contract panicked: Callback computation 0 was not successful #910

Merged
merged 1 commit into from
Oct 28, 2024

Conversation

ppca
Copy link
Contributor

@ppca ppca commented Oct 26, 2024

problem was prepaid gas for clear_state_on_finish was too low.
I doubled prepaid gas for both clear_state_on_finish and return_signature_on_finish

@ppca ppca linked an issue Oct 26, 2024 that may be closed by this pull request
@volovyks
Copy link
Collaborator

Gas consumption must be identical on all calls. If it's enough for one it should be enough for any call.
We are hitting an edge case where we consume more gas than expected, like when people submit multiple sign() call actions in one transaction.

@ppca
Copy link
Contributor Author

ppca commented Oct 28, 2024

Gas consumption must be identical on all calls. If it's enough for one it should be enough for any call. We are hitting an edge case where we consume more gas than expected, like when people submit multiple sign() call actions in one transaction.

More explanation in this issue: #870
Basically not all calls will consume the same gas. For example, sometimes clear_state_on_finish need to wait many blocks for the return value, so it can cost more gas when the waiting is longer.
And when I look into this issue, indeed it fails with callback computation 0 was not successful when clear_state_on_finish has consumed more gas than normally.
So what it means is, clear_state_on_finish needs more gas when waiting is longer.

The change I made is giving the clear_state_on_finish call more prepaid gas. This will not change the total gas we require for the sign call, it is adjusting how much goes to clear_state_on_finish. I also increased the gas prepaid for return_signature_on_finish, in order to reserve some more buffer there in case that call also consumes more gas when waiting is longer.

@ppca ppca merged commit 0afee90 into develop Oct 28, 2024
3 checks passed
@ppca ppca deleted the xiangyi/fix_gas_exceeded branch October 28, 2024 22:34
@ChaoticTempest
Copy link
Member

@ppca we should probably base it on the exact number then instead of purely doubling it everytime we hit the limit. 200 blocks is the limit it should be waiting for anyways, so we can have a definite constant here.

We should also do a check for prepaid_gas < GAS_FOR_SIGN_CALL + CLEAR_STATE_ON_FINISH_CALL_GAS + RETURN_SIGNATURE_ON_FINISH_CALL_GAS because now GAS_FOR_SIGN_CALL amount might not be enough or adjust the constant to make it enough

@ppca
Copy link
Contributor Author

ppca commented Oct 29, 2024

@ppca we should probably base it on the exact number then instead of purely doubling it everytime we hit the limit. 200 blocks is the limit it should be waiting for anyways, so we can have a definite constant here.

We should also do a check for prepaid_gas < GAS_FOR_SIGN_CALL + CLEAR_STATE_ON_FINISH_CALL_GAS + RETURN_SIGNATURE_ON_FINISH_CALL_GAS because now GAS_FOR_SIGN_CALL amount might not be enough or adjust the constant to make it enough

Yeah good idea to base it on exact number. Let's ask Saketh and we'll update the number.

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.

Smart contract panicked: Callback computation 0 was not successful
3 participants