Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Question about transaction cpu limit #4749

Closed
tjchern opened this issue Jul 19, 2018 · 9 comments
Closed

Question about transaction cpu limit #4749

tjchern opened this issue Jul 19, 2018 · 9 comments
Assignees
Labels

Comments

@tjchern
Copy link

tjchern commented Jul 19, 2018

I am a blockchain developer. I have a question: When a running transaction exceed the cpu or mem limit, how to halt this transaction(e.g. A smart contract having a dead loop). I have read the ref:
#353 and #717, but I still can't understand how to halt the transaction which is running and exceeded the limit.
Thx for your time.

@taokayan
Copy link
Contributor

taokayan commented Jul 19, 2018

In this case the transaction will be rolled back as nothing has happened.

@tjchern
Copy link
Author

tjchern commented Jul 19, 2018

So, when the smart contract is running, Is there a mechanism that check the cpu usage and mem usage after every op code?

@taokayan
Copy link
Contributor

Yes. cpu usage will be checked at each op, while mem usage will be checked at the end.

@tjchern
Copy link
Author

tjchern commented Jul 19, 2018

Thank you very much

@tjchern tjchern closed this as completed Jul 19, 2018
@tjchern
Copy link
Author

tjchern commented Jul 20, 2018

Sorry, I have another question, if mem usage will be checked at the end, so how to sovle the mem exceeding when running smart contract?

@tjchern tjchern reopened this Jul 20, 2018
@taokayan
Copy link
Contributor

There's a hard memory limit (around 32M) that can be allocated in the smart contract.

@tjchern
Copy link
Author

tjchern commented Jul 20, 2018

So, in smart contract, for some specific ops which will remove/update/add the mem, it will check the mem usage, but these mem don't be calced to the account mem limit(not reach the hard limit), and in the end of smart contract, the total mem usage delta between the begin of smart contract and the end of smart contract, the delta will be calced to the account mem limit, right?

@taokayan
Copy link
Contributor

taokayan commented Jul 23, 2018

This is correct. RAM usage validation is done after contract execution.

@tjchern
Copy link
Author

tjchern commented Jul 23, 2018

Thank you for your generous reply so many times!

@tjchern tjchern closed this as completed Jul 23, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants