I have function which uses for loops on the calldata array as following:
mapping (address => bool) public userRegistered;
function registerUsers(address[] calldata users) external {
for (uint256 i; i < users.length; ++i) {
userRegistered[users_[i]] = true;
}
}
Context of the function doesn't matter, I just shortened the actual function to give the idea. So I know the block gas limit on ethereum is 15M, but maximum it can be 30M. I want to put a constraint on the length of the users_
array so it does not hit block gas limit ever causing so much loss of money.
I am planning to pick such a maximum length that, gas cost will be very close to the block gas limit. But my confusion is, should I arrange according to 15M or 30M limit? For instance when the network is rather empty at that point and the produced blocks are mostly consist of 15M gas limit, and I submit the tx that will require 29.9M gas, will it not be executed or will the execution will be much slower?