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

CBOR decode error when view/pure function reverts #169

Closed mirayashi closed 9 months ago

mirayashi commented 1 year ago
SUMMARY

Calling a pure/view function via a Sapphire-wrapped ethers instance throws a CBOR decode error instead of the actual reason when the call reverts

ISSUE TYPE
STEPS TO REPRODUCE
ACTUAL RESULTS
Error: CBOR decode error: too many terminals, data makes no sense
    at Module.decode (file:///home/mirayashi/dev/rpc3/node_modules/cborg/esm/lib/decode.js:131:11)
    at X25519DeoxysII.<anonymous> (file:///home/mirayashi/dev/rpc3/node_modules/@oasisprotocol/sapphire-paratime/src/cipher.ts:117:41)
    at Generator.next (<anonymous>)
    at file:///home/mirayashi/dev/rpc3/node_modules/@oasisprotocol/sapphire-paratime/lib/esm/cipher.js:7:71
    at new Promise (<anonymous>)
    at __awaiter (file:///home/mirayashi/dev/rpc3/node_modules/@oasisprotocol/sapphire-paratime/lib/esm/cipher.js:3:12)
    at X25519DeoxysII.decryptEncoded (file:///home/mirayashi/dev/rpc3/node_modules/@oasisprotocol/sapphire-paratime/lib/esm/cipher.js:83:16)
    at file:///home/mirayashi/dev/rpc3/node_modules/@oasisprotocol/sapphire-paratime/src/cipher.ts:274:64
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
EXPECTED RESULTS

I'm expecting to get a more informative error from ethers like

Error: call revert exception; VM Exception while processing transaction: reverted with reason xxx
VERSIONS

@oasisprotocol/sapphire-paratime@1.1.1 ethers@5.7.2

CedarMist commented 9 months ago

This is fixed with Ethers v6, unfortunately there isn't a safe way to work around this behavior with Ethers v5 without type confusion.