Use a better error code and error when creation of a postage batch fails
Context
Using bee 1.18.2 on docker image, running in trace mode.
Summary
I've deployed a new node some days ago. I was able to purchase a first postage when created, but today with a second attempt it gives me error with 500 error:
create batch: depth 20 bucketDepth 16 immutable false: Invalid: VM execution error.
The node is funded but isn't staking. It emit a first "approve" transaction, but after it the 500 error is returned. Attaching logs:
Expected behavior
The batch should be created.
Actual behavior
A 500 error is returned and batch is not created.
I see your depth is 20, but you don't mention what amount you are using. I suspect that the amount needs to be increases such that the stamp will have an initial TTL greater than 24 hours at the current storage price as required by the contract.
https://github.com/ethersphere/storage-incentives/blob/4fdb26e135f7391379ca84100b723f34a1a4175e/src/PostageStamp.sol#L210
// blocks in 24 hours ~ 24 * 60 * 60 / 5 = 17280
uint64 public minimumValidityBlocks = 17280;
function minimumInitialBalancePerChunk() public view returns (uint256) {
return minimumValidityBlocks * lastPrice;
}
if (_initialBalancePerChunk < minimumInitialBalancePerChunk()) {
revert InsufficientBalance();
}
@ldeffenb thanks! That a minimum of 24h was required is a news for me, but it was the issue. I was testing with small amounts, and I encountered it. Anyway, at this point, bee client should return a more specific error instead of 500
Glad it worked! And I concur that there's a lot of places that the API seems to return generic error messages when additional (possibly internal) details would make the problem much more clear.
We already have an unwrapper that should have outputted the error from the smart contract.
"time"="2024-06-12 20:00:26.217651" "level"="debug" "logger"="node/api/post_stamp" "msg"="create batch: create failed" "error"="create batch: depth 20 bucketDepth 16 immutable true: intrinsic gas too low: gas 0, minimum needed 22492: execution reverted: InsufficientBalance()"
VM execution error. is some other generic evm error.
@acha-bill after the proposed solution, obviously I didn't get the same error again. So, if you think this is solved, you can close.