Closed maxrobot closed 1 year ago
It is not being executed twice but it's because fee setting is auto by default, which calls estimate_fee
which calls Simulate
to get consumed gas for simulation. In which it does invoke wasm-vm entrypoint, thus deps.api.debug
is being called.
For block height, after some investigation, it seems to be how Simulate
and DeliverTx
behaves differently. Both calls runTx
under the hood but with different mode. Even calling Simulate
and DeliverTx
in this sequence on the same tx:
Simuate(tx) -> DeliverTx(tx) -> Simulate(tx)
We get:
h -> h + 1 -> h
Where h
is the previous block height.
Ah that's very interesting actually I will need to take a look myself.
Do you think it might be possible to silence them somehow? Reason being that when debugging contracts it's useful to print some debug messages, however it is more difficult to do so if we have duplicated outputs?
Thanks for the great response :)
I haven't yet find a clean solution to prevent this, at first I thought switching wasmOpts
on the fly might help, since the reason why deps.api.debug
works is due to this option but it's set on instantiating keeper and I haven't yet find way to replace them nicely.
Another option is to just redirect all stdout altogether in Simulate
function (example), this is kind of hacky since then all other potentially useful stdout will be gone.
We could make that an optional config to allow Simulate
stdout. What do you think @maxrobot ?
Maybe this is super stupid thought but why do we need to have Simulate for the fee setting, could we not just turn that to optional for test-tube?
Happy for this to be closed as it's not an issue from my PoV anymore :)
Description: when trying to debug my contracts I noticed that some debug messages would be printed twice.
I have even created an integration test here
Which simply instantiates a contract with a debug message:
When I execute the linked test in the
test-tube
repo as follows:As shown above Instantiate Mock Query is printed twice, further investigation printing the block info shows also that these transaction are executed at different block heights.
I am very confused why this would be happening and would be grateful for any pointers how to stop/solve this from happening.