Skip to content
This repository has been archived by the owner on Jun 29, 2023. It is now read-only.

frontendTransfer.validate doesn't raise when revert #462

Closed
ChihChengLiang opened this issue Feb 1, 2021 · 1 comment
Closed

frontendTransfer.validate doesn't raise when revert #462

ChihChengLiang opened this issue Feb 1, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@ChihChengLiang
Copy link
Collaborator

What's wrong

The symptom

We have Frontend contracts that provide convenient methods for the client to perform state transitions or signature validation.

The validate method of the Frontend contracts for Transfer validates the signature of a Transfer transaction. It depends on verifySingle method of the BLS library, which depends on getGasCost method of the BNPairingPrecompileCostEstimator.

Before the BNPairingPrecompileCostEstimator is deployed, the frontendTransfer.validate should fail since the BLS.verifySingle is falling to get the gasCost estimate from the BNPairingPrecompileCostEstimator.getGasCost method.

But frontendTransfer.validate doesn't fail in the typescript call even that the hardhat node reported the error. The result is reproduced in https://github.com/thehubbleproject/hubble-contracts/pull/460/files#diff-65e9827d8828f65c928802491c64307f19c88f9dc8b5cdd258ed11d2d202aff4R28

eth_call
  Contract call:       FrontendTransfer#validate
  From:                0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266
  To:                  0x3155755b79aa083bd953911c92705b7aa82a18f9
  
  Error: Transaction reverted: function call to a non-contract account
      at FrontendTransfer.verifySingle (contracts/libs/BLS.sol:65)
      at FrontendTransfer.validate (contracts/client/FrontendTransfer.sol:99)
      at FrontendTransfer.validate (contracts/client/FrontendTransfer.sol:80)
      at runMicrotasks (<anonymous>)
      at processTicksAndRejections (internal/process/task_queues.js:94:5)
      at EthModule._callAction (/Users/liangcc/projects/EAPL/reddit_optimistic_rollup/contracts/node_modules/hardhat/src/internal/hardhat-network/provider/modules/eth.ts:317:9)
      at HardhatNetworkProvider._sendWithLogging (/Users/liangcc/projects/EAPL/reddit_optimistic_rollup/contracts/node_modules/hardhat/src/internal/hardhat-network/provider/provider.ts:114:22)
      at HardhatNetworkProvider.request (/Users/liangcc/projects/EAPL/reddit_optimistic_rollup/contracts/node_modules/hardhat/src/internal/hardhat-network/provider/provider.ts:98:16)
      at JsonRpcHandler._handleRequest (/Users/liangcc/projects/EAPL/reddit_optimistic_rollup/contracts/node_modules/hardhat/src/internal/hardhat-network/jsonrpc/handler.ts:187:20)
      at JsonRpcHandler._handleSingleRequest (/Users/liangcc/projects/EAPL/reddit_optimistic_rollup/contracts/node_modules/hardhat/src/internal/hardhat-network/jsonrpc/handler.ts:166:17)

Possible root cause

View functions raise no exceptions when revert. It's a bug in the jsonrpc level.

How do we fix it

Add return true at the bottom of the method seems to fix it.

@ChihChengLiang ChihChengLiang added the bug Something isn't working label Feb 1, 2021
@ChihChengLiang
Copy link
Collaborator Author

Addressed in #460

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant