oasisprotocol / sapphire-paratime

Oasis Sapphire - the confidential EVM-compatible ParaTime for the Oasis Network
https://oasisprotocol.org/sapphire
Apache License 2.0
37 stars 27 forks source link

.connect() doesn't change both the caller and signer #197

Open matevz opened 1 year ago

matevz commented 1 year ago

If you want to switch the signer of a wrapped object, for example:

const myContract2 = myContract.connect(await ethers.getSigner(1));

or more explicitly:

const myContract2 = await ethers.getContractAt("MyContract", myContract.address, (await ethers.getSigner(1)));

(see https://github.com/oasisprotocol/demo-quiz/blob/3c6c15038f75fc96bf706a7a0d5ecdbca3b6f46d/backend/test/Quiz.ts#L87-L89 for live example).

Then when calling a signed view call await myContract.foo();, the query fails:

 Error: missing revert data (action="call", data=null, reason=null, transaction={ "data": "0xa36464617461a264626f6479a462706b5820db9991c1c0383bef811444a78e0aca7f32a0c954cac1258b6552812e3f0008446464617461587cb50cdb41f69a75661fc483742c66ee68cf63839ae6b352f9ca405b6dcd5a6ca3a418abc4d788187b565e8ba0175fd31463b469da08b7963d413ba5761d2fb06e5dbedda8a981c1f3afa5de1050d035d44c23e92ee6303497ce146a62eef395c3c8f9b60922284fc87efe266ee2582a58a7dec4d9f05b9537d1c930146565706f63681819656e6f6e63654ff37b5557ce282341c092b719d6351966666f726d617401656c65617368a4656e6f6e6365184f6a626c6f636b5f6861736858209228a8b1d0f4d7d119cb54783a7fed5fcebfa60d686bcb0f370793030cd1bce06b626c6f636b5f72616e6765190fa06c626c6f636b5f6e756d6265721905df697369676e61747572655841abb4f3db8290484acf2ccb1a2eb0bebe847daea6c94b86866e4b96f4240e0bf5134c417d4b41c29c41a5c3f319845e44197a0b45482bc542ebb32c7d4c8fcec51c", "from": "0x70997970C51812dc3A010C7d01b50e0d17dc79C8", "to": "0xc351628EB244ec633d5f21fBD6621e1a683B1181" }, invocation=null, revert=null, code=CALL_EXCEPTION, version=6.10.0)

I tracked down the error in the web3 gateway logs and Sapphire runtime complains:

{"block_or_hash":{"blockNumber":"latest"},"caller":"revert_errors.go:103","err":"invalid signed simulate call query: signer != caller","level":"debug","method":"eth_call","module":"eth_rpc","msg":"failed to execute SimulateCall","ts":"2024-06-03T12:08:07.840799449Z"}

Tested using sapphire-localnet 2024-05-28-git37b7166 (oasis-core: 24.0-gitfb49717, sapphire-paratime: 0.7.3-testnet, oasis-web3-gateway: 5.1.0). Running it on Sapphire Testnet also fails.

lukaw3d commented 3 weeks ago

Does this test assure this has been fixed at some point?:

https://github.com/oasisprotocol/sapphire-paratime/blob/f708f3912424c84a6f03f87b9f6f928093da036a/integrations/hardhat/test/protocol.ts#L59-L67

aefhm commented 2 weeks ago

I also thought the wrapped Signer was working.

rube-de commented 1 week ago

sapphire-paratime/integrations/hardhat/test/protocol.ts

as I see, this test is only in v2. v2 doesn't have signed view calls?