Alternative/fixed implementation for retrieveStateByHash