I have a Registry contract, which holds addresses of different smart contracts. The registry has getter for every contract address it holds.
In other contract at some point I need to retrieve one of the addresses.
When I call the getter function at the beginning of function it works properly.
When I call it after two computed hashes, it just reverts without any reason provided.
There is still a lot of gas left, so not out of gas problem for sure.
Don’t know if it’s about stack overflow , because stack frames are pushed for every function call.
Update for @RickPark questions
Computated hashes is 2 times calculation of
hash = keccak256(
abi.encodePacked(
abi.encodePacked(...someParams),
abi.encodePacked(...moreParams)
)
)
Getters works like this
contract Registry is Ownable {
address core;
function setCore(address _core) external onlyOwner {
core = _core;
}
function getCore() public view returns (address) {
return core;
}
}
and called as
Core(registry.getCore()).doSomething()
My function basically gets 3 structs (experimental ABI v2) and makes those 2 hashes and few more validations. So part of some validations are exactly calling the Core, but before we need to get its address.
If I get address before hashes, it works, after hashes it reverts without any reason.
Update 2 for @RickPark questions
contract LoosingHope is LibOrder, LibSomeStruct, Ownable {
Registry internal registry;
function setRegistry(address _registry) external onlyOwner {
registry = Registry(_registry);
}
function create(Order memory _buyOrder, Order memory _sellOrder, SomeStruct memory _someStruct) public {
require(
_buyOrder.something == _sellOrder.something &&
_sellOrder.something == 0,
"MATCH:NOT_CREATION"
);
// Validate taker if set
validateTakerAddress(_buyOrder, _sellOrder);
validateTakerAddress(_sellOrder, _buyOrder);
// Validate sender if set
validateSenderAddress(_buyOrder);
validateSenderAddress(_sellOrder);
// Validate expiration if set
validateExpiration(_buyOrder);
validateExpiration(_sellOrder);
// Validate if was canceled
// orderHashes[0] - buyOrderHash
// orderHashes[1] - sellOrderHash
bytes32[2] orderHashes;
orderHashes[0] = hashOrder(_buyOrder);
validateCanceled(orderHashes[0]);
// registry.getCore(); <------------ doesn't reverts here
orderHashes[1] = hashOrder(_sellOrder);
registry.getCore(); <------------ reverts here
validateCanceled(orderHashes[1]);
}
}
Update 3 for @RickPark questions
Registry is simple Ownable contract with setter and getter of Core address. Setting the address is following by onlyOwner modifier, getting is public for anyone. It's initialised by me as well, I use it as Registry for addresses, so contracts are able to communicate with each other.
Update 4 for @RickPark questions
Environment
- OS: MacOs
- Solc: v0.4.24
Networks: all of them fail
- Truffle JSONRPC
- Ganache - all latest versions
- Rinkeby
- Kovan