Upgrade Contract on oasis sapphire network

Hi everyone,

I'm using openzeppelin contracts and upgrades plugins such as in the tutorial: upgrading smart-contracts .
with hardhat.

Problem

On polygon it work well. But I try to use the sapphire testnet, an EVM compatible chain developed by Oasis. It uses some technologies that allow "privates" variables to be truly privates.
The problem is that the "upgradeProxy" methode call this function (found in @openzeppelin/upgrades-core/src/eip-1967.ts):

export async function getImplementationAddress(provider: EthereumProvider, address: string): Promise<string> {
  const storage = await getStorageFallback(
    provider,
    address,
    toEip1967Hash('eip1967.proxy.implementation'),
    toFallbackEip1967Hash('org.zeppelinos.proxy.implementation'),
  );
  if (isEmptySlot(storage)) {
    throw new EIP1967ImplementationNotFound(
      `Contract at ${address} doesn't look like an ERC 1967 proxy with a logic contract address`,
    );
  }

  return parseAddressFromStorage(storage);
}

Which uses EVM transparency.

I think one way to deal with tis would be to call getProxyImplementation of ProxyAdmin in the instade of searching in the EVM.

Maybe someone has the same issue? Or an idea to fixes it without changing to much openzeppelin upgrades plugin?

:computer: Environment

My setup is the tutorial's one, I use hardhat, and add sapphire testnet in the hardhat.config.ts

sapphire_testnet: {
      chainId: 23295,
      url: "https://testnet.sapphire.oasis.dev",
      accounts: [`0x${privateKey}`]
    }

Thank for your time!

The plugins relies on being able to read the storage slots defined in ERC-1967. If the network prevents reading from those slots, the plugins won't be able to function as designed.

That's correct, on Oasis Sapphire the eth_getStorageAt RPC call can't be used as it's incompatible with contracts that want to keep their storage private (there is no way to retrieve the encrypted storage for a contract unless it provides a public method to access it).

So, getImplementationAddress would need to be modified to use a public method of the contract to retrieve the implementation address.