I'm trying to move storage of my contract into Storage contract with this code
contract Storage {
struct Block {
address landlord;
uint sellPrice;
}
Block[101][101] public blocks;
function setBlockOwner(uint8 _x, uint8 _y, address _newOwner) external {
blocks[_x][_y].landlord = _newOwner;
}
function getBlockOwner(uint8 _x, uint8 _y) external view returns (address) {
return blocks[_x][_y].landlord;
}
}
contract MyContract {
struct Block {
address landlord;
uint sellPrice;
}
Block[101][101] public blocks;
Storage strg;
function setStorage(address addr) public { strg = Storage(addr); }
function setNewBlockOwner(uint8 _x, uint8 _y, address _newOwner) public returns (bool) { //TODO make private
//strg.setBlockOwner(_x, _y, _newOwner); //throws with "revert"
blocks[_x][_y].landlord = _newOwner; //throws with "out of gas"
return true;
}
// calling this function with (1, 1, 20, 20, some_addr)
function setBlockOwnerForArea(uint8 fromX, uint8 fromY, uint8 toX, uint8 toY, address _newOwner) {
for (uint8 ix=fromX; ix<=toX; ix++) {
for (uint8 iy=fromY; iy<=toY; iy++) {
setNewBlockOwner(ix, iy, _newOwner);
}
}
}
}
When I'm testing setBlockOwnerForArea with explicitly large values (like 1, 1, 20, 20, some_addr) calling setNewBlockOwner 400 or more times I'm expecting to get "Out of gas" exception.
Instead I get "out of gas" only when storing locally, and "revert" when using Storage contract.
Is it how it should work? Could my Truffle setup interfere somehow?
...setBlockOwnerForArea works with lower values perfectly in both cases...