#How to check what limit is exceeded when getting ExceededLimit error on Futurenet?

49 messages · Page 1 of 1 (latest)

ancient aspen
#

After reworking my contract for Preview 10 and deploying it I am getting HostError: Error(Budget, ExceededLimit) for one function on the Futurenet.
Local tests do not generate this error. Preview 9 was working fine with my function and I see no limit reduced, CPU limit was even raised.

How can I find out what limit I am hitting?

median flax
#

CPU limit was raised in response to re-calibrating the metering, so it's possible that you don't fit now

#

local tests don't generate this error because they don't enforce budget limits (probably they could, but that's not going to ever be perfect as you e.g. might run your tests with compiled contracts etc.)

#

also (most importantly) CPU budget (instructions) has to be specified in tx

#

so if you say your tx uses 1000 instructions, but it in fact uses 1001 instructions, then your tx will fail with 'budget exceeded error'

#

since there is no tx in tests there is really no way to alert about that earlier

ancient aspen
#

Thank you!
Is there any way to see number of ledger read-writes in tests?

median flax
#

kind of, you can call host.try_finish() to get the storage from it and then take a look at storage.footprint. every RW entry in the fooprint will be considered a ledger write

#

however, the setup changes you do will also end up there (like uploading wasm or creating a contract instance), so these numbers won't be very precise. the end result really depends on your transaction, so you probably should be looking at the preflight results

ancient aspen
#

Is preflight=simulateTransaction?
This ExceedBudget error I get from simulateTransaction and no additional info.

median flax
#

yeah, sorry, that's the official term for that

#

huh, that's weird

#

if you get it from simulateTransaction, then it means that there is some limit on their side and I'm not even sure if there is any... let me ask around...

median flax
#

if you have some unit tests, you can check the budget (IIRC it's env.budget())

spare slate
#

For cpu and mem limits, local tests will still enforce them against some default limits (40M cpu and 50M memory). So if your local tests pass those limits, they should likely pass the (higher) network limits too.

median flax
#

that's not necessarily true. if you don't deploy contracts as wasm, then you will get much smaller numbers

spare slate
#

Correct, assuming local tests in wasm, not native mode.

ancient aspen
#

Thanks guys, I will try to implement wasm local test and look into budget and RW entries.

median flax
#

FWIW the error you've got may only mean either running out of instructions, or running out of memory

ancient aspen
#

Please help me interpret the env.budget().print() results. Is 24M cpu really critical?
I have imported the contract wasm for this test and used env.budget().reset_default() right before the function in question.

=======================================================
Cpu limit: 40000000; used: 24204179
Mem limit: 52428800; used: 1695674
=======================================================
CostType                 cpu_insns      mem_bytes
WasmInsnExec             1585493        0
WasmMemAlloc             0              0
HostMemAlloc             2867000        148697
HostMemCpy               26220          0
HostMemCmp               106351         0
InvokeHostFunction       283968         0
VisitObject              32243          0
ValXdrConv               148472         0
ValSer                   11924          732
ValDeser                 0              0
ComputeSha256Hash        7797           40
ComputeEd25519PubKey     0              0
MapEntry                 92750          0
VecEntry                 4580           0
GuardFrame               16200          1888
VerifyEd25519Sig         0              0
VmMemRead                0              0
VmMemWrite               1612           0
VmInstantiation          17854563       1543831
VmCachedInstantiation    0              0
InvokeVmFunction         5926           486
ChargeBudget             1159080        0
ComputeKeccak256Hash     0              0
ComputeEcdsaSecp256k1Key 0              0
ComputeEcdsaSecp256k1Sig 0              0
RecoverEcdsaSecp256k1Key 0              0
Int256AddSub             0              0
Int256Mul                0              0
Int256Div                0              0
Int256Pow                0              0
Int256Shift              0              0
=======================================================
ancient aspen
#

After importing tokens as wasm it is much closer to the limit:

=======================================================
Cpu limit: 40000000; used: 38106611
Mem limit: 52428800; used: 3060467
=======================================================
CostType                 cpu_insns      mem_bytes      
WasmInsnExec             1901977        0
WasmMemAlloc             0              0
HostMemAlloc             2493350        163139
HostMemCpy               24288          0
HostMemCmp               135378         0
InvokeHostFunction       335008         0
VisitObject              30780          0
ValXdrConv               136412         0
ValSer                   11924          732
ValDeser                 0              0
ComputeSha256Hash        7797           40
ComputeEd25519PubKey     0              0
MapEntry                 98315          0
VecEntry                 4570           0
GuardFrame               16200          1888
VerifyEd25519Sig         0              0
VmMemRead                0              0
VmMemWrite               1736           0
VmInstantiation          31698792       2892724        
VmCachedInstantiation    0              0
InvokeVmFunction         23704          1944
ChargeBudget             1186380        0
ComputeKeccak256Hash     0              0
ComputeEcdsaSecp256k1Key 0              0
ComputeEcdsaSecp256k1Sig 0              0
RecoverEcdsaSecp256k1Key 0              0
Int256AddSub             0              0
Int256Mul                0              0
Int256Div                0              0
Int256Pow                0              0
Int256Shift              0              0
=======================================================
median flax
#

FWIW futurenet limit is 100M, so seems well below that...

#

but this doesn't really matter: the error you're getting happens at runtime. if you tried to submit a transaction that declares that it uses 101M instructions, we would reject it immediately. but since your contract fails at apply time, that means that it uses more instructions than you've declared in your transaction, not more instructions than network limit

#

i.e. you should compare these numbers to the numbers you have in your transaction's sorobanData

ancient aspen
median flax
#

ah, sorry, forgot about that... that's suspicious indeed

median flax
#

just double-checked that for preflight the CPU limit is 40M (definitely should be bumped to match the network limit...) given that you are pretty close, I guess you might be just reaching it currently? there might be some discrepancy in the setup/enivonment between preflight and local test and it's really just 2% more compared to your numbers

ancient aspen
#

I see, that most likely is blocking my transaction. I will try set fee manually and not use simulateTransaction, will it help to avoid preflight?

median flax
#

you'll need to build the proper transaction yourself, which might be a bit involved depending on how complex it is (you'll need to fill in the footprint and resources manually). you could maybe try optimizing the contracts a bit (e.g. run them through wasm-opt to reduce the contract size and thus vm instantiation cost)

#

there is also a CLI command for that IIRC

ancient aspen
#

Thank you! I'll try. Hope limit will be raised to 100M soon.

median flax
#

yeah, we'll try to fix this. thanks for pointing this out and sorry for all the time it took

ancient aspen
#

@median flax
Hi, is a changed preflight CPU limit on RPC in effect yet?
I am still hitting the limit after all optimizations and wonder if it could be another limit, not CPU?

median flax
#

I don't think this has been released yet...

olive ocean
#

We're running into the same.

olive ocean
#

I'm trying to understand the various numbers here. Running against a WASM the failing function gives something very similar to @ancient aspen , 38M against 40M limit.

Now futurenet has 100M but it fails and I understand that currently the preflight / simulate transaction has still 40M but may function fails at prepareTransaction - is that the same thing?

#

Ah i see in the source that it's the same thing.

tranquil turret
#

Hi, has the change been released here? @median flax

median flax
#

unfortunately we won't be able to update the preview 10 release, so the fix will only be in the next release

tranquil turret
#

@median flax when is that next release expected to launch?

median flax
#

when it's ready - but probably within a few weeks

tranquil turret
#

Hey @median flax -- wanted to follow up here to see if there is any more clarity regarding the next release?

median flax
#

I'm not sure I can share the exact date and it's definitely subject to change. it's still within few weeks (so not tomorrow, but also probably not in 2 months)

simple yacht
#

Slender running into the same for simple tx with just read from another contract. It consumes 10122617 cpu_insns in tests metering, but fails on prefligth with ExceedBudget in Futurenet

olive ocean
#

Is that fixed now?

median flax
#

yes, preflight limits are now consistent with the futurenet limits

olive ocean
#

Hooray!

#

Can we as well use errors > 9 now?

median flax
#

yes, sure